NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
signature-info.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_SIGNATURE_INFO_HPP
23 #define NDN_SIGNATURE_INFO_HPP
24 
25 #include "key-locator.hpp"
27 #include <list>
28 
29 namespace ndn {
30 
34 {
35 public:
36  class Error : public tlv::Error
37  {
38  public:
39  explicit
40  Error(const std::string& what)
41  : tlv::Error(what)
42  {
43  }
44  };
45 
48  SignatureInfo();
49 
52  explicit
54 
57  SignatureInfo(tlv::SignatureTypeValue type, const KeyLocator& keyLocator);
58 
62  explicit
63  SignatureInfo(const Block& wire);
64 
68  template<encoding::Tag TAG>
69  size_t
70  wireEncode(EncodingImpl<TAG>& encoder) const;
71 
74  const Block&
75  wireEncode() const;
76 
80  void
81  wireDecode(const Block& wire);
82 
83 public: // field access
87  int32_t
89  {
90  return m_type;
91  }
92 
95  void
97 
100  bool
102  {
103  return m_hasKeyLocator;
104  }
105 
109  const KeyLocator&
110  getKeyLocator() const;
111 
114  void
115  setKeyLocator(const KeyLocator& keyLocator);
116 
119  void
120  unsetKeyLocator();
121 
126  getValidityPeriod() const;
127 
130  void
131  setValidityPeriod(const security::ValidityPeriod& validityPeriod);
132 
135  void
137 
142  const Block&
143  getTypeSpecificTlv(uint32_t type) const;
144 
147  void
148  appendTypeSpecificTlv(const Block& element);
149 
150 private:
151  int32_t m_type;
152  bool m_hasKeyLocator;
153  KeyLocator m_keyLocator;
154  std::list<Block> m_otherTlvs;
155 
156  mutable Block m_wire;
157 
158  friend bool
159  operator==(const SignatureInfo& lhs, const SignatureInfo& rhs);
160 
161  friend std::ostream&
162  operator<<(std::ostream& os, const SignatureInfo& info);
163 };
164 
166 
167 bool
168 operator==(const SignatureInfo& lhs, const SignatureInfo& rhs);
169 
170 inline bool
171 operator!=(const SignatureInfo& lhs, const SignatureInfo& rhs)
172 {
173  return !(lhs == rhs);
174 }
175 
176 std::ostream&
177 operator<<(std::ostream& os, const SignatureInfo& info);
178 
179 } // namespace ndn
180 
181 #endif // NDN_SIGNATURE_INFO_HPP
friend std::ostream & operator<<(std::ostream &os, const SignatureInfo &info)
Copyright (c) 2011-2015 Regents of the University of California.
void setSignatureType(tlv::SignatureTypeValue type)
Set SignatureType.
const Block & wireEncode() const
Encode to wire format.
Represents a SignatureInfo TLV element.
const Block & getTypeSpecificTlv(uint32_t type) const
Get SignatureType-specific sub-element.
Represents a TLV element of NDN packet format.
Definition: block.hpp:42
void appendTypeSpecificTlv(const Block &element)
Append SignatureType-specific sub-element.
bool operator!=(const Data &lhs, const Data &rhs)
Definition: data.hpp:259
const KeyLocator & getKeyLocator() const
Get KeyLocator.
void unsetValidityPeriod()
Unset ValidityPeriod.
void setKeyLocator(const KeyLocator &keyLocator)
Set KeyLocator.
SignatureInfo()
Create an invalid SignatureInfo.
friend bool operator==(const SignatureInfo &lhs, const SignatureInfo &rhs)
Abstraction of validity period.
Error(const std::string &what)
security::ValidityPeriod getValidityPeriod() const
Get ValidityPeriod.
void unsetKeyLocator()
Unset KeyLocator.
void setValidityPeriod(const security::ValidityPeriod &validityPeriod)
Set ValidityPeriod.
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Exclude)
void wireDecode(const Block &wire)
Decode from wire format.
SignatureTypeValue
Definition: tlv.hpp:99
bool hasKeyLocator() const
Check if KeyLocator exists.
int32_t getSignatureType() const
Get SignatureType.
represents an error in TLV encoding or decoding
Definition: tlv.hpp:50