summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbluhm <>2023-03-30 15:51:09 +0000
committerbluhm <>2023-03-30 15:51:09 +0000
commit96e4788cde61058167082e95712348212c565bf9 (patch)
tree9f2d7e3141902e1554f824d2c9b6bc5d9e54f08a /src
parent3f0e663d41d78ec3603e3d4895fa3700096a3515 (diff)
downloadopenbsd-96e4788cde61058167082e95712348212c565bf9.tar.gz
openbsd-96e4788cde61058167082e95712348212c565bf9.tar.bz2
openbsd-96e4788cde61058167082e95712348212c565bf9.zip
i2d_ECDSA_SIG() may return a negative value in case of error. Handle
this in ossl_ecdsa_sign() and propagate the return code. OK jsing@ tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/ecdsa/ecs_ossl.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/lib/libcrypto/ecdsa/ecs_ossl.c b/src/lib/libcrypto/ecdsa/ecs_ossl.c
index e6d6b0cd71..78e2b4a997 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.31 2023/03/27 10:25:02 tb Exp $ */ 1/* $OpenBSD: ecs_ossl.c,v 1.32 2023/03/30 15:51:09 bluhm Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project 3 * Written by Nils Larsch for the OpenSSL project
4 */ 4 */
@@ -118,14 +118,23 @@ ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen, unsigned char *si
118 unsigned int *siglen, const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey) 118 unsigned int *siglen, const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey)
119{ 119{
120 ECDSA_SIG *s; 120 ECDSA_SIG *s;
121 int outlen = 0;
122 int ret = 0;
121 123
122 if ((s = ECDSA_do_sign_ex(dgst, dlen, kinv, r, eckey)) == NULL) { 124 if ((s = ECDSA_do_sign_ex(dgst, dlen, kinv, r, eckey)) == NULL) {
123 *siglen = 0; 125 goto err;
124 return 0;
125 } 126 }
126 *siglen = i2d_ECDSA_SIG(s, &sig); 127 if ((outlen = i2d_ECDSA_SIG(s, &sig)) < 0) {
128 outlen = 0;
129 goto err;
130 }
131
132 ret = 1;
133
134 err:
135 *siglen = outlen;
127 ECDSA_SIG_free(s); 136 ECDSA_SIG_free(s);
128 return 1; 137 return ret;
129} 138}
130 139
131static int 140static int