mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-20 09:21:55 +00:00
LibCrypto: Use ASN1 macros for EC key parsing
Improve error handling in `EC::parse_ec_key` by using ASN1 macros and generalizing the parsing to both private and public keys.
This commit is contained in:
parent
40f17d9260
commit
0280838944
Notes:
github-actions[bot]
2024-11-30 10:19:02 +00:00
Author: https://github.com/devgianlu
Commit: 0280838944
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2648
3 changed files with 92 additions and 65 deletions
|
@ -395,9 +395,9 @@ ErrorOr<PrivateKey> parse_private_key_info(Crypto::ASN1::Decoder& decoder, Vecto
|
|||
return private_key;
|
||||
}
|
||||
if (private_key.algorithm.identifier.span() == ASN1::ec_public_key_encryption_oid.span()) {
|
||||
auto maybe_key = Crypto::PK::EC::parse_ec_key(value.bytes());
|
||||
auto maybe_key = Crypto::PK::EC::parse_ec_key(value.bytes(), true, current_scope);
|
||||
if (maybe_key.is_error()) {
|
||||
ERROR_WITH_SCOPE(TRY(String::formatted("Invalid EC key at {}: {}", current_scope, maybe_key.release_error())));
|
||||
ERROR_WITH_SCOPE(maybe_key.release_error());
|
||||
}
|
||||
|
||||
private_key.ec = move(maybe_key.release_value().private_key);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue