00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef __CODEX_CLIENT_CLIENT_FUNCTIONS_H__
00030 #define __CODEX_CLIENT_CLIENT_FUNCTIONS_H__
00031
00038 #include <openssl/bn.h>
00039 #include <openssl/rsa.h>
00040
00041
00042 #ifdef __cplusplus
00043
00044 #include "Client.h"
00045
00046
00047 namespace CODEX_Client
00048 {
00055 namespace Interface
00056 {
00062 class Interface : public Client
00063 {
00064 public :
00066 static Interface* instance();
00068 static void destroy();
00069 private :
00070 Interface();
00071 virtual ~Interface() {}
00072 static Interface* m_instance;
00073 };
00074
00075 extern "C"
00076 {
00077 #endif
00078
00083 typedef struct
00084 {
00085 unsigned char* data;
00086 long length;
00087 } codex_policy_t;
00088
00093 typedef struct
00094 {
00095 unsigned char* data;
00096 long length;
00097 } codex_credentials_t;
00098
00103 typedef struct
00104 {
00105
00106 unsigned char * data;
00107 long length;
00109
00110 unsigned char * name;
00111 long namelen;
00113
00114 X509 * owner;
00115 codex_policy_t* read_policy;
00116 codex_policy_t* write_policy;
00118
00119 BIGNUM * signature;
00120 } codex_binding_t;
00121
00122
00131 void codex_zero_policy( codex_policy_t* policy );
00132
00141 void codex_zero_credentials( codex_credentials_t* credentials );
00142
00151 void codex_zero_binding( codex_binding_t* binding );
00152
00153
00157 codex_policy_t* codex_new_policy();
00158
00162 codex_credentials_t* codex_new_credentials();
00163
00167 codex_binding_t* codex_new_binding();
00168
00169
00170
00177 void codex_clear_policy( codex_policy_t* policy );
00178
00185 void codex_clear_credentials( codex_credentials_t* credentials );
00186
00193 void codex_clear_binding( codex_binding_t* binding );
00194
00195
00204 void codex_free_policy( codex_policy_t* policy );
00205
00214 void codex_free_credentials( codex_credentials_t* credentials );
00215
00224 void codex_free_binding( codex_binding_t* binding );
00225
00226
00241 int codex_parse_binding( codex_binding_t* binding );
00242
00243
00251 int codex_set_server( const char* name, int port );
00252
00259 int codex_set_service_key( const X509* cert );
00260
00268 int codex_set_key_pair( const X509* cert, const RSA* key );
00269
00279 int codex_create_policy( const RSA* policy_pub_key,
00280 const RSA* owner_priv_key,
00281 codex_policy_t* policy );
00282
00292 int codex_issue_credentials( const RSA* client_pub_key,
00293 const RSA* policy_priv_key,
00294 codex_credentials_t* credentials );
00295
00307 int codex_create_key( const unsigned char* name,
00308 int length,
00309 const X509* owner_cert,
00310 const codex_policy_t* read_policy,
00311 const codex_policy_t* write_policy,
00312 codex_binding_t* binding );
00313
00326 int codex_write_key( const unsigned char* name,
00327 int length,
00328 const BIGNUM* key_value,
00329 const codex_credentials_t* credentials,
00330 const RSA* cred_private_key,
00331 const codex_binding_t* binding );
00332
00345 int codex_read_key( const unsigned char* name,
00346 int length,
00347 const codex_credentials_t* credentials,
00348 const RSA* cred_private_key,
00349 BIGNUM** returned_key_value );
00350
00358 int codex_to_file( const char* fname );
00359
00367 int codex_from_file( const char* fname );
00368
00372 void codex_clean_up();
00373
00374 #ifdef __cplusplus
00375 }
00376 }
00377 }
00378 #endif
00379
00380 #endif