All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
public-key.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
9 #ifndef NDN_SECURITY_PUBLIC_KEY_HPP
10 #define NDN_SECURITY_PUBLIC_KEY_HPP
11 
12 #include "../common.hpp"
13 #include "../encoding/oid.hpp"
14 #include "../encoding/buffer.hpp"
15 #include "security-common.hpp"
16 
17 namespace ndn {
18 
19 class PublicKey
20 {
21 public:
22  class Error : public std::runtime_error
23  {
24  public:
25  explicit
26  Error(const std::string& what)
27  : std::runtime_error(what)
28  {
29  }
30  };
31 
35  PublicKey();
36 
44  PublicKey(const uint8_t* keyDerBuf, size_t keyDerSize);
45 
46  inline const Buffer&
47  get() const
48  {
49  return m_key;
50  }
51 
52  inline void
53  set(const uint8_t* keyDerBuf, size_t keyDerSize)
54  {
55  Buffer buf(keyDerBuf, keyDerSize);
56  m_key.swap(buf);
57  }
58 
59  void
60  encode(CryptoPP::BufferedTransformation& out) const;
61 
62  void
63  decode(CryptoPP::BufferedTransformation& in);
64 
65  inline bool
66  operator==(const PublicKey& key) const
67  {
68  return m_key == key.m_key;
69  }
70 
71  inline bool
72  operator!=(const PublicKey& key) const
73  {
74  return m_key != key.m_key;
75  }
76 
77 private:
78  Buffer m_key;
79 };
80 
81 std::ostream&
82 operator<<(std::ostream& os, const PublicKey& key);
83 
84 } // namespace ndn
85 
86 #endif //NDN_SECURITY_PUBLIC_KEY_HPP
void encode(CryptoPP::BufferedTransformation &out) const
Definition: public-key.cpp:36
void set(const uint8_t *keyDerBuf, size_t keyDerSize)
Definition: public-key.hpp:53
PublicKey()
The default constructor.
Definition: public-key.cpp:20
Error(const std::string &what)
Definition: public-key.hpp:26
void decode(CryptoPP::BufferedTransformation &in)
Definition: public-key.cpp:46
bool operator!=(const PublicKey &key) const
Definition: public-key.hpp:72
bool operator==(const PublicKey &key) const
Definition: public-key.hpp:66
std::ostream & operator<<(std::ostream &os, const Data &data)
Definition: data.hpp:523
Class representing a general-use automatically managed/resized buffer.
Definition: buffer.hpp:28