Add EF.DIR list aid.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2024-06-28 22:59:52 +02:00
parent 5630043a4d
commit 0c2e728c35
No known key found for this signature in database
GPG key ID: C0095B7870A4CCD3
2 changed files with 21 additions and 1 deletions

View file

@ -19,11 +19,12 @@
extern const uint8_t sc_hsm_aid[];
extern int parse_token_info(const file_t *f, int mode);
extern int parse_ef_dir(const file_t *f, int mode);
file_t file_entries[] = {
/* 0 */ { .fid = 0x3f00, .parent = 0xff, .name = NULL, .type = FILE_TYPE_DF, .data = NULL,
.ef_structure = 0, .acl = { 0 } }, // MF
/* 1 */ { .fid = 0x2f00, .parent = 0, .name = NULL, .type = FILE_TYPE_WORKING_EF, .data = NULL,
/* 1 */ { .fid = 0x2f00, .parent = 0, .name = NULL, .type = FILE_TYPE_WORKING_EF | FILE_DATA_FUNC, .data = (uint8_t *) parse_ef_dir,
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0 } }, //EF.DIR
/* 2 */ { .fid = 0x2f01, .parent = 0, .name = NULL, .type = FILE_TYPE_WORKING_EF, .data = NULL,
.ef_structure = FILE_EF_TRANSPARENT, .acl = { 0 } }, //EF.ATR

View file

@ -314,6 +314,25 @@ int parse_token_info(const file_t *f, int mode) {
return (int)(2 + (2 + 1) + (2 + 8) + (2 + strlen(manu)) + (2 + strlen(label)) + (2 + 2));
}
int parse_ef_dir(const file_t *f, int mode) {
(void)f;
#ifdef __FOR_CI
char *label = "SmartCard-HSM";
#else
char *label = "Pico-HSM";
#endif
if (mode == 1) {
uint8_t *p = res_APDU;
*p++ = 0x61;
*p++ = 0; //set later
*p++ = 0x4F; *p++ = sc_hsm_aid[0]; memcpy(p, sc_hsm_aid + 1, sc_hsm_aid[0]); p += sc_hsm_aid[0];
*p++ = 0x50; *p++ = (uint8_t)strlen(label); strcpy((char *) p, label); p += strlen(label);
res_APDU_size = (uint16_t)(p - res_APDU);
res_APDU[1] = (uint8_t)res_APDU_size - 2;
}
return (int)(2 + (2 + sc_hsm_aid[0]) + (2 + strlen(label)));
}
int pin_reset_retries(const file_t *pin, bool force) {
if (!pin) {
return CCID_ERR_NULL_PARAM;