rearranging the commands into their own directory
[gssweb.git] / json_gssapi / src / commands / GSSPseudoRandom.h
1 /*
2  * Copyright (c) 2014 <copyright holder> <email>
3  *
4  * For license details, see the LICENSE file in the root of this project.
5  *
6  */
7
8 #ifndef GSSPSEUDORANDOMCOMMAND_H
9 #define GSSPSEUDORANDOMCOMMAND_H
10
11 #include <openssl/rand.h>
12 #include <gssapi/gssapi.h>
13
14 #include "datamodel/GSSBuffer.h"
15 #include "GSSCommand.h"
16
17 typedef OM_uint32 (*gss_pseudo_random_type) (
18     OM_uint32 *,        /* minor_status */
19     gss_ctx_id_t,       /* context */
20     int,                /* prf_key */
21     const gss_buffer_t, /* prf_in */
22     ssize_t,            /* desired_output_len */
23     gss_buffer_t);      /* prf_out */
24
25 class GSSPseudoRandom : public GSSCommand
26 {
27 public:
28     GSSPseudoRandom(gss_pseudo_random_type fn = &gss_pseudo_random) : function(fn) {};
29     GSSPseudoRandom(JSONObject *params, 
30                            gss_pseudo_random_type fn = &gss_pseudo_random);
31     void execute();
32     JSONObject* toJSON();
33     bool loadParameters(JSONObject *params);
34     
35     /* Setters */
36     void setContextHandle ( gss_ctx_id_t desiredContext ) { context = (desiredContext); };
37     void setKey ( int prf_in ) { key = (prf_in); };
38     void setInputMessage ( const GSSBuffer prf_in ) { inputMessage.setValue(prf_in.toString()); };
39     void setDesiredOutputLength ( int desired_output_len ) { desiredOutputLength =desired_output_len; };
40     
41     /* Getters */
42     GSSBuffer getInputMessage() { return inputMessage; }
43     GSSBuffer getOutputMessage() { return outputMessage; }
44     OM_uint32 getRetVal() { return(retVal); }
45     OM_uint32 getMinorStatus() { return(minor_status); }
46     int       getKey() { return(key); }
47     int       getDesiredOutputLength() { return(desiredOutputLength); }
48     gss_pseudo_random_type getGSSFunction() { return function; };
49     
50 private:
51     OM_uint32 retVal, minor_status;
52     gss_pseudo_random_type function;
53     gss_ctx_id_t context;
54     int key, desiredOutputLength;
55     GSSBuffer inputMessage;
56     GSSBuffer outputMessage;
57 };
58
59 #endif // GSSPSEUDORANDOMCOMMAND_H