Commit graph

1285 commits

Author SHA1 Message Date
Karel Miko
a58d4b5278 clang-cl fix related to intrin.h 2026-07-31 23:48:18 +02:00
Steffen Jaeckel
4a964ea017 Align macro based and inline LTC_FAST functions. 2026-07-31 20:27:50 +02:00
Karel Miko
6bc4dd9b7b fix UBSanitizer issue: load of misaligned address for type LTC_FAST_TYPE (replacing LTC_FAST_TYPE_PTR_CAST approach) 2026-07-31 20:16:48 +02:00
Steffen Jaeckel
88f95afc5c Rename according to PR #756
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-07-31 20:16:48 +02:00
karel-m
a467ea586b
Merge pull request #785 from libtom/pr/hash-memcpyable
Another attempt to make sha1/sha256 states memcpyable
2026-07-31 11:10:10 +02:00
Marek Knápek
c727c4032a Get rid of LTC_FAST_TYPE_PTR_CAST entirely.
As it might be dangerous to use it.

This introduces `LTC_FAST_TYPE_{ASSIGN,MASK,XOR{2,3}}()` in order to
replace the potential unaligned loads.

This fixes the following UBSAN errors:

src/modes/ctr/ctr_encrypt.c:56:66: runtime error: load of misaligned address 0x7ffea07ee82f for type 'LTC_FAST_TYPE', which requires 8 byte alignment
src/modes/ctr/ctr_encrypt.c:56:64: runtime error: store to misaligned address 0x7ffea07ee82f for type 'LTC_FAST_TYPE', which requires 8 byte alignment
tests/store_test.c:66:91: runtime error: load of misaligned address 0x7ffdd32f0d9f for type 'LTC_FAST_TYPE', which requires 8 byte alignment
tests/store_test.c:66:52: runtime error: load of misaligned address 0x7ffdd32f0d71 for type 'LTC_FAST_TYPE', which requires 8 byte alignment
tests/store_test.c:66:50: runtime error: store to misaligned address 0x7ffdd32f0dc1 for type 'LTC_FAST_TYPE', which requires 8 byte alignment
src/mac/pmac/pmac_process.c:40:50: runtime error: load of misaligned address 0x57c89c4329ec for type 'LTC_FAST_TYPE', which requires 8 byte alignment
src/mac/xcbc/xcbc_process.c:35:60: runtime error: load of misaligned address 0x57c89c432ccc for type 'LTC_FAST_TYPE', which requires 8 byte alignment
src/mac/f9/f9_process.c:39:58: runtime error: load of misaligned address 0x5c2b1a1d2c14 for type 'LTC_FAST_TYPE', which requires 8 byte alignment
src/encauth/gcm/gcm_process.c:82:58: runtime error: load of misaligned address 0x596b3e6aa354 for type 'LTC_FAST_TYPE', which requires 8 byte alignment
2026-07-31 10:45:09 +02:00
Marek Knápek
471f143078 Fix UBSAN errors
src/encauth/siv/siv.c:164:19: runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:44:28: note: nonnull attribute specified here
src/misc/compare_testvector.c:63:25: runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:65:33: note: nonnull attribute specified here
2026-07-31 10:44:16 +02:00
Karel Miko
a1a631efe4 make sha1/sha states clonable via memcpy 2026-07-30 20:17:44 +02:00
Karel Miko
23fca6ed39 Fix LTC_FALLTHROUGH related error reported by MSVC compiler 2026-07-30 16:01:06 +02:00
Karel Miko
cff7442824 SIV properly handle zero AD components 2026-07-30 15:39:27 +02:00
Karel Miko
074a354151 fix build failures with -std=c99 2026-07-30 15:22:33 +02:00
Karel Miko
0b6f0e1232 fix clang warnings -Wimplicit-fallthrough (while keeping /* FALLTHROUGH */ for some code review tools) 2026-07-30 15:22:33 +02:00
Karel Miko
26605163a4 fix clang warnings -Wmissing-variable-declarations 2026-07-30 15:22:33 +02:00
Karel Miko
661fcd6486 fix UBSanitizer issue: applying non-zero offset to null pointer 2026-07-30 15:22:33 +02:00
Karel Miko
5c8ac18bd1 fix UBSanitizer issue: memcpy/memcmp require non-null pointers even when the length is zero 2026-07-30 15:22:33 +02:00
Karel Miko
76a9ece653 fix UBSanitizer issue: left-shifting negative integer is undefined behavior 2026-07-30 15:22:33 +02:00
Karel Miko
509da35eee fix clang warning: 'err' may be used uninitialized 2026-07-30 15:22:33 +02:00
Karel Miko
209df8ae1a hardening pkcs8_get_children against uninitialized output pointers 2026-07-28 16:33:09 +02:00
Karel Miko
5c7757d0a5 various DER related fixes/improvements 2026-07-28 00:10:29 +02:00
Karel Miko
fcadf67bbb Argon2 enforce parallelism max 2^24-1 2026-07-21 11:02:31 +02:00
Karel Miko
39f5e1fae8 EAX properly handle taglen boundaries 2026-07-21 10:56:44 +02:00
Karel Miko
e00b22d939 CCM nonce is 7..13 bytes 2026-07-21 10:53:25 +02:00
Karel Miko
bc95a1fd2d hardening ecc_shared_secret against small-subgroup attacks 2026-05-25 16:18:14 +02:00
Karel Miko
ec7c05f94e fix issue #764 as suggested by @yaotushaozhu 2026-05-25 14:11:27 +02:00
Karel Miko
6c885c7732 SM3 hash function 2026-05-19 13:29:36 +02:00
Karel Miko
37a2e345a4 AES-GCM-SIV 2026-05-19 13:12:32 +02:00
Karel Miko
9b268d6258 KMAC - NIST SP 800-185 2026-05-19 13:03:25 +02:00
Steffen Jaeckel
05ad38ab66 With ARIA added, we can now decrypt ARIA encrypted PEM files.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-05-17 13:49:10 +02:00
Karel Miko
4d513a02fc ARIA block cipher (RFC 5794) 2026-05-16 11:38:38 +02:00
Karel Miko
1e4d471a9f RFC 8702: RSA-PSS-SHAKE128/256 and ECDSA-SHAKE128/256 2026-05-06 09:23:52 +02:00
Karel Miko
2c375b3a3c RSA OAEP - reject ciphertext values 0 and 1 2026-05-05 07:42:20 +02:00
Karel Miko
71f45fedbc x25519/x448 - reject all-zero shared secrets 2026-05-05 07:40:06 +02:00
Steffen Jaeckel
a724483a0b Add gcm_hw_pmul_is_supported()
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-05-04 10:47:11 +02:00
Steffen Jaeckel
c05b3088b4 Use __has_attribute() for target attribute.
... and bring aarch64/PMULL in similar shape as x86/PCLMUL.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-05-04 10:47:05 +02:00
Steffen Jaeckel
9e446e665f Better position to print this info.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-05-04 10:08:07 +02:00
Steffen Jaeckel
f940880a67 Create ENCRYPT_ONLY descriptors in amalgamated build.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-05-04 10:08:07 +02:00
Steffen Jaeckel
3520a0fcf5 Fix maybe-unitialized warnings.
Fixes: e20fff1f3d ("Add more TurboSHAKE unit tests.")
Fixes: 6832f3c106 ("Add KangarooTwelve XOF functions.")
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-05-04 10:08:07 +02:00
Steffen Jaeckel
011d427196 Remove dirty hacks in SHA3.
Fixes: 6832f3c106 ("Add KangarooTwelve XOF functions.")
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-05-04 10:08:07 +02:00
Steffen Jaeckel
001fa107d1 Some minor fixes detected in AMALGAMATED builds.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-05-04 10:08:07 +02:00
Marek Knápek
580be51806 Use LTC_UNUSED_PARAM().
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-05-04 10:08:07 +02:00
Steffen Jaeckel
45f95768da
Merge pull request #747 from libtom/pr/wycheproof-padding_depad
padding_depad - reject zero-length input (except for LTC_PAD_ZERO)
2026-04-30 11:42:08 +02:00
Karel Miko
e312fffaf2 fix ECC failing wycheproof tests 2026-04-30 11:41:04 +02:00
Karel Miko
176c4827fc fix Ed448/X448 failing wycheproof tests 2026-04-30 08:46:13 +02:00
Karel Miko
8a1b70a040 add FRP256v1 (French governmental ECC curve referenced in wycheproof test suite) 2026-04-30 08:44:46 +02:00
Karel Miko
577f2bc155 fix failing wycheproof test (ecdh_brainpoolP224r1_test.json tcId=787) ASN.1 BIT STRING related 2026-04-29 20:07:43 +02:00
Karel Miko
8ea53b4eaf padding_depad - reject zero-length input (except for LTC_PAD_ZERO) 2026-04-29 14:33:20 +02:00
Steffen Jaeckel
576258b5fc Fix ECC FP API.
We have to return an error code when working with the mutex API.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-04-29 10:53:40 +02:00
Steffen Jaeckel
22586373c3 Fix potential unsigned underflow.
Running the `timing` demo with `LTC_MECC_FP` enabled gave a segfault,
which Valgrind narrowed down to

```
==135594== Invalid read of size 1
==135594==    at 0x49298C: ss_accel_fp_mul2add (ltc_ecc_fp_mulmod.c:1007)
==135594==    by 0x4931C1: ltc_ecc_fp_mul2add (ltc_ecc_fp_mulmod.c:1192)
==135594==    by 0x41C1B2: ecc_verify_hash_internal (ecc_verify_hash_internal.c:114)
==135594==    by 0x41C830: ecc_verify_hash_rfc7518_internal (ecc_verify_hash_rfc7518.c:35)
==135594==    by 0x40340F: time_ecc (timing.c:1031)
==135594==    by 0x402894: main (timing.c:1621)
==135594==  Address 0x20feffeb2f is not stack'd, malloc'd or (recently) free'd
```

The origin being `ltc_mp_unsigned_bin_size(tkb)` returning 0, so y is -1,
but as an unsigned type that's no fun.

Fixed by making y a signed type.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-04-29 10:53:40 +02:00
Karel Miko
6affa8b99f fix LTC_MECC_FP 2026-04-29 10:53:40 +02:00
Marek Knápek
44d111e755 Fix for issue #738.
Closes: libtom/libtomcrypt#738
2026-04-27 23:25:14 +02:00