Skip to content

Commit 8e81923

Browse files
committed
Use macros for referring system fids.
Signed-off-by: Pol Henarejos <[email protected]>
1 parent 25c93c2 commit 8e81923

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

src/hsm/cmd_initialize.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ int cmd_initialize() {
7777
}
7878
}
7979
else if (tag == 0x91) { //retries user pin
80-
file_t *tf = search_file(0x1082);
80+
file_t *tf = search_file(EF_PIN1_MAX_RETRIES);
8181
if (tf && tf->data) {
8282
file_put_data(tf, tag_data, tag_len);
8383
}

src/hsm/files.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,22 @@ file_t file_entries[] = {
4141
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0 } }, //EF.TokenInfo
4242
/* 8 */ { .fid = 0x5033, .parent = 0, .name = NULL, .type = FILE_TYPE_WORKING_EF, .data = NULL,
4343
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0 } }, //EF.UnusedSpace
44-
/* 9 */ { .fid = 0x1081, .parent = 5, .name = NULL,
44+
/* 9 */ { .fid = EF_PIN1, .parent = 5, .name = NULL,
4545
.type = FILE_TYPE_INTERNAL_EF | FILE_DATA_FLASH, .data = NULL,
4646
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0xff } }, //PIN (PIN1)
47-
/* 10 */ { .fid = 0x1082, .parent = 5, .name = NULL,
47+
/* 10 */ { .fid = EF_PIN1_MAX_RETRIES, .parent = 5, .name = NULL,
4848
.type = FILE_TYPE_INTERNAL_EF | FILE_DATA_FLASH, .data = NULL,
4949
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0xff } }, //max retries PIN (PIN1)
50-
/* 11 */ { .fid = 0x1083, .parent = 5, .name = NULL,
50+
/* 11 */ { .fid = EF_PIN1_RETRIES, .parent = 5, .name = NULL,
5151
.type = FILE_TYPE_INTERNAL_EF | FILE_DATA_FLASH, .data = NULL,
5252
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0xff } }, //retries PIN (PIN1)
53-
/* 12 */ { .fid = 0x1088, .parent = 5, .name = NULL,
53+
/* 12 */ { .fid = EF_SOPIN, .parent = 5, .name = NULL,
5454
.type = FILE_TYPE_INTERNAL_EF | FILE_DATA_FLASH, .data = NULL,
5555
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0xff } }, //PIN (SOPIN)
56-
/* 13 */ { .fid = 0x1089, .parent = 5, .name = NULL,
56+
/* 13 */ { .fid = EF_SOPIN_MAX_RETRIES, .parent = 5, .name = NULL,
5757
.type = FILE_TYPE_INTERNAL_EF | FILE_DATA_FLASH, .data = NULL,
5858
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0xff } }, //max retries PIN (SOPIN)
59-
/* 14 */ { .fid = 0x108A, .parent = 5, .name = NULL,
59+
/* 14 */ { .fid = EF_SOPIN_RETRIES, .parent = 5, .name = NULL,
6060
.type = FILE_TYPE_INTERNAL_EF | FILE_DATA_FLASH, .data = NULL,
6161
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0xff } }, //retries PIN (SOPIN)
6262
/* 15 */ { .fid = EF_DEVOPS, .parent = 5, .name = NULL,

src/hsm/files.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@
2424
#define EF_DEVOPS 0x100E
2525
#define EF_MKEK 0x100A
2626
#define EF_MKEK_SO 0x100B
27-
#define EF_XKEK 0x1080
27+
#define EF_XKEK 0x1070
28+
#define EF_PIN1 0x1081
29+
#define EF_PIN1_MAX_RETRIES 0x1082
30+
#define EF_PIN1_RETRIES 0x1083
31+
#define EF_SOPIN 0x1088
32+
#define EF_SOPIN_MAX_RETRIES 0x1089
33+
#define EF_SOPIN_RETRIES 0x108A
2834
#define EF_DKEK 0x1090
2935
#define EF_KEY_DOMAIN 0x10A0
3036
#define EF_PUKAUT 0x10C0

src/hsm/sc_hsm.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ INITIALIZER( sc_hsm_ctor ) {
9494
}
9595

9696
void scan_files() {
97-
file_pin1 = search_file(0x1081);
97+
file_pin1 = search_file(EF_PIN1);
9898
if (file_pin1) {
9999
if (!file_pin1->data) {
100100
printf("PIN1 is empty. Initializing with default password\n");
@@ -105,7 +105,7 @@ void scan_files() {
105105
else {
106106
printf("FATAL ERROR: PIN1 not found in memory!\n");
107107
}
108-
file_sopin = search_file(0x1088);
108+
file_sopin = search_file(EF_SOPIN);
109109
if (file_sopin) {
110110
if (!file_sopin->data) {
111111
printf("SOPIN is empty. Initializing with default password\n");
@@ -116,7 +116,7 @@ void scan_files() {
116116
else {
117117
printf("FATAL ERROR: SOPIN not found in memory!\n");
118118
}
119-
file_retries_pin1 = search_file(0x1083);
119+
file_retries_pin1 = search_file(EF_PIN1_RETRIES);
120120
if (file_retries_pin1) {
121121
if (!file_retries_pin1->data) {
122122
printf("Retries PIN1 is empty. Initializing with default retriesr\n");
@@ -127,7 +127,7 @@ void scan_files() {
127127
else {
128128
printf("FATAL ERROR: Retries PIN1 not found in memory!\n");
129129
}
130-
file_retries_sopin = search_file(0x108A);
130+
file_retries_sopin = search_file(EF_SOPIN_RETRIES);
131131
if (file_retries_sopin) {
132132
if (!file_retries_sopin->data) {
133133
printf("Retries SOPIN is empty. Initializing with default retries\n");
@@ -140,7 +140,7 @@ void scan_files() {
140140
}
141141
file_t *tf = NULL;
142142

143-
tf = search_file(0x1082);
143+
tf = search_file(EF_PIN1_MAX_RETRIES);
144144
if (tf) {
145145
if (!tf->data) {
146146
printf("Max retries PIN1 is empty. Initializing with default max retriesr\n");
@@ -151,7 +151,7 @@ void scan_files() {
151151
else {
152152
printf("FATAL ERROR: Max Retries PIN1 not found in memory!\n");
153153
}
154-
tf = search_file(0x1089);
154+
tf = search_file(EF_SOPIN_MAX_RETRIES);
155155
if (tf) {
156156
if (!tf->data) {
157157
printf("Max Retries SOPIN is empty. Initializing with default max retries\n");

0 commit comments

Comments
 (0)