Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
909 changes: 905 additions & 4 deletions doc/crypt.tex

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions libtomcrypt_VS2008.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,10 @@
RelativePath="src\headers\tomcrypt_pkcs.h"
>
</File>
<File
RelativePath="src\headers\tomcrypt_pqc.h"
>
</File>
<File
RelativePath="src\headers\tomcrypt_private.h"
>
Expand Down Expand Up @@ -2876,6 +2880,74 @@
</File>
</Filter>
</Filter>
<Filter
Name="pqc"
>
<File
RelativePath="src\pqc\mldsa.c"
>
</File>
<File
RelativePath="src\pqc\mldsa_export.c"
>
</File>
<File
RelativePath="src\pqc\mldsa_import.c"
>
</File>
<File
RelativePath="src\pqc\mldsa_import_pkcs8.c"
>
</File>
<File
RelativePath="src\pqc\mldsa_import_x509.c"
>
</File>
<File
RelativePath="src\pqc\mlkem.c"
>
</File>
<File
RelativePath="src\pqc\mlkem_export.c"
>
</File>
<File
RelativePath="src\pqc\mlkem_import.c"
>
</File>
<File
RelativePath="src\pqc\mlkem_import_pkcs8.c"
>
</File>
<File
RelativePath="src\pqc\mlkem_import_x509.c"
>
</File>
<File
RelativePath="src\pqc\pqc_algname_match.c"
>
</File>
<File
RelativePath="src\pqc\slhdsa.c"
>
</File>
<File
RelativePath="src\pqc\slhdsa_export.c"
>
</File>
<File
RelativePath="src\pqc\slhdsa_import.c"
>
</File>
<File
RelativePath="src\pqc\slhdsa_import_pkcs8.c"
>
</File>
<File
RelativePath="src\pqc\slhdsa_import_x509.c"
>
</File>
</Filter>
<Filter
Name="prngs"
>
Expand Down
15 changes: 10 additions & 5 deletions makefile.mingw
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ src/pk/x25519/x25519_import.o src/pk/x25519/x25519_import_pkcs8.o src/pk/x25519/
src/pk/x25519/x25519_import_x509.o src/pk/x25519/x25519_make_key.o \
src/pk/x25519/x25519_shared_secret.o src/pk/x448/x448_export.o src/pk/x448/x448_import.o \
src/pk/x448/x448_import_pkcs8.o src/pk/x448/x448_import_raw.o src/pk/x448/x448_import_x509.o \
src/pk/x448/x448_make_key.o src/pk/x448/x448_shared_secret.o src/prngs/chacha20.o src/prngs/fortuna.o \
src/pk/x448/x448_make_key.o src/pk/x448/x448_shared_secret.o src/pqc/mldsa.o src/pqc/mldsa_export.o \
src/pqc/mldsa_import.o src/pqc/mldsa_import_pkcs8.o src/pqc/mldsa_import_x509.o src/pqc/mlkem.o \
src/pqc/mlkem_export.o src/pqc/mlkem_import.o src/pqc/mlkem_import_pkcs8.o src/pqc/mlkem_import_x509.o \
src/pqc/pqc_algname_match.o src/pqc/slhdsa.o src/pqc/slhdsa_export.o src/pqc/slhdsa_import.o \
src/pqc/slhdsa_import_pkcs8.o src/pqc/slhdsa_import_x509.o src/prngs/chacha20.o src/prngs/fortuna.o \
src/prngs/rc4.o src/prngs/rng_get_bytes.o src/prngs/rng_make_prng.o src/prngs/sober128.o \
src/prngs/sprng.o src/prngs/yarrow.o src/stream/chacha/chacha_crypt.o src/stream/chacha/chacha_done.o \
src/stream/chacha/chacha_ivctr32.o src/stream/chacha/chacha_ivctr64.o \
Expand All @@ -247,16 +251,17 @@ tests/dh_test.o tests/dsa_test.o tests/ecc_test.o tests/ed25519_test.o tests/ed4
tests/file_test.o tests/mac_test.o tests/misc_test.o tests/modes_test.o tests/mpi_test.o \
tests/multi_test.o tests/no_null_termination_check_test.o tests/no_prng.o tests/padding_test.o \
tests/pem_test.o tests/pk_oid_test.o tests/pkcs_1_eme_test.o tests/pkcs_1_emsa_test.o \
tests/pkcs_1_oaep_test.o tests/pkcs_1_pss_test.o tests/pkcs_1_test.o tests/prng_test.o \
tests/rotate_test.o tests/rsa_test.o tests/scrypt_test.o tests/siv_wycheproof_test.o tests/ssh_test.o \
tests/store_test.o tests/test.o tests/x25519_test.o tests/x448_test.o
tests/pkcs_1_oaep_test.o tests/pkcs_1_pss_test.o tests/pkcs_1_test.o tests/pqc_mldsa_test.o \
tests/pqc_mlkem_test.o tests/pqc_slhdsa_test.o tests/prng_test.o tests/rotate_test.o tests/rsa_test.o \
tests/scrypt_test.o tests/siv_wycheproof_test.o tests/ssh_test.o tests/store_test.o tests/test.o \
tests/x25519_test.o tests/x448_test.o

