This is the first step in allowing RSA_METHODs to implement their own key
[openssl.git] / crypto / rsa / rsa_gen.c
index e3ae03e6914c8b7b614aaa0b7936ef4fc30e4551..3714b248c456a542fbcde49a68fabf4dd4e1b2b3 100644 (file)
 #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;