Mixes for Privacy and Anonymity in the Internet
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
CAASymCipher Class Reference

List of all members.

Public Member Functions

 CAASymCipher ()
 ~CAASymCipher ()
SINT32 destroy ()
SINT32 decrypt (const UINT8 *from, UINT8 *to)
 Decrypts exactly one block which is stored in from.
SINT32 decryptOAEP (const UINT8 *from, UINT8 *to, UINT32 *len)
 Decrypts one OAEP encoded block which is stored in from.
SINT32 encrypt (const UINT8 *from, UINT8 *to)
 Encrypts exactly one block which is stored in from.
SINT32 encryptOAEP (const UINT8 *from, UINT32 fromlen, UINT8 *to, UINT32 *len)
 Encrypts one block of plain text using OAEP padding.
SINT32 encryptPKCS1 (const UINT8 *from, UINT32 fromlen, UINT8 *to, UINT32 *len)
 Encrypts one block of plain text using PKCS1 padding.
SINT32 generateKeyPair (UINT32 size)
 Generates a new random key-pair of size bits.
SINT32 getPublicKeyAsXML (UINT8 *buff, UINT32 *len)
 Stores the public key in buff as XML.
SINT32 getPublicKeyAsDOMElement (DOMElement *&elemRoot, XERCES_CPP_NAMESPACE::DOMDocument *docOwner)
SINT32 setPublicKey (const CACertificate *pCert)
 Sets the public key which is used for encryption to the contained in the provided certificate.
SINT32 setPublicKeyAsXML (const UINT8 *buff, UINT32 len)
 Sets the public key to the values stored in key.
SINT32 setPublicKeyAsDOMNode (DOMNode *node)
SINT32 setPublicKey (const UINT8 *modulus, UINT32 moduluslen, const UINT8 *exponent, UINT32 exponentlen)

Static Public Member Functions

static SINT32 testSpeed ()

Private Member Functions

SINT32 addKeyPart (DOMElement *elemRoot, XERCES_CPP_NAMESPACE::DOMDocument *docOwner, const char *partName, BIGNUM *part)
 Stores the public key in buff.
SINT32 getKeyPart (BIGNUM **part, DOMNode *node)

Private Attributes

RSA * m_pRSA

Constructor & Destructor Documentation

References m_pRSA.

Referenced by testSpeed().

References destroy().


Member Function Documentation

SINT32 CAASymCipher::addKeyPart ( DOMElement *  elemRoot,
XERCES_CPP_NAMESPACE::DOMDocument *  docOwner,
const char *  partName,
BIGNUM *  part 
) [private]

Stores the public key in buff.

The format is as follows:

  • SIZE-N [2 bytes] - number of bytes which are needed for the modulus n (in network byte order..)
  • N [SIZE-N bytes] - the modulus n as integer (in network byte order)
  • SIZE-E [2 bytes] - number of bytes which are needed for the exponent e (in network byte order..)
  • E [SIZE-E bytes] - the exponent e as integer (in network byte order)
Parameters:
buffbyte array in which the public key should be stored
lenon input holds the size of buff, on return it contains the number of bytes needed to store the public key
Return values:
E_UNKNOWNin case of an error
E_SUCCESSotherwise
See also:
getPublicKeySize()
setPublicKey() Returns the number of bytes needed to store we public key. This is the number of bytes needed for a call of getPublicKey().
Returns:
E_UNKOWN in case of an error number of bytes otherwise
See also:
getPublicKey Sets the public key to the vaules stored in key. The format must match the format described for getPublicKey().
Parameters:
keybyte array which holds the new public key
lenon input,size of key byte array, on successful return number of bytes 'consumed'
Return values:
E_UNKNOWNin case of an error, the cipher is the uninitialized (no key is set)
E_SUCCESSotherwise
See also:
getPublicKey

References createDOMElement(), createDOMText(), E_SUCCESS, and CABase64::encode().

Referenced by getPublicKeyAsDOMElement().

SINT32 CAASymCipher::decrypt ( const UINT8 from,
UINT8 to 
)

Decrypts exactly one block which is stored in from.

The result of the decryption is stored in to.

Parameters:
fromone block of cipher text
tothe decrypted plain text
Return values:
E_UNKNOWNin case of an error
E_SUCCESSotherwise

References E_SUCCESS, E_UNKNOWN, m_pRSA, and RSA_SIZE.

Referenced by decodeXMLEncryptedKey(), and CALastMixB::loop().

SINT32 CAASymCipher::decryptOAEP ( const UINT8 from,
UINT8 to,
UINT32 len 
)

Decrypts one OAEP encoded block which is stored in from.

Parameters:
fromone OAEP encoded block of cipher text
tothe plain text
lenon return contains the size of the plaintext
Return values:
E_UNKNOWNin case of an error
E_SUCCESSotherwise