#The following headers will be installed by "make install"
HEADERS_PUB=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \
src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \
src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \
src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \
src/headers/tomcrypt_prng.h
src/headers/tomcrypt_pqc.h src/headers/tomcrypt_prng.h

HEADERS=$(HEADERS_PUB) src/headers/tomcrypt_private.h

Expand Down
15 changes: 10 additions & 5 deletions makefile.msvc
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ src/pk/x25519/x25519_import.obj src/pk/x25519/x25519_import_pkcs8.obj src/pk/x25
src/pk/x25519/x25519_import_x509.obj src/pk/x25519/x25519_make_key.obj \
src/pk/x25519/x25519_shared_secret.obj src/pk/x448/x448_export.obj src/pk/x448/x448_import.obj \
src/pk/x448/x448_import_pkcs8.obj src/pk/x448/x448_import_raw.obj src/pk/x448/x448_import_x509.obj \
src/pk/x448/x448_make_key.obj src/pk/x448/x448_shared_secret.obj src/prngs/chacha20.obj src/prngs/fortuna.obj \
src/pk/x448/x448_make_key.obj src/pk/x448/x448_shared_secret.obj src/pqc/mldsa.obj src/pqc/mldsa_export.obj \
src/pqc/mldsa_import.obj src/pqc/mldsa_import_pkcs8.obj src/pqc/mldsa_import_x509.obj src/pqc/mlkem.obj \
src/pqc/mlkem_export.obj src/pqc/mlkem_import.obj src/pqc/mlkem_import_pkcs8.obj src/pqc/mlkem_import_x509.obj \
src/pqc/pqc_algname_match.obj src/pqc/slhdsa.obj src/pqc/slhdsa_export.obj src/pqc/slhdsa_import.obj \
src/pqc/slhdsa_import_pkcs8.obj src/pqc/slhdsa_import_x509.obj src/prngs/chacha20.obj src/prngs/fortuna.obj \
src/prngs/rc4.obj src/prngs/rng_get_bytes.obj src/prngs/rng_make_prng.obj src/prngs/sober128.obj \
src/prngs/sprng.obj src/prngs/yarrow.obj src/stream/chacha/chacha_crypt.obj src/stream/chacha/chacha_done.obj \
src/stream/chacha/chacha_ivctr32.obj src/stream/chacha/chacha_ivctr64.obj \
Expand All @@ -240,16 +244,17 @@ tests/dh_test.obj tests/dsa_test.obj tests/ecc_test.obj tests/ed25519_test.obj t
tests/file_test.obj tests/mac_test.obj tests/misc_test.obj tests/modes_test.obj tests/mpi_test.obj \
tests/multi_test.obj tests/no_null_termination_check_test.obj tests/no_prng.obj tests/padding_test.obj \
tests/pem_test.obj tests/pk_oid_test.obj tests/pkcs_1_eme_test.obj tests/pkcs_1_emsa_test.obj \
tests/pkcs_1_oaep_test.obj tests/pkcs_1_pss_test.obj tests/pkcs_1_test.obj tests/prng_test.obj \
tests/rotate_test.obj tests/rsa_test.obj tests/scrypt_test.obj tests/siv_wycheproof_test.obj tests/ssh_test.obj \
tests/store_test.obj tests/test.obj tests/x25519_test.obj tests/x448_test.obj
tests/pkcs_1_oaep_test.obj tests/pkcs_1_pss_test.obj tests/pkcs_1_test.obj tests/pqc_mldsa_test.obj \
tests/pqc_mlkem_test.obj tests/pqc_slhdsa_test.obj tests/prng_test.obj tests/rotate_test.obj tests/rsa_test.obj \
tests/scrypt_test.obj tests/siv_wycheproof_test.obj tests/ssh_test.obj tests/store_test.obj tests/test.obj \
tests/x25519_test.obj tests/x448_test.obj

