diff options
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa_asn1.c')
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_asn1.c | 82 |
1 files changed, 81 insertions, 1 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_asn1.c b/src/lib/libcrypto/rsa/rsa_asn1.c index f931a93e85..fa340a26d2 100644 --- a/src/lib/libcrypto/rsa/rsa_asn1.c +++ b/src/lib/libcrypto/rsa/rsa_asn1.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: rsa_asn1.c,v 1.13 2016/12/30 15:47:07 jsing Exp $ */ | 1 | /* $OpenBSD: rsa_asn1.c,v 1.14 2019/10/24 16:26:13 jsing Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 2000. | 3 | * project 2000. |
4 | */ | 4 | */ |
@@ -63,6 +63,8 @@ | |||
63 | #include <openssl/rsa.h> | 63 | #include <openssl/rsa.h> |
64 | #include <openssl/x509.h> | 64 | #include <openssl/x509.h> |
65 | 65 | ||
66 | #include "rsa_locl.h" | ||
67 | |||
66 | /* Override the default free and new methods */ | 68 | /* Override the default free and new methods */ |
67 | static int | 69 | static int |
68 | rsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | 70 | rsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) |
@@ -267,6 +269,84 @@ RSA_PSS_PARAMS_free(RSA_PSS_PARAMS *a) | |||
267 | ASN1_item_free((ASN1_VALUE *)a, &RSA_PSS_PARAMS_it); | 269 | ASN1_item_free((ASN1_VALUE *)a, &RSA_PSS_PARAMS_it); |
268 | } | 270 | } |
269 | 271 | ||
272 | static int | ||
273 | rsa_oaep_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) | ||
274 | { | ||
275 | /* Free up maskHash */ | ||
276 | if (operation == ASN1_OP_FREE_PRE) { | ||
277 | RSA_OAEP_PARAMS *oaep = (RSA_OAEP_PARAMS *)*pval; | ||
278 | X509_ALGOR_free(oaep->maskHash); | ||
279 | } | ||
280 | return 1; | ||
281 | } | ||
282 | |||
283 | static const ASN1_AUX RSA_OAEP_PARAMS_aux = { | ||
284 | .app_data = NULL, | ||
285 | .flags = 0, | ||
286 | .ref_offset = 0, | ||
287 | .ref_lock = 0, | ||
288 | .asn1_cb = rsa_oaep_cb, | ||
289 | .enc_offset = 0, | ||
290 | }; | ||
291 | static const ASN1_TEMPLATE RSA_OAEP_PARAMS_seq_tt[] = { | ||
292 | { | ||
293 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL, | ||
294 | .tag = 0, | ||
295 | .offset = offsetof(RSA_OAEP_PARAMS, hashFunc), | ||
296 | .field_name = "hashFunc", | ||
297 | .item = &X509_ALGOR_it, | ||
298 | }, | ||
299 | { | ||
300 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL, | ||
301 | .tag = 1, | ||
302 | .offset = offsetof(RSA_OAEP_PARAMS, maskGenFunc), | ||
303 | .field_name = "maskGenFunc", | ||
304 | .item = &X509_ALGOR_it, | ||
305 | }, | ||
306 | { | ||
307 | .flags = ASN1_TFLG_EXPLICIT | ASN1_TFLG_OPTIONAL, | ||
308 | .tag = 2, | ||
309 | .offset = offsetof(RSA_OAEP_PARAMS, pSourceFunc), | ||
310 | .field_name = "pSourceFunc", | ||
311 | .item = &X509_ALGOR_it, | ||
312 | }, | ||
313 | }; | ||
314 | |||
315 | const ASN1_ITEM RSA_OAEP_PARAMS_it = { | ||
316 | .itype = ASN1_ITYPE_SEQUENCE, | ||
317 | .utype = V_ASN1_SEQUENCE, | ||
318 | .templates = RSA_OAEP_PARAMS_seq_tt, | ||
319 | .tcount = sizeof(RSA_OAEP_PARAMS_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
320 | .funcs = &RSA_OAEP_PARAMS_aux, | ||
321 | .size = sizeof(RSA_OAEP_PARAMS), | ||
322 | .sname = "RSA_OAEP_PARAMS", | ||
323 | }; | ||
324 | |||
325 | |||
326 | RSA_OAEP_PARAMS * | ||
327 | d2i_RSA_OAEP_PARAMS(RSA_OAEP_PARAMS **a, const unsigned char **in, long len) | ||
328 | { | ||
329 | return (RSA_OAEP_PARAMS *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, | ||
330 | &RSA_OAEP_PARAMS_it); | ||
331 | } | ||
332 | |||
333 | int | ||
334 | i2d_RSA_OAEP_PARAMS(RSA_OAEP_PARAMS *a, unsigned char **out) | ||
335 | { | ||
336 | return ASN1_item_i2d((ASN1_VALUE *)a, out, &RSA_OAEP_PARAMS_it); | ||
337 | } | ||
338 | |||
339 | RSA_OAEP_PARAMS * | ||
340 | RSA_OAEP_PARAMS_new(void) | ||
341 | { | ||
342 | return (RSA_OAEP_PARAMS *)ASN1_item_new(&RSA_OAEP_PARAMS_it); | ||
343 | } | ||
344 | |||
345 | void | ||
346 | RSA_OAEP_PARAMS_free(RSA_OAEP_PARAMS *a) | ||
347 | { | ||
348 | ASN1_item_free((ASN1_VALUE *)a, &RSA_OAEP_PARAMS_it); | ||
349 | } | ||
270 | 350 | ||
271 | RSA * | 351 | RSA * |
272 | d2i_RSAPrivateKey(RSA **a, const unsigned char **in, long len) | 352 | d2i_RSAPrivateKey(RSA **a, const unsigned char **in, long len) |