From 5364e1f7a35295c8970de0ee8e4ae8196a889ef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Fri, 20 Apr 2007 07:30:22 +0000 Subject: [PATCH] try generate a couple of rsa keys of diffrent (random) sizes. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20461 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/des/test_rsa.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/des/test_rsa.c b/lib/des/test_rsa.c index cbce7321e..49a78ccf3 100644 --- a/lib/des/test_rsa.c +++ b/lib/des/test_rsa.c @@ -58,8 +58,11 @@ static char *time_key; static int key_blinding = 1; static char *rsa_key; static char *id_flag; +static int loops = 1; static struct getargs args[] = { + { "loops", 0, arg_integer, &loops, + "number of loops", "loops" }, { "id", 0, arg_string, &id_flag, "selects the engine id", "engine-id" }, { "time-keygen", 0, arg_flag, &time_keygen, @@ -193,7 +196,7 @@ int main(int argc, char **argv) { ENGINE *engine = NULL; - int i, idx = 0; + int i, j, idx = 0; RSA *rsa; setprogname(argv[0]); @@ -335,9 +338,10 @@ main(int argc, char **argv) RSA_free(rsa); } - { + for (i = 0; i < loops; i++) { BN_GENCB cb; BIGNUM *e; + unsigned int n; rsa = RSA_new_method(engine); if (!key_blinding) @@ -347,13 +351,17 @@ main(int argc, char **argv) BN_set_word(e, 0x10001); BN_GENCB_set(&cb, cb_func, NULL); + + RAND_bytes(&n, sizeof(n)); + n &= 0x1ff; + n += 1024; - if (RSA_generate_key_ex(rsa, 1024, e, &cb) != 1) + if (RSA_generate_key_ex(rsa, n, e, &cb) != 1) errx(1, "RSA_generate_key_ex"); BN_free(e); - for (i = 0; i < 8; i++) { + for (j = 0; j < 8; j++) { unsigned char sha1[20]; RAND_bytes(sha1, sizeof(sha1)); check_rsa(sha1, sizeof(sha1), rsa, RSA_PKCS1_PADDING);