TPM front-end class. More...
#include <tpm.hpp>
Classes | |
class | Error |
Public Member Functions | |
~Tpm () | |
std::string | getTpmLocator () const |
bool | hasKey (const Name &keyName) const |
Check if a private key exists. More... | |
ConstBufferPtr | getPublicKey (const Name &keyName) const |
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 . More... | |
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 . More... | |
ConstBufferPtr | decrypt (const uint8_t *buf, size_t size, const Name &keyName) const |
Decrypt blob using the key with name keyName . More... | |
bool | isTerminalMode () const |
Check if the TPM is in terminal mode. More... | |
void | setTerminalMode (bool isTerminal) const |
Set the terminal mode of the TPM. More... | |
bool | isTpmLocked () const |
NDN_CXX_NODISCARD bool | unlockTpm (const char *password, size_t passwordLength) const |
Unlock the TPM. More... | |
Name | createKey (const Name &identityName, const KeyParams ¶ms) |
Create key for identityName according to params . More... | |
void | deleteKey (const Name &keyName) |
Delete a key pair with name keyName . More... | |
ConstBufferPtr | exportPrivateKey (const Name &keyName, const char *pw, size_t pwLen) const |
Export a private key. More... | |
void | importPrivateKey (const Name &keyName, const uint8_t *pkcs8, size_t pkcs8Len, const char *pw, size_t pwLen) |
Import a private key. More... | |
void | importPrivateKey (const Name &keyName, shared_ptr< transform::PrivateKey > key) |
Import a private key. More... | |
void | clearKeyCache () |
Clear the key cache. More... | |
Public Attributes | |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE | __pad0__: Tpm(const std::string& scheme |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const std::string & | location |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const std::string unique_ptr< BackEnd > | impl |
Friends | |
class | v2::KeyChain |
TPM front-end class.
The TPM (Trusted Platform Module) stores the private portion of a user's cryptography keys. The format and location of stored information is indicated by the TpmLocator. The TPM is designed to work with a PIB (Public Information Base) which stores public keys and related information such as certificate.
The TPM also provides functionalities of crypto transformation, such as signing and decryption.
A TPM consists of a unified front-end interface and a back-end implementation. The front-end cache the handles of private keys which is provided by the back-end implementation.
|
default |
bool ndn::security::tpm::Tpm::hasKey | ( | const Name & | keyName | ) | const |
ConstBufferPtr ndn::security::tpm::Tpm::getPublicKey | ( | const Name & | keyName | ) | const |
keyName
, or nullptr if the key does not exist,The public key is in PKCS#8 format.
Definition at line 73 of file tpm.cpp.
References ndn::security::tpm::KeyHandle::derivePublicKey().
ConstBufferPtr ndn::security::tpm::Tpm::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
.
Definition at line 84 of file tpm.cpp.
References buf, and ndn::security::tpm::KeyHandle::sign().
boost::logic::tribool ndn::security::tpm::Tpm::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
.
true | the signature is valid |
false | the signature is not valid |
indeterminate | the key does not exist |
Definition at line 95 of file tpm.cpp.
References buf, bufLen, sig, sigLen, and ndn::security::tpm::KeyHandle::verify().
Referenced by ndn::security::verifySignature().
ConstBufferPtr ndn::security::tpm::Tpm::decrypt | ( | const uint8_t * | buf, |
size_t | size, | ||
const Name & | keyName | ||
) | const |
Decrypt blob using the key with name keyName
.
Definition at line 107 of file tpm.cpp.
References buf, and ndn::security::tpm::KeyHandle::decrypt().
bool ndn::security::tpm::Tpm::isTerminalMode | ( | ) | const |
void ndn::security::tpm::Tpm::setTerminalMode | ( | bool | isTerminal | ) | const |
bool ndn::security::tpm::Tpm::isTpmLocked | ( | ) | const |
bool ndn::security::tpm::Tpm::unlockTpm | ( | const char * | password, |
size_t | passwordLength | ||
) | const |
Create key for identityName
according to params
.
The created key is named as follows:
/<identityName>/KEY/<keyId>
/<identityName>/<keyDigest>
Error | The key already exists or params is invalid. |
Definition at line 54 of file tpm.cpp.
References nonstd::optional_lite::std11::move().
void ndn::security::tpm::Tpm::deleteKey | ( | const Name & | keyName | ) |
ConstBufferPtr ndn::security::tpm::Tpm::exportPrivateKey | ( | const Name & | keyName, |
const char * | pw, | ||
size_t | pwLen | ||
) | const |
Export a private key.
Export a private key in encrypted PKCS #8 format.
keyName | The private key name |
pw | The password to encrypt the private key |
pwLen | The length of the password |
Error | The key does not exist or it could not be exported. |
void ndn::security::tpm::Tpm::importPrivateKey | ( | const Name & | keyName, |
const uint8_t * | pkcs8, | ||
size_t | pkcs8Len, | ||
const char * | pw, | ||
size_t | pwLen | ||
) |
void ndn::security::tpm::Tpm::importPrivateKey | ( | const Name & | keyName, |
shared_ptr< transform::PrivateKey > | key | ||
) |
Import a private key.
Definition at line 155 of file tpm.cpp.
References nonstd::optional_lite::std11::move().
|
inline |
|
friend |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE ndn::security::tpm::Tpm::__pad0__ |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const std::string& ndn::security::tpm::Tpm::location |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const std::string unique_ptr<BackEnd> ndn::security::tpm::Tpm::impl |