KEKRecipInfoDetails.cpp
Go to the documentation of this file.00001
00009 #include "KEKRecipInfoDetails.h"
00010
00011 #include "PKIFKeyMaterial.h"
00012 #include "Buffer.h"
00013 #include "AlgorithmIdentifier.h"
00014 #include "ToolkitUtils.h"
00015 #include "components.h"
00016 #include "CryptographicMessageSyntax2004.h"
00017 #include "ASN1Helper.h"
00018 #include "OID.h"
00019
00021 struct CPKIFKEKRecipInfoDetailsImpl
00022 {
00023 CPKIFKeyMaterialPtr m_kek;
00024 CPKIFBufferPtr m_kid;
00025 CPKIFBufferPtr m_encKey;
00026 CPKIFAlgorithmIdentifierPtr m_encAlg;
00027 };
00029
00037 CPKIFKEKRecipInfoDetails::CPKIFKEKRecipInfoDetails()
00038 :m_impl (new CPKIFKEKRecipInfoDetailsImpl)
00039 {
00040 }
00050 CPKIFKeyMaterialPtr CPKIFKEKRecipInfoDetails::GetKEK() const
00051 {
00052 return m_impl->m_kek;
00053 }
00061 CPKIFKEKRecipInfoDetails::~CPKIFKEKRecipInfoDetails()
00062 {
00063 LOG_STRING_DEBUG("CPKIFKEKRecipInfoDetails::~CPKIFKEKRecipInfoDetails()", TOOLKIT_MESSAGE_ASN, 0, this);
00064
00065 delete m_impl;
00066 m_impl = NULL;
00067 }
00075 void CPKIFKEKRecipInfoDetails::SetKEK(
00078 CPKIFKeyMaterialPtr& kek)
00079 {
00080 m_impl->m_kek = kek;
00081 }
00089 CPKIFBufferPtr CPKIFKEKRecipInfoDetails::GetKeyIdentifier() const
00090 {
00091 return m_impl->m_kid;
00092 }
00102 void CPKIFKEKRecipInfoDetails::SetKeyIdentifier(
00104 CPKIFBufferPtr& kid)
00105 {
00106 m_impl->m_kid = kid;
00107 }
00108
00116 CPKIFKEKRecipInfoDetails::CPKIFKEKRecipInfoDetails(
00119
00120 const CPKIFBufferPtr& kekBuf)
00121 :m_impl (new CPKIFKEKRecipInfoDetailsImpl)
00122 {
00123 LOG_STRING_DEBUG("CPKIFKEKRecipInfoDetails::CPKIFKEKRecipInfoDetails(CACCMSKEKRecipientInfo& kek)", TOOLKIT_CRYPTO_MISC, 0, this);
00124
00125 CACASNWRAPPER_CREATE(CACCMSKEKRecipientInfo, InfoWrapper);
00126 CACCMSKEKRecipientInfo *kek = InfoWrapper.Decode(kekBuf->GetBuffer(), kekBuf->GetLength() );
00127
00128 CPKIFBufferPtr kid(new CPKIFBuffer(kek->kekid.keyIdentifier.data, kek->kekid.keyIdentifier.numocts));
00129 m_impl->m_kid = kid;
00130
00131 CPKIFBufferPtr encKey(new CPKIFBuffer(kek->encryptedKey.data, kek->encryptedKey.numocts));
00132 m_impl->m_encKey = encKey;
00133
00134
00135 CPKIFOIDPtr algOID(new CPKIFOID(kek->keyEncryptionAlgorithm.algorithm.subid,
00136 kek->keyEncryptionAlgorithm.algorithm.numids));
00137
00138 CPKIFBufferPtr paramBuf;
00139 if(kek->keyEncryptionAlgorithm.m.parametersPresent)
00140 {
00141 paramBuf = CPKIFBufferPtr(new CPKIFBuffer(kek->keyEncryptionAlgorithm.parameters.data,
00142 kek->keyEncryptionAlgorithm.parameters.numocts));
00143
00144
00145 }
00146
00147 CPKIFAlgorithmIdentifierPtr encAlg(new CPKIFAlgorithmIdentifier(algOID, paramBuf));
00148
00149 m_impl->m_encAlg = encAlg;
00150 }
00151
00159
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00186 CPKIFBufferPtr CPKIFKEKRecipInfoDetails::GetEncryptedKey() const
00187 {
00188 return m_impl->m_encKey;
00189 }
00197 CPKIFAlgorithmIdentifierPtr CPKIFKEKRecipInfoDetails::GetKEKAlgorithm() const
00198 {
00199 return m_impl->m_encAlg;
00200 }