{
uint32 prime_bits = keylen / 2;
SilcMPInt p, q;
+ bool found = FALSE;
printf("Generating RSA Public and Private keys, might take a while...\n");
silc_mp_init(&q);
/* Find p and q */
- retry_primes:
- printf("Finding p: ");
- silc_math_gen_prime(&p, prime_bits, TRUE);
-
- printf("\nFinding q: ");
- silc_math_gen_prime(&q, prime_bits, TRUE);
-
- if ((silc_mp_cmp(&p, &q)) == 0) {
- printf("\nFound equal primes, not good, retrying...\n");
- goto retry_primes;
+ while (!found) {
+ printf("Finding p: ");
+ silc_math_gen_prime(&p, prime_bits, TRUE);
+
+ printf("\nFinding q: ");
+ silc_math_gen_prime(&q, prime_bits, TRUE);
+
+ if ((silc_mp_cmp(&p, &q)) == 0)
+ printf("\nFound equal primes, not good, retrying...\n");
+ else
+ found = TRUE;
}
/* If p is smaller than q, switch them */
/* Set the primes */
silc_mp_set(&key->p, p);
silc_mp_set(&key->q, q);
-
+
/* Compute modulus, n = p * q */
silc_mp_mul(&key->n, &key->p, &key->q);