Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

CODEX_Client::Client Class Reference

This class holds the interface methods for client requests, as well as the necessary state information. More...

#include <Client.h>

Inheritance diagram for CODEX_Client::Client:

Inheritance graph
[legend]
Collaboration diagram for CODEX_Client::Client:

Collaboration graph
[legend]
List of all members.

Public Methods

 Client ()
 Default constructor -- does nothing.

virtual ~Client ()
 Virtual destructor.

void setRemoteServer (const string &name, int port)
 Set the remote server.

void setServiceKey (CODEX_Ciphers::RSAPublicKey *key)
 Set the service's RSA public key.

void setKeyPair (CODEX_ASN1::Certificate *cert, CODEX_Ciphers::RSAPrivateKey *key)
 Set the client's RSA public/private key pair.

CODEX_Ciphers::PolicycreatePolicy (const CODEX_Ciphers::RSAPublicKey &policyPubKey, const CODEX_Ciphers::RSAPrivateKey &ownerPrivKey)
 Creates a CODEX_Ciphers::Policy object.

CODEX_Ciphers::CredentialsissueCredentials (const CODEX_Ciphers::RSAPublicKey &clientPubKey, const CODEX_Ciphers::RSAPrivateKey &policyPrivKey)
 Creates a CODEX_Ciphers::Credentials object.

bool createKey (const CODEX_ASN1::ustring &name, const CODEX_ASN1::Certificate &owner_cert, const CODEX_Ciphers::Policy &readPolicy, const CODEX_Ciphers::Policy &writePolicy, SignedBoundNameMsg &binding)
 Bind a name and access control policies.

bool writeKey (const CODEX_ASN1::ustring &name, const BIGNUM *keyValue, const CODEX_Ciphers::Credentials &credentials, const CODEX_Ciphers::RSAPrivateKey &privKey, const SignedBoundNameMsg &binding)
 Associate a value with a name.

bool readKey (const CODEX_ASN1::ustring &name, const CODEX_Ciphers::Credentials &credentials, const CODEX_Ciphers::RSAPrivateKey &privKey, BIGNUM **returnedKeyValue)
 Retrieve the value associated with a name.

void toFile (const char *fname) const
 Writes the Client's state to a file.

void * fromFile (const char *fname)
 Reads the Client's state from a file.

const CODEX_Quorum::RemoteServerserver () const
 
Returns:
The remote server.


const CODEX_ASN1::Certificatecertificate () const
 
Returns:
The client's certificate.


const CODEX_Ciphers::RSAPrivateKeyprivateKey () const
 
Returns:
The client's RSA private key.


const CODEX_Ciphers::RSAPublicKeyserviceKey () const
 
Returns:
The service's RSA public key.


const CODEX_Ciphers::ElGamalPublicKeyserviceEGKey () const
 
Returns:
The service's ElGamal public key.


const CODEX_ASN1::BigNumberserviceH () const
 
Returns:
The service's auxiliary generator.


const CODEX_Ciphers::ElGamalPublicKeypublicEGKey () const
 
Returns:
The client's ElGamal public key.


const CODEX_Ciphers::ElGamalPrivateKeyprivateEGKey () const
 
Returns:
The client's ElGamal private key.



Protected Methods

bool getServiceKey ()
 Fetch the service's ElGamal public key.

bool contactServer (const Message &message, unsigned char mtype, CODEX_Quorum::Message &response)
 Send a message to the remote server and wait for a response.


Detailed Description

This class holds the interface methods for client requests, as well as the necessary state information.

It is also serializable, so that its state can be saved to disk between sessions. It does not inherit CODEX_ASN1::Base, however. Why not? Because there should be no need to ever send client state across the network, especially since some of the fields are private keys. Having serializable private keys is not a significant problem, since it should be obvious to the programmer that they are private keys. There is also something to be said for consistency, and public keys rightfully inherit CODEX_ASN1::Base.

See also:
client_functions.h for C-callable functions.

Definition at line 42 of file Client.h.


Member Function Documentation

bool Client::contactServer const Message   message,
unsigned char    mtype,
CODEX_Quorum::Message   response
[protected]
 

Send a message to the remote server and wait for a response.

