| 1 |
|
| 2 |
typedef unsigned char unit; |
| 3 |
typedef unit *unitptr; |
| 4 |
extern short global_precision; |
| 5 |
typedef __SIZE_TYPE__ size_t; |
| 6 |
extern void *memcpy (void *dest, const void *src, size_t n); |
| 7 |
|
| 8 |
short mp_compare(const unit* r1, const unit* r2) |
| 9 |
{ |
| 10 |
register short precision; |
| 11 |
precision = global_precision; |
| 12 |
(r1) = ((r1)+(precision)-1); |
| 13 |
(r2) = ((r2)+(precision)-1); |
| 14 |
do |
| 15 |
{ if (*r1 < *r2) |
| 16 |
return(-1); |
| 17 |
if (*((r1)--) > *((r2)--)) |
| 18 |
return(1); |
| 19 |
} while (--precision); |
| 20 |
} |
| 21 |
|
| 22 |
static unit modulus[((1280+(2*8))/8)]; |
| 23 |
static unit d_data[((1280+(2*8))/8)*2]; |
| 24 |
|
| 25 |
int upton_modmult (unitptr prod, unitptr multiplicand, unitptr multiplier) |
| 26 |
{ |
| 27 |
unitptr d = d_data; |
| 28 |
while (mp_compare(d,modulus) > 0) |
| 29 |
memcpy((void*)(prod), (const void*)(d), (global_precision)); |
| 30 |
} |