28 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<SignatureInfo>));
29 BOOST_CONCEPT_ASSERT((WireEncodable<SignatureInfo>));
30 BOOST_CONCEPT_ASSERT((WireEncodableWithEncodingBuffer<SignatureInfo>));
31 BOOST_CONCEPT_ASSERT((WireDecodable<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>
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;
127 m_type = readNonNegativeIntegerAs<tlv::SignatureTypeValue>(*it);
133 m_hasKeyLocator =
true;
139 m_otherTlvs.push_back(*it);
164 m_keyLocator = keyLocator;
165 m_hasKeyLocator =
true;
173 m_hasKeyLocator =
false;
180 NDN_THROW(
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)
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() <<
" ";
friend std::ostream & operator<<(std::ostream &os, const SignatureInfo &info)
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::string to_string(const T &val)
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.
bool hasWire() const noexcept
Check if the Block contains a fully encoded wire representation.
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.
friend bool operator==(const SignatureInfo &lhs, const SignatureInfo &rhs)
element_const_iterator elements_end() const
Equivalent to elements().end()
Abstraction of validity period.
bool hasKeyLocator() const
Check if KeyLocator exists.
void reset() noexcept
Reset the Block to a default-constructed state.
int32_t getSignatureType() const
Get SignatureType.
void unsetKeyLocator()
Unset KeyLocator.
#define NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
void setValidityPeriod(const security::ValidityPeriod &validityPeriod)
Set ValidityPeriod.
SignatureTypeValue
SignatureType values.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Prepend wire encoding to encoder.
void wireDecode(const Block &wire)
Decode from wire format.
EncodingImpl< EncoderTag > EncodingBuffer
uint32_t type() const
Return the TLV-TYPE of the Block.
EncodingImpl< EstimatorTag > EncodingEstimator
security::ValidityPeriod getValidityPeriod() const
Get ValidityPeriod.