28 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<SignatureInfo>));
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);
84 totalLength += encoder.prependVarNumber(totalLength);
103 m_wire = buffer.block();
110 m_hasKeyLocator =
false;
117 BOOST_THROW_EXCEPTION(
Error(
"Decoding SignatureInfo, but TLV-TYPE is " +
to_string(m_wire.
type())));
123 m_type = readNonNegativeIntegerAs<int32_t>(*it);
127 BOOST_THROW_EXCEPTION(
Error(
"Missing SignatureType in SignatureInfo"));
132 m_hasKeyLocator =
true;
138 m_otherTlvs.push_back(*it);
156 BOOST_THROW_EXCEPTION(
Error(
"KeyLocator does not exist in SignatureInfo"));
163 m_keyLocator = keyLocator;
164 m_hasKeyLocator =
true;
172 m_hasKeyLocator =
false;
179 BOOST_THROW_EXCEPTION(
Error(
"ValidityPeriod does not exist in SignatureInfo"));
189 m_otherTlvs.push_front(validityPeriod.
wireEncode());
196 m_otherTlvs.pop_front();
204 for (
const Block& block : m_otherTlvs) {
205 if (block.type() == type)
209 BOOST_THROW_EXCEPTION(
Error(
"TLV-TYPE " +
to_string(type) +
" sub-element does not exist in SignatureInfo"));
216 m_otherTlvs.push_back(block);
222 return lhs.m_type == rhs.m_type &&
223 lhs.m_hasKeyLocator == rhs.m_hasKeyLocator &&
224 lhs.m_keyLocator == rhs.m_keyLocator &&
225 lhs.m_otherTlvs == rhs.m_otherTlvs;
235 if (!info.m_otherTlvs.empty()) {
237 for (
const auto& block : info.m_otherTlvs) {
238 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
friend std::ostream & operator<<(std::ostream &os, const SignatureInfo &info)
Copyright (c) 2011-2015 Regents of the University of California.
void setSignatureType(tlv::SignatureTypeValue type)
Set SignatureType.
const Block & wireEncode() const
Encode to wire format.
Represents a SignatureInfo TLV element.
const Block & getTypeSpecificTlv(uint32_t type) const
Get SignatureType-specific sub-element.
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Prepend a TLV element containing a non-negative integer.
element_container::const_iterator element_const_iterator
void wireDecode(const Block &wire)
decode from wire encoding
Represents a TLV element of NDN packet format.
void appendTypeSpecificTlv(const Block &element)
Append SignatureType-specific sub-element.
const KeyLocator & getKeyLocator() const
Get KeyLocator.
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
friend bool operator==(const SignatureInfo &lhs, const SignatureInfo &rhs)
Abstraction of validity period.
security::ValidityPeriod getValidityPeriod() const
Get ValidityPeriod.
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.
void parse() const
Parse TLV-VALUE into sub elements.
uint32_t type() const
Get TLV-TYPE.
void wireDecode(const Block &wire)
Decode from wire format.
bool hasKeyLocator() const
Check if KeyLocator exists.
bool hasWire() const
Check if the Block has fully encoded wire.
std::string to_string(const V &v)
element_const_iterator elements_end() const
Equivalent to elements().end()
int32_t getSignatureType() const
Get SignatureType.
element_const_iterator elements_begin() const
Equivalent to elements().begin()
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
EncodingImpl< EstimatorTag > EncodingEstimator