From d96bbb9b4be69410ad960e24b377f04dd3e16ec1 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Thu, 14 Mar 2024 23:22:19 +0100 Subject: [PATCH] Use new asn1 structs. Signed-off-by: Pol Henarejos --- pico-keys-sdk | 2 +- src/openpgp/files.c | 2 +- src/openpgp/openpgp.c | 8 ++++---- src/openpgp/openpgp.h | 4 ++++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pico-keys-sdk b/pico-keys-sdk index 4d77ca7..151ae5f 160000 --- a/pico-keys-sdk +++ b/pico-keys-sdk @@ -1 +1 @@ -Subproject commit 4d77ca7b75eff04bd401208054a83857844ecca4 +Subproject commit 151ae5fae4c5815042fce5d5cbcc06d76561dc9c diff --git a/src/openpgp/files.c b/src/openpgp/files.c index 4a7f09c..5ea38bd 100644 --- a/src/openpgp/files.c +++ b/src/openpgp/files.c @@ -476,7 +476,7 @@ file_t file_entries[] = { /* 131 */ { .fid = 0x0000, .parent = 0, .name = openpgp_aid, .type = FILE_TYPE_WORKING_EF, .data = NULL, .ef_structure = FILE_EF_TRANSPARENT, .acl = ACL_RO }, - /* 132 */ { .fid = 0x0000, .parent = 0xff, .name = NULL, .type = FILE_TYPE_UNKNOWN, .data = NULL, + /* 132 */ { .fid = 0x0000, .parent = 0xff, .name = NULL, .type = FILE_TYPE_NOT_KNOWN, .data = NULL, .ef_structure = 0, .acl = ACL_NONE } //end }; diff --git a/src/openpgp/openpgp.c b/src/openpgp/openpgp.c index b56734f..10adeb4 100644 --- a/src/openpgp/openpgp.c +++ b/src/openpgp/openpgp.c @@ -22,8 +22,6 @@ #include "random.h" #include "eac.h" #include "crypto_utils.h" -#include "mbedtls/rsa.h" -#include "mbedtls/ecdsa.h" #include "mbedtls/ecdh.h" #include "mbedtls/asn1.h" #include "asn1.h" @@ -821,8 +819,10 @@ static int cmd_get_data() { uint16_t data_len = parse_do(fids, 1); uint8_t *p = NULL; uint16_t tg = 0; - size_t tg_len = 0; - if (walk_tlv(res_APDU, data_len, &p, &tg, &tg_len, NULL)) { + uint16_t tg_len = 0; + asn1_ctx_t ctxi; + asn1_ctx_init(res_APDU, data_len, &ctxi); + if (walk_tlv(&ctxi, &p, &tg, &tg_len, NULL)) { uint8_t dec = 2; if ((tg & 0x1f) == 0x1f) { dec++; diff --git a/src/openpgp/openpgp.h b/src/openpgp/openpgp.h index 990af8c..92f4d1d 100644 --- a/src/openpgp/openpgp.h +++ b/src/openpgp/openpgp.h @@ -25,11 +25,15 @@ #include "pico_keys.h" #include "apdu.h" +#include "mbedtls/rsa.h" +#include "mbedtls/ecdsa.h" extern bool has_pw1; extern bool has_pw3; extern int store_keys(void *key_ctx, int type, uint16_t key_id); +extern void make_rsa_response(mbedtls_rsa_context *rsa); +extern void make_ecdsa_response(mbedtls_ecdsa_context *ecdsa); #define ALGO_RSA 0x01 #define ALGO_ECDH 0x12