9 #ifndef NDN_SECURITY_SEC_TPM_HPP
10 #define NDN_SECURITY_SEC_TPM_HPP
12 #include "../common.hpp"
14 #include "../name.hpp"
15 #include "../data.hpp"
28 class Error :
public std::runtime_error
33 : std::runtime_error(what)
52 setTpmPassword(
const uint8_t* password,
size_t passwordLength) = 0;
96 unlockTpm(
const char* password,
size_t passwordLength,
bool usePassword) = 0;
124 virtual shared_ptr<PublicKey>
138 signInTpm(
const uint8_t* data,
size_t dataLength,
153 decryptInTpm(
const uint8_t* data,
size_t dataLength,
const Name& keyName,
bool isSymmetric) = 0;
166 encryptInTpm(
const uint8_t* data,
size_t dataLength,
const Name& keyName,
bool isSymmetric) = 0;
233 const uint8_t* buf,
size_t size,
234 const std::string& password);
285 pw0 = getpass(prompt.c_str());
288 std::string password1 = pw0;
289 memset(pw0, 0, strlen(pw0));
291 pw0 = getpass(
"Confirm:");
294 char* pw1 =
const_cast<char*
>(password1.c_str());
295 memset(pw1, 0, password1.size());
299 if (!password1.compare(pw0))
302 password.swap(password1);
305 char* pw1 =
const_cast<char*
>(password1.c_str());
306 memset(pw1, 0, password1.size());
307 memset(pw0, 0, strlen(pw0));
309 if (password.empty())
317 #endif //NDN_SECURITY_SEC_TPM_HPP
virtual ConstBufferPtr exportPrivateKeyPkcs8FromTpm(const Name &keyName)=0
Export a private key in PKCS#8 format.
virtual void addAppToACL(const Name &keyName, KeyClass keyClass, const std::string &appPath, AclType acl)=0
Add the application into the ACL of a particular key.
virtual bool importPrivateKeyPkcs8IntoTpm(const Name &keyName, const uint8_t *buf, size_t size)=0
Import a private key in PKCS#8 format.
Error(const std::string &what)
virtual bool importPublicKeyPkcs1IntoTpm(const Name &keyName, const uint8_t *buf, size_t size)=0
Import a public key in PKCS#1 format.
Class representing wire element of the NDN packet.
virtual bool getInTerminal()=0
get inTerminal flag
ptr_lib::shared_ptr< const Buffer > ConstBufferPtr
virtual void setTpmPassword(const uint8_t *password, size_t passwordLength)=0
set password of TPM
virtual bool generateRandomBlock(uint8_t *res, size_t size)=0
Generate a random block.
virtual ConstBufferPtr encryptInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, bool isSymmetric)=0
Encrypt data.
virtual bool locked()=0
check if TPM is locked.
virtual bool doesKeyExistInTpm(const Name &keyName, KeyClass keyClass)=0
Check if a particular key exists.
ConstBufferPtr exportPrivateKeyPkcs5FromTpm(const Name &keyName, const std::string &password)
Export a private key in PKCS#5 format.
virtual void resetTpmPassword()=0
reset password of TPM
virtual void generateSymmetricKeyInTpm(const Name &keyName, KeyType keyType, int keySize)=0
Generate a symmetric key.
virtual shared_ptr< PublicKey > getPublicKeyFromTpm(const Name &keyName)=0
Get a public key.
SecTpm is the base class of the TPM classes.
bool importPrivateKeyPkcs5IntoTpm(const Name &keyName, const uint8_t *buf, size_t size, const std::string &password)
Import a private key in PKCS#5 format.
virtual void deleteKeyPairInTpm(const Name &keyName)=0
Delete a key pair of asymmetric keys.
A Name holds an array of Name::Component and represents an NDN name.
virtual bool getImpExpPassWord(std::string &password, const std::string &prompt)
Get import/export password.
virtual ConstBufferPtr decryptInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, bool isSymmetric)=0
Decrypt data.
virtual Block signInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, DigestAlgorithm digestAlgorithm)=0
Sign data.
virtual bool unlockTpm(const char *password, size_t passwordLength, bool usePassword)=0
Unlock the TPM.
virtual void setInTerminal(bool inTerminal)=0
set inTerminal flag
virtual void generateKeyPairInTpm(const Name &keyName, KeyType keyType, int keySize)=0
Generate a pair of asymmetric keys.