summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/evp_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/evp/evp_lib.c')
-rw-r--r--src/lib/libcrypto/evp/evp_lib.c110
1 files changed, 109 insertions, 1 deletions
diff --git a/src/lib/libcrypto/evp/evp_lib.c b/src/lib/libcrypto/evp/evp_lib.c
index c96813987f..0e354d6272 100644
--- a/src/lib/libcrypto/evp/evp_lib.c
+++ b/src/lib/libcrypto/evp/evp_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_lib.c,v 1.23 2022/01/09 15:15:25 tb Exp $ */ 1/* $OpenBSD: evp_lib.c,v 1.24 2022/01/10 13:42:28 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -371,6 +371,114 @@ EVP_MD_flags(const EVP_MD *md)
371 return md->flags; 371 return md->flags;
372} 372}
373 373
374EVP_MD *
375EVP_MD_meth_new(int md_type, int pkey_type)
376{
377 EVP_MD *md;
378
379 if ((md = calloc(1, sizeof(*md))) == NULL)
380 return NULL;
381
382 md->type = md_type;
383 md->pkey_type = pkey_type;
384
385 return md;
386}
387
388EVP_MD *
389EVP_MD_meth_dup(const EVP_MD *md)
390{
391 EVP_MD *to;
392
393 if ((to = EVP_MD_meth_new(md->type, md->pkey_type)) == NULL)
394 return NULL;
395
396 memcpy(to, md, sizeof(*to));
397
398 return to;
399}
400
401void
402EVP_MD_meth_free(EVP_MD *md)
403{
404 freezero(md, sizeof(*md));
405}
406
407int
408EVP_MD_meth_set_input_blocksize(EVP_MD *md, int blocksize)
409{
410 md->block_size = blocksize;
411 return 1;
412}
413
414int
415EVP_MD_meth_set_result_size(EVP_MD *md, int result_size)
416{
417 md->md_size = result_size;
418 return 1;
419}
420
421int
422EVP_MD_meth_set_app_datasize(EVP_MD *md, int datasize)
423{
424 md->ctx_size = datasize;
425 return 1;
426}
427
428int
429EVP_MD_meth_set_flags(EVP_MD *md, unsigned long flags)
430{
431 md->flags = flags;
432 return 1;
433}
434
435int
436EVP_MD_meth_set_init(EVP_MD *md, int (*init)(EVP_MD_CTX *ctx))
437{
438 md->init = init;
439 return 1;
440}
441
442int
443EVP_MD_meth_set_update(EVP_MD *md,
444 int (*update)(EVP_MD_CTX *ctx, const void *data, size_t count))
445{
446 md->update = update;
447 return 1;
448}
449
450int
451EVP_MD_meth_set_final(EVP_MD *md,
452 int (*final)(EVP_MD_CTX *ctx, unsigned char *md))
453{
454 md->final = final;
455 return 1;
456}
457
458int
459EVP_MD_meth_set_copy(EVP_MD *md,
460 int (*copy)(EVP_MD_CTX *to, const EVP_MD_CTX *from))
461{
462 md->copy = copy;
463 return 1;
464}
465
466int
467EVP_MD_meth_set_cleanup(EVP_MD *md,
468 int (*cleanup)(EVP_MD_CTX *ctx))
469{
470 md->cleanup = cleanup;
471 return 1;
472}
473
474int
475EVP_MD_meth_set_ctrl(EVP_MD *md,
476 int (*ctrl)(EVP_MD_CTX *ctx, int cmd, int p1, void *p2))
477{
478 md->md_ctrl = ctrl;
479 return 1;
480}
481
374const EVP_MD * 482const EVP_MD *
375EVP_MD_CTX_md(const EVP_MD_CTX *ctx) 483EVP_MD_CTX_md(const EVP_MD_CTX *ctx)
376{ 484{