mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-23 19:42:53 +00:00
LibWeb: Make SubtleCrypto AlgorithmParams classes virtual
This allows us to properly destroy the child classes through a pointer to the base class, avoiding ASAN/UBSAN errors.
This commit is contained in:
parent
1d70306c41
commit
0a3d27c41d
Notes:
sideshowbarker
2024-07-17 02:29:45 +09:00
Author: https://github.com/ADKaster
Commit: 0a3d27c41d
Pull-request: https://github.com/SerenityOS/serenity/pull/23579
2 changed files with 44 additions and 4 deletions
|
@ -57,6 +57,8 @@ static ::Crypto::UnsignedBigInteger big_integer_from_api_big_integer(JS::GCPtr<J
|
|||
return result;
|
||||
}
|
||||
|
||||
AlgorithmParams::~AlgorithmParams() = default;
|
||||
|
||||
JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> AlgorithmParams::from_value(JS::VM& vm, JS::Value value)
|
||||
{
|
||||
auto& object = value.as_object();
|
||||
|
@ -64,9 +66,11 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> AlgorithmParams::from_valu
|
|||
auto name = TRY(object.get("name"));
|
||||
auto name_string = TRY(name.to_string(vm));
|
||||
|
||||
return adopt_own(*new AlgorithmParams { .name = name_string });
|
||||
return adopt_own(*new AlgorithmParams { name_string });
|
||||
}
|
||||
|
||||
PBKDF2Params::~PBKDF2Params() = default;
|
||||
|
||||
JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> PBKDF2Params::from_value(JS::VM& vm, JS::Value value)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
@ -96,9 +100,11 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> PBKDF2Params::from_value(J
|
|||
hash = HashAlgorithmIdentifier { hash_object };
|
||||
}
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new PBKDF2Params { { name }, salt, iterations, hash.downcast<HashAlgorithmIdentifier>() });
|
||||
return adopt_own<AlgorithmParams>(*new PBKDF2Params { name, salt, iterations, hash.downcast<HashAlgorithmIdentifier>() });
|
||||
}
|
||||
|
||||
RsaKeyGenParams::~RsaKeyGenParams() = default;
|
||||
|
||||
JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> RsaKeyGenParams::from_value(JS::VM& vm, JS::Value value)
|
||||
{
|
||||
auto& object = value.as_object();
|
||||
|
@ -117,9 +123,11 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> RsaKeyGenParams::from_valu
|
|||
|
||||
public_exponent = static_cast<JS::Uint8Array&>(public_exponent_value.as_object());
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new RsaKeyGenParams { { name }, modulus_length, big_integer_from_api_big_integer(public_exponent) });
|
||||
return adopt_own<AlgorithmParams>(*new RsaKeyGenParams { name, modulus_length, big_integer_from_api_big_integer(public_exponent) });
|
||||
}
|
||||
|
||||
RsaHashedKeyGenParams::~RsaHashedKeyGenParams() = default;
|
||||
|
||||
JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> RsaHashedKeyGenParams::from_value(JS::VM& vm, JS::Value value)
|
||||
{
|
||||
auto& object = value.as_object();
|
||||
|
@ -148,7 +156,7 @@ JS::ThrowCompletionOr<NonnullOwnPtr<AlgorithmParams>> RsaHashedKeyGenParams::fro
|
|||
hash = HashAlgorithmIdentifier { hash_object };
|
||||
}
|
||||
|
||||
return adopt_own<AlgorithmParams>(*new RsaHashedKeyGenParams { { { name }, modulus_length, big_integer_from_api_big_integer(public_exponent) }, hash.get<HashAlgorithmIdentifier>() });
|
||||
return adopt_own<AlgorithmParams>(*new RsaHashedKeyGenParams { name, modulus_length, big_integer_from_api_big_integer(public_exponent), hash.get<HashAlgorithmIdentifier>() });
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webcrypto/#rsa-oaep-operations
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue