22 #ifndef NDN_SECURITY_V2_KEY_CHAIN_HPP 23 #define NDN_SECURITY_V2_KEY_CHAIN_HPP 49 class Error :
public std::runtime_error
52 using std::runtime_error::runtime_error;
95 KeyChain(
const std::string& pibLocator,
const std::string& tpmLocator,
bool allowReset =
false);
338 template<
class PibBackendType>
348 template<
class TpmBackendType>
353 typedef std::map<std::string, function<unique_ptr<pib::PibImpl>(
const std::string& location)>> PibFactories;
354 typedef std::map<std::string, function<unique_ptr<tpm::BackEnd>(
const std::string& location)>> TpmFactories;
362 static std::tuple<std::string, std::string>
363 parseAndCheckPibLocator(
const std::string& pibLocator);
365 static std::tuple<std::string, std::string>
366 parseAndCheckTpmLocator(
const std::string& tpmLocator);
368 static const std::string&
369 getDefaultPibScheme();
371 static const std::string&
372 getDefaultTpmScheme();
377 static unique_ptr<Pib>
378 createPib(
const std::string& pibLocator);
383 static unique_ptr<Tpm>
384 createTpm(
const std::string& tpmLocator);
387 static const std::string&
388 getDefaultPibLocator();
390 static const std::string&
391 getDefaultTpmLocator();
414 std::tuple<Name, SignatureInfo>
432 std::unique_ptr<Pib> m_pib;
433 std::unique_ptr<Tpm> m_tpm;
435 static std::string s_defaultPibLocator;
436 static std::string s_defaultTpmLocator;
439 template<
class PibType>
443 getPibFactories().emplace(scheme, [] (
const std::string& locator) {
444 return unique_ptr<pib::PibImpl>(
new PibType(locator));
448 template<
class TpmType>
452 getTpmFactories().emplace(scheme, [] (
const std::string& locator) {
453 return unique_ptr<tpm::BackEnd>(
new TpmType(locator));
465 #define NDN_CXX_V2_KEYCHAIN_REGISTER_PIB_BACKEND(PibType) \ 466 static class NdnCxxAuto ## PibType ## PibRegistrationClass \ 469 NdnCxxAuto ## PibType ## PibRegistrationClass() \ 471 ::ndn::security::v2::KeyChain::registerPibBackend<PibType>(PibType::getScheme()); \ 473 } ndnCxxAuto ## PibType ## PibRegistrationVariable 483 #define NDN_CXX_V2_KEYCHAIN_REGISTER_TPM_BACKEND(TpmType) \ 484 static class NdnCxxAuto ## TpmType ## TpmRegistrationClass \ 487 NdnCxxAuto ## TpmType ## TpmRegistrationClass() \ 489 ::ndn::security::v2::KeyChain::registerTpmBackend<TpmType>(TpmType::getScheme()); \ 491 } ndnCxxAuto ## TpmType ## TpmRegistrationVariable 503 #endif // NDN_SECURITY_V2_KEY_CHAIN_HPP void deleteKey(const Identity &identity, const Key &key)
Delete a key key of identity.
Copyright (c) 2011-2015 Regents of the University of California.
The certificate following the certificate format naming convention.
The interface of signing key management.
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 key for identity according to params.
KeyChain()
Constructor to create KeyChain with default PIB and TPM.
Represents a TLV element of 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.
represents the front-end of TPM
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 pair of certificate and its corresponding private key encapsulated in 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()
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE DigestAlgorithm digestAlgorithm
static void registerTpmBackend(const std::string &scheme)
Register a new TPM backend.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Represents an absolute name.
Error indicating that the supplied SigningInfo is invalid.
SignatureTypeValue
SignatureType values.
void sign(Data &data, const SigningInfo ¶ms=getDefaultSigningInfo())
Sign data according to the supplied signing information.
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 of key parameters.
A frontend handle of an Identity.
Represents a Data packet.