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, pkcs8Len, pw, pwLen);
110 doImportKey(keyName, key);
122 using namespace transform;
134 }
while (
hasKey(keyName));
ConstBufferPtr derivePublicKey() const
uint64_t generateSecureWord64()
Generate a cryptographically secure random integer from the range [0, 2^64)
void importKey(const Name &keyName, const uint8_t *pkcs8, size_t pkcs8Len, const char *pw, size_t pwLen)
Import a private key in encrypted PKCS #8 format.
unique_ptr< KeyHandle > createKey(const Name &identityName, const KeyParams ¶ms)
Create a key for identityName according to params.
virtual void setTerminalMode(bool isTerminal) const
Set the terminal mode of the TPM.
void deleteKey(const Name &keyName)
Delete the key with name keyName.
Abstraction of TPM key handle.
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.
HMAC key, supports sign/verify operations.
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.
ConstBufferPtr exportKey(const Name &keyName, const char *pw, size_t pwLen)
Get the private key with name keyName in encrypted PKCS #8 format.
virtual bool unlockTpm(const char *pw, size_t pwLen) const
Unlock the TPM.
virtual bool isTerminalMode() const
Check if the TPM is in terminal mode.
Use the SHA256 hash of the public key as key id.
Represents an absolute name.
KeyType getKeyType() const
bool hasKey(const Name &keyName) const
Check if the key with name keyName exists in the TPM.
Represents a name component.
unique_ptr< KeyHandle > getKeyHandle(const Name &keyName) const
Get the handle of the key with name keyName.
shared_ptr< Buffer > buf()
Flush written data to the stream and return shared pointer to the underlying buffer.
Name constructKeyName(const Name &identity, const name::Component &keyId)
Construct key name based on the appropriate naming conventions.
static Component fromNumber(uint64_t number, uint32_t type=tlv::GenericNameComponent)
Create a component encoded as nonNegativeInteger.
Use a 64-bit random number as key id.
Base class for key parameters.
void toUri(std::ostream &os, name::UriFormat format=name::UriFormat::DEFAULT) const
Write URI representation of the name to the output stream.
implements an output stream that constructs ndn::Buffer
KeyIdType getKeyIdType() const
virtual bool isTpmLocked() const
Check if the TPM is locked.
const name::Component & getKeyId() const
shared_ptr< const Buffer > ConstBufferPtr