Use macros for referring system fids.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2024-04-17 19:43:10 +02:00
parent 25c93c279f
commit 8e8192362c
No known key found for this signature in database
GPG Key ID: C0095B7870A4CCD3
4 changed files with 20 additions and 14 deletions

View File

@ -77,7 +77,7 @@ int cmd_initialize() {
}
}
else if (tag == 0x91) { //retries user pin
file_t *tf = search_file(0x1082);
file_t *tf = search_file(EF_PIN1_MAX_RETRIES);
if (tf && tf->data) {
file_put_data(tf, tag_data, tag_len);
}

View File

@ -41,22 +41,22 @@ file_t file_entries[] = {
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0 } }, //EF.TokenInfo
/* 8 */ { .fid = 0x5033, .parent = 0, .name = NULL, .type = FILE_TYPE_WORKING_EF, .data = NULL,
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0 } }, //EF.UnusedSpace
/* 9 */ { .fid = 0x1081, .parent = 5, .name = NULL,
/* 9 */ { .fid = EF_PIN1, .parent = 5, .name = NULL,
.type = FILE_TYPE_INTERNAL_EF | FILE_DATA_FLASH, .data = NULL,
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0xff } }, //PIN (PIN1)
/* 10 */ { .fid = 0x1082, .parent = 5, .name = NULL,
/* 10 */ { .fid = EF_PIN1_MAX_RETRIES, .parent = 5, .name = NULL,
.type = FILE_TYPE_INTERNAL_EF | FILE_DATA_FLASH, .data = NULL,
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0xff } }, //max retries PIN (PIN1)
/* 11 */ { .fid = 0x1083, .parent = 5, .name = NULL,
/* 11 */ { .fid = EF_PIN1_RETRIES, .parent = 5, .name = NULL,
.type = FILE_TYPE_INTERNAL_EF | FILE_DATA_FLASH, .data = NULL,
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0xff } }, //retries PIN (PIN1)
/* 12 */ { .fid = 0x1088, .parent = 5, .name = NULL,
/* 12 */ { .fid = EF_SOPIN, .parent = 5, .name = NULL,
.type = FILE_TYPE_INTERNAL_EF | FILE_DATA_FLASH, .data = NULL,
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0xff } }, //PIN (SOPIN)
/* 13 */ { .fid = 0x1089, .parent = 5, .name = NULL,
/* 13 */ { .fid = EF_SOPIN_MAX_RETRIES, .parent = 5, .name = NULL,
.type = FILE_TYPE_INTERNAL_EF | FILE_DATA_FLASH, .data = NULL,
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0xff } }, //max retries PIN (SOPIN)
/* 14 */ { .fid = 0x108A, .parent = 5, .name = NULL,
/* 14 */ { .fid = EF_SOPIN_RETRIES, .parent = 5, .name = NULL,
.type = FILE_TYPE_INTERNAL_EF | FILE_DATA_FLASH, .data = NULL,
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0xff } }, //retries PIN (SOPIN)
/* 15 */ { .fid = EF_DEVOPS, .parent = 5, .name = NULL,

View File

@ -24,7 +24,13 @@
#define EF_DEVOPS 0x100E
#define EF_MKEK 0x100A
#define EF_MKEK_SO 0x100B
#define EF_XKEK 0x1080
#define EF_XKEK 0x1070
#define EF_PIN1 0x1081
#define EF_PIN1_MAX_RETRIES 0x1082
#define EF_PIN1_RETRIES 0x1083
#define EF_SOPIN 0x1088
#define EF_SOPIN_MAX_RETRIES 0x1089
#define EF_SOPIN_RETRIES 0x108A
#define EF_DKEK 0x1090
#define EF_KEY_DOMAIN 0x10A0
#define EF_PUKAUT 0x10C0

View File

@ -94,7 +94,7 @@ INITIALIZER( sc_hsm_ctor ) {
}
void scan_files() {
file_pin1 = search_file(0x1081);
file_pin1 = search_file(EF_PIN1);
if (file_pin1) {
if (!file_pin1->data) {
printf("PIN1 is empty. Initializing with default password\n");
@ -105,7 +105,7 @@ void scan_files() {
else {
printf("FATAL ERROR: PIN1 not found in memory!\n");
}
file_sopin = search_file(0x1088);
file_sopin = search_file(EF_SOPIN);
if (file_sopin) {
if (!file_sopin->data) {
printf("SOPIN is empty. Initializing with default password\n");
@ -116,7 +116,7 @@ void scan_files() {
else {
printf("FATAL ERROR: SOPIN not found in memory!\n");
}
file_retries_pin1 = search_file(0x1083);
file_retries_pin1 = search_file(EF_PIN1_RETRIES);
if (file_retries_pin1) {
if (!file_retries_pin1->data) {
printf("Retries PIN1 is empty. Initializing with default retriesr\n");
@ -127,7 +127,7 @@ void scan_files() {
else {
printf("FATAL ERROR: Retries PIN1 not found in memory!\n");
}
file_retries_sopin = search_file(0x108A);
file_retries_sopin = search_file(EF_SOPIN_RETRIES);
if (file_retries_sopin) {
if (!file_retries_sopin->data) {
printf("Retries SOPIN is empty. Initializing with default retries\n");
@ -140,7 +140,7 @@ void scan_files() {
}
file_t *tf = NULL;
tf = search_file(0x1082);
tf = search_file(EF_PIN1_MAX_RETRIES);
if (tf) {
if (!tf->data) {
printf("Max retries PIN1 is empty. Initializing with default max retriesr\n");
@ -151,7 +151,7 @@ void scan_files() {
else {
printf("FATAL ERROR: Max Retries PIN1 not found in memory!\n");
}
tf = search_file(0x1089);
tf = search_file(EF_SOPIN_MAX_RETRIES);
if (tf) {
if (!tf->data) {
printf("Max Retries SOPIN is empty. Initializing with default max retries\n");