Commit graph

57 commits

Author SHA1 Message Date
Karel Miko
26605163a4 fix clang warnings -Wmissing-variable-declarations 2026-07-30 15:22:33 +02:00
Karel Miko
2c375b3a3c RSA OAEP - reject ciphertext values 0 and 1 2026-05-05 07:42:20 +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
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
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
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
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
95790221fb Add free() function to password_ctx
The user can now pass a `free()` function pointer that will be used to
free the memory that has been allocated by the `callback()`.
If `free()` is NULL, the library will still call `XFREE()`.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-08-20 13:29:27 +02:00
Steffen Jaeckel
02cb0c4957 Revert "Move password buffer into the library"
This reverts commit d840323bc1d3bc35bc72271e55ffa644f02b4582
2024-08-20 13:29:27 +02:00
Steffen Jaeckel
03515d5611 Move password buffer into the library
The design before was not completely fine. The user had to allocate the
buffer and passed ownership to the library.
As of [0] this seems to be a problem in some environments.

[0] https://github.com/libtom/libtomcrypt/pull/587#issuecomment-1765324724

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-08-20 13:29:27 +02:00
Steffen Jaeckel
a76447f7aa add file-iterator to test_process_dir()
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-08-20 13:29:27 +02:00
Steffen Jaeckel
d1e48df763 Verify that the imported keys match
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-08-20 13:29:27 +02:00
Steffen Jaeckel
3f6f885852 re-factor PKCS#8 API a bit
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2024-08-20 13:29:27 +02:00
Steffen Jaeckel
63091c9e5c Add possibility to use different hash algorithms in RSAES-OAEP
The hash algorithms used in the MGF and to create the hash of the Label
must not forcibly be the same. This change allows to use different
algorithms.

Unfortunately this breaks the API if you use one of:
* `rsa_decrypt_key_ex()`
* `rsa_encrypt_key_ex()`
* `pkcs_1_oaep_decode()`
* `pkcs_1_oaep_encode()`

The `rsa_decrypt_key()` and `rsa_encrypt_key()` macros are still the same.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2023-10-09 12:26:21 +02:00
Steffen Jaeckel
f9c0c63433 allow input-data pointer to be NULL
If we allow the length to be 0, we should also prepare for the case where
the user doesn't want to provide a valid input-data pointer.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2023-03-31 14:42:50 +02:00
Steffen Jaeckel
038db7e03e fix sporadically failing tests when built with pthreads support
... I hope ... :)

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2022-03-17 15:08:39 +01:00
Steffen Jaeckel
2c51ae81ac make sure to check yarrow_read() return values
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2022-03-17 15:08:37 +01:00
Cedric Neveux
d6bc30e8b8 test: add test rsa key generate with public exponent upto 256 bits
Add a RSA test generating a RSA key with a 256 bits public exponent.

Signed-off-by: Cedric Neveux <cedric.neveux@nxp.com>
2021-06-04 08:05:58 +02:00
Steffen Jaeckel
5bc034ff55 re-factor some tests 2021-04-10 13:02:39 +02:00
Steffen Jaeckel
df6e14a9cb make sure basic types are marked as UNIVERSAL&PRIMITIVE
This fixes DCIT/perl-CryptX#69
2021-04-09 12:48:17 +02:00
Steffen Jaeckel
c5d7bfb2cc manually fix the remaining leading _'s 2020-07-16 10:38:33 +02:00
Steffen Jaeckel
9824af8e3b update header 2020-07-14 18:41:30 +02:00
Steffen Jaeckel
24765c30c5 remove footer 2020-07-14 18:41:29 +02:00
Steffen Jaeckel
4e28b922a9 add rsa_shrink_key() 2019-10-17 22:27:54 +02:00
Steffen Jaeckel
68cc580602 use macros in more tests 2019-10-17 12:49:20 +02:00
Karel Miko
8349eda5a5 fix LTC_EASY test failure 2018-10-06 23:04:51 +02:00
Karel Miko
2dd8bcdfe9 rsa_import_pkcs8 tests 2018-10-06 23:04:51 +02:00
Karel Miko
ef20f2e656 remove unused macros 2018-10-04 23:29:12 +02:00
Steffen Jaeckel
0011f7f927 add generic test_process_dir() 2018-05-23 10:33:47 +02:00
Karel Miko
065c89108e base64_* use char * for Base64 strings 2018-03-26 16:42:19 +02:00
Steffen Jaeckel
b026c23b0a use do_compare_testvector() where possible 2018-03-22 16:12:56 +01:00
Steffen Jaeckel
e1cba4da7d fix der_test and rsa_test when compiling for msvc 2018-03-22 16:12:56 +01:00
Steffen Jaeckel
9d03c38ea4 add flags to der_decode_sequence() 2018-02-25 20:42:26 +01:00
Steffen Jaeckel
7e2d163d1d add testvectors from [1]
[1] https://misc.daniel-marschall.de/asn.1/oid_facts.html
2018-02-25 20:42:26 +01:00
Steffen Jaeckel
fdc6cd2013 improve tests and timing in regards to MPI provider selection 2017-10-18 08:46:17 +02:00
Steffen Jaeckel
c702ac6f1c improve rsa_test a bit 2017-10-02 01:18:19 +02:00
Karel Miko
67f9064b71 missing rsa_free in _rsa_issue_301 test 2017-10-01 22:56:47 +02:00
Steffen Jaeckel
30b3a9a986 remove {MIN,MAX}_RSA_SIZE 2017-10-01 22:56:47 +02:00
Steffen Jaeckel
0500aaec45 add tests for MAX_RSA_SIZE sized openssl-standard RSA keys 2017-10-01 22:56:47 +02:00
Steffen Jaeckel
a65cfb8dbe make it possible to 'make all' w/o an MPI provider 2017-08-07 21:11:42 +02:00
Steffen Jaeckel
0aad68c20d clean-up some PK tests
no need to test the same functionality multiple times
these tests were multiplied for the XX_import_radix() functions which
are gone now.
2017-06-28 14:44:06 +02:00
Steffen Jaeckel
ae7d4d2947 re-factor rsa_test() to new rsa_set_X() API 2017-06-27 20:05:36 +02:00
Steffen Jaeckel
05e9f0ee79 Revert "use ltc_pk_part in rsa_import_radix()"
This reverts commit 023e4a2c23641d852cf47000948fa29a53249457.
2017-06-27 20:05:36 +02:00
Steffen Jaeckel
083e8af78b Revert "also test binary import"
This reverts commit 8b6f8c8cce325fa1ce3b61805aa80cdabc1826b4.
2017-06-27 20:05:36 +02:00
Steffen Jaeckel
4afc024f6a also test binary import 2017-06-27 20:05:36 +02:00
Steffen Jaeckel
bfae92e4ab use compare_testvector() in rsa_test() 2017-06-27 20:05:36 +02:00