plugntrust 2.0.0.0
Plug n Trust Click Driver

API for configuring and manipulating Plug n Trust Click driver. More...

Topics

 Protocol Control Byte
 List of pcb of Plug n Trust Click driver.
 
 Plug n Trust Registers List
 List of registers of Plug n Trust Click driver.
 
 Plug n Trust Registers Settings
 Settings for registers of Plug n Trust Click driver.
 
 Plug n Trust MikroBUS Map
 MikroBUS pin mapping of Plug n Trust Click driver.
 

Functions

void plugntrust_cfg_setup (plugntrust_cfg_t *cfg)
 Plug n Trust configuration object setup function.
 
err_t plugntrust_init (plugntrust_t *ctx, plugntrust_cfg_t *cfg)
 Plug n Trust initialization function.
 
err_t plugntrust_default_cfg (plugntrust_t *ctx)
 Plug n Trust default configuration function.
 
err_t plugntrust_apdu_write (plugntrust_t *ctx, plugntrust_frame_data_t *frame_data)
 Writing frame data function.
 
err_t plugntrust_apdu_read (plugntrust_t *ctx, plugntrust_frame_data_t *frame_data)
 Reading frame data function function.
 
err_t plugntrust_apdu_transfer (plugntrust_t *ctx, plugntrust_frame_data_t *frame_data)
 Write-Read frame data function.
 
void plugntrust_set_en (plugntrust_t *ctx, uint8_t state)
 Set Enable pin state.
 
void plugntrust_set_rst (plugntrust_t *ctx, uint8_t state)
 Set Reset pin state.
 
void plugntrust_reset (plugntrust_t *ctx)
 Reset function.
 
void plugntrust_set_tlv_u8 (uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint8_t value)
 Add TLV data of 1 byte value in payload buffer.
 
void plugntrust_set_tlv_u16 (uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint16_t value)
 Add TLV data of 2 bytes value in payload buffer.
 
void plugntrust_set_tlv_u16_optional (uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint16_t value)
 Add TLV data of 2 bytes value in payload buffer if value is greater then 0.
 
void plugntrust_set_tlv_u32 (uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint32_t value)
 Add TLV data of 4 bytes value in payload buffer.
 
err_t plugntrust_set_tlv_u8buf (uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint8_t *cmd, uint32_t cmd_len)
 Add TLV data buffer in payload buffer.
 
err_t plugntrust_set_tlv_u8buf_optional (uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint8_t *cmd, uint32_t cmd_len)
 Add TLV data buffer in payload buffer if TLV data buffer length greater then 0.
 
err_t plugntrust_get_tlv_u8 (uint8_t *buf, uint32_t *buf_index, uint8_t tag, uint8_t *rsp)
 Parses TLV data from payload buffer to find data for desired tag.
 
err_t plugntrust_get_tlv_u16 (uint8_t *buf, uint32_t *buf_index, uint8_t tag, uint16_t *rsp)
 Parses TLV data from payload buffer to find data for desired tag.
 
err_t plugntrust_get_tlv_u8buf (uint8_t *buf, uint32_t *buf_index, uint8_t buf_len, uint8_t tag, uint8_t *rsp, uint32_t *rsp_len)
 Parses TLV data from payload buffer to find data for desired tag.
 
uint8_t plugntrust_calculate_apdu_size (plugntrust_apdu_t *apdu_data)
 Calculates APDU object size.
 
err_t plugntrust_end_apdu_session (plugntrust_t *ctx)
 Sends command for ending APDU session.
 
err_t plugntrust_object_id_list (plugntrust_t *ctx, uint32_t *id_list, uint8_t *list_len)
 Reads all Object ID's from Applet.
 
err_t plugntrust_sw_reset (plugntrust_t *ctx, plugntrust_atr_t *atr_data)
 Sends request to reset device and reads ATR data.
 
err_t plugntrust_select_applet (plugntrust_t *ctx, uint8_t ns_encode, plugntrust_version_info_t *ver_info)
 Selects Clicks Applet and returns info that device sends back to host.
 
err_t plugntrust_select_card_manager (plugntrust_t *ctx, uint8_t rsp, uint8_t *cardmanager_rsp, uint8_t *cardmanager_rsp_len)
 Select card manager.
 
err_t plugntrust_get_free_memory (plugntrust_t *ctx, uint8_t memory_type, uint16_t *free_memory)
 Reads Applet free memory.
 
err_t plugntrust_get_random_numbers (plugntrust_t *ctx, uint8_t *random_buf, uint8_t buf_len)
 Get random data.
 
