CPKIFKeyMaterial Class Reference

#include <PKIFKeyMaterial.h>

Inheritance diagram for CPKIFKeyMaterial:

Inheritance graph
[legend]
Collaboration diagram for CPKIFKeyMaterial:

Collaboration graph
[legend]

List of all members.


Detailed Description

This class is a simple container used to convey plaintext key material. The class can store symmetric key material and public key certificates. Additionally, "working" parameters are stored in CPKIFKeyMaterial objects during path validation.

TSP-enforcing: No

Definition at line 25 of file PKIFKeyMaterial.h.


Public Member Functions

 CPKIFKeyMaterial (void)
virtual ~CPKIFKeyMaterial (void)
bool ContainsSymmetricKeyMaterial () const
bool ContainsCertificate () const
bool ContainsPublicKeyMaterial () const
void SetSubjectPublicKeyInfo (const CPKIFSubjectPublicKeyInfoPtr &spki)
CPKIFSubjectPublicKeyInfoPtr GetSubjectPublicKeyInfo () const
void SetCertificate (const unsigned char *cert, int certLen)
void GetCertificate (unsigned char *cert, int *certLen) const
const unsigned char * GetCertificate () const
int GetCertificateLength () const
void SetWorkingParameters (CPKIFAlgorithmIdentifierPtr &algID)
CPKIFAlgorithmIdentifierPtr GetWorkingParameters () const
void SetIV (const unsigned char *key, int keyLen)
void GetIV (unsigned char *key, int *keyLen) const
const unsigned char * GetIV () const
void SetMode (PKIFCRYPTO::SYMKEY_MODE mode)
PKIFCRYPTO::SYMKEY_MODE GetMode () const
void SetSymmetricKey (const unsigned char *key, int keyLen)
void GetSymmetricKey (unsigned char *key, int *keyLen, PKIFCRYPTO::SYMKEY_ALG *alg) const
const unsigned char * GetSymmetricKey () const
int GetSymmetricKeyLength () const
PKIFCRYPTO::SYMKEY_ALG GetSymmetricKeyAlgorithm () const
void SetSymmetricKeyAlgorithm (PKIFCRYPTO::SYMKEY_ALG alg)

Static Public Member Functions

static CPKIFKeyMaterialPtr CreateWithSymmetricKey (const CPKIFKeyMaterialPtr &km)

Constructor & Destructor Documentation

CPKIFKeyMaterial::CPKIFKeyMaterial ( void   ) 

Interface: External

This function is the default constructor for CPKIFKeyMaterial objects.

Returns:
None

Definition at line 154 of file CACKeyMaterial.cpp.

References PKIFCRYPTO::ECB, LOG_STRING_DEBUG, and TOOLKIT_CRYPTO_KEYMATERIAL.

Referenced by CreateWithSymmetricKey().

CPKIFKeyMaterial::~CPKIFKeyMaterial ( void   )  [virtual]

Interface: External

This function is the default destructor for CPKIFKeyMaterial objects.

Returns:
None

Definition at line 177 of file CACKeyMaterial.cpp.

References LOG_STRING_DEBUG, and TOOLKIT_CRYPTO_KEYMATERIAL.


Member Function Documentation

bool CPKIFKeyMaterial::ContainsSymmetricKeyMaterial (  )  const

bool CPKIFKeyMaterial::ContainsCertificate (  )  const

Interface: External

This function is a convenience function for use in determining the type of contents stored in a CPKIFKeyMaterial object.

Returns:
True if the object contains a public key certificate (i.e. calls to GetCertificate return a non-NULL result); false otherwise.

Definition at line 237 of file CACKeyMaterial.cpp.

Referenced by _Verify(), CPKIFCAPIRaw::CryptInit(), CPKIFNSSRaw::SupportsAlgorithm(), CPKIFCNGCAPIRaw::SupportsAlgorithm(), and CPKIFCAPIRaw::SupportsAlgorithm().

