NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
ndn::SecTpmOsx Class Reference

#include <sec-tpm-osx.hpp>

Inheritance diagram for ndn::SecTpmOsx:
Collaboration diagram for ndn::SecTpmOsx:

Classes

class  Error
 
class  Impl
 

Public Member Functions

 SecTpmOsx (const std::string &location="")
 
virtual ~SecTpmOsx ()
 
virtual void setTpmPassword (const uint8_t *password, size_t passwordLength)
 set password of TPM More...
 
virtual void resetTpmPassword ()
 reset password of TPM More...
 
virtual void setInTerminal (bool inTerminal)
 Set inTerminal flag to inTerminal. More...
 
virtual bool getInTerminal () const
 Get value of inTerminal flag. More...
 
virtual bool isLocked ()
 Check if TPM is locked. More...
 
virtual bool unlockTpm (const char *password, size_t passwordLength, bool usePassword)
 Unlock the TPM. More...
 
virtual void generateKeyPairInTpm (const Name &keyName, const KeyParams &params)
 Generate a pair of asymmetric keys. More...
 
virtual void deleteKeyPairInTpm (const Name &keyName)
 Delete a key pair of asymmetric keys. More...
 
virtual shared_ptr< PublicKeygetPublicKeyFromTpm (const Name &keyName)
 Get a public key. More...
 
virtual Block signInTpm (const uint8_t *data, size_t dataLength, const Name &keyName, DigestAlgorithm digestAlgorithm)
 Sign data. More...
 
virtual ConstBufferPtr decryptInTpm (const uint8_t *data, size_t dataLength, const Name &keyName, bool isSymmetric)
 Decrypt data. More...
 
virtual ConstBufferPtr encryptInTpm (const uint8_t *data, size_t dataLength, const Name &keyName, bool isSymmetric)
 Encrypt data. More...
 
virtual void generateSymmetricKeyInTpm (const Name &keyName, const KeyParams &params)
 Generate a symmetric key. More...
 
virtual bool doesKeyExistInTpm (const Name &keyName, KeyClass keyClass)
 Check if a particular key exists. More...
 
virtual bool generateRandomBlock (uint8_t *res, size_t size)
 Generate a random block. More...
 
virtual void addAppToAcl (const Name &keyName, KeyClass keyClass, const std::string &appPath, AclType acl)
 Add the application into the ACL of a particular key. More...
 
- Public Member Functions inherited from ndn::SecTpm
 SecTpm (const std::string &location)
 
virtual ~SecTpm ()
 
std::string getTpmLocator ()
 
ConstBufferPtr exportPrivateKeyPkcs5FromTpm (const Name &keyName, const std::string &password)
 Export a private key in PKCS#5 format. More...
 
bool importPrivateKeyPkcs5IntoTpm (const Name &keyName, const uint8_t *buffer, size_t bufferSize, const std::string &password)
 Import a private key in PKCS#5 formatted buffer of size bufferSize. More...
 

Static Public Attributes

static const std::string SCHEME
 

Protected Member Functions

virtual std::string getScheme ()
 
virtual ConstBufferPtr exportPrivateKeyPkcs8FromTpm (const Name &keyName)
 Export a private key in PKCS#8 format. More...
 
virtual bool importPrivateKeyPkcs8IntoTpm (const Name &keyName, const uint8_t *buf, size_t size)
 Import a private key from PKCS#8 formatted buffer of size bufferSize. More...
 
virtual bool importPublicKeyPkcs1IntoTpm (const Name &keyName, const uint8_t *buf, size_t size)
 Import a public key in PKCS#1 formatted buffer of size bufferSize. More...
 
void generateKeyPairInTpmInternal (const Name &keyName, const KeyParams &params, bool needRetry)
 
void deleteKeyPairInTpmInternal (const Name &keyName, bool needRetry)
 
ConstBufferPtr exportPrivateKeyPkcs8FromTpmInternal (const Name &keyName, bool needRetry)
 
bool importPrivateKeyPkcs8IntoTpmInternal (const Name &keyName, const uint8_t *buf, size_t size, bool needRetry)
 
Block signInTpmInternal (const uint8_t *data, size_t dataLength, const Name &keyName, DigestAlgorithm digestAlgorithm, bool needRetry)
 
- Protected Member Functions inherited from ndn::SecTpm
virtual bool getImpExpPassWord (std::string &password, const std::string &prompt)
 Get import/export password. More...
 

