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.prependBlock(*i);
152 totalLength += m_keyLocator.
wireEncode(encoder);
156 totalLength += encoder.prependVarNumber(totalLength);
162 SignatureInfo::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder)
const;
165 SignatureInfo::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder)
const;
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);
240 if (!info.m_otherTlvs.empty()) {
242 for (
const auto& block : info.m_otherTlvs) {
243 os << block.type() <<
" ";
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) 2013-2016 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
std::ostream & operator<<(std::ostream &os, const Data &data)
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 hasKeyLocator() const
Check if KeyLocator is set.
bool hasWire() const
Check if the Block has fully encoded wire.
int32_t getSignatureType() const
Get SignatureType.
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