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; -*- */
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 
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 
35 class PublicKey : noncopyable
36 {
37 public:
38  class Error : public std::runtime_error
39  {
40  public:
41  explicit
42  Error(const std::string& what)
43  : std::runtime_error(what)
44  {
45  }
46  };
47 
48 public:
54  PublicKey();
55 
56  ~PublicKey();
57 
61  KeyType
62  getKeyType() const;
63 
67  void
68  loadPkcs8(const uint8_t* buf, size_t size);
69 
73  void
74  loadPkcs8(std::istream& is);
75 
79  void
80  loadPkcs8Base64(const uint8_t* buf, size_t size);
81 
85  void
86  loadPkcs8Base64(std::istream& is);
87 
91  void
92  savePkcs8(std::ostream& os) const;
93 
97  void
98  savePkcs8Base64(std::ostream& os) const;
99 
106  encrypt(const uint8_t* plainText, size_t plainLen) const;
107 
108 private:
109  friend class VerifierFilter;
110 
116  void*
117  getEvpPkey() const;
118 
119 private:
121  toPkcs8() const;
122 
124  rsaEncrypt(const uint8_t* plainText, size_t plainLen) const;
125 
126 private:
127  class Impl;
128  const unique_ptr<Impl> m_impl;
129 };
130 
131 } // namespace transform
132 } // namespace security
133 } // namespace ndn
134 
135 #endif // NDN_CXX_SECURITY_TRANSFORM_PUBLIC_KEY_HPP
Copyright (c) 2011-2015 Regents of the University of California.
The module to verify signatures.
ConstBufferPtr encrypt(const uint8_t *plainText, size_t plainLen) const
Definition: public-key.cpp:133
STL namespace.
Abstraction of public key in crypto transformation.
Definition: public-key.hpp:35
Catch-all error for security policy errors that don&#39;t fit in other categories.
Definition: base.hpp:79
KeyType
The type of a cryptographic key.
void savePkcs8(std::ostream &os) const
Save the public key in PKCS#8 format into a stream os.
Definition: public-key.cpp:121
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:88
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:105
PublicKey()
Create an empty public key instance.
Definition: public-key.cpp:64
void savePkcs8Base64(std::ostream &os) const
Save the public key in base64-encoded PKCS#8 format into a stream os.
Definition: public-key.cpp:127
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:89
KeyType getKeyType() const
Get the type of the public key.
Definition: public-key.cpp:72