2 * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
13 RSA_METHOD *RSA_meth_new(const char *name, int flags)
15 RSA_METHOD *meth = OPENSSL_zalloc(sizeof(RSA_METHOD));
18 meth->name = OPENSSL_strdup(name);
25 void RSA_meth_free(RSA_METHOD *meth)
28 if (meth->name != NULL)
29 OPENSSL_free(meth->name);
34 RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth)
38 ret = OPENSSL_malloc(sizeof(RSA_METHOD));
41 memcpy(ret, meth, sizeof(*meth));
42 ret->name = OPENSSL_strdup(meth->name);
48 const char *RSA_meth_get0_name(const RSA_METHOD *meth)
53 int RSA_meth_set1_name(RSA_METHOD *meth, const char *name)
55 OPENSSL_free(meth->name);
56 meth->name = OPENSSL_strdup(name);
58 return meth->name != NULL;
61 int RSA_meth_get_flags(RSA_METHOD *meth)
66 int RSA_meth_set_flags(RSA_METHOD *meth, int flags)
72 void *RSA_meth_get0_app_data(const RSA_METHOD *meth)
74 return meth->app_data;
77 int RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data)
79 meth->app_data = app_data;
83 int (*RSA_meth_get_pub_enc(const RSA_METHOD *meth))
84 (int flen, const unsigned char *from,
85 unsigned char *to, RSA *rsa, int padding)
87 return meth->rsa_pub_enc;
90 int RSA_meth_set_pub_enc(RSA_METHOD *meth,
91 int (*pub_enc) (int flen, const unsigned char *from,
92 unsigned char *to, RSA *rsa,
95 meth->rsa_pub_enc = pub_enc;
99 int (*RSA_meth_get_pub_dec(const RSA_METHOD *meth))
100 (int flen, const unsigned char *from,
101 unsigned char *to, RSA *rsa, int padding)
103 return meth->rsa_pub_dec;
106 int RSA_meth_set_pub_dec(RSA_METHOD *meth,
107 int (*pub_dec) (int flen, const unsigned char *from,
108 unsigned char *to, RSA *rsa,
111 meth->rsa_pub_dec = pub_dec;
115 int (*RSA_meth_get_priv_enc(const RSA_METHOD *meth))
116 (int flen, const unsigned char *from,
117 unsigned char *to, RSA *rsa, int padding)
119 return meth->rsa_priv_enc;
122 int RSA_meth_set_priv_enc(RSA_METHOD *meth,
123 int (*priv_enc) (int flen, const unsigned char *from,
124 unsigned char *to, RSA *rsa,
127 meth->rsa_priv_enc = priv_enc;
131 int (*RSA_meth_get_priv_dec(const RSA_METHOD *meth))
132 (int flen, const unsigned char *from,
133 unsigned char *to, RSA *rsa, int padding)
135 return meth->rsa_priv_dec;
138 int RSA_meth_set_priv_dec(RSA_METHOD *meth,
139 int (*priv_dec) (int flen, const unsigned char *from,
140 unsigned char *to, RSA *rsa,
143 meth->rsa_priv_dec = priv_dec;
148 int (*RSA_meth_get_mod_exp(const RSA_METHOD *meth))
149 (BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
151 return meth->rsa_mod_exp;
154 int RSA_meth_set_mod_exp(RSA_METHOD *meth,
155 int (*mod_exp) (BIGNUM *r0, const BIGNUM *I, RSA *rsa,
158 meth->rsa_mod_exp = mod_exp;
163 int (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))
164 (BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
165 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
167 return meth->bn_mod_exp;
170 int RSA_meth_set_bn_mod_exp(RSA_METHOD *meth,
171 int (*bn_mod_exp) (BIGNUM *r,
178 meth->bn_mod_exp = bn_mod_exp;
183 int (*RSA_meth_get_init(const RSA_METHOD *meth)) (RSA *rsa)
188 int RSA_meth_set_init(RSA_METHOD *meth, int (*init) (RSA *rsa))
195 int (*RSA_meth_get_finish(const RSA_METHOD *meth)) (RSA *rsa)
200 int RSA_meth_set_finish(RSA_METHOD *meth, int (*finish) (RSA *rsa))
202 meth->finish = finish;
206 int (*RSA_meth_get_sign(const RSA_METHOD *meth))
208 const unsigned char *m, unsigned int m_length,
209 unsigned char *sigret, unsigned int *siglen,
212 return meth->rsa_sign;
215 int RSA_meth_set_sign(RSA_METHOD *meth,
216 int (*sign) (int type, const unsigned char *m,
217 unsigned int m_length,
218 unsigned char *sigret, unsigned int *siglen,
221 meth->rsa_sign = sign;
225 int (*RSA_meth_get_verify(const RSA_METHOD *meth))
226 (int dtype, const unsigned char *m,
227 unsigned int m_length, const unsigned char *sigbuf,
228 unsigned int siglen, const RSA *rsa)
230 return meth->rsa_verify;
233 int RSA_meth_set_verify(RSA_METHOD *meth,
234 int (*verify) (int dtype, const unsigned char *m,
235 unsigned int m_length,
236 const unsigned char *sigbuf,
237 unsigned int siglen, const RSA *rsa))
239 meth->rsa_verify = verify;
243 int (*RSA_meth_get_keygen(const RSA_METHOD *meth))
244 (RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb)
246 return meth->rsa_keygen;
249 int RSA_meth_set_keygen(RSA_METHOD *meth,
250 int (*keygen) (RSA *rsa, int bits, BIGNUM *e,
253 meth->rsa_keygen = keygen;