diff options
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa_meth.c')
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_meth.c | 173 |
1 files changed, 172 insertions, 1 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_meth.c b/src/lib/libcrypto/rsa/rsa_meth.c index ae613cc65c..095368b0cf 100644 --- a/src/lib/libcrypto/rsa/rsa_meth.c +++ b/src/lib/libcrypto/rsa/rsa_meth.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: rsa_meth.c,v 1.2 2018/09/12 06:35:38 djm Exp $ */ | 1 | /* $OpenBSD: rsa_meth.c,v 1.3 2019/06/05 15:41:33 gilles Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> | 3 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> |
4 | * | 4 | * |
@@ -102,3 +102,174 @@ RSA_meth_set_finish(RSA_METHOD *meth, int (*finish)(RSA *rsa)) | |||
102 | meth->finish = finish; | 102 | meth->finish = finish; |
103 | return 1; | 103 | return 1; |
104 | } | 104 | } |
105 | |||
106 | int | ||
107 | RSA_meth_set_pub_enc(RSA_METHOD *meth, int (*pub_enc)(int flen, | ||
108 | const unsigned char *from, unsigned char *to, RSA *rsa, int padding)) | ||
109 | { | ||
110 | meth->rsa_pub_enc = pub_enc; | ||
111 | return 1; | ||
112 | } | ||
113 | |||
114 | int | ||
115 | RSA_meth_set_pub_dec(RSA_METHOD *meth, int (*pub_dec)(int flen, | ||
116 | const unsigned char *from, unsigned char *to, RSA *rsa, int padding)) | ||
117 | { | ||
118 | meth->rsa_pub_dec = pub_dec; | ||
119 | return 1; | ||
120 | } | ||
121 | |||
122 | int | ||
123 | RSA_meth_set_mod_exp(RSA_METHOD *meth, int (*mod_exp)(BIGNUM *r0, | ||
124 | const BIGNUM *i, RSA *rsa, BN_CTX *ctx)) | ||
125 | { | ||
126 | meth->rsa_mod_exp = mod_exp; | ||
127 | return 1; | ||
128 | } | ||
129 | |||
130 | int | ||
131 | RSA_meth_set_bn_mod_exp(RSA_METHOD *meth, int (*bn_mod_exp)(BIGNUM *r, | ||
132 | const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, | ||
133 | BN_MONT_CTX *m_ctx)) | ||
134 | { | ||
135 | meth->bn_mod_exp = bn_mod_exp; | ||
136 | return 1; | ||
137 | } | ||
138 | |||
139 | int | ||
140 | RSA_meth_set_init(RSA_METHOD *meth, int (*init)(RSA *rsa)) | ||
141 | { | ||
142 | meth->init = init; | ||
143 | return 1; | ||
144 | } | ||
145 | |||
146 | int | ||
147 | RSA_meth_set_keygen(RSA_METHOD *meth, int (*keygen)(RSA *rsa, int bits, | ||
148 | BIGNUM *e, BN_GENCB *cb)) | ||
149 | { | ||
150 | meth->rsa_keygen = keygen; | ||
151 | return 1; | ||
152 | } | ||
153 | |||
154 | int | ||
155 | RSA_meth_set_flags(RSA_METHOD *meth, int flags) | ||
156 | { | ||
157 | meth->flags = flags; | ||
158 | return 1; | ||
159 | } | ||
160 | |||
161 | int | ||
162 | RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data) | ||
163 | { | ||
164 | meth->app_data = app_data; | ||
165 | return 1; | ||
166 | } | ||
167 | |||
168 | const char * | ||
169 | RSA_meth_get0_name(const RSA_METHOD *meth) | ||
170 | { | ||
171 | return meth->name; | ||
172 | } | ||
173 | |||
174 | int | ||
175 | (*RSA_meth_get_pub_enc(const RSA_METHOD *meth))(int flen, | ||
176 | const unsigned char *from, unsigned char *to, RSA *rsa, int padding) | ||
177 | { | ||
178 | return meth->rsa_pub_enc; | ||
179 | } | ||
180 | |||
181 | int | ||
182 | (*RSA_meth_get_pub_dec(const RSA_METHOD *meth))(int flen, | ||
183 | const unsigned char *from, unsigned char *to, RSA *rsa, int padding) | ||
184 | { | ||
185 | return meth->rsa_pub_dec; | ||
186 | } | ||
187 | |||
188 | int | ||
189 | (*RSA_meth_get_priv_enc(const RSA_METHOD *meth))(int flen, | ||
190 | const unsigned char *from, unsigned char *to, RSA *rsa, int padding) | ||
191 | { | ||
192 | return meth->rsa_priv_enc; | ||
193 | } | ||
194 | |||
195 | int | ||
196 | (*RSA_meth_get_priv_dec(const RSA_METHOD *meth))(int flen, | ||
197 | const unsigned char *from, unsigned char *to, RSA *rsa, int padding) | ||
198 | { | ||
199 | return meth->rsa_priv_dec; | ||
200 | } | ||
201 | |||
202 | int | ||
203 | (*RSA_meth_get_mod_exp(const RSA_METHOD *meth))(BIGNUM *r0, const BIGNUM *i, | ||
204 | RSA *rsa, BN_CTX *ctx) | ||
205 | { | ||
206 | return meth->rsa_mod_exp; | ||
207 | } | ||
208 | |||
209 | int | ||
210 | (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))(BIGNUM *r, | ||
211 | const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, | ||
212 | BN_MONT_CTX *m_ctx) | ||
213 | { | ||
214 | return meth->bn_mod_exp; | ||
215 | } | ||
216 | |||
217 | int | ||
218 | (*RSA_meth_get_init(const RSA_METHOD *meth))(RSA *rsa) | ||
219 | { | ||
220 | return meth->init; | ||
221 | } | ||
222 | |||
223 | int | ||
224 | (*RSA_meth_get_keygen(const RSA_METHOD *meth))(RSA *rsa, int bits, BIGNUM *e, | ||
225 | BN_GENCB *cb) | ||
226 | { | ||
227 | return meth->rsa_keygen; | ||
228 | } | ||
229 | |||
230 | int | ||
231 | RSA_meth_get_flags(const RSA_METHOD *meth) | ||
232 | { | ||
233 | return meth->flags; | ||
234 | } | ||
235 | |||
236 | void * | ||
237 | RSA_meth_get0_app_data(const RSA_METHOD *meth) | ||
238 | { | ||
239 | return meth->app_data; | ||
240 | } | ||
241 | |||
242 | int | ||
243 | (*RSA_meth_get_sign(const RSA_METHOD *meth))(int type, | ||
244 | const unsigned char *m, unsigned int m_length, | ||
245 | unsigned char *sigret, unsigned int *siglen, | ||
246 | const RSA *rsa) | ||
247 | { | ||
248 | return meth->rsa_sign; | ||
249 | } | ||
250 | |||
251 | int | ||
252 | RSA_meth_set_sign(RSA_METHOD *meth, int (*sign)(int type, | ||
253 | const unsigned char *m, unsigned int m_length, unsigned char *sigret, | ||
254 | unsigned int *siglen, const RSA *rsa)) | ||
255 | { | ||
256 | meth->rsa_sign = sign; | ||
257 | return 1; | ||
258 | } | ||
259 | |||
260 | int | ||
261 | (*RSA_meth_get_verify(const RSA_METHOD *meth))(int dtype, | ||
262 | const unsigned char *m, unsigned int m_length, const unsigned char *sigbuf, | ||
263 | unsigned int siglen, const RSA *rsa) | ||
264 | { | ||
265 | return meth->rsa_verify; | ||
266 | } | ||
267 | |||
268 | int | ||
269 | RSA_meth_set_verify(RSA_METHOD *meth, int (*verify)(int dtype, | ||
270 | const unsigned char *m, unsigned int m_length, const unsigned char *sigbuf, | ||
271 | unsigned int siglen, const RSA *rsa)) | ||
272 | { | ||
273 | meth->rsa_verify = verify; | ||
274 | return 1; | ||
275 | } | ||