NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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
80
void
81
setInfo
(
const
Block
& info);
82
86
void
87
setInfo
(
const
SignatureInfo
& info)
88
{
89
m_info
= info;
90
}
91
95
const
Block
&
96
getValue
()
const
97
{
98
m_value
.
encode
();
// will do nothing if wire already exists
99
return
m_value
;
100
}
101
107
void
108
setValue
(
const
Block
& value);
109
113
uint32_t
114
getType
()
const
115
{
116
return
m_info
.
getSignatureType
();
117
}
118
122
bool
123
hasKeyLocator
()
const
124
{
125
return
m_info
.
hasKeyLocator
();
126
}
127
133
const
KeyLocator
&
134
getKeyLocator
()
const
135
{
136
return
m_info
.
getKeyLocator
();
137
}
138
142
void
143
setKeyLocator
(
const
KeyLocator
& keyLocator)
144
{
145
m_info
.
setKeyLocator
(keyLocator);
146
}
147
154
void
155
unsetKeyLocator
()
156
{
157
m_info
.
unsetKeyLocator
();
158
}
159
160
public
:
// EqualityComparable concept
161
bool
162
operator==
(
const
Signature
& other)
const
163
{
164
return
getInfo
() == other.
getInfo
() &&
165
getValue
() == other.
getValue
();
166
}
167
168
bool
169
operator!=
(
const
Signature
& other)
const
170
{
171
return
!(*
this
== other);
172
}
173
174
protected
:
175
SignatureInfo
m_info
;
176
mutable
Block
m_value
;
177
};
178
179
}
// namespace ndn
180
181
#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:87
ndn::tlv::SignatureSha256WithRsa
Definition:
tlv.hpp:97
ndn::Signature::setKeyLocator
void setKeyLocator(const KeyLocator &keyLocator)
Set KeyLocator.
Definition:
signature.hpp:143
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-2015 Regents of the University of California.
ndn::Signature::hasKeyLocator
bool hasKeyLocator() const
Check if SignatureInfo block has a KeyLocator.
Definition:
signature.hpp:123
ndn::Signature::unsetKeyLocator
void unsetKeyLocator()
Unset KeyLocator.
Definition:
signature.hpp:155
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:141
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:96
ndn::SignatureInfo::unsetKeyLocator
void unsetKeyLocator()
Unset KeyLocator.
Definition:
signature-info.cpp:77
ndn::Signature::operator!=
bool operator!=(const Signature &other) const
Definition:
signature.hpp:169
ndn::tlv::DigestSha256
Definition:
tlv.hpp:96
ndn::Signature::operator==
bool operator==(const Signature &other) const
Definition:
signature.hpp:162
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:114
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:134
ndn::Signature::m_info
SignatureInfo m_info
Definition:
signature.hpp:175
ndn::Signature::m_value
Block m_value
Definition:
signature.hpp:176
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 Sat Nov 12 2016 16:02:53 for ndnSIM by
1.8.12