NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
key-chain.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
24 #ifndef NDN_SECURITY_KEY_CHAIN_HPP
25 #define NDN_SECURITY_KEY_CHAIN_HPP
26 
27 #include "sec-public-info.hpp"
28 #include "sec-tpm.hpp"
29 #include "key-params.hpp"
30 #include "secured-bag.hpp"
33 #include "digest-sha256.hpp"
34 #include "signing-info.hpp"
35 
36 #include "../interest.hpp"
37 #include "../util/crypto.hpp"
38 #include "../util/random.hpp"
39 #include <initializer_list>
40 
41 
42 namespace ndn {
43 namespace security {
44 
48 class KeyChain : noncopyable
49 {
50 public:
51  class Error : public std::runtime_error
52  {
53  public:
54  explicit
55  Error(const std::string& what)
56  : std::runtime_error(what)
57  {
58  }
59  };
60 
65  class MismatchError : public Error
66  {
67  public:
68  explicit
69  MismatchError(const std::string& what)
70  : Error(what)
71  {
72  }
73  };
74 
75  typedef function<unique_ptr<SecPublicInfo> (const std::string&)> PibCreateFunc;
76  typedef function<unique_ptr<SecTpm>(const std::string&)> TpmCreateFunc;
77 
83  template<class PibType>
84  static void
85  registerPib(std::initializer_list<std::string> aliases);
86 
92  template<class TpmType>
93  static void
94  registerTpm(std::initializer_list<std::string> aliases);
95 
99  static std::string
101 
105  static unique_ptr<SecPublicInfo>
106  createPib(const std::string& pibLocator);
107 
111  static std::string
113 
117  static unique_ptr<SecTpm>
118  createTpm(const std::string& tpmLocator);
119 
128  KeyChain();
129 
140  KeyChain(const std::string& pibLocator,
141  const std::string& tpmLocator,
142  bool allowReset = false);
143 
144  virtual
145  ~KeyChain();
146 
155  Name
156  createIdentity(const Name& identityName, const KeyParams& params = DEFAULT_KEY_PARAMS);
157 
167  Name
168  generateRsaKeyPair(const Name& identityName, bool isKsk = false, uint32_t keySize = 2048);
169 
179  Name
180  generateEcdsaKeyPair(const Name& identityName, bool isKsk = false, uint32_t keySize = 256);
181 
192  Name
193  generateRsaKeyPairAsDefault(const Name& identityName, bool isKsk = false, uint32_t keySize = 2048);
194 
205  Name
206  generateEcdsaKeyPairAsDefault(const Name& identityName, bool isKsk = false, uint32_t keySize = 256);
207 
223  shared_ptr<IdentityCertificate>
225  const Name& signingIdentity,
226  const time::system_clock::TimePoint& notBefore,
227  const time::system_clock::TimePoint& notAfter,
228  const std::vector<CertificateSubjectDescription>& subjectDescription,
229  const Name& certPrefix = DEFAULT_PREFIX);
230 
247  shared_ptr<IdentityCertificate>
249  const PublicKey& publicKey,
250  const Name& signingIdentity,
251  const time::system_clock::TimePoint& notBefore,
252  const time::system_clock::TimePoint& notAfter,
253  const std::vector<CertificateSubjectDescription>& subjectDescription,
254  const Name& certPrefix = DEFAULT_PREFIX);
255 
272  void
273  sign(Data& data, const SigningInfo& params = DEFAULT_SIGNING_INFO);
274 
291  void
292  sign(Interest& interest, const SigningInfo& params = DEFAULT_SIGNING_INFO);
293 
304  Block
305  sign(const uint8_t* buffer, size_t bufferLength, const SigningInfo& params);
306 
315  template<typename T>
316  void
317  sign(T& packet, const Name& certificateName);
318 
329  Signature
330  sign(const uint8_t* buffer, size_t bufferLength, const Name& certificateName);
331 
342  template<typename T>
343  void
344  signByIdentity(T& packet, const Name& identityName);
345 
355  Signature
356  signByIdentity(const uint8_t* buffer, size_t bufferLength, const Name& identityName);
357 
362  void
363  signWithSha256(Data& data);
364 
369  void
370  signWithSha256(Interest& interest);
371 
378  shared_ptr<IdentityCertificate>
379  selfSign(const Name& keyName);
380 
387  void
389 
396  void
397  deleteCertificate(const Name& certificateName);
398 
405  void
406  deleteKey(const Name& keyName);
407 
414  void
415  deleteIdentity(const Name& identity);
416 
425  shared_ptr<SecuredBag>
426  exportIdentity(const Name& identity, const std::string& passwordStr);
427 
434  void
435  importIdentity(const SecuredBag& securedBag, const std::string& passwordStr);
436 
439  {
440  return *m_pib;
441  }
442 
443  const SecPublicInfo&
444  getPib() const
445  {
446  return *m_pib;
447  }
448 
449  SecTpm&
451  {
452  return *m_tpm;
453  }
454 
455  const SecTpm&
456  getTpm() const
457  {
458  return *m_tpm;
459  }
460 
461  /*******************************
462  * Wrapper of SecPublicInfo *
463  *******************************/
464  bool
465  doesIdentityExist(const Name& identityName) const
466  {
467  return m_pib->doesIdentityExist(identityName);
468  }
469 
470  void
471  addIdentity(const Name& identityName)
472  {
473  return m_pib->addIdentity(identityName);
474  }
475 
476  bool
477  doesPublicKeyExist(const Name& keyName) const
478  {
479  return m_pib->doesPublicKeyExist(keyName);
480  }
481 
482  void
483  addPublicKey(const Name& keyName, KeyType keyType, const PublicKey& publicKeyDer)
484  {
485  return m_pib->addKey(keyName, publicKeyDer);
486  }
487 
488  void
489  addKey(const Name& keyName, const PublicKey& publicKeyDer)
490  {
491  return m_pib->addKey(keyName, publicKeyDer);
492  }
493 
494  shared_ptr<PublicKey>
495  getPublicKey(const Name& keyName) const
496  {
497  return m_pib->getPublicKey(keyName);
498  }
499 
500  bool
501  doesCertificateExist(const Name& certificateName) const
502  {
503  return m_pib->doesCertificateExist(certificateName);
504  }
505 
506  void
508  {
509  return m_pib->addCertificate(certificate);
510  }
511 
512  shared_ptr<IdentityCertificate>
513  getCertificate(const Name& certificateName) const
514  {
515  return m_pib->getCertificate(certificateName);
516  }
517 
518  Name
520  {
521  return m_pib->getDefaultIdentity();
522  }
523 
524  Name
525  getDefaultKeyNameForIdentity(const Name& identityName) const
526  {
527  return m_pib->getDefaultKeyNameForIdentity(identityName);
528  }
529 
537  const KeyParams&
538  getDefaultKeyParamsForIdentity(const Name& identityName) const;
539 
540  Name
541  getDefaultCertificateNameForKey(const Name& keyName) const
542  {
543  return m_pib->getDefaultCertificateNameForKey(keyName);
544  }
545 
546  void
547  getAllIdentities(std::vector<Name>& nameList, bool isDefault) const
548  {
549  return m_pib->getAllIdentities(nameList, isDefault);
550  }
551 
552  void
553  getAllKeyNames(std::vector<Name>& nameList, bool isDefault) const
554  {
555  return m_pib->getAllKeyNames(nameList, isDefault);
556  }
557 
558  void
559  getAllKeyNamesOfIdentity(const Name& identity, std::vector<Name>& nameList, bool isDefault) const
560  {
561  return m_pib->getAllKeyNamesOfIdentity(identity, nameList, isDefault);
562  }
563 
564  void
565  getAllCertificateNames(std::vector<Name>& nameList, bool isDefault) const
566  {
567  return m_pib->getAllCertificateNames(nameList, isDefault);
568  }
569 
570  void
572  std::vector<Name>& nameList,
573  bool isDefault) const
574  {
575  return m_pib->getAllCertificateNamesOfKey(keyName, nameList, isDefault);
576  }
577 
578  void
579  deleteCertificateInfo(const Name& certificateName)
580  {
581  return m_pib->deleteCertificateInfo(certificateName);
582  }
583 
584  void
585  deletePublicKeyInfo(const Name& keyName)
586  {
587  return m_pib->deletePublicKeyInfo(keyName);
588  }
589 
590  void
591  deleteIdentityInfo(const Name& identity)
592  {
593  return m_pib->deleteIdentityInfo(identity);
594  }
595 
596  void
597  setDefaultIdentity(const Name& identityName)
598  {
599  return m_pib->setDefaultIdentity(identityName);
600  }
601 
602  void
604  {
605  return m_pib->setDefaultKeyNameForIdentity(keyName);
606  }
607 
608  void
609  setDefaultCertificateNameForKey(const Name& certificateName)
610  {
611  return m_pib->setDefaultCertificateNameForKey(certificateName);
612  }
613 
614  Name
615  getNewKeyName(const Name& identityName, bool useKsk)
616  {
617  return m_pib->getNewKeyName(identityName, useKsk);
618  }
619 
620  Name
621  getDefaultCertificateNameForIdentity(const Name& identityName) const
622  {
623  return m_pib->getDefaultCertificateNameForIdentity(identityName);
624  }
625 
626  Name
628  {
629  return m_pib->getDefaultCertificateName();
630  }
631 
632  void
634  {
635  return m_pib->addCertificateAsKeyDefault(certificate);
636  }
637 
638  void
640  {
641  return m_pib->addCertificateAsIdentityDefault(certificate);
642  }
643 
644  void
646  {
647  return m_pib->addCertificateAsSystemDefault(certificate);
648  }
649 
650  shared_ptr<IdentityCertificate>
652  {
653  if (!static_cast<bool>(m_pib->getDefaultCertificate()))
654  const_cast<KeyChain*>(this)->setDefaultCertificateInternal();
655 
656  return m_pib->getDefaultCertificate();
657  }
658 
659  void
661  {
662  return m_pib->refreshDefaultCertificate();
663  }
664 
665  /*******************************
666  * Wrapper of SecTpm *
667  *******************************/
668 
669  void
670  setTpmPassword(const uint8_t* password, size_t passwordLength)
671  {
672  return m_tpm->setTpmPassword(password, passwordLength);
673  }
674 
675  void
677  {
678  return m_tpm->resetTpmPassword();
679  }
680 
681  void
682  setInTerminal(bool inTerminal)
683  {
684  return m_tpm->setInTerminal(inTerminal);
685  }
686 
687  bool
689  {
690  return m_tpm->getInTerminal();
691  }
692 
693  bool
694  isLocked() const
695  {
696  return m_tpm->isLocked();
697  }
698 
699  bool
700  unlockTpm(const char* password, size_t passwordLength, bool usePassword)
701  {
702  return m_tpm->unlockTpm(password, passwordLength, usePassword);
703  }
704 
705  void
706  generateKeyPairInTpm(const Name& keyName, const KeyParams& params)
707  {
708  return m_tpm->generateKeyPairInTpm(keyName, params);
709  }
710 
711  void
712  deleteKeyPairInTpm(const Name& keyName)
713  {
714  return m_tpm->deleteKeyPairInTpm(keyName);
715  }
716 
717  shared_ptr<PublicKey>
718  getPublicKeyFromTpm(const Name& keyName) const
719  {
720  return m_tpm->getPublicKeyFromTpm(keyName);
721  }
722 
723  Block
724  signInTpm(const uint8_t* data, size_t dataLength,
725  const Name& keyName,
726  DigestAlgorithm digestAlgorithm)
727  {
728  return m_tpm->signInTpm(data, dataLength, keyName, digestAlgorithm);
729  }
730 
732  decryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric)
733  {
734  return m_tpm->decryptInTpm(data, dataLength, keyName, isSymmetric);
735  }
736 
738  encryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric)
739  {
740  return m_tpm->encryptInTpm(data, dataLength, keyName, isSymmetric);
741  }
742 
743  void
744  generateSymmetricKeyInTpm(const Name& keyName, const KeyParams& params)
745  {
746  return m_tpm->generateSymmetricKeyInTpm(keyName, params);
747  }
748 
749  bool
750  doesKeyExistInTpm(const Name& keyName, KeyClass keyClass) const
751  {
752  return m_tpm->doesKeyExistInTpm(keyName, keyClass);
753  }
754 
755  bool
756  generateRandomBlock(uint8_t* res, size_t size) const
757  {
758  return m_tpm->generateRandomBlock(res, size);
759  }
760 
761  void
762  addAppToAcl(const Name& keyName, KeyClass keyClass, const std::string& appPath, AclType acl)
763  {
764  return m_tpm->addAppToAcl(keyName, keyClass, appPath, acl);
765  }
766 
768  exportPrivateKeyPkcs5FromTpm(const Name& keyName, const std::string& password)
769  {
770  return m_tpm->exportPrivateKeyPkcs5FromTpm(keyName, password);
771  }
772 
773  bool
775  const uint8_t* buf, size_t size,
776  const std::string& password)
777  {
778  return m_tpm->importPrivateKeyPkcs5IntoTpm(keyName, buf, size, password);
779  }
780 
781 private:
782  void
783  initialize(const std::string& pibLocatorUri,
784  const std::string& tpmLocatorUri,
785  bool needReset);
786 
794  std::tuple<Name, SignatureInfo>
795  prepareSignatureInfo(const SigningInfo& params);
796 
804  template<typename T>
805  void
806  signImpl(T& packet, const SigningInfo& params);
807 
811  void
812  setDefaultCertificateInternal();
813 
822  Name
823  generateKeyPair(const Name& identityName, bool isKsk = false,
824  const KeyParams& params = DEFAULT_KEY_PARAMS);
825 
835  void
836  signPacketWrapper(Data& data, const Signature& signature,
837  const Name& keyName, DigestAlgorithm digestAlgorithm);
838 
848  void
849  signPacketWrapper(Interest& interest, const Signature& signature,
850  const Name& keyName, DigestAlgorithm digestAlgorithm);
851 
856  Block
857  pureSign(const uint8_t* buf, size_t size, const Name& keyName, DigestAlgorithm digestAlgorithm) const;
858 
859  static void
860  registerPibImpl(const std::string& canonicalName,
861  std::initializer_list<std::string> aliases, PibCreateFunc createFunc);
862 
863  static void
864  registerTpmImpl(const std::string& canonicalName,
865  std::initializer_list<std::string> aliases, TpmCreateFunc createFunc);
866 
867 public:
869  getSignatureType(KeyType keyType, DigestAlgorithm digestAlgorithm);
870 
871 public:
872  static const Name DEFAULT_PREFIX;
874 
880 
881  // RsaKeyParams is set to be default for backward compatibility.
883 
884  typedef std::map<std::string, Block> SignParams;
885 
886 private:
887  std::unique_ptr<SecPublicInfo> m_pib;
888  std::unique_ptr<SecTpm> m_tpm;
889  time::milliseconds m_lastTimestamp;
890 };
891 
892 template<typename T>
893 void
894 KeyChain::signImpl(T& packet, const SigningInfo& params)
895 {
896  Name keyName;
897  SignatureInfo sigInfo;
898  std::tie(keyName, sigInfo) = prepareSignatureInfo(params);
899 
900  signPacketWrapper(packet, Signature(sigInfo),
901  keyName, params.getDigestAlgorithm());
902 }
903 
904 template<typename T>
905 void
906 KeyChain::sign(T& packet, const Name& certificateName)
907 {
908  signImpl(packet, SigningInfo(SigningInfo::SIGNER_TYPE_CERT, certificateName));
909 }
910 
911 template<typename T>
912 void
913 KeyChain::signByIdentity(T& packet, const Name& identityName)
914 {
915  signImpl(packet, SigningInfo(SigningInfo::SIGNER_TYPE_ID, identityName));
916 }
917 
918 template<class PibType>
919 inline void
920 KeyChain::registerPib(std::initializer_list<std::string> aliases)
921 {
922  registerPibImpl(*aliases.begin(), aliases, [] (const std::string& locator) {
923  return make_unique<PibType>(locator);
924  });
925 }
926 
927 template<class TpmType>
928 inline void
929 KeyChain::registerTpm(std::initializer_list<std::string> aliases)
930 {
931  registerTpmImpl(*aliases.begin(), aliases, [] (const std::string& locator) {
932  return make_unique<TpmType>(locator);
933  });
934 }
935 
942 #define NDN_CXX_KEYCHAIN_REGISTER_PIB(PibType, ...) \
943 static class NdnCxxAuto ## PibType ## PibRegistrationClass \
944 { \
945 public: \
946  NdnCxxAuto ## PibType ## PibRegistrationClass() \
947  { \
948  ::ndn::KeyChain::registerPib<PibType>({__VA_ARGS__}); \
949  } \
950 } ndnCxxAuto ## PibType ## PibRegistrationVariable
951 
958 #define NDN_CXX_KEYCHAIN_REGISTER_TPM(TpmType, ...) \
959 static class NdnCxxAuto ## TpmType ## TpmRegistrationClass \
960 { \
961 public: \
962  NdnCxxAuto ## TpmType ## TpmRegistrationClass() \
963  { \
964  ::ndn::KeyChain::registerTpm<TpmType>({__VA_ARGS__}); \
965  } \
966 } ndnCxxAuto ## TpmType ## TpmRegistrationVariable
967 
968 } // namespace security
969 
970 using security::KeyChain;
971 
972 } // namespace ndn
973 
974 #endif // NDN_SECURITY_KEY_CHAIN_HPP
static const RsaKeyParams DEFAULT_KEY_PARAMS
Definition: key-chain.hpp:882
const SecPublicInfo & getPib() const
Definition: key-chain.hpp:444
Name getNewKeyName(const Name &identityName, bool useKsk)
Definition: key-chain.hpp:615
bool unlockTpm(const char *password, size_t passwordLength, bool usePassword)
Definition: key-chain.hpp:700
const SecTpm & getTpm() const
Definition: key-chain.hpp:456
shared_ptr< IdentityCertificate > prepareUnsignedIdentityCertificate(const Name &keyName, const Name &signingIdentity, const time::system_clock::TimePoint &notBefore, const time::system_clock::TimePoint &notAfter, const std::vector< CertificateSubjectDescription > &subjectDescription, const Name &certPrefix=DEFAULT_PREFIX)
prepare an unsigned identity certificate
Definition: key-chain.cpp:348
MismatchError(const std::string &what)
Definition: key-chain.hpp:69
Copyright (c) 2011-2015 Regents of the University of California.
function< unique_ptr< SecPublicInfo >const std::string &)> PibCreateFunc
Definition: key-chain.hpp:75
bool doesCertificateExist(const Name &certificateName) const
Definition: key-chain.hpp:501
Name getDefaultCertificateName() const
Definition: key-chain.hpp:627
bool doesIdentityExist(const Name &identityName) const
Definition: key-chain.hpp:465
void getAllIdentities(std::vector< Name > &nameList, bool isDefault) const
Definition: key-chain.hpp:547
void addIdentity(const Name &identityName)
Definition: key-chain.hpp:471
void importIdentity(const SecuredBag &securedBag, const std::string &passwordStr)
import an identity.
Definition: key-chain.cpp:615
void setDefaultIdentity(const Name &identityName)
Definition: key-chain.hpp:597
static unique_ptr< SecPublicInfo > createPib(const std::string &pibLocator)
Create a PIB according to pibLocator.
Definition: key-chain.cpp:189
Name getDefaultCertificateNameForIdentity(const Name &identityName) const
Definition: key-chain.hpp:621
DigestAlgorithm getDigestAlgorithm() const
void addCertificateAsKeyDefault(const IdentityCertificate &certificate)
Definition: key-chain.hpp:633
shared_ptr< PublicKey > getPublicKey(const Name &keyName) const
Definition: key-chain.hpp:495
The packet signing interface.
Definition: key-chain.hpp:48
void signByIdentity(T &packet, const Name &identityName)
Sign packet using the default certificate of a particular identity.
Definition: key-chain.hpp:913
void generateSymmetricKeyInTpm(const Name &keyName, const KeyParams &params)
Definition: key-chain.hpp:744
bool doesKeyExistInTpm(const Name &keyName, KeyClass keyClass) const
Definition: key-chain.hpp:750
STL namespace.
ConstBufferPtr encryptInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, bool isSymmetric)
Definition: key-chain.hpp:738
Error thrown when the supplied TPM locator to KeyChain constructor does not match the locator stored ...
Definition: key-chain.hpp:65
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
represents an Interest packet
Definition: interest.hpp:45
void deleteKeyPairInTpm(const Name &keyName)
Definition: key-chain.hpp:712
void sign(Data &data, const SigningInfo &params=DEFAULT_SIGNING_INFO)
Sign data according to the supplied signing information.
Definition: key-chain.cpp:501
void setTpmPassword(const uint8_t *password, size_t passwordLength)
Definition: key-chain.hpp:670
Signing parameters passed to KeyChain.
shared_ptr< SecuredBag > exportIdentity(const Name &identity, const std::string &passwordStr)
export an identity.
Definition: key-chain.cpp:586
void getAllCertificateNames(std::vector< Name > &nameList, bool isDefault) const
Definition: key-chain.hpp:565
void addCertificateAsSystemDefault(const IdentityCertificate &certificate)
Definition: key-chain.hpp:645
static void registerPib(std::initializer_list< std::string > aliases)
Register a new PIB.
Definition: key-chain.hpp:920
Name generateEcdsaKeyPairAsDefault(const Name &identityName, bool isKsk=false, uint32_t keySize=256)
Generate a pair of ECDSA keys for the specified identity and set it as default key for the identity...
Definition: key-chain.cpp:335
bool doesPublicKeyExist(const Name &keyName) const
Definition: key-chain.hpp:477
static const SigningInfo DEFAULT_SIGNING_INFO
Definition: key-chain.hpp:873
void generateKeyPairInTpm(const Name &keyName, const KeyParams &params)
Definition: key-chain.hpp:706
Name getDefaultCertificateNameForKey(const Name &keyName) const
Definition: key-chain.hpp:541
Name createIdentity(const Name &identityName, const KeyParams &params=DEFAULT_KEY_PARAMS)
Create an identity by creating a pair of Key-Signing-Key (KSK) for this identity and a self-signed ce...
Definition: key-chain.cpp:275
SecTpm is the base class of the TPM classes.
Definition: sec-tpm.hpp:41
SecPublicInfo & getPib()
Definition: key-chain.hpp:438
function< unique_ptr< SecTpm >const std::string &)> TpmCreateFunc
Definition: key-chain.hpp:76
static std::string getDefaultTpmLocator()
Get default TPM locator.
Definition: key-chain.cpp:201
void addAppToAcl(const Name &keyName, KeyClass keyClass, const std::string &appPath, AclType acl)
Definition: key-chain.hpp:762
bool generateRandomBlock(uint8_t *res, size_t size) const
Definition: key-chain.hpp:756
void setInTerminal(bool inTerminal)
Definition: key-chain.hpp:682
void getAllCertificateNamesOfKey(const Name &keyName, std::vector< Name > &nameList, bool isDefault) const
Definition: key-chain.hpp:571
std::map< std::string, Block > SignParams
Definition: key-chain.hpp:884
void deletePublicKeyInfo(const Name &keyName)
Definition: key-chain.hpp:585
Block signInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, DigestAlgorithm digestAlgorithm)
Definition: key-chain.hpp:724
Name abstraction to represent an absolute name.
Definition: name.hpp:46
signer is a certificate, use it directly
Name getDefaultKeyNameForIdentity(const Name &identityName) const
Definition: key-chain.hpp:525
void deleteIdentity(const Name &identity)
delete an identity.
Definition: key-chain.cpp:802
void deleteIdentityInfo(const Name &identity)
Definition: key-chain.hpp:591
time_point TimePoint
Definition: time.hpp:78
Name generateRsaKeyPair(const Name &identityName, bool isKsk=false, uint32_t keySize=2048)
Generate a pair of RSA keys for the specified identity.
Definition: key-chain.cpp:309
static tlv::SignatureTypeValue getSignatureType(KeyType keyType, DigestAlgorithm digestAlgorithm)
Definition: key-chain.cpp:815
KeyChain()
Constructor to create KeyChain with default PIB and TPM.
Definition: key-chain.cpp:121
static unique_ptr< SecTpm > createTpm(const std::string &tpmLocator)
Create a TPM according to tpmLocator.
Definition: key-chain.cpp:226
static std::string getDefaultPibLocator()
Get default PIB locator.
Definition: key-chain.cpp:163
SignatureTypeValue
Definition: tlv.hpp:95
shared_ptr< IdentityCertificate > selfSign(const Name &keyName)
Generate a self-signed certificate for a public key.
Definition: key-chain.cpp:541
void addCertificate(const IdentityCertificate &certificate)
Definition: key-chain.hpp:507
Base class of key parameters.
Definition: key-params.hpp:35
shared_ptr< IdentityCertificate > getDefaultCertificate() const
Definition: key-chain.hpp:651
signer is an identity, use its default key and default certificate
void getAllKeyNamesOfIdentity(const Name &identity, std::vector< Name > &nameList, bool isDefault) const
Definition: key-chain.hpp:559
shared_ptr< PublicKey > getPublicKeyFromTpm(const Name &keyName) const
Definition: key-chain.hpp:718
Name generateEcdsaKeyPair(const Name &identityName, bool isKsk=false, uint32_t keySize=256)
Generate a pair of ECDSA keys for the specified identity.
Definition: key-chain.cpp:316
void getAllKeyNames(std::vector< Name > &nameList, bool isDefault) const
Definition: key-chain.hpp:553
ConstBufferPtr decryptInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, bool isSymmetric)
Definition: key-chain.hpp:732
void setDefaultKeyNameForIdentity(const Name &keyName)
Definition: key-chain.hpp:603
static const Name DEFAULT_PREFIX
Definition: key-chain.hpp:872
Name getDefaultIdentity() const
Definition: key-chain.hpp:519
shared_ptr< IdentityCertificate > getCertificate(const Name &certificateName) const
Definition: key-chain.hpp:513
void addPublicKey(const Name &keyName, KeyType keyType, const PublicKey &publicKeyDer)
Definition: key-chain.hpp:483
bool getInTerminal() const
Definition: key-chain.hpp:688
void signWithSha256(Data &data)
Set Sha256 weak signature for data.
Definition: key-chain.cpp:759
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:33
void setDefaultCertificateNameForKey(const Name &certificateName)
Definition: key-chain.hpp:609
const KeyParams & getDefaultKeyParamsForIdentity(const Name &identityName) const
Get default key parameters for the specified identity.
Definition: key-chain.cpp:640
represents a Data packet
Definition: data.hpp:39
SimplePublicKeyParams is a template for public keys with only one parameter: size.
Definition: key-params.hpp:110
Name generateRsaKeyPairAsDefault(const Name &identityName, bool isKsk=false, uint32_t keySize=2048)
Generate a pair of RSA keys for the specified identity and set it as default key for the identity...
Definition: key-chain.cpp:323
static const Name DIGEST_SHA256_IDENTITY
A localhost identity which indicates that signature is generated using SHA-256.
Definition: key-chain.hpp:879
void deleteCertificateInfo(const Name &certificateName)
Definition: key-chain.hpp:579
void deleteKey(const Name &keyName)
delete a key.
Definition: key-chain.cpp:795
static void registerTpm(std::initializer_list< std::string > aliases)
Register a new TPM.
Definition: key-chain.hpp:929
void addCertificateAsIdentityDefault(const IdentityCertificate &certificate)
Definition: key-chain.hpp:639
ConstBufferPtr exportPrivateKeyPkcs5FromTpm(const Name &keyName, const std::string &password)
Definition: key-chain.hpp:768
SecPublicInfo is a base class for the storage of public information.
void addKey(const Name &keyName, const PublicKey &publicKeyDer)
Definition: key-chain.hpp:489
void deleteCertificate(const Name &certificateName)
delete a certificate.
Definition: key-chain.cpp:789
bool importPrivateKeyPkcs5IntoTpm(const Name &keyName, const uint8_t *buf, size_t size, const std::string &password)
Definition: key-chain.hpp:774
Error(const std::string &what)
Definition: key-chain.hpp:55
A Signature is storage for the signature-related information (info and value) in a Data packet...
Definition: signature.hpp:33