32 #include <boost/lexical_cast.hpp>
43 return doHasKey(keyName);
49 return doGetKeyHandle(keyName);
56 return doCreateKey(identity, params);
73 NDN_THROW(std::invalid_argument(
"Unsupported key id type " +
74 boost::lexical_cast<std::string>(params.
getKeyIdType())));
77 return doCreateKey(identity, params);
92 return doExportKey(keyName, pw, pwLen);
101 doImportKey(keyName, pkcs8, pw, pwLen);
110 doImportKey(keyName, std::move(key));
122 using namespace transform;
134 }
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.
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.
virtual bool unlockTpm(const char *pw, size_t pwLen) const
Unlock the TPM.
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.
virtual bool isTerminalMode() const
Check if the TPM is in terminal mode.
virtual void setTerminalMode(bool isTerminal) const
Set the terminal mode of the TPM.
void deleteKey(const Name &keyName)
Delete the key with name keyName.
virtual bool isTpmLocked() const
Check if the TPM is locked.
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 from the range [0, 2^64)
Name constructKeyName(const Name &identity, const name::Component &keyId)
Construct key name based on the appropriate naming conventions.
shared_ptr< const Buffer > ConstBufferPtr
@ 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.