v1/key-chain.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2017 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  *
21  * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
22  */
23 
24 #ifndef NDN_SECURITY_V1_KEY_CHAIN_HPP
25 #define NDN_SECURITY_V1_KEY_CHAIN_HPP
26 
27 #include "sec-public-info.hpp"
28 #include "sec-tpm.hpp"
29 #include "secured-bag.hpp"
30 #include "../key-params.hpp"
31 #include "../signature-sha256-with-rsa.hpp"
32 #include "../signature-sha256-with-ecdsa.hpp"
33 #include "../digest-sha256.hpp"
34 #include "../signing-info.hpp"
35 #include "../../interest.hpp"
36 #include "../../util/random.hpp"
37 #include <initializer_list>
38 
39 namespace ndn {
40 namespace security {
41 namespace v1 {
42 
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  generateEcKeyPair(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  generateEcKeyPairAsDefault(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 
875  // RsaKeyParams is set to be default for backward compatibility.
877 
878  typedef std::map<std::string, Block> SignParams;
879 
880 private:
881  std::unique_ptr<SecPublicInfo> m_pib;
882  std::unique_ptr<SecTpm> m_tpm;
883  time::milliseconds m_lastTimestamp;
884 };
885 
886 template<typename T>
887 void
888 KeyChain::signImpl(T& packet, const SigningInfo& params)
889 {
890  Name keyName;
891  SignatureInfo sigInfo;
892  std::tie(keyName, sigInfo) = prepareSignatureInfo(params);
893 
894  signPacketWrapper(packet, Signature(sigInfo),
895  keyName, params.getDigestAlgorithm());
896 }
897 
898 template<typename T>
899 void
900 KeyChain::sign(T& packet, const Name& certificateName)
901 {
902  signImpl(packet, SigningInfo(SigningInfo::SIGNER_TYPE_CERT, certificateName));
903 }
904 
905 template<typename T>
906 void
907 KeyChain::signByIdentity(T& packet, const Name& identityName)
908 {
909  signImpl(packet, SigningInfo(SigningInfo::SIGNER_TYPE_ID, identityName));
910 }
911 
912 template<class PibType>
913 inline void
914 KeyChain::registerPib(std::initializer_list<std::string> aliases)
915 {
916  registerPibImpl(*aliases.begin(), aliases, [] (const std::string& locator) {
917  return make_unique<PibType>(locator);
918  });
919 }
920 
921 template<class TpmType>
922 inline void
923 KeyChain::registerTpm(std::initializer_list<std::string> aliases)
924 {
925  registerTpmImpl(*aliases.begin(), aliases, [] (const std::string& locator) {
926  return make_unique<TpmType>(locator);
927  });
928 }
929 
936 #define NDN_CXX_V1_KEYCHAIN_REGISTER_PIB(PibType, ...) \
937 static class NdnCxxAuto ## PibType ## PibRegistrationClass \
938 { \
939 public: \
940  NdnCxxAuto ## PibType ## PibRegistrationClass() \
941  { \
942  ::ndn::security::v1::KeyChain::registerPib<PibType>({__VA_ARGS__}); \
943  } \
944 } ndnCxxAuto ## PibType ## PibRegistrationVariable
945 
952 #define NDN_CXX_V1_KEYCHAIN_REGISTER_TPM(TpmType, ...) \
953 static class NdnCxxAuto ## TpmType ## TpmRegistrationClass \
954 { \
955 public: \
956  NdnCxxAuto ## TpmType ## TpmRegistrationClass() \
957  { \
958  ::ndn::security::v1::KeyChain::registerTpm<TpmType>({__VA_ARGS__}); \
959  } \
960 } ndnCxxAuto ## TpmType ## TpmRegistrationVariable
961 
962 } // namespace v1
963 } // namespace security
964 } // namespace ndn
965 
966 #endif // NDN_SECURITY_V1_KEY_CHAIN_HPP
void setInTerminal(bool inTerminal)
void deleteIdentity(const Name &identity)
delete an identity.
Copyright (c) 2013-2017 Regents of the University of California.
Definition: common.hpp:75
static unique_ptr< SecTpm > createTpm(const std::string &tpmLocator)
Create a TPM according to tpmLocator.
Represents a SignatureInfo TLV element.
static void registerTpm(std::initializer_list< std::string > aliases)
Register a new TPM.
void addKey(const Name &keyName, const PublicKey &publicKeyDer)
Block signInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, DigestAlgorithm digestAlgorithm)
void getAllCertificateNames(std::vector< Name > &nameList, bool isDefault) const
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...
static tlv::SignatureTypeValue getSignatureType(KeyType keyType, DigestAlgorithm digestAlgorithm)
bool doesCertificateExist(const Name &certificateName) const
void setDefaultKeyNameForIdentity(const Name &keyName)
static const Name DEFAULT_PREFIX
const SecTpm & getTpm() const
Name generateEcKeyPair(const Name &identityName, bool isKsk=false, uint32_t keySize=256)
Generate a pair of EC keys for the specified identity.
STL namespace.
ConstBufferPtr encryptInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, bool isSymmetric)
Represents a TLV element of NDN packet format.
Definition: block.hpp:42
void addCertificateAsKeyDefault(const IdentityCertificate &certificate)
void sign(Data &data, const SigningInfo &params=DEFAULT_SIGNING_INFO)
Sign data according to the supplied signing information.
represents an Interest packet
Definition: interest.hpp:42
shared_ptr< PublicKey > getPublicKey(const Name &keyName) const
Name getDefaultCertificateNameForKey(const Name &keyName) const
void getAllCertificateNamesOfKey(const Name &keyName, std::vector< Name > &nameList, bool isDefault) const
bool generateRandomBlock(uint8_t *res, size_t size) const
void signByIdentity(T &packet, const Name &identityName)
Sign packet using the default certificate of a particular identity.
Signing parameters passed to KeyChain.
void addCertificateAsIdentityDefault(const IdentityCertificate &certificate)
ConstBufferPtr exportPrivateKeyPkcs5FromTpm(const Name &keyName, const std::string &password)
Name getNewKeyName(const Name &identityName, bool useKsk)
const KeyParams & getDefaultKeyParamsForIdentity(const Name &identityName) const
Get default key parameters for the specified identity.
Name getDefaultCertificateName() const
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...
void addAppToAcl(const Name &keyName, KeyClass keyClass, const std::string &appPath, AclType acl)
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
void signWithSha256(Data &data)
Set Sha256 weak signature for data.
shared_ptr< SecuredBag > exportIdentity(const Name &identity, const std::string &passwordStr)
export an identity.
bool doesKeyExistInTpm(const Name &keyName, KeyClass keyClass) const
void deleteIdentityInfo(const Name &identity)
void deleteKeyPairInTpm(const Name &keyName)
void setDefaultCertificateNameForKey(const Name &certificateName)
void importIdentity(const SecuredBag &securedBag, const std::string &passwordStr)
import an identity.
Name generateRsaKeyPair(const Name &identityName, bool isKsk=false, uint32_t keySize=2048)
Generate a pair of RSA keys for the specified identity.
void addPublicKey(const Name &keyName, KeyType keyType, const PublicKey &publicKeyDer)
void addCertificate(const IdentityCertificate &certificate)
SecPublicInfo is a base class for the storage of public information.
shared_ptr< PublicKey > getPublicKeyFromTpm(const Name &keyName) const
void setDefaultIdentity(const Name &identityName)
void setTpmPassword(const uint8_t *password, size_t passwordLength)
std::map< std::string, Block > SignParams
Represents an absolute name.
Definition: name.hpp:42
bool doesPublicKeyExist(const Name &keyName) const
signer is a certificate, use it directly
bool unlockTpm(const char *password, size_t passwordLength, bool usePassword)
static const RsaKeyParams DEFAULT_KEY_PARAMS
void deleteCertificateInfo(const Name &certificateName)
time_point TimePoint
Definition: time.hpp:90
static std::string getDefaultPibLocator()
Get default PIB locator.
Name generateEcKeyPairAsDefault(const Name &identityName, bool isKsk=false, uint32_t keySize=256)
Generate a pair of EC keys for the specified identity and set it as default key for the identity...
void deleteCertificate(const Name &certificateName)
delete a certificate.
KeyChain()
Constructor to create KeyChain with default PIB and TPM.
void getAllIdentities(std::vector< Name > &nameList, bool isDefault) const
SecTpm is the base class of the TPM classes.
Definition: v1/sec-tpm.hpp:43
Name getDefaultCertificateNameForIdentity(const Name &identityName) const
The packet signing interface.
Error thrown when the supplied TPM locator to KeyChain constructor does not match the locator stored ...
Name getDefaultKeyNameForIdentity(const Name &identityName) const
ConstBufferPtr decryptInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, bool isSymmetric)
const SecPublicInfo & getPib() const
void addCertificateAsSystemDefault(const IdentityCertificate &certificate)
shared_ptr< IdentityCertificate > getCertificate(const Name &certificateName) const
Base class of key parameters.
Definition: key-params.hpp:36
signer is an identity, use its default key and default certificate
Error(const std::string &what)
void getAllKeyNamesOfIdentity(const Name &identity, std::vector< Name > &nameList, bool isDefault) const
static const SigningInfo DEFAULT_SIGNING_INFO
bool doesIdentityExist(const Name &identityName) const
shared_ptr< IdentityCertificate > selfSign(const Name &keyName)
Generate a self-signed certificate for a public key.
void generateKeyPairInTpm(const Name &keyName, const KeyParams &params)
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:33
void deleteKey(const Name &keyName)
delete a key.
void getAllKeyNames(std::vector< Name > &nameList, bool isDefault) const
void deletePublicKeyInfo(const Name &keyName)
Represents a Data packet.
Definition: data.hpp:35
SimplePublicKeyParams is a template for public keys with only one parameter: size.
Definition: key-params.hpp:150
DigestAlgorithm getDigestAlgorithm() const
bool importPrivateKeyPkcs5IntoTpm(const Name &keyName, const uint8_t *buf, size_t size, const std::string &password)
function< unique_ptr< SecTpm >const std::string &)> TpmCreateFunc
function< unique_ptr< SecPublicInfo >const std::string &)> PibCreateFunc
shared_ptr< IdentityCertificate > getDefaultCertificate() const
void generateSymmetricKeyInTpm(const Name &keyName, const KeyParams &params)
static unique_ptr< SecPublicInfo > createPib(const std::string &pibLocator)
Create a PIB according to pibLocator.
static std::string getDefaultTpmLocator()
Get default TPM locator.
static void registerPib(std::initializer_list< std::string > aliases)
Register a new PIB.
Holds SignatureInfo and SignatureValue in a Data packet.
Definition: signature.hpp:37
void addIdentity(const Name &identityName)