26 #include <boost/lexical_cast.hpp> 30 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<SignatureInfo>));
34 static_assert(std::is_base_of<tlv::Error, SignatureInfo::Error>::value,
35 "SignatureInfo::Error must inherit from tlv::Error");
39 , m_hasKeyLocator(false)
45 , m_hasKeyLocator(false)
51 , m_hasKeyLocator(true)
52 , m_keyLocator(keyLocator)
72 m_keyLocator = keyLocator;
73 m_hasKeyLocator =
true;
81 m_hasKeyLocator =
false;
90 BOOST_THROW_EXCEPTION(
Error(
"KeyLocator does not exist"));
97 m_otherTlvs.push_front(validityPeriod.
wireEncode());
105 m_otherTlvs.erase(m_otherTlvs.begin());
113 BOOST_THROW_EXCEPTION(
Error(
"SignatureInfo does not contain the requested ValidityPeriod field"));
122 m_otherTlvs.push_back(block);
129 for (std::list<Block>::const_iterator i = m_otherTlvs.begin();
130 i != m_otherTlvs.end(); i++) {
131 if (i->type() == type)
135 BOOST_THROW_EXCEPTION(
Error(
"(SignatureInfo::getTypeSpecificTlv) Requested a non-existed type [" +
136 boost::lexical_cast<std::string>(type) +
"] from SignatureInfo"));
139 template<encoding::Tag TAG>
143 size_t totalLength = 0;
145 for (std::list<Block>::const_reverse_iterator i = m_otherTlvs.rbegin();
146 i != m_otherTlvs.rend(); i++) {
147 totalLength += encoder.appendBlock(*i);
151 totalLength += m_keyLocator.
wireEncode(encoder);
155 totalLength += encoder.prependVarNumber(totalLength);
161 SignatureInfo::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder)
const;
164 SignatureInfo::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder)
const;
179 m_wire = buffer.block();
187 BOOST_THROW_EXCEPTION(
Error(
"The supplied block does not contain wire format"));
190 m_hasKeyLocator =
false;
196 BOOST_THROW_EXCEPTION(
tlv::Error(
"Unexpected TLV type when decoding Name"));
206 BOOST_THROW_EXCEPTION(
Error(
"SignatureInfo does not have sub-TLV or the first sub-TLV is not " 212 m_hasKeyLocator =
true;
226 return (m_type == rhs.m_type &&
227 m_hasKeyLocator == rhs.m_hasKeyLocator &&
228 m_keyLocator == rhs.m_keyLocator &&
229 m_otherTlvs == rhs.m_otherTlvs);
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
prepend wire encoding
Copyright (c) 2011-2015 Regents of the University of California.
void setSignatureType(tlv::SignatureTypeValue type)
Set SignatureType.
const Block & wireEncode() const
Encode to a wire format.
const Block & getTypeSpecificTlv(uint32_t type) const
Get signature type specific tlv block.
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Helper to prepend TLV block type type containing non-negative integer value.
EncodingImpl< EstimatorTag > EncodingEstimator
void wireDecode(const Block &wire)
decode from wire encoding
Class representing a wire element of NDN-TLV packet format.
const KeyLocator & getKeyLocator() const
Get KeyLocator.
uint64_t readNonNegativeInteger(const Block &block)
Helper to read a non-negative integer from a block.
void unsetValidityPeriod()
Unset ValidityPeriod.
void appendTypeSpecificTlv(const Block &block)
Append signature type specific tlv block.
element_const_iterator elements_end() const
void setKeyLocator(const KeyLocator &keyLocator)
Set KeyLocator.
element_const_iterator elements_begin() const
a concept check for TLV abstraction with .wireEncode method
Abstraction of validity period.
EncodingImpl< EncoderTag > EncodingBuffer
security::ValidityPeriod getValidityPeriod() const
Get ValidityPeriod.
void unsetKeyLocator()
Unset KeyLocator.
element_container::const_iterator element_const_iterator
void setValidityPeriod(const security::ValidityPeriod &validityPeriod)
Set ValidityPeriod.
bool operator==(const SignatureInfo &rhs) const
void reset()
Reset wire buffer of the element.
void parse() const
Parse wire buffer into subblocks.
void wireDecode(const Block &wire)
Decode from a wire format.
bool hasWire() const
Check if the Block has fully encoded wire.
a concept check for TLV abstraction with .wireEncode method
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
represents an error in TLV encoding or decoding