-/* $OpenBSD: ecs_ossl.c,v 1.47 2023/07/03 05:48:18 tb Exp $ */
+/* $OpenBSD: ecs_ossl.c,v 1.48 2023/07/03 07:28:05 tb Exp $ */
/*
* Written by Nils Larsch for the OpenSSL project
*/
#include "ecs_local.h"
static int ecdsa_prepare_digest(const unsigned char *dgst, int dgst_len,
- BIGNUM *order, BIGNUM *ret);
+ const BIGNUM *order, BIGNUM *ret);
static int
-ecdsa_prepare_digest(const unsigned char *dgst, int dgst_len, BIGNUM *order,
- BIGNUM *ret)
+ecdsa_prepare_digest(const unsigned char *dgst, int dgst_len,
+ const BIGNUM *order, BIGNUM *ret)
{
int dgst_bits, order_bits;
EC_POINT *point = NULL;
BN_CTX *ctx = NULL;
BIGNUM *k = NULL, *r = NULL;
- BIGNUM *order, *x;
+ const BIGNUM *order;
+ BIGNUM *x;
int order_bits;
int ret = 0;
BN_CTX_start(ctx);
- if ((order = BN_CTX_get(ctx)) == NULL)
- goto err;
if ((x = BN_CTX_get(ctx)) == NULL)
goto err;
ECDSAerror(ERR_R_EC_LIB);
goto err;
}
- if (!EC_GROUP_get_order(group, order, ctx)) {
+ if ((order = EC_GROUP_get0_order(group)) == NULL) {
ECDSAerror(ERR_R_EC_LIB);
goto err;
}
const EC_GROUP *group;
BN_CTX *ctx = NULL;
BIGNUM *kinv = NULL, *r = NULL, *s = NULL;
- BIGNUM *b, *binv, *bm, *bxr, *m, *order;
- const BIGNUM *ckinv, *priv_key;
+ BIGNUM *b, *binv, *bm, *bxr, *m;
+ const BIGNUM *ckinv, *order, *priv_key;
int attempts = 0;
ECDSA_SIG *sig = NULL;
BN_CTX_start(ctx);
- if ((order = BN_CTX_get(ctx)) == NULL)
- goto err;
if ((b = BN_CTX_get(ctx)) == NULL)
goto err;
if ((binv = BN_CTX_get(ctx)) == NULL)
if ((m = BN_CTX_get(ctx)) == NULL)
goto err;
- if (!EC_GROUP_get_order(group, order, ctx)) {
+ if ((order = EC_GROUP_get0_order(group)) == NULL) {
ECDSAerror(ERR_R_EC_LIB);
goto err;
}
EC_KEY *eckey)
{
BN_CTX *ctx;
- BIGNUM *order, *u1, *u2, *m, *x;
+ BIGNUM *u1, *u2, *m, *x;
EC_POINT *point = NULL;
const EC_GROUP *group;
const EC_POINT *pub_key;
+ const BIGNUM *order;
int ret = -1;
if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL ||
return -1;
}
BN_CTX_start(ctx);
- order = BN_CTX_get(ctx);
u1 = BN_CTX_get(ctx);
u2 = BN_CTX_get(ctx);
m = BN_CTX_get(ctx);
goto err;
}
- if (!EC_GROUP_get_order(group, order, ctx)) {
+ if ((order = EC_GROUP_get0_order(group)) == NULL) {
ECDSAerror(ERR_R_EC_LIB);
goto err;
}
ECDSA_size(const EC_KEY *r)
{
const EC_GROUP *group;
- BIGNUM *order = NULL;
+ const BIGNUM *order = NULL;
ECDSA_SIG signature;
int ret = 0;
if ((group = EC_KEY_get0_group(r)) == NULL)
goto err;
- if ((order = BN_new()) == NULL)
+ if ((order = EC_GROUP_get0_order(group)) == NULL)
goto err;
- if (!EC_GROUP_get_order(group, order, NULL))
- goto err;
-
- signature.r = order;
- signature.s = order;
+ signature.r = (BIGNUM *)order;
+ signature.s = (BIGNUM *)order;
if ((ret = i2d_ECDSA_SIG(&signature, NULL)) < 0)
ret = 0;
err:
- BN_free(order);
-
return ret;
}