Commit graph

311 commits

Author SHA1 Message Date
Steffen Jaeckel
e5df4f7ce8 Fix build with -DLTC_MINIMAL.
Fixes: 661109f660 ("re-factor modes to use internal ECB implementation")
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-04-23 09:13:02 +02:00
Steffen Jaeckel
661dad10c7 Make HW-accel checkers always available.
Since the SHA-NI checker does the same for all three versions, we only have
to make one version public. This also now enables explicit testing of the
SHA-NI blocks.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-04-23 09:13:02 +02:00
Marek Knápek
874e095a19 SHA-256 & SHA-224 x86 2026-04-15 15:22:25 +02:00
Marek Knápek
7ac05df902 Add x86-optimized SHA1. 2026-04-15 15:20:28 +02:00
Karel Miko
e4d3bd2fa5 RSA: replace hash_alg + mgf1_hash_alg with hash_idx + mgf1_hash_idx 2026-04-15 11:12:30 +02:00
Karel Miko
c1b3281433 RSA: no more dual semantics of pss_oaep (removed from ltc_rsa_parameters; now lives on rsa_key where it belongs) 2026-04-15 11:12:30 +02:00
Steffen Jaeckel
66e677aedd Introduce new RSA API.
This also:
a) deprecates the old RSA and PKCS#1 API.
b) reverts the changes done to them in order to make the now deprecated API
   compatible again with the last release.

The fixes commit mentioned below is the testcase for the Bleichenbacher
attack, which works now again as expected.

Fixes: 9d03c38e ("add flags to `der_decode_sequence()`")
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-04-15 11:12:30 +02:00
Steffen Jaeckel
56f0e118dd Add support for separate MGF1 hashes
Update PKCS#1-PSS and RSA APIs that allow passing a separate hash index for
the MGF1 hash.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-04-15 11:12:30 +02:00
Karel Miko
3aed12c410 The scrypt Password-Based Key Derivation Function (RFC 7914) 2026-04-14 13:59:38 +02:00
Steffen Jaeckel
c68b9c0b3f Minor changes of argon2 implementation.
* We continue using `LTC_ARGCHK()` until we've decided on something else.
* Call the enum/struct the same as the typedef.
* Some other small adjustments/fixes.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-04-12 16:06:53 +02:00
Karel Miko
458b392d01 Argon2 password hashing function (RFC 9106) 2026-04-12 14:48:32 +02:00
Steffen Jaeckel
11929885a4 Basic algo self-tests should be run before the ones using them.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-04-09 15:40:07 +02:00
Marek Knápek
6832f3c106 Add KangarooTwelve XOF functions.
KangarooTwelve 128bits and KangarooTwelve 256 bits.

