PrivatePKIFCMSUtils.h File Reference


Detailed Description

Subsystem: Cryptographic Message Syntax (PKIFCMS)

Module: Miscellaneous

Id
PrivatePKIFCMSUtils.h 10065 2009-06-11 19:37:06Z cwallace

Definition in file PrivatePKIFCMSUtils.h.

#include "PKIFdll.h"
#include "CryptographicMessageSyntax2004.h"

Include dependency graph for PrivatePKIFCMSUtils.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 FD_SMART_PTR (CPKIFOID)
 FD_SMART_PTR (CPKIFSignerInfo)
 FD_LIST_PTR (CPKIFAttribute)
 FD_SMART_PTR (CPKIFName)
 FD_SMART_PTR (CPKIFSubjectKeyIdentifier)
 FD_SMART_PTR (IPKIFCryptoKeyIDOperations)
 FD_SMART_PTR (CPKIFCredential)
 FD_SMART_PTR (CPKIFKeyMaterial)
 FD_SMART_PTR (IPKIFCryptoKeyAgree)
 FD_SMART_PTR (IPKIFCryptoRawOperations)
 FD_SMART_PTR (CPKIFKEKRecipInfoDetails)
 FD_MC_PTR ()
void GetSignerInfo (CACCMSSignerInfo *tmpSignerInfo, CPKIFSignerInfoPtr &siPos, unsigned char *hashResult, int nHashResult, IPKIFMediatorPtr m, CPKIFOIDPtr &eContentType, PKIFCRYPTO::HASH_ALG hashAlg, bool useSKIDIfPresent=true)
HashInfoComputeSignedAttrHash (CACCMSSignerInfo *si, IPKIFCryptoMisc *cMisc)
bool CompareHashes (HashInfo *hi2, CACCMSSignerInfo *si)
void SetupAttributesInObjectiveStructure (CPKIFAttributeList &attrs, DList &objAttrs)
void AddSignedAttributes (unsigned char *hashResult, int nHashResult, CPKIFOIDPtr &eContentType, CPKIFAttributeList &sas)
void EncodeDSASignature (unsigned char *sig, int nSigLen, unsigned char **sigData, int *numocts)
bool RIDMatch (CACCMSRecipientIdentifier *rid, CPKIFNamePtr &issuer, const char *serial, CPKIFSubjectKeyIdentifierPtr &skid)
CPKIFKeyMaterialPtr GetSymmetricKey (CPKIFCredentialPtr &cred, IPKIFCryptoKeyIDOperations *cKeyID, CACCMSRecipientInfos *ris, IPKIFCryptoKeyAgree *ka=NULL, IPKIFCryptoRawOperations *cRaw=NULL, CACCMSOriginatorInfo *oi=NULL)
CPKIFKeyMaterialPtr GetSymmetricKey (const CPKIFKEKRecipInfoDetailsPtr &kek, IPKIFCryptoRawOperations *cKeyID, CACCMSRecipientInfos *ris)
CPKIFCredentialPtr AutoDiscoverDecryptionKey (IPKIFCryptoKeyIDOperations *cKeyID, CACCMSRecipientInfos *ris)
void EncodeIVAsOctetString (unsigned char *iv, int ivLen, unsigned char **encodedIV, int *encodedIVLen)
void PopulateKARIDFromKeyMaterial (CACCMSKeyAgreeRecipientIdentifier *rid, CPKIFKeyMaterialPtr &km)
CPKIFAlgorithmGetCACHashAlg (CACX509V3AlgorithmIdentifier *alg)
CPKIFAlgorithmGetCACSymAlg (CACX509V3AlgorithmIdentifier *alg)


Function Documentation

void AddSignedAttributes ( unsigned char *  hashResult,
int  nHashResult,
CPKIFOIDPtr &  eContentType,
CPKIFAttributeList sas 
)

Interface: Subsystem

This function adds signed attributes

Returns:
None
Parameters:
hashResult  [in] Buffer containing hash result
nHashResult  [in] Hash result length
eContentType  [in] A smart poiter to CPKIFOID object
sas  [out] Attribute list to which the signed attributes are added

Definition at line 312 of file CACCMSUtils.cpp.

References g_contentTypeAttribute, g_data, g_messageDigestAttribute, and AttrMatch::SetRHS().

Referenced by GetSignerInfo().

CPKIFCredentialPtr AutoDiscoverDecryptionKey ( IPKIFCryptoKeyIDOperations cKeyID,
CACCMSRecipientInfos *  ris 
)

