sync
This commit is contained in:
parent
3751effe59
commit
29ec20d7b2
33 changed files with 213 additions and 288 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ec_asn1.c,v 1.45 2023/05/04 05:59:38 tb Exp $ */
|
||||
/* $OpenBSD: ec_asn1.c,v 1.46 2023/06/27 07:28:57 tb Exp $ */
|
||||
/*
|
||||
* Written by Nils Larsch for the OpenSSL project.
|
||||
*/
|
||||
|
@ -70,23 +70,7 @@
|
|||
int
|
||||
EC_GROUP_get_basis_type(const EC_GROUP *group)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) !=
|
||||
NID_X9_62_characteristic_two_field)
|
||||
/* everything else is currently not supported */
|
||||
return 0;
|
||||
|
||||
while (group->poly[i] != 0)
|
||||
i++;
|
||||
|
||||
if (i == 4)
|
||||
return NID_X9_62_ppBasis;
|
||||
else if (i == 2)
|
||||
return NID_X9_62_tpBasis;
|
||||
else
|
||||
/* everything else is currently not supported */
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* some structures needed for the asn1 encoding */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ec_local.h,v 1.21 2023/06/25 19:22:21 tb Exp $ */
|
||||
/* $OpenBSD: ec_local.h,v 1.22 2023/06/27 07:31:18 tb Exp $ */
|
||||
/*
|
||||
* Originally written by Bodo Moeller for the OpenSSL project.
|
||||
*/
|
||||
|
@ -205,22 +205,9 @@ struct ec_group_st {
|
|||
*/
|
||||
BIGNUM field;
|
||||
|
||||
/*
|
||||
* Field specification for GF(2^m). The irreducible polynomial is
|
||||
* f(t) = t^poly[0] + t^poly[1] + ... + t^poly[k],
|
||||
* where
|
||||
* m = poly[0] > poly[1] > ... > poly[k] = 0,
|
||||
* and the array is terminated with poly[k+1] = -1. All elliptic curve
|
||||
* irreducibles have at most 5 non-zero terms.
|
||||
*/
|
||||
int poly[6];
|
||||
|
||||
/*
|
||||
* Curve coefficients. In characteristic > 3, the curve is defined by a
|
||||
* Weierstrass equation of the form
|
||||
* y^2 = x^3 + a*x + b.
|
||||
* For characteristic 2, the curve is defined by an equation of the form
|
||||
* y^2 + x*y = x^3 + a*x^2 + b.
|
||||
* Weierstrass equation of the form y^2 = x^3 + a*x + b.
|
||||
*/
|
||||
BIGNUM a, b;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: eck_prn.c,v 1.20 2022/11/19 07:29:29 tb Exp $ */
|
||||
/* $OpenBSD: eck_prn.c,v 1.21 2023/06/27 07:32:29 tb Exp $ */
|
||||
/*
|
||||
* Written by Nils Larsch for the OpenSSL project.
|
||||
*/
|
||||
|
@ -163,6 +163,7 @@ ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off)
|
|||
unsigned char *buffer = NULL;
|
||||
size_t buf_len = 0, i;
|
||||
int ret = 0, reason = ERR_R_BIO_LIB;
|
||||
int nid;
|
||||
BN_CTX *ctx = NULL;
|
||||
const EC_POINT *point = NULL;
|
||||
BIGNUM *p = NULL, *a = NULL, *b = NULL, *gen = NULL, *order = NULL,
|
||||
|
@ -186,8 +187,6 @@ ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off)
|
|||
}
|
||||
if (EC_GROUP_get_asn1_flag(x)) {
|
||||
/* the curve parameter are given by an asn1 OID */
|
||||
int nid;
|
||||
|
||||
if (!BIO_indent(bp, off, 128))
|
||||
goto err;
|
||||
|
||||
|
@ -209,12 +208,7 @@ ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off)
|
|||
}
|
||||
} else {
|
||||
/* explicit parameters */
|
||||
int is_char_two = 0;
|
||||
point_conversion_form_t form;
|
||||
int tmp_nid = EC_METHOD_get_field_type(EC_GROUP_method_of(x));
|
||||
|
||||
if (tmp_nid == NID_X9_62_characteristic_two_field)
|
||||
is_char_two = 1;
|
||||
|
||||
if ((p = BN_new()) == NULL || (a = BN_new()) == NULL ||
|
||||
(b = BN_new()) == NULL || (order = BN_new()) == NULL ||
|
||||
|
@ -266,32 +260,13 @@ ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off)
|
|||
if (!BIO_indent(bp, off, 128))
|
||||
goto err;
|
||||
|
||||
nid = EC_METHOD_get_field_type(EC_GROUP_method_of(x));
|
||||
/* print the 'short name' of the field type */
|
||||
if (BIO_printf(bp, "Field Type: %s\n", OBJ_nid2sn(tmp_nid))
|
||||
<= 0)
|
||||
if (BIO_printf(bp, "Field Type: %s\n", OBJ_nid2sn(nid)) <= 0)
|
||||
goto err;
|
||||
|
||||
if (is_char_two) {
|
||||
/* print the 'short name' of the base type OID */
|
||||
int basis_type = EC_GROUP_get_basis_type(x);
|
||||
if (basis_type == 0)
|
||||
goto err;
|
||||
|
||||
if (!BIO_indent(bp, off, 128))
|
||||
goto err;
|
||||
|
||||
if (BIO_printf(bp, "Basis Type: %s\n",
|
||||
OBJ_nid2sn(basis_type)) <= 0)
|
||||
goto err;
|
||||
|
||||
/* print the polynomial */
|
||||
if ((p != NULL) && !ASN1_bn_print(bp, "Polynomial:", p, buffer,
|
||||
off))
|
||||
goto err;
|
||||
} else {
|
||||
if ((p != NULL) && !ASN1_bn_print(bp, "Prime:", p, buffer, off))
|
||||
goto err;
|
||||
}
|
||||
if ((p != NULL) && !ASN1_bn_print(bp, "Prime:", p, buffer, off))
|
||||
goto err;
|
||||
if ((a != NULL) && !ASN1_bn_print(bp, "A: ", a, buffer, off))
|
||||
goto err;
|
||||
if ((b != NULL) && !ASN1_bn_print(bp, "B: ", b, buffer, off))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue