diff options
author | Karel Miko <karel.miko@gmail.com> | 2018-06-04 16:45:49 +0200 |
---|---|---|
committer | Karel Miko <karel.miko@gmail.com> | 2018-06-04 16:45:49 +0200 |
commit | 5dbccdcd3dfd5012d44c98b125089da9c64553ed (patch) | |
tree | ddafec2cf2f8778c31133b283ae2acb139ed77ff | |
parent | 4e663d68aa094f9cbd1ac56f8ec0db5c0379a8a6 (diff) |
ltc update
399 files changed, 1315 insertions, 1126 deletions
diff --git a/src/Makefile b/src/Makefile index 0c7ef492..05bed2b1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -103,20 +103,20 @@ ltc/pk/dsa/dsa_set_pqg_dsaparam.o ltc/pk/dsa/dsa_shared_secret.o ltc/pk/dsa/dsa_ ltc/pk/dsa/dsa_verify_hash.o ltc/pk/dsa/dsa_verify_key.o ltc/pk/ecc/ecc.o ltc/pk/ecc/ecc_ansi_x963_export.o \ ltc/pk/ecc/ecc_ansi_x963_import.o ltc/pk/ecc/ecc_decrypt_key.o ltc/pk/ecc/ecc_encrypt_key.o \ ltc/pk/ecc/ecc_export.o ltc/pk/ecc/ecc_export_openssl.o ltc/pk/ecc/ecc_free.o ltc/pk/ecc/ecc_get_curve.o \ -ltc/pk/ecc/ecc_get_key.o ltc/pk/ecc/ecc_get_size.o ltc/pk/ecc/ecc_import.o ltc/pk/ecc/ecc_import_openssl.o \ -ltc/pk/ecc/ecc_import_pkcs8.o ltc/pk/ecc/ecc_import_x509.o ltc/pk/ecc/ecc_make_key.o \ -ltc/pk/ecc/ecc_set_dp.o ltc/pk/ecc/ecc_set_dp_internal.o ltc/pk/ecc/ecc_set_key.o \ -ltc/pk/ecc/ecc_shared_secret.o ltc/pk/ecc/ecc_sign_hash.o ltc/pk/ecc/ecc_sizes.o \ -ltc/pk/ecc/ecc_verify_hash.o ltc/pk/ecc/ltc_ecc_export_point.o ltc/pk/ecc/ltc_ecc_import_point.o \ -ltc/pk/ecc/ltc_ecc_is_point.o ltc/pk/ecc/ltc_ecc_is_point_at_infinity.o ltc/pk/ecc/ltc_ecc_map.o \ -ltc/pk/ecc/ltc_ecc_mul2add.o ltc/pk/ecc/ltc_ecc_mulmod.o ltc/pk/ecc/ltc_ecc_mulmod_timing.o \ -ltc/pk/ecc/ltc_ecc_points.o ltc/pk/ecc/ltc_ecc_projective_add_point.o ltc/pk/ecc/ltc_ecc_projective_dbl_point.o \ -ltc/pk/ecc/ltc_ecc_verify_key.o ltc/pk/pkcs1/pkcs_1_i2osp.o ltc/pk/pkcs1/pkcs_1_mgf1.o \ -ltc/pk/pkcs1/pkcs_1_oaep_decode.o ltc/pk/pkcs1/pkcs_1_oaep_encode.o ltc/pk/pkcs1/pkcs_1_os2ip.o \ -ltc/pk/pkcs1/pkcs_1_pss_decode.o ltc/pk/pkcs1/pkcs_1_pss_encode.o ltc/pk/pkcs1/pkcs_1_v1_5_decode.o \ -ltc/pk/pkcs1/pkcs_1_v1_5_encode.o ltc/pk/rsa/rsa_decrypt_key.o ltc/pk/rsa/rsa_encrypt_key.o \ -ltc/pk/rsa/rsa_export.o ltc/pk/rsa/rsa_exptmod.o ltc/pk/rsa/rsa_free.o ltc/pk/rsa/rsa_get_size.o \ -ltc/pk/rsa/rsa_import.o ltc/pk/rsa/rsa_import_pkcs8.o ltc/pk/rsa/rsa_import_x509.o \ +ltc/pk/ecc/ecc_get_key.o ltc/pk/ecc/ecc_get_oid_str.o ltc/pk/ecc/ecc_get_size.o ltc/pk/ecc/ecc_import.o \ +ltc/pk/ecc/ecc_import_openssl.o ltc/pk/ecc/ecc_import_pkcs8.o ltc/pk/ecc/ecc_import_x509.o \ +ltc/pk/ecc/ecc_make_key.o ltc/pk/ecc/ecc_set_dp.o ltc/pk/ecc/ecc_set_dp_internal.o \ +ltc/pk/ecc/ecc_set_key.o ltc/pk/ecc/ecc_shared_secret.o ltc/pk/ecc/ecc_sign_hash.o \ +ltc/pk/ecc/ecc_sizes.o ltc/pk/ecc/ecc_verify_hash.o ltc/pk/ecc/ltc_ecc_export_point.o \ +ltc/pk/ecc/ltc_ecc_import_point.o ltc/pk/ecc/ltc_ecc_is_point.o ltc/pk/ecc/ltc_ecc_is_point_at_infinity.o \ +ltc/pk/ecc/ltc_ecc_map.o ltc/pk/ecc/ltc_ecc_mul2add.o ltc/pk/ecc/ltc_ecc_mulmod.o \ +ltc/pk/ecc/ltc_ecc_mulmod_timing.o ltc/pk/ecc/ltc_ecc_points.o ltc/pk/ecc/ltc_ecc_projective_add_point.o \ +ltc/pk/ecc/ltc_ecc_projective_dbl_point.o ltc/pk/ecc/ltc_ecc_verify_key.o ltc/pk/pkcs1/pkcs_1_i2osp.o \ +ltc/pk/pkcs1/pkcs_1_mgf1.o ltc/pk/pkcs1/pkcs_1_oaep_decode.o ltc/pk/pkcs1/pkcs_1_oaep_encode.o \ +ltc/pk/pkcs1/pkcs_1_os2ip.o ltc/pk/pkcs1/pkcs_1_pss_decode.o ltc/pk/pkcs1/pkcs_1_pss_encode.o \ +ltc/pk/pkcs1/pkcs_1_v1_5_decode.o ltc/pk/pkcs1/pkcs_1_v1_5_encode.o ltc/pk/rsa/rsa_decrypt_key.o \ +ltc/pk/rsa/rsa_encrypt_key.o ltc/pk/rsa/rsa_export.o ltc/pk/rsa/rsa_exptmod.o ltc/pk/rsa/rsa_free.o \ +ltc/pk/rsa/rsa_get_size.o ltc/pk/rsa/rsa_import.o ltc/pk/rsa/rsa_import_pkcs8.o ltc/pk/rsa/rsa_import_x509.o \ ltc/pk/rsa/rsa_make_key.o ltc/pk/rsa/rsa_set.o ltc/pk/rsa/rsa_sign_hash.o ltc/pk/rsa/rsa_sign_saltlen_get.o \ ltc/pk/rsa/rsa_verify_hash.o ltc/prngs/chacha20.o ltc/prngs/fortuna.o ltc/prngs/rc4.o \ ltc/prngs/rng_get_bytes.o ltc/prngs/rng_make_prng.o ltc/prngs/sober128.o ltc/prngs/sprng.o \ @@ -124,18 +124,18 @@ ltc/prngs/yarrow.o ltc/stream/chacha/chacha_crypt.o ltc/stream/chacha/chacha_don ltc/stream/chacha/chacha_ivctr32.o ltc/stream/chacha/chacha_ivctr64.o ltc/stream/chacha/chacha_keystream.o \ ltc/stream/chacha/chacha_setup.o ltc/stream/rabbit/rabbit.o ltc/stream/rc4/rc4_stream.o \ ltc/stream/salsa20/salsa20_crypt.o ltc/stream/salsa20/salsa20_done.o ltc/stream/salsa20/salsa20_ivctr64.o \ -ltc/stream/salsa20/salsa20_keystream.o ltc/stream/salsa20/salsa20_setup.o ltc/stream/sober128/sober128_stream.o \ -ltc/stream/sosemanuk/sosemanuk.o ltm/bncore.o ltm/bn_error.o ltm/bn_fast_mp_invmod.o \ -ltm/bn_fast_mp_montgomery_reduce.o ltm/bn_fast_s_mp_mul_digs.o ltm/bn_fast_s_mp_mul_high_digs.o \ -ltm/bn_fast_s_mp_sqr.o ltm/bn_mp_2expt.o ltm/bn_mp_abs.o ltm/bn_mp_add.o ltm/bn_mp_addmod.o \ -ltm/bn_mp_add_d.o ltm/bn_mp_and.o ltm/bn_mp_clamp.o ltm/bn_mp_clear.o ltm/bn_mp_clear_multi.o \ -ltm/bn_mp_cmp.o ltm/bn_mp_cmp_d.o ltm/bn_mp_cmp_mag.o ltm/bn_mp_cnt_lsb.o ltm/bn_mp_copy.o \ -ltm/bn_mp_count_bits.o ltm/bn_mp_div.o ltm/bn_mp_div_2.o ltm/bn_mp_div_2d.o ltm/bn_mp_div_3.o \ -ltm/bn_mp_div_d.o ltm/bn_mp_dr_is_modulus.o ltm/bn_mp_dr_reduce.o ltm/bn_mp_dr_setup.o \ -ltm/bn_mp_exch.o ltm/bn_mp_export.o ltm/bn_mp_exptmod.o ltm/bn_mp_exptmod_fast.o \ -ltm/bn_mp_expt_d.o ltm/bn_mp_expt_d_ex.o ltm/bn_mp_exteuclid.o ltm/bn_mp_fread.o \ -ltm/bn_mp_fwrite.o ltm/bn_mp_gcd.o ltm/bn_mp_get_int.o ltm/bn_mp_get_long.o ltm/bn_mp_grow.o \ -ltm/bn_mp_import.o ltm/bn_mp_init.o ltm/bn_mp_init_copy.o ltm/bn_mp_init_multi.o \ +ltc/stream/salsa20/salsa20_keystream.o ltc/stream/salsa20/salsa20_setup.o ltc/stream/salsa20/xsalsa20_setup.o \ +ltc/stream/sober128/sober128_stream.o ltc/stream/sosemanuk/sosemanuk.o ltm/bncore.o \ +ltm/bn_error.o ltm/bn_fast_mp_invmod.o ltm/bn_fast_mp_montgomery_reduce.o ltm/bn_fast_s_mp_mul_digs.o \ +ltm/bn_fast_s_mp_mul_high_digs.o ltm/bn_fast_s_mp_sqr.o ltm/bn_mp_2expt.o ltm/bn_mp_abs.o \ +ltm/bn_mp_add.o ltm/bn_mp_addmod.o ltm/bn_mp_add_d.o ltm/bn_mp_and.o ltm/bn_mp_clamp.o \ +ltm/bn_mp_clear.o ltm/bn_mp_clear_multi.o ltm/bn_mp_cmp.o ltm/bn_mp_cmp_d.o ltm/bn_mp_cmp_mag.o \ +ltm/bn_mp_cnt_lsb.o ltm/bn_mp_copy.o ltm/bn_mp_count_bits.o ltm/bn_mp_div.o ltm/bn_mp_div_2.o \ +ltm/bn_mp_div_2d.o ltm/bn_mp_div_3.o ltm/bn_mp_div_d.o ltm/bn_mp_dr_is_modulus.o \ +ltm/bn_mp_dr_reduce.o ltm/bn_mp_dr_setup.o ltm/bn_mp_exch.o ltm/bn_mp_export.o ltm/bn_mp_exptmod.o \ +ltm/bn_mp_exptmod_fast.o ltm/bn_mp_expt_d.o ltm/bn_mp_expt_d_ex.o ltm/bn_mp_exteuclid.o \ +ltm/bn_mp_fread.o ltm/bn_mp_fwrite.o ltm/bn_mp_gcd.o ltm/bn_mp_get_int.o ltm/bn_mp_get_long.o \ +ltm/bn_mp_grow.o ltm/bn_mp_import.o ltm/bn_mp_init.o ltm/bn_mp_init_copy.o ltm/bn_mp_init_multi.o \ ltm/bn_mp_init_set.o ltm/bn_mp_init_set_int.o ltm/bn_mp_init_size.o ltm/bn_mp_invmod.o \ ltm/bn_mp_invmod_slow.o ltm/bn_mp_is_square.o ltm/bn_mp_jacobi.o ltm/bn_mp_karatsuba_mul.o \ ltm/bn_mp_karatsuba_sqr.o ltm/bn_mp_lcm.o ltm/bn_mp_lshd.o ltm/bn_mp_mod.o ltm/bn_mp_mod_2d.o \ diff --git a/src/Makefile.nmake b/src/Makefile.nmake index b6cd4ff7..47703d56 100644 --- a/src/Makefile.nmake +++ b/src/Makefile.nmake @@ -110,15 +110,15 @@ ltc/pk/dsa/dsa_shared_secret.obj ltc/pk/dsa/dsa_sign_hash.obj ltc/pk/dsa/dsa_ver ltc/pk/dsa/dsa_verify_key.obj ltc/pk/ecc/ecc.obj ltc/pk/ecc/ecc_ansi_x963_export.obj \ ltc/pk/ecc/ecc_ansi_x963_import.obj ltc/pk/ecc/ecc_decrypt_key.obj ltc/pk/ecc/ecc_encrypt_key.obj \ ltc/pk/ecc/ecc_export.obj ltc/pk/ecc/ecc_export_openssl.obj ltc/pk/ecc/ecc_free.obj \ -ltc/pk/ecc/ecc_get_curve.obj ltc/pk/ecc/ecc_get_key.obj ltc/pk/ecc/ecc_get_size.obj \ -ltc/pk/ecc/ecc_import.obj ltc/pk/ecc/ecc_import_openssl.obj ltc/pk/ecc/ecc_import_pkcs8.obj \ -ltc/pk/ecc/ecc_import_x509.obj ltc/pk/ecc/ecc_make_key.obj ltc/pk/ecc/ecc_set_dp.obj \ -ltc/pk/ecc/ecc_set_dp_internal.obj ltc/pk/ecc/ecc_set_key.obj ltc/pk/ecc/ecc_shared_secret.obj \ -ltc/pk/ecc/ecc_sign_hash.obj ltc/pk/ecc/ecc_sizes.obj ltc/pk/ecc/ecc_verify_hash.obj \ -ltc/pk/ecc/ltc_ecc_export_point.obj ltc/pk/ecc/ltc_ecc_import_point.obj ltc/pk/ecc/ltc_ecc_is_point.obj \ -ltc/pk/ecc/ltc_ecc_is_point_at_infinity.obj ltc/pk/ecc/ltc_ecc_map.obj ltc/pk/ecc/ltc_ecc_mul2add.obj \ -ltc/pk/ecc/ltc_ecc_mulmod.obj ltc/pk/ecc/ltc_ecc_mulmod_timing.obj ltc/pk/ecc/ltc_ecc_points.obj \ -ltc/pk/ecc/ltc_ecc_projective_add_point.obj ltc/pk/ecc/ltc_ecc_projective_dbl_point.obj \ +ltc/pk/ecc/ecc_get_curve.obj ltc/pk/ecc/ecc_get_key.obj ltc/pk/ecc/ecc_get_oid_str.obj \ +ltc/pk/ecc/ecc_get_size.obj ltc/pk/ecc/ecc_import.obj ltc/pk/ecc/ecc_import_openssl.obj \ +ltc/pk/ecc/ecc_import_pkcs8.obj ltc/pk/ecc/ecc_import_x509.obj ltc/pk/ecc/ecc_make_key.obj \ +ltc/pk/ecc/ecc_set_dp.obj ltc/pk/ecc/ecc_set_dp_internal.obj ltc/pk/ecc/ecc_set_key.obj \ +ltc/pk/ecc/ecc_shared_secret.obj ltc/pk/ecc/ecc_sign_hash.obj ltc/pk/ecc/ecc_sizes.obj \ +ltc/pk/ecc/ecc_verify_hash.obj ltc/pk/ecc/ltc_ecc_export_point.obj ltc/pk/ecc/ltc_ecc_import_point.obj \ +ltc/pk/ecc/ltc_ecc_is_point.obj ltc/pk/ecc/ltc_ecc_is_point_at_infinity.obj ltc/pk/ecc/ltc_ecc_map.obj \ +ltc/pk/ecc/ltc_ecc_mul2add.obj ltc/pk/ecc/ltc_ecc_mulmod.obj ltc/pk/ecc/ltc_ecc_mulmod_timing.obj \ +ltc/pk/ecc/ltc_ecc_points.obj ltc/pk/ecc/ltc_ecc_projective_add_point.obj ltc/pk/ecc/ltc_ecc_projective_dbl_point.obj \ ltc/pk/ecc/ltc_ecc_verify_key.obj ltc/pk/pkcs1/pkcs_1_i2osp.obj ltc/pk/pkcs1/pkcs_1_mgf1.obj \ ltc/pk/pkcs1/pkcs_1_oaep_decode.obj ltc/pk/pkcs1/pkcs_1_oaep_encode.obj ltc/pk/pkcs1/pkcs_1_os2ip.obj \ ltc/pk/pkcs1/pkcs_1_pss_decode.obj ltc/pk/pkcs1/pkcs_1_pss_encode.obj ltc/pk/pkcs1/pkcs_1_v1_5_decode.obj \ @@ -132,14 +132,14 @@ ltc/prngs/yarrow.obj ltc/stream/chacha/chacha_crypt.obj ltc/stream/chacha/chacha ltc/stream/chacha/chacha_ivctr32.obj ltc/stream/chacha/chacha_ivctr64.obj ltc/stream/chacha/chacha_keystream.obj \ ltc/stream/chacha/chacha_setup.obj ltc/stream/rabbit/rabbit.obj ltc/stream/rc4/rc4_stream.obj \ ltc/stream/salsa20/salsa20_crypt.obj ltc/stream/salsa20/salsa20_done.obj ltc/stream/salsa20/salsa20_ivctr64.obj \ -ltc/stream/salsa20/salsa20_keystream.obj ltc/stream/salsa20/salsa20_setup.obj ltc/stream/sober128/sober128_stream.obj \ -ltc/stream/sosemanuk/sosemanuk.obj ltm/bncore.obj ltm/bn_error.obj ltm/bn_fast_mp_invmod.obj \ -ltm/bn_fast_mp_montgomery_reduce.obj ltm/bn_fast_s_mp_mul_digs.obj ltm/bn_fast_s_mp_mul_high_digs.obj \ -ltm/bn_fast_s_mp_sqr.obj ltm/bn_mp_2expt.obj ltm/bn_mp_abs.obj ltm/bn_mp_add.obj \ -ltm/bn_mp_addmod.obj ltm/bn_mp_add_d.obj ltm/bn_mp_and.obj ltm/bn_mp_clamp.obj ltm/bn_mp_clear.obj \ -ltm/bn_mp_clear_multi.obj ltm/bn_mp_cmp.obj ltm/bn_mp_cmp_d.obj ltm/bn_mp_cmp_mag.obj \ -ltm/bn_mp_cnt_lsb.obj ltm/bn_mp_copy.obj ltm/bn_mp_count_bits.obj ltm/bn_mp_div.obj \ -ltm/bn_mp_div_2.obj ltm/bn_mp_div_2d.obj ltm/bn_mp_div_3.obj ltm/bn_mp_div_d.obj \ +ltc/stream/salsa20/salsa20_keystream.obj ltc/stream/salsa20/salsa20_setup.obj ltc/stream/salsa20/xsalsa20_setup.obj \ +ltc/stream/sober128/sober128_stream.obj ltc/stream/sosemanuk/sosemanuk.obj ltm/bncore.obj \ +ltm/bn_error.obj ltm/bn_fast_mp_invmod.obj ltm/bn_fast_mp_montgomery_reduce.obj ltm/bn_fast_s_mp_mul_digs.obj \ +ltm/bn_fast_s_mp_mul_high_digs.obj ltm/bn_fast_s_mp_sqr.obj ltm/bn_mp_2expt.obj ltm/bn_mp_abs.obj \ +ltm/bn_mp_add.obj ltm/bn_mp_addmod.obj ltm/bn_mp_add_d.obj ltm/bn_mp_and.obj ltm/bn_mp_clamp.obj \ +ltm/bn_mp_clear.obj ltm/bn_mp_clear_multi.obj ltm/bn_mp_cmp.obj ltm/bn_mp_cmp_d.obj \ +ltm/bn_mp_cmp_mag.obj ltm/bn_mp_cnt_lsb.obj ltm/bn_mp_copy.obj ltm/bn_mp_count_bits.obj \ +ltm/bn_mp_div.obj ltm/bn_mp_div_2.obj ltm/bn_mp_div_2d.obj ltm/bn_mp_div_3.obj ltm/bn_mp_div_d.obj \ ltm/bn_mp_dr_is_modulus.obj ltm/bn_mp_dr_reduce.obj ltm/bn_mp_dr_setup.obj ltm/bn_mp_exch.obj \ ltm/bn_mp_export.obj ltm/bn_mp_exptmod.obj ltm/bn_mp_exptmod_fast.obj ltm/bn_mp_expt_d.obj \ ltm/bn_mp_expt_d_ex.obj ltm/bn_mp_exteuclid.obj ltm/bn_mp_fread.obj ltm/bn_mp_fwrite.obj \ diff --git a/src/ltc/ciphers/aes/aes.c b/src/ltc/ciphers/aes/aes.c index 2abff12e..537fecef 100644 --- a/src/ltc/ciphers/aes/aes.c +++ b/src/ltc/ciphers/aes/aes.c @@ -28,7 +28,7 @@ Implementation of AES */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_RIJNDAEL diff --git a/src/ltc/ciphers/anubis.c b/src/ltc/ciphers/anubis.c index 07b22d4d..7bc35908 100644 --- a/src/ltc/ciphers/anubis.c +++ b/src/ltc/ciphers/anubis.c @@ -13,7 +13,7 @@ Authors: Paulo S.L.M. Barreto and Vincent Rijmen. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_ANUBIS diff --git a/src/ltc/ciphers/blowfish.c b/src/ltc/ciphers/blowfish.c index e0cd1d1a..caeb46ee 100644 --- a/src/ltc/ciphers/blowfish.c +++ b/src/ltc/ciphers/blowfish.c @@ -10,7 +10,7 @@ @file blowfish.c Implementation of the Blowfish block cipher, Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_BLOWFISH @@ -394,7 +394,7 @@ int blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symme ulong32 L, R; int r; #ifndef __GNUC__ - ulong32 *S1, *S2, *S3, *S4; + const ulong32 *S1, *S2, *S3, *S4; #endif LTC_ARGCHK(pt != NULL); @@ -456,7 +456,7 @@ int blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symme ulong32 L, R; int r; #ifndef __GNUC__ - ulong32 *S1, *S2, *S3, *S4; + const ulong32 *S1, *S2, *S3, *S4; #endif LTC_ARGCHK(pt != NULL); diff --git a/src/ltc/ciphers/camellia.c b/src/ltc/ciphers/camellia.c index a99647a8..4e5602ee 100644 --- a/src/ltc/ciphers/camellia.c +++ b/src/ltc/ciphers/camellia.c @@ -12,7 +12,7 @@ Implementation by Tom St Denis of Elliptic Semiconductor */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CAMELLIA diff --git a/src/ltc/ciphers/cast5.c b/src/ltc/ciphers/cast5.c index 95693d52..1089ade3 100644 --- a/src/ltc/ciphers/cast5.c +++ b/src/ltc/ciphers/cast5.c @@ -11,7 +11,7 @@ @file cast5.c Implementation of LTC_CAST5 (RFC 2144) by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CAST5 diff --git a/src/ltc/ciphers/des.c b/src/ltc/ciphers/des.c index 3b1cb3a0..a72fdf53 100644 --- a/src/ltc/ciphers/des.c +++ b/src/ltc/ciphers/des.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file des.c @@ -36,7 +36,7 @@ const struct ltc_cipher_descriptor des3_desc = { "3des", 14, - 24, 24, 8, 16, + 16, 24, 8, 16, &des3_setup, &des3_ecb_encrypt, &des3_ecb_decrypt, @@ -2068,8 +2068,11 @@ int des_keysize(int *keysize) int des3_keysize(int *keysize) { LTC_ARGCHK(keysize != NULL); - if(*keysize < 24) { - return CRYPT_INVALID_KEYSIZE; + if (*keysize < 16) + return CRYPT_INVALID_KEYSIZE; + if (*keysize < 24) { + *keysize = 16; + return CRYPT_OK; } *keysize = 24; return CRYPT_OK; diff --git a/src/ltc/ciphers/idea.c b/src/ltc/ciphers/idea.c index ac3cac57..86ded4de 100644 --- a/src/ltc/ciphers/idea.c +++ b/src/ltc/ciphers/idea.c @@ -22,7 +22,7 @@ and Japan (JP 3225440) (expired May 16, 2011). */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_IDEA diff --git a/src/ltc/ciphers/kasumi.c b/src/ltc/ciphers/kasumi.c index aba6cb26..fba9b655 100644 --- a/src/ltc/ciphers/kasumi.c +++ b/src/ltc/ciphers/kasumi.c @@ -13,7 +13,7 @@ Derived from the 3GPP standard source code */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_KASUMI diff --git a/src/ltc/ciphers/khazad.c b/src/ltc/ciphers/khazad.c index 54637d8f..c8d8d7a5 100644 --- a/src/ltc/ciphers/khazad.c +++ b/src/ltc/ciphers/khazad.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file khazad.c diff --git a/src/ltc/ciphers/kseed.c b/src/ltc/ciphers/kseed.c index f4e1345e..6d2b0847 100644 --- a/src/ltc/ciphers/kseed.c +++ b/src/ltc/ciphers/kseed.c @@ -13,7 +13,7 @@ Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_KSEED diff --git a/src/ltc/ciphers/multi2.c b/src/ltc/ciphers/multi2.c index 5421cb2e..39c83a1d 100644 --- a/src/ltc/ciphers/multi2.c +++ b/src/ltc/ciphers/multi2.c @@ -11,7 +11,7 @@ @file multi2.c Multi-2 implementation (not public domain, hence the default disable) */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MULTI2 diff --git a/src/ltc/ciphers/noekeon.c b/src/ltc/ciphers/noekeon.c index 71f9430d..c933d45c 100644 --- a/src/ltc/ciphers/noekeon.c +++ b/src/ltc/ciphers/noekeon.c @@ -10,7 +10,7 @@ @file noekeon.c Implementation of the Noekeon block cipher by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_NOEKEON diff --git a/src/ltc/ciphers/rc2.c b/src/ltc/ciphers/rc2.c index fbb1690d..61219fe7 100644 --- a/src/ltc/ciphers/rc2.c +++ b/src/ltc/ciphers/rc2.c @@ -16,7 +16,7 @@ * Thanks to CodeView, SoftIce, and D86 for helping bring this code to * * the public. * \**********************************************************************/ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file rc2.c diff --git a/src/ltc/ciphers/rc5.c b/src/ltc/ciphers/rc5.c index 5368fac3..41305f04 100644 --- a/src/ltc/ciphers/rc5.c +++ b/src/ltc/ciphers/rc5.c @@ -12,7 +12,7 @@ LTC_RC5 code by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_RC5 diff --git a/src/ltc/ciphers/rc6.c b/src/ltc/ciphers/rc6.c index 5c8a8f9c..1a71e50a 100644 --- a/src/ltc/ciphers/rc6.c +++ b/src/ltc/ciphers/rc6.c @@ -11,7 +11,7 @@ @file rc6.c LTC_RC6 code by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_RC6 diff --git a/src/ltc/ciphers/safer/safer.c b/src/ltc/ciphers/safer/safer.c index 8e1368ff..913e1936 100644 --- a/src/ltc/ciphers/safer/safer.c +++ b/src/ltc/ciphers/safer/safer.c @@ -26,7 +26,7 @@ * *******************************************************************************/ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_SAFER diff --git a/src/ltc/ciphers/safer/saferp.c b/src/ltc/ciphers/safer/saferp.c index 65dc921a..e6e1c909 100644 --- a/src/ltc/ciphers/safer/saferp.c +++ b/src/ltc/ciphers/safer/saferp.c @@ -11,7 +11,7 @@ @file saferp.c LTC_SAFER+ Implementation by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_SAFERP diff --git a/src/ltc/ciphers/serpent.c b/src/ltc/ciphers/serpent.c index 362ce262..340010e5 100644 --- a/src/ltc/ciphers/serpent.c +++ b/src/ltc/ciphers/serpent.c @@ -15,7 +15,7 @@ https://en.wikipedia.org/wiki/Serpent_(cipher) */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_SERPENT diff --git a/src/ltc/ciphers/skipjack.c b/src/ltc/ciphers/skipjack.c index 67be57f0..8726af23 100644 --- a/src/ltc/ciphers/skipjack.c +++ b/src/ltc/ciphers/skipjack.c @@ -11,7 +11,7 @@ @file skipjack.c Skipjack Implementation by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_SKIPJACK diff --git a/src/ltc/ciphers/twofish/twofish.c b/src/ltc/ciphers/twofish/twofish.c index d444bb26..cbc85fad 100644 --- a/src/ltc/ciphers/twofish/twofish.c +++ b/src/ltc/ciphers/twofish/twofish.c @@ -11,7 +11,7 @@ @file twofish.c Implementation of Twofish by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_TWOFISH @@ -473,7 +473,7 @@ int twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const symmet const ulong32 *k; int r; #if !defined(LTC_TWOFISH_SMALL) && !defined(__GNUC__) - ulong32 *S1, *S2, *S3, *S4; + const ulong32 *S1, *S2, *S3, *S4; #endif LTC_ARGCHK(pt != NULL); @@ -547,7 +547,7 @@ int twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const symmet const ulong32 *k; int r; #if !defined(LTC_TWOFISH_SMALL) && !defined(__GNUC__) - ulong32 *S1, *S2, *S3, *S4; + const ulong32 *S1, *S2, *S3, *S4; #endif LTC_ARGCHK(pt != NULL); diff --git a/src/ltc/ciphers/xtea.c b/src/ltc/ciphers/xtea.c index 3f91bf73..b159078c 100644 --- a/src/ltc/ciphers/xtea.c +++ b/src/ltc/ciphers/xtea.c @@ -11,7 +11,7 @@ @file xtea.c Implementation of LTC_XTEA, Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_XTEA diff --git a/src/ltc/encauth/ccm/ccm_add_aad.c b/src/ltc/encauth/ccm/ccm_add_aad.c index 9744c570..53ff299f 100644 --- a/src/ltc/encauth/ccm/ccm_add_aad.c +++ b/src/ltc/encauth/ccm/ccm_add_aad.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CCM_MODE diff --git a/src/ltc/encauth/ccm/ccm_add_nonce.c b/src/ltc/encauth/ccm/ccm_add_nonce.c index ceffb8e4..e2b0faf8 100644 --- a/src/ltc/encauth/ccm/ccm_add_nonce.c +++ b/src/ltc/encauth/ccm/ccm_add_nonce.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CCM_MODE diff --git a/src/ltc/encauth/ccm/ccm_done.c b/src/ltc/encauth/ccm/ccm_done.c index 797b7d98..b379bdf3 100644 --- a/src/ltc/encauth/ccm/ccm_done.c +++ b/src/ltc/encauth/ccm/ccm_done.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CCM_MODE diff --git a/src/ltc/encauth/ccm/ccm_init.c b/src/ltc/encauth/ccm/ccm_init.c index b24e33e4..20c2a17b 100644 --- a/src/ltc/encauth/ccm/ccm_init.c +++ b/src/ltc/encauth/ccm/ccm_init.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CCM_MODE diff --git a/src/ltc/encauth/ccm/ccm_memory.c b/src/ltc/encauth/ccm/ccm_memory.c index 0ffdbcef..40ecba6e 100644 --- a/src/ltc/encauth/ccm/ccm_memory.c +++ b/src/ltc/encauth/ccm/ccm_memory.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ccm_memory.c diff --git a/src/ltc/encauth/ccm/ccm_process.c b/src/ltc/encauth/ccm/ccm_process.c index 8346d225..6e843d12 100644 --- a/src/ltc/encauth/ccm/ccm_process.c +++ b/src/ltc/encauth/ccm/ccm_process.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CCM_MODE diff --git a/src/ltc/encauth/ccm/ccm_reset.c b/src/ltc/encauth/ccm/ccm_reset.c index c2d0cae8..24dcc3f2 100644 --- a/src/ltc/encauth/ccm/ccm_reset.c +++ b/src/ltc/encauth/ccm/ccm_reset.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CCM_MODE diff --git a/src/ltc/encauth/chachapoly/chacha20poly1305_add_aad.c b/src/ltc/encauth/chachapoly/chacha20poly1305_add_aad.c index 0c0cf9d5..630c3834 100644 --- a/src/ltc/encauth/chachapoly/chacha20poly1305_add_aad.c +++ b/src/ltc/encauth/chachapoly/chacha20poly1305_add_aad.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CHACHA20POLY1305_MODE diff --git a/src/ltc/encauth/chachapoly/chacha20poly1305_decrypt.c b/src/ltc/encauth/chachapoly/chacha20poly1305_decrypt.c index 17979322..f19cf181 100644 --- a/src/ltc/encauth/chachapoly/chacha20poly1305_decrypt.c +++ b/src/ltc/encauth/chachapoly/chacha20poly1305_decrypt.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CHACHA20POLY1305_MODE diff --git a/src/ltc/encauth/chachapoly/chacha20poly1305_done.c b/src/ltc/encauth/chachapoly/chacha20poly1305_done.c index 127a7f04..ff1adbd5 100644 --- a/src/ltc/encauth/chachapoly/chacha20poly1305_done.c +++ b/src/ltc/encauth/chachapoly/chacha20poly1305_done.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CHACHA20POLY1305_MODE diff --git a/src/ltc/encauth/chachapoly/chacha20poly1305_encrypt.c b/src/ltc/encauth/chachapoly/chacha20poly1305_encrypt.c index c53c4a65..aeecc185 100644 --- a/src/ltc/encauth/chachapoly/chacha20poly1305_encrypt.c +++ b/src/ltc/encauth/chachapoly/chacha20poly1305_encrypt.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CHACHA20POLY1305_MODE diff --git a/src/ltc/encauth/chachapoly/chacha20poly1305_init.c b/src/ltc/encauth/chachapoly/chacha20poly1305_init.c index 2799e98a..f75ab76c 100644 --- a/src/ltc/encauth/chachapoly/chacha20poly1305_init.c +++ b/src/ltc/encauth/chachapoly/chacha20poly1305_init.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CHACHA20POLY1305_MODE diff --git a/src/ltc/encauth/chachapoly/chacha20poly1305_memory.c b/src/ltc/encauth/chachapoly/chacha20poly1305_memory.c index 54e2011d..34da9125 100644 --- a/src/ltc/encauth/chachapoly/chacha20poly1305_memory.c +++ b/src/ltc/encauth/chachapoly/chacha20poly1305_memory.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CHACHA20POLY1305_MODE diff --git a/src/ltc/encauth/chachapoly/chacha20poly1305_setiv.c b/src/ltc/encauth/chachapoly/chacha20poly1305_setiv.c index b87666e2..4e770a01 100644 --- a/src/ltc/encauth/chachapoly/chacha20poly1305_setiv.c +++ b/src/ltc/encauth/chachapoly/chacha20poly1305_setiv.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CHACHA20POLY1305_MODE diff --git a/src/ltc/encauth/chachapoly/chacha20poly1305_setiv_rfc7905.c b/src/ltc/encauth/chachapoly/chacha20poly1305_setiv_rfc7905.c index 7136a1ee..f2c5cb67 100644 --- a/src/ltc/encauth/chachapoly/chacha20poly1305_setiv_rfc7905.c +++ b/src/ltc/encauth/chachapoly/chacha20poly1305_setiv_rfc7905.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CHACHA20POLY1305_MODE diff --git a/src/ltc/encauth/eax/eax_addheader.c b/src/ltc/encauth/eax/eax_addheader.c index 5545336f..f70c638b 100644 --- a/src/ltc/encauth/eax/eax_addheader.c +++ b/src/ltc/encauth/eax/eax_addheader.c @@ -10,7 +10,7 @@ @file eax_addheader.c EAX implementation, add meta-data, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_EAX_MODE diff --git a/src/ltc/encauth/eax/eax_decrypt.c b/src/ltc/encauth/eax/eax_decrypt.c index b1407163..75001e77 100644 --- a/src/ltc/encauth/eax/eax_decrypt.c +++ b/src/ltc/encauth/eax/eax_decrypt.c @@ -11,7 +11,7 @@ @file eax_decrypt.c EAX implementation, decrypt block, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_EAX_MODE diff --git a/src/ltc/encauth/eax/eax_decrypt_verify_memory.c b/src/ltc/encauth/eax/eax_decrypt_verify_memory.c index 058a6a9a..788ac363 100644 --- a/src/ltc/encauth/eax/eax_decrypt_verify_memory.c +++ b/src/ltc/encauth/eax/eax_decrypt_verify_memory.c @@ -11,7 +11,7 @@ @file eax_decrypt_verify_memory.c EAX implementation, decrypt block of memory, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_EAX_MODE diff --git a/src/ltc/encauth/eax/eax_done.c b/src/ltc/encauth/eax/eax_done.c index b00bfe08..ab0c6c5d 100644 --- a/src/ltc/encauth/eax/eax_done.c +++ b/src/ltc/encauth/eax/eax_done.c @@ -11,7 +11,7 @@ @file eax_done.c EAX implementation, terminate session, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_EAX_MODE diff --git a/src/ltc/encauth/eax/eax_encrypt.c b/src/ltc/encauth/eax/eax_encrypt.c index 174f263d..7b30d1d4 100644 --- a/src/ltc/encauth/eax/eax_encrypt.c +++ b/src/ltc/encauth/eax/eax_encrypt.c @@ -11,7 +11,7 @@ @file eax_encrypt.c EAX implementation, encrypt block by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_EAX_MODE diff --git a/src/ltc/encauth/eax/eax_encrypt_authenticate_memory.c b/src/ltc/encauth/eax/eax_encrypt_authenticate_memory.c index 9980fc0b..b98aef5f 100644 --- a/src/ltc/encauth/eax/eax_encrypt_authenticate_memory.c +++ b/src/ltc/encauth/eax/eax_encrypt_authenticate_memory.c @@ -11,7 +11,7 @@ @file eax_encrypt_authenticate_memory.c EAX implementation, encrypt a block of memory, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_EAX_MODE diff --git a/src/ltc/encauth/eax/eax_init.c b/src/ltc/encauth/eax/eax_init.c index 154d7a9a..2b2f1a67 100644 --- a/src/ltc/encauth/eax/eax_init.c +++ b/src/ltc/encauth/eax/eax_init.c @@ -11,7 +11,7 @@ @file eax_init.c EAX implementation, initialized EAX state, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_EAX_MODE diff --git a/src/ltc/encauth/gcm/gcm_add_aad.c b/src/ltc/encauth/gcm/gcm_add_aad.c index cacc15ba..4f0293b7 100644 --- a/src/ltc/encauth/gcm/gcm_add_aad.c +++ b/src/ltc/encauth/gcm/gcm_add_aad.c @@ -11,7 +11,7 @@ @file gcm_add_aad.c GCM implementation, Add AAD data to the stream, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_GCM_MODE diff --git a/src/ltc/encauth/gcm/gcm_add_iv.c b/src/ltc/encauth/gcm/gcm_add_iv.c index 3fd38614..2099f7b6 100644 --- a/src/ltc/encauth/gcm/gcm_add_iv.c +++ b/src/ltc/encauth/gcm/gcm_add_iv.c @@ -11,7 +11,7 @@ @file gcm_add_iv.c GCM implementation, add IV data to the state, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_GCM_MODE diff --git a/src/ltc/encauth/gcm/gcm_done.c b/src/ltc/encauth/gcm/gcm_done.c index ffd551e8..55a13242 100644 --- a/src/ltc/encauth/gcm/gcm_done.c +++ b/src/ltc/encauth/gcm/gcm_done.c @@ -11,7 +11,7 @@ @file gcm_done.c GCM implementation, Terminate the stream, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_GCM_MODE diff --git a/src/ltc/encauth/gcm/gcm_gf_mult.c b/src/ltc/encauth/gcm/gcm_gf_mult.c index 2e7a9060..b1b8e080 100644 --- a/src/ltc/encauth/gcm/gcm_gf_mult.c +++ b/src/ltc/encauth/gcm/gcm_gf_mult.c @@ -11,7 +11,7 @@ @file gcm_gf_mult.c GCM implementation, do the GF mult, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #if defined(LTC_GCM_TABLES) || defined(LTC_LRW_TABLES) || ((defined(LTC_GCM_MODE) || defined(LTC_GCM_MODE)) && defined(LTC_FAST)) diff --git a/src/ltc/encauth/gcm/gcm_init.c b/src/ltc/encauth/gcm/gcm_init.c index 072870d0..4b582473 100644 --- a/src/ltc/encauth/gcm/gcm_init.c +++ b/src/ltc/encauth/gcm/gcm_init.c @@ -11,7 +11,7 @@ @file gcm_init.c GCM implementation, initialize state, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_GCM_MODE diff --git a/src/ltc/encauth/gcm/gcm_memory.c b/src/ltc/encauth/gcm/gcm_memory.c index 7b59960f..b318f7cf 100644 --- a/src/ltc/encauth/gcm/gcm_memory.c +++ b/src/ltc/encauth/gcm/gcm_memory.c @@ -11,7 +11,7 @@ @file gcm_memory.c GCM implementation, process a packet, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_GCM_MODE diff --git a/src/ltc/encauth/gcm/gcm_mult_h.c b/src/ltc/encauth/gcm/gcm_mult_h.c index 4e374b41..add59c79 100644 --- a/src/ltc/encauth/gcm/gcm_mult_h.c +++ b/src/ltc/encauth/gcm/gcm_mult_h.c @@ -11,7 +11,7 @@ @file gcm_mult_h.c GCM implementation, do the GF mult, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #if defined(LTC_GCM_MODE) /** diff --git a/src/ltc/encauth/gcm/gcm_process.c b/src/ltc/encauth/gcm/gcm_process.c index b1ec20cf..079cdfad 100644 --- a/src/ltc/encauth/gcm/gcm_process.c +++ b/src/ltc/encauth/gcm/gcm_process.c @@ -11,7 +11,7 @@ @file gcm_process.c GCM implementation, process message data, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_GCM_MODE diff --git a/src/ltc/encauth/gcm/gcm_reset.c b/src/ltc/encauth/gcm/gcm_reset.c index 3bd10885..bb6987f8 100644 --- a/src/ltc/encauth/gcm/gcm_reset.c +++ b/src/ltc/encauth/gcm/gcm_reset.c @@ -11,7 +11,7 @@ @file gcm_reset.c GCM implementation, reset a used state so it can accept IV data, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_GCM_MODE diff --git a/src/ltc/encauth/ocb3/ocb3_add_aad.c b/src/ltc/encauth/ocb3/ocb3_add_aad.c index 70e3211a..625e4b9b 100644 --- a/src/ltc/encauth/ocb3/ocb3_add_aad.c +++ b/src/ltc/encauth/ocb3/ocb3_add_aad.c @@ -11,7 +11,7 @@ @file ocb3_add_aad.c OCB implementation, add AAD data, by Karel Miko */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_OCB3_MODE diff --git a/src/ltc/encauth/ocb3/ocb3_decrypt.c b/src/ltc/encauth/ocb3/ocb3_decrypt.c index 4973bd2f..3c57fda0 100644 --- a/src/ltc/encauth/ocb3/ocb3_decrypt.c +++ b/src/ltc/encauth/ocb3/ocb3_decrypt.c @@ -11,7 +11,7 @@ @file ocb3_decrypt.c OCB implementation, decrypt data, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_OCB3_MODE diff --git a/src/ltc/encauth/ocb3/ocb3_decrypt_last.c b/src/ltc/encauth/ocb3/ocb3_decrypt_last.c index 70608dc7..cb0b6ead 100644 --- a/src/ltc/encauth/ocb3/ocb3_decrypt_last.c +++ b/src/ltc/encauth/ocb3/ocb3_decrypt_last.c @@ -11,7 +11,7 @@ @file ocb3_decrypt_last.c OCB implementation, internal helper, by Karel Miko */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_OCB3_MODE diff --git a/src/ltc/encauth/ocb3/ocb3_decrypt_verify_memory.c b/src/ltc/encauth/ocb3/ocb3_decrypt_verify_memory.c index 066b62cb..f6c10232 100644 --- a/src/ltc/encauth/ocb3/ocb3_decrypt_verify_memory.c +++ b/src/ltc/encauth/ocb3/ocb3_decrypt_verify_memory.c @@ -11,7 +11,7 @@ @file ocb3_decrypt_verify_memory.c OCB implementation, helper to decrypt block of memory, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_OCB3_MODE diff --git a/src/ltc/encauth/ocb3/ocb3_done.c b/src/ltc/encauth/ocb3/ocb3_done.c index b913d3a4..0331ccef 100644 --- a/src/ltc/encauth/ocb3/ocb3_done.c +++ b/src/ltc/encauth/ocb3/ocb3_done.c @@ -11,7 +11,7 @@ @file ocb3_done.c OCB implementation, INTERNAL ONLY helper, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_OCB3_MODE diff --git a/src/ltc/encauth/ocb3/ocb3_encrypt.c b/src/ltc/encauth/ocb3/ocb3_encrypt.c index 337b0253..3fd9596f 100644 --- a/src/ltc/encauth/ocb3/ocb3_encrypt.c +++ b/src/ltc/encauth/ocb3/ocb3_encrypt.c @@ -11,7 +11,7 @@ @file ocb3_encrypt.c OCB implementation, encrypt data, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_OCB3_MODE diff --git a/src/ltc/encauth/ocb3/ocb3_encrypt_authenticate_memory.c b/src/ltc/encauth/ocb3/ocb3_encrypt_authenticate_memory.c index efc1a8fb..5261e94e 100644 --- a/src/ltc/encauth/ocb3/ocb3_encrypt_authenticate_memory.c +++ b/src/ltc/encauth/ocb3/ocb3_encrypt_authenticate_memory.c @@ -11,7 +11,7 @@ @file ocb3_encrypt_authenticate_memory.c OCB implementation, encrypt block of memory, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_OCB3_MODE diff --git a/src/ltc/encauth/ocb3/ocb3_encrypt_last.c b/src/ltc/encauth/ocb3/ocb3_encrypt_last.c index 8110a3c0..5834ef4a 100644 --- a/src/ltc/encauth/ocb3/ocb3_encrypt_last.c +++ b/src/ltc/encauth/ocb3/ocb3_encrypt_last.c @@ -11,7 +11,7 @@ @file ocb3_encrypt_last.c OCB implementation, internal helper, by Karel Miko */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_OCB3_MODE diff --git a/src/ltc/encauth/ocb3/ocb3_init.c b/src/ltc/encauth/ocb3/ocb3_init.c index a3cabae8..3ad4ab08 100644 --- a/src/ltc/encauth/ocb3/ocb3_init.c +++ b/src/ltc/encauth/ocb3/ocb3_init.c @@ -11,7 +11,7 @@ @file ocb3_init.c OCB implementation, initialize state, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_OCB3_MODE diff --git a/src/ltc/encauth/ocb3/ocb3_int_ntz.c b/src/ltc/encauth/ocb3/ocb3_int_ntz.c index 3c5b18d0..d2dc4b4c 100644 --- a/src/ltc/encauth/ocb3/ocb3_int_ntz.c +++ b/src/ltc/encauth/ocb3/ocb3_int_ntz.c @@ -11,7 +11,7 @@ @file ocb3_int_ntz.c OCB implementation, INTERNAL ONLY helper, by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_OCB3_MODE diff --git a/src/ltc/encauth/ocb3/ocb3_int_xor_blocks.c b/src/ltc/encauth/ocb3/ocb3_int_xor_blocks.c index 798bddcd..bb7d6eb0 100644 --- a/src/ltc/encauth/ocb3/ocb3_int_xor_blocks.c +++ b/src/ltc/encauth/ocb3/ocb3_int_xor_blocks.c @@ -11,7 +11,7 @@ @file ocb3_int_xor_blocks.c OCB implementation, INTERNAL ONLY helper, by Karel Miko */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_OCB3_MODE diff --git a/src/ltc/hashes/blake2b.c b/src/ltc/hashes/blake2b.c index cd5115ca..6b91a851 100644 --- a/src/ltc/hashes/blake2b.c +++ b/src/ltc/hashes/blake2b.c @@ -23,7 +23,7 @@ */ /* see also https://www.ietf.org/rfc/rfc7693.txt */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_BLAKE2B @@ -199,6 +199,19 @@ static int blake2b_init_param(hash_state *md, const unsigned char *P) return CRYPT_OK; } +/** + Initialize the hash/MAC state + + Use this function to init for arbitrary sizes. + + Give a key and keylen to init for MAC mode. + + @param md The hash state you wish to initialize + @param outlen The desired output-length + @param key The key of the MAC + @param keylen The length of the key + @return CRYPT_OK if successful +*/ int blake2b_init(hash_state *md, unsigned long outlen, const unsigned char *key, unsigned long keylen) { unsigned char P[BLAKE2B_PARAM_SIZE]; @@ -237,12 +250,32 @@ int blake2b_init(hash_state *md, unsigned long outlen, const unsigned char *key, return CRYPT_OK; } +/** + Initialize the hash state + @param md The hash state you wish to initialize + @return CRYPT_OK if successful +*/ int blake2b_160_init(hash_state *md) { return blake2b_init(md, 20, NULL, 0); } +/** + Initialize the hash state + @param md The hash state you wish to initialize + @return CRYPT_OK if successful +*/ int blake2b_256_init(hash_state *md) { return blake2b_init(md, 32, NULL, 0); } +/** + Initialize the hash state + @param md The hash state you wish to initialize + @return CRYPT_OK if successful +*/ int blake2b_384_init(hash_state *md) { return blake2b_init(md, 48, NULL, 0); } +/** + Initialize the hash state + @param md The hash state you wish to initialize + @return CRYPT_OK if successful +*/ int blake2b_512_init(hash_state *md) { return blake2b_init(md, 64, NULL, 0); } #define G(r, i, a, b, c, d) \ @@ -328,6 +361,13 @@ static int blake2b_compress(hash_state *md, const unsigned char *buf) } #endif +/** + Process a block of memory through the hash + @param md The hash state + @param in The data to hash + @param inlen The length of the data (octets) + @return CRYPT_OK if successful +*/ int blake2b_process(hash_state *md, const unsigned char *in, unsigned long inlen) { LTC_ARGCHK(md != NULL); @@ -360,6 +400,12 @@ int blake2b_process(hash_state *md, const unsigned char *in, unsigned long inlen return CRYPT_OK; } +/** + Terminate the hash to get the digest + @param md The hash state + @param out [out] The destination of the hash (size depending on the length used on init) + @return CRYPT_OK if successful +*/ int blake2b_done(hash_state *md, unsigned char *out) { unsigned char buffer[BLAKE2B_OUTBYTES] = { 0 }; diff --git a/src/ltc/hashes/blake2s.c b/src/ltc/hashes/blake2s.c index e3e90f86..96439eb6 100644 --- a/src/ltc/hashes/blake2s.c +++ b/src/ltc/hashes/blake2s.c @@ -23,7 +23,7 @@ */ /* see also https://www.ietf.org/rfc/rfc7693.txt */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_BLAKE2S @@ -193,6 +193,19 @@ static int blake2s_init_param(hash_state *md, const unsigned char *P) return CRYPT_OK; } +/** + Initialize the hash/MAC state + + Use this function to init for arbitrary sizes. + + Give a key and keylen to init for MAC mode. + + @param md The hash state you wish to initialize + @param outlen The desired output-length + @param key The key of the MAC + @param keylen The length of the key + @return CRYPT_OK if successful +*/ int blake2s_init(hash_state *md, unsigned long outlen, const unsigned char *key, unsigned long keylen) { unsigned char P[BLAKE2S_PARAM_SIZE]; @@ -230,12 +243,32 @@ int blake2s_init(hash_state *md, unsigned long outlen, const unsigned char *key, return CRYPT_OK; } +/** + Initialize the hash state + @param md The hash state you wish to initialize + @return CRYPT_OK if successful +*/ int blake2s_128_init(hash_state *md) { return blake2s_init(md, 16, NULL, 0); } +/** + Initialize the hash state + @param md The hash state you wish to initialize + @return CRYPT_OK if successful +*/ int blake2s_160_init(hash_state *md) { return blake2s_init(md, 20, NULL, 0); } +/** + Initialize the hash state + @param md The hash state you wish to initialize + @return CRYPT_OK if successful +*/ int blake2s_224_init(hash_state *md) { return blake2s_init(md, 28, NULL, 0); } +/** + Initialize the hash state + @param md The hash state you wish to initialize + @return CRYPT_OK if successful +*/ int blake2s_256_init(hash_state *md) { return blake2s_init(md, 32, NULL, 0); } #define G(r, i, a, b, c, d) \ @@ -316,6 +349,13 @@ static int blake2s_compress(hash_state *md, const unsigned char *buf) } #endif +/** + Process a block of memory through the hash + @param md The hash state + @param in The data to hash + @param inlen The length of the data (octets) + @return CRYPT_OK if successful +*/ int blake2s_process(hash_state *md, const unsigned char *in, unsigned long inlen) { LTC_ARGCHK(md != NULL); @@ -348,6 +388,12 @@ int blake2s_process(hash_state *md, const unsigned char *in, unsigned long inlen return CRYPT_OK; } +/** + Terminate the hash to get the digest + @param md The hash state + @param out [out] The destination of the hash (size depending on the length used on init) + @return CRYPT_OK if successful +*/ int blake2s_done(hash_state *md, unsigned char *out) { unsigned char buffer[BLAKE2S_OUTBYTES] = { 0 }; diff --git a/src/ltc/hashes/chc/chc.c b/src/ltc/hashes/chc/chc.c index dc350529..bcb6947a 100644 --- a/src/ltc/hashes/chc/chc.c +++ b/src/ltc/hashes/chc/chc.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file chc.c diff --git a/src/ltc/hashes/helper/hash_file.c b/src/ltc/hashes/helper/hash_file.c index 0b96eaee..9c8493b0 100644 --- a/src/ltc/hashes/helper/hash_file.c +++ b/src/ltc/hashes/helper/hash_file.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifndef LTC_NO_FILE /** diff --git a/src/ltc/hashes/helper/hash_filehandle.c b/src/ltc/hashes/helper/hash_filehandle.c index 0e4d7a64..521aa805 100644 --- a/src/ltc/hashes/helper/hash_filehandle.c +++ b/src/ltc/hashes/helper/hash_filehandle.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifndef LTC_NO_FILE /** diff --git a/src/ltc/hashes/helper/hash_memory.c b/src/ltc/hashes/helper/hash_memory.c index e8471acf..483552de 100644 --- a/src/ltc/hashes/helper/hash_memory.c +++ b/src/ltc/hashes/helper/hash_memory.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_HASH_HELPERS /** diff --git a/src/ltc/hashes/helper/hash_memory_multi.c b/src/ltc/hashes/helper/hash_memory_multi.c index d10b4582..5200d9ae 100644 --- a/src/ltc/hashes/helper/hash_memory_multi.c +++ b/src/ltc/hashes/helper/hash_memory_multi.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #include <stdarg.h> #ifdef LTC_HASH_HELPERS diff --git a/src/ltc/hashes/md2.c b/src/ltc/hashes/md2.c index 36cc8aec..b3fc88af 100644 --- a/src/ltc/hashes/md2.c +++ b/src/ltc/hashes/md2.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @param md2.c diff --git a/src/ltc/hashes/md4.c b/src/ltc/hashes/md4.c index e3bc0c55..0dd20748 100644 --- a/src/ltc/hashes/md4.c +++ b/src/ltc/hashes/md4.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @param md4.c diff --git a/src/ltc/hashes/md5.c b/src/ltc/hashes/md5.c index a417970a..f37a4726 100644 --- a/src/ltc/hashes/md5.c +++ b/src/ltc/hashes/md5.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** diff --git a/src/ltc/hashes/rmd128.c b/src/ltc/hashes/rmd128.c index b60cb0ad..a9c26fc4 100644 --- a/src/ltc/hashes/rmd128.c +++ b/src/ltc/hashes/rmd128.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @param rmd128.c diff --git a/src/ltc/hashes/rmd160.c b/src/ltc/hashes/rmd160.c index d38d2beb..550e3ed1 100644 --- a/src/ltc/hashes/rmd160.c +++ b/src/ltc/hashes/rmd160.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file rmd160.c diff --git a/src/ltc/hashes/rmd256.c b/src/ltc/hashes/rmd256.c index da51a1d9..f3ca1061 100644 --- a/src/ltc/hashes/rmd256.c +++ b/src/ltc/hashes/rmd256.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @param rmd256.c diff --git a/src/ltc/hashes/rmd320.c b/src/ltc/hashes/rmd320.c index ba6ba9e1..06f27644 100644 --- a/src/ltc/hashes/rmd320.c +++ b/src/ltc/hashes/rmd320.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file rmd320.c diff --git a/src/ltc/hashes/sha1.c b/src/ltc/hashes/sha1.c index f78ef75c..debf9b0f 100644 --- a/src/ltc/hashes/sha1.c +++ b/src/ltc/hashes/sha1.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file sha1.c diff --git a/src/ltc/hashes/sha2/sha224.c b/src/ltc/hashes/sha2/sha224.c index 773a2c52..bb68abc0 100644 --- a/src/ltc/hashes/sha2/sha224.c +++ b/src/ltc/hashes/sha2/sha224.c @@ -11,7 +11,7 @@ LTC_SHA-224 new NIST standard based off of LTC_SHA-256 truncated to 224 bits (Tom St Denis) */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #if defined(LTC_SHA224) && defined(LTC_SHA256) diff --git a/src/ltc/hashes/sha2/sha256.c b/src/ltc/hashes/sha2/sha256.c index 3b9c4e24..c553fd08 100644 --- a/src/ltc/hashes/sha2/sha256.c +++ b/src/ltc/hashes/sha2/sha256.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file sha256.c diff --git a/src/ltc/hashes/sha2/sha384.c b/src/ltc/hashes/sha2/sha384.c index 16238127..973625fc 100644 --- a/src/ltc/hashes/sha2/sha384.c +++ b/src/ltc/hashes/sha2/sha384.c @@ -11,7 +11,7 @@ LTC_SHA384 hash included in sha512.c, Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #if defined(LTC_SHA384) && defined(LTC_SHA512) diff --git a/src/ltc/hashes/sha2/sha512.c b/src/ltc/hashes/sha2/sha512.c index c7bffd17..5e4ad153 100644 --- a/src/ltc/hashes/sha2/sha512.c +++ b/src/ltc/hashes/sha2/sha512.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @param sha512.c diff --git a/src/ltc/hashes/sha2/sha512_224.c b/src/ltc/hashes/sha2/sha512_224.c index 48bb9384..ad0f95b7 100644 --- a/src/ltc/hashes/sha2/sha512_224.c +++ b/src/ltc/hashes/sha2/sha512_224.c @@ -11,7 +11,7 @@ SHA512/224 hash included in sha512.c */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #if defined(LTC_SHA512_224) && defined(LTC_SHA512) diff --git a/src/ltc/hashes/sha2/sha512_256.c b/src/ltc/hashes/sha2/sha512_256.c index 943adaa6..fda0339c 100644 --- a/src/ltc/hashes/sha2/sha512_256.c +++ b/src/ltc/hashes/sha2/sha512_256.c @@ -11,7 +11,7 @@ SHA512/256 hash included in sha512.c */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #if defined(LTC_SHA512_256) && defined(LTC_SHA512) diff --git a/src/ltc/hashes/sha3.c b/src/ltc/hashes/sha3.c index 5e91538f..d9bbc8af 100644 --- a/src/ltc/hashes/sha3.c +++ b/src/ltc/hashes/sha3.c @@ -9,7 +9,7 @@ /* based on https://github.com/brainhub/SHA3IUF (public domain) */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_SHA3 diff --git a/src/ltc/hashes/sha3_test.c b/src/ltc/hashes/sha3_test.c index 2bf74823..3f119a6c 100644 --- a/src/ltc/hashes/sha3_test.c +++ b/src/ltc/hashes/sha3_test.c @@ -9,7 +9,7 @@ /* based on https://github.com/brainhub/SHA3IUF (public domain) */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_SHA3 diff --git a/src/ltc/hashes/tiger.c b/src/ltc/hashes/tiger.c index c6dce7cf..0d3ba102 100644 --- a/src/ltc/hashes/tiger.c +++ b/src/ltc/hashes/tiger.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file tiger.c diff --git a/src/ltc/hashes/whirl/whirl.c b/src/ltc/hashes/whirl/whirl.c index 636f03a4..1f374f86 100644 --- a/src/ltc/hashes/whirl/whirl.c +++ b/src/ltc/hashes/whirl/whirl.c @@ -12,7 +12,7 @@ LTC_WHIRLPOOL (using their new sbox) hash function by Tom St Denis */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_WHIRLPOOL diff --git a/src/ltc/headers/tomcrypt_cipher.h b/src/ltc/headers/tomcrypt_cipher.h index a94055e9..4b983593 100644 --- a/src/ltc/headers/tomcrypt_cipher.h +++ b/src/ltc/headers/tomcrypt_cipher.h @@ -1031,6 +1031,15 @@ int salsa20_test(void); #endif /* LTC_SALSA20 */ +#ifdef LTC_XSALSA20 + +int xsalsa20_setup(salsa20_state *st, const unsigned char *key, unsigned long keylen, + const unsigned char *nonce, unsigned long noncelen, + int rounds); +int xsalsa20_test(void); + +#endif /* LTC_XSALSA20 */ + #ifdef LTC_SOSEMANUK typedef struct { diff --git a/src/ltc/headers/tomcrypt_custom.h b/src/ltc/headers/tomcrypt_custom.h index ab45e76b..27727186 100644 --- a/src/ltc/headers/tomcrypt_custom.h +++ b/src/ltc/headers/tomcrypt_custom.h @@ -208,6 +208,7 @@ /* stream ciphers */ #define LTC_CHACHA #define LTC_SALSA20 +#define LTC_XSALSA20 #define LTC_SOSEMANUK #define LTC_RABBIT #define LTC_RC4_STREAM @@ -364,6 +365,15 @@ /* time-based rate limit of the reseeding */ #define LTC_FORTUNA_RESEED_RATELIMIT_TIMED +/* with non-glibc or glibc 2.17+ prefer clock_gettime over gettimeofday */ +#if defined(__GLIBC__) && defined(__GLIBC_PREREQ) +#if __GLIBC_PREREQ(2, 17) + #define LTC_CLOCK_GETTIME +#endif +#elif defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L + #define LTC_CLOCK_GETTIME +#endif + #else #ifndef LTC_FORTUNA_WD @@ -415,9 +425,6 @@ #define LTC_DH8192 #endif -/* Include Katja (a Rabin variant like RSA) */ -/* #define LTC_MKAT */ - /* Digital Signature Algorithm */ #define LTC_MDSA @@ -538,7 +545,7 @@ #endif #endif -#if defined(LTC_MECC) || defined(LTC_MRSA) || defined(LTC_MDSA) || defined(LTC_MKAT) +#if defined(LTC_MECC) || defined(LTC_MRSA) || defined(LTC_MDSA) /* Include the MPI functionality? (required by the PK algorithms) */ #define LTC_MPI @@ -568,7 +575,7 @@ #error ASN.1 DER requires MPI functionality #endif -#if (defined(LTC_MDSA) || defined(LTC_MRSA) || defined(LTC_MECC) || defined(LTC_MKAT)) && !defined(LTC_DER) +#if (defined(LTC_MDSA) || defined(LTC_MRSA) || defined(LTC_MECC)) && !defined(LTC_DER) #error PK requires ASN.1 DER functionality, make sure LTC_DER is enabled #endif @@ -580,6 +587,10 @@ #error LTC_CHACHA20_PRNG requires LTC_CHACHA #endif +#if defined(LTC_XSALSA20) && !defined(LTC_SALSA20) + #error LTC_XSALSA20 requires LTC_SALSA20 +#endif + #if defined(LTC_RC4) && !defined(LTC_RC4_STREAM) #error LTC_RC4 requires LTC_RC4_STREAM #endif diff --git a/src/ltc/headers/tomcrypt_hash.h b/src/ltc/headers/tomcrypt_hash.h index ea2077ec..dbb6b9a1 100644 --- a/src/ltc/headers/tomcrypt_hash.h +++ b/src/ltc/headers/tomcrypt_hash.h @@ -507,46 +507,6 @@ int hash_filehandle(int hash, FILE *in, unsigned char *out, unsigned long *outle int hash_file(int hash, const char *fname, unsigned char *out, unsigned long *outlen); #endif -/* a simple macro for making hash "process" functions */ -#define HASH_PROCESS(func_name, compress_name, state_var, block_size) \ -int func_name (hash_state * md, const unsigned char *in, unsigned long inlen) \ -{ \ - unsigned long n; \ - int err; \ - LTC_ARGCHK(md != NULL); \ - LTC_ARGCHK(in != NULL); \ - if (md-> state_var .curlen > sizeof(md-> state_var .buf)) { \ - return CRYPT_INVALID_ARG; \ - } \ - if ((md-> state_var .length + inlen) < md-> state_var .length) { \ - return CRYPT_HASH_OVERFLOW; \ - } \ - while (inlen > 0) { \ - if (md-> state_var .curlen == 0 && inlen >= block_size) { \ - if ((err = compress_name (md, in)) != CRYPT_OK) { \ - return err; \ - } \ - md-> state_var .length += block_size * 8; \ - in += block_size; \ - inlen -= block_size; \ - } else { \ - n = MIN(inlen, (block_size - md-> state_var .curlen)); \ - XMEMCPY(md-> state_var .buf + md-> state_var.curlen, in, (size_t)n); \ - md-> state_var .curlen += n; \ - in += n; \ - inlen -= n; \ - if (md-> state_var .curlen == block_size) { \ - if ((err = compress_name (md, md-> state_var .buf)) != CRYPT_OK) { \ - return err; \ - } \ - md-> state_var .length += 8*block_size; \ - md-> state_var .curlen = 0; \ - } \ - } \ - } \ - return CRYPT_OK; \ -} - /* ref: $Format:%D$ */ /* git commit: $Format:%H$ */ /* commit time: $Format:%ai$ */ diff --git a/src/ltc/headers/tomcrypt_mac.h b/src/ltc/headers/tomcrypt_mac.h index ebb84103..e4fdf14a 100644 --- a/src/ltc/headers/tomcrypt_mac.h +++ b/src/ltc/headers/tomcrypt_mac.h @@ -146,6 +146,7 @@ int blake2bmac_file(const char *fname, const unsigned char *key, unsigned long k int blake2bmac_test(void); #endif /* LTC_BLAKE2BMAC */ + #ifdef LTC_PELICAN typedef struct pelican_state @@ -391,12 +392,6 @@ int ocb3_decrypt_verify_memory(int cipher, int ocb3_test(void); -#ifdef LTC_SOURCE -/* internal helper functions */ -int ocb3_int_ntz(unsigned long x); -void ocb3_int_xor_blocks(unsigned char *out, const unsigned char *block_a, const unsigned char *block_b, unsigned long block_len); -#endif /* LTC_SOURCE */ - #endif /* LTC_OCB3_MODE */ #ifdef LTC_CCM_MODE diff --git a/src/ltc/headers/tomcrypt_math.h b/src/ltc/headers/tomcrypt_math.h index 79f6d21c..06783392 100644 --- a/src/ltc/headers/tomcrypt_math.h +++ b/src/ltc/headers/tomcrypt_math.h @@ -524,77 +524,6 @@ extern const ltc_math_descriptor tfm_desc; extern const ltc_math_descriptor gmp_desc; #endif -#if !defined(DESC_DEF_ONLY) && defined(LTC_SOURCE) - -#define MP_DIGIT_BIT ltc_mp.bits_per_digit - -/* some handy macros */ -#define mp_init(a) ltc_mp.init(a) -#define mp_init_multi ltc_init_multi -#define mp_clear(a) ltc_mp.deinit(a) -#define mp_clear_multi ltc_deinit_multi -#define mp_cleanup_multi ltc_cleanup_multi -#define mp_init_copy(a, b) ltc_mp.init_copy(a, b) - -#define mp_neg(a, b) ltc_mp.neg(a, b) -#define mp_copy(a, b) ltc_mp.copy(a, b) - -#define mp_set(a, b) ltc_mp.set_int(a, b) -#define mp_set_int(a, b) ltc_mp.set_int(a, b) -#define mp_get_int(a) ltc_mp.get_int(a) -#define mp_get_digit(a, n) ltc_mp.get_digit(a, n) -#define mp_get_digit_count(a) ltc_mp.get_digit_count(a) -#define mp_cmp(a, b) ltc_mp.compare(a, b) -#define mp_cmp_d(a, b) ltc_mp.compare_d(a, b) -#define mp_count_bits(a) ltc_mp.count_bits(a) -#define mp_cnt_lsb(a) ltc_mp.count_lsb_bits(a) -#define mp_2expt(a, b) ltc_mp.twoexpt(a, b) - -#define mp_read_radix(a, b, c) ltc_mp.read_radix(a, b, c) -#define mp_toradix(a, b, c) ltc_mp.write_radix(a, b, c) -#define mp_unsigned_bin_size(a) ltc_mp.unsigned_size(a) -#define mp_to_unsigned_bin(a, b) ltc_mp.unsigned_write(a, b) -#define mp_read_unsigned_bin(a, b, c) ltc_mp.unsigned_read(a, b, c) - -#define mp_add(a, b, c) ltc_mp.add(a, b, c) -#define mp_add_d(a, b, c) ltc_mp.addi(a, b, c) -#define mp_sub(a, b, c) ltc_mp.sub(a, b, c) -#define mp_sub_d(a, b, c) ltc_mp.subi(a, b, c) -#define mp_mul(a, b, c) ltc_mp.mul(a, b, c) -#define mp_mul_d(a, b, c) ltc_mp.muli(a, b, c) -#define mp_sqr(a, b) ltc_mp.sqr(a, b) -#define mp_sqrtmod_prime(a, b, c) ltc_mp.sqrtmod_prime(a, b, c) -#define mp_div(a, b, c, d) ltc_mp.mpdiv(a, b, c, d) -#define mp_div_2(a, b) ltc_mp.div_2(a, b) -#define mp_mod(a, b, c) ltc_mp.mpdiv(a, b, NULL, c) -#define mp_mod_d(a, b, c) ltc_mp.modi(a, b, c) -#define mp_gcd(a, b, c) ltc_mp.gcd(a, b, c) -#define mp_lcm(a, b, c) ltc_mp.lcm(a, b, c) - -#define mp_addmod(a, b, c, d) ltc_mp.addmod(a, b, c, d) -#define mp_submod(a, b, c, d) ltc_mp.submod(a, b, c, d) -#define mp_mulmod(a, b, c, d) ltc_mp.mulmod(a, b, c, d) -#define mp_sqrmod(a, b, c) ltc_mp.sqrmod(a, b, c) -#define mp_invmod(a, b, c) ltc_mp.invmod(a, b, c) - -#define mp_montgomery_setup(a, b) ltc_mp.montgomery_setup(a, b) -#define mp_montgomery_normalization(a, b) ltc_mp.montgomery_normalization(a, b) -#define mp_montgomery_reduce(a, b, c) ltc_mp.montgomery_reduce(a, b, c) -#define mp_montgomery_free(a) ltc_mp.montgomery_deinit(a) - -#define mp_exptmod(a,b,c,d) ltc_mp.exptmod(a,b,c,d) -#define mp_prime_is_prime(a, b, c) ltc_mp.isprime(a, b, c) - -#define mp_iszero(a) (mp_cmp_d(a, 0) == LTC_MP_EQ ? LTC_MP_YES : LTC_MP_NO) -#define mp_isodd(a) (mp_get_digit_count(a) > 0 ? (mp_get_digit(a, 0) & 1 ? LTC_MP_YES : LTC_MP_NO) : LTC_MP_NO) -#define mp_exch(a, b) do { void *ABC__tmp = a; a = b; b = ABC__tmp; } while(0) - -#define mp_tohex(a, b) mp_toradix(a, b, 16) - -#define mp_rand(a, b) ltc_mp.rand(a, b) - -#endif - /* ref: $Format:%D$ */ /* git commit: $Format:%H$ */ /* commit time: $Format:%ai$ */ diff --git a/src/ltc/headers/tomcrypt_misc.h b/src/ltc/headers/tomcrypt_misc.h index a022b280..b30e087d 100644 --- a/src/ltc/headers/tomcrypt_misc.h +++ b/src/ltc/headers/tomcrypt_misc.h @@ -54,7 +54,7 @@ int base32_decode(const char *in, unsigned long inlen, #ifdef LTC_BASE16 int base16_encode(const unsigned char *in, unsigned long inlen, char *out, unsigned long *outlen, - int caps); + unsigned int options); int base16_decode(const char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen); #endif @@ -85,9 +85,6 @@ int hkdf(int hash_idx, /* ---- MEM routines ---- */ int mem_neq(const void *a, const void *b, size_t len); void zeromem(volatile void *dst, size_t len); -#ifdef LTC_SOURCE -void copy_or_zeromem(const unsigned char* src, unsigned char* dest, unsigned long len, int coz); -#endif void burn_stack(unsigned long len); const char *error_to_string(int err); @@ -155,11 +152,6 @@ enum padding_type { int padding_pad(unsigned char *data, unsigned long length, unsigned long* padded_length, unsigned long mode); int padding_depad(const unsigned char *data, unsigned long *length, unsigned long mode); - -#ifdef LTC_SOURCE -/* internal helper functions */ -#define LTC_PAD_MASK (0xF000U) -#endif #endif /* LTC_PADDING */ int compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which); diff --git a/src/ltc/headers/tomcrypt_pk.h b/src/ltc/headers/tomcrypt_pk.h index c3d05daf..64e83bd4 100644 --- a/src/ltc/headers/tomcrypt_pk.h +++ b/src/ltc/headers/tomcrypt_pk.h @@ -25,29 +25,6 @@ enum public_key_type { int rand_prime(void *N, long len, prng_state *prng, int wprng); -#ifdef LTC_SOURCE -/* internal helper functions */ -int rand_bn_bits(void *N, int bits, prng_state *prng, int wprng); -int rand_bn_upto(void *N, void *limit, prng_state *prng, int wprng); - -enum public_key_algorithms { - PKA_RSA, - PKA_DSA, - PKA_EC, - PKA_EC_PRIMEF -}; - -typedef struct Oid { - unsigned long OID[16]; - /** Number of OID digits in use */ - unsigned long OIDlen; -} oid_st; - -int pk_get_oid(int pk, oid_st *st); -int pk_oid_str_to_num(const char *OID, unsigned long *oid, unsigned long *oidlen); -int pk_oid_num_to_str(const unsigned long *oid, unsigned long oidlen, char *OID, unsigned long *outlen); -#endif /* LTC_SOURCE */ - /* ---- RSA ---- */ #ifdef LTC_MRSA @@ -149,61 +126,6 @@ int rsa_set_crt_params(const unsigned char *dP, unsigned long dPlen, rsa_key *key); #endif -/* ---- Katja ---- */ -#ifdef LTC_MKAT - -/* Min and Max KAT key sizes (in bits) */ -#define MIN_KAT_SIZE 1024 -#define MAX_KAT_SIZE 4096 - -/** Katja PKCS style key */ -typedef struct KAT_key { - /** Type of key, PK_PRIVATE or PK_PUBLIC */ - int type; - /** The private exponent */ - void *d; - /** The modulus */ - void *N; - /** The p factor of N */ - void *p; - /** The q factor of N */ - void *q; - /** The 1/q mod p CRT param */ - void *qP; - /** The d mod (p - 1) CRT param */ - void *dP; - /** The d mod (q - 1) CRT param */ - void *dQ; - /** The pq param */ - void *pq; -} katja_key; - -int katja_make_key(prng_state *prng, int wprng, int size, katja_key *key); - -int katja_exptmod(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, int which, - katja_key *key); - -void katja_free(katja_key *key); - -/* These use PKCS #1 v2.0 padding */ -int katja_encrypt_key(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, - const unsigned char *lparam, unsigned long lparamlen, - prng_state *prng, int prng_idx, int hash_idx, katja_key *key); - -int katja_decrypt_key(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, - const unsigned char *lparam, unsigned long lparamlen, - int hash_idx, int *stat, - katja_key *key); - -/* PKCS #1 import/export */ -int katja_export(unsigned char *out, unsigned long *outlen, int type, katja_key *key); -int katja_import(const unsigned char *in, unsigned long inlen, katja_key *key); - -#endif - /* ---- DH Routines ---- */ #ifdef LTC_MDH @@ -235,19 +157,6 @@ int dh_shared_secret(const dh_key *private_key, const dh_key *public_key, void dh_free(dh_key *key); int dh_export_key(void *out, unsigned long *outlen, int type, const dh_key *key); - -#ifdef LTC_SOURCE -typedef struct { - int size; - const char *name, *base, *prime; -} ltc_dh_set_type; - -extern const ltc_dh_set_type ltc_dh_sets[]; - -/* internal helper functions */ -int dh_check_pubkey(const dh_key *key); -#endif - #endif /* LTC_MDH */ @@ -347,6 +256,7 @@ int ecc_set_dp(const ltc_ecc_curve *cu, ecc_key *key); int ecc_generate_key(prng_state *prng, int wprng, ecc_key *key); int ecc_set_key(const unsigned char *in, unsigned long inlen, int type, ecc_key *key); int ecc_get_key(unsigned char *out, unsigned long *outlen, int type, const ecc_key *key); +int ecc_get_oid_str(char *out, unsigned long *outlen, const ecc_key *key); int ecc_make_key(prng_state *prng, int wprng, int keysize, ecc_key *key); int ecc_make_key_ex(prng_state *prng, int wprng, ecc_key *key, const ltc_ecc_curve *cu); @@ -393,76 +303,6 @@ int ecc_verify_hash(const unsigned char *sig, unsigned long siglen, const unsigned char *hash, unsigned long hashlen, int *stat, const ecc_key *key); - -#ifdef LTC_SOURCE -/* INTERNAL ONLY - it should be later moved to src/headers/tomcrypt_internal.h */ - -int ecc_set_dp_from_mpis(void *a, void *b, void *prime, void *order, void *gx, void *gy, unsigned long cofactor, ecc_key *key); -int ecc_copy_dp(const ecc_key *srckey, ecc_key *key); -int ecc_set_dp_by_size(int size, ecc_key *key); - -/* low level functions */ -ecc_point *ltc_ecc_new_point(void); -void ltc_ecc_del_point(ecc_point *p); -int ltc_ecc_set_point_xyz(ltc_mp_digit x, ltc_mp_digit y, ltc_mp_digit z, ecc_point *p); -int ltc_ecc_copy_point(const ecc_point *src, ecc_point *dst); -int ltc_ecc_is_point(const ltc_ecc_dp *dp, void *x, void *y); -int ltc_ecc_is_point_at_infinity(const ecc_point *P, void *modulus, int *retval); -int ltc_ecc_import_point(const unsigned char *in, unsigned long inlen, void *prime, void *a, void *b, void *x, void *y); -int ltc_ecc_export_point(unsigned char *out, unsigned long *outlen, void *x, void *y, unsigned long size, int compressed); -int ltc_ecc_verify_key(const ecc_key *key); - -/* point ops (mp == montgomery digit) */ -#if !defined(LTC_MECC_ACCEL) || defined(LTM_DESC) || defined(GMP_DESC) -/* R = 2P */ -int ltc_ecc_projective_dbl_point(const ecc_point *P, ecc_point *R, void *ma, void *modulus, void *mp); - -/* R = P + Q */ -int ltc_ecc_projective_add_point(const ecc_point *P, const ecc_point *Q, ecc_point *R, void *ma, void *modulus, void *mp); -#endif - -#if defined(LTC_MECC_FP) -/* optimized point multiplication using fixed point cache (HAC algorithm 14.117) */ -int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *a, void *modulus, int map); - -/* functions for saving/loading/freeing/adding to fixed point cache */ -int ltc_ecc_fp_save_state(unsigned char **out, unsigned long *outlen); -int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen); -void ltc_ecc_fp_free(void); -int ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock); - -/* lock/unlock all points currently in fixed point cache */ -void ltc_ecc_fp_tablelock(int lock); -#endif - -/* R = kG */ -int ltc_ecc_mulmod(void *k, const ecc_point *G, ecc_point *R, void *a, void *modulus, int map); - -#ifdef LTC_ECC_SHAMIR -/* kA*A + kB*B = C */ -int ltc_ecc_mul2add(const ecc_point *A, void *kA, - const ecc_point *B, void *kB, - ecc_point *C, - void *ma, - void *modulus); - -#ifdef LTC_MECC_FP -/* Shamir's trick with optimized point multiplication using fixed point cache */ -int ltc_ecc_fp_mul2add(const ecc_point *A, void *kA, - const ecc_point *B, void *kB, - ecc_point *C, - void *ma, - void *modulus); -#endif - -#endif - - -/* map P to affine from projective */ -int ltc_ecc_map(ecc_point *P, void *modulus, void *mp); - -#endif /* LTC_SOURCE */ - #endif #ifdef LTC_MDSA @@ -539,16 +379,10 @@ int dsa_decrypt_key(const unsigned char *in, unsigned long inlen, int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key); int dsa_export(unsigned char *out, unsigned long *outlen, int type, const dsa_key *key); int dsa_verify_key(const dsa_key *key, int *stat); -#ifdef LTC_SOURCE -/* internal helper functions */ -int dsa_int_validate_xy(const dsa_key *key, int *stat); -int dsa_int_validate_pqg(const dsa_key *key, int *stat); -int dsa_int_validate_primes(const dsa_key *key, int *stat); -#endif int dsa_shared_secret(void *private_key, void *base, const dsa_key *public_key, unsigned char *out, unsigned long *outlen); -#endif +#endif /* LTC_MDSA */ #ifdef LTC_DER /* DER handling */ @@ -711,30 +545,6 @@ int der_length_custom_type(const ltc_asn1_list *root, unsigned long *outlen, unsigned long *payloadlen); -#ifdef LTC_SOURCE -/* internal helper functions */ -int der_decode_custom_type_ex(const unsigned char *in, unsigned long inlen, - ltc_asn1_list *root, - ltc_asn1_list *list, unsigned long outlen, unsigned int flags); - -int der_encode_asn1_identifier(const ltc_asn1_list *id, unsigned char *out, unsigned long *outlen); -int der_decode_asn1_identifier(const unsigned char *in, unsigned long *inlen, ltc_asn1_list *id); -int der_length_asn1_identifier(const ltc_asn1_list *id, unsigned long *idlen); - -int der_encode_asn1_length(unsigned long len, unsigned char* out, unsigned long* outlen); -int der_decode_asn1_length(const unsigned char* len, unsigned long* lenlen, unsigned long* outlen); -int der_length_asn1_length(unsigned long len, unsigned long *outlen); - -int der_length_sequence_ex(const ltc_asn1_list *list, unsigned long inlen, - unsigned long *outlen, unsigned long *payloadlen); - -extern const ltc_asn1_type der_asn1_tag_to_type_map[]; -extern const unsigned long der_asn1_tag_to_type_map_sz; - -extern const int der_asn1_type_to_identifier_map[]; -extern const unsigned long der_asn1_type_to_identifier_map_sz; -#endif /* LTC_SOURCE */ - /* SET */ #define der_decode_set(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, LTC_DER_SEQ_SET) #define der_length_set der_length_sequence @@ -747,10 +557,6 @@ int der_encode_setof(const ltc_asn1_list *list, unsigned long inlen, /* VA list handy helpers with triplets of <type, size, data> */ int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...); int der_decode_sequence_multi(const unsigned char *in, unsigned long inlen, ...); -#ifdef LTC_SOURCE -/* internal helper functions */ -int der_decode_sequence_multi_ex(const unsigned char *in, unsigned long inlen, unsigned int flags, ...); -#endif /* LTC_SOURCE */ /* FLEXI DECODER handle unknown list decoder */ int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc_asn1_list **out); @@ -815,13 +621,6 @@ int der_decode_teletex_string(const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen); int der_length_teletex_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen); -#ifdef LTC_SOURCE -/* internal helper functions */ -int der_teletex_char_encode(int c); -int der_teletex_value_decode(int v); -#endif /* LTC_SOURCE */ - - /* PRINTABLE STRING */ int der_encode_printable_string(const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen); @@ -834,16 +633,16 @@ int der_printable_value_decode(int v); /* UTF-8 */ #if (defined(SIZE_MAX) || __STDC_VERSION__ >= 199901L || defined(WCHAR_MAX) || defined(__WCHAR_MAX__) || defined(_WCHAR_T) || defined(_WCHAR_T_DEFINED) || defined (__WCHAR_TYPE__)) && !defined(LTC_NO_WCHAR) -#include <wchar.h> -#if defined(__WCHAR_MAX__) -#define LTC_WCHAR_MAX __WCHAR_MAX__ -#elif defined(WCHAR_MAX) -#define LTC_WCHAR_MAX WCHAR_MAX -#endif + #if defined(__WCHAR_MAX__) + #define LTC_WCHAR_MAX __WCHAR_MAX__ + #else + #include <wchar.h> + #define LTC_WCHAR_MAX WCHAR_MAX + #endif /* please note that it might happen that LTC_WCHAR_MAX is undefined */ #else -typedef ulong32 wchar_t; -#define LTC_WCHAR_MAX 0xFFFFFFFF + typedef ulong32 wchar_t; + #define LTC_WCHAR_MAX 0xFFFFFFFF #endif int der_encode_utf8_string(const wchar_t *in, unsigned long inlen, @@ -852,10 +651,6 @@ int der_encode_utf8_string(const wchar_t *in, unsigned long inlen, int der_decode_utf8_string(const unsigned char *in, unsigned long inlen, wchar_t *out, unsigned long *outlen); unsigned long der_utf8_charsize(const wchar_t c); -#ifdef LTC_SOURCE -/* internal helper functions */ -int der_utf8_valid_char(const wchar_t c); -#endif /* LTC_SOURCE */ int der_length_utf8_string(const wchar_t *in, unsigned long noctets, unsigned long *outlen); @@ -906,18 +701,6 @@ int der_decode_generalizedtime(const unsigned char *in, unsigned long *inlen, int der_length_generalizedtime(const ltc_generalizedtime *gtime, unsigned long *outlen); -#ifdef LTC_SOURCE -/* internal helper functions */ -/* SUBJECT PUBLIC KEY INFO */ -int x509_encode_subject_public_key_info(unsigned char *out, unsigned long *outlen, - unsigned int algorithm, const void* public_key, unsigned long public_key_len, - ltc_asn1_type parameters_type, ltc_asn1_list* parameters, unsigned long parameters_len); - -int x509_decode_subject_public_key_info(const unsigned char *in, unsigned long inlen, - unsigned int algorithm, void* public_key, unsigned long* public_key_len, - ltc_asn1_type parameters_type, ltc_asn1_list* parameters, unsigned long *parameters_len); -#endif /* LTC_SOURCE */ - #endif /* ref: $Format:%D$ */ diff --git a/src/ltc/headers/tomcrypt_private.h b/src/ltc/headers/tomcrypt_private.h new file mode 100644 index 00000000..865b7ad2 --- /dev/null +++ b/src/ltc/headers/tomcrypt_private.h @@ -0,0 +1,334 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + */ + +#include "tomcrypt.h" + +/* + * Internal Macros + */ + +#define LTC_PAD_MASK (0xF000U) + +/* + * Internal Enums + */ + +enum public_key_algorithms { + PKA_RSA, + PKA_DSA, + PKA_EC, + PKA_EC_PRIMEF +}; + +/* + * Internal Types + */ + +typedef struct Oid { + unsigned long OID[16]; + /** Number of OID digits in use */ + unsigned long OIDlen; +} oid_st; + +typedef struct { + int size; + const char *name, *base, *prime; +} ltc_dh_set_type; + + +/* + * Internal functions + */ + +/* tomcrypt_hash.h */ + +/* a simple macro for making hash "process" functions */ +#define HASH_PROCESS(func_name, compress_name, state_var, block_size) \ +int func_name (hash_state * md, const unsigned char *in, unsigned long inlen) \ +{ \ + unsigned long n; \ + int err; \ + LTC_ARGCHK(md != NULL); \ + LTC_ARGCHK(in != NULL); \ + if (md-> state_var .curlen > sizeof(md-> state_var .buf)) { \ + return CRYPT_INVALID_ARG; \ + } \ + if ((md-> state_var .length + inlen) < md-> state_var .length) { \ + return CRYPT_HASH_OVERFLOW; \ + } \ + while (inlen > 0) { \ + if (md-> state_var .curlen == 0 && inlen >= block_size) { \ + if ((err = compress_name (md, in)) != CRYPT_OK) { \ + return err; \ + } \ + md-> state_var .length += block_size * 8; \ + in += block_size; \ + inlen -= block_size; \ + } else { \ + n = MIN(inlen, (block_size - md-> state_var .curlen)); \ + XMEMCPY(md-> state_var .buf + md-> state_var.curlen, in, (size_t)n); \ + md-> state_var .curlen += n; \ + in += n; \ + inlen -= n; \ + if (md-> state_var .curlen == block_size) { \ + if ((err = compress_name (md, md-> state_var .buf)) != CRYPT_OK) { \ + return err; \ + } \ + md-> state_var .length += 8*block_size; \ + md-> state_var .curlen = 0; \ + } \ + } \ + } \ + return CRYPT_OK; \ +} + + +/* tomcrypt_mac.h */ + +int ocb3_int_ntz(unsigned long x); +void ocb3_int_xor_blocks(unsigned char *out, const unsigned char *block_a, const unsigned char *block_b, unsigned long block_len); + + +/* tomcrypt_math.h */ + +#if !defined(DESC_DEF_ONLY) + +#define MP_DIGIT_BIT ltc_mp.bits_per_digit + +/* some handy macros */ +#define mp_init(a) ltc_mp.init(a) +#define mp_init_multi ltc_init_multi +#define mp_clear(a) ltc_mp.deinit(a) +#define mp_clear_multi ltc_deinit_multi +#define mp_cleanup_multi ltc_cleanup_multi +#define mp_init_copy(a, b) ltc_mp.init_copy(a, b) + +#define mp_neg(a, b) ltc_mp.neg(a, b) +#define mp_copy(a, b) ltc_mp.copy(a, b) + +#define mp_set(a, b) ltc_mp.set_int(a, b) +#define mp_set_int(a, b) ltc_mp.set_int(a, b) +#define mp_get_int(a) ltc_mp.get_int(a) +#define mp_get_digit(a, n) ltc_mp.get_digit(a, n) +#define mp_get_digit_count(a) ltc_mp.get_digit_count(a) +#define mp_cmp(a, b) ltc_mp.compare(a, b) +#define mp_cmp_d(a, b) ltc_mp.compare_d(a, b) +#define mp_count_bits(a) ltc_mp.count_bits(a) +#define mp_cnt_lsb(a) ltc_mp.count_lsb_bits(a) +#define mp_2expt(a, b) ltc_mp.twoexpt(a, b) + +#define mp_read_radix(a, b, c) ltc_mp.read_radix(a, b, c) +#define mp_toradix(a, b, c) ltc_mp.write_radix(a, b, c) +#define mp_unsigned_bin_size(a) ltc_mp.unsigned_size(a) +#define mp_to_unsigned_bin(a, b) ltc_mp.unsigned_write(a, b) +#define mp_read_unsigned_bin(a, b, c) ltc_mp.unsigned_read(a, b, c) + +#define mp_add(a, b, c) ltc_mp.add(a, b, c) +#define mp_add_d(a, b, c) ltc_mp.addi(a, b, c) +#define mp_sub(a, b, c) ltc_mp.sub(a, b, c) +#define mp_sub_d(a, b, c) ltc_mp.subi(a, b, c) +#define mp_mul(a, b, c) ltc_mp.mul(a, b, c) +#define mp_mul_d(a, b, c) ltc_mp.muli(a, b, c) +#define mp_sqr(a, b) ltc_mp.sqr(a, b) +#define mp_sqrtmod_prime(a, b, c) ltc_mp.sqrtmod_prime(a, b, c) +#define mp_div(a, b, c, d) ltc_mp.mpdiv(a, b, c, d) +#define mp_div_2(a, b) ltc_mp.div_2(a, b) +#define mp_mod(a, b, c) ltc_mp.mpdiv(a, b, NULL, c) +#define mp_mod_d(a, b, c) ltc_mp.modi(a, b, c) +#define mp_gcd(a, b, c) ltc_mp.gcd(a, b, c) +#define mp_lcm(a, b, c) ltc_mp.lcm(a, b, c) + +#define mp_addmod(a, b, c, d) ltc_mp.addmod(a, b, c, d) +#define mp_submod(a, b, c, d) ltc_mp.submod(a, b, c, d) +#define mp_mulmod(a, b, c, d) ltc_mp.mulmod(a, b, c, d) +#define mp_sqrmod(a, b, c) ltc_mp.sqrmod(a, b, c) +#define mp_invmod(a, b, c) ltc_mp.invmod(a, b, c) + +#define mp_montgomery_setup(a, b) ltc_mp.montgomery_setup(a, b) +#define mp_montgomery_normalization(a, b) ltc_mp.montgomery_normalization(a, b) +#define mp_montgomery_reduce(a, b, c) ltc_mp.montgomery_reduce(a, b, c) +#define mp_montgomery_free(a) ltc_mp.montgomery_deinit(a) + +#define mp_exptmod(a,b,c,d) ltc_mp.exptmod(a,b,c,d) +#define mp_prime_is_prime(a, b, c) ltc_mp.isprime(a, b, c) + +#define mp_iszero(a) (mp_cmp_d(a, 0) == LTC_MP_EQ ? LTC_MP_YES : LTC_MP_NO) +#define mp_isodd(a) (mp_get_digit_count(a) > 0 ? (mp_get_digit(a, 0) & 1 ? LTC_MP_YES : LTC_MP_NO) : LTC_MP_NO) +#define mp_exch(a, b) do { void *ABC__tmp = a; a = b; b = ABC__tmp; } while(0) + +#define mp_tohex(a, b) mp_toradix(a, b, 16) + +#define mp_rand(a, b) ltc_mp.rand(a, b) + +#endif + + +/* tomcrypt_misc.h */ + +void copy_or_zeromem(const unsigned char* src, unsigned char* dest, unsigned long len, int coz); + + +/* tomcrypt_pk.h */ + +int rand_bn_bits(void *N, int bits, prng_state *prng, int wprng); +int rand_bn_upto(void *N, void *limit, prng_state *prng, int wprng); + +int pk_get_oid(int pk, oid_st *st); +int pk_oid_str_to_num(const char *OID, unsigned long *oid, unsigned long *oidlen); +int pk_oid_num_to_str(const unsigned long *oid, unsigned long oidlen, char *OID, unsigned long *outlen); + +/* ---- DH Routines ---- */ +#ifdef LTC_MDH +extern const ltc_dh_set_type ltc_dh_sets[]; + +int dh_check_pubkey(const dh_key *key); +#endif /* LTC_MDH */ + +/* ---- ECC Routines ---- */ +#ifdef LTC_MECC +int ecc_set_dp_from_mpis(void *a, void *b, void *prime, void *order, void *gx, void *gy, unsigned long cofactor, ecc_key *key); +int ecc_copy_dp(const ecc_key *srckey, ecc_key *key); +int ecc_set_dp_by_size(int size, ecc_key *key); + +/* low level functions */ +ecc_point *ltc_ecc_new_point(void); +void ltc_ecc_del_point(ecc_point *p); +int ltc_ecc_set_point_xyz(ltc_mp_digit x, ltc_mp_digit y, ltc_mp_digit z, ecc_point *p); +int ltc_ecc_copy_point(const ecc_point *src, ecc_point *dst); +int ltc_ecc_is_point(const ltc_ecc_dp *dp, void *x, void *y); +int ltc_ecc_is_point_at_infinity(const ecc_point *P, void *modulus, int *retval); +int ltc_ecc_import_point(const unsigned char *in, unsigned long inlen, void *prime, void *a, void *b, void *x, void *y); +int ltc_ecc_export_point(unsigned char *out, unsigned long *outlen, void *x, void *y, unsigned long size, int compressed); +int ltc_ecc_verify_key(const ecc_key *key); + +/* point ops (mp == montgomery digit) */ +#if !defined(LTC_MECC_ACCEL) || defined(LTM_DESC) || defined(GMP_DESC) +/* R = 2P */ +int ltc_ecc_projective_dbl_point(const ecc_point *P, ecc_point *R, void *ma, void *modulus, void *mp); + +/* R = P + Q */ +int ltc_ecc_projective_add_point(const ecc_point *P, const ecc_point *Q, ecc_point *R, void *ma, void *modulus, void *mp); +#endif + +#if defined(LTC_MECC_FP) +/* optimized point multiplication using fixed point cache (HAC algorithm 14.117) */ +int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *a, void *modulus, int map); + +/* functions for saving/loading/freeing/adding to fixed point cache */ +int ltc_ecc_fp_save_state(unsigned char **out, unsigned long *outlen); +int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen); +void ltc_ecc_fp_free(void); +int ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock); + +/* lock/unlock all points currently in fixed point cache */ +void ltc_ecc_fp_tablelock(int lock); +#endif + +/* R = kG */ +int ltc_ecc_mulmod(void *k, const ecc_point *G, ecc_point *R, void *a, void *modulus, int map); + +#ifdef LTC_ECC_SHAMIR +/* kA*A + kB*B = C */ +int ltc_ecc_mul2add(const ecc_point *A, void *kA, + const ecc_point *B, void *kB, + ecc_point *C, + void *ma, + void *modulus); + +#ifdef LTC_MECC_FP +/* Shamir's trick with optimized point multiplication using fixed point cache */ +int ltc_ecc_fp_mul2add(const ecc_point *A, void *kA, + const ecc_point *B, void *kB, + ecc_point *C, + void *ma, + void *modulus); +#endif + +#endif + + +/* map P to affine from projective */ +int ltc_ecc_map(ecc_point *P, void *modulus, void *mp); +#endif /* LTC_MECC */ + +#ifdef LTC_MDSA +int dsa_int_validate_xy(const dsa_key *key, int *stat); +int dsa_int_validate_pqg(const dsa_key *key, int *stat); +int dsa_int_validate_primes(const dsa_key *key, int *stat); +#endif /* LTC_MDSA */ + +#ifdef LTC_DER +/* DER handling */ +int der_decode_custom_type_ex(const unsigned char *in, unsigned long inlen, + ltc_asn1_list *root, + ltc_asn1_list *list, unsigned long outlen, unsigned int flags); + +int der_encode_asn1_identifier(const ltc_asn1_list *id, unsigned char *out, unsigned long *outlen); +int der_decode_asn1_identifier(const unsigned char *in, unsigned long *inlen, ltc_asn1_list *id); +int der_length_asn1_identifier(const ltc_asn1_list *id, unsigned long *idlen); + +int der_encode_asn1_length(unsigned long len, unsigned char* out, unsigned long* outlen); +int der_decode_asn1_length(const unsigned char* len, unsigned long* lenlen, unsigned long* outlen); +int der_length_asn1_length(unsigned long len, unsigned long *outlen); + +int der_length_sequence_ex(const ltc_asn1_list *list, unsigned long inlen, + unsigned long *outlen, unsigned long *payloadlen); + +extern const ltc_asn1_type der_asn1_tag_to_type_map[]; +extern const unsigned long der_asn1_tag_to_type_map_sz; + +extern const int der_asn1_type_to_identifier_map[]; +extern const unsigned long der_asn1_type_to_identifier_map_sz; + +int der_decode_sequence_multi_ex(const unsigned char *in, unsigned long inlen, unsigned int flags, ...); + +int der_teletex_char_encode(int c); +int der_teletex_value_decode(int v); + +int der_utf8_valid_char(const wchar_t c); + +/* SUBJECT PUBLIC KEY INFO */ +int x509_encode_subject_public_key_info(unsigned char *out, unsigned long *outlen, + unsigned int algorithm, const void* public_key, unsigned long public_key_len, + ltc_asn1_type parameters_type, ltc_asn1_list* parameters, unsigned long parameters_len); + +int x509_decode_subject_public_key_info(const unsigned char *in, unsigned long inlen, + unsigned int algorithm, void* public_key, unsigned long* public_key_len, + ltc_asn1_type parameters_type, ltc_asn1_list* parameters, unsigned long *parameters_len); + +#endif /* LTC_DER */ + +/* tomcrypt_prng.h */ + +#define _LTC_PRNG_EXPORT(which) \ +int which ## _export(unsigned char *out, unsigned long *outlen, prng_state *prng) \ +{ \ + unsigned long len = which ## _desc.export_size; \ + \ + LTC_ARGCHK(prng != NULL); \ + LTC_ARGCHK(out != NULL); \ + LTC_ARGCHK(outlen != NULL); \ + \ + if (*outlen < len) { \ + *outlen = len; \ + return CRYPT_BUFFER_OVERFLOW; \ + } \ + \ + if (which ## _read(out, len, prng) != len) { \ + return CRYPT_ERROR_READPRNG; \ + } \ + \ + *outlen = len; \ + return CRYPT_OK; \ +} + + +/* ref: $Format:%D$ */ +/* git commit: $Format:%H$ */ +/* commit time: $Format:%ai$ */ diff --git a/src/ltc/headers/tomcrypt_prng.h b/src/ltc/headers/tomcrypt_prng.h index 541f68e5..8525313d 100644 --- a/src/ltc/headers/tomcrypt_prng.h +++ b/src/ltc/headers/tomcrypt_prng.h @@ -13,16 +13,12 @@ struct yarrow_prng { int cipher, hash; unsigned char pool[MAXBLOCKSIZE]; symmetric_CTR ctr; - short ready; /* ready flag 0-1 */ - LTC_MUTEX_TYPE(lock) /* lock */ }; #endif #ifdef LTC_RC4 struct rc4_prng { rc4_state s; - short ready; /* ready flag 0-1 */ - LTC_MUTEX_TYPE(lock) /* lock */ }; #endif @@ -31,8 +27,6 @@ struct chacha20_prng { chacha_state s; /* chacha state */ unsigned char ent[40]; /* entropy buffer */ unsigned long idx; /* entropy counter */ - short ready; /* ready flag 0-1 */ - LTC_MUTEX_TYPE(lock) /* lock */ }; #endif @@ -46,12 +40,9 @@ struct fortuna_prng { IV[16]; /* IV for CTR mode */ unsigned long pool_idx, /* current pool we will add to */ - pool0_len, /* length of 0'th pool */ - wd; - + pool0_len; /* length of 0'th pool */ + ulong64 wd; ulong64 reset_cnt; /* number of times we have reseeded */ - short ready; /* ready flag 0-1 */ - LTC_MUTEX_TYPE(lock) /* lock */ }; #endif @@ -60,28 +51,30 @@ struct sober128_prng { sober128_state s; /* sober128 state */ unsigned char ent[40]; /* entropy buffer */ unsigned long idx; /* entropy counter */ - short ready; /* ready flag 0-1 */ - LTC_MUTEX_TYPE(lock) /* lock */ }; #endif -typedef union Prng_state { - char dummy[1]; +typedef struct { + union { + char dummy[1]; #ifdef LTC_YARROW - struct yarrow_prng yarrow; + struct yarrow_prng yarrow; #endif #ifdef LTC_RC4 - struct rc4_prng rc4; + struct rc4_prng rc4; #endif #ifdef LTC_CHACHA20_PRNG - struct chacha20_prng chacha; + struct chacha20_prng chacha; #endif #ifdef LTC_FORTUNA - struct fortuna_prng fortuna; + struct fortuna_prng fortuna; #endif #ifdef LTC_SOBER128 - struct sober128_prng sober128; + struct sober128_prng sober128; #endif + } u; + short ready; /* ready flag 0-1 */ + LTC_MUTEX_TYPE(lock) /* lock */ } prng_state; /** PRNG descriptor */ @@ -220,31 +213,6 @@ int register_all_prngs(void); int prng_is_valid(int idx); LTC_MUTEX_PROTO(ltc_prng_mutex) -#ifdef LTC_SOURCE -/* internal helper functions */ -#define _LTC_PRNG_EXPORT(which) \ -int which ## _export(unsigned char *out, unsigned long *outlen, prng_state *prng) \ -{ \ - unsigned long len = which ## _desc.export_size; \ - \ - LTC_ARGCHK(prng != NULL); \ - LTC_ARGCHK(out != NULL); \ - LTC_ARGCHK(outlen != NULL); \ - \ - if (*outlen < len) { \ - *outlen = len; \ - return CRYPT_BUFFER_OVERFLOW; \ - } \ - \ - if (which ## _read(out, len, prng) != len) { \ - return CRYPT_ERROR_READPRNG; \ - } \ - \ - *outlen = len; \ - return CRYPT_OK; \ -} -#endif - /* Slow RNG you **might** be able to use to seed a PRNG with. Be careful as this * might not work on all platforms as planned */ diff --git a/src/ltc/mac/blake2/blake2bmac.c b/src/ltc/mac/blake2/blake2bmac.c index 1c80b1c0..fc20cd99 100644 --- a/src/ltc/mac/blake2/blake2bmac.c +++ b/src/ltc/mac/blake2/blake2bmac.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_BLAKE2BMAC diff --git a/src/ltc/mac/blake2/blake2bmac_file.c b/src/ltc/mac/blake2/blake2bmac_file.c index c1e9c6b5..6d436a67 100644 --- a/src/ltc/mac/blake2/blake2bmac_file.c +++ b/src/ltc/mac/blake2/blake2bmac_file.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_BLAKE2BMAC diff --git a/src/ltc/mac/blake2/blake2bmac_memory.c b/src/ltc/mac/blake2/blake2bmac_memory.c index 45ddd6fb..c0a09b72 100644 --- a/src/ltc/mac/blake2/blake2bmac_memory.c +++ b/src/ltc/mac/blake2/blake2bmac_memory.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_BLAKE2BMAC diff --git a/src/ltc/mac/blake2/blake2bmac_memory_multi.c b/src/ltc/mac/blake2/blake2bmac_memory_multi.c index 2b875d7f..e135f6fe 100644 --- a/src/ltc/mac/blake2/blake2bmac_memory_multi.c +++ b/src/ltc/mac/blake2/blake2bmac_memory_multi.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #include <stdarg.h> #ifdef LTC_BLAKE2BMAC diff --git a/src/ltc/mac/blake2/blake2smac.c b/src/ltc/mac/blake2/blake2smac.c index 080241b7..77ef17dd 100644 --- a/src/ltc/mac/blake2/blake2smac.c +++ b/src/ltc/mac/blake2/blake2smac.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_BLAKE2SMAC diff --git a/src/ltc/mac/blake2/blake2smac_file.c b/src/ltc/mac/blake2/blake2smac_file.c index 1ac66797..9d31a18d 100644 --- a/src/ltc/mac/blake2/blake2smac_file.c +++ b/src/ltc/mac/blake2/blake2smac_file.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_BLAKE2SMAC diff --git a/src/ltc/mac/blake2/blake2smac_memory.c b/src/ltc/mac/blake2/blake2smac_memory.c index 1661fb06..487a810b 100644 --- a/src/ltc/mac/blake2/blake2smac_memory.c +++ b/src/ltc/mac/blake2/blake2smac_memory.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_BLAKE2SMAC diff --git a/src/ltc/mac/blake2/blake2smac_memory_multi.c b/src/ltc/mac/blake2/blake2smac_memory_multi.c index 0985c428..2e96c757 100644 --- a/src/ltc/mac/blake2/blake2smac_memory_multi.c +++ b/src/ltc/mac/blake2/blake2smac_memory_multi.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #include <stdarg.h> #ifdef LTC_BLAKE2SMAC diff --git a/src/ltc/mac/f9/f9_done.c b/src/ltc/mac/f9/f9_done.c index 8d2ccb05..b43daa81 100644 --- a/src/ltc/mac/f9/f9_done.c +++ b/src/ltc/mac/f9/f9_done.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file f9_done.c diff --git a/src/ltc/mac/f9/f9_file.c b/src/ltc/mac/f9/f9_file.c index 04d509bf..f9969bb1 100644 --- a/src/ltc/mac/f9/f9_file.c +++ b/src/ltc/mac/f9/f9_file.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file f9_file.c diff --git a/src/ltc/mac/f9/f9_init.c b/src/ltc/mac/f9/f9_init.c index ba59b20e..cc416561 100644 --- a/src/ltc/mac/f9/f9_init.c +++ b/src/ltc/mac/f9/f9_init.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file f9_init.c diff --git a/src/ltc/mac/f9/f9_memory.c b/src/ltc/mac/f9/f9_memory.c index 70c694b3..16d40ef1 100644 --- a/src/ltc/mac/f9/f9_memory.c +++ b/src/ltc/mac/f9/f9_memory.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file f9_process.c diff --git a/src/ltc/mac/f9/f9_memory_multi.c b/src/ltc/mac/f9/f9_memory_multi.c index 2c1d31a0..580980c4 100644 --- a/src/ltc/mac/f9/f9_memory_multi.c +++ b/src/ltc/mac/f9/f9_memory_multi.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #include <stdarg.h> /** diff --git a/src/ltc/mac/f9/f9_process.c b/src/ltc/mac/f9/f9_process.c index ba4d39ff..b945ef42 100644 --- a/src/ltc/mac/f9/f9_process.c +++ b/src/ltc/mac/f9/f9_process.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file f9_process.c diff --git a/src/ltc/mac/hmac/hmac_done.c b/src/ltc/mac/hmac/hmac_done.c index 3c09df16..58d3c490 100644 --- a/src/ltc/mac/hmac/hmac_done.c +++ b/src/ltc/mac/hmac/hmac_done.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file hmac_done.c diff --git a/src/ltc/mac/hmac/hmac_file.c b/src/ltc/mac/hmac/hmac_file.c index 0e1a1631..0ea680b6 100644 --- a/src/ltc/mac/hmac/hmac_file.c +++ b/src/ltc/mac/hmac/hmac_file.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file hmac_file.c diff --git a/src/ltc/mac/hmac/hmac_init.c b/src/ltc/mac/hmac/hmac_init.c index 16e58d5b..fadc839e 100644 --- a/src/ltc/mac/hmac/hmac_init.c +++ b/src/ltc/mac/hmac/hmac_init.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file hmac_init.c diff --git a/src/ltc/mac/hmac/hmac_memory.c b/src/ltc/mac/hmac/hmac_memory.c index 9a3a199b..e4bfa87f 100644 --- a/src/ltc/mac/hmac/hmac_memory.c +++ b/src/ltc/mac/hmac/hmac_memory.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file hmac_memory.c diff --git a/src/ltc/mac/hmac/hmac_memory_multi.c b/src/ltc/mac/hmac/hmac_memory_multi.c index 6e3d0fef..8e3e401d 100644 --- a/src/ltc/mac/hmac/hmac_memory_multi.c +++ b/src/ltc/mac/hmac/hmac_memory_multi.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #include <stdarg.h> /** diff --git a/src/ltc/mac/hmac/hmac_process.c b/src/ltc/mac/hmac/hmac_process.c index 8da62c13..a8714dee 100644 --- a/src/ltc/mac/hmac/hmac_process.c +++ b/src/ltc/mac/hmac/hmac_process.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file hmac_process.c diff --git a/src/ltc/mac/omac/omac_done.c b/src/ltc/mac/omac/omac_done.c index bf22523f..338a4cce 100644 --- a/src/ltc/mac/omac/omac_done.c +++ b/src/ltc/mac/omac/omac_done.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file omac_done.c diff --git a/src/ltc/mac/omac/omac_file.c b/src/ltc/mac/omac/omac_file.c index 3f6a85d0..11cc1b1b 100644 --- a/src/ltc/mac/omac/omac_file.c +++ b/src/ltc/mac/omac/omac_file.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file omac_file.c diff --git a/src/ltc/mac/omac/omac_init.c b/src/ltc/mac/omac/omac_init.c index 55de2a61..70caee67 100644 --- a/src/ltc/mac/omac/omac_init.c +++ b/src/ltc/mac/omac/omac_init.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file omac_init.c diff --git a/src/ltc/mac/omac/omac_memory.c b/src/ltc/mac/omac/omac_memory.c index 1b57db85..5bbc95f5 100644 --- a/src/ltc/mac/omac/omac_memory.c +++ b/src/ltc/mac/omac/omac_memory.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file omac_memory.c diff --git a/src/ltc/mac/omac/omac_memory_multi.c b/src/ltc/mac/omac/omac_memory_multi.c index 50f26e6a..c0922d6d 100644 --- a/src/ltc/mac/omac/omac_memory_multi.c +++ b/src/ltc/mac/omac/omac_memory_multi.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #include <stdarg.h> /** diff --git a/src/ltc/mac/omac/omac_process.c b/src/ltc/mac/omac/omac_process.c index 4ae2bd11..2024d3e6 100644 --- a/src/ltc/mac/omac/omac_process.c +++ b/src/ltc/mac/omac/omac_process.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file omac_process.c diff --git a/src/ltc/mac/pelican/pelican.c b/src/ltc/mac/pelican/pelican.c index 6a4dde64..e8cea642 100644 --- a/src/ltc/mac/pelican/pelican.c +++ b/src/ltc/mac/pelican/pelican.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pelican.c diff --git a/src/ltc/mac/pelican/pelican_memory.c b/src/ltc/mac/pelican/pelican_memory.c index 08607a0d..11ba07cc 100644 --- a/src/ltc/mac/pelican/pelican_memory.c +++ b/src/ltc/mac/pelican/pelican_memory.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pelican_memory.c diff --git a/src/ltc/mac/pmac/pmac_done.c b/src/ltc/mac/pmac/pmac_done.c index de7a5aa0..18296e02 100644 --- a/src/ltc/mac/pmac/pmac_done.c +++ b/src/ltc/mac/pmac/pmac_done.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pmac_done.c diff --git a/src/ltc/mac/pmac/pmac_file.c b/src/ltc/mac/pmac/pmac_file.c index fe202a2f..bdd7b825 100644 --- a/src/ltc/mac/pmac/pmac_file.c +++ b/src/ltc/mac/pmac/pmac_file.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pmac_file.c diff --git a/src/ltc/mac/pmac/pmac_init.c b/src/ltc/mac/pmac/pmac_init.c index b1bb400d..15d433af 100644 --- a/src/ltc/mac/pmac/pmac_init.c +++ b/src/ltc/mac/pmac/pmac_init.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pmac_init.c diff --git a/src/ltc/mac/pmac/pmac_memory.c b/src/ltc/mac/pmac/pmac_memory.c index 78427811..77223d95 100644 --- a/src/ltc/mac/pmac/pmac_memory.c +++ b/src/ltc/mac/pmac/pmac_memory.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pmac_memory.c diff --git a/src/ltc/mac/pmac/pmac_memory_multi.c b/src/ltc/mac/pmac/pmac_memory_multi.c index f3de4b59..19915a9e 100644 --- a/src/ltc/mac/pmac/pmac_memory_multi.c +++ b/src/ltc/mac/pmac/pmac_memory_multi.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #include <stdarg.h> /** diff --git a/src/ltc/mac/pmac/pmac_ntz.c b/src/ltc/mac/pmac/pmac_ntz.c index 2c7dec56..bb262f85 100644 --- a/src/ltc/mac/pmac/pmac_ntz.c +++ b/src/ltc/mac/pmac/pmac_ntz.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pmac_ntz.c diff --git a/src/ltc/mac/pmac/pmac_process.c b/src/ltc/mac/pmac/pmac_process.c index 018fa275..d12684b5 100644 --- a/src/ltc/mac/pmac/pmac_process.c +++ b/src/ltc/mac/pmac/pmac_process.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pmac_process.c diff --git a/src/ltc/mac/pmac/pmac_shift_xor.c b/src/ltc/mac/pmac/pmac_shift_xor.c index 49d48f98..8895d970 100644 --- a/src/ltc/mac/pmac/pmac_shift_xor.c +++ b/src/ltc/mac/pmac/pmac_shift_xor.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pmac_shift_xor.c diff --git a/src/ltc/mac/poly1305/poly1305.c b/src/ltc/mac/poly1305/poly1305.c index f709f720..1cd7a0ac 100644 --- a/src/ltc/mac/poly1305/poly1305.c +++ b/src/ltc/mac/poly1305/poly1305.c @@ -12,7 +12,7 @@ * https://github.com/floodyberry/poly1305-donna */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_POLY1305 diff --git a/src/ltc/mac/poly1305/poly1305_file.c b/src/ltc/mac/poly1305/poly1305_file.c index e57437b3..946d3997 100644 --- a/src/ltc/mac/poly1305/poly1305_file.c +++ b/src/ltc/mac/poly1305/poly1305_file.c @@ -12,7 +12,7 @@ * https://github.com/floodyberry/poly1305-donna */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_POLY1305 diff --git a/src/ltc/mac/poly1305/poly1305_memory.c b/src/ltc/mac/poly1305/poly1305_memory.c index a827f8d3..e9d2ff27 100644 --- a/src/ltc/mac/poly1305/poly1305_memory.c +++ b/src/ltc/mac/poly1305/poly1305_memory.c @@ -12,7 +12,7 @@ * https://github.com/floodyberry/poly1305-donna */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_POLY1305 diff --git a/src/ltc/mac/poly1305/poly1305_memory_multi.c b/src/ltc/mac/poly1305/poly1305_memory_multi.c index f22f2553..952bd6cf 100644 --- a/src/ltc/mac/poly1305/poly1305_memory_multi.c +++ b/src/ltc/mac/poly1305/poly1305_memory_multi.c @@ -12,7 +12,7 @@ * https://github.com/floodyberry/poly1305-donna */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #include <stdarg.h> #ifdef LTC_POLY1305 diff --git a/src/ltc/mac/xcbc/xcbc_done.c b/src/ltc/mac/xcbc/xcbc_done.c index 133d16fd..0ae96c10 100644 --- a/src/ltc/mac/xcbc/xcbc_done.c +++ b/src/ltc/mac/xcbc/xcbc_done.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file xcbc_done.c diff --git a/src/ltc/mac/xcbc/xcbc_file.c b/src/ltc/mac/xcbc/xcbc_file.c index 27eb0dec..bfd5d3e5 100644 --- a/src/ltc/mac/xcbc/xcbc_file.c +++ b/src/ltc/mac/xcbc/xcbc_file.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file xcbc_file.c diff --git a/src/ltc/mac/xcbc/xcbc_init.c b/src/ltc/mac/xcbc/xcbc_init.c index 4eccd5e4..0d80c27a 100644 --- a/src/ltc/mac/xcbc/xcbc_init.c +++ b/src/ltc/mac/xcbc/xcbc_init.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file xcbc_init.c diff --git a/src/ltc/mac/xcbc/xcbc_memory.c b/src/ltc/mac/xcbc/xcbc_memory.c index a1bc0455..65f558f0 100644 --- a/src/ltc/mac/xcbc/xcbc_memory.c +++ b/src/ltc/mac/xcbc/xcbc_memory.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file xcbc_process.c diff --git a/src/ltc/mac/xcbc/xcbc_memory_multi.c b/src/ltc/mac/xcbc/xcbc_memory_multi.c index a5b9d917..db1b8c4a 100644 --- a/src/ltc/mac/xcbc/xcbc_memory_multi.c +++ b/src/ltc/mac/xcbc/xcbc_memory_multi.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #include <stdarg.h> /** diff --git a/src/ltc/mac/xcbc/xcbc_process.c b/src/ltc/mac/xcbc/xcbc_process.c index 12e25c5f..1407a1c9 100644 --- a/src/ltc/mac/xcbc/xcbc_process.c +++ b/src/ltc/mac/xcbc/xcbc_process.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file xcbc_process.c diff --git a/src/ltc/math/fp/ltc_ecc_fp_mulmod.c b/src/ltc/math/fp/ltc_ecc_fp_mulmod.c index eed4483a..757488b4 100644 --- a/src/ltc/math/fp/ltc_ecc_fp_mulmod.c +++ b/src/ltc/math/fp/ltc_ecc_fp_mulmod.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ltc_ecc_fp_mulmod.c diff --git a/src/ltc/math/ltm_desc.c b/src/ltc/math/ltm_desc.c index 47496577..0ee7958d 100644 --- a/src/ltc/math/ltm_desc.c +++ b/src/ltc/math/ltm_desc.c @@ -8,7 +8,7 @@ */ #define DESC_DEF_ONLY -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTM_DESC diff --git a/src/ltc/math/multi.c b/src/ltc/math/multi.c index cfe14512..4b3178f8 100644 --- a/src/ltc/math/multi.c +++ b/src/ltc/math/multi.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MPI #include <stdarg.h> diff --git a/src/ltc/math/radix_to_bin.c b/src/ltc/math/radix_to_bin.c index 409bd20d..83eda819 100644 --- a/src/ltc/math/radix_to_bin.c +++ b/src/ltc/math/radix_to_bin.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file radix_to_bin.c diff --git a/src/ltc/math/rand_bn.c b/src/ltc/math/rand_bn.c index aa6539cc..9c87336d 100644 --- a/src/ltc/math/rand_bn.c +++ b/src/ltc/math/rand_bn.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #if defined(LTC_MDSA) || defined(LTC_MECC) /** diff --git a/src/ltc/math/rand_prime.c b/src/ltc/math/rand_prime.c index 4dd5764d..97c82c74 100644 --- a/src/ltc/math/rand_prime.c +++ b/src/ltc/math/rand_prime.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #if defined(LTC_MRSA) || (!defined(LTC_NO_MATH) && !defined(LTC_NO_PRNGS)) diff --git a/src/ltc/math/tfm_desc.c b/src/ltc/math/tfm_desc.c index 81f14b80..e42d2469 100644 --- a/src/ltc/math/tfm_desc.c +++ b/src/ltc/math/tfm_desc.c @@ -8,7 +8,7 @@ */ #define DESC_DEF_ONLY -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef TFM_DESC diff --git a/src/ltc/misc/adler32.c b/src/ltc/misc/adler32.c index 49ce7d70..c1d7c86f 100644 --- a/src/ltc/misc/adler32.c +++ b/src/ltc/misc/adler32.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file adler32.c diff --git a/src/ltc/misc/base16/base16_decode.c b/src/ltc/misc/base16/base16_decode.c index 67382852..d02b9e28 100644 --- a/src/ltc/misc/base16/base16_decode.c +++ b/src/ltc/misc/base16/base16_decode.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file base16_decode.c @@ -21,6 +21,7 @@ /** Base16 decode a string @param in The Base16 string to decode + @param inlen The length of the Base16 data @param out [out] The destination of the binary decoded data @param outlen [in/out] The max size and resulting size of the decoded data @return CRYPT_OK if successful diff --git a/src/ltc/misc/base16/base16_encode.c b/src/ltc/misc/base16/base16_encode.c index 428002a9..f052fd1f 100644 --- a/src/ltc/misc/base16/base16_encode.c +++ b/src/ltc/misc/base16/base16_encode.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file base16_encode.c @@ -22,12 +22,12 @@ @param inlen The length of the input buffer @param out [out] The destination of the Base16 encoded data @param outlen [in/out] The max size and resulting size of the encoded data - @param caps Output 'a-f' on 0 and 'A-F' otherwise. + @param options Output 'a-f' on 0 and 'A-F' otherwise. @return CRYPT_OK if successful */ int base16_encode(const unsigned char *in, unsigned long inlen, char *out, unsigned long *outlen, - int caps) + unsigned int options) { unsigned long i, x; const char *alphabet; @@ -52,7 +52,7 @@ int base16_encode(const unsigned char *in, unsigned long inlen, x--; *outlen = x; /* returning the length without terminating NUL */ - if (caps == 0) alphabet = alphabets[0]; + if (options == 0) alphabet = alphabets[0]; else alphabet = alphabets[1]; for (i = 0; i < x; i += 2) { diff --git a/src/ltc/misc/base32/base32_decode.c b/src/ltc/misc/base32/base32_decode.c index 5809553e..91db6eed 100644 --- a/src/ltc/misc/base32/base32_decode.c +++ b/src/ltc/misc/base32/base32_decode.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_BASE32 diff --git a/src/ltc/misc/base32/base32_encode.c b/src/ltc/misc/base32/base32_encode.c index 81fa97a8..9e407458 100644 --- a/src/ltc/misc/base32/base32_encode.c +++ b/src/ltc/misc/base32/base32_encode.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_BASE32 diff --git a/src/ltc/misc/base64/base64_decode.c b/src/ltc/misc/base64/base64_decode.c index 6af4eb5c..7506d50b 100644 --- a/src/ltc/misc/base64/base64_decode.c +++ b/src/ltc/misc/base64/base64_decode.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file base64_decode.c diff --git a/src/ltc/misc/base64/base64_encode.c b/src/ltc/misc/base64/base64_encode.c index 788c9d50..a6b7b9bb 100644 --- a/src/ltc/misc/base64/base64_encode.c +++ b/src/ltc/misc/base64/base64_encode.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file base64_encode.c diff --git a/src/ltc/misc/burn_stack.c b/src/ltc/misc/burn_stack.c index afbafee4..b79f5409 100644 --- a/src/ltc/misc/burn_stack.c +++ b/src/ltc/misc/burn_stack.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file burn_stack.c diff --git a/src/ltc/misc/compare_testvector.c b/src/ltc/misc/compare_testvector.c index 74cebcc3..842678a4 100644 --- a/src/ltc/misc/compare_testvector.c +++ b/src/ltc/misc/compare_testvector.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file compare_testvector.c diff --git a/src/ltc/misc/copy_or_zeromem.c b/src/ltc/misc/copy_or_zeromem.c index 237f7123..1cfd2bdc 100644 --- a/src/ltc/misc/copy_or_zeromem.c +++ b/src/ltc/misc/copy_or_zeromem.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file copy_or_zeromem.c diff --git a/src/ltc/misc/crc32.c b/src/ltc/misc/crc32.c index a1bdc8e9..5c49f421 100644 --- a/src/ltc/misc/crc32.c +++ b/src/ltc/misc/crc32.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crc32.c diff --git a/src/ltc/misc/crypt/crypt.c b/src/ltc/misc/crypt/crypt.c index d8eaa735..1f76662e 100644 --- a/src/ltc/misc/crypt/crypt.c +++ b/src/ltc/misc/crypt/crypt.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt.c @@ -135,6 +135,9 @@ const char *crypt_build_settings = #if defined(LTC_SALSA20) " Salsa20\n" #endif +#if defined(LTC_XSALSA20) + " XSalsa20\n" +#endif #if defined(LTC_SOSEMANUK) " Sosemanuk\n" #endif @@ -350,9 +353,6 @@ const char *crypt_build_settings = #if defined(LTC_MDSA) " DSA\n" #endif -#if defined(LTC_MKAT) - " Katja\n" -#endif #if defined(LTC_PK_MAX_RETRIES) " "NAME_VALUE(LTC_PK_MAX_RETRIES)"\n" #endif @@ -515,10 +515,13 @@ const char *crypt_build_settings = " LTC_MECC_ACCEL " #endif #if defined(LTC_MECC_FP) - " LTC_MECC_FP " + " LTC_MECC_FP " #endif #if defined(LTC_ECC_SHAMIR) - " LTC_ECC_SHAMIR " + " LTC_ECC_SHAMIR " +#endif +#if defined(LTC_CLOCK_GETTIME) + " LTC_CLOCK_GETTIME " #endif "\n" ; diff --git a/src/ltc/misc/crypt/crypt_argchk.c b/src/ltc/misc/crypt/crypt_argchk.c index da7306b1..479c6a4e 100644 --- a/src/ltc/misc/crypt/crypt_argchk.c +++ b/src/ltc/misc/crypt/crypt_argchk.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_argchk.c diff --git a/src/ltc/misc/crypt/crypt_cipher_descriptor.c b/src/ltc/misc/crypt/crypt_cipher_descriptor.c index ccc98904..77411e6e 100644 --- a/src/ltc/misc/crypt/crypt_cipher_descriptor.c +++ b/src/ltc/misc/crypt/crypt_cipher_descriptor.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_cipher_descriptor.c diff --git a/src/ltc/misc/crypt/crypt_cipher_is_valid.c b/src/ltc/misc/crypt/crypt_cipher_is_valid.c index aebc94cc..44902434 100644 --- a/src/ltc/misc/crypt/crypt_cipher_is_valid.c +++ b/src/ltc/misc/crypt/crypt_cipher_is_valid.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_cipher_is_valid.c diff --git a/src/ltc/misc/crypt/crypt_constants.c b/src/ltc/misc/crypt/crypt_constants.c index 902b7749..df8ab2d6 100644 --- a/src/ltc/misc/crypt/crypt_constants.c +++ b/src/ltc/misc/crypt/crypt_constants.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_constants.c @@ -96,14 +96,6 @@ static const crypt_constant _crypt_constants[] = { {"LTC_MRSA", 0}, #endif -#ifdef LTC_MKAT - {"LTC_MKAT", 1}, - _C_STRINGIFY(MIN_KAT_SIZE), - _C_STRINGIFY(MAX_KAT_SIZE), -#else - {"LTC_MKAT", 0}, -#endif - #ifdef LTC_MECC {"LTC_MECC", 1}, _C_STRINGIFY(ECC_BUF_SIZE), diff --git a/src/ltc/misc/crypt/crypt_find_cipher.c b/src/ltc/misc/crypt/crypt_find_cipher.c index ba908f4e..a6a9d45f 100644 --- a/src/ltc/misc/crypt/crypt_find_cipher.c +++ b/src/ltc/misc/crypt/crypt_find_cipher.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_find_cipher.c diff --git a/src/ltc/misc/crypt/crypt_find_cipher_any.c b/src/ltc/misc/crypt/crypt_find_cipher_any.c index 5cdcdf89..93b5039c 100644 --- a/src/ltc/misc/crypt/crypt_find_cipher_any.c +++ b/src/ltc/misc/crypt/crypt_find_cipher_any.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_find_cipher_any.c diff --git a/src/ltc/misc/crypt/crypt_find_cipher_id.c b/src/ltc/misc/crypt/crypt_find_cipher_id.c index 34d00499..62b32663 100644 --- a/src/ltc/misc/crypt/crypt_find_cipher_id.c +++ b/src/ltc/misc/crypt/crypt_find_cipher_id.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_find_cipher_id.c diff --git a/src/ltc/misc/crypt/crypt_find_hash.c b/src/ltc/misc/crypt/crypt_find_hash.c index 19ee55cb..f418c272 100644 --- a/src/ltc/misc/crypt/crypt_find_hash.c +++ b/src/ltc/misc/crypt/crypt_find_hash.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_find_hash.c diff --git a/src/ltc/misc/crypt/crypt_find_hash_any.c b/src/ltc/misc/crypt/crypt_find_hash_any.c index 413809fb..a50f915a 100644 --- a/src/ltc/misc/crypt/crypt_find_hash_any.c +++ b/src/ltc/misc/crypt/crypt_find_hash_any.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_find_hash_any.c diff --git a/src/ltc/misc/crypt/crypt_find_hash_id.c b/src/ltc/misc/crypt/crypt_find_hash_id.c index ea784e8a..f8c2e794 100644 --- a/src/ltc/misc/crypt/crypt_find_hash_id.c +++ b/src/ltc/misc/crypt/crypt_find_hash_id.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_find_hash_id.c diff --git a/src/ltc/misc/crypt/crypt_find_hash_oid.c b/src/ltc/misc/crypt/crypt_find_hash_oid.c index 026cc73d..797e9ca2 100644 --- a/src/ltc/misc/crypt/crypt_find_hash_oid.c +++ b/src/ltc/misc/crypt/crypt_find_hash_oid.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_find_hash_oid.c diff --git a/src/ltc/misc/crypt/crypt_find_prng.c b/src/ltc/misc/crypt/crypt_find_prng.c index a0cad16f..8b7e0dce 100644 --- a/src/ltc/misc/crypt/crypt_find_prng.c +++ b/src/ltc/misc/crypt/crypt_find_prng.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_find_prng.c diff --git a/src/ltc/misc/crypt/crypt_fsa.c b/src/ltc/misc/crypt/crypt_fsa.c index dc2a570c..827b94d4 100644 --- a/src/ltc/misc/crypt/crypt_fsa.c +++ b/src/ltc/misc/crypt/crypt_fsa.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #include <stdarg.h> /** diff --git a/src/ltc/misc/crypt/crypt_hash_descriptor.c b/src/ltc/misc/crypt/crypt_hash_descriptor.c index 6e1103f2..73080037 100644 --- a/src/ltc/misc/crypt/crypt_hash_descriptor.c +++ b/src/ltc/misc/crypt/crypt_hash_descriptor.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_hash_descriptor.c diff --git a/src/ltc/misc/crypt/crypt_hash_is_valid.c b/src/ltc/misc/crypt/crypt_hash_is_valid.c index ca75f050..956c8179 100644 --- a/src/ltc/misc/crypt/crypt_hash_is_valid.c +++ b/src/ltc/misc/crypt/crypt_hash_is_valid.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_hash_is_valid.c diff --git a/src/ltc/misc/crypt/crypt_inits.c b/src/ltc/misc/crypt/crypt_inits.c index 871417ca..407b7c8c 100644 --- a/src/ltc/misc/crypt/crypt_inits.c +++ b/src/ltc/misc/crypt/crypt_inits.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_inits.c diff --git a/src/ltc/misc/crypt/crypt_ltc_mp_descriptor.c b/src/ltc/misc/crypt/crypt_ltc_mp_descriptor.c index 0f1407c5..2b9382d8 100644 --- a/src/ltc/misc/crypt/crypt_ltc_mp_descriptor.c +++ b/src/ltc/misc/crypt/crypt_ltc_mp_descriptor.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /* Initialize ltc_mp to nulls, to force allocation on all platforms, including macOS. */ ltc_math_descriptor ltc_mp = { 0 }; diff --git a/src/ltc/misc/crypt/crypt_prng_descriptor.c b/src/ltc/misc/crypt/crypt_prng_descriptor.c index 276047c5..9f35c7d5 100644 --- a/src/ltc/misc/crypt/crypt_prng_descriptor.c +++ b/src/ltc/misc/crypt/crypt_prng_descriptor.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_prng_descriptor.c diff --git a/src/ltc/misc/crypt/crypt_prng_is_valid.c b/src/ltc/misc/crypt/crypt_prng_is_valid.c index 9930a06c..e6f4936f 100644 --- a/src/ltc/misc/crypt/crypt_prng_is_valid.c +++ b/src/ltc/misc/crypt/crypt_prng_is_valid.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_prng_is_valid.c diff --git a/src/ltc/misc/crypt/crypt_prng_rng_descriptor.c b/src/ltc/misc/crypt/crypt_prng_rng_descriptor.c index 1a793374..bdaf8b2e 100644 --- a/src/ltc/misc/crypt/crypt_prng_rng_descriptor.c +++ b/src/ltc/misc/crypt/crypt_prng_rng_descriptor.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_PRNG_ENABLE_LTC_RNG unsigned long (*ltc_rng)(unsigned char *out, unsigned long outlen, void (*callback)(void)); diff --git a/src/ltc/misc/crypt/crypt_register_all_ciphers.c b/src/ltc/misc/crypt/crypt_register_all_ciphers.c index 8d1c939f..d2512e03 100644 --- a/src/ltc/misc/crypt/crypt_register_all_ciphers.c +++ b/src/ltc/misc/crypt/crypt_register_all_ciphers.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_register_all_ciphers.c diff --git a/src/ltc/misc/crypt/crypt_register_all_hashes.c b/src/ltc/misc/crypt/crypt_register_all_hashes.c index 585b9b61..a16a403c 100644 --- a/src/ltc/misc/crypt/crypt_register_all_hashes.c +++ b/src/ltc/misc/crypt/crypt_register_all_hashes.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_register_all_hashes.c diff --git a/src/ltc/misc/crypt/crypt_register_all_prngs.c b/src/ltc/misc/crypt/crypt_register_all_prngs.c index aca8a369..46cdfc96 100644 --- a/src/ltc/misc/crypt/crypt_register_all_prngs.c +++ b/src/ltc/misc/crypt/crypt_register_all_prngs.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_register_all_prngs.c diff --git a/src/ltc/misc/crypt/crypt_register_cipher.c b/src/ltc/misc/crypt/crypt_register_cipher.c index 85178d23..1dc85ddc 100644 --- a/src/ltc/misc/crypt/crypt_register_cipher.c +++ b/src/ltc/misc/crypt/crypt_register_cipher.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_register_cipher.c diff --git a/src/ltc/misc/crypt/crypt_register_hash.c b/src/ltc/misc/crypt/crypt_register_hash.c index fc7f4e02..5b4c5991 100644 --- a/src/ltc/misc/crypt/crypt_register_hash.c +++ b/src/ltc/misc/crypt/crypt_register_hash.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_register_hash.c diff --git a/src/ltc/misc/crypt/crypt_register_prng.c b/src/ltc/misc/crypt/crypt_register_prng.c index 9cbd634d..d58501c1 100644 --- a/src/ltc/misc/crypt/crypt_register_prng.c +++ b/src/ltc/misc/crypt/crypt_register_prng.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_register_prng.c diff --git a/src/ltc/misc/crypt/crypt_sizes.c b/src/ltc/misc/crypt/crypt_sizes.c index af70061c..17274147 100644 --- a/src/ltc/misc/crypt/crypt_sizes.c +++ b/src/ltc/misc/crypt/crypt_sizes.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_sizes.c @@ -249,9 +249,6 @@ static const crypt_size _crypt_sizes[] = { _SZ_STRINGIFY_T(ecc_point), _SZ_STRINGIFY_T(ecc_key), #endif -#ifdef LTC_MKAT - _SZ_STRINGIFY_T(katja_key), -#endif /* DER handling */ #ifdef LTC_DER diff --git a/src/ltc/misc/crypt/crypt_unregister_cipher.c b/src/ltc/misc/crypt/crypt_unregister_cipher.c index b57c7365..b7f713f7 100644 --- a/src/ltc/misc/crypt/crypt_unregister_cipher.c +++ b/src/ltc/misc/crypt/crypt_unregister_cipher.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_unregister_cipher.c diff --git a/src/ltc/misc/crypt/crypt_unregister_hash.c b/src/ltc/misc/crypt/crypt_unregister_hash.c index dbbff330..dee46ca1 100644 --- a/src/ltc/misc/crypt/crypt_unregister_hash.c +++ b/src/ltc/misc/crypt/crypt_unregister_hash.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_unregister_hash.c diff --git a/src/ltc/misc/crypt/crypt_unregister_prng.c b/src/ltc/misc/crypt/crypt_unregister_prng.c index f7606eff..f784b4c7 100644 --- a/src/ltc/misc/crypt/crypt_unregister_prng.c +++ b/src/ltc/misc/crypt/crypt_unregister_prng.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file crypt_unregister_prng.c diff --git a/src/ltc/misc/error_to_string.c b/src/ltc/misc/error_to_string.c index 3d168286..64e5e6da 100644 --- a/src/ltc/misc/error_to_string.c +++ b/src/ltc/misc/error_to_string.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file error_to_string.c diff --git a/src/ltc/misc/hkdf/hkdf.c b/src/ltc/misc/hkdf/hkdf.c index 0db4ed98..1ca3ae3f 100644 --- a/src/ltc/misc/hkdf/hkdf.c +++ b/src/ltc/misc/hkdf/hkdf.c @@ -11,7 +11,7 @@ #include <stdio.h> #include <stdlib.h> -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_HKDF diff --git a/src/ltc/misc/mem_neq.c b/src/ltc/misc/mem_neq.c index fbd0cce1..8bcc6e39 100644 --- a/src/ltc/misc/mem_neq.c +++ b/src/ltc/misc/mem_neq.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file mem_neq.c diff --git a/src/ltc/misc/padding/padding_depad.c b/src/ltc/misc/padding/padding_depad.c index 80603586..e02077fd 100644 --- a/src/ltc/misc/padding/padding_depad.c +++ b/src/ltc/misc/padding/padding_depad.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_PADDING diff --git a/src/ltc/misc/padding/padding_pad.c b/src/ltc/misc/padding/padding_pad.c index 653e31db..ae1a8ae2 100644 --- a/src/ltc/misc/padding/padding_pad.c +++ b/src/ltc/misc/padding/padding_pad.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_PADDING diff --git a/src/ltc/misc/pk_get_oid.c b/src/ltc/misc/pk_get_oid.c index 003925aa..35e35d6b 100644 --- a/src/ltc/misc/pk_get_oid.c +++ b/src/ltc/misc/pk_get_oid.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_DER static const oid_st rsa_oid = { diff --git a/src/ltc/misc/pk_oid_str.c b/src/ltc/misc/pk_oid_str.c index 84a47e15..ef83fb18 100644 --- a/src/ltc/misc/pk_oid_str.c +++ b/src/ltc/misc/pk_oid_str.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" int pk_oid_str_to_num(const char *OID, unsigned long *oid, unsigned long *oidlen) { diff --git a/src/ltc/misc/pkcs5/pkcs_5_1.c b/src/ltc/misc/pkcs5/pkcs_5_1.c index 10325de2..07946983 100644 --- a/src/ltc/misc/pkcs5/pkcs_5_1.c +++ b/src/ltc/misc/pkcs5/pkcs_5_1.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pkcs_5_1.c diff --git a/src/ltc/misc/pkcs5/pkcs_5_2.c b/src/ltc/misc/pkcs5/pkcs_5_2.c index 2265bcb2..8d45a0e7 100644 --- a/src/ltc/misc/pkcs5/pkcs_5_2.c +++ b/src/ltc/misc/pkcs5/pkcs_5_2.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pkcs_5_2.c diff --git a/src/ltc/misc/zeromem.c b/src/ltc/misc/zeromem.c index 1a3b8ed3..d5312d04 100644 --- a/src/ltc/misc/zeromem.c +++ b/src/ltc/misc/zeromem.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file zeromem.c diff --git a/src/ltc/modes/cbc/cbc_decrypt.c b/src/ltc/modes/cbc/cbc_decrypt.c index e9f2785a..9cbf6f30 100644 --- a/src/ltc/modes/cbc/cbc_decrypt.c +++ b/src/ltc/modes/cbc/cbc_decrypt.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file cbc_decrypt.c diff --git a/src/ltc/modes/cbc/cbc_done.c b/src/ltc/modes/cbc/cbc_done.c index 2f1293df..da624dac 100644 --- a/src/ltc/modes/cbc/cbc_done.c +++ b/src/ltc/modes/cbc/cbc_done.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file cbc_done.c diff --git a/src/ltc/modes/cbc/cbc_encrypt.c b/src/ltc/modes/cbc/cbc_encrypt.c index 00d85fcb..6ba9a0ca 100644 --- a/src/ltc/modes/cbc/cbc_encrypt.c +++ b/src/ltc/modes/cbc/cbc_encrypt.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file cbc_encrypt.c diff --git a/src/ltc/modes/cbc/cbc_getiv.c b/src/ltc/modes/cbc/cbc_getiv.c index c3e3bd17..7fd4450e 100644 --- a/src/ltc/modes/cbc/cbc_getiv.c +++ b/src/ltc/modes/cbc/cbc_getiv.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file cbc_getiv.c diff --git a/src/ltc/modes/cbc/cbc_setiv.c b/src/ltc/modes/cbc/cbc_setiv.c index 255d6419..2952d1b6 100644 --- a/src/ltc/modes/cbc/cbc_setiv.c +++ b/src/ltc/modes/cbc/cbc_setiv.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file cbc_setiv.c diff --git a/src/ltc/modes/cbc/cbc_start.c b/src/ltc/modes/cbc/cbc_start.c index 6c5c52c8..5e51b173 100644 --- a/src/ltc/modes/cbc/cbc_start.c +++ b/src/ltc/modes/cbc/cbc_start.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file cbc_start.c diff --git a/src/ltc/modes/cfb/cfb_decrypt.c b/src/ltc/modes/cfb/cfb_decrypt.c index 9749a0be..46c8f957 100644 --- a/src/ltc/modes/cfb/cfb_decrypt.c +++ b/src/ltc/modes/cfb/cfb_decrypt.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file cfb_decrypt.c diff --git a/src/ltc/modes/cfb/cfb_done.c b/src/ltc/modes/cfb/cfb_done.c index 24576c82..fecf9125 100644 --- a/src/ltc/modes/cfb/cfb_done.c +++ b/src/ltc/modes/cfb/cfb_done.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file cfb_done.c diff --git a/src/ltc/modes/cfb/cfb_encrypt.c b/src/ltc/modes/cfb/cfb_encrypt.c index 4503e5b0..eaefd320 100644 --- a/src/ltc/modes/cfb/cfb_encrypt.c +++ b/src/ltc/modes/cfb/cfb_encrypt.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file cfb_encrypt.c diff --git a/src/ltc/modes/cfb/cfb_getiv.c b/src/ltc/modes/cfb/cfb_getiv.c index 8efc7c68..5bfefbe1 100644 --- a/src/ltc/modes/cfb/cfb_getiv.c +++ b/src/ltc/modes/cfb/cfb_getiv.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file cfb_getiv.c diff --git a/src/ltc/modes/cfb/cfb_setiv.c b/src/ltc/modes/cfb/cfb_setiv.c index 4495bf5f..b1801e15 100644 --- a/src/ltc/modes/cfb/cfb_setiv.c +++ b/src/ltc/modes/cfb/cfb_setiv.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file cfb_setiv.c diff --git a/src/ltc/modes/cfb/cfb_start.c b/src/ltc/modes/cfb/cfb_start.c index e49b119b..caccb5aa 100644 --- a/src/ltc/modes/cfb/cfb_start.c +++ b/src/ltc/modes/cfb/cfb_start.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file cfb_start.c diff --git a/src/ltc/modes/ctr/ctr_decrypt.c b/src/ltc/modes/ctr/ctr_decrypt.c index 50080890..16d7593c 100644 --- a/src/ltc/modes/ctr/ctr_decrypt.c +++ b/src/ltc/modes/ctr/ctr_decrypt.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ctr_decrypt.c diff --git a/src/ltc/modes/ctr/ctr_done.c b/src/ltc/modes/ctr/ctr_done.c index 3de13c2b..55e34926 100644 --- a/src/ltc/modes/ctr/ctr_done.c +++ b/src/ltc/modes/ctr/ctr_done.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ctr_done.c diff --git a/src/ltc/modes/ctr/ctr_encrypt.c b/src/ltc/modes/ctr/ctr_encrypt.c index eb7328c2..a5c09393 100644 --- a/src/ltc/modes/ctr/ctr_encrypt.c +++ b/src/ltc/modes/ctr/ctr_encrypt.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ctr_encrypt.c diff --git a/src/ltc/modes/ctr/ctr_getiv.c b/src/ltc/modes/ctr/ctr_getiv.c index 1d950de3..c822ef8f 100644 --- a/src/ltc/modes/ctr/ctr_getiv.c +++ b/src/ltc/modes/ctr/ctr_getiv.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ctr_getiv.c diff --git a/src/ltc/modes/ctr/ctr_setiv.c b/src/ltc/modes/ctr/ctr_setiv.c index 64d73a1f..81b9c227 100644 --- a/src/ltc/modes/ctr/ctr_setiv.c +++ b/src/ltc/modes/ctr/ctr_setiv.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ctr_setiv.c diff --git a/src/ltc/modes/ctr/ctr_start.c b/src/ltc/modes/ctr/ctr_start.c index 039fdd6f..3ef3adec 100644 --- a/src/ltc/modes/ctr/ctr_start.c +++ b/src/ltc/modes/ctr/ctr_start.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ctr_start.c diff --git a/src/ltc/modes/ecb/ecb_decrypt.c b/src/ltc/modes/ecb/ecb_decrypt.c index 213b253a..b8727d2f 100644 --- a/src/ltc/modes/ecb/ecb_decrypt.c +++ b/src/ltc/modes/ecb/ecb_decrypt.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ecb_decrypt.c diff --git a/src/ltc/modes/ecb/ecb_done.c b/src/ltc/modes/ecb/ecb_done.c index 6df7eecf..1a441b47 100644 --- a/src/ltc/modes/ecb/ecb_done.c +++ b/src/ltc/modes/ecb/ecb_done.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ecb_done.c diff --git a/src/ltc/modes/ecb/ecb_encrypt.c b/src/ltc/modes/ecb/ecb_encrypt.c index 5d4661f5..d31635ba 100644 --- a/src/ltc/modes/ecb/ecb_encrypt.c +++ b/src/ltc/modes/ecb/ecb_encrypt.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ecb_encrypt.c diff --git a/src/ltc/modes/ecb/ecb_start.c b/src/ltc/modes/ecb/ecb_start.c index ecd301bd..fd25d31d 100644 --- a/src/ltc/modes/ecb/ecb_start.c +++ b/src/ltc/modes/ecb/ecb_start.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ecb_start.c diff --git a/src/ltc/modes/ofb/ofb_decrypt.c b/src/ltc/modes/ofb/ofb_decrypt.c index f4028026..37afc1c1 100644 --- a/src/ltc/modes/ofb/ofb_decrypt.c +++ b/src/ltc/modes/ofb/ofb_decrypt.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ofb_decrypt.c diff --git a/src/ltc/modes/ofb/ofb_done.c b/src/ltc/modes/ofb/ofb_done.c index 9caddbeb..53937b45 100644 --- a/src/ltc/modes/ofb/ofb_done.c +++ b/src/ltc/modes/ofb/ofb_done.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ofb_done.c diff --git a/src/ltc/modes/ofb/ofb_encrypt.c b/src/ltc/modes/ofb/ofb_encrypt.c index 415842d3..f23c168b 100644 --- a/src/ltc/modes/ofb/ofb_encrypt.c +++ b/src/ltc/modes/ofb/ofb_encrypt.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ofb_encrypt.c diff --git a/src/ltc/modes/ofb/ofb_getiv.c b/src/ltc/modes/ofb/ofb_getiv.c index bfa4eb22..9525cb8a 100644 --- a/src/ltc/modes/ofb/ofb_getiv.c +++ b/src/ltc/modes/ofb/ofb_getiv.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ofb_getiv.c diff --git a/src/ltc/modes/ofb/ofb_setiv.c b/src/ltc/modes/ofb/ofb_setiv.c index 005dbc7a..e8e7c15d 100644 --- a/src/ltc/modes/ofb/ofb_setiv.c +++ b/src/ltc/modes/ofb/ofb_setiv.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ofb_setiv.c diff --git a/src/ltc/modes/ofb/ofb_start.c b/src/ltc/modes/ofb/ofb_start.c index fe7a764f..2a19e6be 100644 --- a/src/ltc/modes/ofb/ofb_start.c +++ b/src/ltc/modes/ofb/ofb_start.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ofb_start.c diff --git a/src/ltc/pk/asn1/der/bit/der_decode_bit_string.c b/src/ltc/pk/asn1/der/bit/der_decode_bit_string.c index 6f25cd9a..42b3523e 100644 --- a/src/ltc/pk/asn1/der/bit/der_decode_bit_string.c +++ b/src/ltc/pk/asn1/der/bit/der_decode_bit_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_decode_bit_string.c diff --git a/src/ltc/pk/asn1/der/bit/der_decode_raw_bit_string.c b/src/ltc/pk/asn1/der/bit/der_decode_raw_bit_string.c index 7e7a4608..ed6440e7 100644 --- a/src/ltc/pk/asn1/der/bit/der_decode_raw_bit_string.c +++ b/src/ltc/pk/asn1/der/bit/der_decode_raw_bit_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_decode_bit_string.c diff --git a/src/ltc/pk/asn1/der/bit/der_encode_bit_string.c b/src/ltc/pk/asn1/der/bit/der_encode_bit_string.c index 7b2c6afa..56217337 100644 --- a/src/ltc/pk/asn1/der/bit/der_encode_bit_string.c +++ b/src/ltc/pk/asn1/der/bit/der_encode_bit_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_encode_bit_string.c diff --git a/src/ltc/pk/asn1/der/bit/der_encode_raw_bit_string.c b/src/ltc/pk/asn1/der/bit/der_encode_raw_bit_string.c index e884dabe..a98a2970 100644 --- a/src/ltc/pk/asn1/der/bit/der_encode_raw_bit_string.c +++ b/src/ltc/pk/asn1/der/bit/der_encode_raw_bit_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_encode_bit_string.c diff --git a/src/ltc/pk/asn1/der/bit/der_length_bit_string.c b/src/ltc/pk/asn1/der/bit/der_length_bit_string.c index 7a652084..edfcc848 100644 --- a/src/ltc/pk/asn1/der/bit/der_length_bit_string.c +++ b/src/ltc/pk/asn1/der/bit/der_length_bit_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_length_bit_string.c diff --git a/src/ltc/pk/asn1/der/boolean/der_decode_boolean.c b/src/ltc/pk/asn1/der/boolean/der_decode_boolean.c index da60ca90..0fddf5ca 100644 --- a/src/ltc/pk/asn1/der/boolean/der_decode_boolean.c +++ b/src/ltc/pk/asn1/der/boolean/der_decode_boolean.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_decode_boolean.c diff --git a/src/ltc/pk/asn1/der/boolean/der_encode_boolean.c b/src/ltc/pk/asn1/der/boolean/der_encode_boolean.c index c5cacdd4..71bdf8d7 100644 --- a/src/ltc/pk/asn1/der/boolean/der_encode_boolean.c +++ b/src/ltc/pk/asn1/der/boolean/der_encode_boolean.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_encode_boolean.c diff --git a/src/ltc/pk/asn1/der/boolean/der_length_boolean.c b/src/ltc/pk/asn1/der/boolean/der_length_boolean.c index a1a3a7b9..6840e5c7 100644 --- a/src/ltc/pk/asn1/der/boolean/der_length_boolean.c +++ b/src/ltc/pk/asn1/der/boolean/der_length_boolean.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_length_boolean.c diff --git a/src/ltc/pk/asn1/der/choice/der_decode_choice.c b/src/ltc/pk/asn1/der/choice/der_decode_choice.c index 6e17a4b7..e2ba8342 100644 --- a/src/ltc/pk/asn1/der/choice/der_decode_choice.c +++ b/src/ltc/pk/asn1/der/choice/der_decode_choice.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_decode_choice.c diff --git a/src/ltc/pk/asn1/der/custom_type/der_decode_custom_type.c b/src/ltc/pk/asn1/der/custom_type/der_decode_custom_type.c index 8a0bc85d..17e24b6a 100644 --- a/src/ltc/pk/asn1/der/custom_type/der_decode_custom_type.c +++ b/src/ltc/pk/asn1/der/custom_type/der_decode_custom_type.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** diff --git a/src/ltc/pk/asn1/der/custom_type/der_encode_custom_type.c b/src/ltc/pk/asn1/der/custom_type/der_encode_custom_type.c index d19774c4..5bbd65be 100644 --- a/src/ltc/pk/asn1/der/custom_type/der_encode_custom_type.c +++ b/src/ltc/pk/asn1/der/custom_type/der_encode_custom_type.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** diff --git a/src/ltc/pk/asn1/der/custom_type/der_length_custom_type.c b/src/ltc/pk/asn1/der/custom_type/der_length_custom_type.c index aecc4647..67b40b4a 100644 --- a/src/ltc/pk/asn1/der/custom_type/der_length_custom_type.c +++ b/src/ltc/pk/asn1/der/custom_type/der_length_custom_type.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_length_custom_type.c diff --git a/src/ltc/pk/asn1/der/general/der_asn1_maps.c b/src/ltc/pk/asn1/der/general/der_asn1_maps.c index ba9820f4..a49504e7 100644 --- a/src/ltc/pk/asn1/der/general/der_asn1_maps.c +++ b/src/ltc/pk/asn1/der/general/der_asn1_maps.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_asn1_maps.c diff --git a/src/ltc/pk/asn1/der/general/der_decode_asn1_identifier.c b/src/ltc/pk/asn1/der/general/der_decode_asn1_identifier.c index 27296fcd..26cf20af 100644 --- a/src/ltc/pk/asn1/der/general/der_decode_asn1_identifier.c +++ b/src/ltc/pk/asn1/der/general/der_decode_asn1_identifier.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_decode_asn1_identifier.c diff --git a/src/ltc/pk/asn1/der/general/der_decode_asn1_length.c b/src/ltc/pk/asn1/der/general/der_decode_asn1_length.c index 0e1bc6c2..0021eea9 100644 --- a/src/ltc/pk/asn1/der/general/der_decode_asn1_length.c +++ b/src/ltc/pk/asn1/der/general/der_decode_asn1_length.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_decode_asn1_length.c diff --git a/src/ltc/pk/asn1/der/general/der_encode_asn1_identifier.c b/src/ltc/pk/asn1/der/general/der_encode_asn1_identifier.c index 82145d56..c366ad3f 100644 --- a/src/ltc/pk/asn1/der/general/der_encode_asn1_identifier.c +++ b/src/ltc/pk/asn1/der/general/der_encode_asn1_identifier.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_encode_asn1_identifier.c diff --git a/src/ltc/pk/asn1/der/general/der_encode_asn1_length.c b/src/ltc/pk/asn1/der/general/der_encode_asn1_length.c index 0d871afe..645626a5 100644 --- a/src/ltc/pk/asn1/der/general/der_encode_asn1_length.c +++ b/src/ltc/pk/asn1/der/general/der_encode_asn1_length.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_encode_asn1_length.c diff --git a/src/ltc/pk/asn1/der/general/der_length_asn1_identifier.c b/src/ltc/pk/asn1/der/general/der_length_asn1_identifier.c index 40e76f02..ac500757 100644 --- a/src/ltc/pk/asn1/der/general/der_length_asn1_identifier.c +++ b/src/ltc/pk/asn1/der/general/der_length_asn1_identifier.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_length_asn1_identifier.c diff --git a/src/ltc/pk/asn1/der/general/der_length_asn1_length.c b/src/ltc/pk/asn1/der/general/der_length_asn1_length.c index 1271e1cb..1ce8be4f 100644 --- a/src/ltc/pk/asn1/der/general/der_length_asn1_length.c +++ b/src/ltc/pk/asn1/der/general/der_length_asn1_length.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_length_asn1_length.c diff --git a/src/ltc/pk/asn1/der/generalizedtime/der_decode_generalizedtime.c b/src/ltc/pk/asn1/der/generalizedtime/der_decode_generalizedtime.c index 016a4c2c..a5f84739 100644 --- a/src/ltc/pk/asn1/der/generalizedtime/der_decode_generalizedtime.c +++ b/src/ltc/pk/asn1/der/generalizedtime/der_decode_generalizedtime.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_decode_generalizedtime.c diff --git a/src/ltc/pk/asn1/der/generalizedtime/der_encode_generalizedtime.c b/src/ltc/pk/asn1/der/generalizedtime/der_encode_generalizedtime.c index d7c81342..018d2efe 100644 --- a/src/ltc/pk/asn1/der/generalizedtime/der_encode_generalizedtime.c +++ b/src/ltc/pk/asn1/der/generalizedtime/der_encode_generalizedtime.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_encode_utctime.c diff --git a/src/ltc/pk/asn1/der/generalizedtime/der_length_generalizedtime.c b/src/ltc/pk/asn1/der/generalizedtime/der_length_generalizedtime.c index f3fbcc6f..a3ba1899 100644 --- a/src/ltc/pk/asn1/der/generalizedtime/der_length_generalizedtime.c +++ b/src/ltc/pk/asn1/der/generalizedtime/der_length_generalizedtime.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_length_utctime.c diff --git a/src/ltc/pk/asn1/der/ia5/der_decode_ia5_string.c b/src/ltc/pk/asn1/der/ia5/der_decode_ia5_string.c index 15e90f88..e5aed676 100644 --- a/src/ltc/pk/asn1/der/ia5/der_decode_ia5_string.c +++ b/src/ltc/pk/asn1/der/ia5/der_decode_ia5_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_decode_ia5_string.c diff --git a/src/ltc/pk/asn1/der/ia5/der_encode_ia5_string.c b/src/ltc/pk/asn1/der/ia5/der_encode_ia5_string.c index fee1c703..fb6a4f8e 100644 --- a/src/ltc/pk/asn1/der/ia5/der_encode_ia5_string.c +++ b/src/ltc/pk/asn1/der/ia5/der_encode_ia5_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_encode_ia5_string.c diff --git a/src/ltc/pk/asn1/der/ia5/der_length_ia5_string.c b/src/ltc/pk/asn1/der/ia5/der_length_ia5_string.c index 422c4d33..02762999 100644 --- a/src/ltc/pk/asn1/der/ia5/der_length_ia5_string.c +++ b/src/ltc/pk/asn1/der/ia5/der_length_ia5_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_length_ia5_string.c diff --git a/src/ltc/pk/asn1/der/integer/der_decode_integer.c b/src/ltc/pk/asn1/der/integer/der_decode_integer.c index e5c5c122..aed4c86c 100644 --- a/src/ltc/pk/asn1/der/integer/der_decode_integer.c +++ b/src/ltc/pk/asn1/der/integer/der_decode_integer.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_decode_integer.c diff --git a/src/ltc/pk/asn1/der/integer/der_encode_integer.c b/src/ltc/pk/asn1/der/integer/der_encode_integer.c index 3bd95932..3bead0a0 100644 --- a/src/ltc/pk/asn1/der/integer/der_encode_integer.c +++ b/src/ltc/pk/asn1/der/integer/der_encode_integer.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_encode_integer.c diff --git a/src/ltc/pk/asn1/der/integer/der_length_integer.c b/src/ltc/pk/asn1/der/integer/der_length_integer.c index 60daffa7..7dce18ef 100644 --- a/src/ltc/pk/asn1/der/integer/der_length_integer.c +++ b/src/ltc/pk/asn1/der/integer/der_length_integer.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_length_integer.c diff --git a/src/ltc/pk/asn1/der/object_identifier/der_decode_object_identifier.c b/src/ltc/pk/asn1/der/object_identifier/der_decode_object_identifier.c index 48a95473..f4978627 100644 --- a/src/ltc/pk/asn1/der/object_identifier/der_decode_object_identifier.c +++ b/src/ltc/pk/asn1/der/object_identifier/der_decode_object_identifier.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_decode_object_identifier.c diff --git a/src/ltc/pk/asn1/der/object_identifier/der_encode_object_identifier.c b/src/ltc/pk/asn1/der/object_identifier/der_encode_object_identifier.c index af2a8f73..881809f6 100644 --- a/src/ltc/pk/asn1/der/object_identifier/der_encode_object_identifier.c +++ b/src/ltc/pk/asn1/der/object_identifier/der_encode_object_identifier.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_encode_object_identifier.c diff --git a/src/ltc/pk/asn1/der/object_identifier/der_length_object_identifier.c b/src/ltc/pk/asn1/der/object_identifier/der_length_object_identifier.c index 9db5fe1e..cc22a3c9 100644 --- a/src/ltc/pk/asn1/der/object_identifier/der_length_object_identifier.c +++ b/src/ltc/pk/asn1/der/object_identifier/der_length_object_identifier.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_length_object_identifier.c diff --git a/src/ltc/pk/asn1/der/octet/der_decode_octet_string.c b/src/ltc/pk/asn1/der/octet/der_decode_octet_string.c index a9b3cdc5..f6006378 100644 --- a/src/ltc/pk/asn1/der/octet/der_decode_octet_string.c +++ b/src/ltc/pk/asn1/der/octet/der_decode_octet_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_decode_octet_string.c diff --git a/src/ltc/pk/asn1/der/octet/der_encode_octet_string.c b/src/ltc/pk/asn1/der/octet/der_encode_octet_string.c index fd79c673..f2745158 100644 --- a/src/ltc/pk/asn1/der/octet/der_encode_octet_string.c +++ b/src/ltc/pk/asn1/der/octet/der_encode_octet_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_encode_octet_string.c diff --git a/src/ltc/pk/asn1/der/octet/der_length_octet_string.c b/src/ltc/pk/asn1/der/octet/der_length_octet_string.c index 9e5386a3..8c3db1c1 100644 --- a/src/ltc/pk/asn1/der/octet/der_length_octet_string.c +++ b/src/ltc/pk/asn1/der/octet/der_length_octet_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_length_octet_string.c diff --git a/src/ltc/pk/asn1/der/printable_string/der_decode_printable_string.c b/src/ltc/pk/asn1/der/printable_string/der_decode_printable_string.c index 1ec9e3c7..2cd88242 100644 --- a/src/ltc/pk/asn1/der/printable_string/der_decode_printable_string.c +++ b/src/ltc/pk/asn1/der/printable_string/der_decode_printable_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_decode_printable_string.c diff --git a/src/ltc/pk/asn1/der/printable_string/der_encode_printable_string.c b/src/ltc/pk/asn1/der/printable_string/der_encode_printable_string.c index bd593916..c2132de7 100644 --- a/src/ltc/pk/asn1/der/printable_string/der_encode_printable_string.c +++ b/src/ltc/pk/asn1/der/printable_string/der_encode_printable_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_encode_printable_string.c diff --git a/src/ltc/pk/asn1/der/printable_string/der_length_printable_string.c b/src/ltc/pk/asn1/der/printable_string/der_length_printable_string.c index b6eb8502..3d48c77a 100644 --- a/src/ltc/pk/asn1/der/printable_string/der_length_printable_string.c +++ b/src/ltc/pk/asn1/der/printable_string/der_length_printable_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_length_printable_string.c diff --git a/src/ltc/pk/asn1/der/sequence/der_decode_sequence_ex.c b/src/ltc/pk/asn1/der/sequence/der_decode_sequence_ex.c index 10cfd218..8143530e 100644 --- a/src/ltc/pk/asn1/der/sequence/der_decode_sequence_ex.c +++ b/src/ltc/pk/asn1/der/sequence/der_decode_sequence_ex.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** diff --git a/src/ltc/pk/asn1/der/sequence/der_decode_sequence_flexi.c b/src/ltc/pk/asn1/der/sequence/der_decode_sequence_flexi.c index a6c3cf76..94c39883 100644 --- a/src/ltc/pk/asn1/der/sequence/der_decode_sequence_flexi.c +++ b/src/ltc/pk/asn1/der/sequence/der_decode_sequence_flexi.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_decode_sequence_flexi.c diff --git a/src/ltc/pk/asn1/der/sequence/der_decode_sequence_multi.c b/src/ltc/pk/asn1/der/sequence/der_decode_sequence_multi.c index 280d7cdb..1bb75d27 100644 --- a/src/ltc/pk/asn1/der/sequence/der_decode_sequence_multi.c +++ b/src/ltc/pk/asn1/der/sequence/der_decode_sequence_multi.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #include <stdarg.h> diff --git a/src/ltc/pk/asn1/der/sequence/der_encode_sequence_ex.c b/src/ltc/pk/asn1/der/sequence/der_encode_sequence_ex.c index a69db8f8..50b3a4cd 100644 --- a/src/ltc/pk/asn1/der/sequence/der_encode_sequence_ex.c +++ b/src/ltc/pk/asn1/der/sequence/der_encode_sequence_ex.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** diff --git a/src/ltc/pk/asn1/der/sequence/der_encode_sequence_multi.c b/src/ltc/pk/asn1/der/sequence/der_encode_sequence_multi.c index c8ec59a9..febb4d4c 100644 --- a/src/ltc/pk/asn1/der/sequence/der_encode_sequence_multi.c +++ b/src/ltc/pk/asn1/der/sequence/der_encode_sequence_multi.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #include <stdarg.h> diff --git a/src/ltc/pk/asn1/der/sequence/der_length_sequence.c b/src/ltc/pk/asn1/der/sequence/der_length_sequence.c index 74628545..df7f2aaf 100644 --- a/src/ltc/pk/asn1/der/sequence/der_length_sequence.c +++ b/src/ltc/pk/asn1/der/sequence/der_length_sequence.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_length_sequence.c diff --git a/src/ltc/pk/asn1/der/sequence/der_sequence_free.c b/src/ltc/pk/asn1/der/sequence/der_sequence_free.c index 3c2a6638..bff19094 100644 --- a/src/ltc/pk/asn1/der/sequence/der_sequence_free.c +++ b/src/ltc/pk/asn1/der/sequence/der_sequence_free.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_sequence_free.c diff --git a/src/ltc/pk/asn1/der/sequence/der_sequence_shrink.c b/src/ltc/pk/asn1/der/sequence/der_sequence_shrink.c index fdfe91bb..eb9335fd 100644 --- a/src/ltc/pk/asn1/der/sequence/der_sequence_shrink.c +++ b/src/ltc/pk/asn1/der/sequence/der_sequence_shrink.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_sequence_shrink.c diff --git a/src/ltc/pk/asn1/der/set/der_encode_set.c b/src/ltc/pk/asn1/der/set/der_encode_set.c index eba52422..636669c7 100644 --- a/src/ltc/pk/asn1/der/set/der_encode_set.c +++ b/src/ltc/pk/asn1/der/set/der_encode_set.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_encode_set.c diff --git a/src/ltc/pk/asn1/der/set/der_encode_setof.c b/src/ltc/pk/asn1/der/set/der_encode_setof.c index 3bac3459..d1dc73b4 100644 --- a/src/ltc/pk/asn1/der/set/der_encode_setof.c +++ b/src/ltc/pk/asn1/der/set/der_encode_setof.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_encode_setof.c diff --git a/src/ltc/pk/asn1/der/short_integer/der_decode_short_integer.c b/src/ltc/pk/asn1/der/short_integer/der_decode_short_integer.c index 71debf31..3b01323e 100644 --- a/src/ltc/pk/asn1/der/short_integer/der_decode_short_integer.c +++ b/src/ltc/pk/asn1/der/short_integer/der_decode_short_integer.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_decode_short_integer.c diff --git a/src/ltc/pk/asn1/der/short_integer/der_encode_short_integer.c b/src/ltc/pk/asn1/der/short_integer/der_encode_short_integer.c index ea413ebc..ddab980d 100644 --- a/src/ltc/pk/asn1/der/short_integer/der_encode_short_integer.c +++ b/src/ltc/pk/asn1/der/short_integer/der_encode_short_integer.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_encode_short_integer.c diff --git a/src/ltc/pk/asn1/der/short_integer/der_length_short_integer.c b/src/ltc/pk/asn1/der/short_integer/der_length_short_integer.c index 8c1de289..75c719b8 100644 --- a/src/ltc/pk/asn1/der/short_integer/der_length_short_integer.c +++ b/src/ltc/pk/asn1/der/short_integer/der_length_short_integer.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_length_short_integer.c diff --git a/src/ltc/pk/asn1/der/teletex_string/der_decode_teletex_string.c b/src/ltc/pk/asn1/der/teletex_string/der_decode_teletex_string.c index cd530a2b..9389369a 100644 --- a/src/ltc/pk/asn1/der/teletex_string/der_decode_teletex_string.c +++ b/src/ltc/pk/asn1/der/teletex_string/der_decode_teletex_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_decode_teletex_string.c diff --git a/src/ltc/pk/asn1/der/teletex_string/der_length_teletex_string.c b/src/ltc/pk/asn1/der/teletex_string/der_length_teletex_string.c index a35c6d76..13b44879 100644 --- a/src/ltc/pk/asn1/der/teletex_string/der_length_teletex_string.c +++ b/src/ltc/pk/asn1/der/teletex_string/der_length_teletex_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_length_teletex_string.c diff --git a/src/ltc/pk/asn1/der/utctime/der_decode_utctime.c b/src/ltc/pk/asn1/der/utctime/der_decode_utctime.c index 07fcb807..fba9184b 100644 --- a/src/ltc/pk/asn1/der/utctime/der_decode_utctime.c +++ b/src/ltc/pk/asn1/der/utctime/der_decode_utctime.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_decode_utctime.c diff --git a/src/ltc/pk/asn1/der/utctime/der_encode_utctime.c b/src/ltc/pk/asn1/der/utctime/der_encode_utctime.c index 19aa9da3..258afcad 100644 --- a/src/ltc/pk/asn1/der/utctime/der_encode_utctime.c +++ b/src/ltc/pk/asn1/der/utctime/der_encode_utctime.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_encode_utctime.c diff --git a/src/ltc/pk/asn1/der/utctime/der_length_utctime.c b/src/ltc/pk/asn1/der/utctime/der_length_utctime.c index c0d1b57b..c85a9357 100644 --- a/src/ltc/pk/asn1/der/utctime/der_length_utctime.c +++ b/src/ltc/pk/asn1/der/utctime/der_length_utctime.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_length_utctime.c diff --git a/src/ltc/pk/asn1/der/utf8/der_decode_utf8_string.c b/src/ltc/pk/asn1/der/utf8/der_decode_utf8_string.c index c86d6603..94555b99 100644 --- a/src/ltc/pk/asn1/der/utf8/der_decode_utf8_string.c +++ b/src/ltc/pk/asn1/der/utf8/der_decode_utf8_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_decode_utf8_string.c diff --git a/src/ltc/pk/asn1/der/utf8/der_encode_utf8_string.c b/src/ltc/pk/asn1/der/utf8/der_encode_utf8_string.c index 1c6e09b5..5deb11ae 100644 --- a/src/ltc/pk/asn1/der/utf8/der_encode_utf8_string.c +++ b/src/ltc/pk/asn1/der/utf8/der_encode_utf8_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_encode_utf8_string.c diff --git a/src/ltc/pk/asn1/der/utf8/der_length_utf8_string.c b/src/ltc/pk/asn1/der/utf8/der_length_utf8_string.c index b4292846..48eed3bb 100644 --- a/src/ltc/pk/asn1/der/utf8/der_length_utf8_string.c +++ b/src/ltc/pk/asn1/der/utf8/der_length_utf8_string.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file der_length_utf8_string.c diff --git a/src/ltc/pk/asn1/x509/x509_decode_subject_public_key_info.c b/src/ltc/pk/asn1/x509/x509_decode_subject_public_key_info.c index 134eac2b..ba51f292 100644 --- a/src/ltc/pk/asn1/x509/x509_decode_subject_public_key_info.c +++ b/src/ltc/pk/asn1/x509/x509_decode_subject_public_key_info.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file x509_decode_subject_public_key_info.c diff --git a/src/ltc/pk/asn1/x509/x509_encode_subject_public_key_info.c b/src/ltc/pk/asn1/x509/x509_encode_subject_public_key_info.c index 25c1195d..bb29fed8 100644 --- a/src/ltc/pk/asn1/x509/x509_encode_subject_public_key_info.c +++ b/src/ltc/pk/asn1/x509/x509_encode_subject_public_key_info.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file x509_encode_subject_public_key_info.c diff --git a/src/ltc/pk/dh/dh.c b/src/ltc/pk/dh/dh.c index 199a83d9..793b5f0c 100644 --- a/src/ltc/pk/dh/dh.c +++ b/src/ltc/pk/dh/dh.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MDH diff --git a/src/ltc/pk/dh/dh_check_pubkey.c b/src/ltc/pk/dh/dh_check_pubkey.c index 5fee5505..bdd07031 100644 --- a/src/ltc/pk/dh/dh_check_pubkey.c +++ b/src/ltc/pk/dh/dh_check_pubkey.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MDH diff --git a/src/ltc/pk/dh/dh_export.c b/src/ltc/pk/dh/dh_export.c index f28ec10a..7a94fa29 100644 --- a/src/ltc/pk/dh/dh_export.c +++ b/src/ltc/pk/dh/dh_export.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MDH diff --git a/src/ltc/pk/dh/dh_export_key.c b/src/ltc/pk/dh/dh_export_key.c index afcbce53..d42844ae 100644 --- a/src/ltc/pk/dh/dh_export_key.c +++ b/src/ltc/pk/dh/dh_export_key.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MDH diff --git a/src/ltc/pk/dh/dh_free.c b/src/ltc/pk/dh/dh_free.c index b4f58cac..32510061 100644 --- a/src/ltc/pk/dh/dh_free.c +++ b/src/ltc/pk/dh/dh_free.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MDH diff --git a/src/ltc/pk/dh/dh_generate_key.c b/src/ltc/pk/dh/dh_generate_key.c index 69fb6f9d..ba737fcf 100644 --- a/src/ltc/pk/dh/dh_generate_key.c +++ b/src/ltc/pk/dh/dh_generate_key.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MDH diff --git a/src/ltc/pk/dh/dh_import.c b/src/ltc/pk/dh/dh_import.c index 601e5e74..2e8d2f2e 100644 --- a/src/ltc/pk/dh/dh_import.c +++ b/src/ltc/pk/dh/dh_import.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MDH diff --git a/src/ltc/pk/dh/dh_set.c b/src/ltc/pk/dh/dh_set.c index 8d0af7d2..fd9163fd 100644 --- a/src/ltc/pk/dh/dh_set.c +++ b/src/ltc/pk/dh/dh_set.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MDH diff --git a/src/ltc/pk/dh/dh_set_pg_dhparam.c b/src/ltc/pk/dh/dh_set_pg_dhparam.c index 7003011d..98599c30 100644 --- a/src/ltc/pk/dh/dh_set_pg_dhparam.c +++ b/src/ltc/pk/dh/dh_set_pg_dhparam.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MDH diff --git a/src/ltc/pk/dh/dh_shared_secret.c b/src/ltc/pk/dh/dh_shared_secret.c index da36408c..a3890a5f 100644 --- a/src/ltc/pk/dh/dh_shared_secret.c +++ b/src/ltc/pk/dh/dh_shared_secret.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MDH diff --git a/src/ltc/pk/dsa/dsa_decrypt_key.c b/src/ltc/pk/dsa/dsa_decrypt_key.c index aa7ac678..754a07b7 100644 --- a/src/ltc/pk/dsa/dsa_decrypt_key.c +++ b/src/ltc/pk/dsa/dsa_decrypt_key.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file dsa_decrypt_key.c diff --git a/src/ltc/pk/dsa/dsa_encrypt_key.c b/src/ltc/pk/dsa/dsa_encrypt_key.c index 61dfbbd2..62869853 100644 --- a/src/ltc/pk/dsa/dsa_encrypt_key.c +++ b/src/ltc/pk/dsa/dsa_encrypt_key.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file dsa_encrypt_key.c diff --git a/src/ltc/pk/dsa/dsa_export.c b/src/ltc/pk/dsa/dsa_export.c index e406cd8e..9058dd31 100644 --- a/src/ltc/pk/dsa/dsa_export.c +++ b/src/ltc/pk/dsa/dsa_export.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file dsa_export.c diff --git a/src/ltc/pk/dsa/dsa_free.c b/src/ltc/pk/dsa/dsa_free.c index 5cac656f..dc9d4367 100644 --- a/src/ltc/pk/dsa/dsa_free.c +++ b/src/ltc/pk/dsa/dsa_free.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file dsa_free.c diff --git a/src/ltc/pk/dsa/dsa_generate_key.c b/src/ltc/pk/dsa/dsa_generate_key.c index 18b2df63..9e7489e3 100644 --- a/src/ltc/pk/dsa/dsa_generate_key.c +++ b/src/ltc/pk/dsa/dsa_generate_key.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file dsa_make_key.c diff --git a/src/ltc/pk/dsa/dsa_generate_pqg.c b/src/ltc/pk/dsa/dsa_generate_pqg.c index 8c5f5582..94a1c404 100644 --- a/src/ltc/pk/dsa/dsa_generate_pqg.c +++ b/src/ltc/pk/dsa/dsa_generate_pqg.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file dsa_generate_pqg.c diff --git a/src/ltc/pk/dsa/dsa_import.c b/src/ltc/pk/dsa/dsa_import.c index 5e77b1e7..b43daeb5 100644 --- a/src/ltc/pk/dsa/dsa_import.c +++ b/src/ltc/pk/dsa/dsa_import.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file dsa_import.c diff --git a/src/ltc/pk/dsa/dsa_make_key.c b/src/ltc/pk/dsa/dsa_make_key.c index 8ac08f84..e7628e1e 100644 --- a/src/ltc/pk/dsa/dsa_make_key.c +++ b/src/ltc/pk/dsa/dsa_make_key.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file dsa_make_key.c diff --git a/src/ltc/pk/dsa/dsa_set.c b/src/ltc/pk/dsa/dsa_set.c index a4d4042f..77461e11 100644 --- a/src/ltc/pk/dsa/dsa_set.c +++ b/src/ltc/pk/dsa/dsa_set.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MDSA diff --git a/src/ltc/pk/dsa/dsa_set_pqg_dsaparam.c b/src/ltc/pk/dsa/dsa_set_pqg_dsaparam.c index edbed1c4..2d55985e 100644 --- a/src/ltc/pk/dsa/dsa_set_pqg_dsaparam.c +++ b/src/ltc/pk/dsa/dsa_set_pqg_dsaparam.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MDSA diff --git a/src/ltc/pk/dsa/dsa_shared_secret.c b/src/ltc/pk/dsa/dsa_shared_secret.c index 0568834f..ca6ce7fb 100644 --- a/src/ltc/pk/dsa/dsa_shared_secret.c +++ b/src/ltc/pk/dsa/dsa_shared_secret.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file dsa_shared_secret.c diff --git a/src/ltc/pk/dsa/dsa_sign_hash.c b/src/ltc/pk/dsa/dsa_sign_hash.c index 04ca330b..cd58292a 100644 --- a/src/ltc/pk/dsa/dsa_sign_hash.c +++ b/src/ltc/pk/dsa/dsa_sign_hash.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file dsa_sign_hash.c diff --git a/src/ltc/pk/dsa/dsa_verify_hash.c b/src/ltc/pk/dsa/dsa_verify_hash.c index ea7d5ada..6bf3a019 100644 --- a/src/ltc/pk/dsa/dsa_verify_hash.c +++ b/src/ltc/pk/dsa/dsa_verify_hash.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file dsa_verify_hash.c diff --git a/src/ltc/pk/dsa/dsa_verify_key.c b/src/ltc/pk/dsa/dsa_verify_key.c index 9061f45f..5818879b 100644 --- a/src/ltc/pk/dsa/dsa_verify_key.c +++ b/src/ltc/pk/dsa/dsa_verify_key.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file dsa_verify_key.c diff --git a/src/ltc/pk/ecc/ecc.c b/src/ltc/pk/ecc/ecc.c index 802097f4..50470ee2 100644 --- a/src/ltc/pk/ecc/ecc.c +++ b/src/ltc/pk/ecc/ecc.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ecc.c diff --git a/src/ltc/pk/ecc/ecc_ansi_x963_export.c b/src/ltc/pk/ecc/ecc_ansi_x963_export.c index b752b6b5..ebecf24d 100644 --- a/src/ltc/pk/ecc/ecc_ansi_x963_export.c +++ b/src/ltc/pk/ecc/ecc_ansi_x963_export.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ecc_ansi_x963_export.c @@ -24,41 +24,7 @@ */ int ecc_ansi_x963_export(const ecc_key *key, unsigned char *out, unsigned long *outlen) { - unsigned char buf[ECC_BUF_SIZE]; - unsigned long numlen, xlen, ylen; - - LTC_ARGCHK(key != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - numlen = key->dp.size; - xlen = mp_unsigned_bin_size(key->pubkey.x); - ylen = mp_unsigned_bin_size(key->pubkey.y); - - if (xlen > numlen || ylen > numlen || sizeof(buf) < numlen) { - return CRYPT_BUFFER_OVERFLOW; - } - - if (*outlen < (1 + 2*numlen)) { - *outlen = 1 + 2*numlen; - return CRYPT_BUFFER_OVERFLOW; - } - - /* store byte 0x04 */ - out[0] = 0x04; - - /* pad and store x */ - zeromem(buf, sizeof(buf)); - mp_to_unsigned_bin(key->pubkey.x, buf + (numlen - xlen)); - XMEMCPY(out+1, buf, numlen); - - /* pad and store y */ - zeromem(buf, sizeof(buf)); - mp_to_unsigned_bin(key->pubkey.y, buf + (numlen - ylen)); - XMEMCPY(out+1+numlen, buf, numlen); - - *outlen = 1 + 2*numlen; - return CRYPT_OK; + return ecc_get_key(out, outlen, PK_PUBLIC, key); } #endif diff --git a/src/ltc/pk/ecc/ecc_ansi_x963_import.c b/src/ltc/pk/ecc/ecc_ansi_x963_import.c index 12b034da..6dbdd215 100644 --- a/src/ltc/pk/ecc/ecc_ansi_x963_import.c +++ b/src/ltc/pk/ecc/ecc_ansi_x963_import.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ecc_ansi_x963_import.c diff --git a/src/ltc/pk/ecc/ecc_decrypt_key.c b/src/ltc/pk/ecc/ecc_decrypt_key.c index 6ce93d52..8c29a174 100644 --- a/src/ltc/pk/ecc/ecc_decrypt_key.c +++ b/src/ltc/pk/ecc/ecc_decrypt_key.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ecc_decrypt_key.c diff --git a/src/ltc/pk/ecc/ecc_encrypt_key.c b/src/ltc/pk/ecc/ecc_encrypt_key.c index e0beb692..17201df6 100644 --- a/src/ltc/pk/ecc/ecc_encrypt_key.c +++ b/src/ltc/pk/ecc/ecc_encrypt_key.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ecc_encrypt_key.c @@ -43,11 +43,6 @@ int ecc_encrypt_key(const unsigned char *in, unsigned long inlen, LTC_ARGCHK(outlen != NULL); LTC_ARGCHK(key != NULL); - /* check that wprng/cipher/hash are not invalid */ - if ((err = prng_is_valid(wprng)) != CRYPT_OK) { - return err; - } - if ((err = hash_is_valid(hash)) != CRYPT_OK) { return err; } diff --git a/src/ltc/pk/ecc/ecc_export.c b/src/ltc/pk/ecc/ecc_export.c index eab854a5..268e4306 100644 --- a/src/ltc/pk/ecc/ecc_export.c +++ b/src/ltc/pk/ecc/ecc_export.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ecc_export.c diff --git a/src/ltc/pk/ecc/ecc_export_openssl.c b/src/ltc/pk/ecc/ecc_export_openssl.c index 4f47dd39..08056fea 100644 --- a/src/ltc/pk/ecc/ecc_export_openssl.c +++ b/src/ltc/pk/ecc/ecc_export_openssl.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MECC diff --git a/src/ltc/pk/ecc/ecc_free.c b/src/ltc/pk/ecc/ecc_free.c index 47d31297..d15709e9 100644 --- a/src/ltc/pk/ecc/ecc_free.c +++ b/src/ltc/pk/ecc/ecc_free.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ecc_free.c diff --git a/src/ltc/pk/ecc/ecc_get_curve.c b/src/ltc/pk/ecc/ecc_get_curve.c index 7f038621..a2f52b0a 100644 --- a/src/ltc/pk/ecc/ecc_get_curve.c +++ b/src/ltc/pk/ecc/ecc_get_curve.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MECC diff --git a/src/ltc/pk/ecc/ecc_get_key.c b/src/ltc/pk/ecc/ecc_get_key.c index 2154e7f5..abae6da1 100644 --- a/src/ltc/pk/ecc/ecc_get_key.c +++ b/src/ltc/pk/ecc/ecc_get_key.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MECC diff --git a/src/ltc/pk/ecc/ecc_get_oid_str.c b/src/ltc/pk/ecc/ecc_get_oid_str.c new file mode 100644 index 00000000..70386c62 --- /dev/null +++ b/src/ltc/pk/ecc/ecc_get_oid_str.c @@ -0,0 +1,32 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + */ + +#include "tomcrypt_private.h" + +#ifdef LTC_MECC + +/** Extract OID as a string from ECC key + @param out [out] destination buffer + @param outlen [in/out] Length of destination buffer and final output size (without terminating NUL byte) + @param key The ECC key + Return CRYPT_OK on success +*/ + +int ecc_get_oid_str(char *out, unsigned long *outlen, const ecc_key *key) +{ + LTC_ARGCHK(key != NULL); + + return pk_oid_num_to_str(key->dp.oid, key->dp.oidlen, out, outlen); +} + +#endif + +/* ref: $Format:%D$ */ +/* git commit: $Format:%H$ */ +/* commit time: $Format:%ai$ */ diff --git a/src/ltc/pk/ecc/ecc_get_size.c b/src/ltc/pk/ecc/ecc_get_size.c index 3f5810cc..3dada78a 100644 --- a/src/ltc/pk/ecc/ecc_get_size.c +++ b/src/ltc/pk/ecc/ecc_get_size.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ecc_get_size.c diff --git a/src/ltc/pk/ecc/ecc_import.c b/src/ltc/pk/ecc/ecc_import.c index 6deea284..e691add5 100644 --- a/src/ltc/pk/ecc/ecc_import.c +++ b/src/ltc/pk/ecc/ecc_import.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ecc_import.c diff --git a/src/ltc/pk/ecc/ecc_import_openssl.c b/src/ltc/pk/ecc/ecc_import_openssl.c index a9e25a6b..bf34c080 100644 --- a/src/ltc/pk/ecc/ecc_import_openssl.c +++ b/src/ltc/pk/ecc/ecc_import_openssl.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MECC @@ -149,9 +149,8 @@ int ecc_import_openssl(const unsigned char *in, unsigned long inlen, ecc_key *ke goto success; } - /* ### 5. backward compatibility - try to load old-DER format */ - - if ((err = ecc_import(in, inlen, key)) != CRYPT_OK) { goto error; } + /* ### 5. all attempts failed */ + goto error; success: err = CRYPT_OK; diff --git a/src/ltc/pk/ecc/ecc_import_pkcs8.c b/src/ltc/pk/ecc/ecc_import_pkcs8.c index 8097eab6..4bf9fbcf 100644 --- a/src/ltc/pk/ecc/ecc_import_pkcs8.c +++ b/src/ltc/pk/ecc/ecc_import_pkcs8.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MECC diff --git a/src/ltc/pk/ecc/ecc_import_x509.c b/src/ltc/pk/ecc/ecc_import_x509.c index e57b156f..1427e982 100644 --- a/src/ltc/pk/ecc/ecc_import_x509.c +++ b/src/ltc/pk/ecc/ecc_import_x509.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MECC diff --git a/src/ltc/pk/ecc/ecc_make_key.c b/src/ltc/pk/ecc/ecc_make_key.c index 16660174..da595850 100644 --- a/src/ltc/pk/ecc/ecc_make_key.c +++ b/src/ltc/pk/ecc/ecc_make_key.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ecc_make_key.c @@ -49,11 +49,6 @@ int ecc_generate_key(prng_state *prng, int wprng, ecc_key *key) LTC_ARGCHK(key != NULL); LTC_ARGCHK(key->dp.size > 0); - /* good prng? */ - if ((err = prng_is_valid(wprng)) != CRYPT_OK) { - return err; - } - /* ECC key pair generation according to FIPS-186-4 (B.4.2 Key Pair Generation by Testing Candidates): * the generated private key k should be the range [1, order-1] * a/ N = bitlen(order) diff --git a/src/ltc/pk/ecc/ecc_set_dp.c b/src/ltc/pk/ecc/ecc_set_dp.c index cecca68d..4c4f4877 100644 --- a/src/ltc/pk/ecc/ecc_set_dp.c +++ b/src/ltc/pk/ecc/ecc_set_dp.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MECC diff --git a/src/ltc/pk/ecc/ecc_set_dp_internal.c b/src/ltc/pk/ecc/ecc_set_dp_internal.c index eca70313..cf9020bf 100644 --- a/src/ltc/pk/ecc/ecc_set_dp_internal.c +++ b/src/ltc/pk/ecc/ecc_set_dp_internal.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MECC diff --git a/src/ltc/pk/ecc/ecc_set_key.c b/src/ltc/pk/ecc/ecc_set_key.c index 9fabcf2e..75e047b7 100644 --- a/src/ltc/pk/ecc/ecc_set_key.c +++ b/src/ltc/pk/ecc/ecc_set_key.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MECC diff --git a/src/ltc/pk/ecc/ecc_shared_secret.c b/src/ltc/pk/ecc/ecc_shared_secret.c index afb86919..bdefd021 100644 --- a/src/ltc/pk/ecc/ecc_shared_secret.c +++ b/src/ltc/pk/ecc/ecc_shared_secret.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ecc_shared_secret.c diff --git a/src/ltc/pk/ecc/ecc_sign_hash.c b/src/ltc/pk/ecc/ecc_sign_hash.c index 027ad7af..360807ec 100644 --- a/src/ltc/pk/ecc/ecc_sign_hash.c +++ b/src/ltc/pk/ecc/ecc_sign_hash.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MECC @@ -36,10 +36,6 @@ static int _ecc_sign_hash(const unsigned char *in, unsigned long inlen, return CRYPT_PK_NOT_PRIVATE; } - if ((err = prng_is_valid(wprng)) != CRYPT_OK) { - return err; - } - /* init the bignums */ if ((err = mp_init_multi(&r, &s, &e, NULL)) != CRYPT_OK) { return err; diff --git a/src/ltc/pk/ecc/ecc_sizes.c b/src/ltc/pk/ecc/ecc_sizes.c index 165c849c..f57f02b5 100644 --- a/src/ltc/pk/ecc/ecc_sizes.c +++ b/src/ltc/pk/ecc/ecc_sizes.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ecc_sizes.c diff --git a/src/ltc/pk/ecc/ecc_verify_hash.c b/src/ltc/pk/ecc/ecc_verify_hash.c index 5127953a..f2a58940 100644 --- a/src/ltc/pk/ecc/ecc_verify_hash.c +++ b/src/ltc/pk/ecc/ecc_verify_hash.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MECC diff --git a/src/ltc/pk/ecc/ltc_ecc_export_point.c b/src/ltc/pk/ecc/ltc_ecc_export_point.c index 84750c80..c64e6b60 100644 --- a/src/ltc/pk/ecc/ltc_ecc_export_point.c +++ b/src/ltc/pk/ecc/ltc_ecc_export_point.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MECC diff --git a/src/ltc/pk/ecc/ltc_ecc_import_point.c b/src/ltc/pk/ecc/ltc_ecc_import_point.c index 7e103f47..2b776f6e 100644 --- a/src/ltc/pk/ecc/ltc_ecc_import_point.c +++ b/src/ltc/pk/ecc/ltc_ecc_import_point.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MECC diff --git a/src/ltc/pk/ecc/ltc_ecc_is_point.c b/src/ltc/pk/ecc/ltc_ecc_is_point.c index 46e1a6d4..efd954b8 100644 --- a/src/ltc/pk/ecc/ltc_ecc_is_point.c +++ b/src/ltc/pk/ecc/ltc_ecc_is_point.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MECC diff --git a/src/ltc/pk/ecc/ltc_ecc_is_point_at_infinity.c b/src/ltc/pk/ecc/ltc_ecc_is_point_at_infinity.c index faf7631d..85bd47a1 100644 --- a/src/ltc/pk/ecc/ltc_ecc_is_point_at_infinity.c +++ b/src/ltc/pk/ecc/ltc_ecc_is_point_at_infinity.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MECC diff --git a/src/ltc/pk/ecc/ltc_ecc_map.c b/src/ltc/pk/ecc/ltc_ecc_map.c index 3c57019f..14ec47e2 100644 --- a/src/ltc/pk/ecc/ltc_ecc_map.c +++ b/src/ltc/pk/ecc/ltc_ecc_map.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ltc_ecc_map.c diff --git a/src/ltc/pk/ecc/ltc_ecc_mul2add.c b/src/ltc/pk/ecc/ltc_ecc_mul2add.c index a2dcf5f2..c9913ff3 100644 --- a/src/ltc/pk/ecc/ltc_ecc_mul2add.c +++ b/src/ltc/pk/ecc/ltc_ecc_mul2add.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ltc_ecc_mul2add.c diff --git a/src/ltc/pk/ecc/ltc_ecc_mulmod.c b/src/ltc/pk/ecc/ltc_ecc_mulmod.c index ec8ba9cf..d6f038d3 100644 --- a/src/ltc/pk/ecc/ltc_ecc_mulmod.c +++ b/src/ltc/pk/ecc/ltc_ecc_mulmod.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ltc_ecc_mulmod.c diff --git a/src/ltc/pk/ecc/ltc_ecc_mulmod_timing.c b/src/ltc/pk/ecc/ltc_ecc_mulmod_timing.c index 9ff37d83..a10285d1 100644 --- a/src/ltc/pk/ecc/ltc_ecc_mulmod_timing.c +++ b/src/ltc/pk/ecc/ltc_ecc_mulmod_timing.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ltc_ecc_mulmod_timing.c diff --git a/src/ltc/pk/ecc/ltc_ecc_points.c b/src/ltc/pk/ecc/ltc_ecc_points.c index 4a890fdc..cf029db4 100644 --- a/src/ltc/pk/ecc/ltc_ecc_points.c +++ b/src/ltc/pk/ecc/ltc_ecc_points.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ltc_ecc_points.c diff --git a/src/ltc/pk/ecc/ltc_ecc_projective_add_point.c b/src/ltc/pk/ecc/ltc_ecc_projective_add_point.c index eff35c93..8bd91c13 100644 --- a/src/ltc/pk/ecc/ltc_ecc_projective_add_point.c +++ b/src/ltc/pk/ecc/ltc_ecc_projective_add_point.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file ltc_ecc_projective_add_point.c diff --git a/src/ltc/pk/ecc/ltc_ecc_projective_dbl_point.c b/src/ltc/pk/ecc/ltc_ecc_projective_dbl_point.c index 1b46457b..da6d5150 100644 --- a/src/ltc/pk/ecc/ltc_ecc_projective_dbl_point.c +++ b/src/ltc/pk/ecc/ltc_ecc_projective_dbl_point.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /* ### Point doubling in Jacobian coordinate system ### * diff --git a/src/ltc/pk/ecc/ltc_ecc_verify_key.c b/src/ltc/pk/ecc/ltc_ecc_verify_key.c index 3d763415..b75af104 100644 --- a/src/ltc/pk/ecc/ltc_ecc_verify_key.c +++ b/src/ltc/pk/ecc/ltc_ecc_verify_key.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /* origin of this code - OLPC */ diff --git a/src/ltc/pk/pkcs1/pkcs_1_i2osp.c b/src/ltc/pk/pkcs1/pkcs_1_i2osp.c index 5324c1ea..5e3e072a 100644 --- a/src/ltc/pk/pkcs1/pkcs_1_i2osp.c +++ b/src/ltc/pk/pkcs1/pkcs_1_i2osp.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pkcs_1_i2osp.c diff --git a/src/ltc/pk/pkcs1/pkcs_1_mgf1.c b/src/ltc/pk/pkcs1/pkcs_1_mgf1.c index c6283ca7..c0db5598 100644 --- a/src/ltc/pk/pkcs1/pkcs_1_mgf1.c +++ b/src/ltc/pk/pkcs1/pkcs_1_mgf1.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pkcs_1_mgf1.c diff --git a/src/ltc/pk/pkcs1/pkcs_1_oaep_decode.c b/src/ltc/pk/pkcs1/pkcs_1_oaep_decode.c index 27c92456..62855024 100644 --- a/src/ltc/pk/pkcs1/pkcs_1_oaep_decode.c +++ b/src/ltc/pk/pkcs1/pkcs_1_oaep_decode.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pkcs_1_oaep_decode.c diff --git a/src/ltc/pk/pkcs1/pkcs_1_oaep_encode.c b/src/ltc/pk/pkcs1/pkcs_1_oaep_encode.c index 50429467..87e7fa98 100644 --- a/src/ltc/pk/pkcs1/pkcs_1_oaep_encode.c +++ b/src/ltc/pk/pkcs1/pkcs_1_oaep_encode.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pkcs_1_oaep_encode.c diff --git a/src/ltc/pk/pkcs1/pkcs_1_os2ip.c b/src/ltc/pk/pkcs1/pkcs_1_os2ip.c index 743c70b3..f3dce66c 100644 --- a/src/ltc/pk/pkcs1/pkcs_1_os2ip.c +++ b/src/ltc/pk/pkcs1/pkcs_1_os2ip.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pkcs_1_os2ip.c diff --git a/src/ltc/pk/pkcs1/pkcs_1_pss_decode.c b/src/ltc/pk/pkcs1/pkcs_1_pss_decode.c index 8e112a14..a70d2964 100644 --- a/src/ltc/pk/pkcs1/pkcs_1_pss_decode.c +++ b/src/ltc/pk/pkcs1/pkcs_1_pss_decode.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pkcs_1_pss_decode.c diff --git a/src/ltc/pk/pkcs1/pkcs_1_pss_encode.c b/src/ltc/pk/pkcs1/pkcs_1_pss_encode.c index c795114b..b09d3006 100644 --- a/src/ltc/pk/pkcs1/pkcs_1_pss_encode.c +++ b/src/ltc/pk/pkcs1/pkcs_1_pss_encode.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pkcs_1_pss_encode.c diff --git a/src/ltc/pk/pkcs1/pkcs_1_v1_5_decode.c b/src/ltc/pk/pkcs1/pkcs_1_v1_5_decode.c index 94e1b2a3..4835ddf8 100644 --- a/src/ltc/pk/pkcs1/pkcs_1_v1_5_decode.c +++ b/src/ltc/pk/pkcs1/pkcs_1_v1_5_decode.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file pkcs_1_v1_5_decode.c * diff --git a/src/ltc/pk/pkcs1/pkcs_1_v1_5_encode.c b/src/ltc/pk/pkcs1/pkcs_1_v1_5_encode.c index dd92c64e..493e50b6 100644 --- a/src/ltc/pk/pkcs1/pkcs_1_v1_5_encode.c +++ b/src/ltc/pk/pkcs1/pkcs_1_v1_5_encode.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /*! \file pkcs_1_v1_5_encode.c * diff --git a/src/ltc/pk/rsa/rsa_decrypt_key.c b/src/ltc/pk/rsa/rsa_decrypt_key.c index 0b54dc80..704b98cd 100644 --- a/src/ltc/pk/rsa/rsa_decrypt_key.c +++ b/src/ltc/pk/rsa/rsa_decrypt_key.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file rsa_decrypt_key.c diff --git a/src/ltc/pk/rsa/rsa_encrypt_key.c b/src/ltc/pk/rsa/rsa_encrypt_key.c index cfe80ac0..57b6dce0 100644 --- a/src/ltc/pk/rsa/rsa_encrypt_key.c +++ b/src/ltc/pk/rsa/rsa_encrypt_key.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file rsa_encrypt_key.c diff --git a/src/ltc/pk/rsa/rsa_export.c b/src/ltc/pk/rsa/rsa_export.c index e1855409..6bd2199e 100644 --- a/src/ltc/pk/rsa/rsa_export.c +++ b/src/ltc/pk/rsa/rsa_export.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file rsa_export.c diff --git a/src/ltc/pk/rsa/rsa_exptmod.c b/src/ltc/pk/rsa/rsa_exptmod.c index 1a79dfe1..ea6e2983 100644 --- a/src/ltc/pk/rsa/rsa_exptmod.c +++ b/src/ltc/pk/rsa/rsa_exptmod.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file rsa_exptmod.c diff --git a/src/ltc/pk/rsa/rsa_free.c b/src/ltc/pk/rsa/rsa_free.c index 1e62f097..f2251dd6 100644 --- a/src/ltc/pk/rsa/rsa_free.c +++ b/src/ltc/pk/rsa/rsa_free.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file rsa_free.c diff --git a/src/ltc/pk/rsa/rsa_get_size.c b/src/ltc/pk/rsa/rsa_get_size.c index f58f256c..748314e9 100644 --- a/src/ltc/pk/rsa/rsa_get_size.c +++ b/src/ltc/pk/rsa/rsa_get_size.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file rsa_get_size.c diff --git a/src/ltc/pk/rsa/rsa_import.c b/src/ltc/pk/rsa/rsa_import.c index 85771783..bb8793dd 100644 --- a/src/ltc/pk/rsa/rsa_import.c +++ b/src/ltc/pk/rsa/rsa_import.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file rsa_import.c diff --git a/src/ltc/pk/rsa/rsa_import_pkcs8.c b/src/ltc/pk/rsa/rsa_import_pkcs8.c index 0546eb06..4deab5ba 100644 --- a/src/ltc/pk/rsa/rsa_import_pkcs8.c +++ b/src/ltc/pk/rsa/rsa_import_pkcs8.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file rsa_import_pkcs8.c diff --git a/src/ltc/pk/rsa/rsa_import_x509.c b/src/ltc/pk/rsa/rsa_import_x509.c index aa35e644..c615b772 100644 --- a/src/ltc/pk/rsa/rsa_import_x509.c +++ b/src/ltc/pk/rsa/rsa_import_x509.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file rsa_import.c diff --git a/src/ltc/pk/rsa/rsa_make_key.c b/src/ltc/pk/rsa/rsa_make_key.c index c5c4c288..9226b234 100644 --- a/src/ltc/pk/rsa/rsa_make_key.c +++ b/src/ltc/pk/rsa/rsa_make_key.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file rsa_make_key.c diff --git a/src/ltc/pk/rsa/rsa_set.c b/src/ltc/pk/rsa/rsa_set.c index 0d540c4d..c89ab219 100644 --- a/src/ltc/pk/rsa/rsa_set.c +++ b/src/ltc/pk/rsa/rsa_set.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_MRSA diff --git a/src/ltc/pk/rsa/rsa_sign_hash.c b/src/ltc/pk/rsa/rsa_sign_hash.c index ef9fd444..630a2038 100644 --- a/src/ltc/pk/rsa/rsa_sign_hash.c +++ b/src/ltc/pk/rsa/rsa_sign_hash.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file rsa_sign_hash.c diff --git a/src/ltc/pk/rsa/rsa_sign_saltlen_get.c b/src/ltc/pk/rsa/rsa_sign_saltlen_get.c index c8f796f3..fb9bbd2f 100644 --- a/src/ltc/pk/rsa/rsa_sign_saltlen_get.c +++ b/src/ltc/pk/rsa/rsa_sign_saltlen_get.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file rsa_sign_saltlen_get.c diff --git a/src/ltc/pk/rsa/rsa_verify_hash.c b/src/ltc/pk/rsa/rsa_verify_hash.c index a454ab2e..f4b6af14 100644 --- a/src/ltc/pk/rsa/rsa_verify_hash.c +++ b/src/ltc/pk/rsa/rsa_verify_hash.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file rsa_verify_hash.c diff --git a/src/ltc/prngs/chacha20.c b/src/ltc/prngs/chacha20.c index 07290b4f..4e686a0b 100644 --- a/src/ltc/prngs/chacha20.c +++ b/src/ltc/prngs/chacha20.c @@ -11,7 +11,7 @@ * http://bxr.su/OpenBSD/lib/libc/crypt/arc4random.c */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CHACHA20_PRNG @@ -37,10 +37,10 @@ const struct ltc_prng_descriptor chacha20_prng_desc = int chacha20_prng_start(prng_state *prng) { LTC_ARGCHK(prng != NULL); - prng->chacha.ready = 0; - XMEMSET(&prng->chacha.ent, 0, sizeof(prng->chacha.ent)); - prng->chacha.idx = 0; - LTC_MUTEX_INIT(&prng->chacha.lock) + prng->ready = 0; + XMEMSET(&prng->u.chacha.ent, 0, sizeof(prng->u.chacha.ent)); + prng->u.chacha.idx = 0; + LTC_MUTEX_INIT(&prng->lock) return CRYPT_OK; } @@ -61,25 +61,25 @@ int chacha20_prng_add_entropy(const unsigned char *in, unsigned long inlen, prng LTC_ARGCHK(in != NULL); LTC_ARGCHK(inlen > 0); - LTC_MUTEX_LOCK(&prng->chacha.lock); - if (prng->chacha.ready) { + LTC_MUTEX_LOCK(&prng->lock); + if (prng->ready) { /* chacha20_prng_ready() was already called, do "rekey" operation */ - if ((err = chacha_keystream(&prng->chacha.s, buf, sizeof(buf))) != CRYPT_OK) goto LBL_UNLOCK; + if ((err = chacha_keystream(&prng->u.chacha.s, buf, sizeof(buf))) != CRYPT_OK) goto LBL_UNLOCK; for(i = 0; i < inlen; i++) buf[i % sizeof(buf)] ^= in[i]; /* key 32 bytes, 20 rounds */ - if ((err = chacha_setup(&prng->chacha.s, buf, 32, 20)) != CRYPT_OK) goto LBL_UNLOCK; + if ((err = chacha_setup(&prng->u.chacha.s, buf, 32, 20)) != CRYPT_OK) goto LBL_UNLOCK; /* iv 8 bytes */ - if ((err = chacha_ivctr64(&prng->chacha.s, buf + 32, 8, 0)) != CRYPT_OK) goto LBL_UNLOCK; + if ((err = chacha_ivctr64(&prng->u.chacha.s, buf + 32, 8, 0)) != CRYPT_OK) goto LBL_UNLOCK; /* clear KEY + IV */ zeromem(buf, sizeof(buf)); } else { /* chacha20_prng_ready() was not called yet, add entropy to ent buffer */ - while (inlen--) prng->chacha.ent[prng->chacha.idx++ % sizeof(prng->chacha.ent)] ^= *in++; + while (inlen--) prng->u.chacha.ent[prng->u.chacha.idx++ % sizeof(prng->u.chacha.ent)] ^= *in++; } err = CRYPT_OK; LBL_UNLOCK: - LTC_MUTEX_UNLOCK(&prng->chacha.lock); + LTC_MUTEX_UNLOCK(&prng->lock); return err; } @@ -94,17 +94,17 @@ int chacha20_prng_ready(prng_state *prng) LTC_ARGCHK(prng != NULL); - LTC_MUTEX_LOCK(&prng->chacha.lock); - if (prng->chacha.ready) { err = CRYPT_OK; goto LBL_UNLOCK; } + LTC_MUTEX_LOCK(&prng->lock); + if (prng->ready) { err = CRYPT_OK; goto LBL_UNLOCK; } /* key 32 bytes, 20 rounds */ - if ((err = chacha_setup(&prng->chacha.s, prng->chacha.ent, 32, 20)) != CRYPT_OK) goto LBL_UNLOCK; + if ((err = chacha_setup(&prng->u.chacha.s, prng->u.chacha.ent, 32, 20)) != CRYPT_OK) goto LBL_UNLOCK; /* iv 8 bytes */ - if ((err = chacha_ivctr64(&prng->chacha.s, prng->chacha.ent + 32, 8, 0)) != CRYPT_OK) goto LBL_UNLOCK; - XMEMSET(&prng->chacha.ent, 0, sizeof(prng->chacha.ent)); - prng->chacha.idx = 0; - prng->chacha.ready = 1; + if ((err = chacha_ivctr64(&prng->u.chacha.s, prng->u.chacha.ent + 32, 8, 0)) != CRYPT_OK) goto LBL_UNLOCK; + XMEMSET(&prng->u.chacha.ent, 0, sizeof(prng->u.chacha.ent)); + prng->u.chacha.idx = 0; + prng->ready = 1; LBL_UNLOCK: - LTC_MUTEX_UNLOCK(&prng->chacha.lock); + LTC_MUTEX_UNLOCK(&prng->lock); return err; } @@ -118,11 +118,11 @@ LBL_UNLOCK: unsigned long chacha20_prng_read(unsigned char *out, unsigned long outlen, prng_state *prng) { if (outlen == 0 || prng == NULL || out == NULL) return 0; - LTC_MUTEX_LOCK(&prng->chacha.lock); - if (!prng->chacha.ready) { outlen = 0; goto LBL_UNLOCK; } - if (chacha_keystream(&prng->chacha.s, out, outlen) != CRYPT_OK) outlen = 0; + LTC_MUTEX_LOCK(&prng->lock); + if (!prng->ready) { outlen = 0; goto LBL_UNLOCK; } + if (chacha_keystream(&prng->u.chacha.s, out, outlen) != CRYPT_OK) outlen = 0; LBL_UNLOCK: - LTC_MUTEX_UNLOCK(&prng->chacha.lock); + LTC_MUTEX_UNLOCK(&prng->lock); return outlen; } @@ -135,11 +135,11 @@ int chacha20_prng_done(prng_state *prng) { int err; LTC_ARGCHK(prng != NULL); - LTC_MUTEX_LOCK(&prng->chacha.lock); - prng->chacha.ready = 0; - err = chacha_done(&prng->chacha.s); - LTC_MUTEX_UNLOCK(&prng->chacha.lock); - LTC_MUTEX_DESTROY(&prng->chacha.lock); + LTC_MUTEX_LOCK(&prng->lock); + prng->ready = 0; + err = chacha_done(&prng->u.chacha.s); + LTC_MUTEX_UNLOCK(&prng->lock); + LTC_MUTEX_DESTROY(&prng->lock); return err; } diff --git a/src/ltc/prngs/fortuna.c b/src/ltc/prngs/fortuna.c index 340cd037..ab56defc 100644 --- a/src/ltc/prngs/fortuna.c +++ b/src/ltc/prngs/fortuna.c @@ -6,12 +6,16 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" +#ifdef LTC_FORTUNA_RESEED_RATELIMIT_TIMED #if defined(_WIN32) #include <windows.h> +#elif defined(LTC_CLOCK_GETTIME) + #include <time.h> /* struct timespec + clock_gettime */ #else - #include <sys/time.h> + #include <sys/time.h> /* struct timeval + gettimeofday */ +#endif #endif /** @@ -60,7 +64,7 @@ static void _fortuna_update_iv(prng_state *prng) int x; unsigned char *IV; /* update IV */ - IV = prng->fortuna.IV; + IV = prng->u.fortuna.IV; for (x = 0; x < 16; x++) { IV[x] = (IV[x] + 1) & 255; if (IV[x] != 0) break; @@ -103,27 +107,27 @@ static int _fortuna_reseed(prng_state *prng) int err, x; #ifdef LTC_FORTUNA_RESEED_RATELIMIT_TIMED - unsigned long now = _fortuna_current_time(); - if (now == prng->fortuna.wd) + ulong64 now = _fortuna_current_time(); + if (now == prng->u.fortuna.wd) return CRYPT_OK; #else - if (++prng->fortuna.wd < LTC_FORTUNA_WD) + if (++prng->u.fortuna.wd < LTC_FORTUNA_WD) return CRYPT_OK; #endif /* new K == LTC_SHA256(K || s) where s == LTC_SHA256(P0) || LTC_SHA256(P1) ... */ sha256_init(&md); - if ((err = sha256_process(&md, prng->fortuna.K, 32)) != CRYPT_OK) { + if ((err = sha256_process(&md, prng->u.fortuna.K, 32)) != CRYPT_OK) { sha256_done(&md, tmp); return err; } - reset_cnt = prng->fortuna.reset_cnt + 1; + reset_cnt = prng->u.fortuna.reset_cnt + 1; for (x = 0; x < LTC_FORTUNA_POOLS; x++) { if (x == 0 || ((reset_cnt >> (x-1)) & 1) == 0) { /* terminate this hash */ - if ((err = sha256_done(&prng->fortuna.pool[x], tmp)) != CRYPT_OK) { + if ((err = sha256_done(&prng->u.fortuna.pool[x], tmp)) != CRYPT_OK) { sha256_done(&md, tmp); return err; } @@ -133,7 +137,7 @@ static int _fortuna_reseed(prng_state *prng) return err; } /* reset this pool */ - if ((err = sha256_init(&prng->fortuna.pool[x])) != CRYPT_OK) { + if ((err = sha256_init(&prng->u.fortuna.pool[x])) != CRYPT_OK) { sha256_done(&md, tmp); return err; } @@ -143,22 +147,22 @@ static int _fortuna_reseed(prng_state *prng) } /* finish key */ - if ((err = sha256_done(&md, prng->fortuna.K)) != CRYPT_OK) { + if ((err = sha256_done(&md, prng->u.fortuna.K)) != CRYPT_OK) { return err; } - if ((err = rijndael_setup(prng->fortuna.K, 32, 0, &prng->fortuna.skey)) != CRYPT_OK) { + if ((err = rijndael_setup(prng->u.fortuna.K, 32, 0, &prng->u.fortuna.skey)) != CRYPT_OK) { return err; } _fortuna_update_iv(prng); /* reset/update internals */ - prng->fortuna.pool0_len = 0; + prng->u.fortuna.pool0_len = 0; #ifdef LTC_FORTUNA_RESEED_RATELIMIT_TIMED - prng->fortuna.wd = now; + prng->u.fortuna.wd = now; #else - prng->fortuna.wd = 0; + prng->u.fortuna.wd = 0; #endif - prng->fortuna.reset_cnt = reset_cnt; + prng->u.fortuna.reset_cnt = reset_cnt; #ifdef LTC_CLEAN_STACK @@ -183,10 +187,10 @@ int fortuna_update_seed(const unsigned char *in, unsigned long inlen, prng_state unsigned char tmp[MAXBLOCKSIZE]; hash_state md; - LTC_MUTEX_LOCK(&prng->fortuna.lock); + LTC_MUTEX_LOCK(&prng->lock); /* new K = LTC_SHA256(K || in) */ sha256_init(&md); - if ((err = sha256_process(&md, prng->fortuna.K, 32)) != CRYPT_OK) { + if ((err = sha256_process(&md, prng->u.fortuna.K, 32)) != CRYPT_OK) { sha256_done(&md, tmp); goto LBL_UNLOCK; } @@ -195,13 +199,13 @@ int fortuna_update_seed(const unsigned char *in, unsigned long inlen, prng_state goto LBL_UNLOCK; } /* finish key */ - if ((err = sha256_done(&md, prng->fortuna.K)) != CRYPT_OK) { + if ((err = sha256_done(&md, prng->u.fortuna.K)) != CRYPT_OK) { goto LBL_UNLOCK; } _fortuna_update_iv(prng); LBL_UNLOCK: - LTC_MUTEX_UNLOCK(&prng->fortuna.lock); + LTC_MUTEX_UNLOCK(&prng->lock); #ifdef LTC_CLEAN_STACK zeromem(&md, sizeof(md)); #endif @@ -220,31 +224,31 @@ int fortuna_start(prng_state *prng) unsigned char tmp[MAXBLOCKSIZE]; LTC_ARGCHK(prng != NULL); - prng->fortuna.ready = 0; + prng->ready = 0; /* initialize the pools */ for (x = 0; x < LTC_FORTUNA_POOLS; x++) { - if ((err = sha256_init(&prng->fortuna.pool[x])) != CRYPT_OK) { + if ((err = sha256_init(&prng->u.fortuna.pool[x])) != CRYPT_OK) { for (y = 0; y < x; y++) { - sha256_done(&prng->fortuna.pool[y], tmp); + sha256_done(&prng->u.fortuna.pool[y], tmp); } return err; } } - prng->fortuna.pool_idx = prng->fortuna.pool0_len = prng->fortuna.wd = 0; - prng->fortuna.reset_cnt = 0; + prng->u.fortuna.pool_idx = prng->u.fortuna.pool0_len = prng->u.fortuna.wd = 0; + prng->u.fortuna.reset_cnt = 0; /* reset bufs */ - zeromem(prng->fortuna.K, 32); - if ((err = rijndael_setup(prng->fortuna.K, 32, 0, &prng->fortuna.skey)) != CRYPT_OK) { + zeromem(prng->u.fortuna.K, 32); + if ((err = rijndael_setup(prng->u.fortuna.K, 32, 0, &prng->u.fortuna.skey)) != CRYPT_OK) { for (x = 0; x < LTC_FORTUNA_POOLS; x++) { - sha256_done(&prng->fortuna.pool[x], tmp); + sha256_done(&prng->u.fortuna.pool[x], tmp); } return err; } - zeromem(prng->fortuna.IV, 16); + zeromem(prng->u.fortuna.IV, 16); - LTC_MUTEX_INIT(&prng->fortuna.lock) + LTC_MUTEX_INIT(&prng->lock) return CRYPT_OK; } @@ -263,14 +267,14 @@ static int _fortuna_add(unsigned long source, unsigned long pool, const unsigned tmp[0] = (unsigned char)source; tmp[1] = (unsigned char)inlen; - if ((err = sha256_process(&prng->fortuna.pool[pool], tmp, 2)) != CRYPT_OK) { + if ((err = sha256_process(&prng->u.fortuna.pool[pool], tmp, 2)) != CRYPT_OK) { return err; } - if ((err = sha256_process(&prng->fortuna.pool[pool], in, inlen)) != CRYPT_OK) { + if ((err = sha256_process(&prng->u.fortuna.pool[pool], in, inlen)) != CRYPT_OK) { return err; } if (pool == 0) { - prng->fortuna.pool0_len += inlen; + prng->u.fortuna.pool0_len += inlen; } return CRYPT_OK; /* success */ } @@ -294,11 +298,11 @@ int fortuna_add_random_event(unsigned long source, unsigned long pool, const uns LTC_ARGCHK(source <= 255); LTC_ARGCHK(pool < LTC_FORTUNA_POOLS); - LTC_MUTEX_LOCK(&prng->fortuna.lock); + LTC_MUTEX_LOCK(&prng->lock); err = _fortuna_add(source, pool, in, inlen, prng); - LTC_MUTEX_UNLOCK(&prng->fortuna.lock); + LTC_MUTEX_UNLOCK(&prng->lock); return err; } @@ -318,16 +322,16 @@ int fortuna_add_entropy(const unsigned char *in, unsigned long inlen, prng_state LTC_ARGCHK(in != NULL); LTC_ARGCHK(inlen > 0); - LTC_MUTEX_LOCK(&prng->fortuna.lock); + LTC_MUTEX_LOCK(&prng->lock); - err = _fortuna_add(0, prng->fortuna.pool_idx, in, inlen, prng); + err = _fortuna_add(0, prng->u.fortuna.pool_idx, in, inlen, prng); if (err == CRYPT_OK) { - ++(prng->fortuna.pool_idx); - prng->fortuna.pool_idx %= LTC_FORTUNA_POOLS; + ++(prng->u.fortuna.pool_idx); + prng->u.fortuna.pool_idx %= LTC_FORTUNA_POOLS; } - LTC_MUTEX_UNLOCK(&prng->fortuna.lock); + LTC_MUTEX_UNLOCK(&prng->lock); return err; } @@ -342,18 +346,18 @@ int fortuna_ready(prng_state *prng) int err; LTC_ARGCHK(prng != NULL); - LTC_MUTEX_LOCK(&prng->fortuna.lock); + LTC_MUTEX_LOCK(&prng->lock); /* make sure the reseed doesn't fail because * of the chosen rate limit */ #ifdef LTC_FORTUNA_RESEED_RATELIMIT_TIMED - prng->fortuna.wd = _fortuna_current_time() - 1; + prng->u.fortuna.wd = _fortuna_current_time() - 1; #else - prng->fortuna.wd = LTC_FORTUNA_WD; + prng->u.fortuna.wd = LTC_FORTUNA_WD; #endif err = _fortuna_reseed(prng); - prng->fortuna.ready = (err == CRYPT_OK) ? 1 : 0; + prng->ready = (err == CRYPT_OK) ? 1 : 0; - LTC_MUTEX_UNLOCK(&prng->fortuna.lock); + LTC_MUTEX_UNLOCK(&prng->lock); return err; } @@ -371,21 +375,21 @@ unsigned long fortuna_read(unsigned char *out, unsigned long outlen, prng_state if (outlen == 0 || prng == NULL || out == NULL) return 0; - LTC_MUTEX_LOCK(&prng->fortuna.lock); + LTC_MUTEX_LOCK(&prng->lock); - if (!prng->fortuna.ready) { + if (!prng->ready) { goto LBL_UNLOCK; } /* do we have to reseed? */ - if (prng->fortuna.pool0_len >= 64) { + if (prng->u.fortuna.pool0_len >= 64) { if (_fortuna_reseed(prng) != CRYPT_OK) { goto LBL_UNLOCK; } } /* ensure that one reseed happened before allowing to read */ - if (prng->fortuna.reset_cnt == 0) { + if (prng->u.fortuna.reset_cnt == 0) { goto LBL_UNLOCK; } @@ -395,7 +399,7 @@ unsigned long fortuna_read(unsigned char *out, unsigned long outlen, prng_state /* handle whole blocks without the extra XMEMCPY */ while (outlen >= 16) { /* encrypt the IV and store it */ - rijndael_ecb_encrypt(prng->fortuna.IV, out, &prng->fortuna.skey); + rijndael_ecb_encrypt(prng->u.fortuna.IV, out, &prng->u.fortuna.skey); out += 16; outlen -= 16; _fortuna_update_iv(prng); @@ -403,19 +407,19 @@ unsigned long fortuna_read(unsigned char *out, unsigned long outlen, prng_state /* left over bytes? */ if (outlen > 0) { - rijndael_ecb_encrypt(prng->fortuna.IV, tmp, &prng->fortuna.skey); + rijndael_ecb_encrypt(prng->u.fortuna.IV, tmp, &prng->u.fortuna.skey); XMEMCPY(out, tmp, outlen); _fortuna_update_iv(prng); } /* generate new key */ - rijndael_ecb_encrypt(prng->fortuna.IV, prng->fortuna.K , &prng->fortuna.skey); + rijndael_ecb_encrypt(prng->u.fortuna.IV, prng->u.fortuna.K , &prng->u.fortuna.skey); _fortuna_update_iv(prng); - rijndael_ecb_encrypt(prng->fortuna.IV, prng->fortuna.K+16, &prng->fortuna.skey); + rijndael_ecb_encrypt(prng->u.fortuna.IV, prng->u.fortuna.K+16, &prng->u.fortuna.skey); _fortuna_update_iv(prng); - if (rijndael_setup(prng->fortuna.K, 32, 0, &prng->fortuna.skey) != CRYPT_OK) { + if (rijndael_setup(prng->u.fortuna.K, 32, 0, &prng->u.fortuna.skey) != CRYPT_OK) { tlen = 0; } @@ -423,7 +427,7 @@ LBL_UNLOCK: #ifdef LTC_CLEAN_STACK zeromem(tmp, sizeof(tmp)); #endif - LTC_MUTEX_UNLOCK(&prng->fortuna.lock); + LTC_MUTEX_UNLOCK(&prng->lock); return tlen; } @@ -439,12 +443,12 @@ int fortuna_done(prng_state *prng) LTC_ARGCHK(prng != NULL); - LTC_MUTEX_LOCK(&prng->fortuna.lock); - prng->fortuna.ready = 0; + LTC_MUTEX_LOCK(&prng->lock); + prng->ready = 0; /* terminate all the hashes */ for (x = 0; x < LTC_FORTUNA_POOLS; x++) { - if ((err = sha256_done(&(prng->fortuna.pool[x]), tmp)) != CRYPT_OK) { + if ((err = sha256_done(&(prng->u.fortuna.pool[x]), tmp)) != CRYPT_OK) { goto LBL_UNLOCK; } } @@ -455,8 +459,8 @@ LBL_UNLOCK: #ifdef LTC_CLEAN_STACK zeromem(tmp, sizeof(tmp)); #endif - LTC_MUTEX_UNLOCK(&prng->fortuna.lock); - LTC_MUTEX_DESTROY(&prng->fortuna.lock); + LTC_MUTEX_UNLOCK(&prng->lock); + LTC_MUTEX_DESTROY(&prng->lock); return err; } diff --git a/src/ltc/prngs/rc4.c b/src/ltc/prngs/rc4.c index b55ad9da..30007619 100644 --- a/src/ltc/prngs/rc4.c +++ b/src/ltc/prngs/rc4.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file prngs/rc4.c @@ -37,12 +37,12 @@ const struct ltc_prng_descriptor rc4_desc = int rc4_start(prng_state *prng) { LTC_ARGCHK(prng != NULL); - prng->rc4.ready = 0; + prng->ready = 0; /* set entropy (key) size to zero */ - prng->rc4.s.x = 0; + prng->u.rc4.s.x = 0; /* clear entropy (key) buffer */ - XMEMSET(&prng->rc4.s.buf, 0, sizeof(prng->rc4.s.buf)); - LTC_MUTEX_INIT(&prng->rc4.lock) + XMEMSET(&prng->u.rc4.s.buf, 0, sizeof(prng->u.rc4.s.buf)); + LTC_MUTEX_INIT(&prng->lock) return CRYPT_OK; } @@ -63,24 +63,24 @@ int rc4_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *pr LTC_ARGCHK(in != NULL); LTC_ARGCHK(inlen > 0); - LTC_MUTEX_LOCK(&prng->rc4.lock); - if (prng->rc4.ready) { + LTC_MUTEX_LOCK(&prng->lock); + if (prng->ready) { /* rc4_ready() was already called, do "rekey" operation */ - if ((err = rc4_stream_keystream(&prng->rc4.s, buf, sizeof(buf))) != CRYPT_OK) goto LBL_UNLOCK; + if ((err = rc4_stream_keystream(&prng->u.rc4.s, buf, sizeof(buf))) != CRYPT_OK) goto LBL_UNLOCK; for(i = 0; i < inlen; i++) buf[i % sizeof(buf)] ^= in[i]; /* initialize RC4 */ - if ((err = rc4_stream_setup(&prng->rc4.s, buf, sizeof(buf))) != CRYPT_OK) goto LBL_UNLOCK; + if ((err = rc4_stream_setup(&prng->u.rc4.s, buf, sizeof(buf))) != CRYPT_OK) goto LBL_UNLOCK; /* drop first 3072 bytes - https://en.wikipedia.org/wiki/RC4#Fluhrer.2C_Mantin_and_Shamir_attack */ - for (i = 0; i < 12; i++) rc4_stream_keystream(&prng->rc4.s, buf, sizeof(buf)); + for (i = 0; i < 12; i++) rc4_stream_keystream(&prng->u.rc4.s, buf, sizeof(buf)); zeromem(buf, sizeof(buf)); } else { /* rc4_ready() was not called yet, add entropy to the buffer */ - while (inlen--) prng->rc4.s.buf[prng->rc4.s.x++ % sizeof(prng->rc4.s.buf)] ^= *in++; + while (inlen--) prng->u.rc4.s.buf[prng->u.rc4.s.x++ % sizeof(prng->u.rc4.s.buf)] ^= *in++; } err = CRYPT_OK; LBL_UNLOCK: - LTC_MUTEX_UNLOCK(&prng->rc4.lock); + LTC_MUTEX_UNLOCK(&prng->lock); return err; } @@ -97,17 +97,17 @@ int rc4_ready(prng_state *prng) LTC_ARGCHK(prng != NULL); - LTC_MUTEX_LOCK(&prng->rc4.lock); - if (prng->rc4.ready) { err = CRYPT_OK; goto LBL_UNLOCK; } - XMEMCPY(buf, prng->rc4.s.buf, sizeof(buf)); + LTC_MUTEX_LOCK(&prng->lock); + if (prng->ready) { err = CRYPT_OK; goto LBL_UNLOCK; } + XMEMCPY(buf, prng->u.rc4.s.buf, sizeof(buf)); /* initialize RC4 */ - len = MIN(prng->rc4.s.x, 256); /* TODO: we can perhaps always use all 256 bytes */ - if ((err = rc4_stream_setup(&prng->rc4.s, buf, len)) != CRYPT_OK) goto LBL_UNLOCK; + len = MIN(prng->u.rc4.s.x, 256); /* TODO: we can perhaps always use all 256 bytes */ + if ((err = rc4_stream_setup(&prng->u.rc4.s, buf, len)) != CRYPT_OK) goto LBL_UNLOCK; /* drop first 3072 bytes - https://en.wikipedia.org/wiki/RC4#Fluhrer.2C_Mantin_and_Shamir_attack */ - for (i = 0; i < 12; i++) rc4_stream_keystream(&prng->rc4.s, buf, sizeof(buf)); - prng->rc4.ready = 1; + for (i = 0; i < 12; i++) rc4_stream_keystream(&prng->u.rc4.s, buf, sizeof(buf)); + prng->ready = 1; LBL_UNLOCK: - LTC_MUTEX_UNLOCK(&prng->rc4.lock); + LTC_MUTEX_UNLOCK(&prng->lock); return err; } @@ -121,11 +121,11 @@ LBL_UNLOCK: unsigned long rc4_read(unsigned char *out, unsigned long outlen, prng_state *prng) { if (outlen == 0 || prng == NULL || out == NULL) return 0; - LTC_MUTEX_LOCK(&prng->rc4.lock); - if (!prng->rc4.ready) { outlen = 0; goto LBL_UNLOCK; } - if (rc4_stream_keystream(&prng->rc4.s, out, outlen) != CRYPT_OK) outlen = 0; + LTC_MUTEX_LOCK(&prng->lock); + if (!prng->ready) { outlen = 0; goto LBL_UNLOCK; } + if (rc4_stream_keystream(&prng->u.rc4.s, out, outlen) != CRYPT_OK) outlen = 0; LBL_UNLOCK: - LTC_MUTEX_UNLOCK(&prng->rc4.lock); + LTC_MUTEX_UNLOCK(&prng->lock); return outlen; } @@ -138,11 +138,11 @@ int rc4_done(prng_state *prng) { int err; LTC_ARGCHK(prng != NULL); - LTC_MUTEX_LOCK(&prng->rc4.lock); - prng->rc4.ready = 0; - err = rc4_stream_done(&prng->rc4.s); - LTC_MUTEX_UNLOCK(&prng->rc4.lock); - LTC_MUTEX_DESTROY(&prng->rc4.lock); + LTC_MUTEX_LOCK(&prng->lock); + prng->ready = 0; + err = rc4_stream_done(&prng->u.rc4.s); + LTC_MUTEX_UNLOCK(&prng->lock); + LTC_MUTEX_DESTROY(&prng->lock); return err; } diff --git a/src/ltc/prngs/rng_get_bytes.c b/src/ltc/prngs/rng_get_bytes.c index 4e9a0634..10b3cadd 100644 --- a/src/ltc/prngs/rng_get_bytes.c +++ b/src/ltc/prngs/rng_get_bytes.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_RNG_GET_BYTES /** diff --git a/src/ltc/prngs/rng_make_prng.c b/src/ltc/prngs/rng_make_prng.c index 19ac1ee3..fba06947 100644 --- a/src/ltc/prngs/rng_make_prng.c +++ b/src/ltc/prngs/rng_make_prng.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_RNG_MAKE_PRNG /** diff --git a/src/ltc/prngs/sober128.c b/src/ltc/prngs/sober128.c index 9947cac8..e194fdd2 100644 --- a/src/ltc/prngs/sober128.c +++ b/src/ltc/prngs/sober128.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file prngs/sober128.c @@ -39,10 +39,10 @@ const struct ltc_prng_descriptor sober128_desc = int sober128_start(prng_state *prng) { LTC_ARGCHK(prng != NULL); - prng->sober128.ready = 0; - XMEMSET(&prng->sober128.ent, 0, sizeof(prng->sober128.ent)); - prng->sober128.idx = 0; - LTC_MUTEX_INIT(&prng->sober128.lock) + prng->ready = 0; + XMEMSET(&prng->u.sober128.ent, 0, sizeof(prng->u.sober128.ent)); + prng->u.sober128.idx = 0; + LTC_MUTEX_INIT(&prng->lock) return CRYPT_OK; } @@ -63,25 +63,25 @@ int sober128_add_entropy(const unsigned char *in, unsigned long inlen, prng_stat LTC_ARGCHK(in != NULL); LTC_ARGCHK(inlen > 0); - LTC_MUTEX_LOCK(&prng->sober128.lock); - if (prng->sober128.ready) { + LTC_MUTEX_LOCK(&prng->lock); + if (prng->ready) { /* sober128_ready() was already called, do "rekey" operation */ - if ((err = sober128_stream_keystream(&prng->sober128.s, buf, sizeof(buf))) != CRYPT_OK) goto LBL_UNLOCK; + if ((err = sober128_stream_keystream(&prng->u.sober128.s, buf, sizeof(buf))) != CRYPT_OK) goto LBL_UNLOCK; for(i = 0; i < inlen; i++) buf[i % sizeof(buf)] ^= in[i]; /* key 32 bytes, 20 rounds */ - if ((err = sober128_stream_setup(&prng->sober128.s, buf, 32)) != CRYPT_OK) goto LBL_UNLOCK; + if ((err = sober128_stream_setup(&prng->u.sober128.s, buf, 32)) != CRYPT_OK) goto LBL_UNLOCK; /* iv 8 bytes */ - if ((err = sober128_stream_setiv(&prng->sober128.s, buf + 32, 8)) != CRYPT_OK) goto LBL_UNLOCK; + if ((err = sober128_stream_setiv(&prng->u.sober128.s, buf + 32, 8)) != CRYPT_OK) goto LBL_UNLOCK; /* clear KEY + IV */ zeromem(buf, sizeof(buf)); } else { /* sober128_ready() was not called yet, add entropy to ent buffer */ - while (inlen--) prng->sober128.ent[prng->sober128.idx++ % sizeof(prng->sober128.ent)] ^= *in++; + while (inlen--) prng->u.sober128.ent[prng->u.sober128.idx++ % sizeof(prng->u.sober128.ent)] ^= *in++; } err = CRYPT_OK; LBL_UNLOCK: - LTC_MUTEX_UNLOCK(&prng->sober128.lock); + LTC_MUTEX_UNLOCK(&prng->lock); return err; } @@ -96,17 +96,17 @@ int sober128_ready(prng_state *prng) LTC_ARGCHK(prng != NULL); - LTC_MUTEX_LOCK(&prng->sober128.lock); - if (prng->sober128.ready) { err = CRYPT_OK; goto LBL_UNLOCK; } + LTC_MUTEX_LOCK(&prng->lock); + if (prng->ready) { err = CRYPT_OK; goto LBL_UNLOCK; } /* key 32 bytes, 20 rounds */ - if ((err = sober128_stream_setup(&prng->sober128.s, prng->sober128.ent, 32)) != CRYPT_OK) goto LBL_UNLOCK; + if ((err = sober128_stream_setup(&prng->u.sober128.s, prng->u.sober128.ent, 32)) != CRYPT_OK) goto LBL_UNLOCK; /* iv 8 bytes */ - if ((err = sober128_stream_setiv(&prng->sober128.s, prng->sober128.ent + 32, 8)) != CRYPT_OK) goto LBL_UNLOCK; - XMEMSET(&prng->sober128.ent, 0, sizeof(prng->sober128.ent)); - prng->sober128.idx = 0; - prng->sober128.ready = 1; + if ((err = sober128_stream_setiv(&prng->u.sober128.s, prng->u.sober128.ent + 32, 8)) != CRYPT_OK) goto LBL_UNLOCK; + XMEMSET(&prng->u.sober128.ent, 0, sizeof(prng->u.sober128.ent)); + prng->u.sober128.idx = 0; + prng->ready = 1; LBL_UNLOCK: - LTC_MUTEX_UNLOCK(&prng->sober128.lock); + LTC_MUTEX_UNLOCK(&prng->lock); return err; } @@ -120,11 +120,11 @@ LBL_UNLOCK: unsigned long sober128_read(unsigned char *out, unsigned long outlen, prng_state *prng) { if (outlen == 0 || prng == NULL || out == NULL) return 0; - LTC_MUTEX_LOCK(&prng->sober128.lock); - if (!prng->sober128.ready) { outlen = 0; goto LBL_UNLOCK; } - if (sober128_stream_keystream(&prng->sober128.s, out, outlen) != CRYPT_OK) outlen = 0; + LTC_MUTEX_LOCK(&prng->lock); + if (!prng->ready) { outlen = 0; goto LBL_UNLOCK; } + if (sober128_stream_keystream(&prng->u.sober128.s, out, outlen) != CRYPT_OK) outlen = 0; LBL_UNLOCK: - LTC_MUTEX_UNLOCK(&prng->sober128.lock); + LTC_MUTEX_UNLOCK(&prng->lock); return outlen; } @@ -137,11 +137,11 @@ int sober128_done(prng_state *prng) { int err; LTC_ARGCHK(prng != NULL); - LTC_MUTEX_LOCK(&prng->sober128.lock); - prng->sober128.ready = 0; - err = sober128_stream_done(&prng->sober128.s); - LTC_MUTEX_UNLOCK(&prng->sober128.lock); - LTC_MUTEX_DESTROY(&prng->sober128.lock); + LTC_MUTEX_LOCK(&prng->lock); + prng->ready = 0; + err = sober128_stream_done(&prng->u.sober128.s); + LTC_MUTEX_UNLOCK(&prng->lock); + LTC_MUTEX_DESTROY(&prng->lock); return err; } diff --git a/src/ltc/prngs/sprng.c b/src/ltc/prngs/sprng.c index b74d8da7..a5876065 100644 --- a/src/ltc/prngs/sprng.c +++ b/src/ltc/prngs/sprng.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file sprng.c diff --git a/src/ltc/prngs/yarrow.c b/src/ltc/prngs/yarrow.c index 7d3adb55..c9d13de1 100644 --- a/src/ltc/prngs/yarrow.c +++ b/src/ltc/prngs/yarrow.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file yarrow.c @@ -38,88 +38,88 @@ int yarrow_start(prng_state *prng) int err; LTC_ARGCHK(prng != NULL); - prng->yarrow.ready = 0; + prng->ready = 0; /* these are the default hash/cipher combo used */ #ifdef LTC_RIJNDAEL #if LTC_YARROW_AES==0 - prng->yarrow.cipher = register_cipher(&rijndael_enc_desc); + prng->u.yarrow.cipher = register_cipher(&rijndael_enc_desc); #elif LTC_YARROW_AES==1 - prng->yarrow.cipher = register_cipher(&aes_enc_desc); + prng->u.yarrow.cipher = register_cipher(&aes_enc_desc); #elif LTC_YARROW_AES==2 - prng->yarrow.cipher = register_cipher(&rijndael_desc); + prng->u.yarrow.cipher = register_cipher(&rijndael_desc); #elif LTC_YARROW_AES==3 - prng->yarrow.cipher = register_cipher(&aes_desc); + prng->u.yarrow.cipher = register_cipher(&aes_desc); #endif #elif defined(LTC_BLOWFISH) - prng->yarrow.cipher = register_cipher(&blowfish_desc); + prng->u.yarrow.cipher = register_cipher(&blowfish_desc); #elif defined(LTC_TWOFISH) - prng->yarrow.cipher = register_cipher(&twofish_desc); + prng->u.yarrow.cipher = register_cipher(&twofish_desc); #elif defined(LTC_RC6) - prng->yarrow.cipher = register_cipher(&rc6_desc); + prng->u.yarrow.cipher = register_cipher(&rc6_desc); #elif defined(LTC_RC5) - prng->yarrow.cipher = register_cipher(&rc5_desc); + prng->u.yarrow.cipher = register_cipher(&rc5_desc); #elif defined(LTC_SAFERP) - prng->yarrow.cipher = register_cipher(&saferp_desc); + prng->u.yarrow.cipher = register_cipher(&saferp_desc); #elif defined(LTC_RC2) - prng->yarrow.cipher = register_cipher(&rc2_desc); + prng->u.yarrow.cipher = register_cipher(&rc2_desc); #elif defined(LTC_NOEKEON) - prng->yarrow.cipher = register_cipher(&noekeon_desc); + prng->u.yarrow.cipher = register_cipher(&noekeon_desc); #elif defined(LTC_ANUBIS) - prng->yarrow.cipher = register_cipher(&anubis_desc); + prng->u.yarrow.cipher = register_cipher(&anubis_desc); #elif defined(LTC_KSEED) - prng->yarrow.cipher = register_cipher(&kseed_desc); + prng->u.yarrow.cipher = register_cipher(&kseed_desc); #elif defined(LTC_KHAZAD) - prng->yarrow.cipher = register_cipher(&khazad_desc); + prng->u.yarrow.cipher = register_cipher(&khazad_desc); #elif defined(LTC_CAST5) - prng->yarrow.cipher = register_cipher(&cast5_desc); + prng->u.yarrow.cipher = register_cipher(&cast5_desc); #elif defined(LTC_XTEA) - prng->yarrow.cipher = register_cipher(&xtea_desc); + prng->u.yarrow.cipher = register_cipher(&xtea_desc); #elif defined(LTC_SAFER) - prng->yarrow.cipher = register_cipher(&safer_sk128_desc); + prng->u.yarrow.cipher = register_cipher(&safer_sk128_desc); #elif defined(LTC_DES) - prng->yarrow.cipher = register_cipher(&des3_desc); + prng->u.yarrow.cipher = register_cipher(&des3_desc); #else #error LTC_YARROW needs at least one CIPHER #endif - if ((err = cipher_is_valid(prng->yarrow.cipher)) != CRYPT_OK) { + if ((err = cipher_is_valid(prng->u.yarrow.cipher)) != CRYPT_OK) { return err; } #ifdef LTC_SHA256 - prng->yarrow.hash = register_hash(&sha256_desc); + prng->u.yarrow.hash = register_hash(&sha256_desc); #elif defined(LTC_SHA512) - prng->yarrow.hash = register_hash(&sha512_desc); + prng->u.yarrow.hash = register_hash(&sha512_desc); #elif defined(LTC_TIGER) - prng->yarrow.hash = register_hash(&tiger_desc); + prng->u.yarrow.hash = register_hash(&tiger_desc); #elif defined(LTC_SHA1) - prng->yarrow.hash = register_hash(&sha1_desc); + prng->u.yarrow.hash = register_hash(&sha1_desc); #elif defined(LTC_RIPEMD320) - prng->yarrow.hash = register_hash(&rmd320_desc); + prng->u.yarrow.hash = register_hash(&rmd320_desc); #elif defined(LTC_RIPEMD256) - prng->yarrow.hash = register_hash(&rmd256_desc); + prng->u.yarrow.hash = register_hash(&rmd256_desc); #elif defined(LTC_RIPEMD160) - prng->yarrow.hash = register_hash(&rmd160_desc); + prng->u.yarrow.hash = register_hash(&rmd160_desc); #elif defined(LTC_RIPEMD128) - prng->yarrow.hash = register_hash(&rmd128_desc); + prng->u.yarrow.hash = register_hash(&rmd128_desc); #elif defined(LTC_MD5) - prng->yarrow.hash = register_hash(&md5_desc); + prng->u.yarrow.hash = register_hash(&md5_desc); #elif defined(LTC_MD4) - prng->yarrow.hash = register_hash(&md4_desc); + prng->u.yarrow.hash = register_hash(&md4_desc); #elif defined(LTC_MD2) - prng->yarrow.hash = register_hash(&md2_desc); + prng->u.yarrow.hash = register_hash(&md2_desc); #elif defined(LTC_WHIRLPOOL) - prng->yarrow.hash = register_hash(&whirlpool_desc); + prng->u.yarrow.hash = register_hash(&whirlpool_desc); #else #error LTC_YARROW needs at least one HASH #endif - if ((err = hash_is_valid(prng->yarrow.hash)) != CRYPT_OK) { + if ((err = hash_is_valid(prng->u.yarrow.hash)) != CRYPT_OK) { return err; } /* zero the memory used */ - zeromem(prng->yarrow.pool, sizeof(prng->yarrow.pool)); - LTC_MUTEX_INIT(&prng->yarrow.lock) + zeromem(prng->u.yarrow.pool, sizeof(prng->u.yarrow.pool)); + LTC_MUTEX_INIT(&prng->lock) return CRYPT_OK; } @@ -140,33 +140,33 @@ int yarrow_add_entropy(const unsigned char *in, unsigned long inlen, prng_state LTC_ARGCHK(in != NULL); LTC_ARGCHK(inlen > 0); - LTC_MUTEX_LOCK(&prng->yarrow.lock); + LTC_MUTEX_LOCK(&prng->lock); - if ((err = hash_is_valid(prng->yarrow.hash)) != CRYPT_OK) { + if ((err = hash_is_valid(prng->u.yarrow.hash)) != CRYPT_OK) { goto LBL_UNLOCK; } /* start the hash */ - if ((err = hash_descriptor[prng->yarrow.hash].init(&md)) != CRYPT_OK) { + if ((err = hash_descriptor[prng->u.yarrow.hash].init(&md)) != CRYPT_OK) { goto LBL_UNLOCK; } /* hash the current pool */ - if ((err = hash_descriptor[prng->yarrow.hash].process(&md, prng->yarrow.pool, - hash_descriptor[prng->yarrow.hash].hashsize)) != CRYPT_OK) { + if ((err = hash_descriptor[prng->u.yarrow.hash].process(&md, prng->u.yarrow.pool, + hash_descriptor[prng->u.yarrow.hash].hashsize)) != CRYPT_OK) { goto LBL_UNLOCK; } /* add the new entropy */ - if ((err = hash_descriptor[prng->yarrow.hash].process(&md, in, inlen)) != CRYPT_OK) { + if ((err = hash_descriptor[prng->u.yarrow.hash].process(&md, in, inlen)) != CRYPT_OK) { goto LBL_UNLOCK; } /* store result */ - err = hash_descriptor[prng->yarrow.hash].done(&md, prng->yarrow.pool); + err = hash_descriptor[prng->u.yarrow.hash].done(&md, prng->u.yarrow.pool); LBL_UNLOCK: - LTC_MUTEX_UNLOCK(&prng->yarrow.lock); + LTC_MUTEX_UNLOCK(&prng->lock); return err; } @@ -181,34 +181,34 @@ int yarrow_ready(prng_state *prng) LTC_ARGCHK(prng != NULL); - LTC_MUTEX_LOCK(&prng->yarrow.lock); + LTC_MUTEX_LOCK(&prng->lock); - if ((err = hash_is_valid(prng->yarrow.hash)) != CRYPT_OK) { + if ((err = hash_is_valid(prng->u.yarrow.hash)) != CRYPT_OK) { goto LBL_UNLOCK; } - if ((err = cipher_is_valid(prng->yarrow.cipher)) != CRYPT_OK) { + if ((err = cipher_is_valid(prng->u.yarrow.cipher)) != CRYPT_OK) { goto LBL_UNLOCK; } /* setup CTR mode using the "pool" as the key */ - ks = (int)hash_descriptor[prng->yarrow.hash].hashsize; - if ((err = cipher_descriptor[prng->yarrow.cipher].keysize(&ks)) != CRYPT_OK) { + ks = (int)hash_descriptor[prng->u.yarrow.hash].hashsize; + if ((err = cipher_descriptor[prng->u.yarrow.cipher].keysize(&ks)) != CRYPT_OK) { goto LBL_UNLOCK; } - if ((err = ctr_start(prng->yarrow.cipher, /* what cipher to use */ - prng->yarrow.pool, /* IV */ - prng->yarrow.pool, ks, /* KEY and key size */ + if ((err = ctr_start(prng->u.yarrow.cipher, /* what cipher to use */ + prng->u.yarrow.pool, /* IV */ + prng->u.yarrow.pool, ks, /* KEY and key size */ 0, /* number of rounds */ CTR_COUNTER_LITTLE_ENDIAN, /* little endian counter */ - &prng->yarrow.ctr)) != CRYPT_OK) { + &prng->u.yarrow.ctr)) != CRYPT_OK) { goto LBL_UNLOCK; } - prng->yarrow.ready = 1; + prng->ready = 1; LBL_UNLOCK: - LTC_MUTEX_UNLOCK(&prng->yarrow.lock); + LTC_MUTEX_UNLOCK(&prng->lock); return err; } @@ -223,9 +223,9 @@ unsigned long yarrow_read(unsigned char *out, unsigned long outlen, prng_state * { if (outlen == 0 || prng == NULL || out == NULL) return 0; - LTC_MUTEX_LOCK(&prng->yarrow.lock); + LTC_MUTEX_LOCK(&prng->lock); - if (!prng->yarrow.ready) { + if (!prng->ready) { outlen = 0; goto LBL_UNLOCK; } @@ -234,12 +234,12 @@ unsigned long yarrow_read(unsigned char *out, unsigned long outlen, prng_state * zeromem(out, outlen); /* now randomize it */ - if (ctr_encrypt(out, out, outlen, &prng->yarrow.ctr) != CRYPT_OK) { + if (ctr_encrypt(out, out, outlen, &prng->u.yarrow.ctr) != CRYPT_OK) { outlen = 0; } LBL_UNLOCK: - LTC_MUTEX_UNLOCK(&prng->yarrow.lock); + LTC_MUTEX_UNLOCK(&prng->lock); return outlen; } @@ -253,16 +253,16 @@ int yarrow_done(prng_state *prng) int err; LTC_ARGCHK(prng != NULL); - LTC_MUTEX_LOCK(&prng->yarrow.lock); - prng->yarrow.ready = 0; + LTC_MUTEX_LOCK(&prng->lock); + prng->ready = 0; /* call cipher done when we invent one ;-) */ /* we invented one */ - err = ctr_done(&prng->yarrow.ctr); + err = ctr_done(&prng->u.yarrow.ctr); - LTC_MUTEX_UNLOCK(&prng->yarrow.lock); - LTC_MUTEX_DESTROY(&prng->yarrow.lock); + LTC_MUTEX_UNLOCK(&prng->lock); + LTC_MUTEX_DESTROY(&prng->lock); return err; } @@ -312,12 +312,12 @@ int yarrow_test(void) } /* now let's test the hash/cipher that was chosen */ - if (cipher_descriptor[prng.yarrow.cipher].test && - ((err = cipher_descriptor[prng.yarrow.cipher].test()) != CRYPT_OK)) { + if (cipher_descriptor[prng.u.yarrow.cipher].test && + ((err = cipher_descriptor[prng.u.yarrow.cipher].test()) != CRYPT_OK)) { return err; } - if (hash_descriptor[prng.yarrow.hash].test && - ((err = hash_descriptor[prng.yarrow.hash].test()) != CRYPT_OK)) { + if (hash_descriptor[prng.u.yarrow.hash].test && + ((err = hash_descriptor[prng.u.yarrow.hash].test()) != CRYPT_OK)) { return err; } diff --git a/src/ltc/stream/chacha/chacha_crypt.c b/src/ltc/stream/chacha/chacha_crypt.c index 6814058f..d72c84e7 100644 --- a/src/ltc/stream/chacha/chacha_crypt.c +++ b/src/ltc/stream/chacha/chacha_crypt.c @@ -12,7 +12,7 @@ * Public domain from D. J. Bernstein */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CHACHA diff --git a/src/ltc/stream/chacha/chacha_done.c b/src/ltc/stream/chacha/chacha_done.c index 9f0196e2..dbf6f246 100644 --- a/src/ltc/stream/chacha/chacha_done.c +++ b/src/ltc/stream/chacha/chacha_done.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CHACHA diff --git a/src/ltc/stream/chacha/chacha_ivctr32.c b/src/ltc/stream/chacha/chacha_ivctr32.c index c9a6dbb5..72856a09 100644 --- a/src/ltc/stream/chacha/chacha_ivctr32.c +++ b/src/ltc/stream/chacha/chacha_ivctr32.c @@ -12,7 +12,7 @@ * Public domain from D. J. Bernstein */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CHACHA diff --git a/src/ltc/stream/chacha/chacha_ivctr64.c b/src/ltc/stream/chacha/chacha_ivctr64.c index 643d11fe..f7cf721f 100644 --- a/src/ltc/stream/chacha/chacha_ivctr64.c +++ b/src/ltc/stream/chacha/chacha_ivctr64.c @@ -12,7 +12,7 @@ * Public domain from D. J. Bernstein */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CHACHA diff --git a/src/ltc/stream/chacha/chacha_keystream.c b/src/ltc/stream/chacha/chacha_keystream.c index 25eb63ad..e399d087 100644 --- a/src/ltc/stream/chacha/chacha_keystream.c +++ b/src/ltc/stream/chacha/chacha_keystream.c @@ -12,7 +12,7 @@ * Public domain from D. J. Bernstein */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CHACHA diff --git a/src/ltc/stream/chacha/chacha_setup.c b/src/ltc/stream/chacha/chacha_setup.c index e34370b8..e997fc95 100644 --- a/src/ltc/stream/chacha/chacha_setup.c +++ b/src/ltc/stream/chacha/chacha_setup.c @@ -12,7 +12,7 @@ * Public domain from D. J. Bernstein */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_CHACHA diff --git a/src/ltc/stream/rabbit/rabbit.c b/src/ltc/stream/rabbit/rabbit.c index cf6ec0b8..4607bc9e 100644 --- a/src/ltc/stream/rabbit/rabbit.c +++ b/src/ltc/stream/rabbit/rabbit.c @@ -62,7 +62,7 @@ ******************************************************************************/ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_RABBIT diff --git a/src/ltc/stream/rc4/rc4_stream.c b/src/ltc/stream/rc4/rc4_stream.c index 178489d7..f1c225d0 100644 --- a/src/ltc/stream/rc4/rc4_stream.c +++ b/src/ltc/stream/rc4/rc4_stream.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_RC4_STREAM diff --git a/src/ltc/stream/salsa20/salsa20_crypt.c b/src/ltc/stream/salsa20/salsa20_crypt.c index 9bf20532..bf1b0016 100644 --- a/src/ltc/stream/salsa20/salsa20_crypt.c +++ b/src/ltc/stream/salsa20/salsa20_crypt.c @@ -13,7 +13,7 @@ * Public domain from D. J. Bernstein */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_SALSA20 @@ -62,7 +62,7 @@ int salsa20_crypt(salsa20_state *st, const unsigned char *in, unsigned long inle LTC_ARGCHK(st != NULL); LTC_ARGCHK(in != NULL); LTC_ARGCHK(out != NULL); - LTC_ARGCHK(st->ivlen == 8); + LTC_ARGCHK(st->ivlen == 8 || st->ivlen == 24); if (st->ksleft > 0) { j = MIN(st->ksleft, inlen); diff --git a/src/ltc/stream/salsa20/salsa20_done.c b/src/ltc/stream/salsa20/salsa20_done.c index 4b7a9f90..086f263a 100644 --- a/src/ltc/stream/salsa20/salsa20_done.c +++ b/src/ltc/stream/salsa20/salsa20_done.c @@ -7,7 +7,7 @@ * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_SALSA20 diff --git a/src/ltc/stream/salsa20/salsa20_ivctr64.c b/src/ltc/stream/salsa20/salsa20_ivctr64.c index 06771533..9c7ac74f 100644 --- a/src/ltc/stream/salsa20/salsa20_ivctr64.c +++ b/src/ltc/stream/salsa20/salsa20_ivctr64.c @@ -13,7 +13,7 @@ * Public domain from D. J. Bernstein */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_SALSA20 diff --git a/src/ltc/stream/salsa20/salsa20_keystream.c b/src/ltc/stream/salsa20/salsa20_keystream.c index c443a3e4..dddfeaa1 100644 --- a/src/ltc/stream/salsa20/salsa20_keystream.c +++ b/src/ltc/stream/salsa20/salsa20_keystream.c @@ -13,7 +13,7 @@ * Public domain from D. J. Bernstein */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_SALSA20 diff --git a/src/ltc/stream/salsa20/salsa20_setup.c b/src/ltc/stream/salsa20/salsa20_setup.c index 6eb65e81..872bd121 100644 --- a/src/ltc/stream/salsa20/salsa20_setup.c +++ b/src/ltc/stream/salsa20/salsa20_setup.c @@ -13,7 +13,7 @@ * Public domain from D. J. Bernstein */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_SALSA20 diff --git a/src/ltc/stream/salsa20/xsalsa20_setup.c b/src/ltc/stream/salsa20/xsalsa20_setup.c new file mode 100644 index 00000000..94133a7f --- /dev/null +++ b/src/ltc/stream/salsa20/xsalsa20_setup.c @@ -0,0 +1,137 @@ +/* LibTomCrypt, modular cryptographic library -- Tom St Denis + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + */ + +/* The implementation is based on: + * "Extending the Salsa20 nonce", https://cr.yp.to/snuffle/xsalsa-20081128.pdf + * "Salsa20 specification", http://cr.yp.to/snuffle/spec.pdf + * and salsa20-ref.c version 20051118 + * Public domain from D. J. Bernstein + */ + +#include "tomcrypt.h" + +#ifdef LTC_XSALSA20 + +static const char * const constants = "expand 32-byte k"; + +#define QUARTERROUND(a,b,c,d) \ + x[b] ^= (ROL((x[a] + x[d]), 7)); \ + x[c] ^= (ROL((x[b] + x[a]), 9)); \ + x[d] ^= (ROL((x[c] + x[b]), 13)); \ + x[a] ^= (ROL((x[d] + x[c]), 18)); + +/* use modified salsa20 doubleround (no final addition as in salsa20) */ +static void _xsalsa20_doubleround(ulong32 *x, int rounds) +{ + int i; + + for (i = rounds; i > 0; i -= 2) { + /* columnround */ + QUARTERROUND( 0, 4, 8,12) + QUARTERROUND( 5, 9,13, 1) + QUARTERROUND(10,14, 2, 6) + QUARTERROUND(15, 3, 7,11) + /* rowround */ + QUARTERROUND( 0, 1, 2, 3) + QUARTERROUND( 5, 6, 7, 4) + QUARTERROUND(10,11, 8, 9) + QUARTERROUND(15,12,13,14) + } +} + +#undef QUARTERROUND + +/** + Initialize an XSalsa20 context + @param st [out] The destination of the XSalsa20 state + @param key The secret key + @param keylen The length of the secret key, must be 32 (octets) + @param nonce The nonce + @param noncelen The length of the nonce, must be 24 (octets) + @param rounds Number of rounds (must be evenly divisible by 2, default is 20) + @return CRYPT_OK if successful +*/ +int xsalsa20_setup(salsa20_state *st, const unsigned char *key, unsigned long keylen, + const unsigned char *nonce, unsigned long noncelen, + int rounds) +{ + const int sti[] = {0, 5, 10, 15, 6, 7, 8, 9}; /* indices used to build subkey fm x */ + ulong32 x[64]; /* input to & output fm doubleround */ + unsigned char subkey[32]; + int i; + + LTC_ARGCHK(st != NULL); + LTC_ARGCHK(key != NULL); + LTC_ARGCHK(keylen == 32); + LTC_ARGCHK(nonce != NULL); + LTC_ARGCHK(noncelen == 24); + if (rounds == 0) rounds = 20; + LTC_ARGCHK(rounds % 2 == 0); /* number of rounds must be evenly divisible by 2 */ + + /* load the state to "hash" the key */ + LOAD32L(x[ 0], constants + 0); + LOAD32L(x[ 5], constants + 4); + LOAD32L(x[10], constants + 8); + LOAD32L(x[15], constants + 12); + LOAD32L(x[ 1], key + 0); + LOAD32L(x[ 2], key + 4); + LOAD32L(x[ 3], key + 8); + LOAD32L(x[ 4], key + 12); + LOAD32L(x[11], key + 16); + LOAD32L(x[12], key + 20); + LOAD32L(x[13], key + 24); + LOAD32L(x[14], key + 28); + LOAD32L(x[ 6], nonce + 0); + LOAD32L(x[ 7], nonce + 4); + LOAD32L(x[ 8], nonce + 8); + LOAD32L(x[ 9], nonce + 12); + + /* use modified salsa20 doubleround (no final addition) */ + _xsalsa20_doubleround(x, rounds); + + /* extract the subkey */ + for (i = 0; i < 8; ++i) { + STORE32L(x[sti[i]], subkey + 4 * i); + } + + /* load the final initial state */ + LOAD32L(st->input[ 0], constants + 0); + LOAD32L(st->input[ 5], constants + 4); + LOAD32L(st->input[10], constants + 8); + LOAD32L(st->input[15], constants + 12); + LOAD32L(st->input[ 1], subkey + 0); + LOAD32L(st->input[ 2], subkey + 4); + LOAD32L(st->input[ 3], subkey + 8); + LOAD32L(st->input[ 4], subkey + 12); + LOAD32L(st->input[11], subkey + 16); + LOAD32L(st->input[12], subkey + 20); + LOAD32L(st->input[13], subkey + 24); + LOAD32L(st->input[14], subkey + 28); + LOAD32L(st->input[ 6], &(nonce[16]) + 0); + LOAD32L(st->input[ 7], &(nonce[16]) + 4); + st->input[ 8] = 0; + st->input[ 9] = 0; + st->rounds = rounds; + st->ksleft = 0; + st->ivlen = 24; /* set switch to say nonce/IV has been loaded */ + +#ifdef LTC_CLEAN_STACK + zeromem(x, sizeof(x)); + zeromem(subkey, sizeof(subkey)); +#endif + + return CRYPT_OK; +} + + +#endif + +/* ref: $Format:%D$ */ +/* git commit: $Format:%H$ */ +/* commit time: $Format:%ai$ */ diff --git a/src/ltc/stream/sober128/sober128_stream.c b/src/ltc/stream/sober128/sober128_stream.c index 7b21edff..44e0c327 100644 --- a/src/ltc/stream/sober128/sober128_stream.c +++ b/src/ltc/stream/sober128/sober128_stream.c @@ -6,7 +6,7 @@ * The library is free for all purposes without any express * guarantee it works. */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" /** @file sober128_stream.c diff --git a/src/ltc/stream/sosemanuk/sosemanuk.c b/src/ltc/stream/sosemanuk/sosemanuk.c index 60ce30a6..7c5a602d 100644 --- a/src/ltc/stream/sosemanuk/sosemanuk.c +++ b/src/ltc/stream/sosemanuk/sosemanuk.c @@ -30,7 +30,7 @@ * <thomas.pornin@cryptolog.com> */ -#include "tomcrypt.h" +#include "tomcrypt_private.h" #ifdef LTC_SOSEMANUK @@ -257,16 +257,12 @@ int sosemanuk_setup(sosemanuk_state *ss, const unsigned char *key, unsigned long LTC_ARGCHK(ss != NULL); LTC_ARGCHK(key != NULL); + LTC_ARGCHK(keylen > 0 && keylen <= 32); /* * The key is copied into the wbuf[] buffer and padded to 256 bits * as described in the Serpent specification. */ - if (keylen == 0 || keylen > 32) { - fprintf(stderr, "invalid key size: %lu\n", - (unsigned long)keylen); - exit(EXIT_FAILURE); - } XMEMCPY(wbuf, key, keylen); if (keylen < 32) { wbuf[keylen] = 0x01; |