Interface: Subsystem

This function discovers the decryption key

Returns:
A smart pointer to CPKIFCredential object
Parameters:
cKeyID  [in] A pointer to IPKIFCryptoKeyIDOperations interface
ris  [in] Pointer to CACCMSRecipientInfos object

Definition at line 1581 of file CACCMSUtils.cpp.

References IPKIFCryptoKeyIDOperations::GetKeyList(), PKIFCRYPTO::KeyEncipherment, and RIDMatch().

Referenced by CPKIFEnvelopedData::Decrypt().

bool CompareHashes ( HashInfo hi2,
CACCMSSignerInfo *  si 
)

Interface: Subsystem

This is a helper function that compares 2 hashes

Return values:
True if hashes are the same
False if hashes are not the same
Exceptions:
CPKIFMessageException(ASN1_DECODE_ERROR) 
Parameters:
hi2  [in] Pointer to HashInfo object
si  [in] Poiter to CACCMSSignerInfo object

Definition at line 909 of file CACCMSUtils.cpp.

References ASN1_DECODE_ERROR, CACASNWRAPPER_CREATE, g_messageDigestAttribute, HashInfo::m_hashAlg, HashInfo::m_hashResult, and TOOLKIT_MESSAGE_ASN.

Referenced by VerifyCounterSignatures().

HashInfo* ComputeSignedAttrHash ( CACCMSSignerInfo *  si,
IPKIFCryptoMisc cMisc 
)

Interface: Subsystem

This function computes signed attribute hash

Returns:
Pointer to HashInfo object
Parameters:
si  [in] Pointer to CACCMSSignerInfo object
cMisc  [in] Pointer to IPKIFCryptoMisc interface

Definition at line 842 of file CACCMSUtils.cpp.

References GetCACHashAlg(), CPKIFAlgorithm::HashAlg(), IPKIFCryptoMisc::HashFinal(), IPKIFCryptoMisc::HashInit(), IPKIFCryptoMisc::HashUpdate(), HashInfo::m_hashAlg, HashInfo::m_hashResult, and MAXHASH.

Referenced by GetSignerInfo(), and VerifyCounterSignatures().

void EncodeDSASignature ( unsigned char *  sig,
int  nSigLen,
unsigned char **  sigData,
int *  numocts 
)

Interface: Subsystem

This function encodes DSA signature

Returns:
None
Exceptions:
CPKIFMessageException(COMMON_INVALID_INPUT) 
Parameters:
sig  [in]Buffer containing the signature to encode
nSigLen  [in] Length of the buffer containing the signature to encode
sigData  [out] Buffer containing the resulting signature
numocts  [out] Length of the resulting signature

Definition at line 258 of file CACCMSUtils.cpp.

References btoa(), CACASNWRAPPER_CREATE, COMMON_INVALID_INPUT, MAXHASH, and TOOLKIT_MESSAGE_ASN.

Referenced by GetSignerInfo().

void EncodeIVAsOctetString ( unsigned char *  iv,
int  ivLen,
unsigned char **  encodedIV,
int *  encodedIVLen 
)

Interface: Subsystem

This is a helper function that encodes an IV as an octet string

Returns:
None
Exceptions:
CPKIFMessageException(ASN1_ENCODE_ERROR) 
Parameters:
iv  [in] Buffer that contains the IV
ivLen  [in] IV length
encodedIV  [out] Buffer that contains the encoded IV
encodedIVLen  [out] Encoded IN length

Definition at line 1654 of file CACCMSUtils.cpp.

References ASN1_ENCODE_ERROR, and TOOLKIT_MESSAGE_ASN.

FD_LIST_PTR ( CPKIFAttribute   ) 

FD_MC_PTR (  ) 

FD_SMART_PTR ( CPKIFKEKRecipInfoDetails   ) 

FD_SMART_PTR ( IPKIFCryptoRawOperations   ) 

FD_SMART_PTR ( IPKIFCryptoKeyAgree   ) 

FD_SMART_PTR ( CPKIFKeyMaterial   ) 

FD_SMART_PTR ( CPKIFCredential   ) 

FD_SMART_PTR ( IPKIFCryptoKeyIDOperations   ) 

FD_SMART_PTR ( CPKIFSubjectKeyIdentifier   ) 

FD_SMART_PTR ( CPKIFName   ) 

