--- pgp/src/mpilib.h 2018/04/24 16:38:37 1.1.1.2 +++ pgp/src/mpilib.h 2018/04/24 16:44:37 1.1.1.8 @@ -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 */ @@ -208,14 +211,6 @@ typedef unit *unitptr; /* #define mp_tstminus(r) ((msunit(r) & uppermostbit)!=0) */ #define mp_tstminus(r) ((signedunit) msunit(r) < 0) -/* 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. -*/ -#define MAX_BIT_PRECISION 1152 -#define MAX_BYTE_PRECISION (MAX_BIT_PRECISION/8) -#define MAX_UNIT_PRECISION (MAX_BIT_PRECISION/UNITSIZE) - /* set working precision to specified number of bits. */ #ifdef mp_setp @@ -317,6 +312,18 @@ void mp_setp(short nbits); #define SMITH_SLOP_BITS 0 #endif /* mp_smul */ +/* 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 (2048+(2*UNITSIZE)) +#else +#define MAX_BIT_PRECISION 2048 +#endif +#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 */ extern short global_precision; @@ -457,8 +464,8 @@ int mp_modexp(register unitptr expout,re register unitptr exponent,register unitptr modulus); /* Combined exponentiation/modulo algorithm. */ -int rsa_decrypt(unitptr M, unitptr C, - unitptr d, unitptr p, unitptr q, unitptr u); - /* Uses Chinese Remainder Theorem shortcut for RSA decryption. */ +int mp_modexp_crt(unitptr expout, unitptr expin, + unitptr p, unitptr q, unitptr ep, unitptr eq, unitptr u); + /* exponentiation and modulo using Chinese Remainder Theorem */ /****************** end of MPI library ****************************/