Commit graph

75 commits

Author SHA1 Message Date
Andreas Kling
52c46483d1 LibWeb: Handle raw-secret key formats in wrap_key
Refresh the imported wrapKey_unwrapKey WPT to the current upstream
version and treat the raw-secret and other raw* formats like raw
when wrap_key() and unwrap_key() serialize wrapped key bytes.

The updated test covers ChaCha20-Poly1305 wrapping with the
raw-secret format. Accepting the full set of byte-oriented raw
formats lets those keys round-trip through wrapKey and unwrapKey.
2026-03-29 13:21:36 +02:00
Andreas Kling
3726df5a9e LibWeb: Align wrapKey steps with the WebCrypto spec
Keep the existing comment wording and wrapping where it already
matched the spec, but fix the places where wrap_key() and
unwrap_key() had drifted from the current wrapKey and unwrapKey
steps.

Add the missing realm and wrappedKey steps, use the spec terms
exportedKey, bytes, and key in the touched blocks, and leave
explicit FIXME comments for the queue-a-task and conversion
steps that we still skip.
2026-03-29 13:21:36 +02:00
mikiubo
d4cf537d58 LibCrypto: Implement KMAC authentication support
Add a LibCrypto::Authentication::KMAC helper over OpenSSL.
Add keygen/import/export logic into WebCrypto.
Register KMAC128/KMAC256 operations with SubtleCrypto.
2026-03-19 10:46:49 +01:00
mikiubo
1ac12651f6 LibWeb: Update SubtleCrypto.digest() to match the spec
The WebCrypto spec was updated to normalize the algorithm before
getting a copy of the data bytes, and to queue a global task on the
crypto task source when rejecting or resolving the promise.

This fixes some WPT tests.
2026-03-17 21:05:13 +01:00
mikiubo
0e2d8ff43a LibWeb: Update SubtleCrypto.sign() and verify() to match the spec
The WebCrypto spec was updated to normalize the algorithm before
getting a copy of the input bytes, and to queue a global task on the
crypto task source when rejecting or resolving the promise.
2026-03-15 20:03:58 +01:00
mikiubo
17fe3ae00c LibWeb: Update SubtleCrypto.encrypt() and decrypt() to match the spec
The WebCrypto spec was updated to normalize the algorithm before
getting a copy of the data bytes, and to queue a global task on the
crypto task source when rejecting or resolving the promise.
2026-03-06 14:21:46 +01:00
mikiubo
0d08aa2b58 LibWeb: Fix incorrect error message in SubtleCrypto::decrypt
The error message incorrectly stated "encryption" when checking
for decrypt usage. Updated it to "decryption" for accuracy and
consistency with the operation being performed.
2026-03-06 14:21:46 +01:00
mikiubo
50ec070017 LibCrypto: Add AES-OCB support
Implement AES-OCB AEAD using OpenSSL and expose it through
the WebCrypto API, including key management and AEAD parameters.

Add WPT:
/encrypt_decrypt/aes_ocb.tentative.https.any.html
2026-02-27 12:03:19 +01:00
mikiubo
ba75d4c014 LibCrypto: Add ChaCha20-Poly1305 support
Implement ChaCha20-Poly1305 AEAD using OpenSSL and expose it through
the WebCrypto API, including key management and AEAD parameters.

Add WPT:
/encrypt_decrypt/chacha20_poly1305.tentative.https.any.worker.html
2026-01-26 10:03:09 +01:00
mikiubo
cd8465a6b5 LibCrypto: Add SHAKE digest support
Introduce a new SHAKE hash wrapper in LibCrypto backed by OpenSSL.

Wire cSHAKE128 and cSHAKE256 into WebCrypto.

Note that cSHAKE with non-empty functionName or customization is
currently rejected due to OpenSSL EVP limitations.

