Try to clean the maze of <openssl/bn.h> defines regarding the BN internals.
authormiod <miod@openbsd.org>
Thu, 24 Apr 2014 21:31:00 +0000 (21:31 +0000)
committermiod <miod@openbsd.org>
Thu, 24 Apr 2014 21:31:00 +0000 (21:31 +0000)
commit012ec40a9c58bfd6dfad2cea92adc7fcd311cf9f
tree47ab9114bb251fe78529df8174301698f5aecd2b
parentc3f747c90e1cc36f4214d014b3220dd1518cf609
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.
21 files changed:
lib/libcrypto/bn/asm/parisc-mont.pl
lib/libcrypto/bn/bn.h
lib/libcrypto/bn/bn_div.c
lib/libcrypto/bn/bn_gf2m.c
lib/libcrypto/bn/bn_lcl.h
lib/libcrypto/bn/bn_lib.c
lib/libcrypto/bn/bn_mod.c
lib/libcrypto/bn/bn_nist.c
lib/libcrypto/bn/bn_prime.h
lib/libcrypto/bn/bn_prime.pl
lib/libssl/src/apps/genrsa.c
lib/libssl/src/crypto/bn/asm/parisc-mont.pl
lib/libssl/src/crypto/bn/bn.h
lib/libssl/src/crypto/bn/bn_div.c
lib/libssl/src/crypto/bn/bn_gf2m.c
lib/libssl/src/crypto/bn/bn_lcl.h
lib/libssl/src/crypto/bn/bn_lib.c
lib/libssl/src/crypto/bn/bn_mod.c
lib/libssl/src/crypto/bn/bn_nist.c
lib/libssl/src/crypto/bn/bn_prime.h
lib/libssl/src/crypto/bn/bn_prime.pl