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
00030
00031
00032 #ifndef __CODEX_CLIENT_CLIENT_FUNCTIONS_H__
00033 #define __CODEX_CLIENT_CLIENT_FUNCTIONS_H__
00034
00041 #include <openssl/bn.h>
00042 #include <openssl/rsa.h>
00043
00044
00045 #ifdef __cplusplus
00046
00047 #include "Client.h"
00048
00049
00050 namespace CODEX_Client
00051 {
00058 namespace Interface
00059 {
00065 class Interface : public Client
00066 {
00067 public :
00069 static Interface* instance();
00071 static void destroy();
00072 private :
00073 Interface();
00074 virtual ~Interface() {}
00075 static Interface* m_instance;
00076 };
00077
00078 extern "C"
00079 {
00080 #endif
00081
00086 typedef struct
00087 {
00088 unsigned char* data;
00089 long length;
00090 } codex_policy_t;
00091
00096 typedef struct
00097 {
00098 unsigned char* data;
00099 long length;
00100 } codex_credentials_t;
00101
00106 typedef struct
00107 {
00108
00109 unsigned char * data;
00110 long length;
00112
00113 unsigned char * name;
00114 long namelen;
00116
00117 X509 * owner;
00118 codex_policy_t* read_policy;
00119 codex_policy_t* write_policy;
00121
00122 BIGNUM * signature;
00123 } codex_binding_t;
00124
00125
00134 void codex_zero_policy( codex_policy_t* policy );
00135
00144 void codex_zero_credentials( codex_credentials_t* credentials );
00145
00154 void codex_zero_binding( codex_binding_t* binding );
00155
00156
00160 codex_policy_t* codex_new_policy();
00161
00165 codex_credentials_t* codex_new_credentials();
00166
00170 codex_binding_t* codex_new_binding();
00171
00172
00173
00180 void codex_clear_policy( codex_policy_t* policy );
00181
00188 void codex_clear_credentials( codex_credentials_t* credentials );
00189
00196 void codex_clear_binding( codex_binding_t* binding );
00197
00198
00207 void codex_free_policy( codex_policy_t* policy );
00208
00217 void codex_free_credentials( codex_credentials_t* credentials );
00218
00227 void codex_free_binding( codex_binding_t* binding );
00228
00229
00244 int codex_parse_binding( codex_binding_t* binding );
00245
00246
00254 int codex_set_server( const char* name, int port );
00255
00262 int codex_set_service_key( const X509* cert );
00263
00271 int codex_set_key_pair( const X509* cert, const RSA* key );
00272
00282 int codex_create_policy( const RSA* policy_pub_key,
00283 const RSA* owner_priv_key,
00284 codex_policy_t* policy );
00285
00295 int codex_issue_credentials( const RSA* client_pub_key,
00296 const RSA* policy_priv_key,
00297 codex_credentials_t* credentials );
00298
00310 int codex_create_key( const unsigned char* name,
00311 int length,
00312 const X509* owner_cert,
00313 const codex_policy_t* read_policy,
00314 const codex_policy_t* write_policy,
00315 codex_binding_t* binding );
00316
00329 int codex_write_key( const unsigned char* name,
00330 int length,
00331 const BIGNUM* key_value,
00332 const codex_credentials_t* credentials,
00333 const RSA* cred_private_key,
00334 const codex_binding_t* binding );
00335
00348 int codex_read_key( const unsigned char* name,
00349 int length,
00350 const codex_credentials_t* credentials,
00351 const RSA* cred_private_key,
00352 BIGNUM** returned_key_value );
00353
00361 int codex_to_file( const char* fname );
00362
00370 int codex_from_file( const char* fname );
00371
00375 void codex_clean_up();
00376
00377 #ifdef __cplusplus
00378 }
00379 }
00380 }
00381 #endif
00382
00383 #endif