Represents an NDN certificate following the version 2.0 format. More...
#include <certificate.hpp>
Public Member Functions | |
Certificate () | |
Certificate (Data &&data) | |
Construct certificate from a data object. More... | |
Certificate (const Data &data) | |
Construct certificate from a data object. More... | |
Certificate (const Block &block) | |
Construct certificate from a wire encoding. More... | |
Name | getKeyName () const |
Get key name. More... | |
Name | getIdentity () const |
Get identity name. More... | |
name::Component | getKeyId () const |
Get key ID. More... | |
name::Component | getIssuerId () const |
Get issuer ID. More... | |
Buffer | getPublicKey () const |
Get public key bits (in PKCS#8 format) More... | |
ValidityPeriod | getValidityPeriod () const |
Get validity period of the certificate. More... | |
bool | isValid (const time::system_clock::TimePoint &ts=time::system_clock::now()) const |
Check if the certificate is valid at ts . More... | |
Block | getExtension (uint32_t type) const |
Get extension with TLV type . More... | |
Public Member Functions inherited from ndn::Data | |
Data (const Name &name=Name()) | |
Construct an unsigned Data packet with given name and empty Content. More... | |
Data (const Block &wire) | |
Construct a Data packet by decoding from wire . More... | |
template<encoding::Tag TAG> | |
size_t | wireEncode (EncodingImpl< TAG > &encoder, bool wantUnsignedPortionOnly=false) const |
Prepend wire encoding to encoder . More... | |
const Block & | wireEncode (EncodingBuffer &encoder, span< const uint8_t > signature) const |
Finalize Data packet encoding with the specified signature. More... | |
const Block & | wireEncode () const |
Encode into a Block. More... | |
void | wireDecode (const Block &wire) |
Decode from wire . More... | |
bool | hasWire () const noexcept |
Check if this instance has cached wire encoding. More... | |
const Name & | getFullName () const |
Get full name including implicit digest. More... | |
const Name & | getName () const noexcept |
Get name. More... | |
Data & | setName (const Name &name) |
Set name. More... | |
const MetaInfo & | getMetaInfo () const noexcept |
Get MetaInfo. More... | |
Data & | setMetaInfo (const MetaInfo &metaInfo) |
Set MetaInfo. More... | |
bool | hasContent () const noexcept |
Return whether this Data has a Content element. More... | |
const Block & | getContent () const noexcept |
Get the Content element. More... | |
Data & | setContent (const Block &block) |
Set Content from a Block. More... | |
Data & | setContent (span< const uint8_t > value) |
Set Content by copying from a contiguous sequence of bytes. More... | |
Data & | setContent (const uint8_t *value, size_t length) |
Set Content by copying from a raw buffer. More... | |
Data & | setContent (ConstBufferPtr value) |
Set Content from a shared buffer. More... | |
Data & | unsetContent () |
Remove the Content element. More... | |
const SignatureInfo & | getSignatureInfo () const noexcept |
Get SignatureInfo. More... | |
Data & | setSignatureInfo (const SignatureInfo &info) |
Set SignatureInfo. More... | |
const Block & | getSignatureValue () const noexcept |
Get SignatureValue. More... | |
Data & | setSignatureValue (ConstBufferPtr value) |
Set SignatureValue. More... | |
InputBuffers | extractSignedRanges () const |
Extract ranges of Data covered by the signature. More... | |
uint32_t | getContentType () const |
Data & | setContentType (uint32_t type) |
time::milliseconds | getFreshnessPeriod () const |
Data & | setFreshnessPeriod (time::milliseconds freshnessPeriod) |
const optional< name::Component > & | getFinalBlock () const |
Data & | setFinalBlock (optional< name::Component > finalBlockId) |
int32_t | getSignatureType () const noexcept |
Get SignatureType. More... | |
optional< KeyLocator > | getKeyLocator () const noexcept |
Get KeyLocator. More... | |
Public Member Functions inherited from ndn::PacketBase | |
uint64_t | getCongestionMark () const |
get the value of the CongestionMark tag More... | |
void | setCongestionMark (uint64_t mark) |
set the CongestionMark tag to the specified value More... | |
Public Member Functions inherited from ndn::TagHost | |
template<typename T > | |
shared_ptr< T > | getTag () const |
get a tag item More... | |
template<typename T > | |
void | setTag (shared_ptr< T > tag) const |
set a tag item More... | |
template<typename T > | |
void | removeTag () const |
remove tag item More... | |
Static Public Member Functions | |
static bool | isValidName (const Name &certName) |
Check if the specified name follows the naming convention for the certificate. More... | |
Static Public Attributes | |
static const ssize_t | VERSION_OFFSET = -1 |
static const ssize_t | ISSUER_ID_OFFSET = -2 |
static const ssize_t | KEY_COMPONENT_OFFSET = -4 |
static const ssize_t | KEY_ID_OFFSET = -3 |
static const size_t | MIN_CERT_NAME_LENGTH = 4 |
static const size_t | MIN_KEY_NAME_LENGTH = 2 |
static const name::Component | KEY_COMPONENT |
static const name::Component | DEFAULT_ISSUER_ID |
Additional Inherited Members | |
Protected Member Functions inherited from ndn::Data | |
void | resetWire () |
Clear wire encoding and cached FullName. More... | |
Represents an NDN certificate following the version 2.0 format.
Example of an NDN certificate name:
Notes:
KeyId
is an opaque name component to identify an instance of the public key for the certificate namespace. The value of KeyId is controlled by the namespace owner. The library includes helpers for generation of key IDs using 8-byte random number, SHA-256 digest of the public key, timestamp, or a specified numerical identifier.IssuerId
is an opaque name component to identify the issuer of the certificate. The value is controlled by the issuer. The library includes helpers to set issuer ID to a 8-byte random number, SHA-256 digest of the issuer's public key, or a specified numerical identifier.Key Name
is a logical name of the key used for management purposes. The key name includes the identity name, the keyword KEY
, and the KeyId
component.Definition at line 60 of file certificate.hpp.
ndn::security::v2::Certificate::Certificate | ( | ) |
Definition at line 47 of file certificate.cpp.
References ndn::tlv::ContentType_Key, and ndn::Data::setContentType().
|
explicit |
Construct certificate from a data object.
tlv::Error | if data does not follow certificate format |
Definition at line 52 of file certificate.cpp.
References ndn::tlv::ContentType_Key, ndn::Data::getContent(), ndn::Data::getContentType(), ndn::Data::getFreshnessPeriod(), ndn::Data::getName(), isValidName(), NDN_THROW, and ndn::to_string().
|
explicit |
Construct certificate from a data object.
tlv::Error | if data does not follow certificate format |
Definition at line 69 of file certificate.cpp.
|
explicit |
Construct certificate from a wire encoding.
tlv::Error | if wire encoding is invalid or does not follow certificate format |
Definition at line 74 of file certificate.cpp.
Name ndn::security::v2::Certificate::getKeyName | ( | ) | const |
Get key name.
Definition at line 80 of file certificate.cpp.
References ndn::Data::getName(), ndn::Name::getPrefix(), and KEY_ID_OFFSET.
Referenced by ndn::security::v2::KeyChain::addCertificate(), ndn::security::v2::KeyChain::exportSafeBag(), ndn::security::v2::KeyChain::importSafeBag(), and ndn::security::v2::operator<<().
Name ndn::security::v2::Certificate::getIdentity | ( | ) | const |
Get identity name.
Definition at line 86 of file certificate.cpp.
References ndn::Data::getName(), ndn::Name::getPrefix(), and KEY_COMPONENT_OFFSET.
Referenced by ndn::security::v2::KeyChain::exportSafeBag(), and ndn::security::v2::KeyChain::importSafeBag().
name::Component ndn::security::v2::Certificate::getKeyId | ( | ) | const |
Get key ID.
Definition at line 92 of file certificate.cpp.
References ndn::Name::at(), ndn::Data::getName(), and KEY_ID_OFFSET.
name::Component ndn::security::v2::Certificate::getIssuerId | ( | ) | const |
Get issuer ID.
Definition at line 98 of file certificate.cpp.
References ndn::Name::at(), ndn::Data::getName(), and ISSUER_ID_OFFSET.
Buffer ndn::security::v2::Certificate::getPublicKey | ( | ) | const |
Get public key bits (in PKCS#8 format)
Error | If content is empty |
Definition at line 104 of file certificate.cpp.
References ndn::Data::getContent(), NDN_THROW, ndn::Block::value_begin(), and ndn::Block::value_end().
Referenced by ndn::security::v2::KeyChain::importSafeBag(), and ndn::security::v2::operator<<().
ValidityPeriod ndn::security::v2::Certificate::getValidityPeriod | ( | ) | const |
Get validity period of the certificate.
Definition at line 113 of file certificate.cpp.
References ndn::Data::getSignatureInfo(), and ndn::SignatureInfo::getValidityPeriod().
Referenced by ndn::security::v2::CertificateCache::insert(), and ndn::security::v2::operator<<().
bool ndn::security::v2::Certificate::isValid | ( | const time::system_clock::TimePoint & | ts = time::system_clock::now() | ) | const |
Check if the certificate is valid at ts
.
Definition at line 119 of file certificate.cpp.
References ndn::Data::getSignatureInfo(), ndn::SignatureInfo::getValidityPeriod(), and ndn::security::ValidityPeriod::isValid().
Referenced by ndn::security::v2::Validator::validate().
Block ndn::security::v2::Certificate::getExtension | ( | uint32_t | type | ) | const |
Get extension with TLV type
.
Error | The specified block type does not exist |
Definition at line 125 of file certificate.cpp.
References ndn::SignatureInfo::getCustomTlv(), ndn::Data::getSignatureInfo(), NDN_THROW, and ndn::to_string().
|
static |
Check if the specified name follows the naming convention for the certificate.
Definition at line 135 of file certificate.cpp.
References KEY_COMPONENT, KEY_COMPONENT_OFFSET, and ndn::Name::size().
Referenced by Certificate(), ndn::security::v2::KeyChain::deleteCertificate(), ndn::security::v2::extractIdentityFromCertName(), and ndn::security::v2::extractKeyNameFromCertName().
|
static |
Definition at line 145 of file certificate.hpp.
|
static |
Definition at line 146 of file certificate.hpp.
Referenced by getIssuerId().
|
static |
Definition at line 147 of file certificate.hpp.
Referenced by ndn::security::v2::extractIdentityNameFromKeyLocator(), getIdentity(), and isValidName().
|
static |
Definition at line 148 of file certificate.hpp.
Referenced by getKeyId(), and getKeyName().
|
static |
Definition at line 149 of file certificate.hpp.
|
static |
Definition at line 150 of file certificate.hpp.
|
static |
Definition at line 151 of file certificate.hpp.
Referenced by ndn::security::v2::extractIdentityNameFromKeyLocator(), and isValidName().
|
static |
Definition at line 152 of file certificate.hpp.