References E_SUCCESS, E_UNKNOWN, m_pRSA, and RSA_SIZE.

Referenced by decryptXMLElement(), CALastMixA::loop(), mm_loopReadFromMixBefore(), and testSpeed().

References E_SUCCESS, and m_pRSA.

Referenced by ~CAASymCipher().

SINT32 CAASymCipher::encrypt ( const UINT8 from,
UINT8 to 
)

Encrypts exactly one block which is stored in from.

The result of the encrpytion is stored in to.

Parameters:
fromone block of plain text
tothe encrypted cipher text
Return values:
E_UNKNOWNin case of an error
E_SUCCESSotherwise

References E_SUCCESS, E_UNKNOWN, m_pRSA, and RSA_SIZE.

Referenced by __encryptKey(), CALocalProxy::loop(), CAMsg::openEncryptedLog(), and CALocalProxy::processKeyExchange().

SINT32 CAASymCipher::encryptOAEP ( const UINT8 from,
UINT32  fromlen,
UINT8 to,
UINT32 len 
)

Encrypts one block of plain text using OAEP padding.

Parameters:
frompointer to one block of plain text
fromlensize of the plain text
tothe OAEP encoded cipher text
lenon return contains the size of the ciphertext
Return values:
E_UNKNOWNin case of an error
E_SUCCESSotherwise

References E_SUCCESS, E_UNKNOWN, and m_pRSA.

Referenced by encryptXMLElement(), CALocalProxy::loop(), and testSpeed().

SINT32 CAASymCipher::encryptPKCS1 ( const UINT8 from,
UINT32  fromlen,
UINT8 to,
UINT32 len 
)

Encrypts one block of plain text using PKCS1 padding.

Parameters:
frompointer to one block of plain text
fromlensize of the plain text
tothe OAEP encoded cipher text
lenon return contains the size of the ciphertext
Return values:
E_UNKNOWNin case of an error
E_SUCCESSotherwise Temporarly will be removed soon.

References E_SUCCESS, E_UNKNOWN, and m_pRSA.

Generates a new random key-pair of size bits.

Parameters:
sizekeysize of the new keypair
Return values:
E_UNKNOWNin case of an error
E_SUCCESSotherwise

References E_SUCCESS, E_UNKNOWN, m_pRSA, and setRSAFlags().

Referenced by CAMiddleMix::init(), CALastMix::init(), CAFirstMix::processKeyExchange(), and testSpeed().

SINT32 CAASymCipher::getKeyPart ( BIGNUM **  part,
DOMNode *  node 
) [private]
SINT32 CAASymCipher::getPublicKeyAsDOMElement ( DOMElement *&  elemRoot,
XERCES_CPP_NAMESPACE::DOMDocument *  docOwner 
)

Stores the public key in buff as XML.

The format is as follows:

	<RSAKeyValue>
	  <Modulus>
	    the modulus of the Key as ds::CryptoBinary
	  </Modulus>
	  <Exponent>
	    the exponent of the key as ds::CryptoBinary
	  </Exponent>
	<RSAKeyValue>

There is NO \0 at the end.

Parameters:
buffbyte array in which the public key should be stored
lenon input holds the size of buff, on return it contains the number of bytes needed to store the public key
Return values:
E_UNKNOWNin case of an error
E_SUCCESSotherwise
See also:
setPublicKeyAsXML()

References createDOMDocument(), DOM_Output::dumpToMem(), E_SUCCESS, E_UNKNOWN, getPublicKeyAsDOMElement(), and m_pRSA.

Sets the public key which is used for encryption to the contained in the provided certificate.

The key has to be a RSA public key.

Return values:
E_SUCCESSif successful
E_UNKNOWNotherwise (in this case the key leaves untouched)

References E_SUCCESS, E_UNKNOWN, CACertificate::m_pCert, m_pRSA, and setRSAFlags().

Referenced by CAMsg::openEncryptedLog().

SINT32 CAASymCipher::setPublicKey ( const UINT8 modulus,
UINT32  moduluslen,
const UINT8 exponent,
UINT32  exponentlen 
)
SINT32 CAASymCipher::setPublicKeyAsXML ( const UINT8 key,
UINT32  len 
)

Sets the public key to the values stored in key.

The format must match the format XML described for getPublicKeyAsXML().

Parameters:
keybyte array which holds the new public key
lenon input,size of key byte array, on successful return number of bytes 'consumed'
Return values:
E_UNKNOWNin case of an error, the cipher is the uninitialized (no key is set)
E_SUCCESSotherwise
See also:
getPublicKeyAsXML

References E_UNKNOWN, parseDOMDocument(), and setPublicKeyAsDOMNode().


Member Data Documentation

RSA* CAASymCipher::m_pRSA [private]