Package list libcryptx-perl / 5dbccdc
ltc update Karel Miko 3 years ago
399 changed file(s) with 1345 addition(s) and 1156 deletion(s). Raw diff Collapse all Expand all
102102 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 \
103103 ltc/pk/ecc/ecc_ansi_x963_import.o ltc/pk/ecc/ecc_decrypt_key.o ltc/pk/ecc/ecc_encrypt_key.o \
104104 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 \
105 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 \
106 ltc/pk/ecc/ecc_import_pkcs8.o ltc/pk/ecc/ecc_import_x509.o ltc/pk/ecc/ecc_make_key.o \
107 ltc/pk/ecc/ecc_set_dp.o ltc/pk/ecc/ecc_set_dp_internal.o ltc/pk/ecc/ecc_set_key.o \
108 ltc/pk/ecc/ecc_shared_secret.o ltc/pk/ecc/ecc_sign_hash.o ltc/pk/ecc/ecc_sizes.o \
109 ltc/pk/ecc/ecc_verify_hash.o ltc/pk/ecc/ltc_ecc_export_point.o ltc/pk/ecc/ltc_ecc_import_point.o \
110 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 \
111 ltc/pk/ecc/ltc_ecc_mul2add.o ltc/pk/ecc/ltc_ecc_mulmod.o ltc/pk/ecc/ltc_ecc_mulmod_timing.o \
112 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 \
113 ltc/pk/ecc/ltc_ecc_verify_key.o ltc/pk/pkcs1/pkcs_1_i2osp.o ltc/pk/pkcs1/pkcs_1_mgf1.o \
114 ltc/pk/pkcs1/pkcs_1_oaep_decode.o ltc/pk/pkcs1/pkcs_1_oaep_encode.o ltc/pk/pkcs1/pkcs_1_os2ip.o \
115 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 \
116 ltc/pk/pkcs1/pkcs_1_v1_5_encode.o ltc/pk/rsa/rsa_decrypt_key.o ltc/pk/rsa/rsa_encrypt_key.o \
117 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 \
118 ltc/pk/rsa/rsa_import.o ltc/pk/rsa/rsa_import_pkcs8.o ltc/pk/rsa/rsa_import_x509.o \
105 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 \
106 ltc/pk/ecc/ecc_import_openssl.o ltc/pk/ecc/ecc_import_pkcs8.o ltc/pk/ecc/ecc_import_x509.o \
107 ltc/pk/ecc/ecc_make_key.o ltc/pk/ecc/ecc_set_dp.o ltc/pk/ecc/ecc_set_dp_internal.o \
108 ltc/pk/ecc/ecc_set_key.o ltc/pk/ecc/ecc_shared_secret.o ltc/pk/ecc/ecc_sign_hash.o \
109 ltc/pk/ecc/ecc_sizes.o ltc/pk/ecc/ecc_verify_hash.o ltc/pk/ecc/ltc_ecc_export_point.o \
110 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 \
111 ltc/pk/ecc/ltc_ecc_map.o ltc/pk/ecc/ltc_ecc_mul2add.o ltc/pk/ecc/ltc_ecc_mulmod.o \
112 ltc/pk/ecc/ltc_ecc_mulmod_timing.o ltc/pk/ecc/ltc_ecc_points.o ltc/pk/ecc/ltc_ecc_projective_add_point.o \
113 ltc/pk/ecc/ltc_ecc_projective_dbl_point.o ltc/pk/ecc/ltc_ecc_verify_key.o ltc/pk/pkcs1/pkcs_1_i2osp.o \
114 ltc/pk/pkcs1/pkcs_1_mgf1.o ltc/pk/pkcs1/pkcs_1_oaep_decode.o ltc/pk/pkcs1/pkcs_1_oaep_encode.o \
115 ltc/pk/pkcs1/pkcs_1_os2ip.o ltc/pk/pkcs1/pkcs_1_pss_decode.o ltc/pk/pkcs1/pkcs_1_pss_encode.o \
116 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 \
117 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 \
118 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 \
119119 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 \
120120 ltc/pk/rsa/rsa_verify_hash.o ltc/prngs/chacha20.o ltc/prngs/fortuna.o ltc/prngs/rc4.o \
121121 ltc/prngs/rng_get_bytes.o ltc/prngs/rng_make_prng.o ltc/prngs/sober128.o ltc/prngs/sprng.o \
123123 ltc/stream/chacha/chacha_ivctr32.o ltc/stream/chacha/chacha_ivctr64.o ltc/stream/chacha/chacha_keystream.o \
124124 ltc/stream/chacha/chacha_setup.o ltc/stream/rabbit/rabbit.o ltc/stream/rc4/rc4_stream.o \
125125 ltc/stream/salsa20/salsa20_crypt.o ltc/stream/salsa20/salsa20_done.o ltc/stream/salsa20/salsa20_ivctr64.o \
126 ltc/stream/salsa20/salsa20_keystream.o ltc/stream/salsa20/salsa20_setup.o ltc/stream/sober128/sober128_stream.o \
127 ltc/stream/sosemanuk/sosemanuk.o ltm/bncore.o ltm/bn_error.o ltm/bn_fast_mp_invmod.o \
128 ltm/bn_fast_mp_montgomery_reduce.o ltm/bn_fast_s_mp_mul_digs.o ltm/bn_fast_s_mp_mul_high_digs.o \
129 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 \
130 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 \
131 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 \
132 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 \
133 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 \
134 ltm/bn_mp_exch.o ltm/bn_mp_export.o ltm/bn_mp_exptmod.o ltm/bn_mp_exptmod_fast.o \
135 ltm/bn_mp_expt_d.o ltm/bn_mp_expt_d_ex.o ltm/bn_mp_exteuclid.o ltm/bn_mp_fread.o \
136 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 \
137 ltm/bn_mp_import.o ltm/bn_mp_init.o ltm/bn_mp_init_copy.o ltm/bn_mp_init_multi.o \
126 ltc/stream/salsa20/salsa20_keystream.o ltc/stream/salsa20/salsa20_setup.o ltc/stream/salsa20/xsalsa20_setup.o \
127 ltc/stream/sober128/sober128_stream.o ltc/stream/sosemanuk/sosemanuk.o ltm/bncore.o \
128 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 \
129 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 \
130 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 \
131 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 \
132 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 \
133 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 \
134 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 \
135 ltm/bn_mp_exptmod_fast.o ltm/bn_mp_expt_d.o ltm/bn_mp_expt_d_ex.o ltm/bn_mp_exteuclid.o \
136 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 \
137 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 \
138138 ltm/bn_mp_init_set.o ltm/bn_mp_init_set_int.o ltm/bn_mp_init_size.o ltm/bn_mp_invmod.o \
139139 ltm/bn_mp_invmod_slow.o ltm/bn_mp_is_square.o ltm/bn_mp_jacobi.o ltm/bn_mp_karatsuba_mul.o \
140140 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 \
109109 ltc/pk/dsa/dsa_verify_key.obj ltc/pk/ecc/ecc.obj ltc/pk/ecc/ecc_ansi_x963_export.obj \
110110 ltc/pk/ecc/ecc_ansi_x963_import.obj ltc/pk/ecc/ecc_decrypt_key.obj ltc/pk/ecc/ecc_encrypt_key.obj \
111111 ltc/pk/ecc/ecc_export.obj ltc/pk/ecc/ecc_export_openssl.obj ltc/pk/ecc/ecc_free.obj \
112 ltc/pk/ecc/ecc_get_curve.obj ltc/pk/ecc/ecc_get_key.obj ltc/pk/ecc/ecc_get_size.obj \
113 ltc/pk/ecc/ecc_import.obj ltc/pk/ecc/ecc_import_openssl.obj ltc/pk/ecc/ecc_import_pkcs8.obj \
114 ltc/pk/ecc/ecc_import_x509.obj ltc/pk/ecc/ecc_make_key.obj ltc/pk/ecc/ecc_set_dp.obj \
115 ltc/pk/ecc/ecc_set_dp_internal.obj ltc/pk/ecc/ecc_set_key.obj ltc/pk/ecc/ecc_shared_secret.obj \
116 ltc/pk/ecc/ecc_sign_hash.obj ltc/pk/ecc/ecc_sizes.obj ltc/pk/ecc/ecc_verify_hash.obj \
117 ltc/pk/ecc/ltc_ecc_export_point.obj ltc/pk/ecc/ltc_ecc_import_point.obj ltc/pk/ecc/ltc_ecc_is_point.obj \
118 ltc/pk/ecc/ltc_ecc_is_point_at_infinity.obj ltc/pk/ecc/ltc_ecc_map.obj ltc/pk/ecc/ltc_ecc_mul2add.obj \
119 ltc/pk/ecc/ltc_ecc_mulmod.obj ltc/pk/ecc/ltc_ecc_mulmod_timing.obj ltc/pk/ecc/ltc_ecc_points.obj \
120 ltc/pk/ecc/ltc_ecc_projective_add_point.obj ltc/pk/ecc/ltc_ecc_projective_dbl_point.obj \
112 ltc/pk/ecc/ecc_get_curve.obj ltc/pk/ecc/ecc_get_key.obj ltc/pk/ecc/ecc_get_oid_str.obj \
113 ltc/pk/ecc/ecc_get_size.obj ltc/pk/ecc/ecc_import.obj ltc/pk/ecc/ecc_import_openssl.obj \
114 ltc/pk/ecc/ecc_import_pkcs8.obj ltc/pk/ecc/ecc_import_x509.obj ltc/pk/ecc/ecc_make_key.obj \
115 ltc/pk/ecc/ecc_set_dp.obj ltc/pk/ecc/ecc_set_dp_internal.obj ltc/pk/ecc/ecc_set_key.obj \
116 ltc/pk/ecc/ecc_shared_secret.obj ltc/pk/ecc/ecc_sign_hash.obj ltc/pk/ecc/ecc_sizes.obj \
117 ltc/pk/ecc/ecc_verify_hash.obj ltc/pk/ecc/ltc_ecc_export_point.obj ltc/pk/ecc/ltc_ecc_import_point.obj \
118 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 \
119 ltc/pk/ecc/ltc_ecc_mul2add.obj ltc/pk/ecc/ltc_ecc_mulmod.obj ltc/pk/ecc/ltc_ecc_mulmod_timing.obj \
120 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 \
121121 ltc/pk/ecc/ltc_ecc_verify_key.obj ltc/pk/pkcs1/pkcs_1_i2osp.obj ltc/pk/pkcs1/pkcs_1_mgf1.obj \
122122 ltc/pk/pkcs1/pkcs_1_oaep_decode.obj ltc/pk/pkcs1/pkcs_1_oaep_encode.obj ltc/pk/pkcs1/pkcs_1_os2ip.obj \
123123 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 \
131131 ltc/stream/chacha/chacha_ivctr32.obj ltc/stream/chacha/chacha_ivctr64.obj ltc/stream/chacha/chacha_keystream.obj \
132132 ltc/stream/chacha/chacha_setup.obj ltc/stream/rabbit/rabbit.obj ltc/stream/rc4/rc4_stream.obj \
133133 ltc/stream/salsa20/salsa20_crypt.obj ltc/stream/salsa20/salsa20_done.obj ltc/stream/salsa20/salsa20_ivctr64.obj \
134 ltc/stream/salsa20/salsa20_keystream.obj ltc/stream/salsa20/salsa20_setup.obj ltc/stream/sober128/sober128_stream.obj \
135 ltc/stream/sosemanuk/sosemanuk.obj ltm/bncore.obj ltm/bn_error.obj ltm/bn_fast_mp_invmod.obj \
136 ltm/bn_fast_mp_montgomery_reduce.obj ltm/bn_fast_s_mp_mul_digs.obj ltm/bn_fast_s_mp_mul_high_digs.obj \
137 ltm/bn_fast_s_mp_sqr.obj ltm/bn_mp_2expt.obj ltm/bn_mp_abs.obj ltm/bn_mp_add.obj \
138 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 \
139 ltm/bn_mp_clear_multi.obj ltm/bn_mp_cmp.obj ltm/bn_mp_cmp_d.obj ltm/bn_mp_cmp_mag.obj \
140 ltm/bn_mp_cnt_lsb.obj ltm/bn_mp_copy.obj ltm/bn_mp_count_bits.obj ltm/bn_mp_div.obj \
141 ltm/bn_mp_div_2.obj ltm/bn_mp_div_2d.obj ltm/bn_mp_div_3.obj ltm/bn_mp_div_d.obj \
134 ltc/stream/salsa20/salsa20_keystream.obj ltc/stream/salsa20/salsa20_setup.obj ltc/stream/salsa20/xsalsa20_setup.obj \
135 ltc/stream/sober128/sober128_stream.obj ltc/stream/sosemanuk/sosemanuk.obj ltm/bncore.obj \
136 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 \
137 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 \
138 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 \
139 ltm/bn_mp_clear.obj ltm/bn_mp_clear_multi.obj ltm/bn_mp_cmp.obj ltm/bn_mp_cmp_d.obj \
140 ltm/bn_mp_cmp_mag.obj ltm/bn_mp_cnt_lsb.obj ltm/bn_mp_copy.obj ltm/bn_mp_count_bits.obj \
141 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 \
142142 ltm/bn_mp_dr_is_modulus.obj ltm/bn_mp_dr_reduce.obj ltm/bn_mp_dr_setup.obj ltm/bn_mp_exch.obj \
143143 ltm/bn_mp_export.obj ltm/bn_mp_exptmod.obj ltm/bn_mp_exptmod_fast.obj ltm/bn_mp_expt_d.obj \
144144 ltm/bn_mp_expt_d_ex.obj ltm/bn_mp_exteuclid.obj ltm/bn_mp_fread.obj ltm/bn_mp_fwrite.obj \
2727 Implementation of AES
2828 */
2929
30 #include "tomcrypt.h"
30 #include "tomcrypt_private.h"
3131
3232 #ifdef LTC_RIJNDAEL
3333
1212 Authors: Paulo S.L.M. Barreto and Vincent Rijmen.
1313 */
1414
15 #include "tomcrypt.h"
15 #include "tomcrypt_private.h"
1616
1717 #ifdef LTC_ANUBIS
1818
99 @file blowfish.c
1010 Implementation of the Blowfish block cipher, Tom St Denis
1111 */
12 #include "tomcrypt.h"
12 #include "tomcrypt_private.h"
1313
1414 #ifdef LTC_BLOWFISH
1515
393393 ulong32 L, R;
394394 int r;
395395 #ifndef __GNUC__
396 ulong32 *S1, *S2, *S3, *S4;
396 const ulong32 *S1, *S2, *S3, *S4;
397397 #endif
398398
399399 LTC_ARGCHK(pt != NULL);
455455 ulong32 L, R;
456456 int r;
457457 #ifndef __GNUC__
458 ulong32 *S1, *S2, *S3, *S4;
458 const ulong32 *S1, *S2, *S3, *S4;
459459 #endif
460460
461461 LTC_ARGCHK(pt != NULL);
1111 Implementation by Tom St Denis of Elliptic Semiconductor
1212 */
1313
14 #include "tomcrypt.h"
14 #include "tomcrypt_private.h"
1515
1616 #ifdef LTC_CAMELLIA
1717
1010 @file cast5.c
1111 Implementation of LTC_CAST5 (RFC 2144) by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_CAST5
1616
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file des.c
3535 {
3636 "3des",
3737 14,
38 24, 24, 8, 16,
38 16, 24, 8, 16,
3939 &des3_setup,
4040 &des3_ecb_encrypt,
4141 &des3_ecb_decrypt,
20672067 int des3_keysize(int *keysize)
20682068 {
20692069 LTC_ARGCHK(keysize != NULL);
2070 if(*keysize < 24) {
2071 return CRYPT_INVALID_KEYSIZE;
2070 if (*keysize < 16)
2071 return CRYPT_INVALID_KEYSIZE;
2072 if (*keysize < 24) {
2073 *keysize = 16;
2074 return CRYPT_OK;
20722075 }
20732076 *keysize = 24;
20742077 return CRYPT_OK;
2121 and Japan (JP 3225440) (expired May 16, 2011).
2222 */
2323
24 #include "tomcrypt.h"
24 #include "tomcrypt_private.h"
2525
2626 #ifdef LTC_IDEA
2727
1212 Derived from the 3GPP standard source code
1313 */
1414
15 #include "tomcrypt.h"
15 #include "tomcrypt_private.h"
1616
1717 #ifdef LTC_KASUMI
1818
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file khazad.c
1212 Tom St Denis
1313 */
1414
15 #include "tomcrypt.h"
15 #include "tomcrypt_private.h"
1616
1717 #ifdef LTC_KSEED
1818
1010 @file multi2.c
1111 Multi-2 implementation (not public domain, hence the default disable)
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_MULTI2
1616
99 @file noekeon.c
1010 Implementation of the Noekeon block cipher by Tom St Denis
1111 */
12 #include "tomcrypt.h"
12 #include "tomcrypt_private.h"
1313
1414 #ifdef LTC_NOEKEON
1515
1515 * Thanks to CodeView, SoftIce, and D86 for helping bring this code to *
1616 * the public. *
1717 \**********************************************************************/
18 #include "tomcrypt.h"
18 #include "tomcrypt_private.h"
1919
2020 /**
2121 @file rc2.c
1111 LTC_RC5 code by Tom St Denis
1212 */
1313
14 #include "tomcrypt.h"
14 #include "tomcrypt_private.h"
1515
1616 #ifdef LTC_RC5
1717
1010 @file rc6.c
1111 LTC_RC6 code by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_RC6
1616
2525 *
2626 *******************************************************************************/
2727
28 #include "tomcrypt.h"
28 #include "tomcrypt_private.h"
2929
3030 #ifdef LTC_SAFER
3131
1010 @file saferp.c
1111 LTC_SAFER+ Implementation by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_SAFERP
1616
1414 https://en.wikipedia.org/wiki/Serpent_(cipher)
1515 */
1616
17 #include "tomcrypt.h"
17 #include "tomcrypt_private.h"
1818
1919 #ifdef LTC_SERPENT
2020
1010 @file skipjack.c
1111 Skipjack Implementation by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_SKIPJACK
1616
1010 @file twofish.c
1111 Implementation of Twofish by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_TWOFISH
1616
472472 const ulong32 *k;
473473 int r;
474474 #if !defined(LTC_TWOFISH_SMALL) && !defined(__GNUC__)
475 ulong32 *S1, *S2, *S3, *S4;
475 const ulong32 *S1, *S2, *S3, *S4;
476476 #endif
477477
478478 LTC_ARGCHK(pt != NULL);
546546 const ulong32 *k;
547547 int r;
548548 #if !defined(LTC_TWOFISH_SMALL) && !defined(__GNUC__)
549 ulong32 *S1, *S2, *S3, *S4;
549 const ulong32 *S1, *S2, *S3, *S4;
550550 #endif
551551
552552 LTC_ARGCHK(pt != NULL);
1010 @file xtea.c
1111 Implementation of LTC_XTEA, Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_XTEA
1616
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 #ifdef LTC_CCM_MODE
1111
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 #ifdef LTC_CCM_MODE
1111
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 #ifdef LTC_CCM_MODE
1111
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 #ifdef LTC_CCM_MODE
1111
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file ccm_memory.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 #ifdef LTC_CCM_MODE
1111
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 #ifdef LTC_CCM_MODE
1111
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 #ifdef LTC_CHACHA20POLY1305_MODE
1212
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 #ifdef LTC_CHACHA20POLY1305_MODE
1212
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 #ifdef LTC_CHACHA20POLY1305_MODE
1212
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 #ifdef LTC_CHACHA20POLY1305_MODE
1212
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 #ifdef LTC_CHACHA20POLY1305_MODE
1212
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 #ifdef LTC_CHACHA20POLY1305_MODE
1212
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 #ifdef LTC_CHACHA20POLY1305_MODE
1212
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 #ifdef LTC_CHACHA20POLY1305_MODE
1212
99 @file eax_addheader.c
1010 EAX implementation, add meta-data, by Tom St Denis
1111 */
12 #include "tomcrypt.h"
12 #include "tomcrypt_private.h"
1313
1414 #ifdef LTC_EAX_MODE
1515
1010 @file eax_decrypt.c
1111 EAX implementation, decrypt block, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_EAX_MODE
1616
1010 @file eax_decrypt_verify_memory.c
1111 EAX implementation, decrypt block of memory, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_EAX_MODE
1616
1010 @file eax_done.c
1111 EAX implementation, terminate session, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_EAX_MODE
1616
1010 @file eax_encrypt.c
1111 EAX implementation, encrypt block by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_EAX_MODE
1616
1010 @file eax_encrypt_authenticate_memory.c
1111 EAX implementation, encrypt a block of memory, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_EAX_MODE
1616
1010 @file eax_init.c
1111 EAX implementation, initialized EAX state, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_EAX_MODE
1616
1010 @file gcm_add_aad.c
1111 GCM implementation, Add AAD data to the stream, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_GCM_MODE
1616
1010 @file gcm_add_iv.c
1111 GCM implementation, add IV data to the state, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_GCM_MODE
1616
1010 @file gcm_done.c
1111 GCM implementation, Terminate the stream, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_GCM_MODE
1616
1010 @file gcm_gf_mult.c
1111 GCM implementation, do the GF mult, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #if defined(LTC_GCM_TABLES) || defined(LTC_LRW_TABLES) || ((defined(LTC_GCM_MODE) || defined(LTC_GCM_MODE)) && defined(LTC_FAST))
1616
1010 @file gcm_init.c
1111 GCM implementation, initialize state, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_GCM_MODE
1616
1010 @file gcm_memory.c
1111 GCM implementation, process a packet, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_GCM_MODE
1616
1010 @file gcm_mult_h.c
1111 GCM implementation, do the GF mult, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #if defined(LTC_GCM_MODE)
1616 /**
1010 @file gcm_process.c
1111 GCM implementation, process message data, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_GCM_MODE
1616
1010 @file gcm_reset.c
1111 GCM implementation, reset a used state so it can accept IV data, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_GCM_MODE
1616
1010 @file ocb3_add_aad.c
1111 OCB implementation, add AAD data, by Karel Miko
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_OCB3_MODE
1616
1010 @file ocb3_decrypt.c
1111 OCB implementation, decrypt data, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_OCB3_MODE
1616
1010 @file ocb3_decrypt_last.c
1111 OCB implementation, internal helper, by Karel Miko
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_OCB3_MODE
1616
1010 @file ocb3_decrypt_verify_memory.c
1111 OCB implementation, helper to decrypt block of memory, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_OCB3_MODE
1616
1010 @file ocb3_done.c
1111 OCB implementation, INTERNAL ONLY helper, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_OCB3_MODE
1616
1010 @file ocb3_encrypt.c
1111 OCB implementation, encrypt data, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_OCB3_MODE
1616
1010 @file ocb3_encrypt_authenticate_memory.c
1111 OCB implementation, encrypt block of memory, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_OCB3_MODE
1616
1010 @file ocb3_encrypt_last.c
1111 OCB implementation, internal helper, by Karel Miko
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_OCB3_MODE
1616
1010 @file ocb3_init.c
1111 OCB implementation, initialize state, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_OCB3_MODE
1616
1010 @file ocb3_int_ntz.c
1111 OCB implementation, INTERNAL ONLY helper, by Tom St Denis
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_OCB3_MODE
1616
1010 @file ocb3_int_xor_blocks.c
1111 OCB implementation, INTERNAL ONLY helper, by Karel Miko
1212 */
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #ifdef LTC_OCB3_MODE
1616
2222 */
2323 /* see also https://www.ietf.org/rfc/rfc7693.txt */
2424
25 #include "tomcrypt.h"
25 #include "tomcrypt_private.h"
2626
2727 #ifdef LTC_BLAKE2B
2828
198198 return CRYPT_OK;
199199 }
200200
201 /**
202 Initialize the hash/MAC state
203
204 Use this function to init for arbitrary sizes.
205
206 Give a key and keylen to init for MAC mode.
207
208 @param md The hash state you wish to initialize
209 @param outlen The desired output-length
210 @param key The key of the MAC
211 @param keylen The length of the key
212 @return CRYPT_OK if successful
213 */
201214 int blake2b_init(hash_state *md, unsigned long outlen, const unsigned char *key, unsigned long keylen)
202215 {
203216 unsigned char P[BLAKE2B_PARAM_SIZE];
236249 return CRYPT_OK;
237250 }
238251
252 /**
253 Initialize the hash state
254 @param md The hash state you wish to initialize
255 @return CRYPT_OK if successful
256 */
239257 int blake2b_160_init(hash_state *md) { return blake2b_init(md, 20, NULL, 0); }
240258
259 /**
260 Initialize the hash state
261 @param md The hash state you wish to initialize
262 @return CRYPT_OK if successful
263 */
241264 int blake2b_256_init(hash_state *md) { return blake2b_init(md, 32, NULL, 0); }
242265
266 /**
267 Initialize the hash state
268 @param md The hash state you wish to initialize
269 @return CRYPT_OK if successful
270 */
243271 int blake2b_384_init(hash_state *md) { return blake2b_init(md, 48, NULL, 0); }
244272
273 /**
274 Initialize the hash state
275 @param md The hash state you wish to initialize
276 @return CRYPT_OK if successful
277 */
245278 int blake2b_512_init(hash_state *md) { return blake2b_init(md, 64, NULL, 0); }
246279
247280 #define G(r, i, a, b, c, d) \
327360 }
328361 #endif
329362
363 /**
364 Process a block of memory through the hash
365 @param md The hash state
366 @param in The data to hash
367 @param inlen The length of the data (octets)
368 @return CRYPT_OK if successful
369 */
330370 int blake2b_process(hash_state *md, const unsigned char *in, unsigned long inlen)
331371 {
332372 LTC_ARGCHK(md != NULL);
359399 return CRYPT_OK;
360400 }
361401
402 /**
403 Terminate the hash to get the digest
404 @param md The hash state
405 @param out [out] The destination of the hash (size depending on the length used on init)
406 @return CRYPT_OK if successful
407 */
362408 int blake2b_done(hash_state *md, unsigned char *out)
363409 {
364410 unsigned char buffer[BLAKE2B_OUTBYTES] = { 0 };
2222 */
2323 /* see also https://www.ietf.org/rfc/rfc7693.txt */
2424
25 #include "tomcrypt.h"
25 #include "tomcrypt_private.h"
2626
2727 #ifdef LTC_BLAKE2S
2828
192192 return CRYPT_OK;
193193 }
194194
195 /**
196 Initialize the hash/MAC state
197
198 Use this function to init for arbitrary sizes.
199
200 Give a key and keylen to init for MAC mode.
201
202 @param md The hash state you wish to initialize
203 @param outlen The desired output-length
204 @param key The key of the MAC
205 @param keylen The length of the key
206 @return CRYPT_OK if successful
207 */
195208 int blake2s_init(hash_state *md, unsigned long outlen, const unsigned char *key, unsigned long keylen)
196209 {
197210 unsigned char P[BLAKE2S_PARAM_SIZE];
229242 return CRYPT_OK;
230243 }
231244
245 /**
246 Initialize the hash state
247 @param md The hash state you wish to initialize
248 @return CRYPT_OK if successful
249 */
232250 int blake2s_128_init(hash_state *md) { return blake2s_init(md, 16, NULL, 0); }
233251
252 /**
253 Initialize the hash state
254 @param md The hash state you wish to initialize
255 @return CRYPT_OK if successful
256 */
234257 int blake2s_160_init(hash_state *md) { return blake2s_init(md, 20, NULL, 0); }
235258
259 /**
260 Initialize the hash state
261 @param md The hash state you wish to initialize
262 @return CRYPT_OK if successful
263 */
236264 int blake2s_224_init(hash_state *md) { return blake2s_init(md, 28, NULL, 0); }
237265
266 /**
267 Initialize the hash state
268 @param md The hash state you wish to initialize
269 @return CRYPT_OK if successful
270 */
238271 int blake2s_256_init(hash_state *md) { return blake2s_init(md, 32, NULL, 0); }
239272
240273 #define G(r, i, a, b, c, d) \
315348 }
316349 #endif
317350
351 /**
352 Process a block of memory through the hash
353 @param md The hash state
354 @param in The data to hash
355 @param inlen The length of the data (octets)
356 @return CRYPT_OK if successful
357 */
318358 int blake2s_process(hash_state *md, const unsigned char *in, unsigned long inlen)
319359 {
320360 LTC_ARGCHK(md != NULL);
347387 return CRYPT_OK;
348388 }
349389
390 /**
391 Terminate the hash to get the digest
392 @param md The hash state
393 @param out [out] The destination of the hash (size depending on the length used on init)
394 @return CRYPT_OK if successful
395 */
350396 int blake2s_done(hash_state *md, unsigned char *out)
351397 {
352398 unsigned char buffer[BLAKE2S_OUTBYTES] = { 0 };
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 /**
1212 @file chc.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 #ifndef LTC_NO_FILE
1111 /**
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 #ifndef LTC_NO_FILE
1111 /**
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 #ifdef LTC_HASH_HELPERS
1111 /**
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99 #include <stdarg.h>
1010
1111 #ifdef LTC_HASH_HELPERS
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @param md2.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @param md4.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010
1111 /**
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @param rmd128.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file rmd160.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @param rmd256.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file rmd320.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file sha1.c
1010 LTC_SHA-224 new NIST standard based off of LTC_SHA-256 truncated to 224 bits (Tom St Denis)
1111 */
1212
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #if defined(LTC_SHA224) && defined(LTC_SHA256)
1616
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file sha256.c
1010 LTC_SHA384 hash included in sha512.c, Tom St Denis
1111 */
1212
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #if defined(LTC_SHA384) && defined(LTC_SHA512)
1616
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @param sha512.c
1010 SHA512/224 hash included in sha512.c
1111 */
1212
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #if defined(LTC_SHA512_224) && defined(LTC_SHA512)
1616
1010 SHA512/256 hash included in sha512.c
1111 */
1212
13 #include "tomcrypt.h"
13 #include "tomcrypt_private.h"
1414
1515 #if defined(LTC_SHA512_256) && defined(LTC_SHA512)
1616
88
99 /* based on https://github.com/brainhub/SHA3IUF (public domain) */
1010
11 #include "tomcrypt.h"
11 #include "tomcrypt_private.h"
1212
1313 #ifdef LTC_SHA3
1414
88
99 /* based on https://github.com/brainhub/SHA3IUF (public domain) */
1010
11 #include "tomcrypt.h"
11 #include "tomcrypt_private.h"
1212
1313 #ifdef LTC_SHA3
1414
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 /**
1212 @file tiger.c
1111 LTC_WHIRLPOOL (using their new sbox) hash function by Tom St Denis
1212 */
1313
14 #include "tomcrypt.h"
14 #include "tomcrypt_private.h"
1515
1616 #ifdef LTC_WHIRLPOOL
1717
10301030
10311031 #endif /* LTC_SALSA20 */
10321032
1033 #ifdef LTC_XSALSA20
1034
1035 int xsalsa20_setup(salsa20_state *st, const unsigned char *key, unsigned long keylen,
1036 const unsigned char *nonce, unsigned long noncelen,
1037 int rounds);
1038 int xsalsa20_test(void);
1039
1040 #endif /* LTC_XSALSA20 */
1041
10331042 #ifdef LTC_SOSEMANUK
10341043
10351044 typedef struct {
207207 /* stream ciphers */
208208 #define LTC_CHACHA
209209 #define LTC_SALSA20
210 #define LTC_XSALSA20
210211 #define LTC_SOSEMANUK
211212 #define LTC_RABBIT
212213 #define LTC_RC4_STREAM
363364 /* time-based rate limit of the reseeding */
364365 #define LTC_FORTUNA_RESEED_RATELIMIT_TIMED
365366
367 /* with non-glibc or glibc 2.17+ prefer clock_gettime over gettimeofday */
368 #if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
369 #if __GLIBC_PREREQ(2, 17)
370 #define LTC_CLOCK_GETTIME
371 #endif
372 #elif defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L
373 #define LTC_CLOCK_GETTIME
374 #endif
375
366376 #else
367377
368378 #ifndef LTC_FORTUNA_WD
413423 #define LTC_DH6144
414424 #define LTC_DH8192
415425 #endif
416
417 /* Include Katja (a Rabin variant like RSA) */
418 /* #define LTC_MKAT */
419426
420427 /* Digital Signature Algorithm */
421428 #define LTC_MDSA
537544 #endif
538545 #endif
539546
540 #if defined(LTC_MECC) || defined(LTC_MRSA) || defined(LTC_MDSA) || defined(LTC_MKAT)
547 #if defined(LTC_MECC) || defined(LTC_MRSA) || defined(LTC_MDSA)
541548 /* Include the MPI functionality? (required by the PK algorithms) */
542549 #define LTC_MPI
543550
567574 #error ASN.1 DER requires MPI functionality
568575 #endif
569576
570 #if (defined(LTC_MDSA) || defined(LTC_MRSA) || defined(LTC_MECC) || defined(LTC_MKAT)) && !defined(LTC_DER)
577 #if (defined(LTC_MDSA) || defined(LTC_MRSA) || defined(LTC_MECC)) && !defined(LTC_DER)
571578 #error PK requires ASN.1 DER functionality, make sure LTC_DER is enabled
572579 #endif
573580
577584
578585 #if defined(LTC_CHACHA20_PRNG) && !defined(LTC_CHACHA)
579586 #error LTC_CHACHA20_PRNG requires LTC_CHACHA
587 #endif
588
589 #if defined(LTC_XSALSA20) && !defined(LTC_SALSA20)
590 #error LTC_XSALSA20 requires LTC_SALSA20
580591 #endif
581592
582593 #if defined(LTC_RC4) && !defined(LTC_RC4_STREAM)
506506 int hash_file(int hash, const char *fname, unsigned char *out, unsigned long *outlen);
507507 #endif
508508
509 /* a simple macro for making hash "process" functions */
510 #define HASH_PROCESS(func_name, compress_name, state_var, block_size) \
511 int func_name (hash_state * md, const unsigned char *in, unsigned long inlen) \
512 { \
513 unsigned long n; \
514 int err; \
515 LTC_ARGCHK(md != NULL); \
516 LTC_ARGCHK(in != NULL); \
517 if (md-> state_var .curlen > sizeof(md-> state_var .buf)) { \
518 return CRYPT_INVALID_ARG; \
519 } \
520 if ((md-> state_var .length + inlen) < md-> state_var .length) { \
521 return CRYPT_HASH_OVERFLOW; \
522 } \
523 while (inlen > 0) { \
524 if (md-> state_var .curlen == 0 && inlen >= block_size) { \
525 if ((err = compress_name (md, in)) != CRYPT_OK) { \
526 return err; \
527 } \
528 md-> state_var .length += block_size * 8; \
529 in += block_size; \
530 inlen -= block_size; \
531 } else { \
532 n = MIN(inlen, (block_size - md-> state_var .curlen)); \
533 XMEMCPY(md-> state_var .buf + md-> state_var.curlen, in, (size_t)n); \
534 md-> state_var .curlen += n; \
535 in += n; \
536 inlen -= n; \
537 if (md-> state_var .curlen == block_size) { \
538 if ((err = compress_name (md, md-> state_var .buf)) != CRYPT_OK) { \
539 return err; \
540 } \
541 md-> state_var .length += 8*block_size; \
542 md-> state_var .curlen = 0; \
543 } \
544 } \
545 } \
546 return CRYPT_OK; \
547 }
548
549509 /* ref: $Format:%D$ */
550510 /* git commit: $Format:%H$ */
551511 /* commit time: $Format:%ai$ */
145145 int blake2bmac_test(void);
146146 #endif /* LTC_BLAKE2BMAC */
147147
148
148149 #ifdef LTC_PELICAN
149150
150151 typedef struct pelican_state
390391
391392 int ocb3_test(void);
392393
393 #ifdef LTC_SOURCE
394 /* internal helper functions */
395 int ocb3_int_ntz(unsigned long x);
396 void ocb3_int_xor_blocks(unsigned char *out, const unsigned char *block_a, const unsigned char *block_b, unsigned long block_len);
397 #endif /* LTC_SOURCE */
398
399394 #endif /* LTC_OCB3_MODE */
400395
401396 #ifdef LTC_CCM_MODE
523523 extern const ltc_math_descriptor gmp_desc;
524524 #endif
525525
526 #if !defined(DESC_DEF_ONLY) && defined(LTC_SOURCE)
527
528 #define MP_DIGIT_BIT ltc_mp.bits_per_digit
529
530 /* some handy macros */
531 #define mp_init(a) ltc_mp.init(a)
532 #define mp_init_multi ltc_init_multi
533 #define mp_clear(a) ltc_mp.deinit(a)
534 #define mp_clear_multi ltc_deinit_multi
535 #define mp_cleanup_multi ltc_cleanup_multi
536 #define mp_init_copy(a, b) ltc_mp.init_copy(a, b)
537
538 #define mp_neg(a, b) ltc_mp.neg(a, b)
539 #define mp_copy(a, b) ltc_mp.copy(a, b)
540
541 #define mp_set(a, b) ltc_mp.set_int(a, b)
542 #define mp_set_int(a, b) ltc_mp.set_int(a, b)
543 #define mp_get_int(a) ltc_mp.get_int(a)
544 #define mp_get_digit(a, n) ltc_mp.get_digit(a, n)
545 #define mp_get_digit_count(a) ltc_mp.get_digit_count(a)
546 #define mp_cmp(a, b) ltc_mp.compare(a, b)
547 #define mp_cmp_d(a, b) ltc_mp.compare_d(a, b)
548 #define mp_count_bits(a) ltc_mp.count_bits(a)
549 #define mp_cnt_lsb(a) ltc_mp.count_lsb_bits(a)
550 #define mp_2expt(a, b) ltc_mp.twoexpt(a, b)
551
552 #define mp_read_radix(a, b, c) ltc_mp.read_radix(a, b, c)
553 #define mp_toradix(a, b, c) ltc_mp.write_radix(a, b, c)
554 #define mp_unsigned_bin_size(a) ltc_mp.unsigned_size(a)
555 #define mp_to_unsigned_bin(a, b) ltc_mp.unsigned_write(a, b)
556 #define mp_read_unsigned_bin(a, b, c) ltc_mp.unsigned_read(a, b, c)
557
558 #define mp_add(a, b, c) ltc_mp.add(a, b, c)
559 #define mp_add_d(a, b, c) ltc_mp.addi(a, b, c)
560 #define mp_sub(a, b, c) ltc_mp.sub(a, b, c)
561 #define mp_sub_d(a, b, c) ltc_mp.subi(a, b, c)
562 #define mp_mul(a, b, c) ltc_mp.mul(a, b, c)
563 #define mp_mul_d(a, b, c) ltc_mp.muli(a, b, c)
564 #define mp_sqr(a, b) ltc_mp.sqr(a, b)
565 #define mp_sqrtmod_prime(a, b, c) ltc_mp.sqrtmod_prime(a, b, c)
566 #define mp_div(a, b, c, d) ltc_mp.mpdiv(a, b, c, d)
567 #define mp_div_2(a, b) ltc_mp.div_2(a, b)
568 #define mp_mod(a, b, c) ltc_mp.mpdiv(a, b, NULL, c)
569 #define mp_mod_d(a, b, c) ltc_mp.modi(a, b, c)
570 #define mp_gcd(a, b, c) ltc_mp.gcd(a, b, c)
571 #define mp_lcm(a, b, c) ltc_mp.lcm(a, b, c)
572
573 #define mp_addmod(a, b, c, d) ltc_mp.addmod(a, b, c, d)
574 #define mp_submod(a, b, c, d) ltc_mp.submod(a, b, c, d)
575 #define mp_mulmod(a, b, c, d) ltc_mp.mulmod(a, b, c, d)
576 #define mp_sqrmod(a, b, c) ltc_mp.sqrmod(a, b, c)
577 #define mp_invmod(a, b, c) ltc_mp.invmod(a, b, c)
578
579 #define mp_montgomery_setup(a, b) ltc_mp.montgomery_setup(a, b)
580 #define mp_montgomery_normalization(a, b) ltc_mp.montgomery_normalization(a, b)
581 #define mp_montgomery_reduce(a, b, c) ltc_mp.montgomery_reduce(a, b, c)
582 #define mp_montgomery_free(a) ltc_mp.montgomery_deinit(a)
583
584 #define mp_exptmod(a,b,c,d) ltc_mp.exptmod(a,b,c,d)
585 #define mp_prime_is_prime(a, b, c) ltc_mp.isprime(a, b, c)
586
587 #define mp_iszero(a) (mp_cmp_d(a, 0) == LTC_MP_EQ ? LTC_MP_YES : LTC_MP_NO)
588 #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)
589 #define mp_exch(a, b) do { void *ABC__tmp = a; a = b; b = ABC__tmp; } while(0)
590
591 #define mp_tohex(a, b) mp_toradix(a, b, 16)
592
593 #define mp_rand(a, b) ltc_mp.rand(a, b)
594
595 #endif
596
597526 /* ref: $Format:%D$ */
598527 /* git commit: $Format:%H$ */
599528 /* commit time: $Format:%ai$ */
5353 #ifdef LTC_BASE16
5454 int base16_encode(const unsigned char *in, unsigned long inlen,
5555 char *out, unsigned long *outlen,
56 int caps);
56 unsigned int options);
5757 int base16_decode(const char *in, unsigned long inlen,
5858 unsigned char *out, unsigned long *outlen);
5959 #endif
8484 /* ---- MEM routines ---- */
8585 int mem_neq(const void *a, const void *b, size_t len);
8686 void zeromem(volatile void *dst, size_t len);
87 #ifdef LTC_SOURCE
88 void copy_or_zeromem(const unsigned char* src, unsigned char* dest, unsigned long len, int coz);
89 #endif
9087 void burn_stack(unsigned long len);
9188
9289 const char *error_to_string(int err);
154151
155152 int padding_pad(unsigned char *data, unsigned long length, unsigned long* padded_length, unsigned long mode);
156153 int padding_depad(const unsigned char *data, unsigned long *length, unsigned long mode);
157
158 #ifdef LTC_SOURCE
159 /* internal helper functions */
160 #define LTC_PAD_MASK (0xF000U)
161 #endif
162154 #endif /* LTC_PADDING */
163155
164156 int compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which);
2323 };
2424
2525 int rand_prime(void *N, long len, prng_state *prng, int wprng);
26
27 #ifdef LTC_SOURCE
28 /* internal helper functions */
29 int rand_bn_bits(void *N, int bits, prng_state *prng, int wprng);
30 int rand_bn_upto(void *N, void *limit, prng_state *prng, int wprng);
31
32 enum public_key_algorithms {
33 PKA_RSA,
34 PKA_DSA,
35 PKA_EC,
36 PKA_EC_PRIMEF
37 };
38
39 typedef struct Oid {
40 unsigned long OID[16];
41 /** Number of OID digits in use */
42 unsigned long OIDlen;
43 } oid_st;
44
45 int pk_get_oid(int pk, oid_st *st);
46 int pk_oid_str_to_num(const char *OID, unsigned long *oid, unsigned long *oidlen);
47 int pk_oid_num_to_str(const unsigned long *oid, unsigned long oidlen, char *OID, unsigned long *outlen);
48 #endif /* LTC_SOURCE */
4926
5027 /* ---- RSA ---- */
5128 #ifdef LTC_MRSA
148125 rsa_key *key);
149126 #endif
150127
151 /* ---- Katja ---- */
152 #ifdef LTC_MKAT
153
154 /* Min and Max KAT key sizes (in bits) */
155 #define MIN_KAT_SIZE 1024
156 #define MAX_KAT_SIZE 4096
157
158 /** Katja PKCS style key */
159 typedef struct KAT_key {
160 /** Type of key, PK_PRIVATE or PK_PUBLIC */
161 int type;
162 /** The private exponent */
163 void *d;
164 /** The modulus */
165 void *N;
166 /** The p factor of N */
167 void *p;
168 /** The q factor of N */
169 void *q;
170 /** The 1/q mod p CRT param */
171 void *qP;
172 /** The d mod (p - 1) CRT param */
173 void *dP;
174 /** The d mod (q - 1) CRT param */
175 void *dQ;
176 /** The pq param */
177 void *pq;
178 } katja_key;
179
180 int katja_make_key(prng_state *prng, int wprng, int size, katja_key *key);
181
182 int katja_exptmod(const unsigned char *in, unsigned long inlen,
183 unsigned char *out, unsigned long *outlen, int which,
184 katja_key *key);
185
186 void katja_free(katja_key *key);
187
188 /* These use PKCS #1 v2.0 padding */
189 int katja_encrypt_key(const unsigned char *in, unsigned long inlen,
190 unsigned char *out, unsigned long *outlen,
191 const unsigned char *lparam, unsigned long lparamlen,
192 prng_state *prng, int prng_idx, int hash_idx, katja_key *key);
193
194 int katja_decrypt_key(const unsigned char *in, unsigned long inlen,
195 unsigned char *out, unsigned long *outlen,
196 const unsigned char *lparam, unsigned long lparamlen,
197 int hash_idx, int *stat,
198 katja_key *key);
199
200 /* PKCS #1 import/export */
201 int katja_export(unsigned char *out, unsigned long *outlen, int type, katja_key *key);
202 int katja_import(const unsigned char *in, unsigned long inlen, katja_key *key);
203
204 #endif
205
206128 /* ---- DH Routines ---- */
207129 #ifdef LTC_MDH
208130
234156 void dh_free(dh_key *key);
235157
236158 int dh_export_key(void *out, unsigned long *outlen, int type, const dh_key *key);
237
238 #ifdef LTC_SOURCE
239 typedef struct {
240 int size;
241 const char *name, *base, *prime;
242 } ltc_dh_set_type;
243
244 extern const ltc_dh_set_type ltc_dh_sets[];
245
246 /* internal helper functions */
247 int dh_check_pubkey(const dh_key *key);
248 #endif
249
250159 #endif /* LTC_MDH */
251160
252161
346255 int ecc_generate_key(prng_state *prng, int wprng, ecc_key *key);
347256 int ecc_set_key(const unsigned char *in, unsigned long inlen, int type, ecc_key *key);
348257 int ecc_get_key(unsigned char *out, unsigned long *outlen, int type, const ecc_key *key);
258 int ecc_get_oid_str(char *out, unsigned long *outlen, const ecc_key *key);
349259
350260 int ecc_make_key(prng_state *prng, int wprng, int keysize, ecc_key *key);
351261 int ecc_make_key_ex(prng_state *prng, int wprng, ecc_key *key, const ltc_ecc_curve *cu);
391301 int ecc_verify_hash(const unsigned char *sig, unsigned long siglen,
392302 const unsigned char *hash, unsigned long hashlen,
393303 int *stat, const ecc_key *key);
394
395
396 #ifdef LTC_SOURCE
397 /* INTERNAL ONLY - it should be later moved to src/headers/tomcrypt_internal.h */
398
399 int ecc_set_dp_from_mpis(void *a, void *b, void *prime, void *order, void *gx, void *gy, unsigned long cofactor, ecc_key *key);
400 int ecc_copy_dp(const ecc_key *srckey, ecc_key *key);
401 int ecc_set_dp_by_size(int size, ecc_key *key);
402
403 /* low level functions */
404 ecc_point *ltc_ecc_new_point(void);
405 void ltc_ecc_del_point(ecc_point *p);
406 int ltc_ecc_set_point_xyz(ltc_mp_digit x, ltc_mp_digit y, ltc_mp_digit z, ecc_point *p);
407 int ltc_ecc_copy_point(const ecc_point *src, ecc_point *dst);
408 int ltc_ecc_is_point(const ltc_ecc_dp *dp, void *x, void *y);
409 int ltc_ecc_is_point_at_infinity(const ecc_point *P, void *modulus, int *retval);
410 int ltc_ecc_import_point(const unsigned char *in, unsigned long inlen, void *prime, void *a, void *b, void *x, void *y);
411 int ltc_ecc_export_point(unsigned char *out, unsigned long *outlen, void *x, void *y, unsigned long size, int compressed);
412 int ltc_ecc_verify_key(const ecc_key *key);
413
414 /* point ops (mp == montgomery digit) */
415 #if !defined(LTC_MECC_ACCEL) || defined(LTM_DESC) || defined(GMP_DESC)
416 /* R = 2P */
417 int ltc_ecc_projective_dbl_point(const ecc_point *P, ecc_point *R, void *ma, void *modulus, void *mp);
418
419 /* R = P + Q */
420 int ltc_ecc_projective_add_point(const ecc_point *P, const ecc_point *Q, ecc_point *R, void *ma, void *modulus, void *mp);
421 #endif
422
423 #if defined(LTC_MECC_FP)
424 /* optimized point multiplication using fixed point cache (HAC algorithm 14.117) */
425 int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *a, void *modulus, int map);
426
427 /* functions for saving/loading/freeing/adding to fixed point cache */
428 int ltc_ecc_fp_save_state(unsigned char **out, unsigned long *outlen);
429 int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen);
430 void ltc_ecc_fp_free(void);
431 int ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock);
432
433 /* lock/unlock all points currently in fixed point cache */
434 void ltc_ecc_fp_tablelock(int lock);
435 #endif
436
437 /* R = kG */
438 int ltc_ecc_mulmod(void *k, const ecc_point *G, ecc_point *R, void *a, void *modulus, int map);
439
440 #ifdef LTC_ECC_SHAMIR
441 /* kA*A + kB*B = C */
442 int ltc_ecc_mul2add(const ecc_point *A, void *kA,
443 const ecc_point *B, void *kB,
444 ecc_point *C,
445 void *ma,
446 void *modulus);
447
448 #ifdef LTC_MECC_FP
449 /* Shamir's trick with optimized point multiplication using fixed point cache */
450 int ltc_ecc_fp_mul2add(const ecc_point *A, void *kA,
451 const ecc_point *B, void *kB,
452 ecc_point *C,
453 void *ma,
454 void *modulus);
455 #endif
456
457 #endif
458
459
460 /* map P to affine from projective */
461 int ltc_ecc_map(ecc_point *P, void *modulus, void *mp);
462
463 #endif /* LTC_SOURCE */
464304
465305 #endif
466306
538378 int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key);
539379 int dsa_export(unsigned char *out, unsigned long *outlen, int type, const dsa_key *key);
540380 int dsa_verify_key(const dsa_key *key, int *stat);
541 #ifdef LTC_SOURCE
542 /* internal helper functions */
543 int dsa_int_validate_xy(const dsa_key *key, int *stat);
544 int dsa_int_validate_pqg(const dsa_key *key, int *stat);
545 int dsa_int_validate_primes(const dsa_key *key, int *stat);
546 #endif
547381 int dsa_shared_secret(void *private_key, void *base,
548382 const dsa_key *public_key,
549383 unsigned char *out, unsigned long *outlen);
550 #endif
384 #endif /* LTC_MDSA */
551385
552386 #ifdef LTC_DER
553387 /* DER handling */
710544 unsigned long *outlen,
711545 unsigned long *payloadlen);
712546
713 #ifdef LTC_SOURCE
714 /* internal helper functions */
715 int der_decode_custom_type_ex(const unsigned char *in, unsigned long inlen,
716 ltc_asn1_list *root,
717 ltc_asn1_list *list, unsigned long outlen, unsigned int flags);
718
719 int der_encode_asn1_identifier(const ltc_asn1_list *id, unsigned char *out, unsigned long *outlen);
720 int der_decode_asn1_identifier(const unsigned char *in, unsigned long *inlen, ltc_asn1_list *id);
721 int der_length_asn1_identifier(const ltc_asn1_list *id, unsigned long *idlen);
722
723 int der_encode_asn1_length(unsigned long len, unsigned char* out, unsigned long* outlen);
724 int der_decode_asn1_length(const unsigned char* len, unsigned long* lenlen, unsigned long* outlen);
725 int der_length_asn1_length(unsigned long len, unsigned long *outlen);
726
727 int der_length_sequence_ex(const ltc_asn1_list *list, unsigned long inlen,
728 unsigned long *outlen, unsigned long *payloadlen);
729
730 extern const ltc_asn1_type der_asn1_tag_to_type_map[];
731 extern const unsigned long der_asn1_tag_to_type_map_sz;
732
733 extern const int der_asn1_type_to_identifier_map[];
734 extern const unsigned long der_asn1_type_to_identifier_map_sz;
735 #endif /* LTC_SOURCE */
736
737547 /* SET */
738548 #define der_decode_set(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, LTC_DER_SEQ_SET)
739549 #define der_length_set der_length_sequence
746556 /* VA list handy helpers with triplets of <type, size, data> */
747557 int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...);
748558 int der_decode_sequence_multi(const unsigned char *in, unsigned long inlen, ...);
749 #ifdef LTC_SOURCE
750 /* internal helper functions */
751 int der_decode_sequence_multi_ex(const unsigned char *in, unsigned long inlen, unsigned int flags, ...);
752 #endif /* LTC_SOURCE */
753559
754560 /* FLEXI DECODER handle unknown list decoder */
755561 int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc_asn1_list **out);
814620 unsigned char *out, unsigned long *outlen);
815621 int der_length_teletex_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen);
816622
817 #ifdef LTC_SOURCE
818 /* internal helper functions */
819 int der_teletex_char_encode(int c);
820 int der_teletex_value_decode(int v);
821 #endif /* LTC_SOURCE */
822
823
824623 /* PRINTABLE STRING */
825624 int der_encode_printable_string(const unsigned char *in, unsigned long inlen,
826625 unsigned char *out, unsigned long *outlen);
833632
834633 /* UTF-8 */
835634 #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)
836 #include <wchar.h>
837 #if defined(__WCHAR_MAX__)
838 #define LTC_WCHAR_MAX __WCHAR_MAX__
839 #elif defined(WCHAR_MAX)
840 #define LTC_WCHAR_MAX WCHAR_MAX
841 #endif
635 #if defined(__WCHAR_MAX__)
636 #define LTC_WCHAR_MAX __WCHAR_MAX__
637 #else
638 #include <wchar.h>
639 #define LTC_WCHAR_MAX WCHAR_MAX
640 #endif
842641 /* please note that it might happen that LTC_WCHAR_MAX is undefined */
843642 #else
844 typedef ulong32 wchar_t;
845 #define LTC_WCHAR_MAX 0xFFFFFFFF
643 typedef ulong32 wchar_t;
644 #define LTC_WCHAR_MAX 0xFFFFFFFF
846645 #endif
847646
848647 int der_encode_utf8_string(const wchar_t *in, unsigned long inlen,
851650 int der_decode_utf8_string(const unsigned char *in, unsigned long inlen,
852651 wchar_t *out, unsigned long *outlen);
853652 unsigned long der_utf8_charsize(const wchar_t c);
854 #ifdef LTC_SOURCE
855 /* internal helper functions */
856 int der_utf8_valid_char(const wchar_t c);
857 #endif /* LTC_SOURCE */
858653 int der_length_utf8_string(const wchar_t *in, unsigned long noctets, unsigned long *outlen);
859654
860655
905700
906701 int der_length_generalizedtime(const ltc_generalizedtime *gtime, unsigned long *outlen);
907702
908 #ifdef LTC_SOURCE
909 /* internal helper functions */
910 /* SUBJECT PUBLIC KEY INFO */
911 int x509_encode_subject_public_key_info(unsigned char *out, unsigned long *outlen,
912 unsigned int algorithm, const void* public_key, unsigned long public_key_len,
913 ltc_asn1_type parameters_type, ltc_asn1_list* parameters, unsigned long parameters_len);
914
915 int x509_decode_subject_public_key_info(const unsigned char *in, unsigned long inlen,
916 unsigned int algorithm, void* public_key, unsigned long* public_key_len,
917 ltc_asn1_type parameters_type, ltc_asn1_list* parameters, unsigned long *parameters_len);
918 #endif /* LTC_SOURCE */
919
920703 #endif
921704
922705 /* ref: $Format:%D$ */
0 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
1 *
2 * LibTomCrypt is a library that provides various cryptographic
3 * algorithms in a highly modular and flexible manner.
4 *
5 * The library is free for all purposes without any express
6 * guarantee it works.
7 */
8
9 #include "tomcrypt.h"
10
11 /*
12 * Internal Macros
13 */
14
15 #define LTC_PAD_MASK (0xF000U)
16
17 /*
18 * Internal Enums
19 */
20
21 enum public_key_algorithms {
22 PKA_RSA,
23 PKA_DSA,
24 PKA_EC,
25 PKA_EC_PRIMEF
26 };
27
28 /*
29 * Internal Types
30 */
31
32 typedef struct Oid {
33 unsigned long OID[16];
34 /** Number of OID digits in use */
35 unsigned long OIDlen;
36 } oid_st;
37
38 typedef struct {
39 int size;
40 const char *name, *base, *prime;
41 } ltc_dh_set_type;
42
43
44 /*
45 * Internal functions
46 */
47
48 /* tomcrypt_hash.h */
49
50 /* a simple macro for making hash "process" functions */
51 #define HASH_PROCESS(func_name, compress_name, state_var, block_size) \
52 int func_name (hash_state * md, const unsigned char *in, unsigned long inlen) \
53 { \
54 unsigned long n; \
55 int err; \
56 LTC_ARGCHK(md != NULL); \
57 LTC_ARGCHK(in != NULL); \
58 if (md-> state_var .curlen > sizeof(md-> state_var .buf)) { \
59 return CRYPT_INVALID_ARG; \
60 } \
61 if ((md-> state_var .length + inlen) < md-> state_var .length) { \
62 return CRYPT_HASH_OVERFLOW; \
63 } \
64 while (inlen > 0) { \
65 if (md-> state_var .curlen == 0 && inlen >= block_size) { \
66 if ((err = compress_name (md, in)) != CRYPT_OK) { \
67 return err; \
68 } \
69 md-> state_var .length += block_size * 8; \
70 in += block_size; \
71 inlen -= block_size; \
72 } else { \
73 n = MIN(inlen, (block_size - md-> state_var .curlen)); \
74 XMEMCPY(md-> state_var .buf + md-> state_var.curlen, in, (size_t)n); \
75 md-> state_var .curlen += n; \
76 in += n; \
77 inlen -= n; \
78 if (md-> state_var .curlen == block_size) { \
79 if ((err = compress_name (md, md-> state_var .buf)) != CRYPT_OK) { \
80 return err; \
81 } \
82 md-> state_var .length += 8*block_size; \
83 md-> state_var .curlen = 0; \
84 } \
85 } \
86 } \
87 return CRYPT_OK; \
88 }
89
90
91 /* tomcrypt_mac.h */
92
93 int ocb3_int_ntz(unsigned long x);
94 void ocb3_int_xor_blocks(unsigned char *out, const unsigned char *block_a, const unsigned char *block_b, unsigned long block_len);
95
96
97 /* tomcrypt_math.h */
98
99 #if !defined(DESC_DEF_ONLY)
100
101 #define MP_DIGIT_BIT ltc_mp.bits_per_digit
102
103 /* some handy macros */
104 #define mp_init(a) ltc_mp.init(a)
105 #define mp_init_multi ltc_init_multi
106 #define mp_clear(a) ltc_mp.deinit(a)
107 #define mp_clear_multi ltc_deinit_multi
108 #define mp_cleanup_multi ltc_cleanup_multi
109 #define mp_init_copy(a, b) ltc_mp.init_copy(a, b)
110
111 #define mp_neg(a, b) ltc_mp.neg(a, b)
112 #define mp_copy(a, b) ltc_mp.copy(a, b)
113
114 #define mp_set(a, b) ltc_mp.set_int(a, b)
115 #define mp_set_int(a, b) ltc_mp.set_int(a, b)
116 #define mp_get_int(a) ltc_mp.get_int(a)
117 #define mp_get_digit(a, n) ltc_mp.get_digit(a, n)
118 #define mp_get_digit_count(a) ltc_mp.get_digit_count(a)
119 #define mp_cmp(a, b) ltc_mp.compare(a, b)
120 #define mp_cmp_d(a, b) ltc_mp.compare_d(a, b)
121 #define mp_count_bits(a) ltc_mp.count_bits(a)
122 #define mp_cnt_lsb(a) ltc_mp.count_lsb_bits(a)
123 #define mp_2expt(a, b) ltc_mp.twoexpt(a, b)
124
125 #define mp_read_radix(a, b, c) ltc_mp.read_radix(a, b, c)
126 #define mp_toradix(a, b, c) ltc_mp.write_radix(a, b, c)
127 #define mp_unsigned_bin_size(a) ltc_mp.unsigned_size(a)
128 #define mp_to_unsigned_bin(a, b) ltc_mp.unsigned_write(a, b)
129 #define mp_read_unsigned_bin(a, b, c) ltc_mp.unsigned_read(a, b, c)
130
131 #define mp_add(a, b, c) ltc_mp.add(a, b, c)
132 #define mp_add_d(a, b, c) ltc_mp.addi(a, b, c)
133 #define mp_sub(a, b, c) ltc_mp.sub(a, b, c)
134 #define mp_sub_d(a, b, c) ltc_mp.subi(a, b, c)
135 #define mp_mul(a, b, c) ltc_mp.mul(a, b, c)
136 #define mp_mul_d(a, b, c) ltc_mp.muli(a, b, c)
137 #define mp_sqr(a, b) ltc_mp.sqr(a, b)
138 #define mp_sqrtmod_prime(a, b, c) ltc_mp.sqrtmod_prime(a, b, c)
139 #define mp_div(a, b, c, d) ltc_mp.mpdiv(a, b, c, d)
140 #define mp_div_2(a, b) ltc_mp.div_2(a, b)
141 #define mp_mod(a, b, c) ltc_mp.mpdiv(a, b, NULL, c)
142 #define mp_mod_d(a, b, c) ltc_mp.modi(a, b, c)
143 #define mp_gcd(a, b, c) ltc_mp.gcd(a, b, c)
144 #define mp_lcm(a, b, c) ltc_mp.lcm(a, b, c)
145
146 #define mp_addmod(a, b, c, d) ltc_mp.addmod(a, b, c, d)
147 #define mp_submod(a, b, c, d) ltc_mp.submod(a, b, c, d)
148 #define mp_mulmod(a, b, c, d) ltc_mp.mulmod(a, b, c, d)
149 #define mp_sqrmod(a, b, c) ltc_mp.sqrmod(a, b, c)
150 #define mp_invmod(a, b, c) ltc_mp.invmod(a, b, c)
151
152 #define mp_montgomery_setup(a, b) ltc_mp.montgomery_setup(a, b)
153 #define mp_montgomery_normalization(a, b) ltc_mp.montgomery_normalization(a, b)
154 #define mp_montgomery_reduce(a, b, c) ltc_mp.montgomery_reduce(a, b, c)
155 #define mp_montgomery_free(a) ltc_mp.montgomery_deinit(a)
156
157 #define mp_exptmod(a,b,c,d) ltc_mp.exptmod(a,b,c,d)
158 #define mp_prime_is_prime(a, b, c) ltc_mp.isprime(a, b, c)
159
160 #define mp_iszero(a) (mp_cmp_d(a, 0) == LTC_MP_EQ ? LTC_MP_YES : LTC_MP_NO)
161 #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)
162 #define mp_exch(a, b) do { void *ABC__tmp = a; a = b; b = ABC__tmp; } while(0)
163
164 #define mp_tohex(a, b) mp_toradix(a, b, 16)
165
166 #define mp_rand(a, b) ltc_mp.rand(a, b)
167
168 #endif
169
170
171 /* tomcrypt_misc.h */
172
173 void copy_or_zeromem(const unsigned char* src, unsigned char* dest, unsigned long len, int coz);
174
175
176 /* tomcrypt_pk.h */
177
178 int rand_bn_bits(void *N, int bits, prng_state *prng, int wprng);
179 int rand_bn_upto(void *N, void *limit, prng_state *prng, int wprng);
180
181 int pk_get_oid(int pk, oid_st *st);
182 int pk_oid_str_to_num(const char *OID, unsigned long *oid, unsigned long *oidlen);
183 int pk_oid_num_to_str(const unsigned long *oid, unsigned long oidlen, char *OID, unsigned long *outlen);
184
185 /* ---- DH Routines ---- */
186 #ifdef LTC_MDH
187 extern const ltc_dh_set_type ltc_dh_sets[];
188
189 int dh_check_pubkey(const dh_key *key);
190 #endif /* LTC_MDH */
191
192 /* ---- ECC Routines ---- */
193 #ifdef LTC_MECC
194 int ecc_set_dp_from_mpis(void *a, void *b, void *prime, void *order, void *gx, void *gy, unsigned long cofactor, ecc_key *key);
195 int ecc_copy_dp(const ecc_key *srckey, ecc_key *key);
196 int ecc_set_dp_by_size(int size, ecc_key *key);
197
198 /* low level functions */
199 ecc_point *ltc_ecc_new_point(void);
200 void ltc_ecc_del_point(ecc_point *p);
201 int ltc_ecc_set_point_xyz(ltc_mp_digit x, ltc_mp_digit y, ltc_mp_digit z, ecc_point *p);
202 int ltc_ecc_copy_point(const ecc_point *src, ecc_point *dst);
203 int ltc_ecc_is_point(const ltc_ecc_dp *dp, void *x, void *y);
204 int ltc_ecc_is_point_at_infinity(const ecc_point *P, void *modulus, int *retval);
205 int ltc_ecc_import_point(const unsigned char *in, unsigned long inlen, void *prime, void *a, void *b, void *x, void *y);
206 int ltc_ecc_export_point(unsigned char *out, unsigned long *outlen, void *x, void *y, unsigned long size, int compressed);
207 int ltc_ecc_verify_key(const ecc_key *key);
208
209 /* point ops (mp == montgomery digit) */
210 #if !defined(LTC_MECC_ACCEL) || defined(LTM_DESC) || defined(GMP_DESC)
211 /* R = 2P */
212 int ltc_ecc_projective_dbl_point(const ecc_point *P, ecc_point *R, void *ma, void *modulus, void *mp);
213
214 /* R = P + Q */
215 int ltc_ecc_projective_add_point(const ecc_point *P, const ecc_point *Q, ecc_point *R, void *ma, void *modulus, void *mp);
216 #endif
217
218 #if defined(LTC_MECC_FP)
219 /* optimized point multiplication using fixed point cache (HAC algorithm 14.117) */
220 int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *a, void *modulus, int map);
221
222 /* functions for saving/loading/freeing/adding to fixed point cache */
223 int ltc_ecc_fp_save_state(unsigned char **out, unsigned long *outlen);
224 int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen);
225 void ltc_ecc_fp_free(void);
226 int ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock);
227
228 /* lock/unlock all points currently in fixed point cache */
229 void ltc_ecc_fp_tablelock(int lock);
230 #endif
231
232 /* R = kG */
233 int ltc_ecc_mulmod(void *k, const ecc_point *G, ecc_point *R, void *a, void *modulus, int map);
234
235 #ifdef LTC_ECC_SHAMIR
236 /* kA*A + kB*B = C */
237 int ltc_ecc_mul2add(const ecc_point *A, void *kA,
238 const ecc_point *B, void *kB,
239 ecc_point *C,
240 void *ma,
241 void *modulus);
242
243 #ifdef LTC_MECC_FP
244 /* Shamir's trick with optimized point multiplication using fixed point cache */
245 int ltc_ecc_fp_mul2add(const ecc_point *A, void *kA,
246 const ecc_point *B, void *kB,
247 ecc_point *C,
248 void *ma,
249 void *modulus);
250 #endif
251
252 #endif
253
254
255 /* map P to affine from projective */
256 int ltc_ecc_map(ecc_point *P, void *modulus, void *mp);
257 #endif /* LTC_MECC */
258
259 #ifdef LTC_MDSA
260 int dsa_int_validate_xy(const dsa_key *key, int *stat);
261 int dsa_int_validate_pqg(const dsa_key *key, int *stat);
262 int dsa_int_validate_primes(const dsa_key *key, int *stat);
263 #endif /* LTC_MDSA */
264
265 #ifdef LTC_DER
266 /* DER handling */
267 int der_decode_custom_type_ex(const unsigned char *in, unsigned long inlen,
268 ltc_asn1_list *root,
269 ltc_asn1_list *list, unsigned long outlen, unsigned int flags);
270
271 int der_encode_asn1_identifier(const ltc_asn1_list *id, unsigned char *out, unsigned long *outlen);
272 int der_decode_asn1_identifier(const unsigned char *in, unsigned long *inlen, ltc_asn1_list *id);
273 int der_length_asn1_identifier(const ltc_asn1_list *id, unsigned long *idlen);
274
275 int der_encode_asn1_length(unsigned long len, unsigned char* out, unsigned long* outlen);
276 int der_decode_asn1_length(const unsigned char* len, unsigned long* lenlen, unsigned long* outlen);
277 int der_length_asn1_length(unsigned long len, unsigned long *outlen);
278
279 int der_length_sequence_ex(const ltc_asn1_list *list, unsigned long inlen,
280 unsigned long *outlen, unsigned long *payloadlen);
281
282 extern const ltc_asn1_type der_asn1_tag_to_type_map[];
283 extern const unsigned long der_asn1_tag_to_type_map_sz;
284
285 extern const int der_asn1_type_to_identifier_map[];
286 extern const unsigned long der_asn1_type_to_identifier_map_sz;
287
288 int der_decode_sequence_multi_ex(const unsigned char *in, unsigned long inlen, unsigned int flags, ...);
289
290 int der_teletex_char_encode(int c);
291 int der_teletex_value_decode(int v);
292
293 int der_utf8_valid_char(const wchar_t c);
294
295 /* SUBJECT PUBLIC KEY INFO */
296 int x509_encode_subject_public_key_info(unsigned char *out, unsigned long *outlen,
297 unsigned int algorithm, const void* public_key, unsigned long public_key_len,
298 ltc_asn1_type parameters_type, ltc_asn1_list* parameters, unsigned long parameters_len);
299
300 int x509_decode_subject_public_key_info(const unsigned char *in, unsigned long inlen,
301 unsigned int algorithm, void* public_key, unsigned long* public_key_len,
302 ltc_asn1_type parameters_type, ltc_asn1_list* parameters, unsigned long *parameters_len);
303
304 #endif /* LTC_DER */
305
306 /* tomcrypt_prng.h */
307
308 #define _LTC_PRNG_EXPORT(which) \
309 int which ## _export(unsigned char *out, unsigned long *outlen, prng_state *prng) \
310 { \
311 unsigned long len = which ## _desc.export_size; \
312 \
313 LTC_ARGCHK(prng != NULL); \
314 LTC_ARGCHK(out != NULL); \
315 LTC_ARGCHK(outlen != NULL); \
316 \
317 if (*outlen < len) { \
318 *outlen = len; \
319 return CRYPT_BUFFER_OVERFLOW; \
320 } \
321 \
322 if (which ## _read(out, len, prng) != len) { \
323 return CRYPT_ERROR_READPRNG; \
324 } \
325 \
326 *outlen = len; \
327 return CRYPT_OK; \
328 }
329
330
331 /* ref: $Format:%D$ */
332 /* git commit: $Format:%H$ */
333 /* commit time: $Format:%ai$ */
1212 int cipher, hash;
1313 unsigned char pool[MAXBLOCKSIZE];
1414 symmetric_CTR ctr;
15 short ready; /* ready flag 0-1 */
16 LTC_MUTEX_TYPE(lock) /* lock */
1715 };
1816 #endif
1917
2018 #ifdef LTC_RC4
2119 struct rc4_prng {
2220 rc4_state s;
23 short ready; /* ready flag 0-1 */
24 LTC_MUTEX_TYPE(lock) /* lock */
2521 };
2622 #endif
2723
3026 chacha_state s; /* chacha state */
3127 unsigned char ent[40]; /* entropy buffer */
3228 unsigned long idx; /* entropy counter */
33 short ready; /* ready flag 0-1 */
34 LTC_MUTEX_TYPE(lock) /* lock */
3529 };
3630 #endif
3731
4539 IV[16]; /* IV for CTR mode */
4640
4741 unsigned long pool_idx, /* current pool we will add to */
48 pool0_len, /* length of 0'th pool */
49 wd;
50
42 pool0_len; /* length of 0'th pool */
43 ulong64 wd;
5144 ulong64 reset_cnt; /* number of times we have reseeded */
52 short ready; /* ready flag 0-1 */
53 LTC_MUTEX_TYPE(lock) /* lock */
5445 };
5546 #endif
5647
5950 sober128_state s; /* sober128 state */
6051 unsigned char ent[40]; /* entropy buffer */
6152 unsigned long idx; /* entropy counter */
62 short ready; /* ready flag 0-1 */
63 LTC_MUTEX_TYPE(lock) /* lock */
64 };
65 #endif
66
67 typedef union Prng_state {
68 char dummy[1];
53 };
54 #endif
55
56 typedef struct {
57 union {
58 char dummy[1];
6959 #ifdef LTC_YARROW
70 struct yarrow_prng yarrow;
60 struct yarrow_prng yarrow;
7161 #endif
7262 #ifdef LTC_RC4
73 struct rc4_prng rc4;
63 struct rc4_prng rc4;
7464 #endif
7565 #ifdef LTC_CHACHA20_PRNG
76 struct chacha20_prng chacha;
66 struct chacha20_prng chacha;
7767 #endif
7868 #ifdef LTC_FORTUNA
79 struct fortuna_prng fortuna;
69 struct fortuna_prng fortuna;
8070 #endif
8171 #ifdef LTC_SOBER128
82 struct sober128_prng sober128;
83 #endif
72 struct sober128_prng sober128;
73 #endif
74 } u;
75 short ready; /* ready flag 0-1 */
76 LTC_MUTEX_TYPE(lock) /* lock */
8477 } prng_state;
8578
8679 /** PRNG descriptor */
219212 int prng_is_valid(int idx);
220213 LTC_MUTEX_PROTO(ltc_prng_mutex)
221214
222 #ifdef LTC_SOURCE
223 /* internal helper functions */
224 #define _LTC_PRNG_EXPORT(which) \
225 int which ## _export(unsigned char *out, unsigned long *outlen, prng_state *prng) \
226 { \
227 unsigned long len = which ## _desc.export_size; \
228 \
229 LTC_ARGCHK(prng != NULL); \
230 LTC_ARGCHK(out != NULL); \
231 LTC_ARGCHK(outlen != NULL); \
232 \
233 if (*outlen < len) { \
234 *outlen = len; \
235 return CRYPT_BUFFER_OVERFLOW; \
236 } \
237 \
238 if (which ## _read(out, len, prng) != len) { \
239 return CRYPT_ERROR_READPRNG; \
240 } \
241 \
242 *outlen = len; \
243 return CRYPT_OK; \
244 }
245 #endif
246
247215 /* Slow RNG you **might** be able to use to seed a PRNG with. Be careful as this
248216 * might not work on all platforms as planned
249217 */
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 #ifdef LTC_BLAKE2BMAC
1212
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 #ifdef LTC_BLAKE2BMAC
1212
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 #ifdef LTC_BLAKE2BMAC
1212
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010 #include <stdarg.h>
1111
1212 #ifdef LTC_BLAKE2BMAC
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 #ifdef LTC_BLAKE2SMAC
1212
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 #ifdef LTC_BLAKE2SMAC
1212
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 #ifdef LTC_BLAKE2SMAC
1212
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010 #include <stdarg.h>
1111
1212 #ifdef LTC_BLAKE2SMAC
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file f9_done.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file f9_file.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file f9_init.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file f9_process.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99 #include <stdarg.h>
1010
1111 /**
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file f9_process.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file hmac_done.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file hmac_file.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file hmac_init.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file hmac_memory.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99 #include <stdarg.h>
1010
1111 /**
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file hmac_process.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file omac_done.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file omac_file.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file omac_init.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file omac_memory.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99 #include <stdarg.h>
1010
1111 /**
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file omac_process.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file pelican.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file pelican_memory.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file pmac_done.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file pmac_file.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file pmac_init.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file pmac_memory.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99 #include <stdarg.h>
1010
1111 /**
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file pmac_ntz.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file pmac_process.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file pmac_shift_xor.c
1111 * https://github.com/floodyberry/poly1305-donna
1212 */
1313
14 #include "tomcrypt.h"
14 #include "tomcrypt_private.h"
1515
1616 #ifdef LTC_POLY1305
1717
1111 * https://github.com/floodyberry/poly1305-donna
1212 */
1313
14 #include "tomcrypt.h"
14 #include "tomcrypt_private.h"
1515
1616 #ifdef LTC_POLY1305
1717
1111 * https://github.com/floodyberry/poly1305-donna
1212 */
1313
14 #include "tomcrypt.h"
14 #include "tomcrypt_private.h"
1515
1616 #ifdef LTC_POLY1305
1717
1111 * https://github.com/floodyberry/poly1305-donna
1212 */
1313
14 #include "tomcrypt.h"
14 #include "tomcrypt_private.h"
1515 #include <stdarg.h>
1616
1717 #ifdef LTC_POLY1305
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file xcbc_done.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file xcbc_file.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file xcbc_init.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file xcbc_process.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99 #include <stdarg.h>
1010
1111 /**
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file xcbc_process.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file ltc_ecc_fp_mulmod.c
77 */
88
99 #define DESC_DEF_ONLY
10 #include "tomcrypt.h"
10 #include "tomcrypt_private.h"
1111
1212 #ifdef LTM_DESC
1313
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 #ifdef LTC_MPI
1111 #include <stdarg.h>
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file radix_to_bin.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 #if defined(LTC_MDSA) || defined(LTC_MECC)
1111 /**
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 #if defined(LTC_MRSA) || (!defined(LTC_NO_MATH) && !defined(LTC_NO_PRNGS))
1111
77 */
88
99 #define DESC_DEF_ONLY
10 #include "tomcrypt.h"
10 #include "tomcrypt_private.h"
1111
1212 #ifdef TFM_DESC
1313
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file adler32.c
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 /**
1212 @file base16_decode.c
2020 /**
2121 Base16 decode a string
2222 @param in The Base16 string to decode
23 @param inlen The length of the Base16 data
2324 @param out [out] The destination of the binary decoded data
2425 @param outlen [in/out] The max size and resulting size of the decoded data
2526 @return CRYPT_OK if successful
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 /**
1212 @file base16_encode.c
2121 @param inlen The length of the input buffer
2222 @param out [out] The destination of the Base16 encoded data
2323 @param outlen [in/out] The max size and resulting size of the encoded data
24 @param caps Output 'a-f' on 0 and 'A-F' otherwise.
24 @param options Output 'a-f' on 0 and 'A-F' otherwise.
2525 @return CRYPT_OK if successful
2626 */
2727 int base16_encode(const unsigned char *in, unsigned long inlen,
2828 char *out, unsigned long *outlen,
29 int caps)
29 unsigned int options)
3030 {
3131 unsigned long i, x;
3232 const char *alphabet;
5151 x--;
5252 *outlen = x; /* returning the length without terminating NUL */
5353
54 if (caps == 0) alphabet = alphabets[0];
54 if (options == 0) alphabet = alphabets[0];
5555 else alphabet = alphabets[1];
5656
5757 for (i = 0; i < x; i += 2) {
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 #ifdef LTC_BASE32
1212
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 #ifdef LTC_BASE32
1212
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file base64_decode.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file base64_encode.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file burn_stack.c
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 /**
1212 @file compare_testvector.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file copy_or_zeromem.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crc32.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt.c
134134 #if defined(LTC_SALSA20)
135135 " Salsa20\n"
136136 #endif
137 #if defined(LTC_XSALSA20)
138 " XSalsa20\n"
139 #endif
137140 #if defined(LTC_SOSEMANUK)
138141 " Sosemanuk\n"
139142 #endif
349352 #if defined(LTC_MDSA)
350353 " DSA\n"
351354 #endif
352 #if defined(LTC_MKAT)
353 " Katja\n"
354 #endif
355355 #if defined(LTC_PK_MAX_RETRIES)
356356 " "NAME_VALUE(LTC_PK_MAX_RETRIES)"\n"
357357 #endif
514514 " LTC_MECC_ACCEL "
515515 #endif
516516 #if defined(LTC_MECC_FP)
517 " LTC_MECC_FP "
517 " LTC_MECC_FP "
518518 #endif
519519 #if defined(LTC_ECC_SHAMIR)
520 " LTC_ECC_SHAMIR "
520 " LTC_ECC_SHAMIR "
521 #endif
522 #if defined(LTC_CLOCK_GETTIME)
523 " LTC_CLOCK_GETTIME "
521524 #endif
522525 "\n"
523526 ;
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_argchk.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_cipher_descriptor.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_cipher_is_valid.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_constants.c
9595 {"LTC_MRSA", 0},
9696 #endif
9797
98 #ifdef LTC_MKAT
99 {"LTC_MKAT", 1},
100 _C_STRINGIFY(MIN_KAT_SIZE),
101 _C_STRINGIFY(MAX_KAT_SIZE),
102 #else
103 {"LTC_MKAT", 0},
104 #endif
105
10698 #ifdef LTC_MECC
10799 {"LTC_MECC", 1},
108100 _C_STRINGIFY(ECC_BUF_SIZE),
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_find_cipher.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_find_cipher_any.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_find_cipher_id.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_find_hash.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_find_hash_any.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_find_hash_id.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_find_hash_oid.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_find_prng.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99 #include <stdarg.h>
1010
1111 /**
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_hash_descriptor.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_hash_is_valid.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_inits.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /* Initialize ltc_mp to nulls, to force allocation on all platforms, including macOS. */
1111 ltc_math_descriptor ltc_mp = { 0 };
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_prng_descriptor.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_prng_is_valid.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 #ifdef LTC_PRNG_ENABLE_LTC_RNG
1111 unsigned long (*ltc_rng)(unsigned char *out, unsigned long outlen, void (*callback)(void));
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 /**
1212 @file crypt_register_all_ciphers.c
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 /**
1212 @file crypt_register_all_hashes.c
66 * guarantee it works.
77 */
88
9 #include "tomcrypt.h"
9 #include "tomcrypt_private.h"
1010
1111 /**
1212 @file crypt_register_all_prngs.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_register_cipher.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_register_hash.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8 #include "tomcrypt.h"
8 #include "tomcrypt_private.h"
99
1010 /**
1111 @file crypt_register_prng.c
55 * The library is free for all purposes without any express
66 * guarantee it works.
77 */
8