NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
ndn::security::v2::Certificate Class Reference

Represents an NDN certificate following the version 2.0 format. More...

#include <certificate.hpp>

Inheritance diagram for ndn::security::v2::Certificate:
Collaboration diagram for ndn::security::v2::Certificate:

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 BlockwireEncode (EncodingBuffer &encoder, span< const uint8_t > signature) const
 Finalize Data packet encoding with the specified signature. More...
 
const BlockwireEncode () 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 NamegetFullName () const
 Get full name including implicit digest. More...
 
const NamegetName () const noexcept
 Get name. More...
 
DatasetName (const Name &name)
 Set name. More...
 
const MetaInfogetMetaInfo () const noexcept
 Get MetaInfo. More...
 
DatasetMetaInfo (const MetaInfo &metaInfo)
 Set MetaInfo. More...
 
bool hasContent () const noexcept
 Return whether this Data has a Content element. More...
 
const BlockgetContent () const noexcept
 Get the Content element. More...
 
DatasetContent (const Block &block)
 Set Content from a Block. More...
 
DatasetContent (span< const uint8_t > value)
 Set Content by copying from a contiguous sequence of bytes. More...
 
DatasetContent (const uint8_t *value, size_t length)
 Set Content by copying from a raw buffer. More...
 
DatasetContent (ConstBufferPtr value)
 Set Content from a shared buffer. More...
 
DataunsetContent ()
 Remove the Content element. More...
 
const SignatureInfogetSignatureInfo () const noexcept
 Get SignatureInfo. More...
 
DatasetSignatureInfo (const SignatureInfo &info)
 Set SignatureInfo. More...
 
const BlockgetSignatureValue () const noexcept
 Get SignatureValue. More...
 
DatasetSignatureValue (ConstBufferPtr value)
 Set SignatureValue. More...
 
InputBuffers extractSignedRanges () const
 Extract ranges of Data covered by the signature. More...
 
uint32_t getContentType () const
 
DatasetContentType (uint32_t type)
 
time::milliseconds getFreshnessPeriod () const
 
DatasetFreshnessPeriod (time::milliseconds freshnessPeriod)
 
const optional< name::Component > & getFinalBlock () const
 
DatasetFinalBlock (optional< name::Component > finalBlockId)
 
int32_t getSignatureType () const noexcept
 Get SignatureType. More...
 
optional< KeyLocatorgetKeyLocator () 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...
 

Detailed Description

Represents an NDN certificate following the version 2.0 format.

Example of an NDN certificate name:

/edu/ucla/cs/yingdi/KEY/%03%CD...%F1/%9F%D3...%B7/v=1617592200702
\_________________/ \___________/\___________/\______________/
Identity Name KeyId IssuerId Version
\__________________________________/
Key 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.
See also
doc/specs/certificate.rst

Definition at line 60 of file certificate.hpp.

Constructor & Destructor Documentation

◆ Certificate() [1/4]

ndn::security::v2::Certificate::Certificate ( )

Definition at line 47 of file certificate.cpp.

References ndn::tlv::ContentType_Key, and ndn::Data::setContentType().

◆ Certificate() [2/4]

ndn::security::v2::Certificate::Certificate ( Data &&  data)
explicit

Construct certificate from a data object.

Exceptions
tlv::Errorif 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().

◆ Certificate() [3/4]

ndn::security::v2::Certificate::Certificate ( const Data data)
explicit

Construct certificate from a data object.

Exceptions
tlv::Errorif data does not follow certificate format

Definition at line 69 of file certificate.cpp.

◆ Certificate() [4/4]

ndn::security::v2::Certificate::Certificate ( const Block block)
explicit

Construct certificate from a wire encoding.

Exceptions
tlv::Errorif wire encoding is invalid or does not follow certificate format

Definition at line 74 of file certificate.cpp.

Member Function Documentation

◆ getKeyName()

◆ getIdentity()

Name ndn::security::v2::Certificate::getIdentity ( ) const

◆ getKeyId()

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.

◆ getIssuerId()

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.

◆ getPublicKey()

Buffer ndn::security::v2::Certificate::getPublicKey ( ) const

Get public key bits (in PKCS#8 format)

Exceptions
ErrorIf 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<<().

◆ getValidityPeriod()

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<<().

◆ isValid()

bool ndn::security::v2::Certificate::isValid ( const time::system_clock::TimePoint ts = time::system_clock::now()) const

◆ getExtension()

Block ndn::security::v2::Certificate::getExtension ( uint32_t  type) const

Get extension with TLV type.

Exceptions
ErrorThe 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().

◆ isValidName()

bool ndn::security::v2::Certificate::isValidName ( const Name certName)
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().

Member Data Documentation

◆ VERSION_OFFSET

const ssize_t ndn::security::v2::Certificate::VERSION_OFFSET = -1
static

Definition at line 145 of file certificate.hpp.

◆ ISSUER_ID_OFFSET

const ssize_t ndn::security::v2::Certificate::ISSUER_ID_OFFSET = -2
static

Definition at line 146 of file certificate.hpp.

Referenced by getIssuerId().

◆ KEY_COMPONENT_OFFSET

const ssize_t ndn::security::v2::Certificate::KEY_COMPONENT_OFFSET = -4
static

◆ KEY_ID_OFFSET

const ssize_t ndn::security::v2::Certificate::KEY_ID_OFFSET = -3
static

Definition at line 148 of file certificate.hpp.

Referenced by getKeyId(), and getKeyName().

◆ MIN_CERT_NAME_LENGTH

const size_t ndn::security::v2::Certificate::MIN_CERT_NAME_LENGTH = 4
static

Definition at line 149 of file certificate.hpp.

◆ MIN_KEY_NAME_LENGTH

const size_t ndn::security::v2::Certificate::MIN_KEY_NAME_LENGTH = 2
static

Definition at line 150 of file certificate.hpp.

◆ KEY_COMPONENT

const name::Component ndn::security::v2::Certificate::KEY_COMPONENT
static

◆ DEFAULT_ISSUER_ID

const name::Component ndn::security::v2::Certificate::DEFAULT_ISSUER_ID
static

Definition at line 152 of file certificate.hpp.


The documentation for this class was generated from the following files: