|
NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
|
API Documentation
|
Go to the documentation of this file.
26 #include <boost/lexical_cast.hpp>
32 Tpm::Tpm(
const std::string& scheme,
const std::string& location, unique_ptr<BackEnd> backEnd)
34 , m_location(location)
35 , m_backEnd(std::
move(backEnd))
44 return m_scheme +
":" + m_location;
50 return m_backEnd->hasKey(keyName);
56 auto keyHandle = m_backEnd->createKey(identityName, params);
57 auto keyName = keyHandle->getKeyName();
65 auto it = m_keys.find(keyName);
66 if (it != m_keys.end())
69 m_backEnd->deleteKey(keyName);
91 return key->
sign(digestAlgorithm,
buf, size);
101 return boost::logic::indeterminate;
120 return m_backEnd->isTerminalMode();
126 m_backEnd->setTerminalMode(isTerminal);
132 return m_backEnd->isTpmLocked();
138 return m_backEnd->unlockTpm(password, passwordLength);
144 return m_backEnd->exportKey(keyName, pw, pwLen);
149 const char* pw,
size_t pwLen)
151 m_backEnd->importKey(keyName, pkcs8, pkcs8Len, pw, pwLen);
157 m_backEnd->importKey(keyName,
std::move(key));
161 Tpm::findKey(
const Name& keyName)
const
163 auto it = m_keys.find(keyName);
164 if (it != m_keys.end())
165 return it->second.get();
167 auto handle = m_backEnd->getKeyHandle(keyName);
168 if (handle ==
nullptr)
bool verify(DigestAlgorithm digestAlgorithm, const uint8_t *buf, size_t bufLen, const uint8_t *sig, size_t sigLen) const
Verify the signature sig created on buf using this key and digestAlgorithm.
Base class for key parameters.
ConstBufferPtr derivePublicKey() const
ConstBufferPtr exportPrivateKey(const Name &keyName, const char *pw, size_t pwLen) const
Export a private key.
ConstBufferPtr decrypt(const uint8_t *cipherText, size_t cipherTextLen) const
ConstBufferPtr getPublicKey(const Name &keyName) const
void deleteKey(const Name &keyName)
Delete a key pair with name keyName.
Abstraction of TPM key handle.
Represents an absolute name.
boost::logic::tribool verify(const uint8_t *buf, size_t bufLen, const uint8_t *sig, size_t sigLen, const Name &keyName, DigestAlgorithm digestAlgorithm) const
Verify blob using the key with name keyName and using the digest digestAlgorithm.
std::string getTpmLocator() const
void importPrivateKey(const Name &keyName, const uint8_t *pkcs8, size_t pkcs8Len, const char *pw, size_t pwLen)
Import a private key.
NDN_CXX_NODISCARD bool unlockTpm(const char *password, size_t passwordLength) const
Unlock the TPM.
void setTerminalMode(bool isTerminal) const
Set the terminal mode of the TPM.
bool isTerminalMode() const
Check if the TPM is in terminal mode.
ConstBufferPtr decrypt(const uint8_t *buf, size_t size, const Name &keyName) const
Decrypt blob using the key with name keyName.
bool hasKey(const Name &keyName) const
Check if a private key exists.
ConstBufferPtr sign(DigestAlgorithm digestAlgorithm, const uint8_t *buf, size_t size) const
Name createKey(const Name &identityName, const KeyParams ¶ms)
Create key for identityName according to params.
shared_ptr< const Buffer > ConstBufferPtr
Copyright (c) 2011-2015 Regents of the University of California.
ConstBufferPtr sign(const uint8_t *buf, size_t size, const Name &keyName, DigestAlgorithm digestAlgorithm) const
Sign blob using the key with name keyName and using the digest digestAlgorithm.