mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-26 11:18:59 +00:00
LibWeb: Implement PBKDF2 getKeyLength for SubtleCrypto
This commit is contained in:
parent
19bb62d60e
commit
abf55fe33d
Notes:
sideshowbarker
2024-07-17 20:33:50 +09:00
Author: https://github.com/stelar7
Commit: abf55fe33d
Pull-request: https://github.com/SerenityOS/serenity/pull/23834
Reviewed-by: https://github.com/ADKaster ✅
3 changed files with 13 additions and 1 deletions
|
@ -1397,4 +1397,10 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::ArrayBuffer>> PBKDF2::derive_bits(Algor
|
||||||
return JS::ArrayBuffer::create(realm, result.release_value());
|
return JS::ArrayBuffer::create(realm, result.release_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebIDL::ExceptionOr<JS::Value> PBKDF2::get_key_length(AlgorithmParams const&)
|
||||||
|
{
|
||||||
|
// 1. Return null.
|
||||||
|
return JS::js_null();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,6 +197,11 @@ public:
|
||||||
return WebIDL::NotSupportedError::create(m_realm, "exportKey is not supported"_fly_string);
|
return WebIDL::NotSupportedError::create(m_realm, "exportKey is not supported"_fly_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual WebIDL::ExceptionOr<JS::Value> get_key_length(AlgorithmParams const&)
|
||||||
|
{
|
||||||
|
return WebIDL::NotSupportedError::create(m_realm, "getKeyLength is not supported"_fly_string);
|
||||||
|
}
|
||||||
|
|
||||||
static NonnullOwnPtr<AlgorithmMethods> create(JS::Realm& realm) { return adopt_own(*new AlgorithmMethods(realm)); }
|
static NonnullOwnPtr<AlgorithmMethods> create(JS::Realm& realm) { return adopt_own(*new AlgorithmMethods(realm)); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -231,6 +236,7 @@ class PBKDF2 : public AlgorithmMethods {
|
||||||
public:
|
public:
|
||||||
virtual WebIDL::ExceptionOr<JS::NonnullGCPtr<CryptoKey>> import_key(AlgorithmParams const&, Bindings::KeyFormat, CryptoKey::InternalKeyData, bool, Vector<Bindings::KeyUsage> const&) override;
|
virtual WebIDL::ExceptionOr<JS::NonnullGCPtr<CryptoKey>> import_key(AlgorithmParams const&, Bindings::KeyFormat, CryptoKey::InternalKeyData, bool, Vector<Bindings::KeyUsage> const&) override;
|
||||||
virtual WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::ArrayBuffer>> derive_bits(AlgorithmParams const&, JS::NonnullGCPtr<CryptoKey>, u32) override;
|
virtual WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::ArrayBuffer>> derive_bits(AlgorithmParams const&, JS::NonnullGCPtr<CryptoKey>, u32) override;
|
||||||
|
virtual WebIDL::ExceptionOr<JS::Value> get_key_length(AlgorithmParams const&) override;
|
||||||
|
|
||||||
static NonnullOwnPtr<AlgorithmMethods> create(JS::Realm& realm) { return adopt_own(*new PBKDF2(realm)); }
|
static NonnullOwnPtr<AlgorithmMethods> create(JS::Realm& realm) { return adopt_own(*new PBKDF2(realm)); }
|
||||||
|
|
||||||
|
|
|
@ -677,7 +677,7 @@ SupportedAlgorithmsMap supported_algorithms()
|
||||||
// https://w3c.github.io/webcrypto/#pbkdf2
|
// https://w3c.github.io/webcrypto/#pbkdf2
|
||||||
define_an_algorithm<PBKDF2>("importKey"_string, "PBKDF2"_string);
|
define_an_algorithm<PBKDF2>("importKey"_string, "PBKDF2"_string);
|
||||||
define_an_algorithm<PBKDF2, PBKDF2Params>("deriveBits"_string, "PBKDF2"_string);
|
define_an_algorithm<PBKDF2, PBKDF2Params>("deriveBits"_string, "PBKDF2"_string);
|
||||||
// FIXME: define_an_algorithm("get key length"_string, "PBKDF2"_string, ""_string);
|
define_an_algorithm<PBKDF2>("get key length"_string, "PBKDF2"_string);
|
||||||
|
|
||||||
// https://w3c.github.io/webcrypto/#rsa-oaep
|
// https://w3c.github.io/webcrypto/#rsa-oaep
|
||||||
define_an_algorithm<RSAOAEP, RsaHashedKeyGenParams>("generateKey"_string, "RSA-OAEP"_string);
|
define_an_algorithm<RSAOAEP, RsaHashedKeyGenParams>("generateKey"_string, "RSA-OAEP"_string);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue