aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/rsa/rsa_gen.c
diff options
context:
space:
mode:
authorGeoff Thorpe <geoff@openssl.org>2003-01-07 05:51:39 +0000
committerGeoff Thorpe <geoff@openssl.org>2003-01-07 05:51:39 +0000
commit2814c629154a2ef9f7371808738eb70c92a1d1b1 (patch)
tree3806a3b2cd04ba5fac003b962250a31e7c194ddf /crypto/rsa/rsa_gen.c
parent876e96fdbf0030c48f9d1ceb7a0c371375dd71d6 (diff)
downloadopenssl-2814c629154a2ef9f7371808738eb70c92a1d1b1.tar.gz
This is the first step in allowing RSA_METHODs to implement their own key
generation. This prototype matches the new API function RSA_generate_key_ex(), though both may be subject to change during development before 0.9.8.
Diffstat (limited to 'crypto/rsa/rsa_gen.c')
-rw-r--r--crypto/rsa/rsa_gen.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/crypto/rsa/rsa_gen.c b/crypto/rsa/rsa_gen.c
index e3ae03e691..3714b248c4 100644
--- a/crypto/rsa/rsa_gen.c
+++ b/crypto/rsa/rsa_gen.c
@@ -68,8 +68,22 @@
#include <openssl/bn.h>
#include <openssl/rsa.h>
+static int rsa_builtin_keygen(RSA *rsa, int bits, unsigned long e_value, BN_GENCB *cb);
+
+/* NB: this wrapper would normally be placed in rsa_lib.c and the static
+ * implementation would probably be in rsa_eay.c. Nonetheless, is kept here so
+ * that we don't introduce a new linker dependency. Eg. any application that
+ * wasn't previously linking object code related to key-generation won't have to
+ * now just because key-generation is part of RSA_METHOD. */
int RSA_generate_key_ex(RSA *rsa, int bits, unsigned long e_value, BN_GENCB *cb)
{
+ if(rsa->meth->rsa_keygen)
+ return rsa->meth->rsa_keygen(rsa, bits, e_value, cb);
+ return rsa_builtin_keygen(rsa, bits, e_value, cb);
+ }
+
+static int rsa_builtin_keygen(RSA *rsa, int bits, unsigned long e_value, BN_GENCB *cb)
+ {
BIGNUM *r0=NULL,*r1=NULL,*r2=NULL,*r3=NULL,*tmp;
int bitsp,bitsq,ok= -1,n=0,i;
BN_CTX *ctx=NULL,*ctx2=NULL;