diff options
Diffstat (limited to 'src/lib/libcrypto/ecdsa/ecs_ossl.c')
| -rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_ossl.c | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/src/lib/libcrypto/ecdsa/ecs_ossl.c b/src/lib/libcrypto/ecdsa/ecs_ossl.c index 78e2b4a997..9702cd6dab 100644 --- a/src/lib/libcrypto/ecdsa/ecs_ossl.c +++ b/src/lib/libcrypto/ecdsa/ecs_ossl.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ecs_ossl.c,v 1.32 2023/03/30 15:51:09 bluhm Exp $ */ | 1 | /* $OpenBSD: ecs_ossl.c,v 1.33 2023/04/13 15:00:24 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Nils Larsch for the OpenSSL project | 3 | * Written by Nils Larsch for the OpenSSL project |
| 4 | */ | 4 | */ |
| @@ -62,9 +62,11 @@ | |||
| 62 | 62 | ||
| 63 | #include <openssl/bn.h> | 63 | #include <openssl/bn.h> |
| 64 | #include <openssl/err.h> | 64 | #include <openssl/err.h> |
| 65 | #include <openssl/evp.h> | ||
| 65 | #include <openssl/objects.h> | 66 | #include <openssl/objects.h> |
| 66 | 67 | ||
| 67 | #include "bn_local.h" | 68 | #include "bn_local.h" |
| 69 | #include "ec_local.h" | ||
| 68 | #include "ecs_local.h" | 70 | #include "ecs_local.h" |
| 69 | 71 | ||
| 70 | static int ecdsa_prepare_digest(const unsigned char *dgst, int dgst_len, | 72 | static int ecdsa_prepare_digest(const unsigned char *dgst, int dgst_len, |
| @@ -572,3 +574,66 @@ ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len, | |||
| 572 | return 0; | 574 | return 0; |
| 573 | return ecdsa->meth->ecdsa_do_verify(dgst, dgst_len, sig, eckey); | 575 | return ecdsa->meth->ecdsa_do_verify(dgst, dgst_len, sig, eckey); |
| 574 | } | 576 | } |
| 577 | |||
| 578 | ECDSA_SIG * | ||
| 579 | ECDSA_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) | ||
| 580 | { | ||
| 581 | return ECDSA_do_sign_ex(dgst, dlen, NULL, NULL, eckey); | ||
| 582 | } | ||
| 583 | |||
| 584 | ECDSA_SIG * | ||
| 585 | ECDSA_do_sign_ex(const unsigned char *dgst, int dlen, const BIGNUM *kinv, | ||
| 586 | const BIGNUM *rp, EC_KEY *eckey) | ||
| 587 | { | ||
| 588 | if (eckey->meth->sign_sig != NULL) | ||
| 589 | return eckey->meth->sign_sig(dgst, dlen, kinv, rp, eckey); | ||
| 590 | ECDSAerror(EVP_R_METHOD_NOT_SUPPORTED); | ||
| 591 | return 0; | ||
| 592 | } | ||
| 593 | |||
| 594 | int | ||
| 595 | ECDSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, | ||
| 596 | unsigned int *siglen, EC_KEY *eckey) | ||
| 597 | { | ||
| 598 | return ECDSA_sign_ex(type, dgst, dlen, sig, siglen, NULL, NULL, eckey); | ||
| 599 | } | ||
| 600 | |||
| 601 | int | ||
| 602 | ECDSA_sign_ex(int type, const unsigned char *dgst, int dlen, unsigned char *sig, | ||
| 603 | unsigned int *siglen, const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey) | ||
| 604 | { | ||
| 605 | if (eckey->meth->sign != NULL) | ||
| 606 | return eckey->meth->sign(type, dgst, dlen, sig, siglen, kinv, r, eckey); | ||
| 607 | ECDSAerror(EVP_R_METHOD_NOT_SUPPORTED); | ||
| 608 | return 0; | ||
| 609 | } | ||
| 610 | |||
| 611 | int | ||
| 612 | ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | ||
| 613 | { | ||
| 614 | if (eckey->meth->sign_setup != NULL) | ||
| 615 | return eckey->meth->sign_setup(eckey, ctx_in, kinvp, rp); | ||
| 616 | ECDSAerror(EVP_R_METHOD_NOT_SUPPORTED); | ||
| 617 | return 0; | ||
| 618 | } | ||
| 619 | |||
| 620 | int | ||
| 621 | ECDSA_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, | ||
| 622 | EC_KEY *eckey) | ||
| 623 | { | ||
| 624 | if (eckey->meth->verify_sig != NULL) | ||
| 625 | return eckey->meth->verify_sig(dgst, dgst_len, sig, eckey); | ||
| 626 | ECDSAerror(EVP_R_METHOD_NOT_SUPPORTED); | ||
| 627 | return 0; | ||
| 628 | } | ||
| 629 | |||
| 630 | int | ||
| 631 | ECDSA_verify(int type, const unsigned char *dgst, int dgst_len, | ||
| 632 | const unsigned char *sigbuf, int sig_len, EC_KEY *eckey) | ||
| 633 | { | ||
| 634 | if (eckey->meth->verify != NULL) | ||
| 635 | return eckey->meth->verify(type, dgst, dgst_len, | ||
| 636 | sigbuf, sig_len, eckey); | ||
| 637 | ECDSAerror(EVP_R_METHOD_NOT_SUPPORTED); | ||
| 638 | return 0; | ||
| 639 | } | ||
