NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
ndn::SignatureInfo Class Reference

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 BlockwireEncode (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...
 
SignatureInfosetSignatureType (tlv::SignatureTypeValue type)
 Set SignatureType. More...
 
bool hasKeyLocator () const noexcept
 Check if KeyLocator is present. More...
 
const KeyLocatorgetKeyLocator () const
 Get KeyLocator. More...
 
SignatureInfosetKeyLocator (optional< KeyLocator > keyLocator)
 Set KeyLocator. More...
 
security::ValidityPeriod getValidityPeriod () const
 Get ValidityPeriod. More...
 
SignatureInfosetValidityPeriod (optional< security::ValidityPeriod > validityPeriod)
 Append or replace ValidityPeriod. More...
 
optional< std::vector< uint8_t > > getNonce () const
 Get SignatureNonce. More...
 
SignatureInfosetNonce (optional< span< const uint8_t >> nonce)
 Append or replace SignatureNonce. More...
 
optional< time::system_clock::time_pointgetTime () const
 Get SignatureTime. More...
 
SignatureInfosetTime (optional< time::system_clock::time_point > time=time::system_clock::now())
 Append or replace SignatureTime. More...
 
optional< uint64_t > getSeqNum () const
 Get SignatureSeqNum. More...
 
SignatureInfosetSeqNum (optional< uint64_t > seqNum)
 Append or replace SignatureSeqNum. More...
 
optional< BlockgetCustomTlv (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)
 

Detailed Description

Represents a SignatureInfo or InterestSignatureInfo TLV element.

Definition at line 32 of file signature-info.hpp.

Member Enumeration Documentation

◆ Type

enum ndn::SignatureInfo::Type : uint32_t
strong
Enumerator
Data 
Interest 

Definition at line 41 of file signature-info.hpp.

Constructor & Destructor Documentation

◆ SignatureInfo() [1/3]

ndn::SignatureInfo::SignatureInfo ( )
default

◆ SignatureInfo() [2/3]

ndn::SignatureInfo::SignatureInfo ( tlv::SignatureTypeValue  type,
optional< KeyLocator keyLocator = nullopt 
)
explicit

Create with the specified type and KeyLocator.

Definition at line 40 of file signature-info.cpp.

◆ SignatureInfo() [3/3]

ndn::SignatureInfo::SignatureInfo ( const Block wire,
SignatureInfo::Type  type = Type::Data 
)
explicit

Create from wire encoding.

Parameters
wireWire to decode from
typeWhich type of SignatureInfo block decoding should expect
Exceptions
tlv::ErrorDecode error

Definition at line 46 of file signature-info.cpp.

References wireDecode().

Member Function Documentation

◆ operator bool()

ndn::SignatureInfo::operator bool ( ) const
inlineexplicitnoexcept

Determine whether SignatureInfo is valid.

Definition at line 65 of file signature-info.hpp.

References Data, wireDecode(), and wireEncode().

◆ wireEncode() [1/2]

template<encoding::Tag TAG>
size_t ndn::SignatureInfo::wireEncode ( EncodingImpl< TAG > &  encoder,
SignatureInfo::Type  type = Type::Data 
) const

Fast encoding or block size estimation.

Parameters
encoderEncodingEstimator or EncodingBuffer instance
typeWhich 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().

◆ wireEncode() [2/2]

const Block & ndn::SignatureInfo::wireEncode ( SignatureInfo::Type  type = Type::Data) const

Encode to wire format.

Parameters
typeWhich 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().

◆ wireDecode()

◆ hasWire()

bool ndn::SignatureInfo::hasWire ( ) const
inlinenoexcept

Check if this instance has cached wire encoding.

Definition at line 103 of file signature-info.hpp.

◆ getSignatureType()

int32_t ndn::SignatureInfo::getSignatureType ( ) const
inlinenoexcept

◆ setSignatureType()

SignatureInfo & ndn::SignatureInfo::setSignatureType ( tlv::SignatureTypeValue  type)

Set SignatureType.

Returns
A reference to this SignatureInfo, to allow chaining

Definition at line 180 of file signature-info.cpp.

References ndn::Block::reset().

Referenced by getSignatureType(), and ndn::security::v2::parseLocatorUri().

◆ hasKeyLocator()

◆ getKeyLocator()

const KeyLocator & ndn::SignatureInfo::getKeyLocator ( ) const

Get KeyLocator.

Exceptions
ErrorThis 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<<().

◆ setKeyLocator()

SignatureInfo & ndn::SignatureInfo::setKeyLocator ( optional< KeyLocator keyLocator)

Set KeyLocator.

Returns
A reference to this SignatureInfo, to allow chaining

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().

◆ getValidityPeriod()

security::ValidityPeriod ndn::SignatureInfo::getValidityPeriod ( ) const

Get ValidityPeriod.

Exceptions
ErrorThis 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<<().

◆ setValidityPeriod()

SignatureInfo & ndn::SignatureInfo::setValidityPeriod ( optional< security::ValidityPeriod validityPeriod)

Append or replace ValidityPeriod.

Returns
A reference to this SignatureInfo, to allow chaining

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().

◆ getNonce()

optional< std::vector< uint8_t > > ndn::SignatureInfo::getNonce ( ) const

Get SignatureNonce.

Return values
nulloptSignatureNonce 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<<().

◆ setNonce()

SignatureInfo & ndn::SignatureInfo::setNonce ( optional< span< const uint8_t >>  nonce)

Append or replace SignatureNonce.

Returns
A reference to this SignatureInfo, to allow chaining

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().

◆ getTime()

optional< time::system_clock::time_point > ndn::SignatureInfo::getTime ( ) const

Get SignatureTime.

Return values
nulloptSignatureTime 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<<().

◆ setTime()

SignatureInfo & ndn::SignatureInfo::setTime ( optional< time::system_clock::time_point time = time::system_clock::now())

Append or replace SignatureTime.

Returns
A reference to this SignatureInfo, to allow chaining

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().

◆ getSeqNum()

optional< uint64_t > ndn::SignatureInfo::getSeqNum ( ) const

Get SignatureSeqNum.

Return values
nulloptSignatureSeqNum 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<<().

◆ setSeqNum()

SignatureInfo & ndn::SignatureInfo::setSeqNum ( optional< uint64_t >  seqNum)

Append or replace SignatureSeqNum.

Returns
A reference to this SignatureInfo, to allow chaining

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().

◆ getCustomTlv()

optional< Block > ndn::SignatureInfo::getCustomTlv ( uint32_t  type) const

Get first custom TLV element with the specified TLV-TYPE.

Parameters
typeTLV-TYPE of element to get
Return values
nulloptNo 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<<().

◆ addCustomTlv()

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().

◆ removeCustomTlv()

void ndn::SignatureInfo::removeCustomTlv ( uint32_t  type)

Remove all arbitrary TLV elements with the specified TLV-TYPE from this SignatureInfo.

Parameters
typeTLV-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().

Friends And Related Function Documentation

◆ operator==

bool operator== ( const SignatureInfo lhs,
const SignatureInfo rhs 
)
friend

Definition at line 345 of file signature-info.cpp.

Referenced by hasKeyLocator().

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const SignatureInfo info 
)
friend

Definition at line 353 of file signature-info.cpp.

Referenced by hasKeyLocator(), and ndn::operator!=().


The documentation for this class was generated from the following files: