23#include "ndn-cxx/security/pib/impl/key-impl.hpp"
30Key::Key(weak_ptr<KeyImpl> impl) noexcept
31 : m_impl(
std::move(impl))
38 return lock()->getName();
44 return lock()->getIdentity();
50 return lock()->getKeyType();
56 return lock()->getPublicKey();
60Key::addCertificate(
const Certificate& certificate)
const
62 lock()->addCertificate(certificate);
66Key::removeCertificate(
const Name& certName)
const
68 lock()->removeCertificate(certName);
74 return lock()->getCertificate(certName);
80 return lock()->getCertificates();
84Key::setDefaultCertificate(
const Name& certName)
const
86 return lock()->setDefaultCertificate(certName);
90Key::setDefaultCertificate(
const Certificate& certificate)
const
92 return lock()->setDefaultCertificate(certificate);
98 return lock()->getDefaultCertificate();
101Key::operator bool() const noexcept
103 return !m_impl.expired();
109 auto impl = m_impl.lock();
110 if (impl ==
nullptr) {
111 NDN_THROW(std::domain_error(
"Invalid PIB key instance"));
117Key::equals(
const Key& other)
const noexcept
119 return !this->m_impl.owner_before(other.m_impl) &&
120 !other.m_impl.owner_before(this->m_impl);
128 return Name(identity)
144 NDN_THROW(std::invalid_argument(
"Key name `" + keyName.
toUri() +
"` "
145 "does not respect the naming conventions"));
Represents an absolute name.
const Component & get(ssize_t i) const noexcept
Returns an immutable reference to the component at the specified index.
PartialName getPrefix(ssize_t nComponents) const
Returns a prefix of the name.
Name & append(const Component &component)
Append a name component.
size_t size() const noexcept
Returns the number of components.
void toUri(std::ostream &os, name::UriFormat format=name::UriFormat::DEFAULT) const
Write URI representation of the name to the output stream.
Represents a name component.
Represents an NDN certificate.
static const name::Component KEY_COMPONENT
static constexpr size_t MIN_KEY_NAME_LENGTH
Container of certificates of a key.
KeyType getKeyType() const
Return the key type.
const Certificate & getDefaultCertificate() const
Return the default certificate for this key.
const Name & getIdentity() const
Return the name of the owning identity.
Key() noexcept
Default constructor.
span< const uint8_t > getPublicKey() const
Return the raw public key bits.
Certificate getCertificate(const Name &certName) const
Return the certificate with the given name.
const Name & getName() const
Return the name of the key.
const CertificateContainer & getCertificates() const
Return all the certificates of this key.
Contains the ndn-cxx security framework.
Name extractIdentityFromKeyName(const Name &keyName)
Extract identity namespace from the key name keyName.
bool isValidKeyName(const Name &keyName)
Check if keyName follow the naming conventions for the key name.
Name constructKeyName(const Name &identity, const name::Component &keyId)
Construct key name based on the appropriate naming conventions.
KeyType
The type of a cryptographic key.