From 3fc41a12a7b3749b8e5a4b917e88f01c846e1546 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Mon, 3 Oct 2022 00:53:31 +0200 Subject: [PATCH] Only return other user fields if credentials > 1. Signed-off-by: Pol Henarejos --- src/fido/cbor_get_assertion.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/fido/cbor_get_assertion.c b/src/fido/cbor_get_assertion.c index 21412e6..86fcb7b 100644 --- a/src/fido/cbor_get_assertion.c +++ b/src/fido/cbor_get_assertion.c @@ -482,20 +482,24 @@ int cbor_get_assertion(const uint8_t *data, size_t len, bool next) { if (selcred->opts.present == true && selcred->opts.rk == ptrue) { CBOR_CHECK(cbor_encode_uint(&mapEncoder, 0x04)); uint8_t lu = 1; - if (selcred->userName.present == true) - lu++; - if (selcred->userDisplayName.present == true) - lu++; + if (numberOfCredentials > 1) { + if (selcred->userName.present == true) + lu++; + if (selcred->userDisplayName.present == true) + lu++; + } CBOR_CHECK(cbor_encoder_create_map(&mapEncoder, &mapEncoder2, lu)); CBOR_CHECK(cbor_encode_text_stringz(&mapEncoder2, "id")); CBOR_CHECK(cbor_encode_byte_string(&mapEncoder2, selcred->userId.data, selcred->userId.len)); - if (selcred->userName.present == true) { - CBOR_CHECK(cbor_encode_text_stringz(&mapEncoder2, "name")); - CBOR_CHECK(cbor_encode_text_stringz(&mapEncoder2, selcred->userName.data)); - } - if (selcred->userDisplayName.present == true) { - CBOR_CHECK(cbor_encode_text_stringz(&mapEncoder2, "displayName")); - CBOR_CHECK(cbor_encode_text_stringz(&mapEncoder2, selcred->userDisplayName.data)); + if (numberOfCredentials > 1) { + if (selcred->userName.present == true) { + CBOR_CHECK(cbor_encode_text_stringz(&mapEncoder2, "name")); + CBOR_CHECK(cbor_encode_text_stringz(&mapEncoder2, selcred->userName.data)); + } + if (selcred->userDisplayName.present == true) { + CBOR_CHECK(cbor_encode_text_stringz(&mapEncoder2, "displayName")); + CBOR_CHECK(cbor_encode_text_stringz(&mapEncoder2, selcred->userDisplayName.data)); + } } CBOR_CHECK(cbor_encoder_close_container(&mapEncoder, &mapEncoder2)); }