Additional Inherited Members

- Protected Attributes inherited from ndn::SecTpm
std::string m_location
 

Detailed Description

Definition at line 37 of file sec-tpm-osx.hpp.

Constructor & Destructor Documentation

§ SecTpmOsx()

ndn::SecTpmOsx::SecTpmOsx ( const std::string &  location = "")
explicit

Definition at line 231 of file sec-tpm-osx.cpp.

Referenced by ndn::SecTpmOsx::Error::Error().

§ ~SecTpmOsx()

ndn::SecTpmOsx::~SecTpmOsx ( )
virtual

Definition at line 247 of file sec-tpm-osx.cpp.

Referenced by ndn::SecTpmOsx::Error::Error().

Member Function Documentation

§ setTpmPassword()

void ndn::SecTpmOsx::setTpmPassword ( const uint8_t *  password,
size_t  passwordLength 
)
virtual

set password of TPM

Password is used to unlock TPM when it is locked. You should be cautious when using this method, because remembering password is kind of dangerous.

Parameters
passwordThe password
passwordLengthThe length of password

Implements ndn::SecTpm.

Definition at line 252 of file sec-tpm-osx.cpp.

Referenced by ndn::SecTpmOsx::Error::Error().

§ resetTpmPassword()

void ndn::SecTpmOsx::resetTpmPassword ( )
virtual

reset password of TPM

Implements ndn::SecTpm.

Definition at line 261 of file sec-tpm-osx.cpp.

Referenced by ndn::SecTpmOsx::Error::Error().

§ setInTerminal()

void ndn::SecTpmOsx::setInTerminal ( bool  inTerminal)
virtual

Set inTerminal flag to inTerminal.

If the inTerminal flag is set, and password is not set, TPM may ask for password via terminal. inTerminal flag is set by default.

Implements ndn::SecTpm.

Definition at line 269 of file sec-tpm-osx.cpp.

Referenced by ndn::SecTpmOsx::Error::Error().

§ getInTerminal()

bool ndn::SecTpmOsx::getInTerminal ( ) const
virtual

Get value of inTerminal flag.

Implements ndn::SecTpm.

Definition at line 279 of file sec-tpm-osx.cpp.

Referenced by ndn::SecTpmOsx::Error::Error().

§ isLocked()

bool ndn::SecTpmOsx::isLocked ( )
virtual

Check if TPM is locked.

Implements ndn::SecTpm.

Definition at line 285 of file sec-tpm-osx.cpp.

Referenced by ndn::SecTpmOsx::Error::Error(), and unlockTpm().

§ unlockTpm()

bool ndn::SecTpmOsx::unlockTpm ( const char *  password,
size_t  passwordLength,
bool  usePassword 
)
virtual

Unlock the TPM.

Parameters
passwordThe password.
passwordLengthThe password size. 0 indicates no password.
usePasswordTrue if we want to use the supplied password to unlock the TPM.
Returns
true if TPM is unlocked, otherwise false.

Implements ndn::SecTpm.

Definition at line 297 of file sec-tpm-osx.cpp.

References isLocked().

Referenced by deleteKeyPairInTpmInternal(), ndn::SecTpmOsx::Error::Error(), exportPrivateKeyPkcs8FromTpmInternal(), generateKeyPairInTpmInternal(), importPrivateKeyPkcs8IntoTpmInternal(), and signInTpmInternal().

§ generateKeyPairInTpm()

virtual void ndn::SecTpmOsx::generateKeyPairInTpm ( const Name keyName,
const KeyParams params 
)
inlinevirtual

Generate a pair of asymmetric keys.

Parameters
keyNameThe name of the key pair.
paramsThe parameters of key.
Exceptions
SecTpm::Errorif fails.

Implements ndn::SecTpm.

Definition at line 76 of file sec-tpm-osx.hpp.

References generateKeyPairInTpmInternal().

§ deleteKeyPairInTpm()

virtual void ndn::SecTpmOsx::deleteKeyPairInTpm ( const Name keyName)
inlinevirtual

Delete a key pair of asymmetric keys.

Parameters
keyNameThe name of the key pair.

Implements ndn::SecTpm.

Definition at line 82 of file sec-tpm-osx.hpp.

References deleteKeyPairInTpmInternal(), and getPublicKeyFromTpm().

§ getPublicKeyFromTpm()

