Backend instance of Key. More...
#include <key-impl.hpp>
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 Name & | getName () const |
Get the name of the key. More... | |
const Name & | getIdentity () 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 CertificateContainer & | getCertificates () 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... | |
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.
PibImpl::Error | when underlying implementation has non-semantic error. |
Definition at line 44 of file key-impl.hpp.
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.
keyName | The name of the key. |
key | The public key bits. |
pibImpl | The Pib backend implementation. |
std::invalid_argument | key 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.
ndn::security::pib::detail::KeyImpl::KeyImpl | ( | const Name & | keyName, |
shared_ptr< PibImpl > | pibImpl | ||
) |
Create a KeyImpl with keyName
.
keyName | The name of the key. |
pibImpl | The Pib backend implementation. |
Pib::Error | the 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().
|
inline |
Get the name of the key.
Definition at line 73 of file key-impl.hpp.
|
inline |
Get the name of the belonging identity.
Definition at line 82 of file key-impl.hpp.
|
inline |
Get key type.
Definition at line 91 of file key-impl.hpp.
|
inline |
Get public key bits.
Definition at line 100 of file key-impl.hpp.
References addCertificate(), getCertificate(), getCertificates(), getDefaultCertificate(), removeCertificate(), and setDefaultCertificate().
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.
std::invalid_argument | the 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().
void ndn::security::pib::detail::KeyImpl::removeCertificate | ( | const Name & | certName | ) |
Remove a certificate with certName
.
std::invalid_argument | certName 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().
Certificate ndn::security::pib::detail::KeyImpl::getCertificate | ( | const Name & | certName | ) | const |
Get a certificate with certName
.
std::invalid_argument | certName does not match the key name. |
Pib::Error | the 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().
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().
const Certificate & ndn::security::pib::detail::KeyImpl::setDefaultCertificate | ( | const Name & | certName | ) |
Set an existing certificate with name certName
as the default certificate.
std::invalid_argument | certName does not match the key name. |
Pib::Error | the certificate does not exist. |
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().
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.
std::invalid_argument | certificate does not match the key name. |
Definition at line 114 of file key-impl.cpp.
References addCertificate(), and setDefaultCertificate().
const Certificate & ndn::security::pib::detail::KeyImpl::getDefaultCertificate | ( | ) | const |
Get the default certificate for this key.
Pib::Error | the default certificate does not exist. |
Definition at line 121 of file key-impl.cpp.
References ndn::security::pib::CertificateContainer::isConsistent().
Referenced by getPublicKey().