Codebase list libcryptx-perl / fce605c
libtommath sync Karel Miko 7 years ago
1 changed file(s) with 38 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
3737 #endif
3838
3939 /* detect 64-bit mode if possible */
40 #if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
41 #if defined(__x86_64__)
40 #if defined(__x86_64__)
41 #if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
4242 #if defined(__GNUC__)
4343 typedef unsigned long mp_uint128 __attribute__ ((mode(TI)));
4444 #define MP_64BIT
5858 * [any size beyond that is ok provided it doesn't overflow the data type]
5959 */
6060 #ifdef MP_8BIT
61 typedef mp_uint8 mp_digit;
62 typedef mp_uint16 mp_word;
63 #define DIGIT_BIT 7
61 typedef mp_uint8 mp_digit;
62 typedef mp_uint16 mp_word;
63 #define MP_SIZEOF_MP_DIGIT 1
64 #ifdef DIGIT_BIT
65 #error You must not define DIGIT_BIT when using MP_8BIT
66 #endif
6467 #elif defined(MP_16BIT)
65 typedef mp_uint16 mp_digit;
66 typedef mp_uint32 mp_word;
67 #define DIGIT_BIT 15
68 typedef mp_uint16 mp_digit;
69 typedef mp_uint32 mp_word;
70 #define MP_SIZEOF_MP_DIGIT 2
71 #ifdef DIGIT_BIT
72 #error You must not define DIGIT_BIT when using MP_16BIT
73 #endif
6874 #elif defined(MP_64BIT)
69 typedef mp_uint64 mp_digit;
70 typedef mp_uint128 mp_word;
71 #define DIGIT_BIT 60
72 #elif defined(MP_32BIT)
73 typedef mp_uint32 mp_digit;
74 typedef mp_uint64 mp_word;
75 #define DIGIT_BIT 31
75 typedef mp_uint64 mp_digit;
76 typedef mp_uint128 mp_word;
77 #define DIGIT_BIT 60
7678 #else
77 typedef mp_uint32 mp_digit;
78 typedef mp_uint64 mp_word;
79 #define DIGIT_BIT 28
79 /* this is the default case, 28-bit digits */
80
81 /* this is to make porting into LibTomCrypt easier :-) */
82 typedef mp_uint32 mp_digit;
83 typedef mp_uint64 mp_word;
84
85 #ifdef MP_31BIT
86 /* this is an extension that uses 31-bit digits */
87 #define DIGIT_BIT 31
88 #else
89 /* default case is 28-bit digits, defines MP_28BIT as a handy macro to test */
90 #define DIGIT_BIT 28
8091 #define MP_28BIT
92 #endif
93 #endif
94
95 /* otherwise the bits per digit is calculated automatically from the size of a mp_digit */
96 #ifndef DIGIT_BIT
97 #define DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */
98 typedef mp_uint32 mp_min_u32;
99 #else
100 typedef mp_digit mp_min_u32;
81101 #endif
82102
83103 /* platforms that can use a better rand function */