FD_SMART_PTR ( CPKIFSignerInfo   ) 

FD_SMART_PTR ( CPKIFOID   ) 

CPKIFAlgorithm* GetCACHashAlg ( CACX509V3AlgorithmIdentifier *  alg  ) 

Interface: Subsystem

This function takes a pointer to a CACX509V3AlgorithmIdentifier object and based on that object returns a PKIFAlgorithm object describing the properties of the hash alg

Returns:
pointer to a CPKIFAlgorithm object if successful, NULL otherwise
Parameters:
alg  [in] A pointer to CACX509V3AlgorithmIdentifier object

Definition at line 192 of file CACCMSUtils.cpp.

References CPKIFAlgorithm::GetAlg(), and CPKIFAlgorithm::OID().

CPKIFAlgorithm* GetCACSymAlg ( CACX509V3AlgorithmIdentifier *  alg  ) 

Interface: Subsystem

This function retrives symmetric algorithm

Returns:
True if successful, false otherwise
Parameters:
alg  [in] A pointer to CACX509V3AlgorithmIdentifier object

Definition at line 213 of file CACCMSUtils.cpp.

References CPKIFAlgorithm::GetAlg(), and CPKIFAlgorithm::OID().

Referenced by CPKIFEnvelopedData::Decrypt().

void GetSignerInfo ( CACCMSSignerInfo *  tmpSignerInfo,
CPKIFSignerInfoPtr &  siPos,
unsigned char *  hashResult,
int  nHashResult,
IPKIFMediatorPtr  m,
CPKIFOIDPtr &  eContentType,
PKIFCRYPTO::HASH_ALG  hashAlg,
bool  useSKIDIfPresent 
)

Interface: Subsystem

Helper function that retrives signer info

Returns:
None
Exceptions:
CPKIFMessageException(COMMON_UNSUPPORTED_CHOICE) 
CPKIFMessageException(COMMON_UNSUPPORTED_ALG) 
Parameters:
tmpSignerInfo  [in] Pointer to CACCMSSignerInfo object
siPos  [out] Smart pointer to CPKIFSignerInfo object
hashResult  [in] Buffer containing hash result
nHashResult  [in] Hash result length
m  [in] Poiter to a mediator object
eContentType  [in] A smart poiter to CPKIFOID object which indicates content type
hashAlg  [in] Hash algorithm itentifier
useSKIDIfPresent  [in] Boolean value

Definition at line 471 of file CACCMSUtils.cpp.

References AddSignedAttributes(), CACASNWRAPPER_CREATE, COMMON_UNSUPPORTED_ALG, COMMON_UNSUPPORTED_CHOICE, ComputeSignedAttrHash(), ConvertStringToASN1OBJID(), CopyName(), CopyOID(), CPKIFAlgorithm::DigestSize(), DSA_CLASS, ECDSA_CLASS, EncodeDSASignature(), g_dsaWithSHA1, g_ecdsa_sha1, g_ecdsa_sha224, g_ecdsa_sha256, g_ecdsa_sha384, g_ecdsa_sha512, g_md5WithRSAEncryption, g_sha1WithRSAEncryption, g_sha224WithRSAEncryption, g_sha256WithRSAEncryption, g_sha384WithRSAEncryption, g_sha512WithRSAEncryption, CPKIFAlgorithm::GetAlg(), GetAlgClass(), CPKIFSignerInfo::ISSUERANDSERIAL, HashInfo::m_hashAlg, HashInfo::m_hashResult, PKIFCRYPTO::MD5, MSG_SIGNATURE_GENERATION_ERROR, nullParams, RSA_CLASS, SetupAttributesInObjectiveStructure(), PKIFCRYPTO::SHA1, PKIFCRYPTO::SHA224, PKIFCRYPTO::SHA256, PKIFCRYPTO::SHA384, PKIFCRYPTO::SHA512, IPKIFCryptoKeyIDOperations::Sign(), CPKIFSignerInfo::SKID, TOOLKIT_MESSAGE, and TOOLKIT_MESSAGE_ASN.

Referenced by Countersign().

CPKIFKeyMaterialPtr GetSymmetricKey ( const CPKIFKEKRecipInfoDetailsPtr &  kek,
IPKIFCryptoRawOperations cKeyID,
CACCMSRecipientInfos *  ris 
)

Interface: Subsystem

Given a credential, a crypto interface pointer and a recipient bag find the recipient info that matches the credential and return decrypted key material.

