Commit Graph

269 Commits

Author SHA1 Message Date
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
Chase Knowlden
6b4e00bc39 LibCrypto: Implement Ed25519 Small Order Points 2025-08-01 14:31:44 +02:00
Timothy Flynn
8600c5149b LibCrypto: Allow moving SignedBigInteger / UnsignedBigInteger
We defined copy operations but not move operations, so every existing
move() resulted in a copy.
2025-07-21 15:17:53 +02:00
Timothy Flynn
cd73c70ad6 LibCrypto: Copy the cached hash in SignedBigInteger / UnsignedBigInteger
The hash computation for big integers is pretty expensive, so if we have
a cached hash when copying a big int, let's also copy the hash.
2025-07-21 15:17:53 +02:00
Timothy Flynn
c6ebb7bf55 Meta+LibCrypto: Update openssl to version 3.5.1
This contains an API change that disallows setting the salt to a null
value. See:

4f5ffddfcb

This seems to be the opposite of the intended effect of that change,
but this patch includes a workaround nonetheless.

Co-Authored-By: devgianlu <altomanigianluca@gmail.com>
2025-07-16 17:03:15 +02:00
ayeteadoe
25f5936dee CMake: Rename serenity_* helper functions/macros to ladybird_* 2025-07-03 23:19:41 +02:00
Shannon Booth
ee8e4d1eec LibCrypto: Remove dependency on LibCore
This is not required.
2025-06-25 16:47:09 +01:00