sipxportlib  Version 3.3
List of all members
UtlCryptoKeyRsa Class Reference

Rsa private/public keypairs. More...

#include <UtlCryptoKeyRsa.h>

Inheritance diagram for UtlCryptoKeyRsa:
Inheritance graph
[legend]
Collaboration diagram for UtlCryptoKeyRsa:
Collaboration graph
[legend]

Public Member Functions

Creators
 UtlCryptoKeyRsa ()
 Constructor. More...
 
 ~UtlCryptoKeyRsa ()
 Destructor. More...
 
Manipulators
int generateKey ()
 Generates a new RSA private/public key pair. More...
 
int importFromFile (const char *pFilename)
 Imports a key from the given file. More...
 
int getMaxEncryptedSize (int srcLen) const
 Returns the max encrypted size of srcLen bytes from encrypt() More...
 
int encrypt (const unsigned char *pSrc, int srcLen, unsigned char *pDest, int *pDestLen) const
 Encrypts the given source data with the current key. More...
 
int getMaxDecryptedSize (int srcLen) const
 Returns the max decrypted size of srcLen bytes from decrypt() More...
 
int decrypt (const unsigned char *pSrc, int srcLen, unsigned char *pDest, int *pDestLen) const
 Decrypts the given source data with the current key. More...
 
int getMaxSignatureSize (int srcLen) const
 Returns the max size of a signature that sign() will return. More...
 
int sign (const unsigned char *pSrc, int srcLen, unsigned char *pDest, int *pDestLen) const
 Signs source data. More...
 
int verify (const unsigned char *pSrc, int srcLen, const unsigned char *pSig, int sigLen) const
 Verifies that the signature is valid for the source data. More...
 
int encryptPrivate (const unsigned char *pSrc, int srcLen, unsigned char *pDest, int *pDestLen) const
 Decrypts the given source data with the current PRIVATE key. More...
 
int decryptPrivate (const unsigned char *pSrc, int srcLen, unsigned char *pDest, int *pDestLen) const
 Decrypts the given source data with the current PRIVATE key. More...
 
int encryptPublic (const unsigned char *pSrc, int srcLen, unsigned char *pDest, int *pDestLen) const
 Encrypts the given source data with the current PUBLIC key. More...
 
int decryptPublic (const unsigned char *pSrc, int srcLen, unsigned char *pDest, int *pDestLen) const
 Decrypts the given source data with the current PUBLIC key. More...
 
Inquiry
UtlString output () const
 Get humane-readable describe. More...
 
- Public Member Functions inherited from UtlCryptoKey
 UtlCryptoKey ()
 Constructor. More...
 
virtual ~UtlCryptoKey ()
 Destructor. More...
 
virtual int loadBinaryKey (const unsigned char *pSrc, int srcLen)
 Loads a binary key value. More...
 
virtual UtlCryptoDatagetBinaryKey () const
 Retrieves a binary key value (for later use by loadBinaryKey) More...
 
virtual UtlCryptoDataencrypt (const unsigned char *pSrc, int srcLen) const
 Encrypts the given source data with the current key. More...
 
virtual UtlCryptoDatadecrypt (const unsigned char *pSrc, int srcLen) const
 Decrypts the given source data with the current key. More...
 
virtual UtlCryptoDatasign (const unsigned char *pSrc, int srcLen) const
 Signs source data. More...
 
bool isValid () const
 
bool isPrivate () const
 
bool isPublic () const
 
bool isSymmetric () const
 
KeyType getKeyType () const
 
unsigned long getLastError () const
 

Additional Inherited Members

- Public Types inherited from UtlCryptoKey
enum  KeyType {
  KEY_INVALID, KEY_SYMMETRIC, KEY_PRIVATE, KEY_PUBLIC,
  NUM_KEY_TYPES
}
 What type of Key is this? More...
 
- Static Public Member Functions inherited from UtlCryptoKey
static int getDigestAlgType ()
 Returns the digest algorithm type that computeDigest() will return. More...
 
static int getMaxDigestSize (int srcLen)
 Returns the max size of a digest that computeDigest() will return. More...
 
static int computeDigest (const unsigned char *pSrc, int srcLen, unsigned char *pDest, int *pDestLen)
 Computes message digest (MD) of given data. More...
 
static UtlCryptoDatacomputeDigest (const unsigned char *pSrc, int srcLen)
 Computes message digest (MD) of given data. More...
 
static int getMaxBase64EncodedSize (int srcLen)
 Returns the max base64-encoded size of srcLen bytes from base64Encode. More...
 
static int base64Encode (const unsigned char *pSrc, int srcLen, unsigned char *pDest, int *pDestLen)
 Encodes the given binary data in base64 format. More...
 
static UtlString base64Encode (const unsigned char *pSrc, int srcLen)
 Encodes the given binary data in base64 format. More...
 
static int getMaxBase64DecodedSize (int srcLen)
 Returns the max decoded size of srcLen bytes from base64Decode. More...
 
static int base64Decode (const unsigned char *pSrc, int srcLen, unsigned char *pDest, int *pDestLen)
 Decodes the given base64 data into binary format. More...
 
static int base64Decode (const UtlString &pSrc, unsigned char *pDest, int *pDestLen)
 Decodes the given base64 data into binary format. More...
 
