第十七章 RSA / 17.4.1 RSA_METHOD

struct rsa_meth_st

       {

       const char      *name;

       int (*rsa_pub_enc)(int flen,const unsigned char *from,unsigned char *to,RSA *rsa,int padding);

       int (*rsa_pub_dec)(int flen,const unsigned char *from,unsigned char *to,RSA *rsa,int padding);

       int (*rsa_priv_enc)(int flen,const unsigned char *from,unsigned char *to,RSA *rsa,int padding);

       int (*rsa_priv_dec)(int flen,const unsigned char *from,unsigned char *to,RSA *rsa,int padding);

       /* 其他函数 */

       int (*rsa_sign)(int type,const unsigned char *m, unsigned int m_length,unsigned char *sigret, unsigned int *siglen, const RSA *rsa);

       int (*rsa_verify)(int dtype,const unsigned char *m, unsigned int m_length,unsigned char *sigbuf, unsigned int siglen, const RSA *rsa);

int (*rsa_keygen)(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);

       };

       主要项说明:

nameRSA_METHOD名称;

rsa_pub_enc:公钥加密函数,padding为其填充方式,输入数据不能太长,否则无法填充;

rsa_pub_dec:公钥解密函数,padding为其去除填充的方式,输入数据长度为RSA密钥长度的字节数;

rsa_priv_enc:私钥加密函数,padding为其填充方式,输入数据长度不能太长,否则无法填充;

rsa_priv_dec:私钥解密函数,padding为其去除填充的方式,输入数据长度为RSA密钥长度的字节数;

rsa_sign:签名函数;

rsa_verify:验签函数;

rsa_keygenRSA密钥对生成函数。

用户可实现自己的RSA_METHOD来替换openssl提供的默认方法。