LibCrypto+LibTLS+LibWeb: Store EC key size + refactor serialization

In order for public/private key serialization to work correctly we must
store the size of the key because P-521 cannot be stored as full words
inside `UnsignedBigInteger` and therefore is exported as the wrong
length (68 instead of 66).

This makes it also possible to refactor some methods and cleanup
constants scattered around.

Gets almost all import/export tests, expect the JWK ones that calculate
the public key on export. The `SECPxxxr1` implementation currently fails
to do calculations for P-521.
This commit is contained in:
devgianlu 2024-12-13 15:37:34 +01:00 committed by Ali Mohammad Pur
commit 9240d38273
Notes: github-actions[bot] 2024-12-14 00:53:11 +00:00
9 changed files with 146 additions and 110 deletions

View file

@ -371,8 +371,7 @@ bool Context::verify_certificate_pair(Certificate const& subject, Certificate co
return false;
}
auto public_key = issuer.public_key.ec;
auto public_point = Crypto::Curves::SECPxxxr1Point { public_key.x(), public_key.y() };
auto public_point = issuer.public_key.ec.to_secpxxxr1_point();
auto maybe_signature = Crypto::Curves::SECPxxxr1Signature::from_asn(subject.signature_value, {});
if (maybe_signature.is_error()) {