mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-25 04:22:50 +00:00
LibWeb: Store PBKDF2Params' salt field as a ByteBuffer directly
Rather than trying to store a Handle to a WebIDL::BufferSource, let's look ahead to what the spec wants us to do with this field and get a copy of the bytes held by the buffer source right away.
This commit is contained in:
parent
a0623a47de
commit
497f3ca0fd
Notes:
sideshowbarker
2024-07-17 23:07:41 +09:00
Author: https://github.com/ADKaster
Commit: 497f3ca0fd
Pull-request: https://github.com/SerenityOS/serenity/pull/23596
Reviewed-by: https://github.com/alimpfard
2 changed files with 4 additions and 5 deletions
|
@ -16,6 +16,7 @@
|
|||
#include <LibWeb/Crypto/CryptoAlgorithms.h>
|
||||
#include <LibWeb/Crypto/KeyAlgorithms.h>
|
||||
#include <LibWeb/Crypto/SubtleCrypto.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
|
||||
namespace Web::Crypto {
|
||||
|
||||
|
@ -216,19 +217,17 @@ PBKDF2Params::~PBKDF2Params() = default;
|
|||
|
||||
JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> PBKDF2Params::from_value(JS::VM& vm, JS::Value value)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto& object = value.as_object();
|
||||
|
||||
auto name_value = TRY(object.get("name"));
|
||||
auto name = TRY(name_value.to_string(vm));
|
||||
|
||||
auto salt_value = TRY(object.get("salt"));
|
||||
JS::Handle<WebIDL::BufferSource> salt;
|
||||
|
||||
if (!salt_value.is_object() || !(is<JS::TypedArrayBase>(salt_value.as_object()) || is<JS::ArrayBuffer>(salt_value.as_object()) || is<JS::DataView>(salt_value.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "BufferSource");
|
||||
|
||||
salt = JS::make_handle(vm.heap().allocate<WebIDL::BufferSource>(realm, salt_value.as_object()));
|
||||
auto salt = TRY_OR_THROW_OOM(vm, WebIDL::get_buffer_source_copy(salt_value.as_object()));
|
||||
|
||||
auto iterations_value = TRY(object.get("iterations"));
|
||||
auto iterations = TRY(iterations_value.to_u32(vm));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue