22 #ifndef NDN_CXX_SECURITY_KEY_CHAIN_HPP 23 #define NDN_CXX_SECURITY_KEY_CHAIN_HPP 89 class Error :
public std::runtime_error
92 using std::runtime_error::runtime_error;
135 KeyChain(
const std::string& pibLocator,
const std::string& tpmLocator,
bool allowReset =
false);
152 getDefaultKeyParams();
173 createIdentity(
const Name& identityName,
const KeyParams& params = getDefaultKeyParams());
182 deleteIdentity(
const Identity& identity);
189 setDefaultIdentity(
const Identity& identity);
205 createKey(
const Identity& identity,
const KeyParams& params = getDefaultKeyParams());
230 deleteKey(
const Identity& identity,
const Key& key);
240 setDefaultKey(
const Identity& identity,
const Key& key);
267 deleteCertificate(
const Key& key,
const Name& certificateName);
279 setDefaultCertificate(
const Key& key,
const Certificate& certificate);
377 exportSafeBag(
const Certificate& certificate,
const char* pw,
size_t pwLen);
395 importSafeBag(
const SafeBag& safeBag,
const char* pw,
size_t pwLen);
401 importPrivateKey(
const Name& keyName, shared_ptr<transform::PrivateKey> key);
410 template<
class PibBackendType>
414 getPibFactories().emplace(scheme, [] (
const std::string& locator) {
415 return shared_ptr<pib::PibImpl>(
new PibBackendType(locator));
425 template<
class TpmBackendType>
429 getTpmFactories().emplace(scheme, [] (
const std::string& locator) {
430 return unique_ptr<tpm::BackEnd>(
new TpmBackendType(locator));
435 using PibFactories = std::map<std::string, std::function<shared_ptr<pib::PibImpl>(
const std::string&)>>;
436 using TpmFactories = std::map<std::string, std::function<unique_ptr<tpm::BackEnd>(
const std::string&)>>;
444 static std::tuple<std::string, std::string>
445 parseAndCheckPibLocator(
const std::string& pibLocator);
447 static std::tuple<std::string, std::string>
448 parseAndCheckTpmLocator(
const std::string& tpmLocator);
450 static const std::string&
451 getDefaultPibScheme();
453 static const std::string&
454 getDefaultTpmScheme();
459 static unique_ptr<Pib>
460 createPib(
const std::string& pibLocator);
465 static unique_ptr<Tpm>
466 createTpm(
const std::string& tpmLocator);
469 static const std::string&
470 getDefaultPibLocator();
472 static const std::string&
473 getDefaultTpmLocator();
483 makeCertificate(
const Name& keyName, span<const uint8_t> publicKey,
SigningInfo params,
502 std::tuple<Name, SignatureInfo>
505 std::tuple<Name, SignatureInfo>
506 prepareSignatureInfoSha256(
const SigningInfo& params);
508 std::tuple<Name, SignatureInfo>
509 prepareSignatureInfoHmac(
const SigningInfo& params);
511 std::tuple<Name, SignatureInfo>
514 std::tuple<Name, SignatureInfo>
516 optional<Name> certName =
nullopt);
526 unique_ptr<Pib> m_pib;
527 unique_ptr<Tpm> m_tpm;
529 static std::string s_defaultPibLocator;
530 static std::string s_defaultTpmLocator;
541 #define NDN_CXX_KEYCHAIN_REGISTER_PIB_BACKEND(PibType) \ 542 static class NdnCxxAuto ## PibType ## PibRegistrationClass \ 545 NdnCxxAuto ## PibType ## PibRegistrationClass() \ 547 ::ndn::security::KeyChain::registerPibBackend<PibType>(PibType::getScheme()); \ 549 } ndnCxxAuto ## PibType ## PibRegistrationVariable 559 #define NDN_CXX_KEYCHAIN_REGISTER_TPM_BACKEND(TpmType) \ 560 static class NdnCxxAuto ## TpmType ## TpmRegistrationClass \ 563 NdnCxxAuto ## TpmType ## TpmRegistrationClass() \ 565 ::ndn::security::KeyChain::registerTpmBackend<TpmType>(TpmType::getScheme()); \ 567 } ndnCxxAuto ## TpmType ## TpmRegistrationVariable 576 #endif // NDN_CXX_SECURITY_KEY_CHAIN_HPP Copyright (c) 2011-2015 Regents of the University of California.
static void registerTpmBackend(const std::string &scheme)
Register a new TPM backend.
Represents an NDN certificate following the version 2.0 format.
The interface of signing key management.
SimpleSymmetricKeyParams is a template for symmetric keys with only one parameter: size...
optional< uint64_t > version
Certificate name version component.
static void registerPibBackend(const std::string &scheme)
Register a new PIB backend.
const Pib & getPib() const noexcept
Error indicating that the supplied TPM locator does not match the locator stored in PIB...
Represents an Interest packet.
Signing parameters passed to KeyChain.
SimpleSymmetricKeyParams< detail::HmacKeyParamsInfo > HmacKeyParams
HmacKeyParams carries parameters for HMAC key.
KeyType
The type of a cryptographic key.
A frontend handle of a key instance.
optional< ValidityPeriod > validity
Certificate ValidityPeriod.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Represents an absolute name.
Error indicating that the supplied SigningInfo is invalid.
SignatureTypeValue
SignatureType values.
Options to KeyChain::makeCertificate() .
const Tpm & getTpm() const noexcept
Represents a name component.
A secured container for sensitive information (certificate, private key)
Base class for key parameters.
A frontend handle of an Identity.
Represents a Data packet.
time::milliseconds freshnessPeriod
Certificate packet FreshnessPeriod.
name::Component issuerId
Certificate name IssuerId component.
const nullopt_t nullopt((nullopt_t::init()))
static const Name & getHmacIdentity()
A localhost identity to indicate that the signature is generated using an HMAC key.
shared_ptr< const Buffer > ConstBufferPtr
boost::chrono::milliseconds milliseconds