ndn::security::tpm::Tpm Class Reference

represents the front-end of TPM More...

#include <tpm.hpp>

Inheritance diagram for ndn::security::tpm::Tpm:
[legend]
Collaboration diagram for ndn::security::tpm::Tpm:
[legend]

Data Structures

class  Error
 

Public Member Functions

 ~Tpm ()
 
std::string getTpmLocator () const
 
bool hasKey (const Name &keyName) const
 Check if a private key exist. 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 key with name keyName with digest digestAlgorithm. More...
 
ConstBufferPtr decrypt (const uint8_t *buf, size_t size, const Name &keyName) const
 Decrypt blob using key with name keyName. More...
 
bool isTerminalMode () const
 Check if TPM is in terminal mode. More...
 
void setTerminalMode (bool isTerminal) const
 Set the terminal mode of TPM. More...
 
bool isTpmLocked () const
 
bool unlockTpm (const char *password, size_t passwordLength) const
 Unlock TPM. More...
 

Friends

class v2::KeyChain
 

Detailed Description

represents the front-end of TPM

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.

Note
Tpm instance is created and managed only by v2::KeyChain. v2::KeyChain::getTpm() returns a const reference to the managed Tpm instance, through which it is possible to check existence of private keys, get public keys for the private keys, sign, and decrypt the supplied buffers using managed private keys.
Exceptions
BackEnd::ErrorFailure with the underlying implementation having non-semantic errors
Tpm::ErrorFailure with semantic error in the underlying implementation

Definition at line 64 of file tpm.hpp.

Constructor & Destructor Documentation

ndn::security::tpm::Tpm::~Tpm ( )
default

Member Function Documentation

ConstBufferPtr ndn::security::tpm::Tpm::decrypt ( const uint8_t *  buf,
size_t  size,
const Name keyName 
) const

Decrypt blob using key with name keyName.

Returns
The signature, or nullptr if the key does not exist

Definition at line 101 of file tpm.cpp.

ConstBufferPtr ndn::security::tpm::Tpm::getPublicKey ( const Name keyName) const
Returns
The public portion of an asymmetric key with name name or nullptr if the key does not exist

The public key is in PKCS#8 format

Definition at line 79 of file tpm.cpp.

std::string ndn::security::tpm::Tpm::getTpmLocator ( ) const

Definition at line 40 of file tpm.cpp.

bool ndn::security::tpm::Tpm::hasKey ( const Name keyName) const

Check if a private key exist.

Parameters
keyNameThe key name
Returns
true if the key exists

Definition at line 46 of file tpm.cpp.

bool ndn::security::tpm::Tpm::isTerminalMode ( ) const

Check if TPM is in terminal mode.

Definition at line 112 of file tpm.cpp.

bool ndn::security::tpm::Tpm::isTpmLocked ( ) const
Returns
True if TPM is locked, otherwise false

Definition at line 124 of file tpm.cpp.

void ndn::security::tpm::Tpm::setTerminalMode ( bool  isTerminal) const

Set the terminal mode of TPM.

In terminal mode, TPM will not ask user permission from GUI.

Definition at line 118 of file tpm.cpp.

ConstBufferPtr ndn::security::tpm::Tpm::sign ( const uint8_t *  buf,
size_t  size,
const Name keyName,
DigestAlgorithm  digestAlgorithm 
) const

Sign blob using key with name keyName with digest digestAlgorithm.

Returns
The signature, or nullptr if the key does not exist

Definition at line 90 of file tpm.cpp.

bool ndn::security::tpm::Tpm::unlockTpm ( const char *  password,
size_t  passwordLength 
) const

Unlock TPM.

Parameters
passwordThe password to unlock TPM
passwordLengthThe password size.

Definition at line 130 of file tpm.cpp.

Friends And Related Function Documentation

friend class v2::KeyChain
friend

Definition at line 236 of file tpm.hpp.