From 56453b60d6f00ce15b0b38e19c9f67b24f81fd36 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Tue, 24 May 2022 23:30:01 +0200 Subject: [PATCH] Added fmd flag to wrap FCP to include later the FMD. Signed-off-by: Pol Henarejos --- src/fs/file.c | 11 +++++++---- src/fs/file.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/fs/file.c b/src/fs/file.c index 6bcd87d..ca54ca8 100644 --- a/src/fs/file.c +++ b/src/fs/file.c @@ -35,12 +35,14 @@ extern uint8_t *flash_read(uintptr_t addr); extern void low_flash_available(); //puts FCI in the RAPDU -void process_fci(const file_t *pe) { +void process_fci(const file_t *pe, int fmd) { uint8_t *p = res_APDU; uint8_t buf[64]; res_APDU_size = 0; - res_APDU[res_APDU_size++] = 0x6f; - res_APDU[res_APDU_size++] = 0x00; //computed later + if (fmd) { + res_APDU[res_APDU_size++] = 0x6f; + res_APDU[res_APDU_size++] = 0x00; //computed later + } res_APDU[res_APDU_size++] = 0x62; res_APDU[res_APDU_size++] = 0x00; //computed later @@ -95,7 +97,8 @@ void process_fci(const file_t *pe) { res_APDU_size += meta_size; } res_APDU[1] = res_APDU_size-2; - res_APDU[3] = res_APDU_size-4; + if (fmd) + res_APDU[3] = res_APDU_size-4; } #define MAX_DYNAMIC_FILES 128 diff --git a/src/fs/file.h b/src/fs/file.h index 41a016c..ab47d99 100644 --- a/src/fs/file.h +++ b/src/fs/file.h @@ -92,7 +92,7 @@ extern file_t *search_by_fid(const uint16_t fid, const file_t *parent, const uin extern file_t *search_by_name(uint8_t *name, uint16_t namelen); extern file_t *search_by_path(const uint8_t *pe_path, uint8_t pathlen, const file_t *parent); extern bool authenticate_action(const file_t *ef, uint8_t op); -extern void process_fci(const file_t *pe); +extern void process_fci(const file_t *pe, int fmd); extern void scan_flash(); extern void initialize_flash(bool);