Commit graph

275 commits

Author SHA1 Message Date
Andreas Kling
b6bef6b688 Libraries: Use UTF-16 for JS-visible runtime strings
Produce JS-visible string results as UTF-16 at their source, including
numeric formatting, BigInt and BigFraction formatting, URI encoding,
console formatting, parser errors, regular expression errors, Intl and
Temporal records, LibUnicode locale boundaries, and LibWeb bindings.

Handle fractional radix formatting through the UTF-16 builder view.
2026-06-22 19:51:25 +02:00
Andreas Kling
7025dd1fa7 Libraries: Parse JS strings from UTF-16
Thread UTF-16 string input through JSON, script parsing, Date parsing,
Intl option parsing, Temporal parsing, and the helper library boundaries
that feed those parsers. Preserve ASCII fast paths where the source data
is known to be ASCII.
2026-06-22 19:51:25 +02:00
Tim Ledbetter
ed6aec8dfa LibCrypto: Restore cached tag when a failed ASN1 read is rolled back
Previously, the stack would be restored to its previous position but
the tag would retain its old value, leading to an inconsistent state.
2026-06-09 08:02:44 +01:00
Tete17
8b8c021a91 LibCrypto: Support EC compressed point format (0x02/0x03)
Add SECPxxxr1Point::from_compressed() to decompress SEC 1 compressed
EC public keys using OpenSSL's EC_POINT_oct2point. Refactor
read_ec_public_key() to delegate to SECPxxxr1Point::from_uncompressed
and from_compressed, removing duplicated parsing logic.
2026-05-12 13:58:38 +02:00
mikiubo
6fb0e6d1fc LibCrypto: Support compressed EC point format for key import
Use OpenSSL's EC_POINT_oct2point to decompress EC public keys
encoded in the compressed point format (0x02/0x03 prefix)
2026-05-12 10:19:29 +02:00
Andreas Kling
c6a79c3ae3 LibJS+LibCrypto: Account BigInt limbs as external memory
Expose the Tommath limb allocation size from LibCrypto big integers.
Use it as the external memory size for LibJS BigInt cells so large
integer values participate in GC threshold calculations.
2026-05-07 10:03:09 +02:00
Undefine
e39a8719fd Meta: Move most dependency checks to check_for_dependencies.cmake
This file was here for quite a long while now. Let's finally move most
of the dependency checks to one centralized place.
2026-04-20 16:41:29 -06:00
mikiubo
4110a05684 LibCrypto: Use OpenSSL wrappers in KMAC
Use OpenSSL_MAC and OpenSSL_MAC_CTX wrappers together with
OPENSSL_TRY to replace manual EVP_MAC resource management in
KMAC::sign(). This eliminates manual EVP_MAC_free/EVP_MAC_CTX_free
calls in every error path.
2026-03-25 22:07:53 +01:00
Praise-Garfield
22e8e99d4c LibCrypto: Use EVP_EncryptInit instead of EVP_DecryptInit in GCM encrypt
The first EVP initialization call in AESGCMCipher::encrypt() used
EVP_DecryptInit. Every other cipher mode in the file correctly matches
its init calls to the operation direction (CBC, CTR, OCB, KW).

