hsw-nbt 1.2.0
OPTIGA Authenticate NBT Host Library for C
Macros | Enumerations | Functions
nbt-cmd-perso.h File Reference

Collection of the NBT personalization commands. More...

#include "infineon/ifx-utils.h"
#include "infineon/nbt-apdu-lib.h"
#include "infineon/nbt-apdu.h"

Go to the source code of this file.

Macros

#define NBT_FINALIZE_PERSONALIZATION   UINT8_C(0x01)
 Identifier for command finalize personalization.
 
#define NBT_PERSONALIZE_DATA   UINT8_C(0x02)
 Identifier for command personalize data.
 
#define NBT_BACKEND_TEST   UINT8_C(0x03)
 Identifier for command to perform backend test.
 
#define NBT_BACKEND_TEST_DISABLE   UINT8_C(0x04)
 Identifier for command to disable backend test.
 

Enumerations

enum  nbt_personalize_data_dgi {
  NBT_DGI_A001 = UINT16_C(0xA001) , NBT_DGI_A002 = UINT16_C(0xA002) , NBT_DGI_A003 = UINT16_C(0xA003) , NBT_DGI_E104 = UINT16_C(0xE104) ,
  NBT_DGI_E1A1 = UINT16_C(0xE1A1) , NBT_DGI_E1A2 = UINT16_C(0xE1A2) , NBT_DGI_E1A3 = UINT16_C(0xE1A3) , NBT_DGI_E1A4 = UINT16_C(0xE1A4) ,
  NBT_DGI_E1AF = UINT16_C(0xE1AF) , NBT_DGI_BF63 = UINT16_C(0xBF63)
}
 Enumeration stores data group identifier (DGI) for personalize data command. More...
 
enum  nbt_backend_test_request {
  NBT_BACKEND_TEST_RANDOM_NUM_GENERATION = (1 << 0) , NBT_BACKEND_TEST_ECDSA_SIGN = (1 << 1) , NBT_BACKEND_TEST_PUBLIC_KEY_EXTRACTION_FROM_CERT = (1 << 2) , NBT_BACKEND_TEST_ECDSA_VERIFY = (1 << 3) ,
  NBT_BACKEND_TEST_UID_EXTRACTION_FROM_CERT = (1 << 4) , NBT_BACKEND_TEST_UID_COMPARISON = (1 << 5) , NBT_BACKEND_TEST_COTT_COMPUTATION = (1 << 6) , NBT_BACKEND_TEST_ALL = 0x7F
}
 Enumeration holds the bitmaps to perform backend tests. More...
 

Functions

ifx_status_t nbt_finalize_personalization (nbt_cmd_t *self)
 Issues finalize personalization command. Personalization is considered completed after successful execution of finalize personalization. On successful processing of this command, the applet transitions from the 'personalization' state to the 'operational state'. Refer the PERSONALIZE_DATA command section in the datasheet to know the possible DGI and the data fields to be used.
 
ifx_status_t nbt_personalize_data (nbt_cmd_t *self, uint16_t dgi, const ifx_blob_t *dgi_data)
 Issues personalize data command to personalize the data elements of the applet. Applet personalization consists of storing data in the applet as standard elementary files and personalizing proprietary key data objects using the personalize data command.
 
ifx_status_t nbt_backend_test (nbt_cmd_t *self, uint8_t test_request)
 Issues backend test command to perform the requested backend tests.
 
ifx_status_t nbt_backend_test_disable (nbt_cmd_t *self)
 Issues backend test command that permanently disables the backend test support in the chip.
 

Detailed Description

Collection of the NBT personalization commands.

Definition in file nbt-cmd-perso.h.

Macro Definition Documentation

◆ NBT_BACKEND_TEST

#define NBT_BACKEND_TEST   UINT8_C(0x03)

Identifier for command to perform backend test.

Definition at line 34 of file nbt-cmd-perso.h.

◆ NBT_BACKEND_TEST_DISABLE

#define NBT_BACKEND_TEST_DISABLE   UINT8_C(0x04)

Identifier for command to disable backend test.

Definition at line 39 of file nbt-cmd-perso.h.

◆ NBT_FINALIZE_PERSONALIZATION

#define NBT_FINALIZE_PERSONALIZATION   UINT8_C(0x01)

Identifier for command finalize personalization.

Definition at line 24 of file nbt-cmd-perso.h.

◆ NBT_PERSONALIZE_DATA

#define NBT_PERSONALIZE_DATA   UINT8_C(0x02)

Identifier for command personalize data.

Definition at line 29 of file nbt-cmd-perso.h.

Enumeration Type Documentation

◆ nbt_backend_test_request

Enumeration holds the bitmaps to perform backend tests.

Definition at line 81 of file nbt-cmd-perso.h.

