32 #include <boost/lexical_cast.hpp>
41 return doHasKey(keyName);
47 return doGetKeyHandle(keyName);
54 return doCreateKey(identity, params);
71 NDN_THROW(std::invalid_argument(
"Unsupported key id type " +
72 boost::lexical_cast<std::string>(params.
getKeyIdType())));
75 return doCreateKey(identity, params);
90 return doExportKey(keyName, pw, pwLen);
99 doImportKey(keyName, pkcs8, pw, pwLen);
108 doImportKey(keyName, std::move(key));
120 using namespace transform;
132 }
while (
hasKey(keyName));
Base class for key parameters.
KeyIdType getKeyIdType() const
KeyType getKeyType() const
const name::Component & getKeyId() const
Represents an absolute name.
void toUri(std::ostream &os, name::UriFormat format=name::UriFormat::DEFAULT) const
Write URI representation of the name to the output stream.
An output stream that writes to a Buffer.
std::shared_ptr< Buffer > buf()
Return a shared pointer to the underlying buffer.
Represents a name component.
static Component fromNumber(uint64_t number, uint32_t type=tlv::GenericNameComponent)
Create a component encoded as NonNegativeInteger.
unique_ptr< KeyHandle > createKey(const Name &identityName, const KeyParams ¶ms)
Create a key for identityName according to params.
void importKey(const Name &keyName, span< const uint8_t > pkcs8, const char *pw, size_t pwLen)
Import a private key in encrypted PKCS #8 format.
bool hasKey(const Name &keyName) const
Check if the key with name keyName exists in the TPM.
Name constructAsymmetricKeyName(const KeyHandle &key, const Name &identity, const KeyParams ¶ms) const
Construct and return the name of a RSA or EC key, based on identity and params.
void deleteKey(const Name &keyName)
Delete the key with name keyName.
ConstBufferPtr exportKey(const Name &keyName, const char *pw, size_t pwLen)
Get the private key with name keyName in encrypted PKCS #8 format.
unique_ptr< KeyHandle > getKeyHandle(const Name &keyName) const
Get the handle of the key with name keyName.
Name constructHmacKeyName(const transform::PrivateKey &key, const Name &identity, const KeyParams ¶ms) const
Construct and return the name of a HMAC key, based on identity and params.
Abstraction of TPM key handle.
ConstBufferPtr derivePublicKey() const
uint64_t generateSecureWord64()
Generate a cryptographically secure random integer in the range [0, 2^64).
Name constructKeyName(const Name &identity, const name::Component &keyId)
Construct key name based on the appropriate naming conventions.
@ HMAC
HMAC key, supports sign/verify operations.
@ RANDOM
Use a 64-bit random number as key id.
@ USER_SPECIFIED
User-specified key id.
@ SHA256
Use the SHA-256 hash of the public key as key id.
std::shared_ptr< const Buffer > ConstBufferPtr