The second EVP_EncryptInit call overrides the context direction before
any ciphertext is produced, but the EVP_CTRL_GCM_SET_IVLEN control call
on the next line executes while the context is in decrypt mode.
2026-03-19 22:28:26 +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
Ben Wiederhake
62e3238aa7 LibCrypto: Remove unused header in RSA 2026-02-23 12:15:23 +01:00
Ben Wiederhake
05f60513f7 LibCrypto: Remove unused header in SECPxxxr1 2026-02-23 12:15:23 +01:00
Ben Wiederhake
f7b7f105f2 LibCrypto: Remove unused header in EdwardsCurve 2026-02-23 12:15:23 +01:00
Ben Wiederhake
e15ba97178 LibCrypto: Remove unused header in ChaCha 2026-02-23 12:15:23 +01:00
Ben Wiederhake
7d92ba189f LibCrypto: Remove unused header in AES 2026-02-23 12:15:23 +01:00
Ben Wiederhake
013e10aee6 LibCrypto: Remove unused header in Certificate 2026-02-23 12:15:23 +01:00
Ben Wiederhake
0e0c85639a LibCrypto: Remove unused header in UnsignedBigInteger 2026-02-23 12:15:23 +01:00
Ben Wiederhake
162e7e6935 LibCrypto: Remove unused header in SignedBigInteger 2026-02-23 12:15:23 +01:00
Ben Wiederhake
ad5e0e28bc LibCrypto: Remove unused header in BigFraction 2026-02-23 12:15:23 +01:00
Ben Wiederhake
09d71f38b4 LibCrypto: Remove unused header in DER 2026-02-23 12:15:23 +01:00
Timothy Flynn
ecdaa7911f LibCrypto: Add a method to count the number of digits in a big int 2026-02-22 09:39:10 -05: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
Luke Wilde
8395db7e84 LibCrypto+LibJS: Add to_i64 method for SignedBigInteger and use it 2026-01-16 07:00:02 -05:00
Tete17
ddcf568c7b LibCrypto: Implement decapsulate method for MLKEM algorithm 2026-01-06 01:06:06 +01:00
Tete17
dac1952e47 LibCrypto: Support the parsing of certs and keys for ml-kem keys 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
03c126e384 LibCrypto: Implement Argon2 hash algorithm 2026-01-04 15:56:54 +01:00
Tete17
23692ccc90 LibCrypto: Make HKDF and PBKDF2 algorithms non copyable
These contain pointer members pointers and copying them can lead to
a double free scenario.
2026-01-04 15:56:54 +01:00
Tete17
18cf5db272 LibCrypto: Support the parsing of certs and keys for ml-kem keys 2025-12-30 14:16:35 +01:00
Tete17
5348e97f87 LibCrypto: Implement encapsulation for ML-KEM algorithms 2025-12-30 14:16:35 +01:00
Tete17
92fdc97d98 LibCrypto: Implement key generation for ML-KEM algorithms 2025-12-30 14:16:35 +01:00
Tete17
cabcf3ed66 LibCrypto: Add wrapper to EVP_PKEY_get_octet_string_param 2025-12-30 14:16:35 +01:00
Tete17
5126e4b409 LibCrypto: Support the parsing of certs and keys for ml-dsa keys 2025-12-10 21:26:06 +01:00
Tete17
83b5ed8e9f LibCrypto: Implement verify for ML-DSA algorithm 2025-12-10 21:26:06 +01:00
Tete17
995850082c LibCrypto: Implement message signing for ML-DSA algorithm 2025-12-10 21:26:06 +01:00
Tete17
2451a9c74b LibCrypto: Implement key pair generation for ML-DSA algorithm
This is the first post quantum algorithm in the project
2025-12-10 21:26:06 +01:00
Tete17
8bb52c7b67 LibCrypto: Remove no longer needed output_size in Public Key class
It is a remnant of serenityos and doesn't make sense in non RSA
algorithms.
2025-12-10 21:26:06 +01:00
Tete17
0786486aa2 LibCrypto: SHA3 hashing algorithm 2025-11-26 22:01:00 -05:00
Psychpsyo
100f37995f Everywhere: Clean up AD-HOC and FIXME comments without colons 2025-11-13 15:56:04 +01:00
Jelle Raaijmakers
c31eff6a47 Everywhere: Use Optional<T>::ensure() where useful
No functional changes.
2025-09-17 12:01:18 -04:00
Ali Mohammad Pur
4462348916 Everywhere: Slap some [[clang::lifetimebound]] where appropriate
This first pass only applies to the following two cases:
- Public functions returning a view type into an object they own
- Public ctors storing a view type

This catches a grand total of one (1) issue, which is fixed in
the previous commit.
2025-09-01 11:11:38 +02:00
Timothy Flynn
28d9d3a2c7 AK+Libraries: Reduce API surface of GenericLexer a bit
* Remove completely unused methods.
* Deduplicate methods that were overloaded with both StringView and
  char const* parameters.

A future commit will templatize GenericLexer by char type. This patch
serves to make that a tiny bit easier.
2025-08-13 09:56:13 -04:00
Timothy Flynn
213683956c LibCrypto: Return StringView from ASN1 enum-to-string factories
We were implicitly including ByteString.h here, which will become a
compile error in an upcoming commit. Let's just return StringView.
2025-08-13 09:56:13 -04:00
Idan Horowitz
110136b862 LibCrypto: Convert SignedBigInteger::import_data to accept Bytes
This brings it up to par with UnsignedBigInteger.
2025-08-05 09:08:56 +02:00
Idan Horowitz
b0fdbe3756 LibCrypto: Convert UnsignedBigInteger::import_data to accept Bytes
All the callers are already using Bytes and manually converting to the
old style pointer + length when calling this API.
2025-08-05 09:08:56 +02:00
Idan Horowitz
2a3b072d0e LibCrypto: Convert SignedBigInteger::export_data to return a span
This brings it up to par with UnsignedBigInteger.
2025-08-05 09:08:56 +02:00
Idan Horowitz
660a499223 LibCrypto: Convert UnsignedBigInteger::export_data to return a span
This helps make callers only use the slice of the output buffer that
was written to.

As part of updating the callers of the API several bugs were fixed and
useless code paths were removed:
- The exported data is not host-endianess dependent (always big endian)
- The exported data does not contain leading zeros
- The output buffer is only written up to the result's size
2025-08-05 09:08:56 +02:00