From c28852d0ea2680cb88645020d0426617a686af76 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Tue, 13 Aug 2024 17:05:35 +0200 Subject: [PATCH] Fix return metadata for PIN/PUK. Signed-off-by: Pol Henarejos --- src/openpgp/piv.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/openpgp/piv.c b/src/openpgp/piv.c index 6ab1467..5399e17 100644 --- a/src/openpgp/piv.c +++ b/src/openpgp/piv.c @@ -529,8 +529,13 @@ static int cmd_get_metadata() { return SW_REFERENCE_NOT_FOUND(); } uint8_t retries = *(file_get_data(pw_status) + 3 + (key_ref & 0xf)); + if (!(pw_status = search_by_fid(EF_PW_RETRIES, NULL, SPECIFY_EF))) { + return SW_REFERENCE_NOT_FOUND(); + } + uint8_t total = *(file_get_data(pw_status) + (key_ref & 0xf)); res_APDU[res_APDU_size++] = 0x6; - res_APDU[res_APDU_size++] = 1; + res_APDU[res_APDU_size++] = 2; + res_APDU[res_APDU_size++] = total; res_APDU[res_APDU_size++] = retries; } }