#The following headers will be installed by "make install"
HEADERS_PUB=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \
src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \
src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \
src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \
src/headers/tomcrypt_prng.h
src/headers/tomcrypt_pqc.h src/headers/tomcrypt_prng.h

HEADERS=$(HEADERS_PUB) src/headers/tomcrypt_private.h

Expand Down
15 changes: 10 additions & 5 deletions makefile.unix
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ src/pk/x25519/x25519_import.o src/pk/x25519/x25519_import_pkcs8.o src/pk/x25519/
src/pk/x25519/x25519_import_x509.o src/pk/x25519/x25519_make_key.o \
src/pk/x25519/x25519_shared_secret.o src/pk/x448/x448_export.o src/pk/x448/x448_import.o \
src/pk/x448/x448_import_pkcs8.o src/pk/x448/x448_import_raw.o src/pk/x448/x448_import_x509.o \
src/pk/x448/x448_make_key.o src/pk/x448/x448_shared_secret.o src/prngs/chacha20.o src/prngs/fortuna.o \
src/pk/x448/x448_make_key.o src/pk/x448/x448_shared_secret.o src/pqc/mldsa.o src/pqc/mldsa_export.o \
src/pqc/mldsa_import.o src/pqc/mldsa_import_pkcs8.o src/pqc/mldsa_import_x509.o src/pqc/mlkem.o \
src/pqc/mlkem_export.o src/pqc/mlkem_import.o src/pqc/mlkem_import_pkcs8.o src/pqc/mlkem_import_x509.o \
src/pqc/pqc_algname_match.o src/pqc/slhdsa.o src/pqc/slhdsa_export.o src/pqc/slhdsa_import.o \
src/pqc/slhdsa_import_pkcs8.o src/pqc/slhdsa_import_x509.o src/prngs/chacha20.o src/prngs/fortuna.o \
src/prngs/rc4.o src/prngs/rng_get_bytes.o src/prngs/rng_make_prng.o src/prngs/sober128.o \
src/prngs/sprng.o src/prngs/yarrow.o src/stream/chacha/chacha_crypt.o src/stream/chacha/chacha_done.o \
src/stream/chacha/chacha_ivctr32.o src/stream/chacha/chacha_ivctr64.o \
Expand All @@ -261,16 +265,17 @@ tests/dh_test.o tests/dsa_test.o tests/ecc_test.o tests/ed25519_test.o tests/ed4
tests/file_test.o tests/mac_test.o tests/misc_test.o tests/modes_test.o tests/mpi_test.o \
tests/multi_test.o tests/no_null_termination_check_test.o tests/no_prng.o tests/padding_test.o \
tests/pem_test.o tests/pk_oid_test.o tests/pkcs_1_eme_test.o tests/pkcs_1_emsa_test.o \
tests/pkcs_1_oaep_test.o tests/pkcs_1_pss_test.o tests/pkcs_1_test.o tests/prng_test.o \
tests/rotate_test.o tests/rsa_test.o tests/scrypt_test.o tests/siv_wycheproof_test.o tests/ssh_test.o \
tests/store_test.o tests/test.o tests/x25519_test.o tests/x448_test.o
tests/pkcs_1_oaep_test.o tests/pkcs_1_pss_test.o tests/pkcs_1_test.o tests/pqc_mldsa_test.o \
tests/pqc_mlkem_test.o tests/pqc_slhdsa_test.o tests/prng_test.o tests/rotate_test.o tests/rsa_test.o \
tests/scrypt_test.o tests/siv_wycheproof_test.o tests/ssh_test.o tests/store_test.o tests/test.o \
tests/x25519_test.o tests/x448_test.o

