From 54bbc0e9ea83510bcdf48e3fc61c21180a1882fe Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Sun, 30 Jun 2024 00:31:29 +0200 Subject: [PATCH] Fix return value when bad key type is provided. Fixes #47. Signed-off-by: Pol Henarejos --- src/fido/cbor_make_credential.c | 6 +++--- tests/pico-fido/test_020_register.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fido/cbor_make_credential.c b/src/fido/cbor_make_credential.c index 4de194a..33ccc98 100644 --- a/src/fido/cbor_make_credential.c +++ b/src/fido/cbor_make_credential.c @@ -225,9 +225,9 @@ int cbor_make_credential(const uint8_t *data, size_t len) { else if (pubKeyCredParams[i].alg <= FIDO2_ALG_RS256 && pubKeyCredParams[i].alg >= FIDO2_ALG_RS512) { // pass } - else { - CBOR_ERROR(CTAP2_ERR_CBOR_UNEXPECTED_TYPE); - } + //else { + // CBOR_ERROR(CTAP2_ERR_CBOR_UNEXPECTED_TYPE); + //} if (curve > 0 && alg == 0) { alg = pubKeyCredParams[i].alg; } diff --git a/tests/pico-fido/test_020_register.py b/tests/pico-fido/test_020_register.py index 378a13e..3a80e7d 100644 --- a/tests/pico-fido/test_020_register.py +++ b/tests/pico-fido/test_020_register.py @@ -151,7 +151,7 @@ def test_unsupported_algorithm(device): with pytest.raises(CtapError) as e: device.doMC(key_params=[{"alg": 1337, "type": "public-key"}]) - assert e.value.code == CtapError.ERR.CBOR_UNEXPECTED_TYPE + assert e.value.code == CtapError.ERR.UNSUPPORTED_ALGORITHM def test_exclude_list(resetdevice): resetdevice.doMC(exclude_list=[{"id": b"1234", "type": "rot13"}])