diff options
author | miod <> | 2014-04-24 21:31:02 +0000 |
---|---|---|
committer | miod <> | 2014-04-24 21:31:02 +0000 |
commit | b2e9d1eed3ec4424b18ce3ee98e78f0030ca2cf3 (patch) | |
tree | e53472b5e8d9eec9f62ca322e053d1c8f66dc1cc /src/lib/libcrypto/bn/bn_lib.c | |
parent | d436f60f68787eee6620cab3a227f119e7813894 (diff) | |
download | openbsd-b2e9d1eed3ec4424b18ce3ee98e78f0030ca2cf3.tar.gz openbsd-b2e9d1eed3ec4424b18ce3ee98e78f0030ca2cf3.tar.bz2 openbsd-b2e9d1eed3ec4424b18ce3ee98e78f0030ca2cf3.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_lib.c')
-rw-r--r-- | src/lib/libcrypto/bn/bn_lib.c | 29 |
1 files changed, 1 insertions, 28 deletions
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c index c8de547ba5..9787a31dbb 100644 --- a/src/lib/libcrypto/bn/bn_lib.c +++ b/src/lib/libcrypto/bn/bn_lib.c | |||
@@ -160,7 +160,7 @@ int BN_num_bits_word(BN_ULONG l) | |||
160 | 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, | 160 | 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, |
161 | }; | 161 | }; |
162 | 162 | ||
163 | #if defined(SIXTY_FOUR_BIT_LONG) | 163 | #ifdef _LP64 |
164 | if (l & 0xffffffff00000000L) | 164 | if (l & 0xffffffff00000000L) |
165 | { | 165 | { |
166 | if (l & 0xffff000000000000L) | 166 | if (l & 0xffff000000000000L) |
@@ -181,32 +181,8 @@ int BN_num_bits_word(BN_ULONG l) | |||
181 | } | 181 | } |
182 | } | 182 | } |
183 | else | 183 | else |
184 | #else | ||
185 | #ifdef SIXTY_FOUR_BIT | ||
186 | if (l & 0xffffffff00000000LL) | ||
187 | { | ||
188 | if (l & 0xffff000000000000LL) | ||
189 | { | ||
190 | if (l & 0xff00000000000000LL) | ||
191 | { | ||
192 | return(bits[(int)(l>>56)]+56); | ||
193 | } | ||
194 | else return(bits[(int)(l>>48)]+48); | ||
195 | } | ||
196 | else | ||
197 | { | ||
198 | if (l & 0x0000ff0000000000LL) | ||
199 | { | ||
200 | return(bits[(int)(l>>40)]+40); | ||
201 | } | ||
202 | else return(bits[(int)(l>>32)]+32); | ||
203 | } | ||
204 | } | ||
205 | else | ||
206 | #endif | ||
207 | #endif | 184 | #endif |
208 | { | 185 | { |
209 | #if defined(THIRTY_TWO_BIT) || defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG) | ||
210 | if (l & 0xffff0000L) | 186 | if (l & 0xffff0000L) |
211 | { | 187 | { |
212 | if (l & 0xff000000L) | 188 | if (l & 0xff000000L) |
@@ -214,13 +190,10 @@ int BN_num_bits_word(BN_ULONG l) | |||
214 | else return(bits[(int)(l>>16L)]+16); | 190 | else return(bits[(int)(l>>16L)]+16); |
215 | } | 191 | } |
216 | else | 192 | else |
217 | #endif | ||
218 | { | 193 | { |
219 | #if defined(THIRTY_TWO_BIT) || defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG) | ||
220 | if (l & 0xff00L) | 194 | if (l & 0xff00L) |
221 | return(bits[(int)(l>>8)]+8); | 195 | return(bits[(int)(l>>8)]+8); |
222 | else | 196 | else |
223 | #endif | ||
224 | return(bits[(int)(l )] ); | 197 | return(bits[(int)(l )] ); |
225 | } | 198 | } |
226 | } | 199 | } |