LibCrypto: Make RSA::generate_key_pair return ErrorOr

Not currently needed as it cannot fail, but useful for future commits.
This commit is contained in:
devgianlu 2024-12-23 17:41:37 +01:00 committed by Ali Mohammad Pur
parent d5e3a557fd
commit 9e08f71fd9
Notes: github-actions[bot] 2025-01-12 00:15:00 +00:00
4 changed files with 33 additions and 24 deletions

View file

@ -764,7 +764,11 @@ WebIDL::ExceptionOr<Variant<GC::Ref<CryptoKey>, GC::Ref<CryptoKeyPair>>> RSAOAEP
// and RSA public exponent equal to the publicExponent member of normalizedAlgorithm.
// 3. If performing the operation results in an error, then throw an OperationError.
auto const& normalized_algorithm = static_cast<RsaHashedKeyGenParams const&>(params);
auto key_pair = ::Crypto::PK::RSA::generate_key_pair(normalized_algorithm.modulus_length, normalized_algorithm.public_exponent);
auto maybe_key_pair = ::Crypto::PK::RSA::generate_key_pair(normalized_algorithm.modulus_length, normalized_algorithm.public_exponent);
if (maybe_key_pair.is_error())
return WebIDL::OperationError::create(m_realm, "Failed generating RSA key pair"_string);
auto key_pair = maybe_key_pair.release_value();
// 4. Let algorithm be a new RsaHashedKeyAlgorithm object.
auto algorithm = RsaHashedKeyAlgorithm::create(m_realm);