diff options
| author | miod <> | 2014-04-24 21:31:02 +0000 |
|---|---|---|
| committer | miod <> | 2014-04-24 21:31:02 +0000 |
| commit | 7e3ee009cb00e65ea487ba61ae3b5271c73c19d6 (patch) | |
| tree | e53472b5e8d9eec9f62ca322e053d1c8f66dc1cc /src/lib/libcrypto/bn/bn.h | |
| parent | 04cb67d517205b357d70ac65a314fea6e6a1a479 (diff) | |
| download | openbsd-7e3ee009cb00e65ea487ba61ae3b5271c73c19d6.tar.gz openbsd-7e3ee009cb00e65ea487ba61ae3b5271c73c19d6.tar.bz2 openbsd-7e3ee009cb00e65ea487ba61ae3b5271c73c19d6.zip | |
Try to clean the maze of <openssl/bn.h> defines regarding the BN internals.
The intent of this change is to only keep support for two kind of architectures:
- those with 32-bit int and long, and 64-bit long long, where
``long * long -> long long'' multiplication routines are available.
- those with 64-bit int and long, and no 128-bit long long type.
This gets rid of the SIXTY_FOUR_BIT_LONG, SIXTY_FOUR_BIT (not the same!),
THIRTY_TWO_BIT, SIXTEEN_BIT and EIGHT_BIT defines.
After this change, the types and defines are as follows:
arch: 64bit 32bit rationale
BN_LLONG undefined defined defined if l * l -> ll
BN_ULLONG undefined u long long result of BN_LONG * BN_LONG
BN_ULONG u long u int native register size
BN_LONG long int the same, signed
BN_BITS 128 64 size of 2*BN_ULONG in bits
BN_BYTES 8 4 size of 2*BN_ULONG in bytes
BN_BITS2 64 32 BN_BITS / 2
Tested on various 32-bit and 64-bit OpenBSD systems of various endianness.
Diffstat (limited to 'src/lib/libcrypto/bn/bn.h')
| -rw-r--r-- | src/lib/libcrypto/bn/bn.h | 53 |
1 files changed, 6 insertions, 47 deletions
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h index 4959232179..74005ed254 100644 --- a/src/lib/libcrypto/bn/bn.h +++ b/src/lib/libcrypto/bn/bn.h | |||
| @@ -167,18 +167,14 @@ extern "C" { | |||
| 167 | * using "long long's", are 32bit, and are not using my assembler code. */ | 167 | * using "long long's", are 32bit, and are not using my assembler code. */ |
| 168 | /* #define BN_DIV2W */ | 168 | /* #define BN_DIV2W */ |
| 169 | 169 | ||
| 170 | /* assuming long is 64bit - this is the DEC Alpha | 170 | #ifdef _LP64 |
| 171 | * unsigned long long is only 64 bits :-(, don't define | 171 | #undef BN_LLONG |
| 172 | * BN_LLONG for the DEC Alpha */ | ||
| 173 | #ifdef SIXTY_FOUR_BIT_LONG | ||
| 174 | #define BN_ULLONG unsigned long long | ||
| 175 | #define BN_ULONG unsigned long | 172 | #define BN_ULONG unsigned long |
| 176 | #define BN_LONG long | 173 | #define BN_LONG long |
| 177 | #define BN_BITS 128 | 174 | #define BN_BITS 128 |
| 178 | #define BN_BYTES 8 | 175 | #define BN_BYTES 8 |
| 179 | #define BN_BITS2 64 | 176 | #define BN_BITS2 64 |
| 180 | #define BN_BITS4 32 | 177 | #define BN_BITS4 32 |
| 181 | #define BN_MASK (0xffffffffffffffffffffffffffffffffLL) | ||
| 182 | #define BN_MASK2 (0xffffffffffffffffL) | 178 | #define BN_MASK2 (0xffffffffffffffffL) |
| 183 | #define BN_MASK2l (0xffffffffL) | 179 | #define BN_MASK2l (0xffffffffL) |
| 184 | #define BN_MASK2h (0xffffffff00000000L) | 180 | #define BN_MASK2h (0xffffffff00000000L) |
| @@ -190,51 +186,16 @@ extern "C" { | |||
| 190 | #define BN_DEC_NUM 19 | 186 | #define BN_DEC_NUM 19 |
| 191 | #define BN_HEX_FMT1 "%lX" | 187 | #define BN_HEX_FMT1 "%lX" |
| 192 | #define BN_HEX_FMT2 "%016lX" | 188 | #define BN_HEX_FMT2 "%016lX" |
| 193 | #endif | 189 | #else |
| 194 | 190 | #define BN_ULLONG unsigned long long | |
| 195 | /* This is where the long long data type is 64 bits, but long is 32. | 191 | #define BN_LLONG |
| 196 | * For machines where there are 64bit registers, this is the mode to use. | ||
| 197 | * IRIX, on R4000 and above should use this mode, along with the relevant | ||
| 198 | * assembler code :-). Do NOT define BN_LLONG. | ||
| 199 | */ | ||
| 200 | #ifdef SIXTY_FOUR_BIT | ||
| 201 | #undef BN_LLONG | ||
| 202 | #undef BN_ULLONG | ||
| 203 | #define BN_ULONG unsigned long long | ||
| 204 | #define BN_LONG long long | ||
| 205 | #define BN_BITS 128 | ||
| 206 | #define BN_BYTES 8 | ||
| 207 | #define BN_BITS2 64 | ||
| 208 | #define BN_BITS4 32 | ||
| 209 | #define BN_MASK2 (0xffffffffffffffffLL) | ||
| 210 | #define BN_MASK2l (0xffffffffL) | ||
| 211 | #define BN_MASK2h (0xffffffff00000000LL) | ||
| 212 | #define BN_MASK2h1 (0xffffffff80000000LL) | ||
| 213 | #define BN_TBIT (0x8000000000000000LL) | ||
| 214 | #define BN_DEC_CONV (10000000000000000000ULL) | ||
| 215 | #define BN_DEC_FMT1 "%llu" | ||
| 216 | #define BN_DEC_FMT2 "%019llu" | ||
| 217 | #define BN_DEC_NUM 19 | ||
| 218 | #define BN_HEX_FMT1 "%llX" | ||
| 219 | #define BN_HEX_FMT2 "%016llX" | ||
| 220 | #endif | ||
| 221 | |||
| 222 | #ifdef THIRTY_TWO_BIT | ||
| 223 | #ifdef BN_LLONG | ||
| 224 | # if defined(_WIN32) && !defined(__GNUC__) | ||
| 225 | # define BN_ULLONG unsigned __int64 | ||
| 226 | # define BN_MASK (0xffffffffffffffffI64) | ||
| 227 | # else | ||
| 228 | # define BN_ULLONG unsigned long long | ||
| 229 | # define BN_MASK (0xffffffffffffffffLL) | ||
| 230 | # endif | ||
| 231 | #endif | ||
| 232 | #define BN_ULONG unsigned int | 192 | #define BN_ULONG unsigned int |
| 233 | #define BN_LONG int | 193 | #define BN_LONG int |
| 234 | #define BN_BITS 64 | 194 | #define BN_BITS 64 |
| 235 | #define BN_BYTES 4 | 195 | #define BN_BYTES 4 |
| 236 | #define BN_BITS2 32 | 196 | #define BN_BITS2 32 |
| 237 | #define BN_BITS4 16 | 197 | #define BN_BITS4 16 |
| 198 | #define BN_MASK (0xffffffffffffffffLL) | ||
| 238 | #define BN_MASK2 (0xffffffffL) | 199 | #define BN_MASK2 (0xffffffffL) |
| 239 | #define BN_MASK2l (0xffff) | 200 | #define BN_MASK2l (0xffff) |
| 240 | #define BN_MASK2h1 (0xffff8000L) | 201 | #define BN_MASK2h1 (0xffff8000L) |
| @@ -248,8 +209,6 @@ extern "C" { | |||
| 248 | #define BN_HEX_FMT2 "%08X" | 209 | #define BN_HEX_FMT2 "%08X" |
| 249 | #endif | 210 | #endif |
| 250 | 211 | ||
| 251 | #define BN_DEFAULT_BITS 1280 | ||
| 252 | |||
| 253 | #define BN_FLG_MALLOCED 0x01 | 212 | #define BN_FLG_MALLOCED 0x01 |
| 254 | #define BN_FLG_STATIC_DATA 0x02 | 213 | #define BN_FLG_STATIC_DATA 0x02 |
| 255 | #define BN_FLG_CONSTTIME 0x04 /* avoid leaking exponent information through timing, | 214 | #define BN_FLG_CONSTTIME 0x04 /* avoid leaking exponent information through timing, |
