All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Classes | Public Member Functions | Static Protected Member Functions | List of all members
ndn::TpmBackEnd Class Referenceabstract

TpmBackEnd is an abstract base class for a TPM backend implementation which provides a TpmKeyHandle to the TPM front end. More...

#include <tpm-back-end.hpp>

Inheritance diagram for ndn::TpmBackEnd:
ndn::TpmBackEndFile ndn::TpmBackEndMemory

Classes

class  Error
 A TpmBackEnd::Error extends runtime_error and represents a non-semantic error in backend TPM processing. More...
 

Public Member Functions

bool hasKey (const Name &keyName) const
 Check if the key with name keyName exists in the TPM. More...
 
ptr_lib::shared_ptr< TpmKeyHandlegetKeyHandle (const Name &keyName) const
 Get the handle of the key with name keyName. More...
 
ptr_lib::shared_ptr< TpmKeyHandlecreateKey (const Name &identityName, const KeyParams &params)
 Create a key for the identityName according to params. More...
 
void deleteKey (const Name &keyName)
 Delete the key with name keyName. More...
 
Blob exportKey (const Name &keyName, const uint8_t *password, size_t passwordLength)
 Get the encoded private key with name keyName in PKCS #8 format, possibly password-encrypted. More...
 
void importKey (const Name &keyName, const uint8_t *pkcs8, size_t pkcs8Length, const uint8_t *password, size_t passwordLength)
 Import an encoded private key with name keyName in PKCS #8 format, possibly password-encrypted. More...
 
virtual bool isTerminalMode () const
 Check if the TPM is in terminal mode. More...
 
virtual void setTerminalMode (bool isTerminal) const
 Set the terminal mode of the TPM. More...
 
virtual bool isTpmLocked () const
 Check if the TPM is locked. More...
 
virtual bool unlockTpm (const uint8_t *password, size_t passwordLength) const
 Unlock the TPM. More...
 

Static Protected Member Functions

static void setKeyName (TpmKeyHandle &keyHandle, const Name &identityName, const KeyParams &params)
 Set the key name in keyHandle according to identityName and params.
 

Detailed Description

TpmBackEnd is an abstract base class for a TPM backend implementation which provides a TpmKeyHandle to the TPM front end.

This class defines the interface that an actual TPM backend implementation should provide, for example TpmBackEndMemory.

Member Function Documentation

ptr_lib::shared_ptr< TpmKeyHandle > ndn::TpmBackEnd::createKey ( const Name identityName,
const KeyParams params 
)

Create a key for the identityName according to params.

Parameters
identityNameThe name if the identity.
paramsThe KeyParams for creating the key.
Returns
The handle of the created key.
Exceptions
Tpm::Errorif params is invalid.
TpmBackEnd::Errorif the key cannot be created.
void ndn::TpmBackEnd::deleteKey ( const Name keyName)
inline

Delete the key with name keyName.

If the key doesn't exist, do nothing. Note: Continuing to use existing Key handles on a deleted key results in undefined behavior.

Parameters
keyNameThe name of the key to delete.
Exceptions
TpmBackEnd::Errorif the deletion fails.
Blob ndn::TpmBackEnd::exportKey ( const Name keyName,
const uint8_t *  password,
size_t  passwordLength 
)

Get the encoded private key with name keyName in PKCS #8 format, possibly password-encrypted.

Parameters
keyNameThe name of the key in the TPM.
passwordThe password for encrypting the private key. If the password is supplied, use it to return a PKCS #8 EncryptedPrivateKeyInfo. If the password is null, return an unencrypted PKCS #8 PrivateKeyInfo.
passwordLengthThe length of the password. If password is null, this is ignored.
Returns
The encoded private key.
Exceptions
TpmBackEnd::Errorif the key does not exist or if the key cannot be exported, e.g., insufficient privileges.
ptr_lib::shared_ptr<TpmKeyHandle> ndn::TpmBackEnd::getKeyHandle ( const Name keyName) const
inline

Get the handle of the key with name keyName.

Calling getKeyHandle multiple times with the same keyName will return different TpmKeyHandle objects that all refer to the same key.

Parameters
keyNameThe name of the key.
Returns
The handle of the key, or null if the key does not exist.
bool ndn::TpmBackEnd::hasKey ( const Name keyName) const
inline

Check if the key with name keyName exists in the TPM.

Parameters
keyNameThe name of the key.
Returns
True if the key exists.
void ndn::TpmBackEnd::importKey ( const Name keyName,
const uint8_t *  pkcs8,
size_t  pkcs8Length,
const uint8_t *  password,
size_t  passwordLength 
)

Import an encoded private key with name keyName in PKCS #8 format, possibly password-encrypted.

Parameters
keyNameThe name of the key to use in the TPM.
pkcs8The input byte array. If the password is supplied, this is a PKCS #8 EncryptedPrivateKeyInfo. If the password is null, this is an unencrypted PKCS #8 PrivateKeyInfo.
pkcs8LengthThe length of the input byte array.
passwordThe password for decrypting the private key. If the password is supplied, use it to decrypt the PKCS #8 EncryptedPrivateKeyInfo. If the password is null, import an unencrypted PKCS #8 PrivateKeyInfo.
passwordLengthThe length of the password. If password is null, this is ignored.
Exceptions
TpmBackEnd::Errorif a key with name keyName already exists, or for an error importing the key.
bool ndn::TpmBackEnd::isTerminalMode ( ) const
virtual

Check if the TPM is in terminal mode.

The default implementation always returns true.

Returns
True if in terminal mode.
bool ndn::TpmBackEnd::isTpmLocked ( ) const
virtual

Check if the TPM is locked.

The default implementation returns false.

Returns
True if the TPM is locked, otherwise false.
void ndn::TpmBackEnd::setTerminalMode ( bool  isTerminal) const
virtual

Set the terminal mode of the TPM.

In terminal mode, the TPM will not ask for a password from the GUI. The default implementation does nothing.

Parameters
isTerminalTrue to enable terminal mode.
bool ndn::TpmBackEnd::unlockTpm ( const uint8_t *  password,
size_t  passwordLength 
) const
virtual

Unlock the TPM.

If !isTerminalMode(), prompt for a password from the GUI. The default implementation does nothing and returns !isTpmLocked().

Parameters
passwordThe password to unlock TPM.
passwordLengthThe length of the password.
Returns
True if the TPM was unlocked.

The documentation for this class was generated from the following files: