27 #include "../../util/time.hpp" 29 #include "../../encoding/cryptopp/asn_ext.hpp" 30 #include "../../encoding/buffer-stream.hpp" 31 #include "../../util/concepts.hpp" 32 #include "../../util/indented-stream.hpp" 34 #include <boost/algorithm/string/split.hpp> 42 static_assert(std::is_base_of<tlv::Error, Certificate::Error>::value,
43 "Certificate::Error must inherit from tlv::Error");
46 : m_notBefore(
time::system_clock::TimePoint::max())
47 , m_notAfter(
time::system_clock::TimePoint::min())
134 CryptoPP::FileSink sink(os);
141 DERSequenceEncoder idCert(sink);
146 DERSequenceEncoder validity(idCert);
151 validity.MessageEnd();
157 DERSequenceEncoder
name(idCert);
178 DERSequenceEncoder extensions(idCert);
183 it->encode(extensions);
186 extensions.MessageEnd();
210 BERSequenceDecoder idCert(source);
215 BERSequenceDecoder validity(idCert);
220 validity.MessageEnd();
227 BERSequenceDecoder
name(idCert);
229 while (!name.EndReached())
248 if (!idCert.EndReached())
250 BERSequenceDecoder extensions(idCert);
252 while (!extensions.EndReached())
257 extensions.MessageEnd();
263 catch (CryptoPP::BERDecodeErr&) {
264 BOOST_THROW_EXCEPTION(
Error(
"Certificate Decoding Error"));
273 os <<
"Certificate name:\n";
274 os <<
" " <<
getName() <<
"\n";
281 os <<
"Subject Description:\n";
283 os <<
" " << description.getOidString() <<
": " << description.getValue() <<
"\n";
285 os <<
"Public key bits: ";
294 os <<
"(Unknown key type)";
301 CryptoPP::Base64Encoder encoder(
new CryptoPP::FileSink(os2),
true, 64);
305 os <<
"Signature Information:\n";
307 os <<
" Signature Type: ";
310 os <<
"DigestSha256";
313 os <<
"SignatureSha256WithRsa";
316 os <<
"SignatureSha256WithEcdsa";
319 os <<
"Unknown Signature Type";
325 os <<
" Key Locator: ";
326 switch (keyLocator.
getType()) {
331 os <<
"(Self-Signed) " << keyLocator.
getName();
333 os <<
"(Name) " << keyLocator.
getName();
Data & setContentType(uint32_t type)
Copyright (c) 2011-2015 Regents of the University of California.
time::system_clock::TimePoint m_notBefore
void wireDecode(const Block &wire)
Decode from the wire format.
Copyright (c) 2013-2016 Regents of the University of California.
size_t DEREncodeGeneralTime(CryptoPP::BufferedTransformation &bt, const time::system_clock::TimePoint &time)
const Block & getContent() const
Get content Block.
std::ostream & operator<<(std::ostream &os, const Certificate &cert)
const Name & getName() const
Get name of the Data packet.
const Name & getName() const
get Name element
Certificate()
The default constructor.
SubjectDescriptionList m_subjectDescriptionList
Data & setContent(const uint8_t *buffer, size_t bufferSize)
Set the content from the buffer (buffer will be copied)
Class representing a wire element of NDN-TLV packet format.
indicates KeyLocator contains a Name
static time_point now() noexcept
Table::const_iterator iterator
bool isTooEarly()
Check if the certificate is valid.
void BERDecodeTime(CryptoPP::BufferedTransformation &bt, time::system_clock::TimePoint &time)
indicates KeyLocator is empty (internal use only)
A CertificateSubjectDescription represents the SubjectDescription entry in a Certificate.
void encode()
encode certificate info into content
Name abstraction to represent an absolute name.
bool isPrefixOf(const Name &name) const
Check if the N components of this name are the same as the first N components of the given name...
std::string toIsoString(const system_clock::TimePoint &timePoint)
Convert to the ISO string representation of the time (YYYYMMDDTHHMMSS,fffffffff)
indicates KeyLocator contains a KeyDigest
shared_ptr< Buffer > buf()
Flush written data to the stream and return shared pointer to the underlying buffer.
void printCertificate(std::ostream &os, const std::string &indent="") const
indicates content is a public key
bool isTooLate()
Check if the certificate is valid.
implements an output stream that constructs ndn::Buffer
void decode(CryptoPP::BufferedTransformation &in)
A CertificateExtension represents the Extension entry in a certificate.
const Signature & getSignature() const
time::system_clock::TimePoint m_notAfter
ExtensionList m_extensionList
a concept check for TLV abstraction with .wireEncode method
const KeyLocator & getKeyLocator() const
Get KeyLocator.
void wireDecode(const Block &wire)
KeyType getKeyType() const
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
Output to stream with specified indent or prefix.
void encode(CryptoPP::BufferedTransformation &out) const