@@ -33,30 +33,83 @@ version (OPENSSL_NO_RSA) {
33
33
extern (C ):
34
34
nothrow :
35
35
36
- /* Declared already in types.h */
37
- /* typedef rsa_meth_st RSA_METHOD; */
36
+ // The following aliases are derived from the `RSA_meth_*` functions' signatures
37
+ // They are not present in the code, hence are `private`.
38
+ private alias RSA_enc_dec_fn = extern (C ) int function (int flen,
39
+ const (ubyte )* from, ubyte * to, RSA * rsa, int padding);
40
+ private alias RSA_modexp_fn = extern (C ) int function (BIGNUM * r0,
41
+ const (BIGNUM )* I, RSA * rsa, BN_CTX * ctx);
42
+ private alias RSA_bn_modexp_fn = extern (C ) int function (BIGNUM * r,
43
+ const (BIGNUM )* a, const (BIGNUM )* p, const (BIGNUM )* m, BN_CTX * ctx,
44
+ BN_MONT_CTX * m_ctx);
45
+ private alias RSA_lifetime_fn = extern (C ) int function (RSA * rsa);
46
+ private alias RSA_sign_fn = extern (C ) int function (int type,
47
+ const (ubyte )* m, uint m_length, ubyte * sigret, uint * siglen, const (RSA )* rsa);
48
+ private alias RSA_verify_fn = extern (C ) int function (int dtype,
49
+ const (ubyte )* m, uint m_length, const (ubyte )* sigret, uint * siglen,
50
+ const (RSA )* rsa);
51
+ private alias RSA_keygen_fn = extern (C ) int function (RSA * rsa,
52
+ int bits, BIGNUM * e, BN_GENCB * cb);
38
53
54
+ static if (OPENSSL_VERSION_AT_LEAST (1 , 1 , 0 ))
55
+ {
56
+ // https://github.com/openssl/openssl/commit/b72c9121379a5de0c8be0d4e1a4a6b9495042621
57
+
58
+ RSA_METHOD * RSA_meth_new (const (char )* name, int flags);
59
+ void RSA_meth_free (RSA_METHOD * meth);
60
+ RSA_METHOD * RSA_meth_dup (const (RSA_METHOD )* meth);
61
+
62
+ const (char )* RSA_meth_get0_name (const (RSA_METHOD )* meth);
63
+ int RSA_meth_set1_name (RSA_METHOD * meth, const (char )* name);
64
+
65
+ int RSA_meth_get_flags (RSA_METHOD * meth);
66
+ int RSA_meth_set_flags (RSA_METHOD * meth, int flags);
67
+ void * RSA_meth_get0_app_data (const (RSA_METHOD )* meth);
68
+ int RSA_meth_set0_app_data (RSA_METHOD * meth, void * app_data);
69
+
70
+ RSA_enc_dec_fn RSA_meth_get_pub_enc (const (RSA_METHOD )* meth);
71
+ int RSA_meth_set_pub_enc (RSA_METHOD * rsa, RSA_enc_dec_fn pub_enc);
72
+ RSA_enc_dec_fn RSA_meth_get_pub_dec (const (RSA_METHOD )* meth);
73
+ int RSA_meth_set_pub_dec (RSA_METHOD * rsa, RSA_enc_dec_fn pub_dec);
74
+
75
+ RSA_enc_dec_fn RSA_meth_get_priv_enc (const (RSA_METHOD )* meth);
76
+ int RSA_meth_set_priv_enc (RSA_METHOD * rsa, RSA_enc_dec_fn priv_enc);
77
+ RSA_enc_dec_fn RSA_meth_get_priv_dec (const (RSA_METHOD )* meth);
78
+ int RSA_meth_set_priv_dec (RSA_METHOD * rsa, RSA_enc_dec_fn priv_dec);
79
+
80
+ RSA_modexp_fn RSA_meth_get_mod_exp (const (RSA_METHOD )* meth);
81
+ int RSA_meth_set_mod_exp (RSA_METHOD * rsa, RSA_modexp_fn mod_exp);
82
+
83
+ RSA_bn_modexp_fn RSA_meth_get_bn_mod_exp (const (RSA_METHOD )* meth);
84
+ int RSA_meth_set_bn_mod_exp (RSA_METHOD * rsa, RSA_bn_modexp_fn bn_mod_exp);
85
+
86
+ RSA_lifetime_fn RSA_meth_get_init (const (RSA_METHOD )* meth);
87
+ int RSA_meth_set_init (RSA_METHOD * rsa, RSA_lifetime_fn init);
88
+ RSA_lifetime_fn RSA_meth_get_finish (const (RSA_METHOD )* meth);
89
+ int RSA_meth_set_finish (RSA_METHOD * rsa, RSA_lifetime_fn finish);
90
+
91
+ RSA_sign_fn RSA_meth_get_sign (const (RSA_METHOD )* meth);
92
+ int RSA_meth_set_sign (RSA_METHOD * rsa, RSA_sign_fn sign);
93
+
94
+ RSA_verify_fn RSA_meth_get_verify (const (RSA_METHOD )* meth);
95
+ int RSA_meth_set_verify (RSA_METHOD * rsa, RSA_verify_fn verify);
96
+
97
+ RSA_keygen_fn RSA_meth_get_keygen (const (RSA_METHOD )* meth);
98
+ int RSA_meth_set_keygen (RSA_METHOD * rsa, RSA_keygen_fn keygen);
99
+ }
100
+ else
101
+ {
39
102
struct rsa_meth_st
40
- {
103
+ {
41
104
const (char )* name;
42
- ExternC! (int function (int flen,const (ubyte )* from,
43
- ubyte * to,
44
- RSA * rsa,int padding)) rsa_pub_enc;
45
- ExternC! (int function (int flen,const (ubyte )* from,
46
- ubyte * to,
47
- RSA * rsa,int padding)) rsa_pub_dec;
48
- ExternC! (int function (int flen,const (ubyte )* from,
49
- ubyte * to,
50
- RSA * rsa,int padding)) rsa_priv_enc;
51
- ExternC! (int function (int flen,const (ubyte )* from,
52
- ubyte * to,
53
- RSA * rsa,int padding)) rsa_priv_dec;
54
- ExternC! (int function (BIGNUM * r0,const (BIGNUM )* I,RSA * rsa,BN_CTX * ctx)) rsa_mod_exp; /* Can be null */
55
- ExternC! (int function (BIGNUM * r, const (BIGNUM )* a, const (BIGNUM )* p,
56
- const (BIGNUM )* m, BN_CTX * ctx,
57
- BN_MONT_CTX * m_ctx)) bn_mod_exp; /* Can be null */
58
- ExternC! (int function (RSA * rsa)) init_; /* called at new */
59
- ExternC! (int function (RSA * rsa)) finish; /* called at free */
105
+ RSA_enc_dec_fn rsa_pub_enc;
106
+ RSA_enc_dec_fn rsa_pub_dec;
107
+ RSA_enc_dec_fn rsa_priv_enc;
108
+ RSA_enc_dec_fn rsa_priv_dec;
109
+ RSA_modexp_fn rsa_mod_exp; /* Can be null */
110
+ RSA_bn_modexp_fn bn_mod_exp; /* Can be null */
111
+ RSA_lifetime_fn init_; /* called at new */
112
+ RSA_lifetime_fn finish; /* called at free */
60
113
int flags; /* RSA_METHOD_FLAG_* things */
61
114
char * app_data; /* may be needed! */
62
115
/* New sign and verify functions: some libraries don't allow arbitrary data
@@ -66,19 +119,15 @@ struct rsa_meth_st
66
119
* compatibility this functionality is only enabled if the RSA_FLAG_SIGN_VER
67
120
* option is set in 'flags'.
68
121
*/
69
- ExternC! (int function (int type,
70
- const (ubyte )* m, uint m_length,
71
- ubyte * sigret, uint * siglen, const (RSA )* rsa)) rsa_sign;
72
- ExternC! (int function (int dtype,
73
- const (ubyte )* m, uint m_length,
74
- const (ubyte )* sigbuf, uint siglen,
75
- const (RSA )* rsa)) rsa_verify;
122
+ RSA_sign_fn rsa_sign;
123
+ RSA_verify_fn rsa_verify;
76
124
/* If this callback is NULL, the builtin software RSA key-gen will be used. This
77
125
* is for behavioural compatibility whilst the code gets rewired, but one day
78
126
* it would be nice to assume there are no such things as "builtin software"
79
127
* implementations. */
80
- ExternC! (int function (RSA * rsa, int bits, BIGNUM * e, BN_GENCB * cb)) rsa_keygen;
81
- };
128
+ RSA_keygen_fn rsa_keygen;
129
+ }
130
+ }
82
131
83
132
static if (OPENSSL_VERSION_AT_LEAST (1 , 1 , 0 ))
84
133
{
0 commit comments