err_t plugntrust_check_object_exist (plugntrust_t *ctx, uint32_t object_id)
 Check if object exists.
 
err_t plugntrust_delete_object (plugntrust_t *ctx, uint32_t object_id)
 Delete object.
 
err_t plugntrust_read_object (plugntrust_t *ctx, uint32_t object_id, uint16_t offset, uint16_t read_len, uint8_t *data_buf, uint32_t *data_len)
 Read object data.
 
err_t plugntrust_write_binary_object (plugntrust_t *ctx, uint32_t object_id, uint16_t offset, uint16_t data_len, uint8_t *data_buf)
 Create/Write to binary object.
 
err_t plugntrust_get_applet_info (plugntrust_t *ctx, plugntrust_version_info_t *ver_info)
 Get Version info from Applet.
 

Detailed Description

API for configuring and manipulating Plug n Trust Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ plugntrust_apdu_read()

err_t plugntrust_apdu_read ( plugntrust_t * ctx,
plugntrust_frame_data_t * frame_data )

Reading frame data function function.

This function reads a frame_data from device.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
[out]frame_data: Communication data. See plugntrust_frame_data_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ plugntrust_apdu_transfer()

err_t plugntrust_apdu_transfer ( plugntrust_t * ctx,
plugntrust_frame_data_t * frame_data )

Write-Read frame data function.

This function writes a frame_data and then reads return data from device and stores it in frame_data.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
[in/out]frame_data : Communication data. See plugntrust_frame_data_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ plugntrust_apdu_write()

err_t plugntrust_apdu_write ( plugntrust_t * ctx,
plugntrust_frame_data_t * frame_data )

Writing frame data function.

This function writes a frame_data to device.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
[in]frame_data: Communication data. See plugntrust_frame_data_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ plugntrust_calculate_apdu_size()

uint8_t plugntrust_calculate_apdu_size ( plugntrust_apdu_t * apdu_data)

Calculates APDU object size.

Goes through apdu object and returns size value of it.

Parameters
[in]apdu_data: APDU object. See plugntrust_apdu_t object definition for detailed explanation.
Returns
Value size of APDU data object
Note
On the start return value is 4[CLA,INS,P1,P2] and then adds payload_len and rsp_len.

◆ plugntrust_cfg_setup()

void plugntrust_cfg_setup ( plugntrust_cfg_t * cfg)

Plug n Trust configuration object setup function.

This function initializes click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See plugntrust_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ plugntrust_check_object_exist()

err_t plugntrust_check_object_exist ( plugntrust_t * ctx,
uint32_t object_id )

Check if object exists.

Sends request to check if object with object_id exists.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
[in]object_id: Object ID.
Returns
  • 1 - Does exists,
  • 2 - Doesn't exist,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Functions plugntrust_select_card_manager and plugntrust_select_applet needs to be called for this function to be successful. At the end of function it calls plugntrust_end_apdu_session function.

◆ plugntrust_default_cfg()

err_t plugntrust_default_cfg ( plugntrust_t * ctx)

Plug n Trust default configuration function.

This function executes a default configuration of Plug n Trust click board.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ plugntrust_delete_object()

err_t plugntrust_delete_object ( plugntrust_t * ctx,
uint32_t object_id )

Delete object.

Sends request to delete object with object_id.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
[in]object_id: Object ID.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Functions plugntrust_select_card_manager and plugntrust_select_applet needs to be called for this function to be successful. At the end of function it calls plugntrust_end_apdu_session function.

◆ plugntrust_end_apdu_session()

err_t plugntrust_end_apdu_session ( plugntrust_t * ctx)

Sends command for ending APDU session.

This function sends SBLOCK request for ending APDU session.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ plugntrust_get_applet_info()

err_t plugntrust_get_applet_info ( plugntrust_t * ctx,
plugntrust_version_info_t * ver_info )

Get Version info from Applet.

Sends request to read version info from Applet.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
[out]ver_info: Version info data. See #ver_info object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Functions plugntrust_select_card_manager and plugntrust_select_applet needs to be called for this function to be successful. At the end of function it calls plugntrust_end_apdu_session function.

◆ plugntrust_get_free_memory()

err_t plugntrust_get_free_memory ( plugntrust_t * ctx,
uint8_t memory_type,
uint16_t * free_memory )

Reads Applet free memory.

Sends request to check free memory of memory_type.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
[in]memory_type: Memory type to check. See #Memory type definition for memory type options.
[out]free_memory: Response buffer.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Functions plugntrust_select_card_manager and plugntrust_select_applet needs to be called for this function to be successful. At the end of function it calls plugntrust_end_apdu_session function.

