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

Backend instance of Key. More...

#include <key-impl.hpp>

Inheritance diagram for ndn::security::pib::detail::KeyImpl:
Collaboration diagram for ndn::security::pib::detail::KeyImpl:

Public Member Functions

 KeyImpl (const Name &keyName, span< const uint8_t > key, shared_ptr< PibImpl > pibImpl)
 Create a KeyImpl with keyName. More...
 
 KeyImpl (const Name &keyName, shared_ptr< PibImpl > pibImpl)
 Create a KeyImpl with keyName. More...
 
const NamegetName () const
 Get the name of the key. More...
 
const NamegetIdentity () const
 Get the name of the belonging identity. More...
 
KeyType getKeyType () const
 Get key type. More...
 
span< const uint8_t > getPublicKey () const
 Get public key bits. More...
 
void addCertificate (const Certificate &certificate)
 Add certificate. More...
 
void removeCertificate (const Name &certName)
 Remove a certificate with certName. More...
 
Certificate getCertificate (const Name &certName) const
 Get a certificate with certName. More...
 
const CertificateContainergetCertificates () const
 Get all the certificates for this key. More...
 
const Certificate & setDefaultCertificate (const Name &certName)
 Set an existing certificate with name certName as the default certificate. More...
 
const Certificate & setDefaultCertificate (const Certificate &certificate)
 Add certificate and set it as the default certificate for this key. More...
 
const Certificate & getDefaultCertificate () const
 Get the default certificate for this key. More...
 

Detailed Description

Backend instance of Key.

A Key has only one backend instance, but may have multiple frontend handles. Each frontend handle is associated with the only one backend KeyImpl.

Exceptions
PibImpl::Errorwhen underlying implementation has non-semantic error.

Definition at line 44 of file key-impl.hpp.

Constructor & Destructor Documentation

◆ KeyImpl() [1/2]

ndn::security::pib::detail::KeyImpl::KeyImpl ( const Name keyName,
span< const uint8_t >  key,
shared_ptr< PibImpl pibImpl 
)

Create a KeyImpl with keyName.

If the key does not exist in the backend, it will be added. If a key with the same name already exists, it will be overwritten.

Parameters
keyNameThe name of the key.
keyThe public key bits.
pibImplThe Pib backend implementation.
Exceptions
std::invalid_argumentkey is invalid.

Definition at line 32 of file key-impl.cpp.

References ndn::security::transform::PublicKey::getKeyType(), ndn::security::transform::PublicKey::loadPkcs8(), and NDN_THROW_NESTED.

◆ KeyImpl() [2/2]

ndn::security::pib::detail::KeyImpl::KeyImpl ( const Name keyName,
shared_ptr< PibImpl pibImpl 
)

Create a KeyImpl with keyName.

Parameters
keyNameThe name of the key.
pibImplThe Pib backend implementation.
Exceptions
Pib::Errorthe key does not exist.

Definition at line 54 of file key-impl.cpp.

References ndn::security::transform::PublicKey::getKeyType(), and ndn::security::transform::PublicKey::loadPkcs8().

Member Function Documentation

◆ getName()

const Name& ndn::security::pib::detail::KeyImpl::getName ( ) const
inline

Get the name of the key.

Definition at line 73 of file key-impl.hpp.

◆ getIdentity()

const Name& ndn::security::pib::detail::KeyImpl::getIdentity ( ) const
inline

Get the name of the belonging identity.

Definition at line 82 of file key-impl.hpp.

◆ getKeyType()

KeyType ndn::security::pib::detail::KeyImpl::getKeyType ( ) const
inline

Get key type.

Definition at line 91 of file key-impl.hpp.

◆ getPublicKey()

span<const uint8_t> ndn::security::pib::detail::KeyImpl::getPublicKey ( ) const
inline

◆ addCertificate()

void ndn::security::pib::detail::KeyImpl::addCertificate ( const Certificate &  certificate)

Add certificate.

If no default certificate is set before, the new certificate will be set as the default certificate of the key.

If a certificate with the same name (without implicit digest) already exists, it will be overwritten.

Exceptions
std::invalid_argumentthe certificate name does not match the key name.

Definition at line 71 of file key-impl.cpp.

References ndn::security::pib::CertificateContainer::add(), and ndn::security::pib::CertificateContainer::isConsistent().

Referenced by getPublicKey(), and setDefaultCertificate().

◆ removeCertificate()

void ndn::security::pib::detail::KeyImpl::removeCertificate ( const Name certName)

Remove a certificate with certName.

Exceptions
std::invalid_argumentcertName does not match the key name.

Definition at line 78 of file key-impl.cpp.

References ndn::security::pib::CertificateContainer::isConsistent(), and ndn::security::pib::CertificateContainer::remove().

Referenced by getPublicKey().

◆ getCertificate()

Certificate ndn::security::pib::detail::KeyImpl::getCertificate ( const Name certName) const

Get a certificate with certName.

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

Definition at line 89 of file key-impl.cpp.

References ndn::security::pib::CertificateContainer::get(), and ndn::security::pib::CertificateContainer::isConsistent().

Referenced by getPublicKey().

◆ getCertificates()

const CertificateContainer & ndn::security::pib::detail::KeyImpl::getCertificates ( ) const

Get all the certificates for this key.

Definition at line 96 of file key-impl.cpp.

References ndn::security::pib::CertificateContainer::isConsistent().

Referenced by getPublicKey().

◆ setDefaultCertificate() [1/2]

const Certificate & ndn::security::pib::detail::KeyImpl::setDefaultCertificate ( const Name certName)

Set an existing certificate with name certName as the default certificate.

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

Definition at line 103 of file key-impl.cpp.

References ndn::security::pib::CertificateContainer::get(), and ndn::security::pib::CertificateContainer::isConsistent().

Referenced by getPublicKey(), and setDefaultCertificate().

◆ setDefaultCertificate() [2/2]

const Certificate & ndn::security::pib::detail::KeyImpl::setDefaultCertificate ( const Certificate &  certificate)

Add certificate and set it as the default certificate for this key.

If a certificate with the same name (without implicit digest) already exists, it will be overwritten.

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

Definition at line 114 of file key-impl.cpp.

References addCertificate(), and setDefaultCertificate().

◆ getDefaultCertificate()

const Certificate & ndn::security::pib::detail::KeyImpl::getDefaultCertificate ( ) const

Get the default certificate for this key.

Exceptions
Pib::Errorthe default certificate does not exist.

Definition at line 121 of file key-impl.cpp.

References ndn::security::pib::CertificateContainer::isConsistent().

Referenced by getPublicKey().


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