sync
This commit is contained in:
parent
01bad5edf2
commit
f609457dcf
85 changed files with 1589 additions and 1491 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ec_curve.c,v 1.39 2023/05/01 17:53:01 tb Exp $ */
|
||||
/* $OpenBSD: ec_curve.c,v 1.41 2023/05/02 13:01:57 tb Exp $ */
|
||||
/*
|
||||
* Written by Nils Larsch for the OpenSSL project.
|
||||
*/
|
||||
|
@ -3000,11 +3000,10 @@ static const struct ec_list_element {
|
|||
static EC_GROUP *
|
||||
ec_group_new_from_data(const struct ec_list_element *curve)
|
||||
{
|
||||
EC_GROUP *group = NULL;
|
||||
EC_POINT *P = NULL;
|
||||
EC_GROUP *group = NULL, *ret = NULL;
|
||||
EC_POINT *generator = NULL;
|
||||
BN_CTX *ctx = NULL;
|
||||
BIGNUM *p, *a, *b, *x, *y, *order, *cofactor;
|
||||
int ok = 0;
|
||||
|
||||
if ((ctx = BN_CTX_new()) == NULL) {
|
||||
ECerror(ERR_R_MALLOC_FAILURE);
|
||||
|
@ -3057,8 +3056,9 @@ ec_group_new_from_data(const struct ec_list_element *curve)
|
|||
ECerror(ERR_R_EC_LIB);
|
||||
goto err;
|
||||
}
|
||||
EC_GROUP_set_curve_name(group, curve->nid);
|
||||
|
||||
if ((P = EC_POINT_new(group)) == NULL) {
|
||||
if ((generator = EC_POINT_new(group)) == NULL) {
|
||||
ECerror(ERR_R_EC_LIB);
|
||||
goto err;
|
||||
}
|
||||
|
@ -3070,7 +3070,7 @@ ec_group_new_from_data(const struct ec_list_element *curve)
|
|||
ECerror(ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
if (!EC_POINT_set_affine_coordinates(group, P, x, y, ctx)) {
|
||||
if (!EC_POINT_set_affine_coordinates(group, generator, x, y, ctx)) {
|
||||
ECerror(ERR_R_EC_LIB);
|
||||
goto err;
|
||||
}
|
||||
|
@ -3082,51 +3082,45 @@ ec_group_new_from_data(const struct ec_list_element *curve)
|
|||
ECerror(ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
if (!EC_GROUP_set_generator(group, P, order, cofactor)) {
|
||||
if (!EC_GROUP_set_generator(group, generator, order, cofactor)) {
|
||||
ECerror(ERR_R_EC_LIB);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (curve->seed != NULL) {
|
||||
if (!EC_GROUP_set_seed(group, curve->seed, curve->seed_len)) {
|
||||
ECerror(ERR_R_EC_LIB);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
ok = 1;
|
||||
|
||||
ret = group;
|
||||
group = NULL;
|
||||
|
||||
err:
|
||||
if (!ok) {
|
||||
EC_GROUP_free(group);
|
||||
group = NULL;
|
||||
}
|
||||
EC_POINT_free(P);
|
||||
EC_GROUP_free(group);
|
||||
EC_POINT_free(generator);
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx);
|
||||
|
||||
return group;
|
||||
return ret;
|
||||
}
|
||||
|
||||
EC_GROUP *
|
||||
EC_GROUP_new_by_curve_name(int nid)
|
||||
{
|
||||
size_t i;
|
||||
EC_GROUP *ret = NULL;
|
||||
|
||||
if (nid <= 0)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < CURVE_LIST_LENGTH; i++) {
|
||||
if (curve_list[i].nid == nid) {
|
||||
ret = ec_group_new_from_data(&curve_list[i]);
|
||||
break;
|
||||
}
|
||||
if (curve_list[i].nid == nid)
|
||||
return ec_group_new_from_data(&curve_list[i]);
|
||||
}
|
||||
if (ret == NULL) {
|
||||
ECerror(EC_R_UNKNOWN_GROUP);
|
||||
return NULL;
|
||||
}
|
||||
EC_GROUP_set_curve_name(ret, nid);
|
||||
|
||||
return ret;
|
||||
ECerror(EC_R_UNKNOWN_GROUP);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue