HashValue.cpp
Go to the documentation of this file.00001
00010 #include "HashValue.h"
00011 #include "components.h"
00012 #include "ToolkitUtils.h"
00013 #include "Buffer.h"
00014 #include "PKIFSCVPErrors.h"
00015 #include "SCVPException.h"
00016 #include "ASN1Helper.h"
00017 #include "AlgorithmIdentifier.h"
00018 #include "OID.h"
00019 #include "SCVP.h"
00020
00021
00022 using namespace std;
00023
00025
00026 struct CPKIFHashValueImpl
00027 {
00028 CPKIFBufferPtr m_value;
00029 CPKIFAlgorithmIdentifierPtr m_algID;
00030 };
00031
00033
00042 CPKIFHashValue::CPKIFHashValue() :m_impl(new CPKIFHashValueImpl)
00043 {
00044 LOG_STRING_DEBUG("CPKIFHashValue::CPKIFHashValue()", TOOLKIT_SCVP_ASN, 0, this);
00045
00046 }
00057 CPKIFHashValue::CPKIFHashValue(
00059 const CPKIFBufferPtr& hashValue)
00060 :m_impl (new CPKIFHashValueImpl)
00061 {
00062 if(hashValue == (CPKIFBuffer*)NULL || 0 == hashValue->GetLength())
00063 {
00064 throw CPKIFSCVPException(TOOLKIT_SCVP_ASN, COMMON_INVALID_INPUT);
00065 }
00066
00067 CACASNWRAPPER_CREATE(HashValue, objPDU);
00068 objPDU.Decode(hashValue->GetBuffer(), hashValue->GetLength());
00069
00070 CPKIFBufferPtr tmpBuf(new CPKIFBuffer(objPDU->value.data, objPDU->value.numocts));
00071 m_impl->m_value = tmpBuf;
00072
00073 if(0 < objPDU->m.algorithmPresent)
00074 {
00075 CPKIFOIDPtr algOID(new CPKIFOID(objPDU->algorithm.algorithm.subid, objPDU->algorithm.algorithm.numids));
00076
00077 CPKIFBufferPtr algParams;
00078 if(objPDU->algorithm.m.parametersPresent == 1)
00079 {
00080 CPKIFBufferPtr tmpAlgParams(new CPKIFBuffer(objPDU->algorithm.parameters.data,
00081 objPDU->algorithm.parameters.numocts));
00082 algParams = tmpAlgParams;
00083 }
00084 CPKIFAlgorithmIdentifierPtr algID(new CPKIFAlgorithmIdentifier(algOID, algParams));
00085
00086 m_impl->m_algID = algID;
00087 }
00088 }
00096 CPKIFHashValue::~CPKIFHashValue()
00097 {
00098 LOG_STRING_DEBUG("CPKIFHashValue::~CPKIFHashValue()", TOOLKIT_SCVP_ASN, 0, this);
00099
00100 if (m_impl) {
00101 delete m_impl;
00102 }
00103 }
00111 void CPKIFHashValue::SetValue(
00113 CPKIFBufferPtr& value)
00114 {
00115 m_impl->m_value = value;
00116 }
00124 const CPKIFBufferPtr CPKIFHashValue::GetValue() const
00125 {
00126 return m_impl->m_value;
00127 }
00128
00136 void CPKIFHashValue::SetAlgID(
00138 CPKIFAlgorithmIdentifierPtr& algID)
00139 {
00140 m_impl->m_algID = algID;
00141 }
00149 const CPKIFAlgorithmIdentifierPtr CPKIFHashValue::GetAlgID() const
00150 {
00151 return m_impl->m_algID;
00152 }
00153