sync with OpenBSD -current

This commit is contained in:
purplerain 2024-10-16 01:51:11 +00:00
parent 74987653ce
commit 037d9f0129
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
17 changed files with 71 additions and 68 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ec_asn1.c,v 1.72 2024/10/14 18:17:11 tb Exp $ */
/* $OpenBSD: ec_asn1.c,v 1.73 2024/10/15 06:35:59 tb Exp $ */
/*
* Written by Nils Larsch for the OpenSSL project.
*/
@ -695,15 +695,11 @@ ec_asn1_group2parameters(const EC_GROUP *group)
int ok = 0;
size_t len = 0;
ECPARAMETERS *ret = NULL;
BIGNUM *tmp = NULL;
const BIGNUM *order, *cofactor;
unsigned char *buffer = NULL;
const EC_POINT *point = NULL;
point_conversion_form_t form;
if ((tmp = BN_new()) == NULL) {
ECerror(ERR_R_MALLOC_FAILURE);
goto err;
}
if ((ret = ECPARAMETERS_new()) == NULL) {
ECerror(ERR_R_MALLOC_FAILURE);
goto err;
@ -750,19 +746,27 @@ ec_asn1_group2parameters(const EC_GROUP *group)
ECerror(ERR_R_ASN1_LIB);
goto err;
}
if (!EC_GROUP_get_order(group, tmp, NULL)) {
if ((order = EC_GROUP_get0_order(group)) == NULL) {
ECerror(ERR_R_EC_LIB);
goto err;
}
if (BN_is_zero(order)) {
ECerror(ERR_R_EC_LIB);
goto err;
}
ASN1_INTEGER_free(ret->order);
if ((ret->order = BN_to_ASN1_INTEGER(tmp, NULL)) == NULL) {
if ((ret->order = BN_to_ASN1_INTEGER(order, NULL)) == NULL) {
ECerror(ERR_R_ASN1_LIB);
goto err;
}
ASN1_INTEGER_free(ret->cofactor);
ret->cofactor = NULL;
if (EC_GROUP_get_cofactor(group, tmp, NULL)) {
if ((ret->cofactor = BN_to_ASN1_INTEGER(tmp, NULL)) == NULL) {
if ((cofactor = EC_GROUP_get0_cofactor(group)) == NULL) {
ECerror(ERR_R_EC_LIB);
goto err;
}
if (!BN_is_zero(cofactor)) {
if ((ret->cofactor = BN_to_ASN1_INTEGER(cofactor, NULL)) == NULL) {
ECerror(ERR_R_ASN1_LIB);
goto err;
}
@ -774,7 +778,6 @@ ec_asn1_group2parameters(const EC_GROUP *group)
ECPARAMETERS_free(ret);
ret = NULL;
}
BN_free(tmp);
free(buffer);
return (ret);
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ec_lib.c,v 1.67 2024/04/23 10:52:08 tb Exp $ */
/* $OpenBSD: ec_lib.c,v 1.69 2024/10/15 17:44:43 tb Exp $ */
/*
* Originally written by Bodo Moeller for the OpenSSL project.
*/
@ -335,11 +335,11 @@ EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,
return 0;
}
if (group->generator == NULL) {
if (group->generator == NULL)
group->generator = EC_POINT_new(group);
if (group->generator == NULL)
return 0;
}
if (group->generator == NULL)
return 0;
if (!EC_POINT_copy(group->generator, generator))
return 0;
@ -393,6 +393,12 @@ EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx)
}
LCRYPTO_ALIAS(EC_GROUP_get_cofactor);
const BIGNUM *
EC_GROUP_get0_cofactor(const EC_GROUP *group)
{
return &group->cofactor;
}
void
EC_GROUP_set_curve_name(EC_GROUP *group, int nid)
{

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ec_local.h,v 1.28 2024/10/03 06:24:07 tb Exp $ */
/* $OpenBSD: ec_local.h,v 1.29 2024/10/15 06:27:43 tb Exp $ */
/*
* Originally written by Bodo Moeller for the OpenSSL project.
*/
@ -356,6 +356,7 @@ int EC_POINT_get_Jprojective_coordinates(const EC_GROUP *group,
const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx);
/* Public API in OpenSSL */
const BIGNUM *EC_GROUP_get0_cofactor(const EC_GROUP *group);
const BIGNUM *EC_GROUP_get0_order(const EC_GROUP *group);
__END_HIDDEN_DECLS