Mercurial > dropbear
comparison bn_mp_reduce_is_2k.c @ 190:d8254fc979e9 libtommath-orig LTM_0.35
Initial import of libtommath 0.35
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 06 May 2005 08:59:30 +0000 |
parents | d29b64170cf0 |
children |
comparison
equal
deleted
inserted
replaced
142:d29b64170cf0 | 190:d8254fc979e9 |
---|---|
20 { | 20 { |
21 int ix, iy, iw; | 21 int ix, iy, iw; |
22 mp_digit iz; | 22 mp_digit iz; |
23 | 23 |
24 if (a->used == 0) { | 24 if (a->used == 0) { |
25 return 0; | 25 return MP_NO; |
26 } else if (a->used == 1) { | 26 } else if (a->used == 1) { |
27 return 1; | 27 return MP_YES; |
28 } else if (a->used > 1) { | 28 } else if (a->used > 1) { |
29 iy = mp_count_bits(a); | 29 iy = mp_count_bits(a); |
30 iz = 1; | 30 iz = 1; |
31 iw = 1; | 31 iw = 1; |
32 | 32 |
33 /* Test every bit from the second digit up, must be 1 */ | 33 /* Test every bit from the second digit up, must be 1 */ |
34 for (ix = DIGIT_BIT; ix < iy; ix++) { | 34 for (ix = DIGIT_BIT; ix < iy; ix++) { |
35 if ((a->dp[iw] & iz) == 0) { | 35 if ((a->dp[iw] & iz) == 0) { |
36 return 0; | 36 return MP_NO; |
37 } | 37 } |
38 iz <<= 1; | 38 iz <<= 1; |
39 if (iz > (mp_digit)MP_MASK) { | 39 if (iz > (mp_digit)MP_MASK) { |
40 ++iw; | 40 ++iw; |
41 iz = 1; | 41 iz = 1; |
42 } | 42 } |
43 } | 43 } |
44 } | 44 } |
45 return 1; | 45 return MP_YES; |
46 } | 46 } |
47 | 47 |
48 #endif | 48 #endif |