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"));
123 m_otherTlvs.push_back(block);
130 for (std::list<Block>::const_iterator i = m_otherTlvs.begin();
131 i != m_otherTlvs.end(); i++) {
132 if (i->type() == type)
136 BOOST_THROW_EXCEPTION(
Error(
"(SignatureInfo::getTypeSpecificTlv) Requested a non-existed type [" +
137 boost::lexical_cast<std::string>(type) +
"] from SignatureInfo"));
140 template<encoding::Tag TAG>
144 size_t totalLength = 0;
146 for (std::list<Block>::const_reverse_iterator i = m_otherTlvs.rbegin();
147 i != m_otherTlvs.rend(); i++) {
148 totalLength += encoder.appendBlock(*i);
152 totalLength += m_keyLocator.
wireEncode(encoder);
156 totalLength += encoder.prependVarNumber(totalLength);
180 m_wire = buffer.block();
188 BOOST_THROW_EXCEPTION(
Error(
"The supplied block does not contain wire format"));
191 m_hasKeyLocator =
false;
197 BOOST_THROW_EXCEPTION(
tlv::Error(
"Unexpected TLV type when decoding Name"));
207 BOOST_THROW_EXCEPTION(
Error(
"SignatureInfo does not have sub-TLV or the first sub-TLV is not " 213 m_hasKeyLocator =
true;
219 m_otherTlvs.push_back(*it);
227 return (m_type == rhs.m_type &&
228 m_hasKeyLocator == rhs.m_hasKeyLocator &&
229 m_keyLocator == rhs.m_keyLocator &&
230 m_otherTlvs == rhs.m_otherTlvs);
element_const_iterator elements_begin() const
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.
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
const Block & getTypeSpecificTlv(uint32_t type) const
Get signature type specific tlv block.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
void wireDecode(const Block &wire)
decode from wire encoding
element_const_iterator elements_end() const
void parse() const
Parse wire buffer into subblocks.
Class representing a wire element of NDN-TLV packet format.
const Block & wireEncode() const
Encode to a wire format.
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.
void setKeyLocator(const KeyLocator &keyLocator)
Set KeyLocator.
a concept check for TLV abstraction with .wireEncode method
Abstraction of validity period.
bool operator==(const SignatureInfo &rhs) const
EncodingImpl< EncoderTag > EncodingBuffer
void unsetKeyLocator()
Unset KeyLocator.
element_container::const_iterator element_const_iterator
void setValidityPeriod(const security::ValidityPeriod &validityPeriod)
Set ValidityPeriod.
void reset()
Reset wire buffer of the element.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
prepend wire encoding
void wireDecode(const Block &wire)
Decode from a wire format.
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
security::ValidityPeriod getValidityPeriod() const
Get ValidityPeriod.