|
ndn-embeds 0.1.0
Lightweight NDN protocol stack for embedded systems
|
NDN Certificate. More...
#include <ndn/certificate.hpp>
Public Member Functions | |
| Certificate ()=default | |
| Default constructor. | |
| Error | toData (Data &data) const |
| Convert the Certificate to a Data packet. | |
| Error | encode (uint8_t *buf, size_t bufSize, size_t &encodedLen) const |
| Encode the Certificate to TLV wire format. | |
| Error | buildName (Name &name) const |
| Build the full certificate name and store it in a Name. | |
| bool | isValidAt (std::string_view timestamp) const |
| Check if the certificate is valid at a given time. | |
Identity Name | |
| const Name & | identityName () const |
| Get the identity name. | |
| Certificate & | setIdentityName (const Name &name) |
| Set the identity name. | |
| Error | setIdentityName (std::string_view uri) |
| Set the identity name from a URI string. | |
Key ID | |
| const uint8_t * | keyId () const |
| Get the Key ID. | |
| size_t | keyIdSize () const |
| Get the Key ID size. | |
| Error | setKeyId (const uint8_t *id, size_t len) |
| Set the Key ID. | |
Issuer ID | |
| const uint8_t * | issuerId () const |
| Get the Issuer ID. | |
| size_t | issuerIdSize () const |
| Get the Issuer ID size. | |
| Error | setIssuerId (const uint8_t *id, size_t len) |
| Set the Issuer ID (bytes) | |
| Error | setIssuerId (std::string_view id) |
| Set the Issuer ID (string) | |
Version | |
| uint64_t | version () const |
| Get the version. | |
| Certificate & | setVersion (uint64_t version) |
| Set the version. | |
Public Key | |
| const uint8_t * | publicKey () const |
| Get the public key. | |
| size_t | publicKeySize () const |
| Get the public key size. | |
| Error | setPublicKey (const uint8_t *key, size_t len) |
| Set the public key. | |
Validity Period | |
| const ValidityPeriod & | validity () const |
| Get the validity period (const) | |
| ValidityPeriod & | validity () |
| Get the validity period. | |
| Certificate & | setValidity (const ValidityPeriod &validity) |
| Set the validity period. | |
Signature | |
| SignatureType | signatureType () const |
| Get the signature type. | |
| Certificate & | setSignatureType (SignatureType type) |
| Set the signature type. | |
| Error | signWithDigestSha256 () |
| Sign with DigestSha256. | |
| Error | signWithHmac (const uint8_t *key, size_t keyLen) |
| Sign with HMAC-SHA256. | |
| bool | verifyDigestSha256 () const |
| Verify a DigestSha256 signature. | |
| bool | verifyHmac (const uint8_t *key, size_t keyLen) const |
| Verify an HMAC-SHA256 signature. | |
Static Public Member Functions | |
| static Result< Certificate > | fromData (const Data &data) |
| Create a Certificate from a Data packet. | |
| static Result< Certificate > | fromWire (const uint8_t *buf, size_t len) |
| Decode a Certificate from TLV wire format. | |
NDN Certificate.
A class representing an NDN certificate. A certificate is a special Data packet with ContentType=KEY, Content=public key (DER format), and a ValidityPeriod in the SignatureInfo.
Certificate name format: /<IdentityName>/KEY/<KeyId>/<IssuerId>/<Version>
Definition at line 185 of file certificate.hpp.
Build the full certificate name and store it in a Name.
/<IdentityName>/KEY/<KeyId>/<IssuerId>/<Version>
| name | Output Name |
Definition at line 454 of file certificate.cpp.
References ndn::Name::appendComponent(), ndn::Name::component(), and ndn::Name::componentCount().
Referenced by toData().
| Error ndn::Certificate::encode | ( | uint8_t * | buf, |
| size_t | bufSize, | ||
| size_t & | encodedLen | ||
| ) | const |
Encode the Certificate to TLV wire format.
| buf | Output buffer |
| bufSize | Buffer size |
| encodedLen | Stores the number of encoded bytes |
Definition at line 347 of file certificate.cpp.
References ndn::tlv::Data, ndn::PACKET_MAX_SIZE, ndn::tlv::SignatureValue, ndn::TlvEncoder::size(), ndn::varNumberSize(), ndn::TlvEncoder::writeBytes(), ndn::TlvEncoder::writeLength(), ndn::TlvEncoder::writeTlv(), and ndn::TlvEncoder::writeType().
|
static |
Create a Certificate from a Data packet.
| data | Data packet |
Definition at line 222 of file certificate.cpp.
References ndn::Name::appendComponent(), ndn::CERTIFICATE_MAX_KEY_SIZE, ndn::Name::component(), ndn::Name::componentCount(), ndn::Data::content(), ndn::Data::contentSize(), ndn::Data::contentType(), ndn::Data::hasContent(), ndn::Data::hasSignature(), identityName(), ndn::Data::name(), ndn::SIGNATURE_MAX_SIZE, ndn::Data::signatureType(), ndn::Data::signatureValue(), ndn::Data::signatureValueSize(), ndn::NameComponent::value, and version().
Referenced by fromWire().
|
static |
Decode a Certificate from TLV wire format.
| buf | Input buffer |
| len | Buffer length |
Definition at line 309 of file certificate.cpp.
References fromData(), and ndn::Data::fromWire().
|
inline |
Get the identity name.
Definition at line 235 of file certificate.hpp.
Referenced by fromData().
|
inline |
Get the Issuer ID.
Definition at line 285 of file certificate.hpp.
|
inline |
Get the Issuer ID size.
Definition at line 291 of file certificate.hpp.
| bool ndn::Certificate::isValidAt | ( | std::string_view | timestamp | ) | const |
Check if the certificate is valid at a given time.
| timestamp | ISO 8601 format time (YYYYMMDDThhmmss) |
Definition at line 663 of file certificate.cpp.
References ndn::ValidityPeriod::isValidAt().
|
inline |
|
inline |
|
inline |
Get the public key.
Definition at line 335 of file certificate.hpp.
|
inline |
Get the public key size.
Definition at line 341 of file certificate.hpp.
| Certificate & ndn::Certificate::setIdentityName | ( | const Name & | name | ) |
Set the identity name.
| name | Identity name |
Definition at line 394 of file certificate.cpp.
| Error ndn::Certificate::setIdentityName | ( | std::string_view | uri | ) |
Set the identity name from a URI string.
| uri | URI string |
Definition at line 399 of file certificate.cpp.
References ndn::Name::fromUri().
| Error ndn::Certificate::setIssuerId | ( | const uint8_t * | id, |
| size_t | len | ||
| ) |
Set the Issuer ID (bytes)
| id | Issuer ID bytes |
| len | Size in bytes |
Definition at line 417 of file certificate.cpp.
Referenced by setIssuerId().
| Error ndn::Certificate::setIssuerId | ( | std::string_view | id | ) |
Set the Issuer ID (string)
| id | Issuer ID string |
Definition at line 426 of file certificate.cpp.
References setIssuerId().
| Error ndn::Certificate::setKeyId | ( | const uint8_t * | id, |
| size_t | len | ||
| ) |
Set the Key ID.
| id | Key ID bytes |
| len | Size in bytes |
Definition at line 408 of file certificate.cpp.
| Error ndn::Certificate::setPublicKey | ( | const uint8_t * | key, |
| size_t | len | ||
| ) |
Set the public key.
| key | DER-encoded public key |
| len | Size in bytes |
Definition at line 435 of file certificate.cpp.
References ndn::CERTIFICATE_MAX_KEY_SIZE.
| Certificate & ndn::Certificate::setSignatureType | ( | SignatureType | type | ) |
Set the signature type.
Definition at line 449 of file certificate.cpp.
| Certificate & ndn::Certificate::setValidity | ( | const ValidityPeriod & | validity | ) |
Set the validity period.
| validity | Validity period |
Definition at line 444 of file certificate.cpp.
References validity().
| Certificate & ndn::Certificate::setVersion | ( | uint64_t | version | ) |
Set the version.
| version | Version number |
Definition at line 430 of file certificate.cpp.
References version().
|
inline |
Get the signature type.
Definition at line 383 of file certificate.hpp.
| Error ndn::Certificate::signWithDigestSha256 | ( | ) |
Sign with DigestSha256.
Definition at line 574 of file certificate.cpp.
References ndn::PACKET_MAX_SIZE, and ndn::SHA256_DIGEST_SIZE.
| Error ndn::Certificate::signWithHmac | ( | const uint8_t * | key, |
| size_t | keyLen | ||
| ) |
Sign with HMAC-SHA256.
| key | Key data |
| keyLen | Key length |
Definition at line 593 of file certificate.cpp.
References ndn::HMAC_SHA256_SIZE, and ndn::PACKET_MAX_SIZE.
Convert the Certificate to a Data packet.
| data | Output Data packet |
Definition at line 319 of file certificate.cpp.
References buildName(), ndn::Data::setContent(), ndn::Data::setContentType(), ndn::Data::setFreshnessPeriod(), ndn::Data::setName(), and ndn::Data::setSignatureType().
|
inline |
Get the validity period.
Definition at line 366 of file certificate.hpp.
|
inline |
Get the validity period (const)
Definition at line 360 of file certificate.hpp.
Referenced by setValidity().
| bool ndn::Certificate::verifyDigestSha256 | ( | ) | const |
Verify a DigestSha256 signature.
Definition at line 616 of file certificate.cpp.
References ndn::PACKET_MAX_SIZE, and ndn::SHA256_DIGEST_SIZE.
| bool ndn::Certificate::verifyHmac | ( | const uint8_t * | key, |
| size_t | keyLen | ||
| ) | const |
Verify an HMAC-SHA256 signature.
| key | Key data |
| keyLen | Key length |
Definition at line 638 of file certificate.cpp.
References ndn::HMAC_SHA256_SIZE, and ndn::PACKET_MAX_SIZE.
|
inline |
Get the version.
Definition at line 317 of file certificate.hpp.
Referenced by fromData(), and setVersion().