NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
signature.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2019 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_HPP
23 #define NDN_SIGNATURE_HPP
24 
26 
27 namespace ndn {
28 
37 class Signature
38 {
39 public:
40  class Error : public tlv::Error
41  {
42  public:
43  using tlv::Error::Error;
44  };
45 
46  Signature() = default;
47 
48  explicit
49  Signature(const Block& info, const Block& value = Block());
50 
51  explicit
52  Signature(const SignatureInfo& info, const Block& value = Block());
53 
56  explicit
57  operator bool() const
58  {
59  return m_info.getSignatureType() != -1;
60  }
61 
64  const SignatureInfo&
66  {
67  return m_info;
68  }
69 
72  const Block&
73  getInfo() const
74  {
75  return m_info.wireEncode();
76  }
77 
81  void
82  setInfo(const Block& info);
83 
86  void
87  setInfo(const SignatureInfo& info)
88  {
89  m_info = info;
90  }
91 
94  const Block&
95  getValue() const
96  {
97  return m_value;
98  }
99 
103  void
104  setValue(const Block& value);
105 
106 public: // SignatureInfo fields
111  getType() const;
112 
115  bool
117  {
118  return m_info.hasKeyLocator();
119  }
120 
124  const KeyLocator&
126  {
127  return m_info.getKeyLocator();
128  }
129 
132  void
133  setKeyLocator(const KeyLocator& keyLocator)
134  {
135  m_info.setKeyLocator(keyLocator);
136  }
137 
143  void
145  {
147  }
148 
149 protected:
151  mutable Block m_value;
152 };
153 
154 } // namespace ndn
155 
156 #endif // NDN_SIGNATURE_HPP
ndn::Signature::getInfo
const Block & getInfo() const
Get SignatureInfo as wire format.
Definition: signature.hpp:73
ndn::Signature::getValue
const Block & getValue() const
Get SignatureValue.
Definition: signature.hpp:95
signature-info.hpp
ndn::Signature::Error
Definition: signature.hpp:41
ndn::Signature::setValue
void setValue(const Block &value)
Set SignatureValue.
Definition: signature.cpp:58
ndn::Signature::m_info
SignatureInfo m_info
Definition: signature.hpp:150
ndn::Signature::m_value
Block m_value
Definition: signature.hpp:151
ndn::Signature::getKeyLocator
const KeyLocator & getKeyLocator() const
Get KeyLocator.
Definition: signature.hpp:125
ndn::Signature::getSignatureInfo
const SignatureInfo & getSignatureInfo() const
Get SignatureInfo.
Definition: signature.hpp:65
ndn::SignatureInfo::getKeyLocator
const KeyLocator & getKeyLocator() const
Get KeyLocator.
Definition: signature-info.cpp:152
ndn::Signature::setInfo
void setInfo(const Block &info)
Decode SignatureInfo from wire format.
Definition: signature.cpp:52
ndn::SignatureInfo::unsetKeyLocator
void unsetKeyLocator()
Unset KeyLocator.
Definition: signature-info.cpp:169
ndn::SignatureInfo
Represents a SignatureInfo TLV element.
Definition: signature-info.hpp:35
ndn::Signature
Holds SignatureInfo and SignatureValue in a Data packet.
Definition: signature.hpp:38
ndn::SignatureInfo::getSignatureType
int32_t getSignatureType() const
Get SignatureType.
Definition: signature-info.hpp:85
ndn::Signature::Signature
Signature()=default
ndn::tlv::SignatureTypeValue
SignatureTypeValue
SignatureType values.
Definition: tlv.hpp:129
ndn::Signature::hasKeyLocator
bool hasKeyLocator() const
Check if KeyLocator exists in SignatureInfo.
Definition: signature.hpp:116
ndn::Block
Represents a TLV element of NDN packet format.
Definition: block.hpp:43
ndn::Signature::setInfo
void setInfo(const SignatureInfo &info)
Set SignatureInfo.
Definition: signature.hpp:87
ndn::Signature::getType
tlv::SignatureTypeValue getType() const
Get SignatureType.
Definition: signature.cpp:43
ndn::Signature::setKeyLocator
void setKeyLocator(const KeyLocator &keyLocator)
Set KeyLocator.
Definition: signature.hpp:133
ndn::SignatureInfo::wireEncode
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
Definition: signature-info.cpp:61
ndn::tlv::Error
represents an error in TLV encoding or decoding
Definition: tlv.hpp:53
ndn::KeyLocator
Definition: key-locator.hpp:30
ndn::Signature::unsetKeyLocator
void unsetKeyLocator()
Unset KeyLocator.
Definition: signature.hpp:144
ndn::tlv::Error::Error
Error(const char *expectedType, uint32_t actualType)
Definition: tlv.cpp:27
ndn::SignatureInfo::hasKeyLocator
bool hasKeyLocator() const
Check if KeyLocator exists.
Definition: signature-info.hpp:98
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34
ndn::SignatureInfo::setKeyLocator
void setKeyLocator(const KeyLocator &keyLocator)
Set KeyLocator.
Definition: signature-info.cpp:161