diff --git a/src/ltc/headers/tomcrypt_pk.h b/src/ltc/headers/tomcrypt_pk.h index 49eeda5..fc196d0 100644 --- a/src/ltc/headers/tomcrypt_pk.h +++ b/src/ltc/headers/tomcrypt_pk.h @@ -259,7 +259,6 @@ /** the ECC params provided */ extern const ltc_ecc_curve ltc_ecc_curves[]; -int ecc_test(void); void ecc_sizes(int *low, int *high); int ecc_get_size(const ecc_key *key); diff --git a/src/ltm/bn_mp_get_long.c b/src/ltm/bn_mp_get_long.c index bb9bd75..7a455df 100644 --- a/src/ltm/bn_mp_get_long.c +++ b/src/ltm/bn_mp_get_long.c @@ -37,3 +37,7 @@ return res; } #endif + +/* ref: $Format:%D$ */ +/* git commit: $Format:%H$ */ +/* commit time: $Format:%ai$ */ diff --git a/src/ltm/bn_mp_sqrtmod_prime.c b/src/ltm/bn_mp_sqrtmod_prime.c index f7647b9..6502f78 100644 --- a/src/ltm/bn_mp_sqrtmod_prime.c +++ b/src/ltm/bn_mp_sqrtmod_prime.c @@ -4,6 +4,10 @@ * * LibTomMath is a library that provides multiple-precision * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. * * The library is free for all purposes without any express * guarantee it works. @@ -122,3 +126,7 @@ } #endif + +/* ref: $Format:%D$ */ +/* git commit: $Format:%H$ */ +/* commit time: $Format:%ai$ */ diff --git a/src/ltm/tommath.h b/src/ltm/tommath.h index c6145f4..d7bff00 100644 --- a/src/ltm/tommath.h +++ b/src/ltm/tommath.h @@ -17,7 +17,7 @@ #include #include -#include +#include "tommath_class.h" #ifdef __cplusplus extern "C" { @@ -204,6 +204,9 @@ /* set to a digit */ void mp_set(mp_int *a, mp_digit b); +/* set a double */ +int mp_set_double(mp_int *a, double b); + /* set a 32-bit const */ int mp_set_int(mp_int *a, unsigned long b); @@ -212,6 +215,9 @@ /* set a platform dependent unsigned long long value */ /* int mp_set_long_long(mp_int *a, unsigned long long b); */ + +/* get a double */ +double mp_get_double(const mp_int *a); /* get a 32-bit value */ unsigned long mp_get_int(const mp_int *a); diff --git a/src/ltm/tommath_class.h b/src/ltm/tommath_class.h index 1989054..234d4da 100644 --- a/src/ltm/tommath_class.h +++ b/src/ltm/tommath_class.h @@ -1,3 +1,15 @@ +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + */ #if !(defined(LTM1) && defined(LTM2) && defined(LTM3)) #if defined(LTM2) # define LTM3 @@ -48,6 +60,7 @@ # define BN_MP_FREAD_C # define BN_MP_FWRITE_C # define BN_MP_GCD_C +# define BN_MP_GET_DOUBLE_C # define BN_MP_GET_INT_C # define BN_MP_GET_LONG_C # define BN_MP_GET_LONG_LONG_C @@ -105,6 +118,7 @@ # define BN_MP_REDUCE_SETUP_C # define BN_MP_RSHD_C # define BN_MP_SET_C +# define BN_MP_SET_DOUBLE_C # define BN_MP_SET_INT_C # define BN_MP_SET_LONG_C # define BN_MP_SET_LONG_LONG_C @@ -425,6 +439,10 @@ # define BN_MP_CLEAR_C #endif +#if defined(BN_MP_GET_DOUBLE_C) +# define BN_MP_ISNEG_C +#endif + #if defined(BN_MP_GET_INT_C) #endif @@ -833,6 +851,13 @@ # define BN_MP_ZERO_C #endif +#if defined(BN_MP_SET_DOUBLE_C) +# define BN_MP_SET_LONG_LONG_C +# define BN_MP_DIV_2D_C +# define BN_MP_MUL_2D_C +# define BN_MP_ISZERO_C +#endif + #if defined(BN_MP_SET_INT_C) # define BN_MP_ZERO_C # define BN_MP_MUL_2D_C @@ -1108,8 +1133,12 @@ # define LTM_LAST #endif -#include -#include +#include "tommath_superclass.h" +#include "tommath_class.h" #else # define LTM_LAST #endif + +/* ref: $Format:%D$ */ +/* git commit: $Format:%H$ */ +/* commit time: $Format:%ai$ */ diff --git a/src/ltm/tommath_superclass.h b/src/ltm/tommath_superclass.h index da53793..718c75d 100644 --- a/src/ltm/tommath_superclass.h +++ b/src/ltm/tommath_superclass.h @@ -1,3 +1,16 @@ +/* LibTomMath, multiple-precision integer library -- Tom St Denis + * + * LibTomMath is a library that provides multiple-precision + * integer arithmetic as well as number theoretic functionality. + * + * The library was designed directly after the MPI library by + * Michael Fromberger but has been written from scratch with + * additional optimizations in place. + * + * The library is free for all purposes without any express + * guarantee it works. + */ + /* super class file for PK algos */ /* default ... include all MPI */ diff --git a/src/update-libtom.pl b/src/update-libtom.pl index a42edd4..c8e7144 100755 --- a/src/update-libtom.pl +++ b/src/update-libtom.pl @@ -36,6 +36,8 @@ ### get rid of bn_mp_set_long_long + bn_mp_get_long_long system 'rm', '-rf', "$FindBin::Bin/ltm/bn_mp_set_long_long.c"; system 'rm', '-rf', "$FindBin::Bin/ltm/bn_mp_get_long_long.c"; +system 'rm', '-rf', "$FindBin::Bin/ltm/bn_mp_get_double.c"; +system 'rm', '-rf', "$FindBin::Bin/ltm/bn_mp_set_double.c"; system 'sed', '-i', 's,^\(int *mp_set_long_long.*\),/* \1 */,', 'src//ltm/tommath.h'; system 'sed', '-i', 's,^\(unsigned *long *long *mp_get_long_long.*\),/* \1 */,', 'src//ltm/tommath.h';