Use pseudo random generator for primality test

This commit is contained in:
NIIBE Yutaka
2013-10-01 11:53:00 +09:00
parent 4a78181c10
commit 093917927b
3 changed files with 107 additions and 9 deletions

View File

@@ -216,10 +216,16 @@ rsa_genkey (void)
uint8_t *p = p_q_modulus;
uint8_t *q = p_q_modulus + KEY_CONTENT_LEN/2;
uint8_t *modulus = p_q_modulus + KEY_CONTENT_LEN;
extern int prng_seed (int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng);
extern void neug_flush (void);
if (p_q_modulus == NULL)
return NULL;
neug_flush ();
prng_seed (random_gen, &index);
rsa_init (&rsa_ctx, RSA_PKCS_V15, 0);
r = rsa_gen_key (&rsa_ctx, random_gen, &index,
KEY_CONTENT_LEN * 8, RSA_EXPONENT);