comparison genrsa.c @ 188:c9483550701b

- refactored random mp_int generation and byte->mp_int code - added RSA blinding
author Matt Johnston <matt@ucc.asn.au>
date Thu, 05 May 2005 03:58:21 +0000
parents 29a5c7c62350
children 740e782679be 657c045054ab
comparison
equal deleted inserted replaced
187:c44df7123b0a 188:c9483550701b
106 /* generate a random odd number with MSB set, then find the 106 /* generate a random odd number with MSB set, then find the
107 the next prime above it */ 107 the next prime above it */
108 genrandom(buf, size+1); 108 genrandom(buf, size+1);
109 buf[0] |= 0x80; /* MSB set */ 109 buf[0] |= 0x80; /* MSB set */
110 110
111 if (mp_read_unsigned_bin(prime, buf, size+1) != MP_OKAY) { 111 bytes_to_mp(prime, buf, size+1);
112 fprintf(stderr, "rsa generation failed\n");
113 exit(1);
114 }
115 112
116 /* find the next integer which is prime, 8 round of miller-rabin */ 113 /* find the next integer which is prime, 8 round of miller-rabin */
117 if (mp_prime_next_prime(prime, 8, 0) != MP_OKAY) { 114 if (mp_prime_next_prime(prime, 8, 0) != MP_OKAY) {
118 fprintf(stderr, "rsa generation failed\n"); 115 fprintf(stderr, "rsa generation failed\n");
119 exit(1); 116 exit(1);