From 7d4024a2cb4f38c3c2185dc6ebaf485d7eef05a6 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Sat, 23 Apr 2022 20:46:10 +0200 Subject: [PATCH] Added INS GET CHALLENGE. Signed-off-by: Pol Henarejos --- src/openpgp/openpgp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/openpgp/openpgp.c b/src/openpgp/openpgp.c index 16f9ff5..bdcd9da 100644 --- a/src/openpgp/openpgp.c +++ b/src/openpgp/openpgp.c @@ -1091,6 +1091,15 @@ static int cmd_activate_file() { return SW_OK(); } +static int cmd_challenge() { + uint8_t *rb = (uint8_t *)random_bytes_get(apdu.expected_res_size); + if (!rb) + return SW_WRONG_LENGTH(); + memcpy(res_APDU, rb, apdu.expected_res_size); + res_APDU_size = apdu.expected_res_size; + return SW_OK(); +} + typedef struct cmd { uint8_t ins; @@ -1102,6 +1111,7 @@ typedef struct cmd #define INS_PSO_SIG 0x2A #define INS_RESET_RETRY 0x2C #define INS_ACTIVATE_FILE 0x44 +#define INS_CHALLENGE 0x84 #define INS_KEYPAIR_GEN 0x47 #define INS_SELECT 0xA4 #define INS_GET_DATA 0xCA @@ -1119,6 +1129,7 @@ static const cmd_t cmds[] = { { INS_PSO_SIG, cmd_pso_sig }, { INS_TERMINATE_DF, cmd_terminate_df }, { INS_ACTIVATE_FILE, cmd_activate_file }, + { INS_CHALLENGE, cmd_challenge }, { 0x00, 0x0} };