mirror of
https://github.com/openssl/openssl.git
synced 2025-02-17 14:32:04 +08:00
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.
This commit is contained in:
parent
876e96fdbf
commit
2814c62915
@ -114,7 +114,11 @@ typedef struct rsa_meth_st
|
||||
int (*rsa_verify)(int dtype,
|
||||
const unsigned char *m, unsigned int m_length,
|
||||
unsigned char *sigbuf, unsigned int siglen, const RSA *rsa);
|
||||
|
||||
/* If this callback is NULL, the builtin software RSA key-gen will be used. This
|
||||
* is for behavioural compatibility whilst the code gets rewired, but one day
|
||||
* it would be nice to assume there are no such things as "builtin software"
|
||||
* implementations. */
|
||||
int (*rsa_keygen)(RSA *rsa, int bits, unsigned long e, BN_GENCB *cb);
|
||||
} RSA_METHOD;
|
||||
|
||||
struct rsa_st
|
||||
|
@ -89,7 +89,8 @@ static RSA_METHOD rsa_pkcs1_eay_meth={
|
||||
0, /* flags */
|
||||
NULL,
|
||||
0, /* rsa_sign */
|
||||
0 /* rsa_verify */
|
||||
0, /* rsa_verify */
|
||||
NULL /* rsa_keygen */
|
||||
};
|
||||
|
||||
const RSA_METHOD *RSA_PKCS1_SSLeay(void)
|
||||
|
@ -68,7 +68,21 @@
|
||||
#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;
|
||||
|
@ -94,6 +94,9 @@ static RSA_METHOD rsa_null_meth={
|
||||
RSA_null_finish,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
const RSA_METHOD *RSA_null_method(void)
|
||||
|
Loading…
Reference in New Issue
Block a user