Fix return value when bad key type is provided. Fixes #47.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2024-06-30 00:31:29 +02:00
parent b0b0187919
commit 54bbc0e9ea
No known key found for this signature in database
GPG Key ID: C0095B7870A4CCD3
2 changed files with 4 additions and 4 deletions

View File

@ -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) { else if (pubKeyCredParams[i].alg <= FIDO2_ALG_RS256 && pubKeyCredParams[i].alg >= FIDO2_ALG_RS512) {
// pass // pass
} }
else { //else {
CBOR_ERROR(CTAP2_ERR_CBOR_UNEXPECTED_TYPE); // CBOR_ERROR(CTAP2_ERR_CBOR_UNEXPECTED_TYPE);
} //}
if (curve > 0 && alg == 0) { if (curve > 0 && alg == 0) {
alg = pubKeyCredParams[i].alg; alg = pubKeyCredParams[i].alg;
} }

View File

@ -151,7 +151,7 @@ def test_unsupported_algorithm(device):
with pytest.raises(CtapError) as e: with pytest.raises(CtapError) as e:
device.doMC(key_params=[{"alg": 1337, "type": "public-key"}]) 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): def test_exclude_list(resetdevice):
resetdevice.doMC(exclude_list=[{"id": b"1234", "type": "rot13"}]) resetdevice.doMC(exclude_list=[{"id": b"1234", "type": "rot13"}])