NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
public-key.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_CXX_SECURITY_TRANSFORM_PUBLIC_KEY_HPP
23 #define NDN_CXX_SECURITY_TRANSFORM_PUBLIC_KEY_HPP
24 
25 #include "../security-common.hpp"
26 #include "../../encoding/buffer.hpp"
27 
28 namespace ndn {
29 namespace security {
30 namespace transform {
31 
32 class VerifierFilter;
33 
37 class PublicKey : noncopyable
38 {
39 public:
40  class Error : public std::runtime_error
41  {
42  public:
43  explicit
44  Error(const std::string& what)
45  : std::runtime_error(what)
46  {
47  }
48  };
49 
50  friend class VerifierFilter;
51 
52 public:
58  PublicKey();
59 
60  ~PublicKey();
61 
65  KeyType
66  getKeyType() const;
67 
71  void
72  loadPkcs8(const uint8_t* buf, size_t size);
73 
77  void
78  loadPkcs8(std::istream& is);
79 
83  void
84  loadPkcs8Base64(const uint8_t* buf, size_t size);
85 
89  void
90  loadPkcs8Base64(std::istream& is);
91 
95  void
96  savePkcs8(std::ostream& os) const;
97 
101  void
102  savePkcs8Base64(std::ostream& os) const;
103 
110  encrypt(const uint8_t* plainText, size_t plainLen) const;
111 
112 private:
118  void*
119  getEvpPkey() const;
120 
121 private:
123  toPkcs8() const;
124 
126  rsaEncrypt(const uint8_t* plainText, size_t plainLen) const;
127 
128 private:
129  class Impl;
130  unique_ptr<Impl> m_impl;
131 };
132 
133 } // namespace transform
134 } // namespace security
135 } // namespace ndn
136 
137 #endif // NDN_CXX_SECURITY_TRANSFORM_PUBLIC_KEY_HPP
KeyType getKeyType() const
Get the type of the public key.
Definition: public-key.cpp:66
Copyright (c) 2011-2015 Regents of the University of California.
The module to verify signature.
STL namespace.
Abstraction of public key in crypto transformation.
Definition: public-key.hpp:37
void loadPkcs8(const uint8_t *buf, size_t size)
Load the public key in PKCS#8 format from a buffer buf.
Definition: public-key.cpp:85
ConstBufferPtr encrypt(const uint8_t *plainText, size_t plainLen) const
Definition: public-key.cpp:140
void loadPkcs8Base64(const uint8_t *buf, size_t size)
Load the public key in base64-encoded PKCS#8 format from a buffer buf.
Definition: public-key.cpp:104
PublicKey()
Create a public key instance.
Definition: public-key.cpp:58
void savePkcs8Base64(std::ostream &os) const
Save the public key in base64-encoded PKCS#8 format into a stream os.
Definition: public-key.cpp:133
void savePkcs8(std::ostream &os) const
Save the public key in PKCS#8 format into a stream os.
Definition: public-key.cpp:126
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:33