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 "key-locator.hpp"
27 #include <list>
28 
29 namespace ndn {
30 
34 {
35 public:
36  class Error : public tlv::Error
37  {
38  public:
39  using tlv::Error::Error;
40  };
41 
44  SignatureInfo();
45 
48  explicit
50 
53  SignatureInfo(tlv::SignatureTypeValue type, const KeyLocator& keyLocator);
54 
58  explicit
59  SignatureInfo(const Block& wire);
60 
64  template<encoding::Tag TAG>
65  size_t
66  wireEncode(EncodingImpl<TAG>& encoder) const;
67 
70  const Block&
71  wireEncode() const;
72 
76  void
77  wireDecode(const Block& wire);
78 
79 public: // field access
83  int32_t
85  {
86  return m_type;
87  }
88 
91  void
93 
96  bool
97  hasKeyLocator() const
98  {
99  return m_hasKeyLocator;
100  }
101 
105  const KeyLocator&
106  getKeyLocator() const;
107 
110  void
111  setKeyLocator(const KeyLocator& keyLocator);
112 
115  void
116  unsetKeyLocator();
117 
122  getValidityPeriod() const;
123 
126  void
127  setValidityPeriod(const security::ValidityPeriod& validityPeriod);
128 
131  void
133 
138  const Block&
139  getTypeSpecificTlv(uint32_t type) const;
140 
143  void
144  appendTypeSpecificTlv(const Block& element);
145 
146 private:
147  int32_t m_type;
148  bool m_hasKeyLocator;
149  KeyLocator m_keyLocator;
150  std::list<Block> m_otherTlvs;
151 
152  mutable Block m_wire;
153 
154  friend bool
155  operator==(const SignatureInfo& lhs, const SignatureInfo& rhs);
156 
157  friend std::ostream&
158  operator<<(std::ostream& os, const SignatureInfo& info);
159 };
160 
162 
163 bool
164 operator==(const SignatureInfo& lhs, const SignatureInfo& rhs);
165 
166 inline bool
167 operator!=(const SignatureInfo& lhs, const SignatureInfo& rhs)
168 {
169  return !(lhs == rhs);
170 }
171 
172 std::ostream&
173 operator<<(std::ostream& os, const SignatureInfo& info);
174 
175 } // namespace ndn
176 
177 #endif // NDN_SIGNATURE_INFO_HPP
friend std::ostream & operator<<(std::ostream &os, const SignatureInfo &info)
Copyright (c) 2013-2017 Regents of the University of California.
Definition: common.hpp:65
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:276
const KeyLocator & getKeyLocator() const
Get KeyLocator.
#define NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
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.
security::ValidityPeriod getValidityPeriod() const
Get ValidityPeriod.
void unsetKeyLocator()
Unset KeyLocator.
void setValidityPeriod(const security::ValidityPeriod &validityPeriod)
Set ValidityPeriod.
SignatureTypeValue
SignatureType values.
void wireDecode(const Block &wire)
Decode from wire format.
bool hasKeyLocator() const
Check if KeyLocator exists.
int32_t getSignatureType() const
Get SignatureType.
represents an error in TLV encoding or decoding