refactor indentation of preprocessor directives
This commit is contained in:
parent
aab1b3d99f
commit
82a2d385db
|
@ -24,9 +24,9 @@
|
|||
*/
|
||||
|
||||
#ifdef MP_LOW_MEM
|
||||
#define TAB_SIZE 32
|
||||
# define TAB_SIZE 32
|
||||
#else
|
||||
#define TAB_SIZE 256
|
||||
# define TAB_SIZE 256
|
||||
#endif
|
||||
|
||||
int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
* Tom St Denis, tstdenis82@gmail.com, http://libtom.org
|
||||
*/
|
||||
#ifdef MP_LOW_MEM
|
||||
#define TAB_SIZE 32
|
||||
# define TAB_SIZE 32
|
||||
#else
|
||||
#define TAB_SIZE 256
|
||||
# define TAB_SIZE 256
|
||||
#endif
|
||||
|
||||
int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
|
||||
|
|
68
tommath.h
68
tommath.h
|
@ -33,9 +33,9 @@ extern "C" {
|
|||
defined(__sparcv9) || defined(__sparc_v9__) || defined(__sparc64__) || \
|
||||
defined(__ia64) || defined(__ia64__) || defined(__itanium__) || defined(_M_IA64) || \
|
||||
defined(__LP64__) || defined(_LP64) || defined(__64BIT__)
|
||||
#if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
|
||||
#define MP_64BIT
|
||||
#endif
|
||||
# if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
|
||||
# define MP_64BIT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* some default configurations.
|
||||
|
@ -49,31 +49,31 @@ extern "C" {
|
|||
#ifdef MP_8BIT
|
||||
typedef uint8_t mp_digit;
|
||||
typedef uint16_t mp_word;
|
||||
#define MP_SIZEOF_MP_DIGIT 1
|
||||
#ifdef DIGIT_BIT
|
||||
#error You must not define DIGIT_BIT when using MP_8BIT
|
||||
#endif
|
||||
# define MP_SIZEOF_MP_DIGIT 1
|
||||
# ifdef DIGIT_BIT
|
||||
# error You must not define DIGIT_BIT when using MP_8BIT
|
||||
# endif
|
||||
#elif defined(MP_16BIT)
|
||||
typedef uint16_t mp_digit;
|
||||
typedef uint32_t mp_word;
|
||||
#define MP_SIZEOF_MP_DIGIT 2
|
||||
#ifdef DIGIT_BIT
|
||||
#error You must not define DIGIT_BIT when using MP_16BIT
|
||||
#endif
|
||||
# define MP_SIZEOF_MP_DIGIT 2
|
||||
# ifdef DIGIT_BIT
|
||||
# error You must not define DIGIT_BIT when using MP_16BIT
|
||||
# endif
|
||||
#elif defined(MP_64BIT)
|
||||
/* for GCC only on supported platforms */
|
||||
typedef uint64_t mp_digit;
|
||||
#if defined(_WIN32)
|
||||
# if defined(_WIN32)
|
||||
typedef unsigned __int128 mp_word;
|
||||
#elif defined(__GNUC__)
|
||||
# elif defined(__GNUC__)
|
||||
typedef unsigned long mp_word __attribute__ ((mode(TI)));
|
||||
#else
|
||||
# else
|
||||
/* it seems you have a problem
|
||||
* but we assume you can somewhere define your own uint128_t */
|
||||
typedef uint128_t mp_word;
|
||||
#endif
|
||||
# endif
|
||||
|
||||
#define DIGIT_BIT 60
|
||||
# define DIGIT_BIT 60
|
||||
#else
|
||||
/* this is the default case, 28-bit digits */
|
||||
|
||||
|
@ -81,19 +81,19 @@ extern "C" {
|
|||
typedef uint32_t mp_digit;
|
||||
typedef uint64_t mp_word;
|
||||
|
||||
#ifdef MP_31BIT
|
||||
# ifdef MP_31BIT
|
||||
/* this is an extension that uses 31-bit digits */
|
||||
#define DIGIT_BIT 31
|
||||
#else
|
||||
# define DIGIT_BIT 31
|
||||
# else
|
||||
/* default case is 28-bit digits, defines MP_28BIT as a handy macro to test */
|
||||
#define DIGIT_BIT 28
|
||||
#define MP_28BIT
|
||||
#endif
|
||||
# define DIGIT_BIT 28
|
||||
# define MP_28BIT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* otherwise the bits per digit is calculated automatically from the size of a mp_digit */
|
||||
#ifndef DIGIT_BIT
|
||||
#define DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */
|
||||
# define DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */
|
||||
typedef uint_least32_t mp_min_u32;
|
||||
#else
|
||||
typedef mp_digit mp_min_u32;
|
||||
|
@ -101,14 +101,14 @@ extern "C" {
|
|||
|
||||
/* use arc4random on platforms that support it */
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
|
||||
#define MP_GEN_RANDOM() arc4random()
|
||||
#define MP_GEN_RANDOM_MAX 0xffffffff
|
||||
# define MP_GEN_RANDOM() arc4random()
|
||||
# define MP_GEN_RANDOM_MAX 0xffffffff
|
||||
#endif
|
||||
|
||||
/* use rand() as fall-back if there's no better rand function */
|
||||
#ifndef MP_GEN_RANDOM
|
||||
#define MP_GEN_RANDOM() rand()
|
||||
#define MP_GEN_RANDOM_MAX RAND_MAX
|
||||
# define MP_GEN_RANDOM() rand()
|
||||
# define MP_GEN_RANDOM_MAX RAND_MAX
|
||||
#endif
|
||||
|
||||
#define MP_DIGIT_BIT DIGIT_BIT
|
||||
|
@ -149,11 +149,11 @@ extern int KARATSUBA_MUL_CUTOFF,
|
|||
|
||||
/* default precision */
|
||||
#ifndef MP_PREC
|
||||
#ifndef MP_LOW_MEM
|
||||
#define MP_PREC 32 /* default digits of precision */
|
||||
#else
|
||||
#define MP_PREC 8 /* default digits of precision */
|
||||
#endif
|
||||
# ifndef MP_LOW_MEM
|
||||
# define MP_PREC 32 /* default digits of precision */
|
||||
# else
|
||||
# define MP_PREC 8 /* default digits of precision */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
|
||||
|
@ -455,9 +455,9 @@ int mp_exptmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d);
|
|||
|
||||
/* number of primes */
|
||||
#ifdef MP_8BIT
|
||||
#define PRIME_SIZE 31
|
||||
# define PRIME_SIZE 31
|
||||
#else
|
||||
#define PRIME_SIZE 256
|
||||
# define PRIME_SIZE 256
|
||||
#endif
|
||||
|
||||
/* table of first PRIME_SIZE primes */
|
||||
|
|
1315
tommath_class.h
1315
tommath_class.h
File diff suppressed because it is too large
Load Diff
|
@ -30,22 +30,22 @@
|
|||
extern "C" {
|
||||
|
||||
/* C++ compilers don't like assigning void * to mp_digit * */
|
||||
#define OPT_CAST(x) (x *)
|
||||
#define OPT_CAST(x) (x *)
|
||||
|
||||
#else
|
||||
|
||||
/* C on the other hand doesn't care */
|
||||
#define OPT_CAST(x)
|
||||
#define OPT_CAST(x)
|
||||
|
||||
#endif
|
||||
|
||||
/* define heap macros */
|
||||
#ifndef XMALLOC
|
||||
/* default to libc stuff */
|
||||
#define XMALLOC malloc
|
||||
#define XFREE free
|
||||
#define XREALLOC realloc
|
||||
#define XCALLOC calloc
|
||||
# define XMALLOC malloc
|
||||
# define XFREE free
|
||||
# define XREALLOC realloc
|
||||
# define XCALLOC calloc
|
||||
#else
|
||||
/* prototypes for our heap functions */
|
||||
extern void *XMALLOC(size_t n);
|
||||
|
|
|
@ -14,60 +14,60 @@
|
|||
|
||||
/* Works for RSA only, mpi.o is 68KiB */
|
||||
#ifdef SC_RSA_1
|
||||
#define BN_MP_SHRINK_C
|
||||
#define BN_MP_LCM_C
|
||||
#define BN_MP_PRIME_RANDOM_EX_C
|
||||
#define BN_MP_INVMOD_C
|
||||
#define BN_MP_GCD_C
|
||||
#define BN_MP_MOD_C
|
||||
#define BN_MP_MULMOD_C
|
||||
#define BN_MP_ADDMOD_C
|
||||
#define BN_MP_EXPTMOD_C
|
||||
#define BN_MP_SET_INT_C
|
||||
#define BN_MP_INIT_MULTI_C
|
||||
#define BN_MP_CLEAR_MULTI_C
|
||||
#define BN_MP_UNSIGNED_BIN_SIZE_C
|
||||
#define BN_MP_TO_UNSIGNED_BIN_C
|
||||
#define BN_MP_MOD_D_C
|
||||
#define BN_MP_PRIME_RABIN_MILLER_TRIALS_C
|
||||
#define BN_REVERSE_C
|
||||
#define BN_PRIME_TAB_C
|
||||
# define BN_MP_SHRINK_C
|
||||
# define BN_MP_LCM_C
|
||||
# define BN_MP_PRIME_RANDOM_EX_C
|
||||
# define BN_MP_INVMOD_C
|
||||
# define BN_MP_GCD_C
|
||||
# define BN_MP_MOD_C
|
||||
# define BN_MP_MULMOD_C
|
||||
# define BN_MP_ADDMOD_C
|
||||
# define BN_MP_EXPTMOD_C
|
||||
# define BN_MP_SET_INT_C
|
||||
# define BN_MP_INIT_MULTI_C
|
||||
# define BN_MP_CLEAR_MULTI_C
|
||||
# define BN_MP_UNSIGNED_BIN_SIZE_C
|
||||
# define BN_MP_TO_UNSIGNED_BIN_C
|
||||
# define BN_MP_MOD_D_C
|
||||
# define BN_MP_PRIME_RABIN_MILLER_TRIALS_C
|
||||
# define BN_REVERSE_C
|
||||
# define BN_PRIME_TAB_C
|
||||
|
||||
/* other modifiers */
|
||||
#define BN_MP_DIV_SMALL /* Slower division, not critical */
|
||||
# define BN_MP_DIV_SMALL /* Slower division, not critical */
|
||||
|
||||
/* here we are on the last pass so we turn things off. The functions classes are still there
|
||||
* but we remove them specifically from the build. This also invokes tweaks in functions
|
||||
* like removing support for even moduli, etc...
|
||||
*/
|
||||
#ifdef LTM_LAST
|
||||
#undef BN_MP_TOOM_MUL_C
|
||||
#undef BN_MP_TOOM_SQR_C
|
||||
#undef BN_MP_KARATSUBA_MUL_C
|
||||
#undef BN_MP_KARATSUBA_SQR_C
|
||||
#undef BN_MP_REDUCE_C
|
||||
#undef BN_MP_REDUCE_SETUP_C
|
||||
#undef BN_MP_DR_IS_MODULUS_C
|
||||
#undef BN_MP_DR_SETUP_C
|
||||
#undef BN_MP_DR_REDUCE_C
|
||||
#undef BN_MP_REDUCE_IS_2K_C
|
||||
#undef BN_MP_REDUCE_2K_SETUP_C
|
||||
#undef BN_MP_REDUCE_2K_C
|
||||
#undef BN_S_MP_EXPTMOD_C
|
||||
#undef BN_MP_DIV_3_C
|
||||
#undef BN_S_MP_MUL_HIGH_DIGS_C
|
||||
#undef BN_FAST_S_MP_MUL_HIGH_DIGS_C
|
||||
#undef BN_FAST_MP_INVMOD_C
|
||||
# ifdef LTM_LAST
|
||||
# undef BN_MP_TOOM_MUL_C
|
||||
# undef BN_MP_TOOM_SQR_C
|
||||
# undef BN_MP_KARATSUBA_MUL_C
|
||||
# undef BN_MP_KARATSUBA_SQR_C
|
||||
# undef BN_MP_REDUCE_C
|
||||
# undef BN_MP_REDUCE_SETUP_C
|
||||
# undef BN_MP_DR_IS_MODULUS_C
|
||||
# undef BN_MP_DR_SETUP_C
|
||||
# undef BN_MP_DR_REDUCE_C
|
||||
# undef BN_MP_REDUCE_IS_2K_C
|
||||
# undef BN_MP_REDUCE_2K_SETUP_C
|
||||
# undef BN_MP_REDUCE_2K_C
|
||||
# undef BN_S_MP_EXPTMOD_C
|
||||
# undef BN_MP_DIV_3_C
|
||||
# undef BN_S_MP_MUL_HIGH_DIGS_C
|
||||
# undef BN_FAST_S_MP_MUL_HIGH_DIGS_C
|
||||
# undef BN_FAST_MP_INVMOD_C
|
||||
|
||||
/* To safely undefine these you have to make sure your RSA key won't exceed the Comba threshold
|
||||
* which is roughly 255 digits [7140 bits for 32-bit machines, 15300 bits for 64-bit machines]
|
||||
* which means roughly speaking you can handle upto 2536-bit RSA keys with these defined without
|
||||
* trouble.
|
||||
*/
|
||||
#undef BN_S_MP_MUL_DIGS_C
|
||||
#undef BN_S_MP_SQR_C
|
||||
#undef BN_MP_MONTGOMERY_REDUCE_C
|
||||
#endif
|
||||
# undef BN_S_MP_MUL_DIGS_C
|
||||
# undef BN_S_MP_SQR_C
|
||||
# undef BN_MP_MONTGOMERY_REDUCE_C
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue