cryptopp-pem
cryptopp-pem copied to clipboard
Implement various DEREncoding methods
This commit provides implementation for the following DEREncode methods:
RdnValue::DEREncode
DateValue::DEREncode
ExtensionValue::DEREncode
KeyIdentifierValue::DEREncode
BasicConstraintValue::BERDecode
Notably, it does not implement the
X509Certificate::DEREncode
method, which is the main missing part for being able to go back-and-forth between a CryptoPP cert and its DER-encoding.
The commit is still useful, e.g., for returning certificate attributes in a PKCS#11 which are supposed to
be DER-encoded, e.g. to return a CKA_START_DATE of a certificate, one can just write:
X509Certificate cert = ...;
std::vector<unsigned char> start_date;
VectorSource der_sink(start_date, true);
cert->GetNotBefore().DEREncode(der_sink);