Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CODEX_Ciphers::RSAPrivateKey Class Reference

Serializable encapsulation of an RSA private key. More...

#include <RSA.h>

Inheritance diagram for CODEX_Ciphers::RSAPrivateKey:

Inheritance graph
[legend]
Collaboration diagram for CODEX_Ciphers::RSAPrivateKey:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 RSAPrivateKey ()
 Default constructor, for creating an object to be unmarshalled.
 RSAPrivateKey (BIGNUM *p, BIGNUM *q, BIGNUM *d, BIGNUM *n=0, BIGNUM *phi=0)
 Create an RSAPrivateKey from BIGNUM%s.
 RSAPrivateKey (const CODEX_ASN1::BigNumber &p, const CODEX_ASN1::BigNumber &q, const CODEX_ASN1::BigNumber &d)
 Create an RSAPrivateKey from BigNumber%s.
 RSAPrivateKey (const RSAPrivateKey &aKey)
 Copy constructor.
virtual ~RSAPrivateKey ()
 Destructor.
void operator= (const RSAPrivateKey &aKey)
 Assignment operator.
virtual const CODEX_ASN1::SecureBigNumberp () const
 One prime factor of the public modulus.
virtual const CODEX_ASN1::SecureBigNumberq () const
 One prime factor of the public modulus.
virtual const CODEX_ASN1::SecureBigNumberd () const
 The private decryption exponent.
virtual const CODEX_ASN1::SecureBigNumbern () const
 The public modulus.
virtual const CODEX_ASN1::SecureBigNumberphi () const
 Euler totient function of n.
BIGNUM * decrypt (const RSACipherText &cipherText) const
 Decrypt a message.
RSASignaturesign (const BIGNUM *message) const
 Sign a message.
int marshal (unsigned char **pp) const
 Serialize the object.
void * unmarshal (void *bogus, unsigned char **pp, long length)
 Unserialize the object.
void toFile (const char *fname) const
 Writes the private key to a file.
void * fromFile (const char *fname)
 Reads the private key from a file.
void fromPEMFile (const char *fname, const char *phrase=0)
 Reads the private key from a PEM-format file.
bool initialized () const

Protected Member Functions

BIGNUM * exponentiate (const BIGNUM *aBN) const

Protected Attributes

bool m_initialized
 Has this object been initialized yet, or is it still blank?

Detailed Description

Serializable encapsulation of an RSA private key.

This is not an especially memory-efficient implementation, in that the public modulus and the Euler totient function of it are both stored and are also marshalled with the data. Since private keys are not typically sent over the wire and only need to be read during process initialization (or upon creation of a new key), this should not be a serious issue.

Definition at line 190 of file RSA.h.


Constructor & Destructor Documentation

RSAPrivateKey::RSAPrivateKey BIGNUM *  p,
BIGNUM *  q,
BIGNUM *  d,
BIGNUM *  n = 0,
BIGNUM *  phi = 0
 

Create an RSAPrivateKey from BIGNUM%s.

Exceptions:
BignumMulException 
BignumSubException 

Definition at line 36 of file RSAPrivateKey.cc.

References n(), p(), phi(), and q().

RSAPrivateKey::RSAPrivateKey const CODEX_ASN1::BigNumber p,
const CODEX_ASN1::BigNumber q,
const CODEX_ASN1::BigNumber d
 

Create an RSAPrivateKey from BigNumber%s.

Exceptions:
BignumMulException 
BignumSubException 

Definition at line 132 of file RSAPrivateKey.cc.

References p(), q(), and CODEX_ASN1::BigNumber::value().


Member Function Documentation

BIGNUM * RSAPrivateKey::decrypt const RSACipherText cipherText  )  const
 

Decrypt a message.

Parameters:
cipherText The encryption of a message using the public key corresponding to this private key.
Returns:
A pointer to a new BIGNUM containing the plaintext.
Exceptions:
BignumNullException Some memory allocation failed.
BignumModExpException There was an error during modular exponentiation.
BignumContextException Memory allocation failed for a BN_CTX.

Definition at line 235 of file RSAPrivateKey.cc.

void * RSAPrivateKey::fromFile const char *  fname  ) 
 

Reads the private key from a file.

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

Definition at line 376 of file RSAPrivateKey.cc.

References p(), and unmarshal().

void RSAPrivateKey::fromPEMFile const char *  fname,
const char *  phrase = 0
 

Reads the private key from a PEM-format file.