82{
83 /* Backend Test - Random number generation */
84 NBT_BACKEND_TEST_RANDOM_NUM_GENERATION = (1 << 0),
85
86 /* Backend Test - ECDSA sign */
87 NBT_BACKEND_TEST_ECDSA_SIGN = (1 << 1),
88
89 /* Backend Test - Public key extraction from certificate */
90 NBT_BACKEND_TEST_PUBLIC_KEY_EXTRACTION_FROM_CERT = (1 << 2),
91
92 /* Backend Test - ECDSA verification */
93 NBT_BACKEND_TEST_ECDSA_VERIFY = (1 << 3),
94
95 /* Backend Test - UID Extraction from Certificate */
96 NBT_BACKEND_TEST_UID_EXTRACTION_FROM_CERT = (1 << 4),
97
98 /* Backend Test - UID comparison */
99 NBT_BACKEND_TEST_UID_COMPARISON = (1 << 5),
100
101 /* Backend Test - COTT computation */
102 NBT_BACKEND_TEST_COTT_COMPUTATION = (1 << 6),
103
104 /* Backend Test - Enable all */
105 NBT_BACKEND_TEST_ALL = 0x7F,
nbt_backend_test_request
Enumeration holds the bitmaps to perform backend tests.

◆ nbt_personalize_data_dgi

Enumeration stores data group identifier (DGI) for personalize data command.

Definition at line 45 of file nbt-cmd-perso.h.

46{
47 /* DGI for personalize AES COTT key */
48 NBT_DGI_A001 = UINT16_C(0xA001),
49
50 /* DGI for personalize ECC key */
51 NBT_DGI_A002 = UINT16_C(0xA002),
52
53 /* DGI for personalize password data */
54 NBT_DGI_A003 = UINT16_C(0xA003),
55
56 /* DGI for personalize NDEF file content */
57 NBT_DGI_E104 = UINT16_C(0xE104),
58
59 /* DGI for personalize proprietary files (E1A1) content */
60 NBT_DGI_E1A1 = UINT16_C(0xE1A1),
61
62 /* DGI for personalize proprietary files (E1A2) content */
63 NBT_DGI_E1A2 = UINT16_C(0xE1A2),
64
65 /* DGI for personalize proprietary files (E1A3) content */
66 NBT_DGI_E1A3 = UINT16_C(0xE1A3),
67
68 /* DGI for personalize proprietary files (E1A4) content */
69 NBT_DGI_E1A4 = UINT16_C(0xE1A4),
70
71 /* DGI for personalize configuration data (File access policy) */
72 NBT_DGI_E1AF = UINT16_C(0xE1AF),
73
74 /* DGI for finalize personalization command */
75 NBT_DGI_BF63 = UINT16_C(0xBF63)
nbt_personalize_data_dgi
Enumeration stores data group identifier (DGI) for personalize data command.

Function Documentation

◆ nbt_backend_test()

ifx_status_t nbt_backend_test ( nbt_cmd_t * self,
uint8_t test_request )

Issues backend test command to perform the requested backend tests.

Parameters
[in,out]selfCommand set with communication protocol and response.
[in]test_request8-bit field to request the backend tests to perform.
Note
Set respective bit(s) of test_request parameter to request which test(s) to perform

| Bit 0 | Random number generation | | Bit 1 | ECDSA sign | | Bit 2 | Public key extraction from certificate | | Bit 3 | ECDSA verify | | Bit 4 | UID extraction from certificate | | Bit 5 | UID comparison | | Bit 6 | COTT computation | | Bit 7 | RFU (ignored) |

For example, to run ECDSA sign and ECDSA verify tests, set test_request variable to NBT_BACKEND_TEST_ECDSA_SIGN|NBT_BACKEND_TEST_ECDSA_VERIFY. Use bit map combinations from nbt_backend_test_request to request specific backend tests. 7F(OR combination of all 7 tests) is the value of the test_request_bitmap to request all tests to be performed and the expected returned test_result_bitmap is 7F, i.e. is all tests performed successfully.

C-APDU: 00 BE 00 7F (Enable all tests) Expected R-APDU: 90 00 7F (7F is returned test_result bitmap in response data if all tests are performed successfully

If the backend test command has been deactivated, response as (NBT_CLA/INS) does not exist is sent. This command is not needed on NFC interface, as the back end testing is performed via I2C.

Returns
ifx_status_t
Return values
IFX_SUCCESS: If API operation is successful
IFX_ILLEGAL_ARGUMENT: If invalid/NULL parameter is passed to function
IFX_OUT_OF_MEMORY: If any memory allocation fails

◆ nbt_backend_test_disable()

ifx_status_t nbt_backend_test_disable ( nbt_cmd_t * self)

Issues backend test command that permanently disables the backend test support in the chip.

Warning
This command permanently disable the backend test support and cannot be enabled again.
Parameters
[in,out]selfCommand set with communication protocol and response.
Returns
ifx_status_t
Return values
IFX_SUCCESS: If API operation is successful
IFX_ILLEGAL_ARGUMENT: If invalid/NULL parameter is passed to function
IFX_OUT_OF_MEMORY: If any memory allocation fails

◆ nbt_finalize_personalization()

ifx_status_t nbt_finalize_personalization ( nbt_cmd_t * self)

Issues finalize personalization command. Personalization is considered completed after successful execution of finalize personalization. On successful processing of this command, the applet transitions from the 'personalization' state to the 'operational state'. Refer the PERSONALIZE_DATA command section in the datasheet to know the possible DGI and the data fields to be used.

Parameters
[in,out]selfCommand set with communication protocol and response.
Returns
ifx_status_t
Return values
IFX_SUCCESS: If API operation is successful
IFX_ILLEGAL_ARGUMENT: If invalid/NULL parameter is passed to function

◆ nbt_personalize_data()

ifx_status_t nbt_personalize_data ( nbt_cmd_t * self,
uint16_t dgi,
const ifx_blob_t * dgi_data )

Issues personalize data command to personalize the data elements of the applet. Applet personalization consists of storing data in the applet as standard elementary files and personalizing proprietary key data objects using the personalize data command.

Parameters
[in,out]selfCommand set with communication protocol and response.
[in]dgiData group identifier (DGI) value
[in]dgi_dataPointer to the data field of the respective DGI. (Example: AES COTT Key, ECC Key, and NDEF file content)
Returns
ifx_status_t
Return values
IFX_SUCCESS: If API operation is successful
IFX_ILLEGAL_ARGUMENT: If invalid/NULL parameter is passed to function