#include <sec-tpm-osx.hpp>
Classes | |
class | Error |
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 ¶ms) |
Generate a pair of asymmetric keys. More... | |
virtual void | deleteKeyPairInTpm (const Name &keyName) |
Delete a key pair of asymmetric keys. More... | |
virtual shared_ptr< v1::PublicKey > | getPublicKeyFromTpm (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 ¶ms) |
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::security::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 ¶ms, 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::security::SecTpm | |
virtual bool | getImpExpPassWord (std::string &password, const std::string &prompt) |
Get import/export password. More... | |
Additional Inherited Members | |
Protected Attributes inherited from ndn::security::SecTpm | |
std::string | m_location |
Definition at line 38 of file sec-tpm-osx.hpp.
|
explicit |
Definition at line 245 of file sec-tpm-osx.cpp.
Referenced by ndn::security::SecTpmOsx::Error::Error().
|
virtual |
Definition at line 261 of file sec-tpm-osx.cpp.
Referenced by ndn::security::SecTpmOsx::Error::Error().
|
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.
password | The password |
passwordLength | The length of password |
Implements ndn::security::SecTpm.
Definition at line 266 of file sec-tpm-osx.cpp.
Referenced by ndn::security::SecTpmOsx::Error::Error().
|
virtual |
reset password of TPM
Implements ndn::security::SecTpm.
Definition at line 275 of file sec-tpm-osx.cpp.
Referenced by ndn::security::SecTpmOsx::Error::Error().
|
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::security::SecTpm.
Definition at line 283 of file sec-tpm-osx.cpp.
Referenced by ndn::security::SecTpmOsx::Error::Error().
|
virtual |
Get value of inTerminal flag.
Implements ndn::security::SecTpm.
Definition at line 293 of file sec-tpm-osx.cpp.
Referenced by ndn::security::SecTpmOsx::Error::Error().
|
virtual |
Check if TPM is locked.
Implements ndn::security::SecTpm.
Definition at line 299 of file sec-tpm-osx.cpp.
Referenced by ndn::security::SecTpmOsx::Error::Error(), and unlockTpm().
|
virtual |
Unlock the TPM.
password | The password. |
passwordLength | The password size. 0 indicates no password. |
usePassword | True if we want to use the supplied password to unlock the TPM. |
Implements ndn::security::SecTpm.
Definition at line 311 of file sec-tpm-osx.cpp.
References isLocked().
Referenced by deleteKeyPairInTpmInternal(), ndn::security::SecTpmOsx::Error::Error(), exportPrivateKeyPkcs8FromTpmInternal(), generateKeyPairInTpmInternal(), importPrivateKeyPkcs8IntoTpmInternal(), and signInTpmInternal().
|
inlinevirtual |
Generate a pair of asymmetric keys.
keyName | The name of the key pair. |
params | The parameters of key. |
SecTpm::Error | if fails. |
Implements ndn::security::SecTpm.
Definition at line 77 of file sec-tpm-osx.hpp.
References generateKeyPairInTpmInternal().
|
inlinevirtual |
Delete a key pair of asymmetric keys.
keyName | The name of the key pair. |
Implements ndn::security::SecTpm.
Definition at line 83 of file sec-tpm-osx.hpp.
References deleteKeyPairInTpmInternal(), and getPublicKeyFromTpm().
|
virtual |
Get a public key.
keyName | The public key name. |
SecTpm::Error | if public key does not exist in TPM. |
Implements ndn::security::SecTpm.
Definition at line 503 of file sec-tpm-osx.cpp.
References ndn::security::CFReleaser< T >::get(), ndn::PUBLIC, and ndn::Name::toUri().
Referenced by deleteKeyPairInTpm(), and exportPrivateKeyPkcs8FromTpmInternal().
|
inlinevirtual |
Sign data.
data | Pointer to the byte array to be signed. |
dataLength | The length of data. |
keyName | The name of the signing key. |
digestAlgorithm | the digest algorithm. |
SecTpm::Error | if signing fails. |
Implements ndn::security::SecTpm.
Definition at line 92 of file sec-tpm-osx.hpp.
References addAppToAcl(), decryptInTpm(), doesKeyExistInTpm(), encryptInTpm(), generateRandomBlock(), generateSymmetricKeyInTpm(), getScheme(), and signInTpmInternal().
|
virtual |
Decrypt data.
data | Pointer to the byte arry to be decrypted. |
dataLength | The length of data. |
keyName | The name of the decrypting key. |
isSymmetric | If true symmetric encryption is used, otherwise asymmetric encryption. |
SecTpm::Error | if decryption fails. |
Implements ndn::security::SecTpm.
Definition at line 870 of file sec-tpm-osx.cpp.
Referenced by signInTpm().
|
virtual |
Encrypt data.
data | Pointer to the byte arry to be decrypted. |
dataLength | The length of data. |
keyName | The name of the encrypting key. |
isSymmetric | If true symmetric encryption is used, otherwise asymmetric encryption. |
SecTpm::Error | if encryption fails. |
Implements ndn::security::SecTpm.
Definition at line 960 of file sec-tpm-osx.cpp.
Referenced by signInTpm().
|
virtual |
Generate a symmetric key.
keyName | The name of the key. |
params | The parameter of the key. |
SecTpm::Error | if key generating fails. |
Implements ndn::security::SecTpm.
Definition at line 468 of file sec-tpm-osx.cpp.
Referenced by signInTpm().
|
virtual |
Check if a particular key exists.
keyName | The name of the key. |
keyClass | The class of the key, e.g. KeyClass::PUBLIC, KeyClass::PRIVATE. |
Implements ndn::security::SecTpm.
Definition at line 1000 of file sec-tpm-osx.cpp.
References ndn::security::CFReleaser< T >::get().
Referenced by generateKeyPairInTpmInternal(), and signInTpm().
|
virtual |
Generate a random block.
res | The pointer to the generated block |
size | The random block size |
Implements ndn::security::SecTpm.
Definition at line 1031 of file sec-tpm-osx.cpp.
Referenced by signInTpm().
|
virtual |
Add the application into the ACL of a particular key.
keyName | the name of key |
keyClass | the class of key, e.g. Private Key |
appPath | the absolute path to the application |
acl | the new acl of the key |
Implements ndn::security::SecTpm.
Definition at line 914 of file sec-tpm-osx.cpp.
References ndn::security::CFReleaser< T >::get(), ndn::PRIVATE, and ndn::Name::toUri().
Referenced by signInTpm().
|
protectedvirtual |
Implements ndn::security::SecTpm.
Definition at line 527 of file sec-tpm-osx.cpp.
References SCHEME.
Referenced by signInTpm().
|
inlineprotectedvirtual |
Export a private key in PKCS#8 format.
keyName | The private key name. |
Implements ndn::security::SecTpm.
Definition at line 122 of file sec-tpm-osx.hpp.
References exportPrivateKeyPkcs8FromTpmInternal().
|
inlineprotectedvirtual |
Import a private key from PKCS#8 formatted buffer of size bufferSize
.
keyName | The private key name. |
buffer | Pointer to the first byte of the buffer containing PKCS#8-encoded private key info |
bufferSize | Size of the buffer |
Implements ndn::security::SecTpm.
Definition at line 128 of file sec-tpm-osx.hpp.
References deleteKeyPairInTpmInternal(), exportPrivateKeyPkcs8FromTpmInternal(), generateKeyPairInTpmInternal(), importPrivateKeyPkcs8IntoTpmInternal(), importPublicKeyPkcs1IntoTpm(), and signInTpmInternal().
|
protectedvirtual |
Import a public key in PKCS#1 formatted buffer of size bufferSize
.
keyName | The public key name |
buffer | Pointer to the first byte of the buffer containing PKCS#1-encoded private key info |
bufferSize | Size of the buffer |
Implements ndn::security::SecTpm.
Definition at line 743 of file sec-tpm-osx.cpp.
References ndn::security::CFReleaser< T >::get(), and ndn::Name::toUri().
Referenced by importPrivateKeyPkcs8IntoTpm().
|
protected |
Definition at line 373 of file sec-tpm-osx.cpp.
References doesKeyExistInTpm(), ndn::EC, ndn::security::CFReleaser< T >::get(), ndn::SimplePublicKeyParams< KeyParamsInfo >::getKeySize(), ndn::KeyParams::getKeyType(), ndn::PUBLIC, ndn::RSA, and unlockTpm().
Referenced by generateKeyPairInTpm(), and importPrivateKeyPkcs8IntoTpm().
|
protected |
Definition at line 441 of file sec-tpm-osx.cpp.
References ndn::security::CFReleaser< T >::get(), ndn::Name::toUri(), and unlockTpm().
Referenced by deleteKeyPairInTpm(), and importPrivateKeyPkcs8IntoTpm().
|
protected |
Definition at line 533 of file sec-tpm-osx.cpp.
References ndn::Oid::decode(), ndn::EC, ndn::Oid::encode(), ndn::security::CFReleaser< T >::get(), getPublicKeyFromTpm(), ndn::PRIVATE, ndn::RSA, ndn::oid::RSA, ndn::Name::toUri(), and unlockTpm().
Referenced by exportPrivateKeyPkcs8FromTpm(), and importPrivateKeyPkcs8IntoTpm().
|
protected |
Definition at line 632 of file sec-tpm-osx.cpp.
References ndn::Oid::decode(), ndn::oid::ECDSA, ndn::security::CFReleaser< T >::get(), ndn::oid::RSA, ndn::Name::toUri(), and unlockTpm().
Referenced by importPrivateKeyPkcs8IntoTpm().
|
protected |
Definition at line 790 of file sec-tpm-osx.cpp.
References ndn::security::CFReleaser< T >::get(), ndn::PRIVATE, ndn::tlv::SignatureValue, ndn::Name::toUri(), and unlockTpm().
Referenced by importPrivateKeyPkcs8IntoTpm(), and signInTpm().
|
static |
Definition at line 157 of file sec-tpm-osx.hpp.
Referenced by getScheme().