Represents a SignatureInfo or InterestSignatureInfo TLV element. More...
#include <signature-info.hpp>
Classes | |
class | Error |
Public Types | |
enum | Type : uint32_t { Type::Data = tlv::SignatureInfo, Type::Interest = tlv::InterestSignatureInfo } |
Public Member Functions | |
SignatureInfo () | |
SignatureInfo (tlv::SignatureTypeValue type, optional< KeyLocator > keyLocator=nullopt) | |
Create with the specified type and KeyLocator. More... | |
SignatureInfo (const Block &wire, Type type=Type::Data) | |
Create from wire encoding. More... | |
operator bool () const noexcept | |
Determine whether SignatureInfo is valid. More... | |
template<encoding::Tag TAG> | |
size_t | wireEncode (EncodingImpl< TAG > &encoder, Type type=Type::Data) const |
Fast encoding or block size estimation. More... | |
const Block & | wireEncode (Type type=Type::Data) const |
Encode to wire format. More... | |
void | wireDecode (const Block &wire, Type type=Type::Data) |
Decode from wire format. More... | |
bool | hasWire () const noexcept |
Check if this instance has cached wire encoding. More... | |
int32_t | getSignatureType () const noexcept |
Get SignatureType. More... | |
SignatureInfo & | setSignatureType (tlv::SignatureTypeValue type) |
Set SignatureType. More... | |
bool | hasKeyLocator () const noexcept |
Check if KeyLocator is present. More... | |
const KeyLocator & | getKeyLocator () const |
Get KeyLocator. More... | |
SignatureInfo & | setKeyLocator (optional< KeyLocator > keyLocator) |
Set KeyLocator. More... | |
security::ValidityPeriod | getValidityPeriod () const |
Get ValidityPeriod. More... | |
SignatureInfo & | setValidityPeriod (optional< security::ValidityPeriod > validityPeriod) |
Append or replace ValidityPeriod. More... | |
optional< std::vector< uint8_t > > | getNonce () const |
Get SignatureNonce. More... | |
SignatureInfo & | setNonce (optional< span< const uint8_t >> nonce) |
Append or replace SignatureNonce. More... | |
optional< time::system_clock::time_point > | getTime () const |
Get SignatureTime. More... | |
SignatureInfo & | setTime (optional< time::system_clock::time_point > time=time::system_clock::now()) |
Append or replace SignatureTime. More... | |
optional< uint64_t > | getSeqNum () const |
Get SignatureSeqNum. More... | |
SignatureInfo & | setSeqNum (optional< uint64_t > seqNum) |
Append or replace SignatureSeqNum. More... | |
optional< Block > | getCustomTlv (uint32_t type) const |
Get first custom TLV element with the specified TLV-TYPE. More... | |
void | addCustomTlv (Block block) |
Append an arbitrary TLV element to this SignatureInfo. More... | |
void | removeCustomTlv (uint32_t type) |
Remove all arbitrary TLV elements with the specified TLV-TYPE from this SignatureInfo. More... | |
Friends | |
bool | operator== (const SignatureInfo &lhs, const SignatureInfo &rhs) |
std::ostream & | operator<< (std::ostream &os, const SignatureInfo &info) |
Represents a SignatureInfo or InterestSignatureInfo TLV element.
Definition at line 32 of file signature-info.hpp.
|
strong |
Enumerator | |
---|---|
Data | |
Interest |
Definition at line 41 of file signature-info.hpp.
|
default |
|
explicit |
Create with the specified type and KeyLocator.
Definition at line 40 of file signature-info.cpp.
|
explicit |
Create from wire encoding.
wire | Wire to decode from |
type | Which type of SignatureInfo block decoding should expect |
tlv::Error | Decode error |
Definition at line 46 of file signature-info.cpp.
References wireDecode().
|
inlineexplicitnoexcept |
Determine whether SignatureInfo is valid.
Definition at line 65 of file signature-info.hpp.
References Data, wireDecode(), and wireEncode().
size_t ndn::SignatureInfo::wireEncode | ( | EncodingImpl< TAG > & | encoder, |
SignatureInfo::Type | type = Type::Data |
||
) | const |
Fast encoding or block size estimation.
encoder | EncodingEstimator or EncodingBuffer instance |
type | Which type of SignatureInfo block to encode |
Elements are encoded in the following order: SignatureType, KeyLocator (if present), and other elements in the order they were set (changing the value of an already present element will not change that element's encoding order).
Definition at line 53 of file signature-info.cpp.
References NDN_THROW, ndn::encoding::prependBlock(), ndn::encoding::prependNonNegativeIntegerBlock(), ndn::tlv::SignatureType, and ndn::to_underlying().
Referenced by operator bool(), ndn::Interest::setSignatureInfo(), ndn::security::v2::KeyChain::sign(), ndn::Data::wireEncode(), and wireEncode().
const Block & ndn::SignatureInfo::wireEncode | ( | SignatureInfo::Type | type = Type::Data | ) | const |
Encode to wire format.
type | Which type of SignatureInfo block to encode |
Elements are encoded in the following order: SignatureType, KeyLocator (if present), and other elements in the order they were set (changing the value of an already present element will not change that element's encoding order).
Definition at line 101 of file signature-info.cpp.
References ndn::Block::hasWire(), and wireEncode().
void ndn::SignatureInfo::wireDecode | ( | const Block & | wire, |
SignatureInfo::Type | type = Type::Data |
||
) |
Decode from wire format.
wire | Wire to decode from |
type | Which type of SignatureInfo block decoding should expect |
tlv::Error | Decode error |
Definition at line 117 of file signature-info.cpp.
References ndn::Block::elements(), ndn::tlv::isCriticalType(), ndn::tlv::KeyLocator, NDN_THROW, nonstd::optional_lite::nullopt, ndn::Block::parse(), ndn::tlv::SignatureNonce, ndn::tlv::SignatureType, ndn::to_string(), ndn::to_underlying(), ndn::Block::type(), and ndn::tlv::ValidityPeriod.
Referenced by ndn::security::v2::validator_config::ValidationPolicyConfig::checkPolicy(), ndn::security::v2::getKeyLocatorName(), operator bool(), SignatureInfo(), and ndn::Data::wireDecode().
|
inlinenoexcept |
Check if this instance has cached wire encoding.
Definition at line 103 of file signature-info.hpp.
|
inlinenoexcept |
Get SignatureType.
Definition at line 113 of file signature-info.hpp.
References setSignatureType().
Referenced by ndn::security::v2::validator_config::ValidationPolicyConfig::checkPolicy(), ndn::security::v2::getKeyLocatorName(), and ndn::operator<<().
SignatureInfo & ndn::SignatureInfo::setSignatureType | ( | tlv::SignatureTypeValue | type | ) |
Set SignatureType.
Definition at line 180 of file signature-info.cpp.
References ndn::Block::reset().
Referenced by getSignatureType(), and ndn::security::v2::parseLocatorUri().
|
inlinenoexcept |
Check if KeyLocator is present.
Definition at line 127 of file signature-info.hpp.
References addCustomTlv(), getCustomTlv(), getKeyLocator(), getNonce(), getSeqNum(), getTime(), getValidityPeriod(), info, ndn::time::system_clock::now(), operator<<, operator==, removeCustomTlv(), setKeyLocator(), setNonce(), setSeqNum(), setTime(), and setValidityPeriod().
Referenced by getKeyLocator(), ndn::security::v2::getKeyLocatorName(), and ndn::operator<<().
const KeyLocator & ndn::SignatureInfo::getKeyLocator | ( | ) | const |
Get KeyLocator.
Error | This SignatureInfo does not contain a KeyLocator |
Definition at line 190 of file signature-info.cpp.
References hasKeyLocator(), and NDN_THROW.
Referenced by ndn::security::v2::getKeyLocatorName(), hasKeyLocator(), and ndn::operator<<().
SignatureInfo & ndn::SignatureInfo::setKeyLocator | ( | optional< KeyLocator > | keyLocator | ) |
Set KeyLocator.
Passing nullopt
will remove the KeyLocator.
Definition at line 199 of file signature-info.cpp.
References nonstd::optional_lite::std11::move(), and ndn::Block::reset().
Referenced by hasKeyLocator(), and ndn::security::v2::parseLocatorUri().
security::ValidityPeriod ndn::SignatureInfo::getValidityPeriod | ( | ) | const |
Get ValidityPeriod.
Error | This SignatureInfo does not contain a ValidityPeriod |
Definition at line 209 of file signature-info.cpp.
References NDN_THROW, and ndn::tlv::ValidityPeriod.
Referenced by ndn::security::v2::Certificate::getValidityPeriod(), hasKeyLocator(), ndn::security::v2::Certificate::isValid(), and ndn::operator<<().
SignatureInfo & ndn::SignatureInfo::setValidityPeriod | ( | optional< security::ValidityPeriod > | validityPeriod | ) |
Append or replace ValidityPeriod.
Passing nullopt
will remove the ValidityPeriod.
Definition at line 219 of file signature-info.cpp.
References addCustomTlv(), removeCustomTlv(), and ndn::tlv::ValidityPeriod.
Referenced by hasKeyLocator(), and ndn::security::v2::parseLocatorUri().
optional< std::vector< uint8_t > > ndn::SignatureInfo::getNonce | ( | ) | const |
Get SignatureNonce.
nullopt | SignatureNonce is not set |
Definition at line 231 of file signature-info.cpp.
References nonstd::optional_lite::nullopt, and ndn::tlv::SignatureNonce.
Referenced by hasKeyLocator(), and ndn::operator<<().
SignatureInfo & ndn::SignatureInfo::setNonce | ( | optional< span< const uint8_t >> | nonce | ) |
Append or replace SignatureNonce.
Passing nullopt
will remove the SignatureNonce.
Definition at line 241 of file signature-info.cpp.
References addCustomTlv(), ndn::encoding::makeBinaryBlock(), removeCustomTlv(), and ndn::tlv::SignatureNonce.
Referenced by hasKeyLocator(), and ndn::security::InterestSigner::makeSignedInterest().
optional< time::system_clock::time_point > ndn::SignatureInfo::getTime | ( | ) | const |
Get SignatureTime.
nullopt | SignatureTime is not set |
Definition at line 253 of file signature-info.cpp.
References ndn::time::fromUnixTimestamp(), nonstd::optional_lite::nullopt, ndn::encoding::readNonNegativeInteger(), and ndn::tlv::SignatureTime.
Referenced by hasKeyLocator(), and ndn::operator<<().
SignatureInfo & ndn::SignatureInfo::setTime | ( | optional< time::system_clock::time_point > | time = time::system_clock::now() | ) |
Append or replace SignatureTime.
Passing nullopt
will remove the SignatureTime.
Definition at line 263 of file signature-info.cpp.
References addCustomTlv(), ndn::encoding::makeNonNegativeIntegerBlock(), removeCustomTlv(), ndn::tlv::SignatureTime, and ndn::time::toUnixTimestamp().
Referenced by hasKeyLocator(), and ndn::security::InterestSigner::makeSignedInterest().
optional< uint64_t > ndn::SignatureInfo::getSeqNum | ( | ) | const |
Get SignatureSeqNum.
nullopt | SignatureSeqNum is not set |
Definition at line 276 of file signature-info.cpp.
References nonstd::optional_lite::nullopt, ndn::encoding::readNonNegativeInteger(), and ndn::tlv::SignatureSeqNum.
Referenced by hasKeyLocator(), and ndn::operator<<().
SignatureInfo & ndn::SignatureInfo::setSeqNum | ( | optional< uint64_t > | seqNum | ) |
Append or replace SignatureSeqNum.
Passing nullopt
will remove the SignatureSeqNum.
Definition at line 286 of file signature-info.cpp.
References addCustomTlv(), ndn::encoding::makeNonNegativeIntegerBlock(), removeCustomTlv(), and ndn::tlv::SignatureSeqNum.
Referenced by hasKeyLocator(), and ndn::security::InterestSigner::makeSignedInterest().
optional< Block > ndn::SignatureInfo::getCustomTlv | ( | uint32_t | type | ) | const |
Get first custom TLV element with the specified TLV-TYPE.
type | TLV-TYPE of element to get |
nullopt | No custom TLV elements with the specified TLV-TYPE exist |
Definition at line 298 of file signature-info.cpp.
References nonstd::optional_lite::nullopt.
Referenced by ndn::security::v2::Certificate::getExtension(), hasKeyLocator(), and ndn::security::v2::operator<<().
void ndn::SignatureInfo::addCustomTlv | ( | Block | block | ) |
Append an arbitrary TLV element to this SignatureInfo.
If an element of the same TLV-TYPE already exists, it will be replaced by the new element.
Definition at line 308 of file signature-info.cpp.
References nonstd::optional_lite::std11::move(), ndn::Block::reset(), and ndn::Block::type().
Referenced by hasKeyLocator(), setNonce(), setSeqNum(), setTime(), and setValidityPeriod().
void ndn::SignatureInfo::removeCustomTlv | ( | uint32_t | type | ) |
Remove all arbitrary TLV elements with the specified TLV-TYPE from this SignatureInfo.
type | TLV-TYPE of elements to remove |
Definition at line 324 of file signature-info.cpp.
References ndn::Block::reset().
Referenced by hasKeyLocator(), setNonce(), setSeqNum(), setTime(), and setValidityPeriod().
|
friend |
Definition at line 345 of file signature-info.cpp.
Referenced by hasKeyLocator().
|
friend |
Definition at line 353 of file signature-info.cpp.
Referenced by hasKeyLocator(), and ndn::operator!=().