我刚刚开始编写一个 openssl 引擎。我看到所有需要的是定义各种调用的函数指针。对于 RSA 引擎,实现签名,必须使用RSA_METHOD
结构:
typedef struct rsa_meth_st
{
const char *name;
int (*rsa_pub_enc)(int flen, unsigned char *from,
unsigned char *to, RSA *rsa, int padding);
int (*rsa_pub_dec)(int flen, unsigned char *from,
unsigned char *to, RSA *rsa, int padding);
int (*rsa_priv_enc)(int flen, unsigned char *from,
unsigned char *to, RSA *rsa, int padding);
int (*rsa_priv_dec)(int flen, unsigned char *from,
unsigned char *to, RSA *rsa, int padding);
int (*rsa_mod_exp)(BIGNUM *r0, BIGNUM *I, RSA *rsa);
int (*bn_mod_exp)(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
int (*init)(RSA *rsa);
int (*finish)(RSA *rsa);
int flags;
char *app_data; /* ?? */
int (*rsa_sign)(int type, unsigned char *m, unsigned int m_len,
unsigned char *sigret, unsigned int *siglen, RSA *rsa);//here m points to digest of type 'type'
int (*rsa_verify)(int type, unsigned char *m, unsigned int m_len,
unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
} RSA_METHOD;
但是,我在or结构中看不到任何SignInit
,SignUpdate
指针。EVP_CIPHER
EVP_MD
我需要将 , 重定向SignInit
到SignUpdate
我们的库。我需要将“原始”消息而不是其摘要转发给我们的实现。我怎样才能做到这一点?