static UtlCryptoDatabase64Decode (const unsigned char *pSrc, int srcLen)
 Decodes the given base64 data into binary format. More...
 
static UtlCryptoDatabase64Decode (const UtlString &pSrc)
 Decodes the given base64 data into binary format. More...
 
- Protected Member Functions inherited from UtlCryptoKey
KeyType setKeyType (KeyType type)
 
unsigned long setLastError (unsigned long err) const
 
- Static Protected Member Functions inherited from UtlCryptoKey
static int getBase64Idx (unsigned char c)
 Decode base64 character. More...
 
static bool isBase64 (unsigned char c)
 Returns true if the given char is a base64 char. More...
 
- Static Protected Attributes inherited from UtlCryptoKey
static const char sBase64Chars []
 Set of base64 chars. More...
 

Detailed Description

Rsa private/public keypairs.

Constructor & Destructor Documentation

Constructor.

Destructor.

Member Function Documentation

int generateKey ( )
virtual

Generates a new RSA private/public key pair.

Returns
0 on success, non-0 error code on failure

Implements UtlCryptoKey.

int importFromFile ( const char *  pFilename)
virtual

Imports a key from the given file.

Returns
0 on success, non-0 error code on failure

Reimplemented from UtlCryptoKey.

int getMaxEncryptedSize ( int  srcLen) const
virtual

Returns the max encrypted size of srcLen bytes from encrypt()

Implements UtlCryptoKey.

int encrypt ( const unsigned char *  pSrc,
int  srcLen,
unsigned char *  pDest,
int *  pDestLen 
) const
virtual

Encrypts the given source data with the current key.

Parameters
[in]pSrc- Source data
[in]srcLen- Source data len
[out]pDest- Destination buffer
[in,out]pDestLen- Size of destination buffer and actual encrypted size after operation
Returns
Length of the encrypted data (0 on error)

Implements UtlCryptoKey.

int getMaxDecryptedSize ( int  srcLen) const
virtual

Returns the max decrypted size of srcLen bytes from decrypt()

Implements UtlCryptoKey.

int decrypt ( const unsigned char *  pSrc,
int  srcLen,
unsigned char *  pDest,
int *  pDestLen 
) const
virtual

Decrypts the given source data with the current key.

Parameters
[in]pSrc- Source data
[in]srcLen- Source data len
[out]pDest- Destination buffer
[in,out]pDestLen- Size of destination buffer and actual decrypted size after operation
Returns
Length of the decrypted data (0 on error)

Implements UtlCryptoKey.

int getMaxSignatureSize ( int  srcLen) const
virtual

Returns the max size of a signature that sign() will return.

Reimplemented from UtlCryptoKey.

int sign ( const unsigned char *  pSrc,
int  srcLen,
unsigned char *  pDest,
int *  pDestLen 
) const
virtual

Signs source data.

Parameters
[in]pSrc- Source data
[in]srcLen- Source data len
[out]pDest- Destination buffer
[in,out]pDestLen- Size of destination buffer and actual decrypted size after operation
Returns
Length of the decrypted data (0 on error)

Reimplemented from UtlCryptoKey.

int verify ( const unsigned char *  pSrc,
int  srcLen,
const unsigned char *  pSig,
int  sigLen 
) const
virtual

Verifies that the signature is valid for the source data.

Parameters
[in]pSrc- Source data
[in]srcLen- Source data len
[in]pSig- Signature data
[in]sigLen- Signature data len
Returns
0 if signature is valid, non-0 if not

Reimplemented from UtlCryptoKey.

int encryptPrivate ( const unsigned char *  pSrc,
int  srcLen,
unsigned char *  pDest,
int *  pDestLen 
) const

Decrypts the given source data with the current PRIVATE key.

Parameters
[in]pSrc- Source data
[in]srcLen- Source data len
[out]pDest- Destination buffer
[in,out]pDestLen- Size of destination buffer and actual decrypted size after operation
Returns
Length of the encrypted data (0 on error)
int decryptPrivate ( const unsigned char *  pSrc,
int  srcLen,
unsigned char *  pDest,
int *  pDestLen 
) const

Decrypts the given source data with the current PRIVATE key.

Parameters
[in]pSrc- Source data
[in]srcLen- Source data len
[out]pDest- Destination buffer
[in,out]pDestLen- Size of destination buffer and actual decrypted size after operation
Returns
Length of the decrypted data (0 on error)
int encryptPublic ( const unsigned char *  pSrc,
int  srcLen,
unsigned char *  pDest,
int *  pDestLen 
) const

Encrypts the given source data with the current PUBLIC key.

Parameters
[in]pSrc- Source data
[in]srcLen- Source data len
[out]pDest- Destination buffer
[in,out]pDestLen- Size of destination buffer and actual decrypted size after operation
Returns
Length of the encrypted data (0 on error)
int decryptPublic ( const unsigned char *  pSrc,
int  srcLen,
unsigned char *  pDest,
int *  pDestLen 
) const

Decrypts the given source data with the current PUBLIC key.

Parameters
[in]pSrc- Source data
[in]srcLen- Source data len
[out]pDest- Destination buffer
[in,out]pDestLen- Size of destination buffer and actual decrypted size after operation
Returns
Length of the decrypted data (0 on error)
UtlString output ( ) const
virtual

Get humane-readable describe.

Reimplemented from UtlCryptoKey.