◆ plugntrust_get_random_numbers()

err_t plugntrust_get_random_numbers ( plugntrust_t * ctx,
uint8_t * random_buf,
uint8_t buf_len )

Get random data.

Sends request to get buff_len of random data.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
[out]random_buf: Buffer to store random data.
[in]buf_len: Length of random buffer data.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Functions plugntrust_select_card_manager and plugntrust_select_applet needs to be called for this function to be successful. At the end of function it calls plugntrust_end_apdu_session function.

◆ plugntrust_get_tlv_u16()

err_t plugntrust_get_tlv_u16 ( uint8_t * buf,
uint32_t * buf_index,
uint8_t tag,
uint16_t * rsp )

Parses TLV data from payload buffer to find data for desired tag.

Searches APDU payload response to find 2 bytes of value for desired tag.

Parameters
[in]buf: Input buffer.
[in/out]buf_index : Buffer index to search from.
[in]tag: Tag of TLV data.
[out]rsp: Value of TLV data.
Returns
  • 0 - Data found,
  • -1 - Data missing. See #err_t definition for detailed explanation.
Note
None.

Example

uint32_t buff_index = 0;
uint16_t value = 0;
plugntrust_get_tlv_u16( frame_data.apdu->payload, &parse_index, PLUGNTRUST_TLV_TAG_1, &value )
#define PLUGNTRUST_TLV_TAG_1
Definition plugntrust.h:297
err_t plugntrust_get_tlv_u16(uint8_t *buf, uint32_t *buf_index, uint8_t tag, uint16_t *rsp)
Parses TLV data from payload buffer to find data for desired tag.

◆ plugntrust_get_tlv_u8()

err_t plugntrust_get_tlv_u8 ( uint8_t * buf,
uint32_t * buf_index,
uint8_t tag,
uint8_t * rsp )

Parses TLV data from payload buffer to find data for desired tag.

Searches APDU payload response to find 1 byte of value for desired tag.

Parameters
[in]buf: Input buffer.
[in/out]buf_index : Buffer index to search from.
[in]tag: Tag of TLV data.
[out]rsp: Value of TLV data.
Returns
  • 0 - Data found,
  • -1 - Data missing. See #err_t definition for detailed explanation.
Note
None.

Example

uint32_t buff_index = 0;
uint8_t value = 0;
plugntrust_get_tlv_u8( frame_data.apdu->payload, &parse_index, PLUGNTRUST_TLV_TAG_1, &value )
err_t plugntrust_get_tlv_u8(uint8_t *buf, uint32_t *buf_index, uint8_t tag, uint8_t *rsp)
Parses TLV data from payload buffer to find data for desired tag.

◆ plugntrust_get_tlv_u8buf()

err_t plugntrust_get_tlv_u8buf ( uint8_t * buf,
uint32_t * buf_index,
uint8_t buf_len,
uint8_t tag,
uint8_t * rsp,
uint32_t * rsp_len )

Parses TLV data from payload buffer to find data for desired tag.

Searches APDU payload response to find 4 bytes of value for desired tag.

Parameters
[in]buf: Input buffer.
[in/out]buf_index : Buffer index to search from.
[in]buf_len: Input buffer length.
[in]tag: Tag of TLV data.
[out]rsp: Buffer of TLV data.
[in/out]rsp_len : Rsp buffer length.
Returns
  • 0 - Data found,
  • -1 - Error parssing data. See #err_t definition for detailed explanation.
Note
None.

Example

uint32_t buff_index = 0;
uint8_t parse_len = 0xFF;
uint8_t data_out[ 0xFF ] = 0;
plugntrust_get_tlv_u8buf( frame_data.apdu->payload, &parse_index, frame_data.len,
PLUGNTRUST_TLV_TAG_1, data_out, &parse_len )
err_t plugntrust_get_tlv_u8buf(uint8_t *buf, uint32_t *buf_index, uint8_t buf_len, uint8_t tag, uint8_t *rsp, uint32_t *rsp_len)
Parses TLV data from payload buffer to find data for desired tag.

◆ plugntrust_init()

err_t plugntrust_init ( plugntrust_t * ctx,
plugntrust_cfg_t * cfg )

Plug n Trust initialization function.

This function initializes all necessary pins and peripherals used for this click board.

Parameters
[out]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See plugntrust_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ plugntrust_object_id_list()

err_t plugntrust_object_id_list ( plugntrust_t * ctx,
uint32_t * id_list,
uint8_t * list_len )

Reads all Object ID's from Applet.

Reads list of all objects from Applet and outputs array of objects ID's.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
[out]id_list: Buffer of Object ID's.
[out]list_len: Length of id_list.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
By default Applet has 26 predefined and reserved objects.

