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

CODEX_Ciphers::ElGamalPrivateKey Class Reference

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

#include <ElGamal.h>

Inheritance diagram for CODEX_Ciphers::ElGamalPrivateKey:

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

Collaboration graph
[legend]
List of all members.

Public Methods

 ElGamalPrivateKey ()
 Default constructor, for creating an object to be unmarshalled.

 ElGamalPrivateKey (BIGNUM *x)
 Create an ElGamalPrivateKey from a BIGNUM.

 ElGamalPrivateKey (const CODEX_ASN1::BigNumber &x)
 Create an ElGamalPrivateKey from a BigNumber.

 ElGamalPrivateKey (const ElGamalPrivateKey &aKey)
 Copy constructor.

virtual ~ElGamalPrivateKey ()
 Destructor.

const CODEX_ASN1::SecureBigNumberx () const
 
Returns:
this object as a SecureBigNumber


BIGNUM * decrypt (const ElGamalCipherText &cipherText, const ElGamalPublicKey &publicKey) const
 Decrypt a message.

ElGamalSignaturesign (const BIGNUM *message, const ElGamalPublicKey &publicKey) const
 Sign a message.

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.


Detailed Description

Serializable encapsulation of an ElGamal private key.

This is just an extension of a SecureBigNumber.

Definition at line 367 of file ElGamal.h.


Member Function Documentation

BIGNUM * ElGamalPrivateKey::decrypt const ElGamalCipherText   cipherText,
const ElGamalPublicKey   publicKey
const
 

Decrypt a message.

Parameters:
cipherText  The encryption of a message using the public key corresponding to this private key.
publicKey  The corresponding public 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.
BignumModInverseException  There was an error during modular inversion.
BignumModMulException  There was an error during modular multiplication.
BignumContextException  Memory allocation failed for a BN_CTX.

Definition at line 49 of file ElGamalPrivateKey.cc.

References CODEX_Ciphers::ElGamalCipherText::c1(), CODEX_Ciphers::ElGamalCipherText::c2(), CODEX_ASN1::BigNumber::m_value, CODEX_Ciphers::ElGamalPublicKey::p(), CODEX_Ciphers::ElGamalPublicKey::q(), and CODEX_ASN1::BigNumber::value().

void * ElGamalPrivateKey::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 266 of file ElGamalPrivateKey.cc.

References CODEX_ASN1::BigNumber::unmarshal().

ElGamalSignature * ElGamalPrivateKey::sign const BIGNUM *    message,
const ElGamalPublicKey   publicKey
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.
publicKey  The corresponding public key.
Returns:
A pointer to a new ElGamalSignature object.
Exceptions:
BignumNullException  The message is 0 or some memory allocation failed.
BignumSubException  There was an error during subtraction.
BignumAddException  There was an error during addition.
BignumRandRangeException  There was an error generating the random exponent.
BignumGCDException  There was an error while computing a greatest common denominator.
BignumModInverseException  There was an error during modular inversion.
BignumModExpException  There was an error during modular exponentiation.
BignumModMulException  There was an error during modular multiplication.
BignumContextException  Memory allocation failed for a BN_CTX.

Definition at line 120 of file ElGamalPrivateKey.cc.

References CODEX_Ciphers::ElGamalPublicKey::g(), CODEX_ASN1::BigNumber::m_value, CODEX_Ciphers::ElGamalPublicKey::p(), CODEX_Ciphers::ElGamalPublicKey::q(), and CODEX_ASN1::BigNumber::value().

void ElGamalPrivateKey::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 244 of file ElGamalPrivateKey.cc.

References CODEX_ASN1::BigNumber::marshal().


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