--- pgp/src/mpilib.h 2018/04/24 16:41:00 1.1.1.5 +++ pgp/src/mpilib.h 2018/04/24 16:45:26 1.1.1.9 @@ -117,13 +117,15 @@ typedef long signedunit; #define power_of_2(b) ((unit) 1 << (b)) /* computes power-of-2 bit masks */ #define bits2bytes(n) (((n)+7) >> 3) /* Some C compilers (like the ADSP2101) will not always collapse constant - expressions at compile time if the expressions contain shift operators. */ + expressions at compile time if the expressions contain shift + operators. */ /* #define uppermostbit power_of_2(UNITSIZE-1) */ /* #define UNITSIZE units2bits(1) */ /* number of bits in a unit */ /* #define bytes2units(n) bits2units((n)<<3) */ /* #define BYTES_PER_UNIT (UNITSIZE >> 3) */ /* LOG_UNITSIZE is the log base 2 of UNITSIZE, ie: 4 for 16-bit units */ -/* #define units2bits(n) ((n) << LOG_UNITSIZE) */ /* fast multiply by UNITSIZE */ +/* #define units2bits(n) ((n) << LOG_UNITSIZE) */ /* fast multiply by + UNITSIZE */ /* #define units2bytes(n) ((n) << (LOG_UNITSIZE-3)) */ /* #define bits2units(n) (((n)+(UNITSIZE-1)) >> LOG_UNITSIZE) */ /* #define bytes2units(n) (((n)+(BYTES_PER_UNIT-1)) >> (LOG_UNITSIZE-3)) */ @@ -196,7 +198,8 @@ typedef unit *unitptr; /* Note that the address calculations require that lsbptr, msbptr, make_lsbptr, make_msbptr, mp_tstbit, mp_setbit, mp_clrbit, - and bitptr all have unitptr arguments, not byte pointer arguments. */ + and bitptr all have unitptr arguments, not byte pointer arguments. +*/ #define bitptr(r,n) &((r)[bit_index(n)]) #define bitmsk(n) power_of_2((n) & (UNITSIZE-1)) /* bitmsk() assumes UNITSIZE is a power of 2 */ @@ -217,6 +220,12 @@ void mp_setp(short nbits); #define set_precision(prec) (global_precision = (prec)) #endif +/* We'll pull in the assembler code here if asked to. */ +#ifdef WIN32 +#ifdef USE_WIN32_ASSEMBLER +#include "mpw32asm.h" +#endif /* USE_WIN32_ASSEMBLER */ +#endif /* WIN32 */ #ifdef PEASANT @@ -259,8 +268,10 @@ void mp_setp(short nbits); #define mp_shift_left(r1) mp_rotate_left(r1,(boolean)0) /* multiprecision shift left 1 bit */ +#if !defined(mp_add) #define mp_add(r1,r2) mp_addc(r1,r2,(boolean)0) /* multiprecision add with no carry */ +#endif #define mp_sub(r1,r2) mp_subb(r1,r2,(boolean)0) /* multiprecision subtract with no borrow */ @@ -309,21 +320,25 @@ void mp_setp(short nbits); #define SMITH_SLOP_BITS 0 #endif /* mp_smul */ +#define MIN_KEY_BITS 384 +#define MAX_KEY_BITS 2048 + /* MAX_BIT_PRECISION is upper limit that assembly primitives can handle. It must be less than 32704 bits, or 4088 bytes. It should be an integer multiple of UNITSIZE*2. */ -#if (SLOP_BITS > 0) -#define MAX_BIT_PRECISION (1280+(2*UNITSIZE)) -#else -#define MAX_BIT_PRECISION 1280 -#endif +#define MAX_BIT_PRECISION (MAX_KEY_BITS+(2*UNITSIZE)) #define MAX_BYTE_PRECISION (MAX_BIT_PRECISION/8) #define MAX_UNIT_PRECISION (MAX_BIT_PRECISION/UNITSIZE) /* global_precision is the unit precision last set by set_precision */ +#if defined(WIN32) +/* For Win32 we want this to be 32-bit, for compatibility with the assembler code */ +extern unsigned int global_precision; +#else extern short global_precision; +#endif /* The "bit sniffer" macros all begin sniffing at the MSB.