I have the necessary information (type, size, n, e, d, p, q, dmp1, dmq1, iqmp) necessary for the RSA key. These were obtained from a separate source other than openssl.
I need to use this info to fill the openssl's RSA structure so that I can parse the structure to other openssl functions. Looking from the openssl source file, RSA structure consists other information such as meth, engine, ex_data,, etc.
struct rsa_st
{
/* The first parameter is used to pickup errors where
* this is passed instead of aEVP_PKEY, it is set to 0 */
int pad;
long version;
const RSA_METHOD *meth;
/* functional reference if 'meth' is ENGINE-provided */
ENGINE *engine;
BIGNUM *n;
BIGNUM *e;
BIGNUM *d;
BIGNUM *p;
BIGNUM *q;
BIGNUM *dmp1;
BIGNUM *dmq1;
BIGNUM *iqmp;
/* be careful using this if the RSA structure is shared */
CRYPTO_EX_DATA ex_data;
int references;
int flags;
/* Used to cache montgomery values */
BN_MONT_CTX *_method_mod_n;
BN_MONT_CTX *_method_mod_p;
BN_MONT_CTX *_method_mod_q;
/* all BIGNUM values are actually in the following data, if it is not
* NULL */
char *bignum_data;
BN_BLINDING *blinding;
BN_BLINDING *mt_blinding;
};
What would be the optimal way to fulfil my requirement? One method I thought of was to create the RSA struct first with
RSA_new()
and then just swap the BIGNUM values with my data. But I doubt it that's the optimal way of doing such stuff. Any help would be appreciated.
Thank you.
Aucun commentaire:
Enregistrer un commentaire