From 5e257729a3b77505c3a79fb3caede1ed26b1edad Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Fri, 3 Feb 2023 19:17:42 +0100 Subject: [PATCH] Some fixes. Signed-off-by: Pol Henarejos --- src/openpgp/openpgp.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/openpgp/openpgp.c b/src/openpgp/openpgp.c index d51166b..680a7d6 100644 --- a/src/openpgp/openpgp.c +++ b/src/openpgp/openpgp.c @@ -256,6 +256,14 @@ void scan_files() { flash_write_data_to_file(ef, def, sizeof(def)); } } + + if ((ef = search_by_fid(EF_SEX, NULL, SPECIFY_ANY))) { + if (!ef->data) { + printf("Sex is empty. Initializing to default\r\n"); + const uint8_t def[] = { 0x30 }; + flash_write_data_to_file(ef, def, sizeof(def)); + } + } low_flash_available(); } @@ -346,6 +354,7 @@ app_t *openpgp_select_aid(app_t *a, const uint8_t *aid, uint8_t aid_len) { res_APDU[res_APDU_size++] = ((heap_left >> 8) & 0xff); res_APDU[res_APDU_size++] = ((heap_left >> 0) & 0xff); res_APDU[1] += 8; + apdu.ne = res_APDU_size; return a; } return NULL; @@ -1163,8 +1172,8 @@ static int cmd_keypair_gen() { return SW_WRONG_DATA(); file_t *algo_ef = search_by_fid(fid-0x0010, NULL, SPECIFY_EF); - if (!algo_ef) - return SW_REFERENCE_NOT_FOUND(); + //if (!algo_ef) + // return SW_REFERENCE_NOT_FOUND(); const uint8_t *algo = algorithm_attr_rsa2k+1; uint16_t algo_len = algorithm_attr_rsa2k[0]; if (algo_ef && algo_ef->data) {