diff --git a/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp b/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp index 000c148200..1459e94445 100644 --- a/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp +++ b/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp @@ -91,8 +91,7 @@ static ::Crypto::UnsignedBigInteger big_integer_from_api_big_integer(GC::Ptrviewed_array_buffer()->bytes(); - + auto buffer = MUST(WebIDL::get_buffer_source_copy(*big_integer)); if (!buffer.is_empty()) return ::Crypto::UnsignedBigInteger::import_data(buffer); return ::Crypto::UnsignedBigInteger(0); diff --git a/Libraries/LibWeb/Crypto/CryptoKey.cpp b/Libraries/LibWeb/Crypto/CryptoKey.cpp index 3dc3905a65..a8e5ff8d8e 100644 --- a/Libraries/LibWeb/Crypto/CryptoKey.cpp +++ b/Libraries/LibWeb/Crypto/CryptoKey.cpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace Web::Crypto { @@ -44,7 +45,7 @@ enum class KeyAlgorithmTag : u8 { ::Crypto::UnsignedBigInteger big_integer_from_api_big_integer(JS::Uint8Array const& big_integer) { - auto buffer = big_integer.viewed_array_buffer()->bytes().slice(big_integer.byte_offset(), big_integer.byte_length().length()); + auto buffer = MUST(WebIDL::get_buffer_source_copy(big_integer)); if (!buffer.is_empty()) return ::Crypto::UnsignedBigInteger::import_data(buffer); return ::Crypto::UnsignedBigInteger(0); diff --git a/Tests/LibWeb/Text/expected/Crypto/SubtleCrypto-generateKey-detached-public-exponent.txt b/Tests/LibWeb/Text/expected/Crypto/SubtleCrypto-generateKey-detached-public-exponent.txt new file mode 100644 index 0000000000..563bb83b20 --- /dev/null +++ b/Tests/LibWeb/Text/expected/Crypto/SubtleCrypto-generateKey-detached-public-exponent.txt @@ -0,0 +1 @@ +rejected: OperationError diff --git a/Tests/LibWeb/Text/expected/Crypto/SubtleCrypto-structuredClone-detached-public-exponent.txt b/Tests/LibWeb/Text/expected/Crypto/SubtleCrypto-structuredClone-detached-public-exponent.txt new file mode 100644 index 0000000000..96ad8180ac --- /dev/null +++ b/Tests/LibWeb/Text/expected/Crypto/SubtleCrypto-structuredClone-detached-public-exponent.txt @@ -0,0 +1 @@ +PASS (didn't crash): cloned diff --git a/Tests/LibWeb/Text/input/Crypto/SubtleCrypto-generateKey-detached-public-exponent.html b/Tests/LibWeb/Text/input/Crypto/SubtleCrypto-generateKey-detached-public-exponent.html new file mode 100644 index 0000000000..b9112b2499 --- /dev/null +++ b/Tests/LibWeb/Text/input/Crypto/SubtleCrypto-generateKey-detached-public-exponent.html @@ -0,0 +1,25 @@ + + + diff --git a/Tests/LibWeb/Text/input/Crypto/SubtleCrypto-structuredClone-detached-public-exponent.html b/Tests/LibWeb/Text/input/Crypto/SubtleCrypto-structuredClone-detached-public-exponent.html new file mode 100644 index 0000000000..25878b9f93 --- /dev/null +++ b/Tests/LibWeb/Text/input/Crypto/SubtleCrypto-structuredClone-detached-public-exponent.html @@ -0,0 +1,22 @@ + + +