diff options
author | tb <> | 2019-01-19 01:07:00 +0000 |
---|---|---|
committer | tb <> | 2019-01-19 01:07:00 +0000 |
commit | dc38b357c3a6e0db4a7172af29148961b86b0724 (patch) | |
tree | f28042e7a3c924e4bf846d6cded984e02699177d /src/lib/libcrypto/ecdsa/ecs_sign.c | |
parent | f11f1c0f8ad579cfb88a2559e3efe0e0367cec85 (diff) | |
download | openbsd-dc38b357c3a6e0db4a7172af29148961b86b0724.tar.gz openbsd-dc38b357c3a6e0db4a7172af29148961b86b0724.tar.bz2 openbsd-dc38b357c3a6e0db4a7172af29148961b86b0724.zip |
Partial port of EC_KEY_METHOD from OpenSSL 1.1.
This commit adds init/free, support for signing, setting and
getting the method, engine support as well as extra data.
from markus
Diffstat (limited to 'src/lib/libcrypto/ecdsa/ecs_sign.c')
-rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_sign.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/src/lib/libcrypto/ecdsa/ecs_sign.c b/src/lib/libcrypto/ecdsa/ecs_sign.c index 029a0cb562..5beb853b94 100644 --- a/src/lib/libcrypto/ecdsa/ecs_sign.c +++ b/src/lib/libcrypto/ecdsa/ecs_sign.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ecs_sign.c,v 1.6 2015/02/08 13:35:07 jsing Exp $ */ | 1 | /* $OpenBSD: ecs_sign.c,v 1.7 2019/01/19 01:07:00 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -55,11 +55,13 @@ | |||
55 | 55 | ||
56 | #include <openssl/opensslconf.h> | 56 | #include <openssl/opensslconf.h> |
57 | 57 | ||
58 | #include "ecs_locl.h" | ||
59 | #ifndef OPENSSL_NO_ENGINE | 58 | #ifndef OPENSSL_NO_ENGINE |
60 | #include <openssl/engine.h> | 59 | #include <openssl/engine.h> |
61 | #endif | 60 | #endif |
62 | 61 | ||
62 | #include "ecs_locl.h" | ||
63 | #include "ec_lcl.h" | ||
64 | |||
63 | ECDSA_SIG * | 65 | ECDSA_SIG * |
64 | ECDSA_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) | 66 | ECDSA_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) |
65 | { | 67 | { |
@@ -70,11 +72,10 @@ ECDSA_SIG * | |||
70 | ECDSA_do_sign_ex(const unsigned char *dgst, int dlen, const BIGNUM *kinv, | 72 | ECDSA_do_sign_ex(const unsigned char *dgst, int dlen, const BIGNUM *kinv, |
71 | const BIGNUM *rp, EC_KEY *eckey) | 73 | const BIGNUM *rp, EC_KEY *eckey) |
72 | { | 74 | { |
73 | ECDSA_DATA *ecdsa = ecdsa_check(eckey); | 75 | if (eckey->meth->sign_sig != NULL) |
74 | 76 | return eckey->meth->sign_sig(dgst, dlen, kinv, rp, eckey); | |
75 | if (ecdsa == NULL) | 77 | ECDSAerror(EVP_R_METHOD_NOT_SUPPORTED); |
76 | return NULL; | 78 | return 0; |
77 | return ecdsa->meth->ecdsa_do_sign(dgst, dlen, kinv, rp, eckey); | ||
78 | } | 79 | } |
79 | 80 | ||
80 | int | 81 | int |
@@ -88,24 +89,17 @@ int | |||
88 | ECDSA_sign_ex(int type, const unsigned char *dgst, int dlen, unsigned char *sig, | 89 | ECDSA_sign_ex(int type, const unsigned char *dgst, int dlen, unsigned char *sig, |
89 | unsigned int *siglen, const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey) | 90 | unsigned int *siglen, const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey) |
90 | { | 91 | { |
91 | ECDSA_SIG *s; | 92 | if (eckey->meth->sign != NULL) |
92 | 93 | return eckey->meth->sign(type, dgst, dlen, sig, siglen, kinv, r, eckey); | |
93 | s = ECDSA_do_sign_ex(dgst, dlen, kinv, r, eckey); | 94 | ECDSAerror(EVP_R_METHOD_NOT_SUPPORTED); |
94 | if (s == NULL) { | 95 | return 0; |
95 | *siglen = 0; | ||
96 | return 0; | ||
97 | } | ||
98 | *siglen = i2d_ECDSA_SIG(s, &sig); | ||
99 | ECDSA_SIG_free(s); | ||
100 | return 1; | ||
101 | } | 96 | } |
102 | 97 | ||
103 | int | 98 | int |
104 | ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | 99 | ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) |
105 | { | 100 | { |
106 | ECDSA_DATA *ecdsa = ecdsa_check(eckey); | 101 | if (eckey->meth->sign_setup != NULL) |
107 | 102 | return eckey->meth->sign_setup(eckey, ctx_in, kinvp, rp); | |
108 | if (ecdsa == NULL) | 103 | ECDSAerror(EVP_R_METHOD_NOT_SUPPORTED); |
109 | return 0; | 104 | return 0; |
110 | return ecdsa->meth->ecdsa_sign_setup(eckey, ctx_in, kinvp, rp); | ||
111 | } | 105 | } |