bool CPKIFKeyMaterial::ContainsPublicKeyMaterial (  )  const

Interface: External

This function returns true if this CPKIFKeyMaterial object contains Subject Public Key Information

Returns:
True if Subject Public Key Information present. false otherwise

Definition at line 501 of file CACKeyMaterial.cpp.

Referenced by _Verify().

void CPKIFKeyMaterial::SetSubjectPublicKeyInfo ( const CPKIFSubjectPublicKeyInfoPtr &  spki  ) 

Interface: External

This function is used to set SubjectPublicKeyInfo assosiated with this object

Returns:
None
Parameters:
spki  [in] A refernce to a smart pointer to CPKIFSubjectPublicKeyInfo object

Definition at line 512 of file CACKeyMaterial.cpp.

Referenced by CPKIFCryptoPPKeyMaterial::InitWithSPKI(), PathSigChecker(), and CPKIFCryptoPPKeyMaterial::SetRawSPKI().

CPKIFSubjectPublicKeyInfoPtr CPKIFKeyMaterial::GetSubjectPublicKeyInfo (  )  const

Interface: External

This function is used to get SubjectPublicKeyInfo assosiated with this object

Returns:
A refernce to a smart pointer to CPKIFSubjectPublicKeyInfo object

Definition at line 525 of file CACKeyMaterial.cpp.

Referenced by _Verify(), CPKIFBCryptPublicKey::Initialize(), CPKIFCryptoPPKeyMaterial::InitWithKeyMaterial(), and CPKIFCryptoPPRaw::SupportsAlgorithm().

void CPKIFKeyMaterial::SetCertificate ( const unsigned char *  cert,
int  certLen 
)

Interface: External

This function is used to store a DER encoded public key certificate in a CPKIFKeyMaterial object.

Returns:
None
Exceptions:
CPKIFCryptoException(COMMON_INVALID_INPUT) 
Parameters:
cert  [in] Buffer containing a DER encoded X.509 public key certificate
certLen  [in] Integer indicating the length of the cert parameter

Definition at line 250 of file CACKeyMaterial.cpp.

References COMMON_INVALID_INPUT, LOG_STRING_DEBUG, TOOLKIT_CRYPTO, and TOOLKIT_CRYPTO_KEYMATERIAL.

Referenced by PathSigChecker(), and VerifyCounterSignatures().

void CPKIFKeyMaterial::GetCertificate ( unsigned char *  cert,
int *  certLen 
) const

Interface: External

This function can be used to retrieve public key certificate values from a CPKIFKeyMaterial object. It copies the stored value into the buffer passed by the application. If the buffer is NULL the length of the stored certificate value is returned via the certLen parameter to permit the application to allocate a buffer of sufficient size.

get the length of the certificate using GetCertificateLength int newCertLen = key.GetCertificateLength();

or get the length by invoking GetCertificate with a NULL first parameter key.GetCertificate(NULL, &newCertLen);

allocate a buffer to receive the certificate unsigned char* newCertBuf = new unsigned char[newCertLen];

get a copy of the certificate value key.GetCertificate(newCertBuf, &newCertLen);

delete[] newCertBuf;

Returns:
None
Exceptions:
CPKIFCryptoException(COMMON_INVALID_INPUT) 
Parameters:
cert  [in/out] Buffer of sufficient size to receive the stored certificate value or NULL, if querying for the length of the stored certificate value
certLen  [in/out] (In) Pointer to an integer indicating the size of the cert parameter. (Out) Used to return the size of the stored certificate value.

Definition at line 297 of file CACKeyMaterial.cpp.

References COMMON_INVALID_INPUT, LOG_STRING_DEBUG, TOOLKIT_CRYPTO, and TOOLKIT_CRYPTO_KEYMATERIAL.

