Commit graph

311 commits

Author SHA1 Message Date
Karel Miko
5b05baaf36 BLAKE3 2026-08-04 11:26:06 +02:00
karel-m
02788482af
Merge pull request #788 from libtom/pr/pbes-fix-stack-over-read
PBES - fix stack over-read with malformed PBES2 parameters
2026-08-01 18:37:52 +02:00
Karel Miko
b50ffea546 PBES - fix stack over-read with malformed PBES2 parameters 2026-08-01 15:44:26 +02:00
Karel Miko
9e2984aa7e SHA-512 accelerated by x86 (alternative) 2026-08-01 11:17:36 +02:00
Steffen Jaeckel
97f5d72457 Ensure the table sizes are OK.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-07-31 23:57:51 +02:00
Steffen Jaeckel
b0894f683f Add pem tests with empty files.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-07-31 23:57:51 +02:00
Steffen Jaeckel
7978822b69 Add help to test binary.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-07-31 23:57:51 +02:00
Steffen Jaeckel
54f5803ad8 Rename keccac hash descriptors.
They're the only ones which don't follow the same pattern.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-07-31 23:57:51 +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
Karel Miko
a1a631efe4 make sha1/sha states clonable via memcpy 2026-07-30 20:17:44 +02:00
Karel Miko
074a354151 fix build failures with -std=c99 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
317994fb1b fix clang warnings -Wstrict-prototypes -Wmissing-prototypes in tests+demos 2026-07-30 15:22:33 +02:00
Karel Miko
fcadf67bbb Argon2 enforce parallelism max 2^24-1 2026-07-21 11:02:31 +02:00
Karel Miko
bc95a1fd2d hardening ecc_shared_secret against small-subgroup attacks 2026-05-25 16:18:14 +02:00
Karel Miko
afb09869f7 failing test for issue #764 - small-subgroup attack regression test 2026-05-25 13:56:48 +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
ccbbb797f0 Fix indentation.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-05-03 11:11:39 +02:00
Steffen Jaeckel
229f540c48 Don't print warning in case LTC_NO_TEST is defined.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-05-03 11:11:39 +02:00
Steffen Jaeckel
0834f876cd Split up ec25519/448 tests.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-05-03 11:11:39 +02:00
Steffen Jaeckel
811b1a6c14 Introduce LTC_NOP_TEST()
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-05-03 11:11:39 +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
7c0e52114e ecc - failing wycheproof tests 2026-04-30 11:41:04 +02:00
Karel Miko
8dd6ecfd20 ed448/x448 - failing wycheproof tests 2026-04-30 08:46:13 +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
Karel Miko
66a2e73eb8 fix for issue #116 2026-04-27 14:19:59 +02:00
Karel Miko
8e9b1983af fix ecc_projective_add_point + ecc_projective_dbl_point 2026-04-27 14:19:59 +02:00
Karel Miko
1d55aca785 failing wycheproof tests 2026-04-27 14:19:59 +02:00
Steffen Jaeckel
876460e7b6 Add testcases.
Link: libtom/libtomcrypt#743
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-04-27 12:56:58 +02:00
Steffen Jaeckel
55bf39c50e Also add the failing key to the test corpus.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-04-24 18:32:50 +02:00
Karel Miko
e0599e2b3a Update makefiles 2026-04-24 11:50:39 +02:00
Karel Miko
076a11037a Ed448 + X448 2026-04-24 11:49:23 +02:00
Steffen Jaeckel
800e5ce319 Remove OCB v1.
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-04-24 10:45:24 +02:00
Karel Miko
0e4c5aff7e XChaCha20 / XChaCha20-Poly1305 2026-04-24 09:41:08 +02:00
Karel Miko
0f37c60fd7 Wycheproof Ed25519 test vectors + fix 2026-04-24 09:36:09 +02:00
Steffen Jaeckel
760d09031e Add Project Wycheproof testvectors for SIV.
Gemini proposed this to convert
```
import json
import requests

def to_c_hex(hex_str):
    if not hex_str: return "NULL"
    bytes_list = [f"0x{hex_str[i:i+2]}" for i in range(0, len(hex_str), 2)]
    return "{" + ",".join(bytes_list) + "}"

url = "https://raw.githubusercontent.com/C2SP/wycheproof/main/testvectors_v1/aes_siv_cmac_test.json"
data = requests.get(url).json()

print("#include <stdint.h>\n#include <stddef.h>\n")
print("typedef struct { int tcId; const char* comment; uint8_t key[64]; size_t keyLen; const uint8_t* aad; size_t aadLen; const uint8_t* msg; size_t msgLen; const uint8_t* ct; size_t ctLen; const char* result; } aes_siv_test_case;\n")

for group in data['testGroups']:
    for test in group['tests']:
        tid = test['tcId']
        if test['aad']: print(f"static const uint8_t aad_{tid}[] = {to_c_hex(test['aad'])};")
        if test['msg']: print(f"static const uint8_t msg_{tid}[] = {to_c_hex(test['msg'])};")
        if test['ct']:  print(f"static const uint8_t ct_{tid}[]  = {to_c_hex(test['ct'])};")

print("\nstatic const aes_siv_test_case aes_siv_tests[] = {")
for group in data['testGroups']:
    for test in group['tests']:
        tid = test['tcId']
        key_hex = to_c_hex(test['key'])
        aad_ptr = f"aad_{tid}" if test['aad'] else "NULL"
        msg_ptr = f"msg_{tid}" if test['msg'] else "NULL"
        ct_ptr  = f"ct_{tid}"  if test['ct']  else "NULL"

        print(f"    {{ {tid}, \"{test['comment']}\", {key_hex}, {len(test['key'])//2}, {aad_ptr}, {len(test['aad'])//2}, {msg_ptr}, {len(test['msg'])//2}, {ct_ptr}, {len(test['ct'])//2}, \"{test['result']}\" }},")
print("};")
```

I manually modified the result type to be an enum.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-04-23 10:30:32 +02:00
Steffen Jaeckel
72642a7e8c Make depadding better against timing attacks.
Fixes: 82482119df ("add padding module")
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-04-23 10:30:27 +02:00
Steffen Jaeckel
6be6de1ffa Replace int* recid hack in ECC.
Link: libtom/libtomcrypt#724
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-04-23 09:13:02 +02:00