shared_ptr< PublicKey > ndn::SecTpmOsx::getPublicKeyFromTpm ( const Name keyName)
virtual

Get a public key.

Parameters
keyNameThe public key name.
Returns
The public key.
Exceptions
SecTpm::Errorif public key does not exist in TPM.

Implements ndn::SecTpm.

Definition at line 500 of file sec-tpm-osx.cpp.

References ndn::CFReleaser< T >::get(), ndn::KEY_CLASS_PUBLIC, and ndn::Name::toUri().

Referenced by deleteKeyPairInTpm(), and exportPrivateKeyPkcs8FromTpmInternal().

§ signInTpm()

virtual Block ndn::SecTpmOsx::signInTpm ( const uint8_t *  data,
size_t  dataLength,
const Name keyName,
DigestAlgorithm  digestAlgorithm 
)
inlinevirtual

Sign data.

Parameters
dataPointer to the byte array to be signed.
dataLengthThe length of data.
keyNameThe name of the signing key.
digestAlgorithmthe digest algorithm.
Returns
The signature block.
Exceptions
SecTpm::Errorif signing fails.

Implements ndn::SecTpm.

Definition at line 91 of file sec-tpm-osx.hpp.

References addAppToAcl(), decryptInTpm(), doesKeyExistInTpm(), encryptInTpm(), generateRandomBlock(), generateSymmetricKeyInTpm(), getScheme(), and signInTpmInternal().

§ decryptInTpm()

ConstBufferPtr ndn::SecTpmOsx::decryptInTpm ( const uint8_t *  data,
size_t  dataLength,
const Name keyName,
bool  isSymmetric 
)
virtual

Decrypt data.

Parameters
dataPointer to the byte arry to be decrypted.
dataLengthThe length of data.
keyNameThe name of the decrypting key.
isSymmetricIf true symmetric encryption is used, otherwise asymmetric encryption.
Returns
The decrypted data.
Exceptions
SecTpm::Errorif decryption fails.

Implements ndn::SecTpm.

Definition at line 882 of file sec-tpm-osx.cpp.

Referenced by signInTpm().

§ encryptInTpm()

ConstBufferPtr ndn::SecTpmOsx::encryptInTpm ( const uint8_t *  data,
size_t  dataLength,
const Name keyName,
bool  isSymmetric 
)
virtual

Encrypt data.

Parameters
dataPointer to the byte arry to be decrypted.
dataLengthThe length of data.
keyNameThe name of the encrypting key.
isSymmetricIf true symmetric encryption is used, otherwise asymmetric encryption.
Returns
The encrypted data.
Exceptions
SecTpm::Errorif encryption fails.

Implements ndn::SecTpm.

Definition at line 974 of file sec-tpm-osx.cpp.

Referenced by signInTpm().

§ generateSymmetricKeyInTpm()

void ndn::SecTpmOsx::generateSymmetricKeyInTpm ( const Name keyName,
const KeyParams params 
)
virtual

Generate a symmetric key.

Parameters
keyNameThe name of the key.
paramsThe parameter of the key.
Exceptions
SecTpm::Errorif key generating fails.

Implements ndn::SecTpm.

Definition at line 465 of file sec-tpm-osx.cpp.

Referenced by signInTpm().

§ doesKeyExistInTpm()

bool ndn::SecTpmOsx::doesKeyExistInTpm ( const Name keyName,
KeyClass  keyClass 
)
virtual

Check if a particular key exists.

Parameters
keyNameThe name of the key.
keyClassThe class of the key, e.g. KEY_CLASS_PUBLIC, KEY_CLASS_PRIVATE.
Returns
True if the key exists, otherwise false.

Implements ndn::SecTpm.

Definition at line 1014 of file sec-tpm-osx.cpp.

References ndn::CFReleaser< T >::get().

Referenced by generateKeyPairInTpmInternal(), and signInTpm().

§ generateRandomBlock()

bool ndn::SecTpmOsx::generateRandomBlock ( uint8_t *  res,
size_t  size 
)
virtual

Generate a random block.

Parameters
resThe pointer to the generated block
sizeThe random block size
Returns
true for success, otherwise false

Implements ndn::SecTpm.

Definition at line 1045 of file sec-tpm-osx.cpp.

Referenced by signInTpm().

§ addAppToAcl()

