00001
00010 #include "ASN1Helper.h"
00011 #include "Accuracy.h"
00012 #include "AlgorithmIdentifier.h"
00013 #include "Buffer.h"
00014 #include "GeneralName.h"
00015 #include "MessageImprint.h"
00016 #include "OID.h"
00017 #include "PKIFTSP.h"
00018 #include "pkiftsperrors.h"
00019 #include "PKIFTime.h"
00020 #include "PKIFX509Extensions2.h"
00021 #include "PKIXTSP.h"
00022 #include "TSPException.h"
00023 #include "TSTInfo.h"
00024 #include "ToolkitUtils.h"
00025 #include "X509Extension.h"
00026 #include "private/PKIFTSPMemoryHelper.h"
00027
00029
00030 struct CPKIFTSTInfoImpl
00031 {
00032 CPKIFTSTInfo *m_parent;
00033
00034
00035 void populateExtensionsVector();
00036
00037 int m_version;
00038 CPKIFMessageImprintPtr m_messageImprint;
00039 CPKIFOIDPtr m_policy;
00040 CPKIFStringPtr m_nonce;
00041
00042 CPKIFStringPtr m_serialNum;
00043 CPKIFTimePtr m_time;
00044
00045 CPKIFAccuracyPtr m_accuracy;
00046 bool m_bOrdering;
00047 CPKIFGeneralNamePtr m_tsa;
00048
00049 ASN1CGeneralizedTime* m_gt;
00050
00051 std::vector<CPKIFX509ExtensionPtr> m_exts;
00052
00053
00054 CPKIFASNWrapper<PKIFTSPTSTInfo>* m_tstInfo;
00055
00056 void ClearAllMembers();
00057 void MakeTSTInfo();
00058 void FreeTSTInfo();
00059
00060
00061 void CallingAllGets();
00062 };
00063
00074 void CPKIFTSTInfoImpl::populateExtensionsVector()
00075 {
00076 LOG_STRING_DEBUG("CPKIFTSTInfo::populateExtensionsVector()", TOOLKIT_TSP_ASN, 0, this);
00077
00078 if(NULL == m_tstInfo->data())
00079 return;
00080
00081
00082 if(!m_exts.empty())
00083 return;
00084
00085
00086 if(0 == (*m_tstInfo)->m.extensionsPresent)
00087 {
00088 m_exts.clear();
00089 return;
00090 }
00091
00092
00093
00094 CPKIFX509ExtensionMediator2 * mediator = CPKIFX509ExtensionMediator2::GetInstance();
00095
00096 m_parent->IPKIFHasExtensions::GetExtensions (mediator, m_exts);
00097
00098 }
00099
00108 void CPKIFTSTInfoImpl::ClearAllMembers()
00109 {
00110 LOG_STRING_DEBUG("CPKIFTSTInfo::ClearAllMembers()", TOOLKIT_TSP_ASN, 0, this);
00111
00112 CPKIFMessageImprintPtr tmpMI;
00113 m_messageImprint = tmpMI;
00114
00115 CPKIFOIDPtr tmpPolicy;
00116 m_policy = tmpPolicy;
00117
00118 CPKIFStringPtr tmpNonce;
00119 m_nonce = tmpNonce;
00120 m_serialNum = tmpNonce;
00121
00122 CPKIFTimePtr tmpTime;
00123 m_time = tmpTime;
00124
00125 CPKIFAccuracyPtr tmpAccuracy;
00126 m_accuracy = tmpAccuracy;
00127
00128 CPKIFGeneralNamePtr tmpGN;
00129 m_tsa = tmpGN;
00130
00131 m_exts.clear();
00132 m_version = 1;
00133 m_bOrdering = false;
00134 FreeTSTInfo();
00135 }
00136
00144 void CPKIFTSTInfoImpl::MakeTSTInfo()
00145 {
00146 LOG_STRING_DEBUG("CPKIFTSTInfo::MakeTSTInfo()", TOOLKIT_TSP_ASN, 0, this);
00147
00148 FreeTSTInfo();
00149
00150
00151 m_tstInfo = new CPKIFASNWrapper<PKIFTSPTSTInfo>( BEREncPKIFTSPTSTInfo, BERDecPKIFTSPTSTInfo );
00152 }
00160 void CPKIFTSTInfoImpl::FreeTSTInfo()
00161 {
00162 LOG_STRING_DEBUG("CPKIFTSTInfo::FreeTSTInfo()", TOOLKIT_TSP_ASN, 0, this);
00163
00164 if(NULL != m_tstInfo)
00165 delete m_tstInfo;
00166 m_tstInfo = NULL;
00167 }
00175 void CPKIFTSTInfoImpl::CallingAllGets()
00176 {
00177 LOG_STRING_DEBUG("CPKIFTSTInfo::CallingAllGets()", TOOLKIT_TSP_ASN, 0, this);
00178
00179 #ifdef WIN32
00180 GetVersion();
00181 #endif
00182 m_parent->GetPolicy();
00183 m_parent->GetMessageImprint();
00184 m_parent->GetSerialNumber();
00185 m_parent->GetGeneralizedTime();
00186 m_parent->GetAccuracy();
00187 m_parent->GetOrdering();
00188 m_parent->GetNonce();
00189 m_parent->GetTSA();
00190 FreeTSTInfo();
00191 }
00192
00194
00201 void CPKIFTSTInfo::GetExtensionByOID(
00203 const CPKIFOID& oid,
00205 CPKIFX509ExtensionPtr& ref)
00206 {
00207 if(m_impl->m_exts.empty() && 0 != (*m_impl->m_tstInfo)->m.extensionsPresent)
00208 m_impl->populateExtensionsVector();
00209
00210 std::vector<CPKIFX509ExtensionPtr>::iterator pos;
00211 std::vector<CPKIFX509ExtensionPtr>::iterator end = m_impl->m_exts.end();
00212 for(pos = m_impl->m_exts.begin(); pos != end; ++pos)
00213 {
00214 if(oid == (*pos)->oid())
00215 {
00216 ref = *pos;
00217 return;
00218 }
00219 }
00220 }
00221
00230 CPKIFTSTInfo::CPKIFTSTInfo()
00231 :m_impl(new CPKIFTSTInfoImpl)
00232 {
00233 LOG_STRING_DEBUG("CPKIFTSTInfo::CPKIFTSTInfo()", TOOLKIT_TSP_ASN, 0, this);
00234
00235 m_impl->m_parent = this;
00236 m_impl->m_version = 1;
00237 m_impl->m_bOrdering = false;
00238 m_impl->m_tstInfo = NULL;
00239 }
00247 CPKIFTSTInfo::~CPKIFTSTInfo()
00248 {
00249 LOG_STRING_DEBUG("CPKIFTSTInfo::~CPKIFTSTInfo()", TOOLKIT_TSP_ASN, 0, this);
00250
00251 if (m_impl)
00252 {
00253 m_impl->FreeTSTInfo();
00254
00255 delete m_impl;
00256 }
00257 }
00258
00259
00267 int CPKIFTSTInfo::GetVersion() const
00268 {
00269 LOG_STRING_DEBUG("CPKIFTSTInfo::GetVersion()", TOOLKIT_TSP_ASN, 0, this);
00270
00271 if(NULL != m_impl->m_tstInfo && NULL != (*m_impl->m_tstInfo).data() && m_impl->m_version != (*m_impl->m_tstInfo)->version)
00272 {
00273 CPKIFTSTInfo* nonConst = const_cast<CPKIFTSTInfo*>(this);
00274 nonConst->m_impl->m_version = (*m_impl->m_tstInfo)->version;
00275 }
00276
00277 return m_impl->m_version;
00278 }
00286 void CPKIFTSTInfo::SetPolicy(
00288 CPKIFOIDPtr& policy)
00289 {
00290 LOG_STRING_DEBUG("CPKIFTSTInfo::SetPolicy(CPKIFOIDPtr& policy)", TOOLKIT_TSP_ASN, 0, this);
00291
00292 m_impl->CallingAllGets();
00293 m_impl->m_policy = policy;
00294 }
00303 CPKIFOIDPtr CPKIFTSTInfo::GetPolicy() const
00304 {
00305 if(m_impl->m_policy == (CPKIFOID*)NULL && NULL != m_impl->m_tstInfo && NULL != (*m_impl->m_tstInfo).data())
00306 {
00307 LOG_STRING_DEBUG("CPKIFTSTInfo::GetPolicy()", TOOLKIT_TSP_ASN, 0, this);
00308
00309 CPKIFOIDPtr tmpRef(new CPKIFOID((*m_impl->m_tstInfo)->policy.subid, (*m_impl->m_tstInfo)->policy.numids));
00310
00311 CPKIFTSTInfo* nonConst = const_cast<CPKIFTSTInfo*>(this);
00312 nonConst->m_impl->m_policy = tmpRef;
00313 }
00314 return m_impl->m_policy;
00315 }
00323 void CPKIFTSTInfo::SetMessageImprint(
00325 CPKIFMessageImprintPtr& messageImprint)
00326 {
00327 LOG_STRING_DEBUG("CPKIFTSTInfo::SetMessageImprint(CPKIFMessageImprintPtr& messageImprint)", TOOLKIT_TSP_ASN, 0, this);
00328
00329 m_impl->CallingAllGets();
00330 m_impl->m_messageImprint = messageImprint;
00331 }
00340 CPKIFMessageImprintPtr CPKIFTSTInfo::GetMessageImprint() const
00341 {
00342 if(m_impl->m_messageImprint == (CPKIFMessageImprint*)NULL && NULL != m_impl->m_tstInfo && NULL != (*m_impl->m_tstInfo).data())
00343 {
00344 LOG_STRING_DEBUG("CPKIFTSTInfo::GetMessageImprint()", TOOLKIT_TSP_ASN, 0, this);
00345
00346 CACASNWRAPPER_CREATE(PKIFTSPMessageImprint, miWrapper);
00347 ASN1OpenType *data = miWrapper.Encode(&(*m_impl->m_tstInfo)->messageImprint);
00348 CPKIFBufferPtr miBuf(new CPKIFBuffer(data->data, data->numocts));
00349
00350 CPKIFMessageImprintPtr tmpRef(new CPKIFMessageImprint(miBuf));
00351
00352
00353 CPKIFTSTInfo* nonConst = const_cast<CPKIFTSTInfo*>(this);
00354 nonConst->m_impl->m_messageImprint = tmpRef;
00355
00356 if (data)
00357 {
00358 delete data;
00359 }
00360 }
00361 return m_impl->m_messageImprint;
00362 }
00370 void CPKIFTSTInfo::SetSerialNumber(
00372 CPKIFStringPtr& serialNumber)
00373 {
00374 LOG_STRING_DEBUG("CPKIFTSTInfo::SetSerialNumber(CPKIFStringPtr& serialNumber)", TOOLKIT_TSP_ASN, 0, this);
00375
00376 m_impl->CallingAllGets();
00377 m_impl->m_serialNum = serialNumber;
00378 }
00388 const char* CPKIFTSTInfo::GetSerialNumber() const
00389 {
00390 if(m_impl->m_serialNum == NULL && NULL != m_impl->m_tstInfo && NULL != (*m_impl->m_tstInfo).data())
00391 {
00392 LOG_STRING_DEBUG("CPKIFTSTInfo::GetSerialNumber()", TOOLKIT_TSP_ASN, 0, this);
00393
00394 CPKIFStringPtr tmpRef(new std::string((char*)(*m_impl->m_tstInfo)->serialNumber));
00395
00396 CPKIFTSTInfo* nonConst = const_cast<CPKIFTSTInfo*>(this);
00397 nonConst->m_impl->m_serialNum = tmpRef;
00398 }
00399
00400 if(m_impl->m_serialNum == NULL)
00401 return NULL;
00402 else
00403 return m_impl->m_serialNum->c_str();
00404 }
00412 void CPKIFTSTInfo::SetGeneralizedTime(
00414 CPKIFTimePtr& genTime)
00415 {
00416 LOG_STRING_DEBUG("CPKIFTSTInfo::SetGeneralizedTime(CPKIFTimePtr& genTime)", TOOLKIT_TSP_ASN, 0, this);
00417
00418 m_impl->CallingAllGets();
00419 m_impl->m_time = genTime;
00420 }
00429 CPKIFTimePtr CPKIFTSTInfo::GetGeneralizedTime() const
00430 {
00431 if(m_impl->m_time == NULL && NULL != m_impl->m_tstInfo && NULL != (*m_impl->m_tstInfo).data())
00432 {
00433 LOG_STRING_DEBUG("CPKIFTSTInfo::GetGeneralizedTime()", TOOLKIT_TSP_ASN, 0, this);
00434
00435 CPKIFTimePtr tmpTime(new CPKIFTime((*m_impl->m_tstInfo)->genTime));
00436
00437 CPKIFTSTInfo* nonConst = const_cast<CPKIFTSTInfo*>(this);
00438 nonConst->m_impl->m_time = tmpTime;
00439 }
00440
00441 return m_impl->m_time;
00442 }
00450 void CPKIFTSTInfo::SetAccuracy(
00453 CPKIFAccuracyPtr& accuracy)
00454 {
00455 LOG_STRING_DEBUG("CPKIFTSTInfo::SetAccuracy(CPKIFAccuracyPtr& accuracy)", TOOLKIT_TSP_ASN, 0, this);
00456
00457 m_impl->CallingAllGets();
00458 m_impl->m_accuracy = accuracy;
00459 }
00468 CPKIFAccuracyPtr CPKIFTSTInfo::GetAccuracy() const
00469 {
00470 if(m_impl->m_accuracy == (CPKIFMessageImprint*)NULL && NULL != m_impl->m_tstInfo && 1 == (*m_impl->m_tstInfo)->m.accuracyPresent)
00471 {
00472 LOG_STRING_DEBUG("CPKIFTSTInfo::GetAccuracy()", TOOLKIT_TSP_ASN, 0, this);
00473
00474 CACASNWRAPPER_CREATE(PKIFTSPAccuracy, accuWrapper);
00475 ASN1OpenType *data = accuWrapper.Encode(&(*m_impl->m_tstInfo)->accuracy);
00476 CPKIFBufferPtr accuBuf(new CPKIFBuffer(data->data, data->numocts));
00477
00478 CPKIFAccuracyPtr tmpRef(new CPKIFAccuracy(accuBuf));
00479
00480
00481 CPKIFTSTInfo* nonConst = const_cast<CPKIFTSTInfo*>(this);
00482 nonConst->m_impl->m_accuracy = tmpRef;
00483
00484 if (data)
00485 {
00486 delete data;
00487 }
00488
00489 }
00490 return m_impl->m_accuracy;
00491 }
00499 void CPKIFTSTInfo::SetOrdering(
00501 bool ordering)
00502 {
00503 LOG_STRING_DEBUG("CPKIFTSTInfo::SetOrdering(bool ordering)", TOOLKIT_TSP_ASN, 0, this);
00504
00505 m_impl->CallingAllGets();
00506 m_impl->m_bOrdering = ordering;
00507 }
00515 bool CPKIFTSTInfo::GetOrdering() const
00516 {
00517 return m_impl->m_bOrdering;
00518 }
00526 void CPKIFTSTInfo::SetNonce(
00529 CPKIFStringPtr& nonce)
00530 {
00531 LOG_STRING_DEBUG("CPKIFTSTInfo::SetNonce(CPKIFStringPtr& nonce)", TOOLKIT_TSP_ASN, 0, this);
00532
00533 m_impl->CallingAllGets();
00534 m_impl->m_nonce = nonce;
00535 }
00545 const char* CPKIFTSTInfo::GetNonce() const
00546 {
00547 if(m_impl->m_nonce == NULL && NULL != m_impl->m_tstInfo && 1 == (*m_impl->m_tstInfo)->m.noncePresent)
00548 {
00549 LOG_STRING_DEBUG("CPKIFTSTInfo::GetNonce()", TOOLKIT_TSP_ASN, 0, this);
00550
00551 CPKIFStringPtr tmpRef(new std::string((*m_impl->m_tstInfo)->nonce));
00552
00553 CPKIFTSTInfo* nonConst = const_cast<CPKIFTSTInfo*>(this);
00554 nonConst->m_impl->m_nonce = tmpRef;
00555 }
00556
00557 if(m_impl->m_nonce == NULL)
00558 return NULL;
00559 else
00560 return m_impl->m_nonce->c_str();
00561 }
00569 void CPKIFTSTInfo::SetTSA(
00571 CPKIFGeneralNamePtr& tsa)
00572 {
00573 LOG_STRING_DEBUG("CPKIFTSTInfo::SetTSA(CPKIFGeneralNamePtr& tsa)", TOOLKIT_TSP_ASN, 0, this);
00574
00575 m_impl->CallingAllGets();
00576 m_impl->m_tsa = tsa;
00577 }
00585 CPKIFGeneralNamePtr CPKIFTSTInfo::GetTSA() const
00586 {
00587 if(m_impl->m_tsa == (CPKIFGeneralName*)NULL && NULL != m_impl->m_tstInfo && 1 == (*m_impl->m_tstInfo)->m.tsaPresent)
00588 {
00589 LOG_STRING_DEBUG("CPKIFTSTInfo::GetTSA()", TOOLKIT_TSP_ASN, 0, this);
00590
00591 CACASNWRAPPER_CREATE(CACX509V3GeneralName, objPDU);
00592 ASN1OpenType* data1 = objPDU.Encode(&((*m_impl->m_tstInfo)->tsa));
00593 CPKIFBufferPtr tmpBuf;
00594 if (data1 != NULL)
00595 {
00596 tmpBuf = CPKIFBufferPtr(new CPKIFBuffer(data1->data, data1->numocts));
00597 delete data1;
00598 }
00599 CPKIFGeneralNamePtr tmpRef(new CPKIFGeneralName(tmpBuf));
00600
00601
00602 CPKIFTSTInfo* nonConst = const_cast<CPKIFTSTInfo*>(this);
00603 nonConst->m_impl->m_tsa = tmpRef;
00604 }
00605 return m_impl->m_tsa;
00606 }
00607
00608
00609
00610
00611
00612
00622 bool CPKIFTSTInfo::ExtensionsPresent() const
00623 {
00624 LOG_STRING_DEBUG("CPKIFTSTInfo::ExtensionsPresent()", TOOLKIT_TSP_ASN, 0, this);
00625
00626 if(NULL != m_impl->m_tstInfo && (*m_impl->m_tstInfo)->m.extensionsPresent)
00627 return true;
00628 else
00629 return false;
00630 }
00642 CPKIFBufferPtr CPKIFTSTInfo::Encode()
00643 {
00644 LOG_STRING_DEBUG("CPKIFTSTInfo::Encode()", TOOLKIT_TSP_ASN, 0, this);
00645
00646 PKIFTSPMemoryHelper mhTSTInfo;
00647 mhTSTInfo.pTSTInfo = new PKIFTSPTSTInfo;
00648 memset(mhTSTInfo.pTSTInfo, 0, sizeof(PKIFTSPTSTInfo));
00649
00650
00651 mhTSTInfo.pTSTInfo->version = PKIFTSPv1_1;
00652
00653
00654 CPKIFOIDPtr policy = GetPolicy();
00655 if(policy != (CPKIFOID*)NULL)
00656 {
00657 CPKIFStringPtr str(new std::string(policy->ToString()));
00658 ASN1OBJID* tmpOid = ConvertStringToASN1OBJID(str);
00659
00660 CopyOID(&mhTSTInfo.pTSTInfo->policy, tmpOid);
00661
00662 if(NULL != tmpOid)
00663 delete tmpOid;
00664
00665 }
00666 else
00667 {
00668 throw CPKIFTSPException(TOOLKIT_TSP_ASN, TSP_MISSING_REQUIRED_FIELD, "Missing policy field.");
00669 }
00670
00671 CPKIFMessageImprintPtr mi = GetMessageImprint();
00672 if(mi != (CPKIFMessageImprint*)NULL)
00673 {
00674
00675 mhTSTInfo.pTSTInfo->messageImprint.hashAlgorithm.m.parametersPresent = 1;
00676 mhTSTInfo.pTSTInfo->messageImprint.hashAlgorithm.parameters.data = g_nullParams;
00677 mhTSTInfo.pTSTInfo->messageImprint.hashAlgorithm.parameters.numocts = 2;
00678 CPKIFStringPtr str(new std::string(mi->GetHashAlgorithm()->oid()->ToString()));
00679 ASN1OBJID* tmpOid = ConvertStringToASN1OBJID(str);
00680
00681 CopyOID(&mhTSTInfo.pTSTInfo->messageImprint.hashAlgorithm.algorithm,tmpOid);
00682
00683 if(NULL != tmpOid)
00684 delete tmpOid;
00685
00686
00687
00688 mhTSTInfo.pTSTInfo->messageImprint.hashedMessage.data = mi->GetHashedMessage()->GetBuffer();
00689 mhTSTInfo.pTSTInfo->messageImprint.hashedMessage.numocts = mi->GetHashedMessage()->GetLength();
00690 }
00691 else
00692 throw CPKIFTSPException(TOOLKIT_TSP_ASN, TSP_MISSING_REQUIRED_FIELD, "Missing message imprint field.");
00693
00694
00695 const char* serialNumber = GetSerialNumber();
00696 if(NULL != serialNumber)
00697 {
00698 mhTSTInfo.pTSTInfo->serialNumber = serialNumber;
00699 }
00700 else
00701 throw CPKIFTSPException(TOOLKIT_TSP_ASN, TSP_MISSING_REQUIRED_FIELD, "Missing serial number field.");
00702
00703
00704 CPKIFTimePtr genTime = GetGeneralizedTime();
00705 if(genTime != (CPKIFTime*)NULL)
00706 {
00707 mhTSTInfo.pTSTInfo->genTime = genTime->GetTime();
00708 }
00709 else
00710 throw CPKIFTSPException(TOOLKIT_TSP_ASN, TSP_MISSING_REQUIRED_FIELD, "Missing generalized time field.");
00711
00712
00713 CPKIFAccuracyPtr acc = GetAccuracy();
00714 if(acc != (CPKIFAccuracy*)NULL)
00715 {
00716 mhTSTInfo.pTSTInfo->m.accuracyPresent = 1;
00717 mhTSTInfo.pTSTInfo->accuracy.m.secondsPresent = 0;
00718 mhTSTInfo.pTSTInfo->accuracy.m.millisPresent = 0;
00719 mhTSTInfo.pTSTInfo->accuracy.m.microsPresent = 0;
00720 if(acc->GetSecondsPresent())
00721 {
00722 mhTSTInfo.pTSTInfo->accuracy.m.secondsPresent = 1;
00723 mhTSTInfo.pTSTInfo->accuracy.seconds = acc->GetSeconds();
00724 }
00725 if(acc->GetMillisPresent())
00726 {
00727 mhTSTInfo.pTSTInfo->accuracy.m.millisPresent = 1;
00728 mhTSTInfo.pTSTInfo->accuracy.millis = acc->GetMillis();
00729 }
00730 if(acc->GetMicrosPresent())
00731 {
00732 mhTSTInfo.pTSTInfo->accuracy.m.microsPresent = 1;
00733 mhTSTInfo.pTSTInfo->accuracy.micros = acc->GetMicros();
00734 }
00735 }
00736
00737
00738 if(GetOrdering())
00739 {
00740 mhTSTInfo.pTSTInfo->ordering = 1;
00741 }
00742
00743
00744 const char* nonce = GetNonce();
00745 if(NULL != nonce)
00746 {
00747 mhTSTInfo.pTSTInfo->nonce = nonce;
00748 mhTSTInfo.pTSTInfo->m.noncePresent = 1;
00749 }
00750
00751
00752 CPKIFGeneralNamePtr tsa = GetTSA();
00753 if(tsa != (CPKIFGeneralName*)NULL)
00754 {
00755 mhTSTInfo.pTSTInfo->m.tsaPresent = 1;
00756 CopyGeneralName(mhTSTInfo.pTSTInfo->tsa, tsa);
00757 }
00758
00759
00760 if(!m_impl->m_exts.empty())
00761 throw CPKIFTSPException(TOOLKIT_TSP_ASN, COMMON_NOT_IMPLEMENTED, "There is currently no support for including extensions in a CPKIFTimeStampRequest.");
00762
00763 CACASNWRAPPER_CREATE(PKIFTSPTSTInfo, objPDU);
00764 ASN1OpenType* data1 = objPDU.Encode(mhTSTInfo.pTSTInfo);
00765 CPKIFBufferPtr tmp(new CPKIFBuffer(data1->data, data1->numocts));
00766 delete data1;
00767 return tmp;
00768 }
00776 void CPKIFTSTInfo::Decode(
00778 CPKIFBufferPtr& msg)
00779 {
00780 LOG_STRING_DEBUG("CPKIFTSTInfo::Decode(CPKIFBufferPtr& msg)", TOOLKIT_TSP_ASN, 0, this);
00781
00782 m_impl->ClearAllMembers();
00783
00784
00785 if(msg == (CPKIFBuffer*)NULL || 0 == msg->GetLength())
00786 {
00787 throw CPKIFTSPException(TOOLKIT_TSP_ASN, COMMON_INVALID_INPUT);
00788 }
00789
00790 m_impl->MakeTSTInfo();
00791
00792 try
00793 {
00794
00795 (*m_impl->m_tstInfo).Decode(msg->GetBuffer(), msg->GetLength());
00796 }
00797 catch(CPKIFException&)
00798 {
00799
00800
00801 throw CPKIFTSPException(TOOLKIT_TSP_ASN, ASN1_DECODE_ERROR);
00802 }
00803 }
00804
00812 void CPKIFTSTInfo::GetEncodedExtensions (
00814 CPKIFBufferPtr& buf)
00815 {
00816 try
00817 {
00818 if ((*m_impl->m_tstInfo)->m.extensionsPresent)
00819 {
00820 CACASNWRAPPER_CREATE(CACX509V3Extensions, extsWrapper);
00821 ASN1OpenType *data = extsWrapper.Encode (&(*m_impl->m_tstInfo)->extensions);
00822 CPKIFBufferPtr tmp(new CPKIFBuffer(data->data, data->numocts));
00823 buf = tmp;
00824 delete data;
00825 return;
00826 }
00827 }
00828 catch (... )
00829 {
00830
00831 }
00832
00833 CPKIFBufferPtr nullExt;
00834 buf = nullExt;
00835 }