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

A frontend handle of a key instance. More...

#include <key.hpp>

Public Member Functions

 Key ()
 Default Constructor. More...
 
 Key (weak_ptr< detail::KeyImpl > impl)
 Create a Key with a backend implementation impl. More...
 
const NamegetName () const
 Get key name. More...
 
const NamegetIdentity () const
 Get the name of the belonging identity. More...
 
KeyType getKeyType () const
 Get key type. More...
 
const BuffergetPublicKey () const
 Get public key bits. More...
 
v2::Certificate getCertificate (const Name &certName) const
 Get a certificate with certName. More...
 
const CertificateContainergetCertificates () const
 Get all certificates for this key. More...
 
const v2::CertificategetDefaultCertificate () const
 Get the default certificate for this Key. More...
 
 operator bool () const
 Check if the Key instance is valid. More...
 
void removeCertificate (const Name &certName) const
 Remove a certificate with certName. More...
 
const v2::CertificatesetDefaultCertificate (const Name &certName) const
 Set an existing certificate with certName as the default certificate. More...
 
const v2::CertificatesetDefaultCertificate (const v2::Certificate &certificate) const
 Add certificate and set it as the default certificate of the key. More...
 

Public Attributes

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE __pad0__: void addCertificate(const v2::Certificate& certificate) const
 

Friends

class v2::KeyChain
 
bool operator!= (const Key &, const Key &)
 

Detailed Description

A frontend handle of a key instance.

Key is at the second level in PIB's Identity-Key-Certificate hierarchy. A Key has a Name (identity + "KEY" + keyId), and contains one or more certificates, one of which is set as the default certificate of this key. A certificate can be directly accessed from a Key object.

Definition at line 49 of file key.hpp.

Constructor & Destructor Documentation

◆ Key() [1/2]

ndn::security::pib::Key::Key ( )
default

Default Constructor.

Key created using this default constructor is just a place holder. It 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&) { ... }

A Key instance created using this constructor is invalid. Calling a member method on an invalid Key instance may cause an std::domain_error.

◆ Key() [2/2]

ndn::security::pib::Key::Key ( weak_ptr< detail::KeyImpl impl)
explicit

Create a Key with a backend implementation impl.

This method should only be used by KeyContainer.

Definition at line 32 of file key.cpp.

Member Function Documentation

◆ getName()

◆ getIdentity()

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

Get the name of the belonging identity.

Definition at line 44 of file key.cpp.

Referenced by ndn::security::v2::KeyChain::deleteKey(), and ndn::security::v2::KeyChain::setDefaultKey().

◆ getKeyType()

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

Get key type.

Definition at line 50 of file key.cpp.

◆ getPublicKey()

const Buffer & ndn::security::pib::Key::getPublicKey ( ) const

Get public key bits.

Definition at line 56 of file key.cpp.

Referenced by ndn::security::v2::KeyChain::addCertificate(), and ndn::security::verifySignature().

◆ getCertificate()

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

Get a certificate with certName.

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

Definition at line 74 of file key.cpp.

◆ getCertificates()

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

Get all certificates for this key.

Definition at line 80 of file key.cpp.

◆ getDefaultCertificate()

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

Get the default certificate for this Key.

Exceptions
Pib::Errorthe default certificate does not exist.

Definition at line 98 of file key.cpp.

Referenced by ndn::security::v2::KeyChain::createIdentity().

◆ operator bool()

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

Check if the Key instance is valid.

Definition at line 103 of file key.cpp.

◆ removeCertificate()

void ndn::security::pib::Key::removeCertificate ( const Name certName) const

Remove a certificate with certName.

Exceptions
std::invalid_argumentcertName does not match key name

Definition at line 68 of file key.cpp.

Referenced by ndn::security::v2::KeyChain::deleteCertificate().

◆ setDefaultCertificate() [1/2]

const v2::Certificate & ndn::security::pib::Key::setDefaultCertificate ( const Name certName) const

Set an existing certificate with certName as the default certificate.

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

Definition at line 86 of file key.cpp.

Referenced by ndn::security::v2::KeyChain::setDefaultCertificate().

◆ setDefaultCertificate() [2/2]

const v2::Certificate & ndn::security::pib::Key::setDefaultCertificate ( const v2::Certificate certificate) const

Add certificate and set it as the default certificate of the key.

Exceptions
std::invalid_argumentcertificate does not match key name
Returns
the default certificate

Definition at line 92 of file key.cpp.

Friends And Related Function Documentation

◆ v2::KeyChain

friend class v2::KeyChain
friend

Definition at line 178 of file key.hpp.

◆ operator!=

bool operator!= ( const Key ,
const Key  
)
friend

Definition at line 121 of file key.cpp.

Member Data Documentation

◆ __pad0__

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE ndn::security::pib::Key::__pad0__

Definition at line 140 of file key.hpp.


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