void ndn::SecTpmOsx::addAppToAcl ( const Name keyName,
KeyClass  keyClass,
const std::string &  appPath,
AclType  acl 
)
virtual

Add the application into the ACL of a particular key.

Parameters
keyNamethe name of key
keyClassthe class of key, e.g. Private Key
appPaththe absolute path to the application
aclthe new acl of the key

Implements ndn::SecTpm.

Definition at line 926 of file sec-tpm-osx.cpp.

References ndn::ACL_TYPE_PRIVATE, ndn::CFReleaser< T >::get(), ndn::KEY_CLASS_PRIVATE, and ndn::Name::toUri().

Referenced by signInTpm().

§ getScheme()

std::string ndn::SecTpmOsx::getScheme ( )
protectedvirtual

Implements ndn::SecTpm.

Definition at line 526 of file sec-tpm-osx.cpp.

References SCHEME.

Referenced by signInTpm().

§ exportPrivateKeyPkcs8FromTpm()

virtual ConstBufferPtr ndn::SecTpmOsx::exportPrivateKeyPkcs8FromTpm ( const Name keyName)
inlineprotectedvirtual

Export a private key in PKCS#8 format.

Parameters
keyNameThe private key name.
Returns
The private key info (in PKCS#8 format) if exist, otherwise a NULL pointer.

Implements ndn::SecTpm.

Definition at line 121 of file sec-tpm-osx.hpp.

References exportPrivateKeyPkcs8FromTpmInternal().

§ importPrivateKeyPkcs8IntoTpm()

virtual bool ndn::SecTpmOsx::importPrivateKeyPkcs8IntoTpm ( const Name keyName,
const uint8_t *  buffer,
size_t  bufferSize 
)
inlineprotectedvirtual

Import a private key from PKCS#8 formatted buffer of size bufferSize.

Parameters
keyNameThe private key name.
bufferPointer to the first byte of the buffer containing PKCS#8-encoded private key info
bufferSizeSize of the buffer
Returns
false if import fails

Implements ndn::SecTpm.

Definition at line 127 of file sec-tpm-osx.hpp.

References deleteKeyPairInTpmInternal(), exportPrivateKeyPkcs8FromTpmInternal(), generateKeyPairInTpmInternal(), importPrivateKeyPkcs8IntoTpmInternal(), importPublicKeyPkcs1IntoTpm(), and signInTpmInternal().

§ importPublicKeyPkcs1IntoTpm()

bool ndn::SecTpmOsx::importPublicKeyPkcs1IntoTpm ( const Name keyName,
const uint8_t *  buffer,
size_t  bufferSize 
)
protectedvirtual

Import a public key in PKCS#1 formatted buffer of size bufferSize.

Parameters
keyNameThe public key name
bufferPointer to the first byte of the buffer containing PKCS#1-encoded private key info
bufferSizeSize of the buffer
Returns
false if import fails

Implements ndn::SecTpm.

Definition at line 751 of file sec-tpm-osx.cpp.

References ndn::CFReleaser< T >::get(), and ndn::Name::toUri().

Referenced by importPrivateKeyPkcs8IntoTpm().

§ generateKeyPairInTpmInternal()

void ndn::SecTpmOsx::generateKeyPairInTpmInternal ( const Name keyName,
const KeyParams params,
bool  needRetry 
)
protected

§ deleteKeyPairInTpmInternal()

void ndn::SecTpmOsx::deleteKeyPairInTpmInternal ( const Name keyName,
bool  needRetry 
)
protected

§ exportPrivateKeyPkcs8FromTpmInternal()

ConstBufferPtr ndn::SecTpmOsx::exportPrivateKeyPkcs8FromTpmInternal ( const Name keyName,
bool  needRetry 
)
protected

§ importPrivateKeyPkcs8IntoTpmInternal()

bool ndn::SecTpmOsx::importPrivateKeyPkcs8IntoTpmInternal ( const Name keyName,
const uint8_t *  buf,
size_t  size,
bool  needRetry 
)
protected

§ signInTpmInternal()

Block ndn::SecTpmOsx::signInTpmInternal ( const uint8_t *  data,
size_t  dataLength,
const Name keyName,
DigestAlgorithm  digestAlgorithm,
bool  needRetry 
)
protected

Member Data Documentation

§ SCHEME

const std::string ndn::SecTpmOsx::SCHEME
static

Definition at line 156 of file sec-tpm-osx.hpp.

Referenced by getScheme().


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