◆ plugntrust_read_object()

err_t plugntrust_read_object ( plugntrust_t * ctx,
uint32_t object_id,
uint16_t offset,
uint16_t read_len,
uint8_t * data_buf,
uint32_t * data_len )

Read object data.

Sends request to read object data of object with object_id.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
[in]object_id: Object ID.
[in]offset: Offset read data OPTIONAL: set 0 if not needed.
[in]read_len: Length to be read OPTIONAL: set 0 to read full data from object.
[out]data_buf: Read data buffer.
[out]data_len: Length of read data bffer.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Functions plugntrust_select_card_manager and plugntrust_select_applet needs to be called for this function to be successful. At the end of function it calls plugntrust_end_apdu_session function.

◆ plugntrust_reset()

void plugntrust_reset ( plugntrust_t * ctx)

Reset function.

Sets en pin to enable selected interface from ctx and then resets device by toggling rst pin.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
Returns
Nothing.
Note
None.

◆ plugntrust_select_applet()

err_t plugntrust_select_applet ( plugntrust_t * ctx,
uint8_t ns_encode,
plugntrust_version_info_t * ver_info )

Selects Clicks Applet and returns info that device sends back to host.

Selects Clicks Applet and returns version info that device sens back to host.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
[in]ns_encode: NS encode of I-Block.
[out]ver_info: Version info data. See plugntrust_version_info_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ plugntrust_select_card_manager()

err_t plugntrust_select_card_manager ( plugntrust_t * ctx,
uint8_t rsp,
uint8_t * cardmanager_rsp,
uint8_t * cardmanager_rsp_len )

Select card manager.

Selects card manager and depending of rsp parameter returns data to host.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
[in]rsp: Request response from card manager.
[out]cardmanager_rsp: Response buffer.
[out]cardmanager_rsp_len: Length of response buffer.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ plugntrust_set_en()

void plugntrust_set_en ( plugntrust_t * ctx,
uint8_t state )

Set Enable pin state.

This function sets en pin state.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
[in]state: Logic state.
Returns
Nothing.
Note
None.

◆ plugntrust_set_rst()

void plugntrust_set_rst ( plugntrust_t * ctx,
uint8_t state )

Set Reset pin state.

This function sets rst pin state.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
[in]state: Logic state.
Returns
Nothing.
Note
None.

◆ plugntrust_set_tlv_u16()

void plugntrust_set_tlv_u16 ( uint8_t * buf,
uint8_t * buf_len,
uint8_t tag,
uint16_t value )

Add TLV data of 2 bytes value in payload buffer.

Concatenates TLV data in APDU payload for writing data to device.

Parameters
[out]buf: Output buffer.
[out]buf_len: Output buffer size, incresed by adding TLV.
[in]tag: Tag of TLV data.
[in]value: Value of TLV data.
Returns
Nothing.
Note
None.

Example

