comparison bn_mp_rand.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
27 return MP_OKAY; 27 return MP_OKAY;
28 } 28 }
29 29
30 /* first place a random non-zero digit */ 30 /* first place a random non-zero digit */
31 do { 31 do {
32 d = ((mp_digit) abs (rand ())); 32 d = ((mp_digit) abs (rand ())) & MP_MASK;
33 } while (d == 0); 33 } while (d == 0);
34 34
35 if ((res = mp_add_d (a, d, a)) != MP_OKAY) { 35 if ((res = mp_add_d (a, d, a)) != MP_OKAY) {
36 return res; 36 return res;
37 } 37 }
38 38
39 while (digits-- > 0) { 39 while (--digits > 0) {
40 if ((res = mp_lshd (a, 1)) != MP_OKAY) { 40 if ((res = mp_lshd (a, 1)) != MP_OKAY) {
41 return res; 41 return res;
42 } 42 }
43 43
44 if ((res = mp_add_d (a, ((mp_digit) abs (rand ())), a)) != MP_OKAY) { 44 if ((res = mp_add_d (a, ((mp_digit) abs (rand ())), a)) != MP_OKAY) {