hsw-nbt 1.2.0
OPTIGA Authenticate NBT Host Library for C
Data Structures | Macros | Functions
ifx-tlv.h File Reference

provides the function implementation for TLV(tag length value) DGI encoder and decoder. More...

#include "ifx-utils-lib.h"
#include "ifx-utils.h"
#include "infineon/ifx-error.h"

Go to the source code of this file.

Data Structures

struct  ifx_tlv_t
 Data storage for TLV(tag, length & value) fields TLV value field can be NULL. More...
 

Macros

#define IFX_TLV_DGI_ENCODER   UINT8_C(0x01)
 Function identifier of simple TLV encoder DGI for 1 byte & 3 byte TLV length field size.
 
#define IFX_TLV_DGI_DECODER   UINT8_C(0x02)
 Function identifier of simple TLV decoder DGI for 1 byte & 3 byte TLV length field size.
 
#define IFX_TLV_DGI_2B_LEN_IDENTIFIER   UINT8_C(0xFF)
 Its identifier byte, followed by 2 bytes length in encoded bytes.
 
#define IFX_TLV_DGI_LEN_IDENTIFIER_SIZE   UINT8_C(0x01)
 Size of TLV identifier for 2B length size.
 
#define IFX_TLV_DGI_MIN_LEN_SIZE   UINT8_C(0x01)
 Minimum size of TLV length field (1 or 3 bytes)
 
#define IFX_TLV_DGI_TAG_SIZE   UINT8_C(0x02)
 Size of TLV tag field.
 
#define IFX_TLV_DGI_LEN_SIZE_1B   UINT8_C(0x01)
 Size of TLV length field of 1 byte.
 
#define IFX_TLV_DGI_LEN_SIZE_2B   UINT8_C(0x02)
 Size of TLV length field of 2 bytes.
 
#define IFX_TLV_DGI_LEN_WITH_ID_SIZE   UINT8_C(0x03)
 Size of TLV length field, when TLV length value is greater than 254 bytes.
 
#define IFX_TLV_DGI_ENCODED_BYTES_INVALID   UINT8_C(0xF9)
 Return error status if encoded byte array is invalid.
 

Functions

ifx_status_t ifx_tlv_dgi_encode (const ifx_tlv_t *tlv_data, uint32_t tlv_data_count, ifx_blob_t *encoded_bytes)
 Encodes the array of TLV type data into byte array. This method encodes in DGI TLV format, which is similar to a simple TLV format but with 2 bytes TAG. TAG (2 bytes) LENGTH (1 or 3 bytes): If value >=255, 0xFF followed by 2 bytes length. Otherwise 1 byte. VALUE (0 or more bytes)
 
ifx_status_t ifx_tlv_dgi_decode (const ifx_blob_t *encoded_bytes, uint32_t *tlv_data_count, ifx_tlv_t *tlv_data)
 Decodes the byte array into array of TLV type data. This method decodes DGI TLV formatted data, which is similar to a simple TLV format but with 2 bytes TAG. TAG (2 bytes) LENGTH (1 or 3 bytes): If value>=255, 0xFF followed by 2 bytes length. Otherwise 1 byte. VALUE (0 or more bytes)
 

Detailed Description

provides the function implementation for TLV(tag length value) DGI encoder and decoder.

Definition in file ifx-tlv.h.

Macro Definition Documentation

◆ IFX_TLV_DGI_2B_LEN_IDENTIFIER

#define IFX_TLV_DGI_2B_LEN_IDENTIFIER   UINT8_C(0xFF)

Its identifier byte, followed by 2 bytes length in encoded bytes.

Definition at line 37 of file ifx-tlv.h.

◆ IFX_TLV_DGI_DECODER

#define IFX_TLV_DGI_DECODER   UINT8_C(0x02)

Function identifier of simple TLV decoder DGI for 1 byte & 3 byte TLV length field size.

Definition at line 32 of file ifx-tlv.h.

◆ IFX_TLV_DGI_ENCODED_BYTES_INVALID

#define IFX_TLV_DGI_ENCODED_BYTES_INVALID   UINT8_C(0xF9)

Return error status if encoded byte array is invalid.

