NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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_PUBLIC_KEY_HPP
27 #define NDN_SECURITY_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 }
38 
39 namespace ndn {
40 
41 class PublicKey
42 {
43 public:
44  class Error : public std::runtime_error
45  {
46  public:
47  explicit
48  Error(const std::string& what)
49  : std::runtime_error(what)
50  {
51  }
52  };
53 
57  PublicKey();
58 
67  PublicKey(const uint8_t* keyDerBuf, size_t keyDerSize);
68 
69  const Buffer&
70  get() const
71  {
72  return m_key;
73  }
74 
75  void
76  set(const uint8_t* keyDerBuf, size_t keyDerSize)
77  {
78  Buffer buf(keyDerBuf, keyDerSize);
79  m_key.swap(buf);
80  }
81 
82  KeyType
83  getKeyType() const
84  {
85  return m_type;
86  }
87 
91  const Block&
92  computeDigest() const;
93 
94  void
95  encode(CryptoPP::BufferedTransformation& out) const;
96 
97  void
98  decode(CryptoPP::BufferedTransformation& in);
99 
100  bool
101  operator==(const PublicKey& key) const
102  {
103  return m_key == key.m_key;
104  }
105 
106  bool
107  operator!=(const PublicKey& key) const
108  {
109  return m_key != key.m_key;
110  }
111 
112 private:
113  KeyType m_type;
114  Buffer m_key;
115  mutable Block m_digest;
116 };
117 
118 std::ostream&
119 operator<<(std::ostream& os, const PublicKey& key);
120 
121 } // namespace ndn
122 
123 #endif //NDN_SECURITY_PUBLIC_KEY_HPP
Copyright (c) 2011-2015 Regents of the University of California.
std::ostream & operator<<(std::ostream &os, const ContentStore &cs)
Copyright (c) 2013-2014 Regents of the University of California.
Definition: oid.hpp:29
STL namespace.
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
Error(const std::string &what)
Definition: public-key.hpp:48
KeyType getKeyType() const
Definition: public-key.hpp:83
bool operator!=(const PublicKey &key) const
Definition: public-key.hpp:107
bool operator==(const PublicKey &key) const
Definition: public-key.hpp:101
Class representing a general-use automatically managed/resized buffer.
Definition: buffer.hpp:44