00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __CODEX_CLIENT_CLIENT_H__
00019 #define __CODEX_CLIENT_CLIENT_H__
00020
00021 #include "Message.h"
00022 #include "CODEX_Quorum/SocketBuilder.h"
00023 #include "CODEX_Quorum/RemoteServer.h"
00024 #include "CODEX_Ciphers/SHA1HashFunction.h"
00025
00026 namespace CODEX_Client
00027 {
00042 class Client
00043 {
00044 public :
00046 Client();
00047
00049 virtual ~Client();
00050
00056 void setRemoteServer( const string& name, int port );
00057
00061 void setServiceKey( CODEX_Ciphers::RSAPublicKey* key );
00062
00069 void setKeyPair( CODEX_ASN1::Certificate* cert,
00070 CODEX_Ciphers::RSAPrivateKey* key );
00071
00072
00080 CODEX_Ciphers::Policy*
00081 createPolicy( const CODEX_Ciphers::RSAPublicKey& policyPubKey,
00082 const CODEX_Ciphers::RSAPrivateKey& ownerPrivKey );
00083
00091 CODEX_Ciphers::Credentials*
00092 issueCredentials( const CODEX_Ciphers::RSAPublicKey& clientPubKey,
00093 const CODEX_Ciphers::RSAPrivateKey& policyPrivKey );
00094
00105 bool createKey( const CODEX_ASN1::ustring& name,
00106 const CODEX_ASN1::Certificate& owner_cert,
00107 const CODEX_Ciphers::Policy& readPolicy,
00108 const CODEX_Ciphers::Policy& writePolicy,
00109 SignedBoundNameMsg& binding );
00110
00123 bool writeKey( const CODEX_ASN1::ustring& name,
00124 const BIGNUM* keyValue,
00125 const CODEX_Ciphers::Credentials& credentials,
00126 const CODEX_Ciphers::RSAPrivateKey& privKey,
00127 const SignedBoundNameMsg& binding );
00128
00145 bool readKey( const CODEX_ASN1::ustring& name,
00146 const CODEX_Ciphers::Credentials& credentials,
00147 const CODEX_Ciphers::RSAPrivateKey& privKey,
00148 BIGNUM ** returnedKeyValue );
00149
00158 void toFile( const char* fname ) const;
00159
00166 void* fromFile( const char* fname );
00167
00169 const CODEX_Quorum::RemoteServer* server() const
00170 {
00171 return m_server;
00172 }
00173
00175 const CODEX_ASN1::Certificate* certificate() const
00176 {
00177 return m_certificate;
00178 }
00179
00181 const CODEX_Ciphers::RSAPrivateKey* privateKey() const
00182 {
00183 return m_privateKey;
00184 }
00185
00187 const CODEX_Ciphers::RSAPublicKey* serviceKey() const
00188 {
00189 return m_serviceKey;
00190 }
00191
00193 const CODEX_Ciphers::ElGamalPublicKey* serviceEGKey() const
00194 {
00195 return m_serviceEGKey;
00196 }
00197
00199 const CODEX_ASN1::BigNumber* serviceH() const
00200 {
00201 return m_serviceH;
00202 }
00203
00205 const CODEX_Ciphers::ElGamalPublicKey* publicEGKey() const
00206 {
00207 return m_publicEGKey;
00208 }
00209
00211 const CODEX_Ciphers::ElGamalPrivateKey* privateEGKey() const
00212 {
00213 return m_privateEGKey;
00214 }
00215
00216 protected :
00218 bool getServiceKey();
00219
00227 bool contactServer( const Message& message,
00228 unsigned char mtype,
00229 CODEX_Quorum::Message& response );
00230
00231 private :
00232 CODEX_Quorum::SocketBuilder m_socketBuilder;
00233 CODEX_Ciphers::SHA1HashFunction m_hashFunc;
00234 CODEX_Quorum::RemoteServer* m_server;
00235 CODEX_ASN1::Certificate* m_certificate;
00236 CODEX_Ciphers::RSAPrivateKey* m_privateKey;
00237 CODEX_Ciphers::RSAPublicKey* m_serviceKey;
00238 CODEX_Ciphers::ElGamalPublicKey* m_serviceEGKey;
00239 CODEX_ASN1::BigNumber* m_serviceH;
00240 CODEX_Ciphers::ElGamalPublicKey* m_publicEGKey;
00241 CODEX_Ciphers::ElGamalPrivateKey* m_privateEGKey;
00242 };
00243 }
00244
00245 #endif