Referenced by _Verify(), CPKIFCAPIRaw::CryptInit(), CPKIFBCryptPublicKey::Initialize(), CPKIFCryptoPPKeyMaterial::InitWithKeyMaterial(), CPKIFNSSRaw::SupportsAlgorithm(), CPKIFCNGCAPIRaw::SupportsAlgorithm(), and CPKIFCAPIRaw::SupportsAlgorithm().

const unsigned char * CPKIFKeyMaterial::GetCertificate (  )  const

Interface: External

This function can be used to retrieve public key certificate values from a CPKIFKeyMaterial object. It returns a pointer to the internal buffer held by the object and is thus valid only for the life of the certificate property of the CPKIFKeyMaterial object, i.e. until the object is destroyedor the certificate property is re-set via a call to SetCertificate.

Returns:
A pointer to a buffer

Definition at line 327 of file CACKeyMaterial.cpp.

int CPKIFKeyMaterial::GetCertificateLength (  )  const

Interface: External

This function can be used to determine the size of the value stored in the certificate property of a CPKIFKeyMaterial object. Alternatively, the length can be determined by invoking GetCertificate with a NULL first parameter.

Returns:
Integer indicating the size of the value stored in the certificate property

Definition at line 56 of file CACKeyMaterial.cpp.

Referenced by _Verify(), CPKIFCAPIRaw::CryptInit(), CPKIFBCryptPublicKey::Initialize(), CPKIFCryptoPPKeyMaterial::InitWithKeyMaterial(), CPKIFNSSRaw::SupportsAlgorithm(), CPKIFCNGCAPIRaw::SupportsAlgorithm(), and CPKIFCAPIRaw::SupportsAlgorithm().

void CPKIFKeyMaterial::SetWorkingParameters ( CPKIFAlgorithmIdentifierPtr &  algID  ) 

Interface: External

This function is invoked by path processing functionality to return the working parameters resulting from a path validation operation.

Returns:
Parameters:
algID  [in] Reference to a smart pointer to a CPKIFAlgorithmIdentifier object containing the parameters of interest

Definition at line 68 of file CACKeyMaterial.cpp.

Referenced by CPKIFCryptoPPKeyMaterial::InitWithKeyMaterial(), PathSigChecker(), and VerifyCounterSignatures().

CPKIFAlgorithmIdentifierPtr CPKIFKeyMaterial::GetWorkingParameters (  )  const

Interface: External

This function returns a smart pointer to a CPKIFAlgorithmIdentifier object if working parmeters have been specified via a call to SetWorkingParameters and NULL otherwise.

Returns:
A smart pointer to a CPKIFAlgorithmIdentifier object.

Definition at line 82 of file CACKeyMaterial.cpp.

Referenced by _Verify(), CPKIFBCryptPublicKey::Initialize(), CPKIFCryptoPPKeyMaterial::InitWithKeyMaterial(), and CPKIFCryptoPPKeyMaterial::InitWithSPKI().

void CPKIFKeyMaterial::SetIV ( const unsigned char *  iv,
int  ivLen 
)

Interface: External

This function is used to set the initialization vector property.

Returns:
None
Exceptions:
CPKIFCryptoException(COMMON_INVALID_INPUT) 
Parameters:
iv  [in] Pointer to array of characters containing an initialization vector
ivLen  [in] Integer containing the length of the key parameter

Definition at line 421 of file CACKeyMaterial.cpp.

References COMMON_INVALID_INPUT, LOG_STRING_DEBUG, TOOLKIT_CRYPTO, and TOOLKIT_CRYPTO_KEYMATERIAL.

void CPKIFKeyMaterial::GetIV ( unsigned char *  iv,
int *  ivLen 
) const

Interface: External

This function can be used to retrieve initialization vector values from a CPKIFKeyMaterial object. It takes two parameters copies the stored value into the buffer passed by the application. If the buffer is NULL the length of the stored IV value is returned via the ivLen parameter to permit the application to allocate a buffer of sufficient size.