Definition at line 73 of file ifx-tlv.h.

◆ IFX_TLV_DGI_ENCODER

#define IFX_TLV_DGI_ENCODER   UINT8_C(0x01)

Function identifier of simple TLV encoder DGI for 1 byte & 3 byte TLV length field size.

Definition at line 26 of file ifx-tlv.h.

◆ IFX_TLV_DGI_LEN_IDENTIFIER_SIZE

#define IFX_TLV_DGI_LEN_IDENTIFIER_SIZE   UINT8_C(0x01)

Size of TLV identifier for 2B length size.

Definition at line 42 of file ifx-tlv.h.

◆ IFX_TLV_DGI_LEN_SIZE_1B

#define IFX_TLV_DGI_LEN_SIZE_1B   UINT8_C(0x01)

Size of TLV length field of 1 byte.

Definition at line 57 of file ifx-tlv.h.

◆ IFX_TLV_DGI_LEN_SIZE_2B

#define IFX_TLV_DGI_LEN_SIZE_2B   UINT8_C(0x02)

Size of TLV length field of 2 bytes.

Definition at line 62 of file ifx-tlv.h.

◆ IFX_TLV_DGI_LEN_WITH_ID_SIZE

#define IFX_TLV_DGI_LEN_WITH_ID_SIZE   UINT8_C(0x03)

Size of TLV length field, when TLV length value is greater than 254 bytes.

Definition at line 68 of file ifx-tlv.h.

◆ IFX_TLV_DGI_MIN_LEN_SIZE

#define IFX_TLV_DGI_MIN_LEN_SIZE   UINT8_C(0x01)

Minimum size of TLV length field (1 or 3 bytes)

Definition at line 47 of file ifx-tlv.h.

◆ IFX_TLV_DGI_TAG_SIZE

#define IFX_TLV_DGI_TAG_SIZE   UINT8_C(0x02)

Size of TLV tag field.

Definition at line 52 of file ifx-tlv.h.

Function Documentation

◆ ifx_tlv_dgi_decode()

ifx_status_t ifx_tlv_dgi_decode ( const ifx_blob_t * encoded_bytes,
uint32_t * tlv_data_count,
ifx_tlv_t * tlv_data )

Decodes the byte array into array of TLV type data. This method decodes DGI TLV formatted data, which is similar to a simple TLV format but with 2 bytes TAG. TAG (2 bytes) LENGTH (1 or 3 bytes): If value>=255, 0xFF followed by 2 bytes length. Otherwise 1 byte. VALUE (0 or more bytes)

Parameters
[in]encoded_bytespointer to ifx_blob_t type encoded byte array
[out]tlv_data_countpointer to number of TLV type data
[out]tlv_datapointer to array of TLV type data, memory should be allocated before passing with this function
Returns
ifx_status_t IFX_SUCCESS, if successful otherwise error information in case of error error status IFX_ILLEGAL_ARGUMENT, if parameter is NULL or illegal error status IFX_OUT_OF_MEMORY, if memory allocation is invalid error status IFX_TLV_DGI_ENCODED_BYTES_INVALID, if encoded bytes contain invalid TLV structure

◆ ifx_tlv_dgi_encode()

ifx_status_t ifx_tlv_dgi_encode ( const ifx_tlv_t * tlv_data,
uint32_t tlv_data_count,
ifx_blob_t * encoded_bytes )

Encodes the array of TLV type data into byte array. This method encodes in DGI TLV format, which is similar to a simple TLV format but with 2 bytes TAG. TAG (2 bytes) LENGTH (1 or 3 bytes): If value >=255, 0xFF followed by 2 bytes length. Otherwise 1 byte. VALUE (0 or more bytes)

Parameters
[in]tlv_datapointer to array of TLV type data
[in]tlv_data_countnumber of TLV type data
[out]encoded_bytespointer to ifx_blob_t type encoded byte array
Returns
ifx_status_t IFX_SUCCESS, if successful otherwise error information in case of error error status IFX_ILLEGAL_ARGUMENT, if parameter is NULL or illegal error status IFX_OUT_OF_MEMORY, if memory allocation is invalid