From 2b917959af3da6d3a1f9a7af41ec7a36a2b96754 Mon Sep 17 00:00:00 2001 From: z4yx Date: Wed, 9 Aug 2023 08:09:22 +0800 Subject: [PATCH] reorder keys in the extension map --- applets/ctap/ctap.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/applets/ctap/ctap.c b/applets/ctap/ctap.c index 5f131d78..a998f989 100644 --- a/applets/ctap/ctap.c +++ b/applets/ctap/ctap.c @@ -432,12 +432,6 @@ static uint8_t ctap_make_credential(CborEncoder *encoder, uint8_t *params, size_ (mc.ext_cred_protect > 0 ? 1 : 0) + (mc.ext_has_cred_blob ? 1 : 0)); CHECK_CBOR_RET(ret); - if (mc.ext_hmac_secret) { - ret = cbor_encode_text_stringz(&map, "hmac-secret"); - CHECK_CBOR_RET(ret); - ret = cbor_encode_boolean(&map, true); - CHECK_CBOR_RET(ret); - } if (mc.ext_large_blob_key) { if (mc.options.rk != OPTION_TRUE) { DBG_MSG("largeBlobKey requires rk\n"); @@ -445,12 +439,6 @@ static uint8_t ctap_make_credential(CborEncoder *encoder, uint8_t *params, size_ } // Generate key in Step 17 } - if (mc.ext_cred_protect > 0) { - ret = cbor_encode_text_stringz(&map, "credProtect"); - CHECK_CBOR_RET(ret); - ret = cbor_encode_int(&map, mc.ext_cred_protect); - CHECK_CBOR_RET(ret); - } if (mc.ext_has_cred_blob) { bool accepted = false; if (mc.ext_cred_blob_len <= MAX_CRED_BLOB_LENGTH && mc.options.rk == OPTION_TRUE) { @@ -461,6 +449,18 @@ static uint8_t ctap_make_credential(CborEncoder *encoder, uint8_t *params, size_ ret = cbor_encode_boolean(&map, accepted); CHECK_CBOR_RET(ret); } + if (mc.ext_cred_protect > 0) { + ret = cbor_encode_text_stringz(&map, "credProtect"); + CHECK_CBOR_RET(ret); + ret = cbor_encode_int(&map, mc.ext_cred_protect); + CHECK_CBOR_RET(ret); + } + if (mc.ext_hmac_secret) { + ret = cbor_encode_text_stringz(&map, "hmac-secret"); + CHECK_CBOR_RET(ret); + ret = cbor_encode_boolean(&map, true); + CHECK_CBOR_RET(ret); + } ret = cbor_encoder_close_container(&extension_encoder, &map); CHECK_CBOR_RET(ret); size_t extension_size = cbor_encoder_get_buffer_size(&extension_encoder, extension_buffer);