Backend instance of Key. More...
#include <key-impl.hpp>
Public Member Functions | |
KeyImpl (const Name &keyName, const uint8_t *key, size_t keyLen, 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... | |
const Buffer & | getPublicKey () const |
Get public key bits. More... | |
void | addCertificate (const v2::Certificate &certificate) |
Add certificate . More... | |
void | removeCertificate (const Name &certName) |
Remove a certificate with certName . More... | |
v2::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 v2::Certificate & | setDefaultCertificate (const Name &certName) |
Set an existing certificate with name certName as the default certificate. More... | |
const v2::Certificate & | setDefaultCertificate (const v2::Certificate &certificate) |
Add certificate and set it as the default certificate for this key. More... | |
const v2::Certificate & | getDefaultCertificate () const |
Get the default certificate for this key. More... | |
Backend instance of Key.
An 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, |
const uint8_t * | key, | ||
size_t | keyLen, | ||
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 to add. |
keyLen | The length of the key. |
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(), and ndn::security::transform::PublicKey::loadPkcs8().
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 74 of file key-impl.hpp.
|
inline |
Get the name of the belonging identity.
Definition at line 83 of file key-impl.hpp.
|
inline |
Get key type.
Definition at line 92 of file key-impl.hpp.
|
inline |
Get public key bits.
Definition at line 101 of file key-impl.hpp.
References addCertificate(), getCertificate(), getCertificates(), getDefaultCertificate(), removeCertificate(), and setDefaultCertificate().
void ndn::security::pib::detail::KeyImpl::addCertificate | ( | const v2::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::Data::getName(), ndn::security::pib::CertificateContainer::isConsistent(), and ndn::security::pib::CertificateContainer::remove().
Referenced by getPublicKey().
v2::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 v2::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 v2::Certificate & ndn::security::pib::detail::KeyImpl::setDefaultCertificate | ( | const v2::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(), ndn::Data::getName(), and setDefaultCertificate().
const v2::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(), and ndn::Data::wireEncode().
Referenced by getPublicKey().