From 000f0274e26d287bd814ef8f2b519243085c2e4f Mon Sep 17 00:00:00 2001 From: Michiel Visser Date: Mon, 27 Nov 2023 20:17:17 +0100 Subject: [PATCH] LibCrypto: Fix SECP384r1 verification when hash is SHA256 Some websites actually provide a SECP384 certificate which is signed using a SHA256 hash. We assumed that SECP384 always used a SHA384 hash, but this is not the case. --- Userland/Libraries/LibCrypto/Curves/SECPxxxr1.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibCrypto/Curves/SECPxxxr1.h b/Userland/Libraries/LibCrypto/Curves/SECPxxxr1.h index 3c6a2123fa..19936e0bea 100644 --- a/Userland/Libraries/LibCrypto/Curves/SECPxxxr1.h +++ b/Userland/Libraries/LibCrypto/Curves/SECPxxxr1.h @@ -196,8 +196,11 @@ public: } // z is the hash - AK::FixedMemoryStream hash_stream { hash }; - StorageType z = TRY(hash_stream.read_value>()); + StorageType z = 0u; + for (uint8_t byte : hash) { + z <<= 8; + z |= byte; + } AK::FixedMemoryStream pubkey_stream { pubkey }; JacobianPoint pubkey_point = TRY(read_uncompressed_point(pubkey_stream));