Returns:
None
Exceptions:
CPKIFCryptoException(COMMON_INVALID_INPUT) 
Parameters:
iv  [in/out] Pointer to a buffer to receive the value stored in the initialization vector property
ivLen  [in/out] (In) Pointer to an integer indicating the size of the iv parameter. (Out) Used to return the size of the stored initialization vector value.

Definition at line 455 of file CACKeyMaterial.cpp.

References COMMON_INVALID_INPUT, LOG_STRING_DEBUG, TOOLKIT_CRYPTO, and TOOLKIT_CRYPTO_KEYMATERIAL.

Referenced by CPKIFNSSRaw::CryptInit(), CPKIFNSSAesKeyWrap::CryptInit(), CPKIFCryptoPPRaw::CryptInit(), CPKIFCNGCAPIRaw::CryptInit(), and CPKIFCAPIRaw::CryptInit().

const unsigned char * CPKIFKeyMaterial::GetIV (  )  const

Interface: External

This function can be used to retrieve initialization vector values from a CPKIFKeyMaterial object. It returns a pointer to the internal buffer held by the object and is thus valid only for the life of the IV property of the CPKIFKeyMaterial object, i.e. until the object is destroyed or the IV property is re-set via a call to SetIV.

Returns:
A pointerto the internal buffer

Definition at line 489 of file CACKeyMaterial.cpp.

void CPKIFKeyMaterial::SetMode ( PKIFCRYPTO::SYMKEY_MODE  mode  ) 

Interface: External

This function is used to specify the mode to use when exercising the key material associated with a CPKIFKeyMaterial object. By default, the value of the mode property is ECB.

Returns:
None

Definition at line 94 of file CACKeyMaterial.cpp.

PKIFCRYPTO::SYMKEY_MODE CPKIFKeyMaterial::GetMode (  )  const

Interface: External

This function is used to retrieve the value of the mode property. By default, the value of the mode property is ECB.

Returns:

Definition at line 105 of file CACKeyMaterial.cpp.

Referenced by CPKIFNSSRaw::CryptInit(), CPKIFCryptoPPRaw::CryptInit(), CPKIFCNGCAPIRaw::CryptInit(), and CPKIFCAPIRaw::CryptInit().

void CPKIFKeyMaterial::SetSymmetricKey ( const unsigned char *  key,
int  keyLen 
)

Interface: External

This function is used to set the value of the symmetric key property.

Returns:
None
Exceptions:
CPKIFCryptoException(COMMON_INVALID_INPUT) 
Parameters:
key  [in] Buffer containing symmetric key value
keyLen  [in] Integer indicating the size of the key parameter

Definition at line 340 of file CACKeyMaterial.cpp.

References COMMON_INVALID_INPUT, LOG_STRING_DEBUG, TOOLKIT_CRYPTO, and TOOLKIT_CRYPTO_KEYMATERIAL.

void CPKIFKeyMaterial::GetSymmetricKey ( unsigned char *  key,
int *  keyLen,
PKIFCRYPTO::SYMKEY_ALG alg 
) const

Interface: External

This function can be used to retrieve symmetric key values from a CPKIFKeyMaterial object. It takes three parameters copies the stored value into the buffer passed by the application. If the buffer is NULL the length of the stored symmetric key value is returned via the ivLen parameter to permit the application to allocate a buffer of sufficient size.

Returns:
None
Exceptions:
CPKIFCryptoException(COMMON_INVALID_INPUT) 
Parameters:
key  [in/out] Pointer to a buffer to receive the value stored in the symmetric key property or NULL if querying for the length of the value stored in the symmetric key property
keyLen  [in/out] (In) Pointer to an integer indicating the size of the key parameter. (Out) Used to return the size of the stored symmetric key value.
alg  [out] Pointer to a SYMKEY_ALG to receive the algorithm associated with the symmetric key property

Definition at line 372 of file CACKeyMaterial.cpp.

References COMMON_INVALID_INPUT, LOG_STRING_DEBUG, TOOLKIT_CRYPTO, and TOOLKIT_CRYPTO_KEYMATERIAL.

