28 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<SignatureInfo>));
32 static_assert(std::is_base_of<tlv::Error, SignatureInfo::Error>::value,
33 "SignatureInfo::Error must inherit from tlv::Error");
37 , m_hasKeyLocator(false)
43 , m_hasKeyLocator(false)
49 , m_hasKeyLocator(true)
50 , m_keyLocator(keyLocator)
59 template<encoding::Tag TAG>
64 BOOST_THROW_EXCEPTION(
Error(
"Cannot encode invalid SignatureInfo"));
73 size_t totalLength = 0;
75 for (
auto i = m_otherTlvs.rbegin(); i != m_otherTlvs.rend(); i++) {
76 totalLength += encoder.prependBlock(*i);
80 totalLength += m_keyLocator.
wireEncode(encoder);
83 static_cast<uint64_t>(m_type));
84 totalLength += encoder.prependVarNumber(totalLength);
104 m_wire = buffer.block();
112 m_hasKeyLocator =
false;
119 BOOST_THROW_EXCEPTION(
Error(
"Decoding SignatureInfo, but TLV-TYPE is " +
to_string(m_wire.
type())));
125 BOOST_THROW_EXCEPTION(
Error(
"Missing SignatureType in SignatureInfo"));
127 m_type = readNonNegativeIntegerAs<tlv::SignatureTypeValue>(*it);
133 m_hasKeyLocator =
true;
139 m_otherTlvs.push_back(*it);
157 BOOST_THROW_EXCEPTION(
Error(
"KeyLocator does not exist in SignatureInfo"));
164 m_keyLocator = keyLocator;
165 m_hasKeyLocator =
true;
173 m_hasKeyLocator =
false;
180 BOOST_THROW_EXCEPTION(
Error(
"ValidityPeriod does not exist in SignatureInfo"));
190 m_otherTlvs.push_front(validityPeriod.
wireEncode());
197 m_otherTlvs.pop_front();
205 for (
const Block& block : m_otherTlvs) {
206 if (block.type() == type)
210 BOOST_THROW_EXCEPTION(
Error(
"TLV-TYPE " +
to_string(type) +
" sub-element does not exist in SignatureInfo"));
217 m_otherTlvs.push_back(block);
223 return lhs.m_type == rhs.m_type &&
224 lhs.m_hasKeyLocator == rhs.m_hasKeyLocator &&
225 lhs.m_keyLocator == rhs.m_keyLocator &&
226 lhs.m_otherTlvs == rhs.m_otherTlvs;
233 return os <<
"Invalid SignatureInfo";
239 if (!info.m_otherTlvs.empty()) {
241 for (
const auto& block : info.m_otherTlvs) {
242 os << block.type() <<
" ";
bool hasWire() const
Check if the Block has fully encoded wire.
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.
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Prepend a TLV element containing a non-negative integer.
std::ostream & operator<<(std::ostream &os, const Data &data)
const Block & getTypeSpecificTlv(uint32_t type) const
Get SignatureType-specific sub-element.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
void wireDecode(const Block &wire)
decode from wire encoding
void parse() const
Parse TLV-VALUE into sub elements.
Represents a TLV element of NDN packet format.
const Block & wireEncode() const
Encode to wire format.
void appendTypeSpecificTlv(const Block &element)
Append SignatureType-specific sub-element.
element_const_iterator elements_begin() const
Equivalent to elements().begin()
void unsetValidityPeriod()
Unset ValidityPeriod.
void setKeyLocator(const KeyLocator &keyLocator)
Set KeyLocator.
SignatureInfo()
Create an invalid SignatureInfo.
a concept check for TLV abstraction with .wireEncode method
element_const_iterator elements_end() const
Equivalent to elements().end()
Abstraction of validity period.
bool hasKeyLocator() const
Check if KeyLocator exists.
int32_t getSignatureType() const
Get SignatureType.
void unsetKeyLocator()
Unset KeyLocator.
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Exclude)
void setValidityPeriod(const security::ValidityPeriod &validityPeriod)
Set ValidityPeriod.
void reset()
Reset wire buffer of the element.
SignatureTypeValue
SignatureType values.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
prepend wire encoding
void wireDecode(const Block &wire)
Decode from wire format.
bool operator==(const Data &lhs, const Data &rhs)
std::string to_string(const V &v)
a concept check for TLV abstraction with .wireEncode method
a concept check for TLV abstraction with .wireDecode method and constructible from Block
EncodingImpl< EncoderTag > EncodingBuffer
uint32_t type() const
Get TLV-TYPE.
EncodingImpl< EstimatorTag > EncodingEstimator
security::ValidityPeriod getValidityPeriod() const
Get ValidityPeriod.