sipxportlib  Version 3.3
List of all members
UtlCryptoKeySym Class Reference

A symmetric key implementation of UtlCryptoKey. More...

#include <UtlCryptoKeySym.h>

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

Public Member Functions

Creators
 UtlCryptoKeySym ()
 Constructor. More...
 
 ~UtlCryptoKeySym ()
 Destructor. More...
 
Manipulators
int generateKey ()
 Generates a new key. More...
 
int loadBinaryKey (const unsigned char *pSrc, int srcLen)
 Loads a binary key value. More...
 
UtlCryptoDatagetBinaryKey () const
 Retrieves a binary key value (for later use by loadBinaryKey) 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...
 
Inquiry
int getTotalKeyLength ()
 Return total key length. More...
 
UtlBoolean getBinaryKey (char *buffer, int bufferLength)
 Dump key to memeory. More...
 
UtlString output () const
 Get humane-readable describe. More...
 
- Public Member Functions inherited from UtlCryptoKey
 UtlCryptoKey ()
 Constructor. More...
 
virtual ~UtlCryptoKey ()
 Destructor. More...
 
virtual int importFromFile (const char *pFilename)
 Imports a key from the given file. 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 int getMaxSignatureSize (int srcLen) const
 Signing & verifying. More...
 
virtual int sign (const unsigned char *pSrc, int srcLen, unsigned char *pDest, int *pDestLen) const
 Signs source data. More...
 
virtual UtlCryptoDatasign (const unsigned char *pSrc, int srcLen) const
 Signs source data. More...
 
virtual 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...
 
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

A symmetric key implementation of UtlCryptoKey.

Constructor & Destructor Documentation

Constructor.

Destructor.

Member Function Documentation

int generateKey ( )
virtual

Generates a new key.

: Don't use it due the not strong algorithm, for testing only

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

Implements UtlCryptoKey.

int loadBinaryKey ( const unsigned char *  pSrc,
int  srcLen 
)
virtual

Loads a binary key value.

Returns
0 on success

Reimplemented from UtlCryptoKey.

UtlCryptoData* getBinaryKey ( ) const
virtual

Retrieves a binary key value (for later use by loadBinaryKey)

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 getTotalKeyLength ( )

Return total key length.

UtlBoolean getBinaryKey ( char *  buffer,
int  bufferLength 
)

Dump key to memeory.

UtlString output ( ) const
virtual

Get humane-readable describe.

Reimplemented from UtlCryptoKey.