Referenced by CPKIFNSSRaw::CryptInit(), CPKIFNSSAesKeyWrap::CryptInit(), CPKIFCryptoPPRaw::CryptInit(), CPKIFCNGCAPIRaw::CryptInit(), CPKIFCAPIRaw::CryptInit(), CPKIFNSSRaw::HMACInit(), CPKIFCryptoPPRaw::HMACInit(), and CPKIFCNGCAPIRaw::HMACInit().

const unsigned char * CPKIFKeyMaterial::GetSymmetricKey (  )  const

Interface: External

This function can be used to retrieve symmetric key values from a CPKIFKeyMaterial object. It returns a pointer to the internal buffer held by the object and is thus valid only for the life of the symmetric key property of the CPKIFKeyMaterial object, i.e. until the object is destroyed or the symmetric key property is re-set via a call to SetSymmetricKey.

Returns:
A pointer to the internal buffer

Definition at line 408 of file CACKeyMaterial.cpp.

int CPKIFKeyMaterial::GetSymmetricKeyLength (  )  const

Interface: External

This function can be used to retrieve the length of the value stored in the symmetric key property.

Returns:
Integer indicating the size of the value stored in the symmetric key property.

Definition at line 116 of file CACKeyMaterial.cpp.

Referenced by CPKIFNSSRaw::CryptInit(), CPKIFNSSAesKeyWrap::CryptInit(), CPKIFCryptoPPRaw::CryptInit(), CPKIFCAPIRaw::CryptInit(), CPKIFNSSRaw::HMACInit(), CPKIFCryptoPPRaw::HMACInit(), and CPKIFCNGCAPIRaw::HMACInit().

PKIFCRYPTO::SYMKEY_ALG CPKIFKeyMaterial::GetSymmetricKeyAlgorithm (  )  const

Interface: External

This function is used to get symmetric key algorithm id from the CPKIFKeyMaterial object.

Returns:
This function returns an enum representation of the symmetric key algorithm set on the CPKIFKeyMaterial object via a call to SetSymmetricKeyAlgorithm. The value is defined by the SYMKEY_ALG enumeration.

Definition at line 128 of file CACKeyMaterial.cpp.

Referenced by CPKIFNSSAesKeyWrap::CryptInit(), CPKIFCryptoPPRaw::CryptInit(), CPKIFCNGCAPIRaw::CryptInit(), CPKIFCAPIRaw::CryptInit(), GetCNGSymAlgorithm(), GetSymAlgorithm(), CPKIFNSSAesKeyWrap::SupportsAlgorithm(), and CPKIFCryptoPPRaw::SupportsAlgorithm().

void CPKIFKeyMaterial::SetSymmetricKeyAlgorithm ( PKIFCRYPTO::SYMKEY_ALG  alg  ) 

Interface: External

This function can be used to set the value of the symmetric key algorithm property.

Returns:
None
Parameters:
alg  [in] SYMKEY_ALG value indicating the the algorithm that should be associated with the key stored in the symmetric key property

Definition at line 139 of file CACKeyMaterial.cpp.

CPKIFKeyMaterialPtr CPKIFKeyMaterial::CreateWithSymmetricKey ( const CPKIFKeyMaterialPtr &  km  )  [static]

Interface: External

Create a new CPKIFKeyMaterial object based with the symmetric key from km

Returns:
A smart pointer to the new object
Parameters:
km  [IN] key material to copy into the new object

Definition at line 537 of file CACKeyMaterial.cpp.

References COMMON_INVALID_INPUT, CPKIFKeyMaterial(), and TOOLKIT_CRYPTO.

Referenced by UnwrapSymmKey(), and WrapSymmKey().


The documentation for this class was generated from the following files:

Generated on Mon Nov 15 11:20:23 2010 for PublicKeyInfrastructureFramework(PKIF) by  doxygen 1.5.6