Parameters:
message  The message to send.
mtype  The one-byte message type.
response  The response, in marshalled form.
Returns:
Success or failure of the operation.

Definition at line 618 of file Client.cc.

References CODEX_Quorum::RemoteServer::flushSocket(), CODEX_Quorum::RemoteServerReturn::kSuccess, CODEX_ASN1::Base::marshal(), CODEX_Quorum::RemoteServer::receiveFrom(), CODEX_Quorum::RemoteServerReturn::reset(), CODEX_Quorum::RemoteServerReturn::returnCode(), and CODEX_Quorum::RemoteServer::sendTo().

Referenced by createKey(), getServiceKey(), readKey(), and writeKey().

bool Client::createKey const CODEX_ASN1::ustring   name,
const CODEX_ASN1::Certificate   owner_cert,
const CODEX_Ciphers::Policy   readPolicy,
const CODEX_Ciphers::Policy   writePolicy,
SignedBoundNameMsg   binding
 

Bind a name and access control policies.

Parameters:
name  The name for the key.
owner_cert  The owner's certificate.
readPolicy  The read policy to set for this name.
writePolicy  The write policy to set for this name.
binding  The response from the service. Must be allocated but not initialized.
Returns:
Success or failure of the operation.

Definition at line 127 of file Client.cc.

References CODEX_Quorum::Message::buffer(), contactServer(), CODEX_Client::Message::digest(), CODEX_ASN1::Base::initialized(), CODEX_Quorum::Message::length(), CODEX_Client::CreateKeyMsg::name(), CODEX_Ciphers::RSAPrivateKey::sign(), CODEX_ASN1::OctetString::value(), and CODEX_Ciphers::RSAPublicKey::verifySignature().

Referenced by CODEX_Client::Interface::codex_create_key().

CODEX_Ciphers::Policy * Client::createPolicy const CODEX_Ciphers::RSAPublicKey   policyPubKey,
const CODEX_Ciphers::RSAPrivateKey   ownerPrivKey
 

Creates a CODEX_Ciphers::Policy object.

Parameters:
policyPubKey  The public key specifying the access policy.
ownerPrivKey  The owner's private key, which will be used to sign policyPubKey.
Returns:
The new policy, or NULL if an error occurred.

Definition at line 92 of file Client.cc.

References CODEX_Ciphers::Policy::unmarshal().

Referenced by CODEX_Client::Interface::codex_create_policy().

void * Client::fromFile const char *    fname
 

Reads the Client's state from a file.

Parameters:
fname  Name of the file to read.
Exceptions:
CODEX_Ciphers::FileCannotOpenException  The file fname could not be opened.

Definition at line 774 of file Client.cc.

References CODEX_ASN1::BigNumber::unmarshal(), CODEX_Ciphers::ElGamalPublicKey::unmarshal(), CODEX_Ciphers::RSAPublicKey::unmarshal(), CODEX_Ciphers::RSAPrivateKey::unmarshal(), CODEX_ASN1::Certificate::unmarshal(), CODEX_ASN1::Integer::unmarshal(), and CODEX_ASN1::Integer::value().

Referenced by CODEX_Client::Interface::codex_from_file().

CODEX_Ciphers::Credentials * Client::issueCredentials const CODEX_Ciphers::RSAPublicKey   clientPubKey,
const CODEX_Ciphers::RSAPrivateKey   policyPrivKey
 

Creates a CODEX_Ciphers::Credentials object.

Parameters:
clientPubKey  The public key of the credentials holder.
policyPrivKey  The private key for the access policy, which will be used to sign policyPubKey.
Returns:
The new credentials, or NULL if an error occurred.

Definition at line 111 of file Client.cc.

Referenced by CODEX_Client::Interface::codex_issue_credentials().

bool Client::readKey const CODEX_ASN1::ustring   name,
const CODEX_Ciphers::Credentials   credentials,
const CODEX_Ciphers::RSAPrivateKey   privKey,
BIGNUM **    returnedKeyValue
 

Retrieve the value associated with a name.

The key value is returned blind, and all blinding operations for the client are performed in this method. If an application needs to keep the blinding factor for some reason, it should be straightforward to adapt this method.

