71 size_t* bytesRead =
nullptr);
81 Error encode(uint8_t* buf,
size_t bufSize,
size_t& encodedLen)
const;
98 Error setNotBefore(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute,
112 const char*
notBefore()
const {
return notBefore_.data(); }
122 Error setNotAfter(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute,
136 const char*
notAfter()
const {
return notAfter_.data(); }
145 bool isValidAt(std::string_view currentTimestamp)
const;
153 std::array<char, VALIDITY_TIMESTAMP_SIZE> notBefore_{};
154 std::array<char, VALIDITY_TIMESTAMP_SIZE> notAfter_{};
225 Error encode(uint8_t* buf,
size_t bufSize,
size_t& encodedLen)
const;
260 const uint8_t*
keyId()
const {
return keyId_.data(); }
285 const uint8_t*
issuerId()
const {
return issuerId_.data(); }
335 const uint8_t*
publicKey()
const {
return publicKey_.data(); }
416 bool verifyHmac(
const uint8_t* key,
size_t keyLen)
const;
434 bool isValidAt(std::string_view timestamp)
const;
444 Error encodeSignedPortion(uint8_t* buf,
size_t bufSize,
size_t& encodedLen)
const;
447 std::array<uint8_t, 32> keyId_{};
448 size_t keyIdSize_ = 0;
449 std::array<uint8_t, 32> issuerId_{};
450 size_t issuerIdSize_ = 0;
451 uint64_t version_ = 0;
452 std::array<uint8_t, CERTIFICATE_MAX_KEY_SIZE> publicKey_{};
453 size_t publicKeySize_ = 0;
456 std::array<uint8_t, SIGNATURE_MAX_SIZE> signatureValue_{};
457 size_t signatureSize_ = 0;
constexpr size_t CERTIFICATE_MAX_KEY_SIZE
Maximum public key size (DER-encoded SubjectPublicKeyInfo)
constexpr size_t VALIDITY_TIMESTAMP_SIZE
Length of ValidityPeriod ISO 8601 format string (YYYYMMDDThhmmss)
Certificate & setVersion(uint64_t version)
Set the version.
SignatureType signatureType() const
Get the signature type.
bool isValidAt(std::string_view timestamp) const
Check if the certificate is valid at a given time.
Error setIssuerId(const uint8_t *id, size_t len)
Set the Issuer ID (bytes)
Error signWithDigestSha256()
Sign with DigestSha256.
const uint8_t * issuerId() const
Get the Issuer ID.
Error toData(Data &data) const
Convert the Certificate to a Data packet.
static Result< Certificate > fromWire(const uint8_t *buf, size_t len)
Decode a Certificate from TLV wire format.
const uint8_t * publicKey() const
Get the public key.
Certificate & setSignatureType(SignatureType type)
Set the signature type.
size_t publicKeySize() const
Get the public key size.
ValidityPeriod & validity()
Get the validity period.
Error signWithHmac(const uint8_t *key, size_t keyLen)
Sign with HMAC-SHA256.
Certificate()=default
Default constructor.
Certificate & setValidity(const ValidityPeriod &validity)
Set the validity period.
bool verifyHmac(const uint8_t *key, size_t keyLen) const
Verify an HMAC-SHA256 signature.
Error setKeyId(const uint8_t *id, size_t len)
Set the Key ID.
Certificate & setIdentityName(const Name &name)
Set the identity name.
Error encode(uint8_t *buf, size_t bufSize, size_t &encodedLen) const
Encode the Certificate to TLV wire format.
const Name & identityName() const
Get the identity name.
Error buildName(Name &name) const
Build the full certificate name and store it in a Name.
bool verifyDigestSha256() const
Verify a DigestSha256 signature.
Error setPublicKey(const uint8_t *key, size_t len)
Set the public key.
static Result< Certificate > fromData(const Data &data)
Create a Certificate from a Data packet.
const uint8_t * keyId() const
Get the Key ID.
size_t issuerIdSize() const
Get the Issuer ID size.
const ValidityPeriod & validity() const
Get the validity period (const)
size_t keyIdSize() const
Get the Key ID size.
uint64_t version() const
Get the version.
static Result< ValidityPeriod > fromWire(const uint8_t *buf, size_t len, size_t *bytesRead=nullptr)
Decode a ValidityPeriod from TLV wire format.
const char * notAfter() const
Get the NotAfter time as an ISO 8601 string.
Error setNotAfter(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second)
Set the NotAfter time from date/time components.
bool equals(const ValidityPeriod &other) const
Check equality of two validity periods.
ValidityPeriod()=default
Default constructor.
static Result< ValidityPeriod > fromStrings(std::string_view notBefore, std::string_view notAfter)
Create a ValidityPeriod from ISO 8601 format strings.
Error setNotBefore(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second)
Set the NotBefore time from date/time components.
bool isValidAt(std::string_view currentTimestamp) const
Check if the current time is within the validity period.
Error encode(uint8_t *buf, size_t bufSize, size_t &encodedLen) const
Encode the ValidityPeriod to TLV wire format.
const char * notBefore() const
Get the NotBefore time as an ISO 8601 string.
Common definitions for the NDN protocol stack.
constexpr uint32_t ValidityPeriod
Validity period (253)
SignatureType
Signature type.