NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: 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-2018 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 "ndn-cxx/key-locator.hpp"
27 
28 #include <list>
29 
30 namespace ndn {
31 
35 {
36 public:
37  class Error : public tlv::Error
38  {
39  public:
40  using tlv::Error::Error;
41  };
42 
45  SignatureInfo();
46 
49  explicit
51 
54  SignatureInfo(tlv::SignatureTypeValue type, const KeyLocator& keyLocator);
55 
59  explicit
60  SignatureInfo(const Block& wire);
61 
65  template<encoding::Tag TAG>
66  size_t
67  wireEncode(EncodingImpl<TAG>& encoder) const;
68 
71  const Block&
72  wireEncode() const;
73 
77  void
78  wireDecode(const Block& wire);
79 
80 public: // field access
84  int32_t
86  {
87  return m_type;
88  }
89 
92  void
94 
97  bool
98  hasKeyLocator() const
99  {
100  return m_hasKeyLocator;
101  }
102 
106  const KeyLocator&
107  getKeyLocator() const;
108 
111  void
112  setKeyLocator(const KeyLocator& keyLocator);
113 
116  void
117  unsetKeyLocator();
118 
123  getValidityPeriod() const;
124 
127  void
128  setValidityPeriod(const security::ValidityPeriod& validityPeriod);
129 
132  void
134 
139  const Block&
140  getTypeSpecificTlv(uint32_t type) const;
141 
144  void
145  appendTypeSpecificTlv(const Block& element);
146 
147 private:
148  int32_t m_type;
149  bool m_hasKeyLocator;
150  KeyLocator m_keyLocator;
151  std::list<Block> m_otherTlvs;
152 
153  mutable Block m_wire;
154 
155  friend bool
156  operator==(const SignatureInfo& lhs, const SignatureInfo& rhs);
157 
158  friend std::ostream&
159  operator<<(std::ostream& os, const SignatureInfo& info);
160 };
161 
163 
164 bool
165 operator==(const SignatureInfo& lhs, const SignatureInfo& rhs);
166 
167 inline bool
168 operator!=(const SignatureInfo& lhs, const SignatureInfo& rhs)
169 {
170  return !(lhs == rhs);
171 }
172 
173 std::ostream&
174 operator<<(std::ostream& os, const SignatureInfo& info);
175 
176 } // namespace ndn
177 
178 #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 KeyLocator & getKeyLocator() const
Get KeyLocator.
Represents a SignatureInfo TLV element.
std::ostream & operator<<(std::ostream &os, const Data &data)
Definition: data.cpp:322
const Block & getTypeSpecificTlv(uint32_t type) const
Get SignatureType-specific sub-element.
Represents a TLV element of NDN packet format.
Definition: block.hpp:42
const Block & wireEncode() const
Encode to wire format.
void appendTypeSpecificTlv(const Block &element)
Append SignatureType-specific sub-element.
bool operator!=(const Data &lhs, const Data &rhs)
Definition: data.hpp:262
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.
bool hasKeyLocator() const
Check if KeyLocator exists.
int32_t getSignatureType() const
Get SignatureType.
void unsetKeyLocator()
Unset KeyLocator.
void setValidityPeriod(const security::ValidityPeriod &validityPeriod)
Set ValidityPeriod.
SignatureTypeValue
SignatureType values.
Definition: tlv.hpp:126
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Exclude)
void wireDecode(const Block &wire)
Decode from wire format.
bool operator==(const Data &lhs, const Data &rhs)
Definition: data.cpp:313
represents an error in TLV encoding or decoding
Definition: tlv.hpp:52
security::ValidityPeriod getValidityPeriod() const
Get ValidityPeriod.