#The following headers will be installed by "make install"
HEADERS_PUB=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \
src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \
src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \
src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \
src/headers/tomcrypt_prng.h
src/headers/tomcrypt_pqc.h src/headers/tomcrypt_prng.h

HEADERS=$(HEADERS_PUB) src/headers/tomcrypt_private.h

Expand Down
15 changes: 10 additions & 5 deletions makefile_include.mk
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,11 @@ src/pk/x25519/x25519_import.o src/pk/x25519/x25519_import_pkcs8.o src/pk/x25519/
src/pk/x25519/x25519_import_x509.o src/pk/x25519/x25519_make_key.o \
src/pk/x25519/x25519_shared_secret.o src/pk/x448/x448_export.o src/pk/x448/x448_import.o \
src/pk/x448/x448_import_pkcs8.o src/pk/x448/x448_import_raw.o src/pk/x448/x448_import_x509.o \
src/pk/x448/x448_make_key.o src/pk/x448/x448_shared_secret.o src/prngs/chacha20.o src/prngs/fortuna.o \
src/pk/x448/x448_make_key.o src/pk/x448/x448_shared_secret.o src/pqc/mldsa.o src/pqc/mldsa_export.o \
src/pqc/mldsa_import.o src/pqc/mldsa_import_pkcs8.o src/pqc/mldsa_import_x509.o src/pqc/mlkem.o \
src/pqc/mlkem_export.o src/pqc/mlkem_import.o src/pqc/mlkem_import_pkcs8.o src/pqc/mlkem_import_x509.o \
src/pqc/pqc_algname_match.o src/pqc/slhdsa.o src/pqc/slhdsa_export.o src/pqc/slhdsa_import.o \
src/pqc/slhdsa_import_pkcs8.o src/pqc/slhdsa_import_x509.o src/prngs/chacha20.o src/prngs/fortuna.o \
src/prngs/rc4.o src/prngs/rng_get_bytes.o src/prngs/rng_make_prng.o src/prngs/sober128.o \
src/prngs/sprng.o src/prngs/yarrow.o src/stream/chacha/chacha_crypt.o src/stream/chacha/chacha_done.o \
src/stream/chacha/chacha_ivctr32.o src/stream/chacha/chacha_ivctr64.o \
Expand Down Expand Up @@ -437,16 +441,17 @@ tests/dh_test.o tests/dsa_test.o tests/ecc_test.o tests/ed25519_test.o tests/ed4
tests/file_test.o tests/mac_test.o tests/misc_test.o tests/modes_test.o tests/mpi_test.o \
tests/multi_test.o tests/no_null_termination_check_test.o tests/no_prng.o tests/padding_test.o \
tests/pem_test.o tests/pk_oid_test.o tests/pkcs_1_eme_test.o tests/pkcs_1_emsa_test.o \
tests/pkcs_1_oaep_test.o tests/pkcs_1_pss_test.o tests/pkcs_1_test.o tests/prng_test.o \
tests/rotate_test.o tests/rsa_test.o tests/scrypt_test.o tests/siv_wycheproof_test.o tests/ssh_test.o \
tests/store_test.o tests/test.o tests/x25519_test.o tests/x448_test.o
tests/pkcs_1_oaep_test.o tests/pkcs_1_pss_test.o tests/pkcs_1_test.o tests/pqc_mldsa_test.o \
tests/pqc_mlkem_test.o tests/pqc_slhdsa_test.o tests/prng_test.o tests/rotate_test.o tests/rsa_test.o \
tests/scrypt_test.o tests/siv_wycheproof_test.o tests/ssh_test.o tests/store_test.o tests/test.o \
tests/x25519_test.o tests/x448_test.o

