From d677f8c34657ed397c67f481056e17863d3d5341 Mon Sep 17 00:00:00 2001 From: Conor Patrick Date: Tue, 24 Mar 2020 17:12:46 -0400 Subject: [PATCH] add rk delete implementations --- fido2/device.c | 15 +++++++++++++++ fido2/device.h | 7 +++++++ pc/device.c | 6 ++++++ targets/stm32l432/src/device.c | 7 +++++++ 4 files changed, 35 insertions(+) diff --git a/fido2/device.c b/fido2/device.c index 908c765..22e58f5 100644 --- a/fido2/device.c +++ b/fido2/device.c @@ -185,6 +185,21 @@ __attribute__((weak)) void ctap_store_rk(int index, CTAP_residentKey * rk) } +__attribute__((weak)) void ctap_delete_rk(int index) +{ + CTAP_residentKey rk; + + if (index < RK_NUM) + { + memmove(RK_STORE.rks + index, &rk, sizeof(CTAP_residentKey)); + } + else + { + printf1(TAG_ERR,"Out of bounds for delete_rk\r\n"); + } + +} + __attribute__((weak)) void ctap_load_rk(int index, CTAP_residentKey * rk) { memmove(rk, RK_STORE.rks + index, sizeof(CTAP_residentKey)); diff --git a/fido2/device.h b/fido2/device.h index 20029dd..0c96c73 100644 --- a/fido2/device.h +++ b/fido2/device.h @@ -140,6 +140,13 @@ uint32_t ctap_rk_size(); */ void ctap_store_rk(int index,CTAP_residentKey * rk); +/** Delete a resident key from an index. + * @param index to delete resident key from. Has no effect if no RK exists at index. + * + * *Optional*, if not implemented, operates on non-persistant RK's. +*/ +void ctap_delete_rk(int index); + /** Read a resident key from an index into memory * @param index to read resident key from. * @param rk pointer to resident key structure to write into with RK. diff --git a/pc/device.c b/pc/device.c index c3c5905..0536bb2 100644 --- a/pc/device.c +++ b/pc/device.c @@ -449,6 +449,12 @@ void ctap_store_rk(int index, CTAP_residentKey * rk) } +void ctap_delete_rk(int index) +{ + CTAP_residentKey rk; + memset(&rk, 0xff, sizeof(CTAP_residentKey)); + memmove(RK_STORE.rks + index, &rk, sizeof(CTAP_residentKey)); +} void ctap_load_rk(int index, CTAP_residentKey * rk) { diff --git a/targets/stm32l432/src/device.c b/targets/stm32l432/src/device.c index e863ea5..c8f487b 100644 --- a/targets/stm32l432/src/device.c +++ b/targets/stm32l432/src/device.c @@ -793,6 +793,13 @@ void ctap_store_rk(int index,CTAP_residentKey * rk) ctap_overwrite_rk(index, rk); } +void ctap_delete_rk(int index) +{ + CTAP_residentKey rk; + memset(&rk, 0xff, sizeof(CTAP_residentKey)); + ctap_overwrite_rk(index, &rk); +} + void ctap_load_rk(int index,CTAP_residentKey * rk) { int byte_offset_into_page = (sizeof(CTAP_residentKey) * (index % (PAGE_SIZE/sizeof(CTAP_residentKey))));