23 #ifndef NDN_CERTIFICATE_V2_HPP
24 #define NDN_CERTIFICATE_V2_HPP
26 #include <ndn-cpp/security/validity-period.hpp>
27 #include <ndn-cpp/data.hpp>
87 class Error :
public std::runtime_error
90 Error(
const std::string& what)
91 : std::runtime_error(what)
202 (
const uint8_t* input,
size_t inputLength,
210 (
const std::vector<uint8_t>& input,
213 wireDecode(&input[0], input.size(), wireFormat);
245 static const Name::Component&
248 static const int VERSION_OFFSET = -1;
249 static const int ISSUER_ID_OFFSET = -2;
250 static const int KEY_ID_OFFSET = -3;
251 static const int KEY_COMPONENT_OFFSET = -4;
252 static const int MIN_CERT_NAME_LENGTH = 4;
253 static const int MIN_KEY_NAME_LENGTH = 2;
256 static Name::Component* KEY_COMPONENT;
263 operator << (std::ostream& os,
const CertificateV2& certificate)
265 certificate.printCertificate(os);
Name getIdentity() const
Get the identity name from the certificate name.
Definition: certificate-v2.hpp:121
Name::Component getIssuerId() const
Get issuer ID component from the certificate name.
Definition: certificate-v2.hpp:135
A CertificateV2::Error extends runtime_error and represents errors for not complying with the certifi...
Definition: certificate-v2.hpp:87
CertificateV2()
Create a CertificateV2 with content type KEY and default or unspecified values.
Definition: certificate-v2.cpp:36
bool isValid(MillisecondsSince1970 time=-1.0) const
Check if the time falls within the validity period.
Definition: validity-period.cpp:34
virtual void wireDecode(const Blob &input, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
Override to call the base class wireDecode then check the certificate format.
Definition: certificate-v2.cpp:135
Name getKeyName() const
Get key name from the certificate name.
Definition: certificate-v2.hpp:114
static const Name::Component & getKEY_COMPONENT()
Get the name component for "KEY".
Definition: certificate-v2.cpp:175
bool isValid(MillisecondsSince1970 time=-1.0) const
Check if the time falls within the validity period.
Definition: certificate-v2.hpp:168
static Name extractKeyNameFromCertName(const Name &certificateName)
Extract key name from certificateName.
Definition: certificate-v2.cpp:162
CertificateV2 represents a certificate following the certificate format naming convention.
Definition: certificate-v2.hpp:81
A Name::Component holds a read-only name component value.
Definition: name.hpp:45
A ValidityPeriod is used in a Data packet's SignatureInfo and represents the begin and end times of a...
Definition: validity-period.hpp:37
Name::Component getKeyId() const
Get the key ID component from the certificate name.
Definition: certificate-v2.hpp:128
static bool isValidName(const Name &certificateName)
Check if certificateName follows the naming convention for a certificate.
Definition: certificate-v2.cpp:142
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
A Blob holds a pointer to an immutable byte array implemented as const std::vector<uint8_t>.
Definition: blob.hpp:42
double MillisecondsSince1970
The calendar time represented as the number of milliseconds since 1/1/1970.
Definition: common.hpp:119
ValidityPeriod & getValidityPeriod()
Get the certificate validity period from the SignatureInfo.
Definition: certificate-v2.cpp:75
const Blob & getPublicKey() const
Get the public key DER encoding.
Definition: certificate-v2.cpp:66
void printCertificate() const
Print the certificate information to std::cout.
Definition: certificate-v2.hpp:186
void get(NameLite &nameLite) const
Set nameLite to point to the components in this name, without copying any memory. ...
Definition: name.cpp:463
Name getPrefix(int nComponents) const
Return a new Name with the first nComponents components of this Name.
Definition: name.hpp:1102
static Name extractIdentityFromCertName(const Name &certificateName)
Extract the identity namespace from certificateName.
Definition: certificate-v2.cpp:150