Parameters:
fname Name of the file from which to read the key
phrase Passphrase for the file. If 0 the user will be prompted for it.
Exceptions:
FileCannotOpenException The file fname could not be opened.
BignumContextException A BN_CTX could not be allocated.
BignumNullException A BIGNUM could not be allocated.
BignumSubException Error occurred in subtraction.
BignumMulException Error occurred in multiplication.

Definition at line 405 of file RSAPrivateKey.cc.

bool CODEX_ASN1::Base::initialized  )  const [inline, inherited]
 

Returns:
Has this object been initialized?

Definition at line 175 of file Base.h.

References CODEX_ASN1::Base::m_initialized.

Referenced by CODEX_APSS::SecretManagement::addComputeMsg(), CODEX_APSS::SecretManagement::addEstablishMsg(), CODEX_APSS::SecretManagement::addEstablishResponse(), CODEX_APSS::SecretManagement::addInitMsg(), CODEX_APSS::SecretManagement::addSharing(), CODEX_APSS::SecretManagement::addSubsharing(), CODEX_VSS::Combinatoric< NumT, ThreshT >::apply(), CODEX_Server::ServerState::caKey(), CODEX_KeyService::ClientCreateCallback::ClientCreateCallback(), CODEX_VSS::Combinatoric< NumT, ThreshT >::count(), CODEX_Server::QuorumBuilderAct::handler(), CODEX_APSS::MessageVerifier::handler(), CODEX_KeyService::DelegateResponseVerifier::handler(), CODEX_KeyService::DelegateRequestDistributor::handler(), CODEX_KeyService::ClientMessageVerifier::handler(), CODEX_KeyService::ClientMessageSigner::handler(), CODEX_VSS::SubshareLabel< LabelType >::marshal(), CODEX_KeyService::KeyInfo::marshal(), CODEX_VSS::LabeledShare< ShareType, OneWay >::marshal(), CODEX_VSS::ShareLabel< _ShareType, _OneWay >::marshal(), CODEX_VSS::ModExpFunctionalArgs::marshal(), CODEX_VSS::Combinatoric< NumT, ThreshT >::marshal(), CODEX_KeyService::SignWriteCallback::operator()(), CODEX_KeyService::SignReadCallback::operator()(), CODEX_KeyService::SignCreateCallback::operator()(), CODEX_VSS::ModExpFunctional::operator()(), CODEX_KeyService::ClientReadCallback::operator()(), CODEX_KeyService::ClientCreateCallback::operator()(), CODEX_VSS::Combinatoric< NumT, ThreshT >::operator+=(), CODEX_Server::ServerState::readElGamalShares(), CODEX_VSS::Combinatoric< NumT, ThreshT >::recover(), CODEX_APSS::SecretManagement::sendFinished(), CODEX_Server::ServerState::serviceKey(), CODEX_Server::ServerState::setEGShareCallback(), and CODEX_Server::ServerState::setRSAShareCallback().

RSASignature * RSAPrivateKey::sign const BIGNUM *  message  )  const
 

Sign a message.

Parameters:
message Non-null pointer to a BIGNUM containing the message to sign. This message must be smaller than the modulus of the public key.
Returns:
A pointer to a new RSASignature object.
Exceptions:
BignumNullException The message is 0 or some memory allocation failed.
BignumModExpException There was an error during modular exponentiation.
BignumContextException Memory allocation failed for a BN_CTX.

Reimplemented in CODEX_Ciphers::VarRSAPrivateKey.

Definition at line 241 of file RSAPrivateKey.cc.

Referenced by CODEX_APSS::InitActivity::addEvidence(), CODEX_APSS::SecretManagement::beginRun(), CODEX_Client::Client::createKey(), CODEX_Server::QuorumBuilderAct::handler(), CODEX_APSS::MessageProcessor::handler(), CODEX_APSS::InitActivity::handler(), CODEX_KeyService::ClientResponseSigner::handler(), CODEX_APSS::StateInfo::recover(), and CODEX_Ciphers::VarRSAPrivateKey::sign().

void RSAPrivateKey::toFile const char *  fname  )  const
 

Writes the private key to a file.

Parameters:
fname Name of the file in which to store the key
Exceptions:
FileCannotCreateException The file fname could not be created.

Definition at line 353 of file RSAPrivateKey.cc.

References marshal(), and p().


The documentation for this class was generated from the following files:
Generated on Fri May 6 17:41:53 2005 for COrnell Data EXchange (CODEX) by  doxygen 1.4.1