41 return doHasKey(keyName);
47 return doGetKeyHandle(keyName);
58 BOOST_THROW_EXCEPTION(
Tpm::Error(
"Key `" + keyName.
toUri() +
"` already exists"));
74 const_cast<KeyParams&>(params).setKeyId(keyId);
78 BOOST_THROW_EXCEPTION(
Error(
"Unsupported key id type"));
82 return doCreateKey(identity, params);
95 BOOST_THROW_EXCEPTION(
Error(
"Key `" + keyName.
toUri() +
"` does not exist"));
97 return doExportKey(keyName, pw, pwLen);
104 BOOST_THROW_EXCEPTION(
Error(
"Key `" + keyName.
toUri() +
"` already exists"));
106 doImportKey(keyName, pkcs8, pkcs8Len, pw, pwLen);
134 BOOST_THROW_EXCEPTION(
Error(
"Unsupported key id type"));
void setKeyName(const Name &keyName)
static Component fromNumber(uint64_t number)
Create a component encoded as nonNegativeInteger.
Copyright (c) 2011-2015 Regents of the University of California.
std::string toUri() const
Get URI representation of the name.
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.
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 the key id.
Represents an absolute name.
static void setKeyName(KeyHandle &keyHandle, const Name &identity, const KeyParams ¶ms)
Set the key name in keyHandle according to identity and params.
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.
Use a 64-bit random number as the key id.
Base class of key parameters.
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