From 773f26c5006f389dab09a53955be0eb5bb3cefe5 Mon Sep 17 00:00:00 2001 From: Benedict Date: Mon, 19 Dec 2016 20:07:21 +0100 Subject: lib5: added bits parameter to rsa_generate_key() --- lib/lib5.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'lib/lib5.c') diff --git a/lib/lib5.c b/lib/lib5.c index f87014c..1eb25e3 100644 --- a/lib/lib5.c +++ b/lib/lib5.c @@ -479,7 +479,14 @@ int modular_multiplicative_inverse_bignum_my(BIGNUM *res, BIGNUM *number, BIGNUM return BN_nnmod(res, tmp.s, modulo, ctx); } -int rsa_generate_key_bignum(struct rsa_key_bignum *public, struct rsa_key_bignum *private) +int rsa_generate_key_bignum(struct rsa_key_bignum *public, + struct rsa_key_bignum *private) +{ + return __rsa_generate_key_bignum(public, private ,512); +} + +int __rsa_generate_key_bignum(struct rsa_key_bignum *public, + struct rsa_key_bignum *private, int bits) { // RSA with bignum // using openssl'S BN @@ -487,9 +494,9 @@ int rsa_generate_key_bignum(struct rsa_key_bignum *public, struct rsa_key_bignum // well should check here for error but asusme infinte memory here BIGNUM *q = BN_new(); - BN_generate_prime_ex(p, 256, 1, NULL, NULL, NULL); + BN_generate_prime_ex(p, bits, 1, NULL, NULL, NULL); do { - BN_generate_prime_ex(q, 256, 1, NULL, NULL, NULL); + BN_generate_prime_ex(q, bits, 1, NULL, NULL, NULL); } while (!BN_cmp(p, q)); BIGNUM *n = BN_new(); -- cgit v1.2.3-70-g09d2