22 #ifndef NDN_SECURITY_KEY_CHAIN_HPP 23 #define NDN_SECURITY_KEY_CHAIN_HPP 48 class Error :
public std::runtime_error
51 using std::runtime_error::runtime_error;
94 KeyChain(
const std::string& pibLocator,
const std::string& tpmLocator,
bool allowReset =
false);
305 [[deprecated(
"sign Interests and Data directly")]]
360 template<
class PibBackendType>
370 template<
class TpmBackendType>
375 typedef std::map<std::string, function<std::shared_ptr<pib::PibImpl>(
const std::string& location)>> PibFactories;
376 typedef std::map<std::string, function<unique_ptr<tpm::BackEnd>(
const std::string& location)>> TpmFactories;
384 static std::tuple<std::string, std::string>
385 parseAndCheckPibLocator(
const std::string& pibLocator);
387 static std::tuple<std::string, std::string>
388 parseAndCheckTpmLocator(
const std::string& tpmLocator);
390 static const std::string&
391 getDefaultPibScheme();
393 static const std::string&
394 getDefaultTpmScheme();
399 static unique_ptr<Pib>
400 createPib(
const std::string& pibLocator);
405 static unique_ptr<Tpm>
406 createTpm(
const std::string& tpmLocator);
409 static const std::string&
410 getDefaultPibLocator();
412 static const std::string&
413 getDefaultTpmLocator();
432 std::tuple<Name, SignatureInfo>
446 [[deprecated(
"use default constructor for SigningInfo")]]
454 std::unique_ptr<Pib> m_pib;
455 std::unique_ptr<Tpm> m_tpm;
457 static std::string s_defaultPibLocator;
458 static std::string s_defaultTpmLocator;
461 template<
class PibType>
465 getPibFactories().emplace(scheme, [] (
const std::string& locator) {
466 return std::shared_ptr<pib::PibImpl>(
new PibType(locator));
470 template<
class TpmType>
474 getTpmFactories().emplace(scheme, [] (
const std::string& locator) {
475 return unique_ptr<tpm::BackEnd>(
new TpmType(locator));
487 #define NDN_CXX_KEYCHAIN_REGISTER_PIB_BACKEND(PibType) \ 488 static class NdnCxxAuto ## PibType ## PibRegistrationClass \ 491 NdnCxxAuto ## PibType ## PibRegistrationClass() \ 493 ::ndn::security::v2::KeyChain::registerPibBackend<PibType>(PibType::getScheme()); \ 495 } ndnCxxAuto ## PibType ## PibRegistrationVariable 505 #define NDN_CXX_KEYCHAIN_REGISTER_TPM_BACKEND(TpmType) \ 506 static class NdnCxxAuto ## TpmType ## TpmRegistrationClass \ 509 NdnCxxAuto ## TpmType ## TpmRegistrationClass() \ 511 ::ndn::security::v2::KeyChain::registerTpmBackend<TpmType>(TpmType::getScheme()); \ 513 } ndnCxxAuto ## TpmType ## TpmRegistrationVariable 518 using security::v2::KeyChain;
522 #endif // NDN_SECURITY_KEY_CHAIN_HPP void deleteKey(const Identity &identity, const Key &key)
Delete a key key of identity.
The certificate following the certificate format naming convention.
The interface of signing key management.
SimpleSymmetricKeyParams is a template for symmetric keys with only one parameter: size...
void addCertificate(const Key &key, const Certificate &certificate)
Add a certificate certificate for key.
Key createKey(const Identity &identity, const KeyParams ¶ms=getDefaultKeyParams())
Create a new key for identity.
KeyChain()
Constructor to create KeyChain with default PIB and TPM.
void sign(Data &data, const SigningInfo ¶ms=SigningInfo())
Sign a Data packet according to the supplied signing information.
Represents a TLV element of the NDN packet format.
Error indicating that the supplied TPM locator does not match the locator stored in PIB...
Represents an Interest packet.
Signing parameters passed to KeyChain.
void deleteCertificate(const Key &key, const Name &certificateName)
delete a certificate with name certificateName of key.
SimpleSymmetricKeyParams< detail::HmacKeyParamsInfo > HmacKeyParams
HmacKeyParams carries parameters for HMAC key.
const Pib & getPib() const
Identity createIdentity(const Name &identityName, const KeyParams ¶ms=getDefaultKeyParams())
Create an identity identityName.
void importSafeBag(const SafeBag &safeBag, const char *pw, size_t pwLen)
Import a certificate and its corresponding private key from a SafeBag.
KeyType
The type of a cryptographic key.
const Tpm & getTpm() const
shared_ptr< SafeBag > exportSafeBag(const Certificate &certificate, const char *pw, size_t pwLen)
Export a certificate and its corresponding private key.
A frontend handle of a key instance.
void setDefaultCertificate(const Key &key, const Certificate &certificate)
Set cert as the default certificate of key.
void setDefaultIdentity(const Identity &identity)
Set identity as the default identity.
static void registerPibBackend(const std::string &scheme)
Register a new PIB backend.
static const SigningInfo & getDefaultSigningInfo()
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
static void registerTpmBackend(const std::string &scheme)
Register a new TPM backend.
Represents an absolute name.
Error indicating that the supplied SigningInfo is invalid.
Name createHmacKey(const Name &prefix=SigningInfo::getHmacIdentity(), const HmacKeyParams ¶ms=HmacKeyParams())
Create a new HMAC key.
void importPrivateKey(const Name &keyName, shared_ptr< transform::PrivateKey > key)
Import a private key into the TPM.
SignatureTypeValue
SignatureType values.
void deleteIdentity(const Identity &identity)
delete identity.
static const KeyParams & getDefaultKeyParams()
a secured container for sensitive information(certificate, private key)
void setDefaultKey(const Identity &identity, const Key &key)
Set key as the default key of identity.
Base class for key parameters.
A frontend handle of an Identity.
Represents a Data packet.
static const Name & getHmacIdentity()
A localhost identity to indicate that the signature is generated using an HMAC key.
shared_ptr< const Buffer > ConstBufferPtr