mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
LibCrypto: Use ASN1 macros for RSA key parsing
Improve error handling in `RSA::parse_rsa_key` by using ASN1 macros and generalizing the parsing to both private and public keys.
This commit is contained in:
parent
ee50a8c0f7
commit
1f7586ce14
Notes:
github-actions[bot]
2024-11-30 10:18:46 +00:00
Author: https://github.com/devgianlu
Commit: 1f7586ce14
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2648
5 changed files with 104 additions and 101 deletions
|
@ -127,7 +127,7 @@ c8yGzl89pYST
|
|||
EXPECT_EQ(decoded.type, Crypto::PEMType::PrivateKey);
|
||||
auto decoder = Crypto::ASN1::Decoder { decoded.data };
|
||||
auto priv_key_info = MUST(Crypto::Certificate::parse_private_key_info(decoder, {}));
|
||||
auto keypair = Crypto::PK::RSA::parse_rsa_key(priv_key_info.raw_key);
|
||||
auto keypair = MUST(Crypto::PK::RSA::parse_rsa_key(priv_key_info.raw_key, true, {}));
|
||||
auto priv_der = MUST(priv_key_info.rsa.export_as_der());
|
||||
auto rsa_encryption_oid = Array<int, 7> { 1, 2, 840, 113549, 1, 1, 1 };
|
||||
auto wrapped_priv_der = MUST(Crypto::PK::wrap_in_private_key_info(priv_key_info.raw_key, rsa_encryption_oid, nullptr));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue