NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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; -*- */
22
#ifndef NDN_SIGNATURE_HPP
23
#define NDN_SIGNATURE_HPP
24
25
#include "
common.hpp
"
26
#include "
signature-info.hpp
"
27
28
namespace
ndn
{
29
33
class
Signature
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
47
enum
{
48
Sha256
=
tlv::DigestSha256
,
49
Sha256WithRsa
=
tlv::SignatureSha256WithRsa
,
50
Sha256WithEcdsa
=
tlv::SignatureSha256WithEcdsa
51
};
52
53
Signature
() =
default
;
54
55
explicit
56
Signature
(
const
Block
& info,
const
Block
& value =
Block
());
57
58
explicit
59
Signature
(
const
SignatureInfo
& info,
const
Block
& value =
Block
());
60
61
operator
bool()
const
62
{
63
return
m_info
.
getSignatureType
() != -1;
64
}
65
69
const
Block
&
70
getInfo
()
const
71
{
72
return
m_info
.
wireEncode
();
// will do nothing if wire already exists
73
}
74
78
const
SignatureInfo
&
79
getSignatureInfo
()
const
80
{
81
return
m_info
;
82
}
83
89
void
90
setInfo
(
const
Block
& info);
91
95
void
96
setInfo
(
const
SignatureInfo
& info)
97
{
98
m_info
= info;
99
}
100
104
const
Block
&
105
getValue
()
const
106
{
107
m_value
.
encode
();
// will do nothing if wire already exists
108
return
m_value
;
109
}
110
116
void
117
setValue
(
const
Block
& value);
118
122
uint32_t
123
getType
()
const
124
{
125
return
m_info
.
getSignatureType
();
126
}
127
131
bool
132
hasKeyLocator
()
const
133
{
134
return
m_info
.
hasKeyLocator
();
135
}
136
142
const
KeyLocator
&
143
getKeyLocator
()
const
144
{
145
return
m_info
.
getKeyLocator
();
146
}
147
151
void
152
setKeyLocator
(
const
KeyLocator
& keyLocator)
153
{
154
m_info
.
setKeyLocator
(keyLocator);
155
}
156
163
void
164
unsetKeyLocator
()
165
{
166
m_info
.
unsetKeyLocator
();
167
}
168
169
public
:
// EqualityComparable concept
170
bool
171
operator==
(
const
Signature
& other)
const
172
{
173
return
getInfo
() == other.
getInfo
() &&
174
getValue
() == other.
getValue
();
175
}
176
177
bool
178
operator!=
(
const
Signature
& other)
const
179
{
180
return
!(*
this
== other);
181
}
182
183
protected
:
184
SignatureInfo
m_info
;
185
mutable
Block
m_value
;
186
};
187
188
}
// namespace ndn
189
190
#endif // NDN_SIGNATURE_HPP
ndn::Signature::Sha256
Definition:
signature.hpp:48
ndn::Signature::Sha256WithEcdsa
Definition:
signature.hpp:50
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::SignatureInfo::getKeyLocator
const KeyLocator & getKeyLocator() const
Get KeyLocator.
Definition:
signature-info.cpp:85
ndn::Signature::Signature
Signature()=default
ndn::SignatureInfo
Definition:
signature-info.hpp:32
ndn::Signature::setInfo
void setInfo(const SignatureInfo &info)
Set SignatureInfo.
Definition:
signature.hpp:96
ndn::tlv::SignatureSha256WithRsa
Definition:
tlv.hpp:97
ndn::Signature::setKeyLocator
void setKeyLocator(const KeyLocator &keyLocator)
Set KeyLocator.
Definition:
signature.hpp:152
ndn::Signature::setInfo
void setInfo(const Block &info)
Set SignatureInfo from a block.
Definition:
signature.cpp:44
ndn::Block
Class representing a wire element of NDN-TLV packet format.
Definition:
block.hpp:43
common.hpp
Copyright (c) 2013-2016 Regents of the University of California.
ndn::Signature::hasKeyLocator
bool hasKeyLocator() const
Check if SignatureInfo block has a KeyLocator.
Definition:
signature.hpp:132
ndn::Signature::unsetKeyLocator
void unsetKeyLocator()
Unset KeyLocator.
Definition:
signature.hpp:164
ndn::Signature::Error::Error
Error(const std::string &what)
Definition:
signature.hpp:40
ndn::SignatureInfo::setKeyLocator
void setKeyLocator(const KeyLocator &keyLocator)
Set KeyLocator.
Definition:
signature-info.cpp:69
ndn::SignatureInfo::wireEncode
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Encode to a wire format or estimate wire format.
Definition:
signature-info.cpp:142
ndn::SignatureInfo::hasKeyLocator
bool hasKeyLocator() const
Check if KeyLocator is set.
Definition:
signature-info.hpp:73
ndn::Signature::setValue
void setValue(const Block &value)
Get SignatureValue from a block.
Definition:
signature.cpp:50
ndn::Signature::Sha256WithRsa
Definition:
signature.hpp:49
ndn::Signature::getInfo
const Block & getInfo() const
Get SignatureInfo in the wire format.
Definition:
signature.hpp:70
ndn::SignatureInfo::getSignatureType
int32_t getSignatureType() const
Get SignatureType.
Definition:
signature-info.hpp:66
signature-info.hpp
ndn::Signature::getValue
const Block & getValue() const
Get SignatureValue in the wire format.
Definition:
signature.hpp:105
ndn::SignatureInfo::unsetKeyLocator
void unsetKeyLocator()
Unset KeyLocator.
Definition:
signature-info.cpp:77
ndn::Signature::operator!=
bool operator!=(const Signature &other) const
Definition:
signature.hpp:178
ndn::tlv::DigestSha256
Definition:
tlv.hpp:96
ndn::Signature::operator==
bool operator==(const Signature &other) const
Definition:
signature.hpp:171
ndn::KeyLocator
Definition:
key-locator.hpp:30
ndn::Block::encode
void encode()
Encode subblocks into wire buffer.
Definition:
block.cpp:355
ndn::Signature::getType
uint32_t getType() const
Get signature type.
Definition:
signature.hpp:123
ndn::Signature::Error
Definition:
signature.hpp:36
ndn::tlv::SignatureSha256WithEcdsa
Definition:
tlv.hpp:99
ndn::Signature::getKeyLocator
const KeyLocator & getKeyLocator() const
Get KeyLocator.
Definition:
signature.hpp:143
ndn::Signature::m_info
SignatureInfo m_info
Definition:
signature.hpp:184
ndn::Signature::getSignatureInfo
const SignatureInfo & getSignatureInfo() const
Get SignatureInfo.
Definition:
signature.hpp:79
ndn::Signature::m_value
Block m_value
Definition:
signature.hpp:185
ndn::tlv::Error
represents an error in TLV encoding or decoding
Definition:
tlv.hpp:50
ndn::Signature
A Signature is storage for the signature-related information (info and value) in a Data packet...
Definition:
signature.hpp:33
ndnSIM
ndn-cxx
src
signature.hpp
Generated on Wed Jan 11 2017 18:17:14 for ndnSIM by
1.8.13