comparison genrsa.c @ 219:654bc8327787

merge of 9522146cb07d4576f161fc4567c2c2fbd6f61fbb and b11630c15bc4d0649dba51c3572cac6f44e0ab0e
author Matt Johnston <matt@ucc.asn.au>
date Fri, 08 Jul 2005 13:28:03 +0000
parents c9483550701b
children 740e782679be 657c045054ab
comparison
equal deleted inserted replaced
218:3ee0c2f85e1e 219:654bc8327787
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);