mirror of
https://github.com/openbsd/src.git
synced 2025-01-09 22:38:01 -08:00
Move ECDSA_size() to a more sensible place in this file
This commit is contained in:
parent
b4a65d296e
commit
c0ee283e97
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user