From: tb Date: Wed, 5 Jul 2023 12:27:36 +0000 (+0000) Subject: Move ECDSA_size() to a more sensible place in this file X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c0ee283e976ede249a34ca5fe4ce21ae8d60d09c;p=openbsd Move ECDSA_size() to a more sensible place in this file --- diff --git a/lib/libcrypto/ecdsa/ecdsa.c b/lib/libcrypto/ecdsa/ecdsa.c index c831e9f7160..20d605cafd0 100644 --- a/lib/libcrypto/ecdsa/ecdsa.c +++ b/lib/libcrypto/ecdsa/ecdsa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecdsa.c,v 1.1 2023/07/05 12:18:21 tb Exp $ */ +/* $OpenBSD: ecdsa.c,v 1.2 2023/07/05 12:27:36 tb Exp $ */ /* ==================================================================== * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. * @@ -158,6 +158,33 @@ ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) return 1; } +int +ECDSA_size(const EC_KEY *r) +{ + const EC_GROUP *group; + const BIGNUM *order = NULL; + ECDSA_SIG sig; + int ret = 0; + + if (r == NULL) + goto err; + + if ((group = EC_KEY_get0_group(r)) == NULL) + goto err; + + if ((order = EC_GROUP_get0_order(group)) == NULL) + goto err; + + sig.r = (BIGNUM *)order; + sig.s = (BIGNUM *)order; + + if ((ret = i2d_ECDSA_SIG(&sig, NULL)) < 0) + ret = 0; + + err: + return ret; +} + /* * FIPS 186-5, section 6.4.1, step 2: convert hashed message into an integer. * Use the order_bits leftmost bits if it exceeds the group order. @@ -792,30 +819,3 @@ ECDSA_verify(int type, const unsigned char *digest, int digest_len, } return key->meth->verify(type, digest, digest_len, sigbuf, sig_len, key); } - -int -ECDSA_size(const EC_KEY *r) -{ - const EC_GROUP *group; - const BIGNUM *order = NULL; - ECDSA_SIG sig; - int ret = 0; - - if (r == NULL) - goto err; - - if ((group = EC_KEY_get0_group(r)) == NULL) - goto err; - - if ((order = EC_GROUP_get0_order(group)) == NULL) - goto err; - - sig.r = (BIGNUM *)order; - sig.s = (BIGNUM *)order; - - if ((ret = i2d_ECDSA_SIG(&sig, NULL)) < 0) - ret = 0; - - err: - return ret; -}