NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
Public Member Functions | Static Public Member Functions | List of all members
BiometricEvaluation::Device::TLV Class Reference

A class to represent a Tag-Length-Value (TLV) data structure as described in the ISO 7816-4 integrated circuit card standard. More...

#include <be_device_tlv.h>

Public Member Functions

 TLV ()
 Construct an empty Tag-Length-Value object that can be filled with setter methods. More...
 
 TLV (const Memory::uint8Array &buf)
 Construct a Tag-Length-Value object from the given buffer. More...
 
 TLV (Memory::IndexedBuffer &ibuf)
 Construct a single TLV from the indexed buffer. More...
 
 TLV (const std::string &filename)
 Construct a Tag-Length-Value object from the given file name. More...
 
void setTag (const Memory::uint8Array &tag)
 Set the encoded tag value. More...
 
const Memory::uint8Array getTag () const
 Obtain the encoded tag value. More...
 
uint32_t getTagNum () const
 Get the decoded tag number. More...
 
uint8_t getTagClass () const
 Get the decoded tag class. More...
 
bool isPrimitive () const
 Obtain the type of TLV: primitive/constructed. More...
 
void setPrimitive (const Memory::uint8Array &value)
 Set the primitive data associated with this TLV. More...
 
Memory::uint8Array getPrimitive () const
 Obtain the primitive data associated with this TLV. More...
 
void addChild (const TLV &tlv)
 Add a child TLV. More...
 
std::vector< TLVgetChildren () const
 Get copies of the child TLVs. More...
 
Memory::uint8Array getRawTLV () const
 Obtain the TLV as an array of 8-bit values. More...
 

Static Public Member Functions

static std::string stringFromTLV (const TLV &tlv, const int tabCount)
 Class utility function to print the contents of a TLV into a string object, in readable format. More...
 

Detailed Description

A class to represent a Tag-Length-Value (TLV) data structure as described in the ISO 7816-4 integrated circuit card standard.

A TLV is composed of tag and length fields, then a value field that may be another TLV (a child), or data of another format, represented as the primitive object in this class.

Definition at line 34 of file be_device_tlv.h.

Constructor & Destructor Documentation

◆ TLV() [1/4]

BiometricEvaluation::Device::TLV::TLV ( )

Construct an empty Tag-Length-Value object that can be filled with setter methods.

Empty TLV objects are primitive.

◆ TLV() [2/4]

BiometricEvaluation::Device::TLV::TLV ( const Memory::uint8Array buf)

Construct a Tag-Length-Value object from the given buffer.

Exceptions
Error::DataErrorThe data in the buffer is not conforming.

◆ TLV() [3/4]

BiometricEvaluation::Device::TLV::TLV ( Memory::IndexedBuffer ibuf)

Construct a single TLV from the indexed buffer.

Exceptions
Error::DataErrorError parsing the data in the buffer.

◆ TLV() [4/4]

BiometricEvaluation::Device::TLV::TLV ( const std::string &  filename)

Construct a Tag-Length-Value object from the given file name.

Exceptions
Error::DataErrorThe data in the file is not conformance.

Member Function Documentation

◆ stringFromTLV()

static std::string BiometricEvaluation::Device::TLV::stringFromTLV ( const TLV tlv,
const int  tabCount 
)
static

Class utility function to print the contents of a TLV into a string object, in readable format.

Parameters
tlvThe TLV to print.
tabCountThe number of tab characters to insert before each line of the output.

◆ setTag()

void BiometricEvaluation::Device::TLV::setTag ( const Memory::uint8Array tag)

Set the encoded tag value.

This function will cause a recalculation of the decoded tag number, class and primitive indicators.

Exceptions
Error::DataErrorThe primitive indicator conflicts with the presence of children TLVs, or presence of primitive data.
Error::ParameterErrorThe length of the buffer is larger than the maximum tag length.

◆ getTag()

const Memory::uint8Array BiometricEvaluation::Device::TLV::getTag ( ) const

Obtain the encoded tag value.

◆ getTagNum()

uint32_t BiometricEvaluation::Device::TLV::getTagNum ( ) const

Get the decoded tag number.

Returns
The tag number.

◆ getTagClass()

uint8_t BiometricEvaluation::Device::TLV::getTagClass ( ) const

Get the decoded tag class.

Returns
The tag class.

◆ isPrimitive()

bool BiometricEvaluation::Device::TLV::isPrimitive ( ) const

Obtain the type of TLV: primitive/constructed.

Returns
True if is a primitive TLV, false otherwise.

◆ setPrimitive()

void BiometricEvaluation::Device::TLV::setPrimitive ( const Memory::uint8Array value)

Set the primitive data associated with this TLV.

The primitive data is added as the value data item.

Exceptions
Error::DataErrorThe TLV is already of the constructed form, meaning that there are TLV children set as the value data.

◆ getPrimitive()

Memory::uint8Array BiometricEvaluation::Device::TLV::getPrimitive ( ) const

Obtain the primitive data associated with this TLV.

Exceptions
Error::DataErrorThe TLV is of the constructed form.
See also
getChildren.

◆ addChild()

void BiometricEvaluation::Device::TLV::addChild ( const TLV tlv)

Add a child TLV.

Parameters
tlvThe TLV to be added as a child of this TLV.
Exceptions
Error::DataErrorThe TLV is primitive.

◆ getChildren()

std::vector< TLV > BiometricEvaluation::Device::TLV::getChildren ( ) const

Get copies of the child TLVs.

Returns
A vector of child TLVs.
Exceptions
Error::DataErrorThe TLV is primitive.

◆ getRawTLV()

Memory::uint8Array BiometricEvaluation::Device::TLV::getRawTLV ( ) const

Obtain the TLV as an array of 8-bit values.

The array can be sent to a device that accepts TLV-encoded objects, typically wrapped in device command structures.

Returns
The TLV as an array.

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