summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ecdsa/ecs_ossl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/ecdsa/ecs_ossl.c')
-rw-r--r--src/lib/libcrypto/ecdsa/ecs_ossl.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/lib/libcrypto/ecdsa/ecs_ossl.c b/src/lib/libcrypto/ecdsa/ecs_ossl.c
index 87d80642df..4e05cb9aac 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.16 2018/07/10 21:36:02 tb Exp $ */ 1/* $OpenBSD: ecs_ossl.c,v 1.17 2019/01/19 01:07:00 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project 3 * Written by Nils Larsch for the OpenSSL project
4 */ 4 */
@@ -111,6 +111,21 @@ ecdsa_prepare_digest(const unsigned char *dgst, int dgst_len, BIGNUM *order,
111 return 1; 111 return 1;
112} 112}
113 113
114int
115ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig,
116 unsigned int *siglen, const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey)
117{
118 ECDSA_SIG *s;
119
120 if ((s = ECDSA_do_sign_ex(dgst, dlen, kinv, r, eckey)) == NULL) {
121 *siglen = 0;
122 return 0;
123 }
124 *siglen = i2d_ECDSA_SIG(s, &sig);
125 ECDSA_SIG_free(s);
126 return 1;
127}
128
114static int 129static int
115ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) 130ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
116{ 131{
@@ -234,6 +249,16 @@ ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
234 return (ret); 249 return (ret);
235} 250}
236 251
252/* replace w/ ecdsa_sign_setup() when ECDSA_METHOD gets removed */
253int
254ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
255{
256 ECDSA_DATA *ecdsa;
257
258 if ((ecdsa = ecdsa_check(eckey)) == NULL)
259 return 0;
260 return ecdsa->meth->ecdsa_sign_setup(eckey, ctx_in, kinvp, rp);
261}
237 262
238static ECDSA_SIG * 263static ECDSA_SIG *
239ecdsa_do_sign(const unsigned char *dgst, int dgst_len, 264ecdsa_do_sign(const unsigned char *dgst, int dgst_len,
@@ -384,6 +409,18 @@ ecdsa_do_sign(const unsigned char *dgst, int dgst_len,
384 return ret; 409 return ret;
385} 410}
386 411
412/* replace w/ ecdsa_do_sign() when ECDSA_METHOD gets removed */
413ECDSA_SIG *
414ossl_ecdsa_sign_sig(const unsigned char *dgst, int dgst_len,
415 const BIGNUM *in_kinv, const BIGNUM *in_r, EC_KEY *eckey)
416{
417 ECDSA_DATA *ecdsa;
418
419 if ((ecdsa = ecdsa_check(eckey)) == NULL)
420 return NULL;
421 return ecdsa->meth->ecdsa_do_sign(dgst, dgst_len, in_kinv, in_r, eckey);
422}
423
387static int 424static int
388ecdsa_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, 425ecdsa_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig,
389 EC_KEY *eckey) 426 EC_KEY *eckey)