25 #include "../pib/key.hpp" 26 #include "../transform/buffer-source.hpp" 27 #include "../transform/digest-filter.hpp" 28 #include "../transform/stream-sink.hpp" 29 #include "../../encoding/buffer-stream.hpp" 30 #include "../../util/random.hpp" 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.
unique_ptr< KeyHandle > createKey(const Name &identity, const KeyParams ¶ms)
Create key for identity according to params.
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.
virtual void setTerminalMode(bool isTerminal) const
Set the terminal mode of TPM.
void deleteKey(const Name &keyName)
Delete a key with name keyName.
Abstraction of TPM key handle.
ConstBufferPtr exportKey(const Name &keyName, const char *pw, size_t pwLen)
virtual bool unlockTpm(const char *pw, size_t pwLen) const
Unlock TPM.
virtual bool isTerminalMode() const
Check if 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
Represents a name component.
unique_ptr< KeyHandle > getKeyHandle(const Name &keyName) const
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
const name::Component & getKeyId() const
shared_ptr< const Buffer > ConstBufferPtr