ndn::SignatureInfo Class Reference

Represents a SignatureInfo or InterestSignatureInfo TLV element. More...

#include <ndn-cxx/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...
 
void addCustomTlv (Block block)
 Append an arbitrary TLV element to this SignatureInfo. More...
 
void appendTypeSpecificTlv (const Block &block)
 Append SignatureType-specific sub-element. More...
 
optional< BlockgetCustomTlv (uint32_t type) const
 Get first custom TLV element with the specified TLV-TYPE. More...
 
const KeyLocatorgetKeyLocator () const
 Get KeyLocator. More...
 
optional< std::vector< uint8_t > > getNonce () const
 Get SignatureNonce. More...
 
optional< uint64_t > getSeqNum () const
 Get SignatureSeqNum. More...
 
int32_t getSignatureType () const noexcept
 Get SignatureType. More...
 
optional< time::system_clock::time_pointgetTime () const
 Get SignatureTime. More...
 
const BlockgetTypeSpecificTlv (uint32_t type) const
 Get SignatureType-specific sub-element. More...
 
security::ValidityPeriod getValidityPeriod () const
 Get ValidityPeriod. More...
 
bool hasKeyLocator () const noexcept
 Check if KeyLocator is present. More...
 
bool hasWire () const noexcept
 Check if this instance has cached wire encoding. More...
 
 operator bool () const noexcept
 Determine whether SignatureInfo is valid. More...
 
void removeCustomTlv (uint32_t type)
 Remove all arbitrary TLV elements with the specified TLV-TYPE from this SignatureInfo. More...
 
SignatureInfosetKeyLocator (optional< KeyLocator > keyLocator)
 Set KeyLocator. More...
 
SignatureInfosetNonce (optional< std::vector< uint8_t >> nonce)
 Append or replace SignatureNonce. More...
 
SignatureInfosetSeqNum (optional< uint64_t > seqNum)
 Append or replace SignatureSeqNum. More...
 
SignatureInfosetSignatureType (tlv::SignatureTypeValue type)
 Set SignatureType. More...
 
SignatureInfosetTime (optional< time::system_clock::time_point > time=time::system_clock::now())
 Append or replace SignatureTime. More...
 
SignatureInfosetValidityPeriod (optional< security::ValidityPeriod > validityPeriod)
 Append or replace ValidityPeriod. More...
 
void unsetKeyLocator ()
 Remove KeyLocator. More...
 
void unsetValidityPeriod ()
 Remove ValidityPeriod. More...
 
void wireDecode (const Block &wire, Type type=Type::Data)
 Decode from wire format. 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...
 

Friends

std::ostream & operator<< (std::ostream &os, const SignatureInfo &info)
 
bool operator== (const SignatureInfo &lhs, const SignatureInfo &rhs)
 

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.

Member Function Documentation

◆ 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 319 of file signature-info.cpp.

◆ appendTypeSpecificTlv()

void ndn::SignatureInfo::appendTypeSpecificTlv ( const Block block)

Append SignatureType-specific sub-element.

Deprecated:
Use addCustomTlv

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

◆ 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 309 of file signature-info.cpp.

◆ 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.

◆ getNonce()

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

Get SignatureNonce.

Return values
nulloptSignatureNonce is not set

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

◆ getSeqNum()

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

Get SignatureSeqNum.

Return values
nulloptSignatureSeqNum is not set

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

◆ getSignatureType()

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

Get SignatureType.

Returns
tlv::SignatureTypeValue, or -1 to indicate an invalid SignatureInfo

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

◆ getTime()

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

Get SignatureTime.

Return values
nulloptSignatureTime is not set

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

◆ getTypeSpecificTlv()

const Block & ndn::SignatureInfo::getTypeSpecificTlv ( uint32_t  type) const

Get SignatureType-specific sub-element.

Deprecated:
Use getCustomTlv
Parameters
typeTLV-TYPE of sub-element
Exceptions
ErrorSub-element of specified type does not exist

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

◆ getValidityPeriod()

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

Get ValidityPeriod.

Exceptions
ErrorThis SignatureInfo does not contain a ValidityPeriod

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

◆ hasKeyLocator()

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

Check if KeyLocator is present.

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

◆ hasWire()

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

Check if this instance has cached wire encoding.

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

◆ operator bool()

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

Determine whether SignatureInfo is valid.

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

◆ 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 335 of file signature-info.cpp.

◆ 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.

◆ setNonce()

SignatureInfo & ndn::SignatureInfo::setNonce ( optional< std::vector< 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 253 of file signature-info.cpp.

◆ 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 297 of file signature-info.cpp.

◆ 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.

◆ 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 275 of file signature-info.cpp.

◆ 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 225 of file signature-info.cpp.

◆ unsetKeyLocator()

void ndn::SignatureInfo::unsetKeyLocator ( )

Remove KeyLocator.

Deprecated:
Use setKeyLocator(nullopt)

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

◆ unsetValidityPeriod()

void ndn::SignatureInfo::unsetValidityPeriod ( )

Remove ValidityPeriod.

Deprecated:
Use setValidityPeriod(nullopt)

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

◆ wireDecode()

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

Decode from wire format.

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

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

◆ 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.

◆ 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.

Friends And Related Function Documentation

◆ operator<<

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

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

◆ operator==

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

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