Returns:
A smart ponter to CPKIFKeyMaterial object
Exceptions:
CPKIFMessageException(ASN1_DECODE_ERROR) 
Parameters:
kek  [in] A smart pointer to CPKIFKEKRecipInfoDetails object
cKeyID  [in] Pointer to IPKIFCryptoRawOperations interface
ris  [in] Pointer to CACCMSRecipientInfos object

Definition at line 1135 of file CACCMSUtils.cpp.

References ASN1_DECODE_ERROR, IPKIFCryptoRawOperations::Decrypt(), and TOOLKIT_MESSAGE_ASN.

Referenced by CPKIFEnvelopedData::Decrypt().

CPKIFKeyMaterialPtr GetSymmetricKey ( CPKIFCredentialPtr &  cred,
IPKIFCryptoKeyIDOperations cKeyID,
CACCMSRecipientInfos *  ris,
IPKIFCryptoKeyAgree ka,
IPKIFCryptoRawOperations cRaw,
CACCMSOriginatorInfo *  oi 
)

Interface: Subsystem

This is a helper function that retrives symmmetric key. At present, this function supports ktri and kari. For kekri, use the other GetSymmetricKey call.

Returns:
A smart pointer to CPKIFKeyMaterial object
Parameters:
cred  [in] A smart pointer to CPKIFCredential object
cKeyID  [in] Pointer to IPKIFCryptoKeyIDOperations interface
ris  [in] Pointer to CACCMSRecipientInfos object

Definition at line 1374 of file CACCMSUtils.cpp.

References CACASNWRAPPER_CREATE, IPKIFCryptoRawOperations::Decrypt(), IPKIFCryptoKeyIDOperations::Decrypt(), IPKIFCryptoKeyAgree::DeriveKey(), g_ecdh_std_sha1kdf, g_ecmqv_sha1kdf, CPKIFAlgorithm::GetAlg(), GetOriginatorPublicKey(), CPKIFAlgorithm::KeySize(), RIDMatch(), IPKIFCryptoKeyAgree::SecretAgree(), CPKIFAlgorithm::SymkeyAlg(), and CPKIFAlgorithm::SymkeyMode().

void PopulateKARIDFromKeyMaterial ( CACCMSKeyAgreeRecipientIdentifier *  rid,
CPKIFKeyMaterialPtr &  km 
)

Interface: Subsystem

This is a helper function that populates objective CACCMSKeyAgreeRecipientIdentifier structure using information from CPKIFKeyMaterial object,

Returns:
None
Parameters:
rid  [in/out] A pointer to CACCMSKeyAgreeRecipientIdentifier structure to be populated
km  [in] A reference to a smart pointer to CPKIFKeyMaterial containing the information that will be used to populate CACCMSKeyAgreeRecipientIdentifier

Definition at line 2143 of file CACCMSUtils.cpp.

References CACASNWRAPPER_CREATE, and CopyName().

bool RIDMatch ( CACCMSRecipientIdentifier *  rid,
CPKIFNamePtr &  issuer,
const char *  serial,
CPKIFSubjectKeyIdentifierPtr &  skid 
)

Interface: Subsystem

This function compares RID info with info from a cert that is also passed as parameters

Returns:
True if RID info matches, false otherwise
Parameters:
rid  [in] Pointer to CACCMSRecipientIdentifier object
issuer  [in] A smart pointer to CPKIFName object
serial  [in] buffer containing the serial number
skid  [in] A smart pointer to CPKIFSubjectKeyIdentifier object

Definition at line 986 of file CACCMSUtils.cpp.

References CACASNWRAPPER_CREATE, and stricmp.

Referenced by AutoDiscoverDecryptionKey(), and GetSymmetricKey().

void SetupAttributesInObjectiveStructure ( CPKIFAttributeList attrs,
DList &  objAttrs 
)

Interface: Subsystem

This function sets up attributes in an objective structure

Returns:
None
Parameters:
attrs  [in]List of attributes
objAttrs  [out]Objective structure that will contain the attributes

Definition at line 363 of file CACCMSUtils.cpp.

References CACASNWRAPPER_CREATE, ConvertStringToASN1OBJID(), CopyOID(), NEW_NEXT_AND_ADVANCE, NEW_NODE, and SET_HEAD_TAIL_INCREMENT.

Referenced by CPKIFEnvelopedData::Encode(), CPKIFEncryptedData::Encode(), and GetSignerInfo().


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