ValidationPolRef.cpp
Go to the documentation of this file.00001
00009 #include "AlgorithmIdentifier.h"
00010 #include "OID.h"
00011 #include "Buffer.h"
00012 #include "ASN1Helper.h"
00013
00014 #include "PKIX1Implicit88.h"
00015 #include "PKIX1Explicit88.h"
00016
00018
00019 struct CPKIFAlgorithmIdentifierImpl
00020 {
00022 CPKIFOIDPtr m_algorithm;
00023
00025 ASN1OpenType* m_parameters;
00026 };
00027
00029
00040 CPKIFAlgorithmIdentifier::CPKIFAlgorithmIdentifier()
00041 : m_impl (new CPKIFAlgorithmIdentifierImpl)
00042 {
00043 m_impl->m_parameters = NULL;
00044 }
00045
00056 CPKIFAlgorithmIdentifier::CPKIFAlgorithmIdentifier(
00058 const CPKIFOIDPtr &oid,
00060 const CPKIFBufferPtr& params)
00061 : m_impl (new CPKIFAlgorithmIdentifierImpl)
00062 {
00063 CPKIFOIDPtr tmp(new CPKIFOID((std::string(oid->ToString()))));
00064 m_impl->m_algorithm = tmp;
00065 if(params)
00066 {
00067 m_impl->m_parameters = new ASN1OpenType;
00068 m_impl->m_parameters->data = new unsigned char[params->GetLength()];
00069 memcpy((void*)m_impl->m_parameters->data, params->GetBuffer(), params->GetLength());
00070 m_impl->m_parameters->numocts = params->GetLength();
00071 }
00072 else
00073 m_impl->m_parameters = NULL;
00074 }
00075
00086 CPKIFAlgorithmIdentifier::CPKIFAlgorithmIdentifier(
00088 const CPKIFOIDPtr& oid)
00089 : m_impl (new CPKIFAlgorithmIdentifierImpl)
00090 {
00091 m_impl->m_algorithm = oid; m_impl->m_parameters = NULL;
00092 }
00100 CPKIFAlgorithmIdentifier::CPKIFAlgorithmIdentifier(
00102 const CPKIFAlgorithmIdentifier& alg)
00103 : m_impl (new CPKIFAlgorithmIdentifierImpl)
00104 {
00105 CPKIFOIDPtr tmp(new CPKIFOID((std::string(alg.m_impl->m_algorithm->ToString()))));
00106 m_impl->m_algorithm = tmp;
00107 if( alg.m_impl->m_parameters )
00108 {
00109 m_impl->m_parameters = new ASN1OpenType;
00110 m_impl->m_parameters->data = new unsigned char[alg.m_impl->m_parameters->numocts];
00111 memcpy((void*)m_impl->m_parameters->data, alg.m_impl->m_parameters->data, alg.m_impl->m_parameters->numocts);
00112 m_impl->m_parameters->numocts = alg.m_impl->m_parameters->numocts;
00113 }
00114 else
00115 m_impl->m_parameters = NULL;
00116 }
00117
00125 CPKIFAlgorithmIdentifier::~CPKIFAlgorithmIdentifier()
00126 {
00127 if(m_impl)
00128 {
00129 if(NULL != m_impl->m_parameters)
00130 {
00131 if(NULL != m_impl->m_parameters->data)
00132 {
00133 delete[] m_impl->m_parameters->data; m_impl->m_parameters->data = NULL;
00134 }
00135
00136 delete m_impl->m_parameters; m_impl->m_parameters = NULL;
00137 }
00138
00139 delete m_impl;
00140 m_impl = 0;
00141 }
00142 }
00143
00152 CPKIFOIDPtr CPKIFAlgorithmIdentifier::oid() const
00153 {
00154 return m_impl->m_algorithm;
00155 }
00156
00164 bool CPKIFAlgorithmIdentifier::hasParameters() const
00165 {
00166 return NULL != m_impl->m_parameters;
00167 }
00168
00179 bool CPKIFAlgorithmIdentifier::operator==(
00181 const CPKIFAlgorithmIdentifier& rhs) const
00182 {
00183 return *m_impl->m_algorithm == *rhs.m_impl->m_algorithm;
00184 }
00185
00196 CPKIFBufferPtr CPKIFAlgorithmIdentifier::parameters() const
00197 {
00198 if(hasParameters())
00199 {
00200 CPKIFBufferPtr tmp(new CPKIFBuffer(m_impl->m_parameters->data, m_impl->m_parameters->numocts));
00201 return tmp;
00202 }
00203 else
00204 {
00205 CPKIFBufferPtr tmp;
00206 return tmp;
00207 }
00208 }
00209