From 05044b498dd5bc70ceef4aabbf85667d2b703c76 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Fri, 18 Aug 2023 13:06:51 +0200 Subject: [PATCH 1/2] Added test for testing algorithms on make credential. Signed-off-by: Pol Henarejos --- tests/pico-fido/test_020_register.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/pico-fido/test_020_register.py b/tests/pico-fido/test_020_register.py index 76cf631..d5e876a 100644 --- a/tests/pico-fido/test_020_register.py +++ b/tests/pico-fido/test_020_register.py @@ -19,7 +19,7 @@ from fido2.client import CtapError -from fido2.cose import ES256 +from fido2.cose import ES256, ES384, ES512, EdDSA import pytest @@ -31,7 +31,7 @@ def test_make_credential(): pass def test_attestation_format(MCRes): - assert MCRes['res'].attestation_object.fmt in ["packed", "tpm", "android-key", "adroid-safetynet"] + assert MCRes['res'].attestation_object.fmt in ["packed", "tpm", "android-key", "adroid-safetynet"] def test_authdata_length(MCRes): assert len(MCRes['res'].attestation_object.auth_data) >= 77 @@ -120,6 +120,13 @@ def test_bad_type_pubKeyCredParams(device): with pytest.raises(CtapError) as e: device.doMC(key_params=["wrong"]) +@pytest.mark.parametrize( + "alg", [ES256.ALGORITHM, ES384.ALGORITHM, ES512.ALGORITHM] +) +def test_algorithms(device, info, alg): + if ({'alg': alg, 'type': 'public-key'} in info.algorithms): + device.doMC(key_params=[{"alg": alg, "type": "public-key"}]) + def test_missing_pubKeyCredParams_type(device): with pytest.raises(CtapError) as e: device.doMC(key_params=[{"alg": ES256.ALGORITHM}]) From 26148282e67a6de0afcaa418c9730ccd5836b234 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Fri, 18 Aug 2023 13:07:06 +0200 Subject: [PATCH 2/2] Fix credential creation for ES512. Signed-off-by: Pol Henarejos --- src/fido/fido.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/fido/fido.c b/src/fido/fido.c index abb0bf9..885e58b 100644 --- a/src/fido/fido.c +++ b/src/fido/fido.c @@ -262,6 +262,9 @@ int derive_key(const uint8_t *app_id, if (cinfo == NULL) { return 1; } + if (cinfo->bit_size % 8 != 0) { + outk[0] >>= 8 - (cinfo->bit_size % 8); + } r = mbedtls_ecp_read_key(curve, key, outk, ceil((float) cinfo->bit_size / 8)); mbedtls_platform_zeroize(outk, sizeof(outk)); if (r != 0) {