RecipientInfo.cpp

Go to the documentation of this file.
00001 
00009 #include "RecipientInfo.h"
00010 #include "KeyTransRecipientInfo.h"
00011 #include "KEKRecipInfoDetails.h"
00012 
00013 #include "ToolkitUtils.h"
00014 #include "PKIFCommonErrors.h"
00015 #include "PKIFMessageException.h"
00016 #include "Buffer.h"
00017 #include "ASN1Helper.h"
00018 #include "CryptographicMessageSyntax2004.h"
00019 
00021 struct CPKIFRecipientInfoImpl
00022 {
00023     CPKIFKeyTransRecipientInfoPtr m_ktri;
00024     CPKIFKEKRecipInfoDetailsPtr m_kek;
00025 };
00027 
00035 CPKIFRecipientInfo::CPKIFRecipientInfo()
00036     :m_impl (new CPKIFRecipientInfoImpl)
00037 {
00038 }
00039 
00051 CPKIFRecipientInfo::CPKIFRecipientInfo(
00053     // CACCMSRecipientInfo& ri) 
00054     const CPKIFBufferPtr& riBuf)
00055     :m_impl (new CPKIFRecipientInfoImpl)
00056 {
00057     CACASNWRAPPER_CREATE(CACCMSRecipientInfo, InfoWrapper);
00058     CACCMSRecipientInfo *ri = InfoWrapper.Decode(riBuf->GetBuffer(), riBuf->GetLength());
00059 
00060     if(1 != ri->t && 3 != ri->t)
00061     {
00062         //modified error description to reflect addition of support for kekri 3/2/2004
00063         throw CPKIFMessageException(TOOLKIT_MESSAGE_ASN, COMMON_NOT_IMPLEMENTED, "PKIF currently supports the ktri and kekri RecipientInfo choices only");
00064     }
00065     else if(1 == ri->t)
00066     {
00067         CACASNWRAPPER_CREATE(CACCMSKeyTransRecipientInfo, InfoWrapper);
00068         ASN1OpenType *data = InfoWrapper.Encode(ri->u.ktri);
00069         CPKIFBufferPtr ktriBuf(new CPKIFBuffer(data->data, data->numocts));
00070         delete data;
00071 
00072         CPKIFKeyTransRecipientInfoPtr tmp(new CPKIFKeyTransRecipientInfo(ktriBuf));
00073         //CPKIFKeyTransRecipientInfoPtr tmp(new CPKIFKeyTransRecipientInfo(*ri->u.ktri));
00074         m_impl->m_ktri = tmp;
00075     }
00076     else
00077     {
00078         CACASNWRAPPER_CREATE(CACCMSKEKRecipientInfo, InfoWrapper);
00079         ASN1OpenType *data = InfoWrapper.Encode(ri->u.kekri);
00080         CPKIFBufferPtr kekriBuf(new CPKIFBuffer(data->data, data->numocts));
00081         delete data;
00082 
00083         CPKIFKEKRecipInfoDetailsPtr tmp(new CPKIFKEKRecipInfoDetails(kekriBuf));
00084         //CPKIFKEKRecipInfoDetailsPtr tmp(new CPKIFKEKRecipInfoDetails(*ri->u.kekri));
00085         m_impl->m_kek = tmp;
00086     }
00087 }
00088 
00100 /*CPKIFRecipientInfo::CPKIFRecipientInfo(
00102     CACCMSRecipientInfo& ri)
00103     :m_impl (new CPKIFRecipientInfoImpl)
00104 {
00105     if(1 != ri.t && 3 != ri.t)
00106     {
00107         //modified error description to reflect addition of support for kekri 3/2/2004
00108         throw CPKIFMessageException(TOOLKIT_MESSAGE_ASN, COMMON_NOT_IMPLEMENTED, "PKIF currently supports the ktri and kekri RecipientInfo choices only");
00109     }
00110     else if(1 == ri.t)
00111     {
00112         CPKIFKeyTransRecipientInfoPtr tmp(new CPKIFKeyTransRecipientInfo(*ri.u.ktri));
00113         m_impl->m_ktri = tmp;
00114     }
00115     else
00116     {
00117         CPKIFKEKRecipInfoDetailsPtr tmp(new CPKIFKEKRecipInfoDetails(*ri.u.kekri));
00118         m_impl->m_kek = tmp;
00119     }
00120 }
00121 */
00122 
00130 CPKIFRecipientInfo::~CPKIFRecipientInfo()
00131 {
00132     delete m_impl;
00133     m_impl = NULL;
00134 }
00144 CPKIFKeyTransRecipientInfoPtr CPKIFRecipientInfo::GetKeyTransRecipInfo() const
00145 {
00146     return m_impl->m_ktri;
00147 }
00156 CPKIFKEKRecipInfoDetailsPtr CPKIFRecipientInfo::GetKEKRecipInfo() const
00157 {
00158     return m_impl->m_kek;
00159 }

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