ndn::security::pib::Key Class Reference

Frontend handle for a key in the PIB. More...

#include <ndn-cxx/security/pib/key.hpp>

+ Inheritance diagram for ndn::security::pib::Key:
+ Collaboration diagram for ndn::security::pib::Key:

Public Member Functions

 Key () noexcept
 Default constructor. More...
 
Certificate getCertificate (const Name &certName) const
 Return the certificate with the given name. More...
 
const CertificateContainergetCertificates () const
 Return all the certificates of this key. More...
 
const CertificategetDefaultCertificate () const
 Return the default certificate for this key. More...
 
const NamegetIdentity () const
 Return the name of the owning identity. More...
 
KeyType getKeyType () const
 Return the key type. More...
 
const NamegetName () const
 Return the name of the key. More...
 
span< const uint8_t > getPublicKey () const
 Return the raw public key bits. More...
 
 operator bool () const noexcept
 Returns true if the instance is valid. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Key &key)
 
bool operator== (const Key &lhs, const Key &rhs) noexcept
 

Detailed Description

Frontend handle for a key in the PIB.

Key is at the second level in PIB's Identity-Key-Certificate hierarchy. A key has the name /<Identity>/KEY/<KeyId>, and contains one or more certificates, one of which is set as default certificate of that key. Certificates can be directly accessed from a Key object.

Definition at line 44 of file key.hpp.

Constructor & Destructor Documentation

◆ Key()

ndn::security::pib::Key::Key ( )
defaultnoexcept

Default constructor.

A Key created using this default constructor is just a placeholder. You can obtain an actual instance from Identity::getKey(). A typical usage would be for exception handling:

Key key;
try {
key = identity.getKey(...);
}
catch (const Pib::Error&) {
...
}
Key() noexcept
Default constructor.

An instance created using this constructor is invalid. Calling a member function on an invalid Key instance may throw an std::domain_error.

Member Function Documentation

◆ getCertificate()

Certificate ndn::security::pib::Key::getCertificate ( const Name certName) const

Return the certificate with the given name.

Exceptions
std::invalid_argumentcertName does not match the key name.
Pib::Errorthe certificate does not exist.

Definition at line 72 of file key.cpp.

◆ getCertificates()

const CertificateContainer & ndn::security::pib::Key::getCertificates ( ) const

Return all the certificates of this key.

Definition at line 78 of file key.cpp.

◆ getDefaultCertificate()

const Certificate & ndn::security::pib::Key::getDefaultCertificate ( ) const

Return the default certificate for this key.

Exceptions
Pib::Errorthe default certificate does not exist.

Definition at line 96 of file key.cpp.

◆ getIdentity()

const Name & ndn::security::pib::Key::getIdentity ( ) const

Return the name of the owning identity.

Definition at line 42 of file key.cpp.

◆ getKeyType()

KeyType ndn::security::pib::Key::getKeyType ( ) const

Return the key type.

Definition at line 48 of file key.cpp.

◆ getName()

const Name & ndn::security::pib::Key::getName ( ) const

Return the name of the key.

Definition at line 36 of file key.cpp.

◆ getPublicKey()

span< const uint8_t > ndn::security::pib::Key::getPublicKey ( ) const

Return the raw public key bits.

Definition at line 54 of file key.cpp.

◆ operator bool()

ndn::security::pib::Key::operator bool ( ) const
explicitnoexcept

Returns true if the instance is valid.

Definition at line 101 of file key.cpp.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Key key 
)
friend

Definition at line 184 of file key.hpp.

◆ operator==

bool operator== ( const Key lhs,
const Key rhs 
)
friend

Definition at line 179 of file key.hpp.