Only return numberOfCredentials if allowList is empty.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2022-10-03 01:11:51 +02:00
parent 3fc41a12a7
commit 0c5b308aef

View File

@@ -50,7 +50,7 @@ int cbor_get_next_assertion(const uint8_t *data, size_t len) {
timerx = board_millis(); timerx = board_millis();
credentialCounter++; credentialCounter++;
err: err:
if (error != CborNoError) { if (error != CborNoError || credentialCounter == numberOfCredentialsx) {
for (int i = 0; i < MAX_CREDENTIAL_COUNT_IN_LIST; i++) for (int i = 0; i < MAX_CREDENTIAL_COUNT_IN_LIST; i++)
credential_free(&credsx[i]); credential_free(&credsx[i]);
if (datax) { if (datax) {
@@ -255,8 +255,7 @@ int cbor_get_assertion(const uint8_t *data, size_t len, bool next) {
CBOR_ERROR(CTAP1_ERR_INVALID_LEN); CBOR_ERROR(CTAP1_ERR_INVALID_LEN);
} }
if (allowList_len > 0) if (allowList_len > 0) {
{
for (int e = 0; e < allowList_len; e++) { for (int e = 0; e < allowList_len; e++) {
if (allowList[e].type.present == false || allowList[e].id.present == false) if (allowList[e].type.present == false || allowList[e].id.present == false)
CBOR_ERROR(CTAP2_ERR_MISSING_PARAMETER); CBOR_ERROR(CTAP2_ERR_MISSING_PARAMETER);
@@ -334,7 +333,7 @@ int cbor_get_assertion(const uint8_t *data, size_t len, bool next) {
} }
else { else {
selcred = &creds[0]; selcred = &creds[0];
if (numberOfCredentials > 1) { if (numberOfCredentials > 1 && allowList_len == 0) {
asserted = true; asserted = true;
residentx = resident; residentx = resident;
for (int i = 0; i < MAX_CREDENTIAL_COUNT_IN_LIST; i++) for (int i = 0; i < MAX_CREDENTIAL_COUNT_IN_LIST; i++)
@@ -461,7 +460,7 @@ int cbor_get_assertion(const uint8_t *data, size_t len, bool next) {
uint8_t lfields = 3; uint8_t lfields = 3;
if (selcred->opts.present == true && selcred->opts.rk == ptrue) if (selcred->opts.present == true && selcred->opts.rk == ptrue)
lfields++; lfields++;
if (numberOfCredentials > 1 && next == false) if (numberOfCredentials > 1 && next == false && allowList_len == 0)
lfields++; lfields++;
cbor_encoder_init(&encoder, ctap_resp->init.data + 1, CTAP_MAX_PACKET_SIZE, 0); cbor_encoder_init(&encoder, ctap_resp->init.data + 1, CTAP_MAX_PACKET_SIZE, 0);
CBOR_CHECK(cbor_encoder_create_map(&encoder, &mapEncoder, lfields)); CBOR_CHECK(cbor_encoder_create_map(&encoder, &mapEncoder, lfields));
@@ -503,7 +502,7 @@ int cbor_get_assertion(const uint8_t *data, size_t len, bool next) {
} }
CBOR_CHECK(cbor_encoder_close_container(&mapEncoder, &mapEncoder2)); CBOR_CHECK(cbor_encoder_close_container(&mapEncoder, &mapEncoder2));
} }
if (numberOfCredentials > 1 && next == false) { if (numberOfCredentials > 1 && next == false && allowList_len == 0) {
CBOR_CHECK(cbor_encode_uint(&mapEncoder, 0x05)); CBOR_CHECK(cbor_encode_uint(&mapEncoder, 0x05));
CBOR_CHECK(cbor_encode_uint(&mapEncoder, numberOfCredentials)); CBOR_CHECK(cbor_encode_uint(&mapEncoder, numberOfCredentials));
} }