This fixes WPT:
WebCryptoAPI/digest/cshake.tentative.https.any.html
2026-01-22 19:47:09 -05:00
Tete17
7ac6aecef0 LibWeb: Implement decapsulation for ML-KEM algorithms 2026-01-06 01:06:06 +01:00
Tete17
140bbe50ab LibWeb: Extend decapsulate(Key|Bits) methods to pass the key
This is mandated by the spec but since no algorithm supported this
method, yet we didn't notice it was missing.
2026-01-06 01:06:06 +01:00
Tete17
56804e7930 LibWeb: Support the exporting of ml-kem keys in spki format 2026-01-06 01:06:06 +01:00
Tete17
86e9765fe7 LibWeb: Pass the correct algorithms parameters when importing shared key
During decapsulate we were passing the parameters for decapsulate
instead of the ones for the shared key.
2026-01-06 01:06:06 +01:00
Tete17
94410298f3 LibWeb: Implement Derive Bits for Argon2 algorithm 2026-01-04 15:56:54 +01:00
Tete17
2cc71e6437 LibWeb: Support the importing for Argon2 keys 2026-01-04 15:56:54 +01:00
Tete17
ebd0874fb5 LibWeb: Implement Get Key Length for Argon2 algorithm 2026-01-04 15:56:54 +01:00
Tete17
1e6b5a6f81 LibWeb: Set the extractable and usages fields of the generated key
This was a spec bug updated in
https://github.com/WICG/webcrypto-modern-algos/pull/39
2025-12-30 14:16:35 +01:00
Tete17
a414819dd6 LibWeb: Support the importing of ml-kem keys in spki format 2025-12-30 14:16:35 +01:00
Tete17
6350b063ab LibWeb: Implement encapsulation for ML-KEM algorithms 2025-12-30 14:16:35 +01:00
Tete17
013cf34d1b LibWeb: Implement key generation for ML-KEM algorithms 2025-12-30 14:16:35 +01:00
Tete17
336929c5a3 LibWeb: Add TemporaryExecutionContext to encapsulate/decapsulate methods
Some operations like retrieving the algorithm name require it.
2025-12-30 14:16:35 +01:00
Tete17
ec67f0ae8d LibWeb: Change return type of encapsulate for AlgorithmMethods
The standard ask to turn EncapsulatedBits into an ECMAScript Object
which means it must initially live in the host stack.
2025-12-30 14:16:35 +01:00
Tete17
63c99f3703 LibWeb: Correctly check the usage of the encapsulation key 2025-12-30 14:16:35 +01:00
Tete17
fdb01e7f93 LibWeb: Add the Crypto task source
This is used by the spec to queue tasks to resolve or reject promises
created in response to calls to methods of SubtleCrypto.
2025-12-28 18:56:50 +01:00
Tete17
305e9c1b0f LibWeb: Implement decapsulateBits for SubtleCrypto 2025-12-28 18:56:50 +01:00
Tete17
c9b8b4557d LibWeb: Implement decapsulateKey for SubtleCrypto 2025-12-28 18:56:50 +01:00
Tete17
f13c0fb317 LibWeb: Support the exporting of ml-dsa keys in spki format 2025-12-10 21:26:06 +01:00
Tete17
7a9ed4ba71 LibWeb: Support the importing of ml-dsa keys in spki format 2025-12-10 21:26:06 +01:00
Tete17
e596572085 LibWeb: Implement verify for ML-DSA algorithm 2025-12-10 21:26:06 +01:00
Tete17
ef0205ec86 LibWeb: Implement message signing for ML-DSA algorithm 2025-12-10 21:26:06 +01:00
Tete17
a9ade1c238 LibWeb: Implement key generation for ML-DSA algorithms 2025-12-10 21:26:06 +01:00
Tete17
6c143049b3 LibWeb: Fix typo in spec url 2025-12-10 21:26:06 +01:00
Tete17
c790de24dd LibWeb: Implement encapsulateBits method for SubtleCrypto
None of the current algorithms supports the method but the future
post quantum algorithms will do so.
2025-11-27 21:50:06 +01:00
Tete17
b36a702ad1 LibWeb: Implement encapsulateKey method for SubtleCrypto
None of the current algorithms supports the method but the future
post quantum algorithms will do so.
2025-11-27 21:50:06 +01:00
Tete17
1d6a64b26c LibWeb: Update the Key Usage enum to adapt for PostQuantum Algorithms 2025-11-27 21:50:06 +01:00
Tete17
5e736d4e07 LibWeb: Expose SHA3 hashing algorithm through WebCryptoAPI
This give us 48 WPT subtests :)
2025-11-26 22:01:00 -05:00
Timothy Flynn
70db474cf0 LibJS+LibWeb: Port interned bytecode strings to UTF-16
This was almost a no-op, except we intern JS exception messages. So the
bulk of this patch is porting exception messages to UTF-16.
2025-08-14 10:27:08 +02:00
Timothy Flynn
0efa98a57a LibJS+LibWeb+WebContent: Port JS::PropertyKey to UTF-16
This has quite a lot of fall out. But the majority of it is just type or
UDL substitution, where the changes just fall through to other function
calls.