# The following headers will be installed by "make install"
HEADERS_PUB=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \
src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \
src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \
src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \
src/headers/tomcrypt_prng.h
src/headers/tomcrypt_pqc.h src/headers/tomcrypt_prng.h

HEADERS=$(HEADERS_PUB) src/headers/tomcrypt_private.h

Expand Down
18 changes: 18 additions & 0 deletions sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ src/headers/tomcrypt_math.h
src/headers/tomcrypt_misc.h
src/headers/tomcrypt_pk.h
src/headers/tomcrypt_pkcs.h
src/headers/tomcrypt_pqc.h
src/headers/tomcrypt_private.h
src/headers/tomcrypt_prng.h
src/mac/blake2/blake2bmac.c
Expand Down Expand Up @@ -510,6 +511,22 @@ src/pk/x448/x448_import_raw.c
src/pk/x448/x448_import_x509.c
src/pk/x448/x448_make_key.c
src/pk/x448/x448_shared_secret.c
src/pqc/mldsa.c
src/pqc/mldsa_export.c
src/pqc/mldsa_import.c
src/pqc/mldsa_import_pkcs8.c
src/pqc/mldsa_import_x509.c
src/pqc/mlkem.c
src/pqc/mlkem_export.c
src/pqc/mlkem_import.c
src/pqc/mlkem_import_pkcs8.c
src/pqc/mlkem_import_x509.c
src/pqc/pqc_algname_match.c
src/pqc/slhdsa.c
src/pqc/slhdsa_export.c
src/pqc/slhdsa_import.c
src/pqc/slhdsa_import_pkcs8.c
src/pqc/slhdsa_import_x509.c
src/prngs/chacha20.c
src/prngs/fortuna.c
src/prngs/rc4.c
Expand Down Expand Up @@ -566,6 +583,7 @@ src/headers/tomcrypt_math.h
src/headers/tomcrypt_misc.h
src/headers/tomcrypt_pk.h
src/headers/tomcrypt_pkcs.h
src/headers/tomcrypt_pqc.h
src/headers/tomcrypt_prng.h
)

Expand Down
5 changes: 5 additions & 0 deletions src/headers/tomcrypt_custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,11 @@
/* Ed448 & X448 */
#define LTC_CURVE448

/* Post-Quantum Cryptography */
#define LTC_MLKEM
#define LTC_MLDSA
#define LTC_SLHDSA

/* ECC */
#define LTC_MECC

Expand Down
14 changes: 14 additions & 0 deletions src/headers/tomcrypt_pk.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ enum ltc_pka_id {
LTC_PKA_EC,
LTC_PKA_X25519,
LTC_PKA_ED25519,
LTC_PKA_MLDSA,
LTC_PKA_SLHDSA,
LTC_PKA_MLKEM,
LTC_PKA_DH,
LTC_PKA_RSA_PSS,
LTC_PKA_X448,
Expand Down Expand Up @@ -794,6 +797,8 @@ int dsa_shared_secret(void *private_key, void *base,
* LibTomCrypt tagged-union for holding a Public Key
*/

#include "tomcrypt_pqc.h"

typedef struct {
union {
#ifdef LTC_CURVE25519
Expand All @@ -815,6 +820,15 @@ typedef struct {
#endif
#ifdef LTC_MRSA
rsa_key rsa;
#endif
#ifdef LTC_MLKEM
mlkem_key mlkem;
#endif
#ifdef LTC_MLDSA
mldsa_key mldsa;
#endif
#ifdef LTC_SLHDSA
slhdsa_key slhdsa;
#endif
char dummy;
} u;
Expand Down
Loading
Loading