All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
safe-bag.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_SAFE_BAG_HPP
24 #define NDN_SAFE_BAG_HPP
25 
26 #include "security-common.hpp"
27 #include "v2/certificate-v2.hpp"
28 
29 namespace ndn {
30 
35 class SafeBag {
36 public:
44  SafeBag(const Data& certificate, Blob privateKeyBag)
45  {
46  certificate_ = ptr_lib::make_shared<Data>(certificate);
47  privateKeyBag_ = privateKeyBag;
48  }
49 
72  SafeBag
73  (const Name& keyName, Blob privateKeyBag, Blob publicKeyEncoding,
74  const uint8_t* password = 0, size_t passwordLength = 0,
75  DigestAlgorithm digestAlgorithm = DIGEST_ALGORITHM_SHA256,
77  {
78  certificate_ = makeSelfSignedCertificate
79  (keyName, privateKeyBag, publicKeyEncoding, password, passwordLength,
80  digestAlgorithm, wireFormat);
81  privateKeyBag_ = privateKeyBag;
82  }
83 
89  const ptr_lib::shared_ptr<Data>& getCertificate() const { return certificate_; }
90 
97  const Blob& getPrivateKeyBag() const { return privateKeyBag_; }
98 
99 private:
100  static ptr_lib::shared_ptr<CertificateV2>
101  makeSelfSignedCertificate
102  (const Name& keyName, Blob privateKeyBag, Blob publicKeyEncoding,
103  const uint8_t* password, size_t passwordLength,
104  DigestAlgorithm digestAlgorithm, WireFormat& wireFormat);
105 
106  ptr_lib::shared_ptr<Data> certificate_;
107  Blob privateKeyBag_;
108 };
109 
110 }
111 
112 #endif
Definition: data.hpp:37
const Blob & getPrivateKeyBag() const
Get the encoded private key.
Definition: safe-bag.hpp:97
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
A Blob holds a pointer to an immutable byte array implemented as const std::vector<uint8_t>.
Definition: blob.hpp:42
A SafeBag represents a container for sensitive related information such as a certificate and private ...
Definition: safe-bag.hpp:35
const ptr_lib::shared_ptr< Data > & getCertificate() const
Get the certificate data packet.
Definition: safe-bag.hpp:89
static WireFormat * getDefaultWireFormat()
Return the default WireFormat used by default encoding and decoding methods which was set with setDef...
Definition: wire-format.cpp:34
Definition: wire-format.hpp:39
SafeBag(const Data &certificate, Blob privateKeyBag)
Create a SafeBag with the given certificate and private key.
Definition: safe-bag.hpp:44