uint16_t offset = 0;
plugntrust_set_tlv_u16( frame_data.apdu->payload, &frame_data.apdu->payload_len,
#define PLUGNTRUST_TLV_TAG_2
Definition plugntrust.h:298
void plugntrust_set_tlv_u16(uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint16_t value)
Add TLV data of 2 bytes value in payload buffer.

◆ plugntrust_set_tlv_u16_optional()

void plugntrust_set_tlv_u16_optional ( uint8_t * buf,
uint8_t * buf_len,
uint8_t tag,
uint16_t value )

Add TLV data of 2 bytes value in payload buffer if value is greater then 0.

Calls plugntrust_set_tlv_u16 if value parameter is greater then 0.

Parameters
[out]buf: Output buffer.
[out]buf_len: Output buffer size, incresed by adding TLV.
[in]tag: Tag of TLV data.
[in]value: Value of TLV data.
Returns
Nothing.
Note
None.

Example

uint16_t offset = 10;
plugntrust_set_tlv_u16_optional( frame_data.apdu->payload, &frame_data.apdu->payload_len,
void plugntrust_set_tlv_u16_optional(uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint16_t value)
Add TLV data of 2 bytes value in payload buffer if value is greater then 0.

◆ plugntrust_set_tlv_u32()

void plugntrust_set_tlv_u32 ( uint8_t * buf,
uint8_t * buf_len,
uint8_t tag,
uint32_t value )

Add TLV data of 4 bytes value in payload buffer.

Concatenates TLV data in APDU payload for writing data to device.

Parameters
[out]buf: Output buffer.
[out]buf_len: Output buffer size, incresed by adding TLV.
[in]tag: Tag of TLV data.
[in]value: Value of TLV data.
Returns
Nothing.
Note
None.

Example

uint32_t object_id = 0x12345678;
plugntrust_set_tlv_u32( frame_data.apdu->payload, &frame_data.apdu->payload_len,
PLUGNTRUST_TLV_TAG_1, object_id );
void plugntrust_set_tlv_u32(uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint32_t value)
Add TLV data of 4 bytes value in payload buffer.

◆ plugntrust_set_tlv_u8()

void plugntrust_set_tlv_u8 ( uint8_t * buf,
uint8_t * buf_len,
uint8_t tag,
uint8_t value )

Add TLV data of 1 byte value in payload buffer.

Concatenates TLV data in APDU payload for writing data to device.

Parameters
[out]buf: Output buffer.
[out]buf_len: Output buffer size, incresed by adding TLV.
[in]tag: Tag of TLV data.
[in]value: Value of TLV data.
Returns
Nothing.
Note
None.

Example

plugntrust_set_tlv_u8( frame_data.apdu->payload, &frame_data.apdu->payload_len,
#define PLUGNTRUST_MEM_PERSISTENT
Memory type.
Definition plugntrust.h:276
void plugntrust_set_tlv_u8(uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint8_t value)
Add TLV data of 1 byte value in payload buffer.

◆ plugntrust_set_tlv_u8buf()

err_t plugntrust_set_tlv_u8buf ( uint8_t * buf,
uint8_t * buf_len,
uint8_t tag,
uint8_t * cmd,
uint32_t cmd_len )

Add TLV data buffer in payload buffer.

Concatenates TLV data in APDU payload for writing data to device.

Parameters
[out]buf: Output buffer.
[out]buf_len: Output buffer size, incresed by adding TLV.
[in]tag: Tag of TLV data.
[in]cmd: TLV data buffer.
[in]cmd_len: TLV data buffer length.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

Example

#define AES_KEY_SIZE 16
uint8_t aes_key[ AES_KEY_SIZE ] = { 0 }
plugntrust_set_tlv_u8buf( frame_data.apdu->payload, &frame_data.apdu->payload_len,
#define PLUGNTRUST_TLV_TAG_3
Definition plugntrust.h:299
err_t plugntrust_set_tlv_u8buf(uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint8_t *cmd, uint32_t cmd_len)
Add TLV data buffer in payload buffer.
#define AES_KEY_SIZE

◆ plugntrust_set_tlv_u8buf_optional()

err_t plugntrust_set_tlv_u8buf_optional ( uint8_t * buf,
uint8_t * buf_len,
uint8_t tag,
uint8_t * cmd,
uint32_t cmd_len )

Add TLV data buffer in payload buffer if TLV data buffer length greater then 0.

Calls plugntrust_set_tlv_u8buf if cmd_len parameter is greater then 0.

Parameters
[out]buf: Output buffer.
[out]buf_len: Output buffer size, incresed by adding TLV.
[in]tag: Tag of TLV data.
[in]cmd: TLV data buffer.
[in]cmd_len: TLV data buffer length.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

Example

#define AES_KEY_SIZE 16
uint8_t aes_key[ AES_KEY_SIZE ] = { 0 }
plugntrust_set_tlv_u8buf_optional( frame_data.apdu->payload, &frame_data.apdu->payload_len,
err_t plugntrust_set_tlv_u8buf_optional(uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint8_t *cmd, uint32_t cmd_len)
Add TLV data buffer in payload buffer if TLV data buffer length greater then 0.

◆ plugntrust_sw_reset()

err_t plugntrust_sw_reset ( plugntrust_t * ctx,
plugntrust_atr_t * atr_data )

Sends request to reset device and reads ATR data.

Sends request to reset device and parses and returns ATR data.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
[out]atr_data: Output data after reset. See plugntrust_atr_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ plugntrust_write_binary_object()

err_t plugntrust_write_binary_object ( plugntrust_t * ctx,
uint32_t object_id,
uint16_t offset,
uint16_t data_len,
uint8_t * data_buf )

Create/Write to binary object.

If binary object with object_id exist function will write data_buf to it. If binary object doesn't exist it will be created and then data will be written.

Parameters
[in]ctx: Click context object. See plugntrust_t object definition for detailed explanation.
[in]object_id: Object ID.
[in]offset: Offset of data to be written.
[in]data_len: Length of data to be written to binary object.
[in]data_buf: Buffer of data to be written to binary object.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Functions plugntrust_select_card_manager and plugntrust_select_applet needs to be called for this function to be successful. At the end of function it calls plugntrust_end_apdu_session function.