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; -*- */
26 #ifndef NDN_SECURITY_V1_PUBLIC_KEY_HPP
27 #define NDN_SECURITY_V1_PUBLIC_KEY_HPP
28 
29 #include "../../common.hpp"
30 
31 #include "../../encoding/buffer.hpp"
32 #include "../../encoding/block.hpp"
33 #include "../security-common.hpp"
34 
35 namespace CryptoPP {
36 class BufferedTransformation;
37 } // namespace CryptoPP
38 
39 namespace ndn {
40 namespace security {
41 namespace v1 {
42 
43 class PublicKey
44 {
45 public:
46  class Error : public std::runtime_error
47  {
48  public:
49  explicit
50  Error(const std::string& what)
51  : std::runtime_error(what)
52  {
53  }
54  };
55 
59  PublicKey();
60 
69  PublicKey(const uint8_t* keyDerBuf, size_t keyDerSize);
70 
71  const Buffer&
72  get() const
73  {
74  return m_key;
75  }
76 
77  void
78  set(const uint8_t* keyDerBuf, size_t keyDerSize)
79  {
80  Buffer buf(keyDerBuf, keyDerSize);
81  m_key.swap(buf);
82  }
83 
84  KeyType
85  getKeyType() const
86  {
87  return m_type;
88  }
89 
93  const Block&
94  computeDigest() const;
95 
96  void
97  encode(CryptoPP::BufferedTransformation& out) const;
98 
99  void
100  decode(CryptoPP::BufferedTransformation& in);
101 
102  bool
103  operator==(const PublicKey& key) const
104  {
105  return m_key == key.m_key;
106  }
107 
108  bool
109  operator!=(const PublicKey& key) const
110  {
111  return m_key != key.m_key;
112  }
113 
114 private:
115  KeyType m_type;
116  Buffer m_key;
117  mutable Block m_digest;
118 };
119 
120 std::ostream&
121 operator<<(std::ostream& os, const PublicKey& key);
122 
123 } // namespace v1
124 } // namespace security
125 
126 #ifdef NDN_CXX_KEEP_SECURITY_V1_ALIASES
129 #endif // NDN_CXX_KEEP_SECURITY_V1_ALIASES
130 
131 } // namespace ndn
132 
133 #endif // NDN_SECURITY_V1_PUBLIC_KEY_HPP
Copyright (c) 2011-2015 Regents of the University of California.
bool operator==(const PublicKey &key) const
Definition: public-key.hpp:103
std::ostream & operator<<(std::ostream &os, const ContentStore &cs)
Copyright (c) 2013-2016 Regents of the University of California.
Definition: oid.hpp:29
STL namespace.
bool operator!=(const PublicKey &key) const
Definition: public-key.hpp:109
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
Error(const std::string &what)
Definition: public-key.hpp:50
KeyType getKeyType() const
Definition: public-key.hpp:85
Class representing a general-use automatically managed/resized buffer.
Definition: buffer.hpp:44