소스 검색

LibWeb: Fix modulus length being wrong for RSA-OAEP key import

stelar7 9 달 전
부모
커밋
37f2818e90
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      Userland/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp

+ 2 - 2
Userland/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp

@@ -902,12 +902,12 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<CryptoKey>> RSAOAEP::import_key(Web::Crypto
     // 6. Set the publicExponent attribute of algorithm to the BigInteger representation of the RSA public exponent.
     TRY(key->handle().visit(
         [&](::Crypto::PK::RSAPublicKey<> const& public_key) -> WebIDL::ExceptionOr<void> {
-            algorithm->set_modulus_length(public_key.length());
+            algorithm->set_modulus_length(public_key.modulus().trimmed_byte_length() * 8);
             TRY(algorithm->set_public_exponent(public_key.public_exponent()));
             return {};
         },
         [&](::Crypto::PK::RSAPrivateKey<> const& private_key) -> WebIDL::ExceptionOr<void> {
-            algorithm->set_modulus_length(private_key.length());
+            algorithm->set_modulus_length(private_key.modulus().trimmed_byte_length() * 8);
             TRY(algorithm->set_public_exponent(private_key.public_exponent()));
             return {};
         },