22 #ifndef NDN_CXX_SECURITY_TPM_TPM_HPP
23 #define NDN_CXX_SECURITY_TPM_TPM_HPP
29 #include <unordered_map>
30 #include <boost/logic/tribool.hpp>
65 class Tpm : noncopyable
68 class Error :
public std::runtime_error
71 using std::runtime_error::runtime_error;
111 [[deprecated(
"use the overload that takes InputBuffers")]]
115 return sign({{buf, size}}, keyName, digestAlgorithm);
137 [[deprecated(
"use the overload that takes InputBuffers and span")]]
138 boost::logic::tribool
139 verify(
const uint8_t* buf,
size_t bufLen,
const uint8_t*
sig,
size_t sigLen,
142 return verify({{buf, bufLen}}, {
sig, sigLen}, keyName, digestAlgorithm);
151 decrypt(span<const uint8_t> buf,
const Name& keyName)
const;
158 [[deprecated(
"use the overload that takes a span<>")]]
160 decrypt(
const uint8_t* buf,
size_t size,
const Name& keyName)
const
162 return decrypt({buf, size}, keyName);
193 unlockTpm(
const char* password,
size_t passwordLength)
const;
203 Tpm(
const std::string& scheme,
const std::string& location, unique_ptr<BackEnd> impl);
216 createKey(
const Name& identityName,
const KeyParams& params);
222 deleteKey(
const Name& keyName);
237 exportPrivateKey(
const Name& keyName,
const char* pw,
size_t pwLen)
const;
252 importPrivateKey(
const Name& keyName, span<const uint8_t> pkcs8,
const char* pw,
size_t pwLen);
258 importPrivateKey(
const Name& keyName, shared_ptr<transform::PrivateKey> key);
278 findKey(
const Name& keyName)
const;
281 std::string m_scheme;
282 std::string m_location;
284 mutable std::unordered_map<Name, unique_ptr<KeyHandle>> m_keys;
286 const unique_ptr<BackEnd> m_backEnd;
#define NDN_CXX_NODISCARD
Base class for key parameters.
Represents an absolute name.
boost::logic::tribool verify(const uint8_t *buf, size_t bufLen, const uint8_t *sig, size_t sigLen, const Name &keyName, DigestAlgorithm digestAlgorithm) const
Verify blob using the key with name keyName and using the digest digestAlgorithm.
bool unlockTpm(const char *password, size_t passwordLength) const
Unlock the TPM.
void setTerminalMode(bool isTerminal) const
Set the terminal mode of the TPM.
ConstBufferPtr getPublicKey(const Name &keyName) const
ConstBufferPtr decrypt(span< const uint8_t > buf, const Name &keyName) const
Decrypt blob using the key with name keyName.
boost::logic::tribool verify(const InputBuffers &bufs, span< const uint8_t > sig, const Name &keyName, DigestAlgorithm digestAlgorithm) const
Verify discontiguous ranges using the key with name keyName and using the digest digestAlgorithm.
ConstBufferPtr sign(const InputBuffers &bufs, const Name &keyName, DigestAlgorithm digestAlgorithm) const
Sign discontiguous ranges using the key with name keyName and using the digest digestAlgorithm.
ConstBufferPtr decrypt(const uint8_t *buf, size_t size, const Name &keyName) const
Decrypt blob using the key with name keyName.
bool isTerminalMode() const
Check if the TPM is in terminal mode.
ConstBufferPtr sign(const uint8_t *buf, size_t size, const Name &keyName, DigestAlgorithm digestAlgorithm) const
Sign blob using the key with name keyName and using the digest digestAlgorithm.
bool hasKey(const Name &keyName) const
Check if a private key exists.
std::string getTpmLocator() const
The interface of signing key management.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
shared_ptr< const Buffer > ConstBufferPtr
span< const uint8_t > sig