Skip to content

Commit abf55fe

Browse files
stelar7awesomekling
authored andcommitted
LibWeb: Implement PBKDF2 getKeyLength for SubtleCrypto
1 parent 19bb62d commit abf55fe

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Userland/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,4 +1397,10 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::ArrayBuffer>> PBKDF2::derive_bits(Algor
13971397
return JS::ArrayBuffer::create(realm, result.release_value());
13981398
}
13991399

1400+
WebIDL::ExceptionOr<JS::Value> PBKDF2::get_key_length(AlgorithmParams const&)
1401+
{
1402+
// 1. Return null.
1403+
return JS::js_null();
1404+
}
1405+
14001406
}

Userland/Libraries/LibWeb/Crypto/CryptoAlgorithms.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ class AlgorithmMethods {
197197
return WebIDL::NotSupportedError::create(m_realm, "exportKey is not supported"_fly_string);
198198
}
199199

200+
virtual WebIDL::ExceptionOr<JS::Value> get_key_length(AlgorithmParams const&)
201+
{
202+
return WebIDL::NotSupportedError::create(m_realm, "getKeyLength is not supported"_fly_string);
203+
}
204+
200205
static NonnullOwnPtr<AlgorithmMethods> create(JS::Realm& realm) { return adopt_own(*new AlgorithmMethods(realm)); }
201206

202207
protected:
@@ -231,6 +236,7 @@ class PBKDF2 : public AlgorithmMethods {
231236
public:
232237
virtual WebIDL::ExceptionOr<JS::NonnullGCPtr<CryptoKey>> import_key(AlgorithmParams const&, Bindings::KeyFormat, CryptoKey::InternalKeyData, bool, Vector<Bindings::KeyUsage> const&) override;
233238
virtual WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::ArrayBuffer>> derive_bits(AlgorithmParams const&, JS::NonnullGCPtr<CryptoKey>, u32) override;
239+
virtual WebIDL::ExceptionOr<JS::Value> get_key_length(AlgorithmParams const&) override;
234240

235241
static NonnullOwnPtr<AlgorithmMethods> create(JS::Realm& realm) { return adopt_own(*new PBKDF2(realm)); }
236242

Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ SupportedAlgorithmsMap supported_algorithms()
677677
// https://w3c.github.io/webcrypto/#pbkdf2
678678
define_an_algorithm<PBKDF2>("importKey"_string, "PBKDF2"_string);
679679
define_an_algorithm<PBKDF2, PBKDF2Params>("deriveBits"_string, "PBKDF2"_string);
680-
// FIXME: define_an_algorithm("get key length"_string, "PBKDF2"_string, ""_string);
680+
define_an_algorithm<PBKDF2>("get key length"_string, "PBKDF2"_string);
681681

682682
// https://w3c.github.io/webcrypto/#rsa-oaep
683683
define_an_algorithm<RSAOAEP, RsaHashedKeyGenParams>("generateKey"_string, "RSA-OAEP"_string);

0 commit comments

Comments
 (0)