00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __CODEX_CLIENT_CLIENT_H__
00022 #define __CODEX_CLIENT_CLIENT_H__
00023
00024 #include "Message.h"
00025 #include "CODEX_Quorum/SocketBuilder.h"
00026 #include "CODEX_Quorum/RemoteServer.h"
00027 #include "CODEX_Ciphers/SHA1HashFunction.h"
00028
00029 namespace CODEX_Client
00030 {
00045 class Client
00046 {
00047 public :
00049 Client();
00050
00052 virtual ~Client();
00053
00059 void setRemoteServer( const string& name, int port );
00060
00064 void setServiceKey( CODEX_Ciphers::RSAPublicKey* key );
00065
00072 void setKeyPair( CODEX_ASN1::Certificate* cert,
00073 CODEX_Ciphers::RSAPrivateKey* key );
00074
00075
00083 CODEX_Ciphers::Policy*
00084 createPolicy( const CODEX_Ciphers::RSAPublicKey& policyPubKey,
00085 const CODEX_Ciphers::RSAPrivateKey& ownerPrivKey );
00086
00094 CODEX_Ciphers::Credentials*
00095 issueCredentials( const CODEX_Ciphers::RSAPublicKey& clientPubKey,
00096 const CODEX_Ciphers::RSAPrivateKey& policyPrivKey );
00097
00108 bool createKey( const CODEX_ASN1::ustring& name,
00109 const CODEX_ASN1::Certificate& owner_cert,
00110 const CODEX_Ciphers::Policy& readPolicy,
00111 const CODEX_Ciphers::Policy& writePolicy,
00112 SignedBoundNameMsg& binding );
00113
00126 bool writeKey( const CODEX_ASN1::ustring& name,
00127 const BIGNUM* keyValue,
00128 const CODEX_Ciphers::Credentials& credentials,
00129 const CODEX_Ciphers::RSAPrivateKey& privKey,
00130 const SignedBoundNameMsg& binding );
00131
00148 bool readKey( const CODEX_ASN1::ustring& name,
00149 const CODEX_Ciphers::Credentials& credentials,
00150 const CODEX_Ciphers::RSAPrivateKey& privKey,
00151 BIGNUM ** returnedKeyValue );
00152
00161 void toFile( const char* fname ) const;
00162
00169 void* fromFile( const char* fname );
00170
00172 const CODEX_Quorum::RemoteServer* server() const
00173 {
00174 return m_server;
00175 }
00176
00178 const CODEX_ASN1::Certificate* certificate() const
00179 {
00180 return m_certificate;
00181 }
00182
00184 const CODEX_Ciphers::RSAPrivateKey* privateKey() const
00185 {
00186 return m_privateKey;
00187 }
00188
00190 const CODEX_Ciphers::RSAPublicKey* serviceKey() const
00191 {
00192 return m_serviceKey;
00193 }
00194
00196 const CODEX_Ciphers::ElGamalPublicKey* serviceEGKey() const
00197 {
00198 return m_serviceEGKey;
00199 }
00200
00202 const CODEX_ASN1::BigNumber* serviceH() const
00203 {
00204 return m_serviceH;
00205 }
00206
00208 const CODEX_Ciphers::ElGamalPublicKey* publicEGKey() const
00209 {
00210 return m_publicEGKey;
00211 }
00212
00214 const CODEX_Ciphers::ElGamalPrivateKey* privateEGKey() const
00215 {
00216 return m_privateEGKey;
00217 }
00218
00219 protected :
00221 bool getServiceKey();
00222
00230 bool contactServer( const Message& message,
00231 unsigned char mtype,
00232 CODEX_Quorum::Message& response );
00233
00234 private :
00235 CODEX_Quorum::SocketBuilder m_socketBuilder;
00236 CODEX_Ciphers::SHA1HashFunction m_hashFunc;
00237 CODEX_Quorum::RemoteServer* m_server;
00238 CODEX_ASN1::Certificate* m_certificate;
00239 CODEX_Ciphers::RSAPrivateKey* m_privateKey;
00240 CODEX_Ciphers::RSAPublicKey* m_serviceKey;
00241 CODEX_Ciphers::ElGamalPublicKey* m_serviceEGKey;
00242 CODEX_ASN1::BigNumber* m_serviceH;
00243 CODEX_Ciphers::ElGamalPublicKey* m_publicEGKey;
00244 CODEX_Ciphers::ElGamalPrivateKey* m_privateEGKey;
00245 };
00246 }
00247
00248 #endif