https://keccak.team/files/TurboSHAKE.pdf
https://www.rfc-editor.org/rfc/rfc9861.txt
https://datatracker.ietf.org/doc/html/rfc9861
2025-11-28 19:05:31 +01:00
Marek Knápek
709572e22e Add TurboSHAKE XOF functions.
TurboSHAKE128 and TurboSHAKE256.
https://datatracker.ietf.org/doc/html/rfc9861
https://www.rfc-editor.org/rfc/rfc9861.txt
https://keccak.team/files/TurboSHAKE.pdf
https://github.com/libtom/libtomcrypt/issues/691
2025-11-25 09:22:35 +01:00
Steffen Jaeckel
dda1c7eedf Re-factor modes_test().
... also funny that no static analyzer complained about `ret` being
assigned, but never read ...

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-11-24 14:58:13 +01:00
Steffen Jaeckel
6daff83d82 Deprecate compare_testvector().
This should never have been public API.
Also introduce a `LTC_COMPARE_TESTVECTOR()` macro to be used within the
library, which doesn't exit, but only returns an error.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-11-24 14:58:13 +01:00
Steffen Jaeckel
d77afd6a68 Use rsa_init() to initialize an rsa_key
(and you should do that too)

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-11-18 23:03:42 +01:00
Steffen Jaeckel
b46c695505 Add tests for deprecated APIs
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-11-18 18:53:26 +01:00
Steffen Jaeckel
35a4a5fc1b Move RFC6979 hash alg to a new ecc signature options struct
Fixes #700

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-11-18 18:53:26 +01:00
Steffen Jaeckel
47162b9609 Add demos/der_print_flexi.c
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-11-03 13:56:42 +01:00
Steffen Jaeckel
e2d0935792 Add SHA3-HMAC support to PKCS#8
This also enables testing of PKCS#8 keys using modern hash algos with
LTC_EASY.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-11-03 13:52:38 +01:00
Steffen Jaeckel
78e2675bfe Make store_test() a bit more aggressive.
With `LTC_FAST` enabled test to read from different offsets.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-11-03 13:52:29 +01:00
Steffen Jaeckel
5dbdaff16b Minor fixes
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-11-03 13:52:16 +01:00
Steffen Jaeckel
a58de2e03d Fix some scan-build warnings
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-09-13 12:04:38 +02:00
Steffen Jaeckel
1978245572 Update makefiles 2025-09-13 12:04:38 +02:00
Steffen Jaeckel
78bb06c8d6 Minor cleanup
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-09-12 18:25:09 +02:00
Steffen Jaeckel
07d544c5d9 Add tests for & fix pk_oid API
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-09-12 18:25:09 +02:00
Steffen Jaeckel
fe32e7ea9d Add LTC_ARRAY_SIZE() macro
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-09-06 15:00:00 +02:00
Steffen Jaeckel
6155a33e5f Use COMPARE_TESTVECTOR() consistently
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-09-06 15:00:00 +02:00
Steffen Jaeckel
cb12f2e7d0 Clarify some test descriptions
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-09-06 15:00:00 +02:00
Steffen Jaeckel
661109f660 re-factor modes to use internal ECB implementation 2025-09-05 17:37:02 +02:00
Steffen Jaeckel
46fa363f2c Finish up RFC6979 ECDSA keygen
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-09-04 17:36:30 +02:00
Russ Williams
d376af52ca RFC6979: implementation, tests, docs 2025-09-04 17:36:30 +02:00
Steffen Jaeckel
ecb5fdd997 Add testcase for Ethereum signatures.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-03-02 12:09:24 +01:00
Karel Miko
6561b37bac refactor ecc_verify_hash_ex 2025-03-02 12:09:24 +01:00
Karel Miko
0ee3bb5786 refactor ecc_sign_hash_ex 2025-03-02 12:09:24 +01:00
Steffen Jaeckel
236477823a prefix the MPI related macros with ltc_
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-02-20 14:41:50 +01:00
Steffen Jaeckel
cda7d42647 Improve ILP32 detection
This should fix https://github.com/DCIT/perl-CryptX/issues/117

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2025-02-17 15:12:53 +01:00
Steffen Jaeckel
faa8cd71e5 add SIV
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-12-17 18:24:26 +01:00
Steffen Jaeckel
d96605b4b9 Fix build on x32
* `CONSTPTR()` must be 32bit.
* `CRYPT_HASH_OVERFLOW` test operates on `unsigned long`, which is only
  32bit wide on x32.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-12-11 11:09:58 +01:00
Steffen Jaeckel
a9bb1c1525 Use cmake-format to format CMake files
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-12-03 19:51:26 +01:00
Steffen Jaeckel
1d07689581 Remove unnecessary casts in the tests
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-11-08 17:15:39 +01:00
Steffen Jaeckel
5a1545a8ae Ensure test buffers are always '\0' terminated
This caused spurious test failures.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-10-12 14:04:49 +02:00
Steffen Jaeckel
ebfcff3027 Fix handling of trailing spaces when decoding PEM files
Reported via [0].

[0] https://github.com/DCIT/perl-CryptX/issues/110#issuecomment-2407279713

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-10-12 14:04:49 +02:00
Steffen Jaeckel
c1437deec2 Fix hang when decoding PEM
Reported via [0]

[0] https://github.com/DCIT/perl-CryptX/issues/110#issue-2533207989

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-10-12 14:04:33 +02:00
Tim van der Molen
33d1c81485 Improve SSE4.1/AES-NI support 2024-09-02 13:54:35 +02:00
Chao Wei
6f15a45adc Add SM4 block cipher
SM4 (formerly SMS4)[1] is a block cipher used in the Chinese
National Standard for Wireless LAN WAPI (Wired Authentication
and Privacy Infrastructure).
--from wikipedia
2024-08-30 05:30:48 +02:00
Richard Levitte
6170ba5205 fix: tests/cipher_hash_test.c failed to use aes_enc_test
Depending on build circumstances, the AES test function is either
aes_test() or aes_enc_test().
2024-08-20 14:35:16 +02:00
Steffen Jaeckel
2613264cef We can now also decrypt PEM files encrypted in CFB1 and CFB8 mode
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-08-20 13:29:27 +02:00
Steffen Jaeckel
cf79facfb9 Add support for CFB1 and CFB8
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-08-20 13:29:27 +02:00