Parameters:
name  The name of the key.
credentials  The client's credentials for this operation.
privKey  The client's private key corresponding to the public key in credentials.
returnedKeyValue  The key, possibly with padding. This must point to a valid pointer. That is, it may not be NULL.
Returns:
Success or failure of the operation. On failure, *returnedKeyValue will be NULL.

Definition at line 370 of file Client.cc.

References CODEX_Quorum::Message::buffer(), contactServer(), CODEX_Client::Message::digest(), CODEX_Ciphers::RSAPublicKey::encrypt(), CODEX_Ciphers::ElGamalPublicKey::encryptS(), getServiceKey(), CODEX_ASN1::Base::initialized(), CODEX_Quorum::Message::length(), CODEX_Ciphers::RSAPublicKey::n(), CODEX_Client::ReadKeyMsg::name(), CODEX_Ciphers::ElGamalPublicKey::p(), CODEX_Ciphers::ElGamalPublicKey::q(), CODEX_Ciphers::RSAPrivateKey::sign(), CODEX_ASN1::OctetString::value(), CODEX_ASN1::BigNumber::value(), and CODEX_Ciphers::RSAPublicKey::verifySignature().

Referenced by CODEX_Client::Interface::codex_read_key().

void Client::setKeyPair CODEX_ASN1::Certificate   cert,
CODEX_Ciphers::RSAPrivateKey   key
 

Set the client's RSA public/private key pair.

Parameters:
cert  A certificate signed by the client-authorizing CA.
key  The private key corresponding to the public key in cert.

Definition at line 83 of file Client.cc.

Referenced by CODEX_Client::Interface::codex_set_key_pair().

void Client::setRemoteServer const string &    name,
int    port
 

Set the remote server.

Parameters:
name  The name of the remote host.
port  Port on the remote host to contact.

Definition at line 59 of file Client.cc.

Referenced by CODEX_Client::Interface::codex_set_server().

void Client::toFile const char *    fname const
 

Writes the Client's state to a file.

Only the key information is stored. The CODEX_Quorum::RemoteServer will still need to be set in subsequent sessions.

Parameters:
fname  The name of the file.
Exceptions:
CODEX_Ciphers::FileCannotCreateException  The file fname could not be created.

Definition at line 674 of file Client.cc.

References CODEX_ASN1::BigNumber::marshal(), CODEX_Ciphers::ElGamalPublicKey::marshal(), CODEX_Ciphers::RSAPublicKey::marshal(), CODEX_Ciphers::RSAPrivateKey::marshal(), CODEX_ASN1::Certificate::marshal(), CODEX_ASN1::Integer::marshal(), and CODEX_ASN1::Integer::value().

Referenced by CODEX_Client::Interface::codex_to_file().

bool Client::writeKey const CODEX_ASN1::ustring   name,
const BIGNUM *    keyValue,
const CODEX_Ciphers::Credentials   credentials,
const CODEX_Ciphers::RSAPrivateKey   privKey,
const SignedBoundNameMsg   binding
 

Associate a value with a name.

Parameters:
name  The name of the key.
keyValue  The value to be stored. This should be padded to a reasonable length.
credentials  The client's credentials for this operation.
privKey  The client's private key corresponding to the public key in credentials.
binding  The service's signed response to the CreateKeyMsg request.
Returns:
Success or failure of the operation.

Definition at line 218 of file Client.cc.

References CODEX_Quorum::Message::buffer(), contactServer(), CODEX_Client::Message::digest(), CODEX_Ciphers::VarRSAPublicKey::encrypt(), CODEX_Ciphers::ElGamalPublicKey::encryptS(), getServiceKey(), CODEX_ASN1::Base::initialized(), CODEX_Quorum::Message::length(), CODEX_Client::WriteKeyMsg::name(), CODEX_Ciphers::RSAPrivateKey::sign(), CODEX_ASN1::OctetString::value(), and CODEX_Ciphers::RSAPublicKey::verifySignature().

Referenced by CODEX_Client::Interface::codex_write_key().


The documentation for this class was generated from the following files:
Generated on Wed Jun 2 16:33:05 2004 for COrnell Data EXchange (CODEX) by doxygen1.2.18