From bb20dd7a5325190f4b3f682abd65fc4206d93f4b Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Wed, 16 Aug 2023 19:16:54 +0200 Subject: [PATCH] First attempt to include CBOR as CCID. Signed-off-by: Pol Henarejos --- src/fido/fido.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/fido/fido.c b/src/fido/fido.c index e86d7c6..dc5f6ce 100644 --- a/src/fido/fido.c +++ b/src/fido/fido.c @@ -32,6 +32,7 @@ #endif #include #include "management.h" +#include "ctap_hid.h" int fido_process_apdu(); int fido_unload(); @@ -403,16 +404,32 @@ void set_opts(uint8_t opts) { extern int cmd_register(); extern int cmd_authenticate(); extern int cmd_version(); +extern int cbor_parse(int, uint8_t *, size_t); + +#define CTAP_CBOR 0x10 + +int cmd_cbor() { + uint8_t *old_buf = res_APDU; + int ret = cbor_parse(0x90, apdu.data, apdu.nc); + if (ret != 0) { + return SW_EXEC_ERROR(); + } + res_APDU = old_buf; + res_APDU_size += 1; + memcpy(res_APDU, ctap_resp->init.data, res_APDU_size); + return SW_OK(); +} static const cmd_t cmds[] = { { CTAP_REGISTER, cmd_register }, { CTAP_AUTHENTICATE, cmd_authenticate }, { CTAP_VERSION, cmd_version }, + { CTAP_CBOR, cmd_cbor }, { 0x00, 0x0 } }; int fido_process_apdu() { - if (CLA(apdu) != 0x00) { + if (CLA(apdu) != 0x00 && CLA(apdu) != 0x80) { return SW_CLA_NOT_SUPPORTED(); } if (cap_supported(CAP_U2F)) {