Commit Graph

151 Commits

Author SHA1 Message Date
Shannon Booth
0cf991e205 LibWeb/Crypto: Move WebCrypto dictionaries into Crypto namespace
Keep the JsonWebKey dictionary types in line with other dictionary
types in the codebase by putting them in the Crypto namespace
rather than under Web::Bindings.
2026-04-23 22:12:13 +02:00
Tete17
1af8cc471d LibWeb: Validate JWK key pair consistency for OKP importKey
For private key JWK imports, after decoding both d and x, derive
the public key from d and verify it matches x. A private key that
doesn't correspond to the provided public key doesn't "contain the
private key" as required by RFC 8037 Section 2.
2026-04-19 13:35:36 +02:00
Tete17
32af84b698 LibWeb: Validate JWK key length for OKP importKey
After base64url-decoding the x and d fields during JWK import,
verify the decoded byte length matches the expected key size for
the curve (32 for Ed25519/X25519, 57 for Ed448, 56 for X448).
A truncated value does not "contain the public/private key" as
required by RFC 8037 Section 2.
2026-04-19 13:35:36 +02:00
Tete17
00e9396cfe LibWeb: Fix Ed448 raw key length check in importKey
Ed448 public keys are 57 bytes (456 bits), not 56 bytes (448 bits).
The curve is named "Ed448" after its 448-bit prime field, but per
RFC 8032 Section 5.2.5, the parameter b=456 and both private and
public keys are 57 bytes. This caused importKey to reject valid raw
Ed448 public keys with a DataError.

Note: The spec incorrectly says "not 448" for this check.
See https://github.com/w3c/webcrypto/pull/425#discussion_r3070135408
2026-04-19 13:35:36 +02:00
mikiubo
29ae949798 LibWeb: Use outputLength instead of length in KmacParams
The WebCrypto spec was updated to rename the KMAC algorithm
parameter from length to outputLength.
2026-03-25 22:07:53 +01:00
mikiubo
63d8f6b4a9 LibWeb: Use outputLength instead of length in CShakeParams
The WebCrypto spec was updated to rename the CSHAKE algorithm
parameter from length to outputLength.
2026-03-22 14:13:21 +01: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
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
devgianlu
492b97f769 LibWeb/Crypto: Update spec links
Add and update spec links to more precise ones
and move X25519 and Ed25519 from WICG to W3C.
2026-02-14 17:43:34 +01:00
Psychpsyo
dab742ed84 Everywhere: Remove double // on comments 2026-02-11 13:28:01 -06:00
mikiubo
4a1a15ce66 LibWeb: Allow importing ChaCha20-Poly1305 JWK without alg
The WebCrypto specification does not require the "alg" member
to be present when importing a symmetric JWK, as long as the
key material itself is valid.

Add tests covering JWK import without an "alg" field.

This fixes the following WPT:
WebCryptoAPI/import_export/ChaCha20-Poly1305_importKey
2026-02-05 09:05:11 +01:00
mikiubo
ff2acd1d33 LibWeb: Use unchecked_append for pre-sized JWK key_ops vectors
The key_ops vector is pre-sized with ensure_capacity(), so
bounds-checked append() is unnecessary here.

Switch to unchecked_append() to avoid redundant checks.

This change was suggested in a previous pull request #7563.

Add some typo and wrong comment.
2026-02-04 19:19:09 +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
Colleirose
bf7fd80140 LibCrypto+AK: Merge LibCrypto/SecureRandom into AK/Random
AK/Random is already the same as SecureRandom. See PR for more details.

ProcessPrng is used on Windows for compatibility w/ sandboxing measures
See e.g. https://crbug.com/40277768
2026-01-23 15:53:27 +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
Jelle Raaijmakers
ae20ecf857 AK+Everywhere: Add Vector::contains(predicate) and use it
No functional changes.
2026-01-08 15:27:30 +00:00
Tete17
7ac6aecef0 LibWeb: Implement decapsulation for ML-KEM algorithms 2026-01-06 01:06:06 +01:00
Tete17
08b48d5369 LibWeb: Align input argument name to the spec 2026-01-06 01:06:06 +01:00
Tete17
a739311fdc LibWeb: Support the exporting of ml-kem keys in pkcs8 format 2026-01-06 01:06:06 +01:00
Tete17
9c5cb08b63 LibWeb: Support the importing of ml-kem keys in pkcs8 format 2026-01-06 01:06:06 +01:00
Tete17
df0796bdf2 LibWeb: Support the exporting of ml-kem keys in raw-seed format 2026-01-06 01:06:06 +01:00
Tete17
ed025f5fcd LibWeb: Support the importing of ml-kem keys in raw-seed format 2026-01-06 01:06:06 +01:00
Tete17
ab74519a0b LibWeb: Support the exporting of ml-kem keys in raw-public format 2026-01-06 01:06:06 +01:00
Tete17
0fc7746b96 LibWeb: Support the importing of ml-kem keys in raw-public format 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
4e41cfb6c4 LibWeb: Correctly set the usage on the private key for ML-KEM
This is one lines gives us almost 1000 WPTs :)
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
7b3a97a928 LibWeb: Implement Argon2Params
This is the needed context for the Derive Bits operation of the 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
bbf70e320f LibWeb: Allow symmetric algorithms to be imported with RawSecret
This new format is equivalent to the old Raw.
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
26a9551db2 LibWeb: Correctly transform EncapsulatedKey into an ECMAScript object
The spec prefers camel case, but we internally use snake case.
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
b65b8c2e6a LibWeb: Use ReadOnlyBytes when encoding ml-dsa public keys
This fixes a build error caused by a merge conflict with some recent
changes in out base64 infrastructure.
2025-12-10 22:46:54 +01:00
Tete17
006428db7a LibWeb: Support the exporting of ml-dsa keys in pkcs8 format 2025-12-10 21:26:06 +01:00
Tete17
b63a0903aa LibWeb: Support the importing of ml-dsa keys in pkcs8 format 2025-12-10 21:26:06 +01:00
Tete17
2078317a51 LibWeb: Support the exporting of ml-dsa keys in jwk format 2025-12-10 21:26:06 +01:00
Tete17
a5e037e2af LibWeb: Support the importing of ml-dsa keys in jwk format 2025-12-10 21:26:06 +01:00
Tete17
affaa8169f LibWeb: Support the exporting of ml-dsa keys in raw-seed format 2025-12-10 21:26:06 +01:00
Tete17
9bea146212 LibWeb: Support the importing of ml-dsa keys in raw-seed format 2025-12-10 21:26:06 +01:00
Tete17
16b0918579 LibWeb: Support the exporting of ml-dsa keys in raw-public format 2025-12-10 21:26:06 +01:00
Tete17
f56f7a0916 LibWeb: Support the importing of ml-dsa keys in raw-public format 2025-12-10 21:26:06 +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