From 20b7a05554825679c412fca3a82702381876dba7 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 2 Jan 2025 20:27:28 +0000 Subject: [PATCH] Workaround private pem missmatch in e2e tests (#6716) Co-authored-by: Amaury Chamayou --- tests/npm_tests.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/npm_tests.py b/tests/npm_tests.py index 49351a13c735..703476106963 100644 --- a/tests/npm_tests.py +++ b/tests/npm_tests.py @@ -94,8 +94,16 @@ def generate_and_verify_jwk(client): r = client.post("/app/rsaJwkToPem", body={"jwk": body}) body = r.body.json() - assert r.status_code == http.HTTPStatus.OK - assert body["pem"] == priv_pem + converted_pem = body["pem"] + + # PEMs may vary because of discrepancies of RSA key private components + # computation, in particular, using Euler VS Carmichael totient + # functions. For more details check the thread: + # https://github.com/microsoft/CCF/issues/6588#issuecomment-2568037993. + algorithm = {"name": "RSA-PSS", "hash": "SHA-256"} + data = rand_bytes(random.randint(2, 50)) + signature = infra.crypto.sign(algorithm, converted_pem, data) + infra.crypto.verify_signature(algorithm, signature, data, pub_pem) # Public ref_pub_jwk = jwk.JWK.from_pem(pub_pem.encode()).export(as_dict=True)