diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/evp/evp.h | 22 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/evp_lib.c | 110 |
2 files changed, 130 insertions, 2 deletions
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h index a3a55caf88..7fae46f610 100644 --- a/src/lib/libcrypto/evp/evp.h +++ b/src/lib/libcrypto/evp/evp.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: evp.h,v 1.94 2022/01/10 12:10:26 tb Exp $ */ | 1 | /* $OpenBSD: evp.h,v 1.95 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 | * |
| @@ -495,6 +495,26 @@ int EVP_MD_size(const EVP_MD *md); | |||
| 495 | int EVP_MD_block_size(const EVP_MD *md); | 495 | int EVP_MD_block_size(const EVP_MD *md); |
| 496 | unsigned long EVP_MD_flags(const EVP_MD *md); | 496 | unsigned long EVP_MD_flags(const EVP_MD *md); |
| 497 | 497 | ||
| 498 | #if defined(LIBRESSL_NEXT_API) || defined(LIBRESSL_CRYPTO_INTERNAL) | ||
| 499 | EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type); | ||
| 500 | void EVP_MD_meth_free(EVP_MD *md); | ||
| 501 | EVP_MD *EVP_MD_meth_dup(const EVP_MD *md); | ||
| 502 | int EVP_MD_meth_set_input_blocksize(EVP_MD *md, int blocksize); | ||
| 503 | int EVP_MD_meth_set_result_size(EVP_MD *md, int resultsize); | ||
| 504 | int EVP_MD_meth_set_app_datasize(EVP_MD *md, int datasize); | ||
| 505 | int EVP_MD_meth_set_flags(EVP_MD *md, unsigned long flags); | ||
| 506 | int EVP_MD_meth_set_init(EVP_MD *md, int (*init)(EVP_MD_CTX *ctx)); | ||
| 507 | int EVP_MD_meth_set_update(EVP_MD *md, | ||
| 508 | int (*update)(EVP_MD_CTX *ctx, const void *data, size_t count)); | ||
| 509 | int EVP_MD_meth_set_final(EVP_MD *md, | ||
| 510 | int (*final)(EVP_MD_CTX *ctx, unsigned char *md)); | ||
| 511 | int EVP_MD_meth_set_copy(EVP_MD *md, | ||
| 512 | int (*copy)(EVP_MD_CTX *to, const EVP_MD_CTX *from)); | ||
| 513 | int EVP_MD_meth_set_cleanup(EVP_MD *md, int (*cleanup)(EVP_MD_CTX *ctx)); | ||
| 514 | int EVP_MD_meth_set_ctrl(EVP_MD *md, | ||
| 515 | int (*ctrl)(EVP_MD_CTX *ctx, int cmd, int p1, void *p2)); | ||
| 516 | #endif | ||
| 517 | |||
| 498 | const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx); | 518 | const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx); |
| 499 | void *EVP_MD_CTX_md_data(const EVP_MD_CTX *ctx); | 519 | void *EVP_MD_CTX_md_data(const EVP_MD_CTX *ctx); |
| 500 | #if defined(LIBRESSL_CRYPTO_INTERANL) || defined(LIBRESSL_NEXT_API) | 520 | #if defined(LIBRESSL_CRYPTO_INTERANL) || defined(LIBRESSL_NEXT_API) |
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 | ||
| 374 | EVP_MD * | ||
| 375 | EVP_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 | |||
| 388 | EVP_MD * | ||
| 389 | EVP_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 | |||
| 401 | void | ||
| 402 | EVP_MD_meth_free(EVP_MD *md) | ||
| 403 | { | ||
| 404 | freezero(md, sizeof(*md)); | ||
| 405 | } | ||
| 406 | |||
| 407 | int | ||
| 408 | EVP_MD_meth_set_input_blocksize(EVP_MD *md, int blocksize) | ||
| 409 | { | ||
| 410 | md->block_size = blocksize; | ||
| 411 | return 1; | ||
| 412 | } | ||
| 413 | |||
| 414 | int | ||
| 415 | EVP_MD_meth_set_result_size(EVP_MD *md, int result_size) | ||
| 416 | { | ||
| 417 | md->md_size = result_size; | ||
| 418 | return 1; | ||
| 419 | } | ||
| 420 | |||
| 421 | int | ||
| 422 | EVP_MD_meth_set_app_datasize(EVP_MD *md, int datasize) | ||
| 423 | { | ||
| 424 | md->ctx_size = datasize; | ||
| 425 | return 1; | ||
| 426 | } | ||
| 427 | |||
| 428 | int | ||
| 429 | EVP_MD_meth_set_flags(EVP_MD *md, unsigned long flags) | ||
| 430 | { | ||
| 431 | md->flags = flags; | ||
| 432 | return 1; | ||
| 433 | } | ||
| 434 | |||
| 435 | int | ||
| 436 | EVP_MD_meth_set_init(EVP_MD *md, int (*init)(EVP_MD_CTX *ctx)) | ||
| 437 | { | ||
| 438 | md->init = init; | ||
| 439 | return 1; | ||
| 440 | } | ||
| 441 | |||
| 442 | int | ||
| 443 | EVP_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 | |||
| 450 | int | ||
| 451 | EVP_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 | |||
| 458 | int | ||
| 459 | EVP_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 | |||
| 466 | int | ||
| 467 | EVP_MD_meth_set_cleanup(EVP_MD *md, | ||
| 468 | int (*cleanup)(EVP_MD_CTX *ctx)) | ||
| 469 | { | ||
| 470 | md->cleanup = cleanup; | ||
| 471 | return 1; | ||
| 472 | } | ||
| 473 | |||
| 474 | int | ||
| 475 | EVP_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 | |||
| 374 | const EVP_MD * | 482 | const EVP_MD * |
| 375 | EVP_MD_CTX_md(const EVP_MD_CTX *ctx) | 483 | EVP_MD_CTX_md(const EVP_MD_CTX *ctx) |
| 376 | { | 484 | { |