By changing property key storage to UTF-16, the main affected areas are:
* NativeFunction names must now be UTF-16
* Bytecode identifiers must now be UTF-16
* Module/binding names must now be UTF-16
2025-08-05 07:07:15 -04:00
Andreas Kling
a6dfc74e93 LibWeb: Only set prototype once for object with IDL interface
Before this change, we were going through the chain of base classes for
each IDL interface object and having them set the prototype to their
prototype.

Instead of doing that, reorder things so that we set the right prototype
immediately in Foo::initialize(), and then don't bother in all the base
class overrides.

This knocks off a ~1% profile item on Speedometer 3.
2025-04-20 18:43:11 +02:00
Andreas Kling
938b1e91fe LibJS: Inline the fast path of Value::to_i32() and simplify to_u32()
The fast path of to_i32() can be neatly inlined everywhere, and we still
have to_i32_slow_case() for non-trivial conversions.

For to_u32(), it really can just be implemented as a static cast to i32!
2025-04-09 22:06:49 +02:00
Andreas Kling
de424d6879 LibJS: Make Completion.[[Value]] non-optional
Instead, just use js_undefined() whenever the [[Value]] field is unused.
This avoids a whole bunch of presence checks.
2025-04-05 11:20:26 +02:00
Andreas Kling
53da8893ac LibJS: Replace PropertyKey(char[]) with PropertyKey(FlyString)
...and deal with the fallout.
2025-03-24 22:27:17 +00:00
Andreas Kling
d7908dbff5 LibJS: Change PropertyKey(ByteString) to PropertyKey(String)
...and deal with the fallout.
2025-03-24 22:27:17 +00:00
devgianlu
718d338d68 LibWeb: Remove useless JS::ThrowCompletionOr return types
All `SubtleCrypto` methods except `import_key` do not require
`JS::ThrowCompletionOr` as they return only rejected promises.
2025-02-12 00:40:17 +01:00
Timothy Flynn
85b424464a AK+Everywhere: Rename verify_cast to as
Follow-up to fc20e61e72.
2025-01-21 11:34:06 -05:00
devgianlu
999f456ba4 LibWeb: Support RSASSA-PKCS1-v1_5 in WebCryptoAPI 2025-01-17 12:43:03 +01:00
devgianlu
e05ee9d297 LibWeb: Support RSA-PSS in WebCryptoAPI 2025-01-17 12:43:03 +01:00
devgianlu
b9ba1b3f72 LibWeb: Add Ed448 support in WebCryptoAPI
Add full support for Ed448 and import relevant tests.
2025-01-11 11:13:06 +01:00
devgianlu
4b87467fc2 LibWeb: Update SubtleCrypto IDL according to latest spec
I suppose the IDL definition for `deriveBits` changed to make the
last parameter optional.
2024-12-18 13:18:40 +01:00