Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 35 additions & 17 deletions x509cert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// http://www.cryptopp.com/wiki/PEM_Pack
///////////////////////////////////////////////////////////////////////////

#include "asn.h"
#include "pch.h"
#include "cryptlib.h"
#include "secblock.h"
Expand Down Expand Up @@ -375,10 +376,10 @@ void RdnValue::BERDecode(BufferedTransformation &bt)

void RdnValue::DEREncode(BufferedTransformation &bt) const
{
CRYPTOPP_UNUSED(bt);

// TODO: Implement this function
throw NotImplemented("RdnValue::DEREncode");
DERSequenceEncoder seq(bt);
m_oid.DEREncode(seq);
DEREncodeTextString(seq, m_value, m_tag);
seq.MessageEnd();
}

bool RdnValue::ValidateTag(byte tag) const
Expand Down Expand Up @@ -433,10 +434,7 @@ void DateValue::BERDecode(BufferedTransformation &bt)

void DateValue::DEREncode(BufferedTransformation &bt) const
{
CRYPTOPP_UNUSED(bt);

// TODO: Implement this function
throw NotImplemented("DateValue::DEREncode");
DEREncodeDate(bt, m_value, m_tag);
}

bool DateValue::ValidateTag(byte tag) const
Expand Down Expand Up @@ -484,8 +482,13 @@ void ExtensionValue::DEREncode(BufferedTransformation &bt) const
{
CRYPTOPP_UNUSED(bt);

// TODO: Implement this function
throw NotImplemented("ExtensionValue::DEREncode");
DERSequenceEncoder seq(bt);
m_oid.DEREncode(seq);
if (m_critical) {
DEREncodeUnsigned(seq, m_critical, BOOLEAN);
}
DEREncodeOctetString(seq, m_value);
seq.MessageEnd();
}

bool ExtensionValue::ValidateTag(byte tag) const
Expand Down Expand Up @@ -565,10 +568,21 @@ void KeyIdentifierValue::BERDecode(BufferedTransformation &bt)

void KeyIdentifierValue::DEREncode(BufferedTransformation &bt) const
{
CRYPTOPP_UNUSED(bt);
if (m_oid == id_subjectPublicKeyIdentifier) {
DEREncodeOctetString(bt, m_value);
return;
}

// TODO: Implement this function
throw NotImplemented("KeyIdentifierValue::DEREncode");
DERSequenceEncoder seq(bt, (CONSTRUCTED | SEQUENCE));
if (! m_value.empty()) {
DERSequenceEncoder enc(seq, CONTEXT_SPECIFIC|0);
enc.Put(ConstBytePtr(m_value), BytePtrSize(m_value));
enc.MessageEnd();
}
if (! m_other.empty()) {
seq.Put(ConstBytePtr(m_other), BytePtrSize(m_other));
}
seq.MessageEnd();
}

bool KeyIdentifierValue::ValidateTag(byte tag) const
Expand Down Expand Up @@ -975,10 +989,14 @@ void BasicConstraintValue::BERDecode(BufferedTransformation &bt)

void BasicConstraintValue::DEREncode(BufferedTransformation &bt) const
{
CRYPTOPP_UNUSED(bt);

// TODO: Implement this function
throw NotImplemented("BasicConstraintValue::DEREncode");
DERSequenceEncoder seq(bt);
if (m_ca) {
DEREncodeUnsigned(seq, m_ca, BOOLEAN);
}
if (m_pathLen) {
DEREncodeUnsigned(seq, m_pathLen, INTEGER);
}
seq.MessageEnd();
}

// Null values so some accessors can return something
Expand Down