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);
134 }
while (
hasKey(keyName));
Copyright (c) 2011-2015 Regents of the University of California.
ConstBufferPtr derivePublicKey() const
uint64_t generateSecureWord64()
Generate a cryptographically secure random integer from the range [0, 2^64)
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.
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.
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 NDN_CXX_NODISCARD 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 SHA-256 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