From fa4ae9b2e2bf73253e698c73d9079ce2f4c895ac Mon Sep 17 00:00:00 2001 From: tb Date: Tue, 18 Apr 2023 08:05:18 +0000 Subject: [PATCH] ec_point_conversion: drop test for sect571k1 Maybe it should be replaced by another test, although P-256 seems enough. --- .../lib/libcrypto/ec/ec_point_conversion.c | 352 +----------------- 1 file changed, 2 insertions(+), 350 deletions(-) diff --git a/regress/lib/libcrypto/ec/ec_point_conversion.c b/regress/lib/libcrypto/ec/ec_point_conversion.c index 1b40ddc2eba..398f8686157 100644 --- a/regress/lib/libcrypto/ec/ec_point_conversion.c +++ b/regress/lib/libcrypto/ec/ec_point_conversion.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_point_conversion.c,v 1.11 2023/04/17 21:00:35 tb Exp $ */ +/* $OpenBSD: ec_point_conversion.c,v 1.12 2023/04/18 08:05:18 tb Exp $ */ /* * Copyright (c) 2021 Theo Buehler * Copyright (c) 2021 Joel Sing @@ -110,43 +110,6 @@ roundtrip(EC_GROUP *group, EC_POINT *point, int form, BIGNUM *x, BIGNUM *y) return failed; } -#ifndef OPENSSL_NO_EC2M -static int -test_hybrid_corner_case(void) -{ - BIGNUM *x = NULL, *y = NULL; - EC_GROUP *group; - EC_POINT *point; - size_t i; - int failed = 0; - - if (!BN_hex2bn(&x, "0")) - errx(1, "BN_hex2bn x"); - if (!BN_hex2bn(&y, "01")) - errx(1, "BN_hex2bn y"); - - if ((group = EC_GROUP_new_by_curve_name(NID_sect571k1)) == NULL) - errx(1, "group"); - if ((point = EC_POINT_new(group)) == NULL) - errx(1, "point"); - - if (!EC_POINT_set_affine_coordinates(group, point, x, y, NULL)) - errx(1, "set affine"); - - for (i = 0; i < N_FORMS; i++) - failed |= roundtrip(group, point, forms[i], x, y); - - fprintf(stderr, "%s %s\n", __func__, failed ? ": FAILED" : ""); - - EC_GROUP_free(group); - EC_POINT_free(point); - BN_free(x); - BN_free(y); - - return failed; -} -#endif - /* XXX This only tests multiples of the generator for now... */ static int test_random_points_on_curve(EC_builtin_curve *curve) @@ -258,315 +221,7 @@ static const struct point_conversion { uint8_t octets_len; int valid; } point_conversions[] = { -#ifndef OPENSSL_NO_EC2M - { - .description = "point at infinity on sect571k1", - .nid = NID_sect571k1, - .octets = { 0x00 }, - .octets_len = 1, - .valid = 1, - }, - { - .description = "point at infinity on sect571k1 (flipped y_bit)", - .nid = NID_sect571k1, - .octets = { 0x01 }, - .octets_len = 1, - .valid = 0, - }, - { - .description = "zero x compressed point on sect571k1", - .nid = NID_sect571k1, - .octets = { - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, - }, - .octets_len = 73, - .valid = 1, - }, - { - .description = - "zero x compressed point on sect571k1 (flipped y_bit)", - .nid = NID_sect571k1, - .octets = { - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, - }, - .octets_len = 73, - .valid = 0, - }, - { - .description = "generic compressed point on sect571k1", - .nid = NID_sect571k1, - .octets = { - 0x02, 0x00, 0x5e, 0x33, 0x9f, 0xd6, 0xf1, 0xae, - 0x10, 0xbd, 0x48, 0xcf, 0xf1, 0x0d, 0x8e, 0x0e, - 0xd7, 0x83, 0xce, 0xf0, 0x3d, 0x14, 0x06, 0x41, - 0x29, 0x7d, 0x7e, 0xa3, 0x01, 0xf4, 0x9b, 0xa2, - 0x8c, 0xa6, 0xab, 0x24, 0xa0, 0x9e, 0xfd, 0xc4, - 0x2d, 0xc2, 0x95, 0xb4, 0xf9, 0xd4, 0xf4, 0x97, - 0x53, 0x5d, 0xe9, 0xe3, 0x47, 0xc3, 0xa8, 0x6b, - 0xbb, 0x27, 0x74, 0x6b, 0xfb, 0x26, 0xca, 0x96, - 0x76, 0x5b, 0x36, 0xe8, 0x87, 0xb5, 0xc5, 0x6a, - 0xc5, - }, - .octets_len = 73, - .valid = 1, - }, - { - .description = - "generic compressed point on sect571k1 (flipped y_bit)", - .nid = NID_sect571k1, - .octets = { - 0x03, 0x00, 0x5e, 0x33, 0x9f, 0xd6, 0xf1, 0xae, - 0x10, 0xbd, 0x48, 0xcf, 0xf1, 0x0d, 0x8e, 0x0e, - 0xd7, 0x83, 0xce, 0xf0, 0x3d, 0x14, 0x06, 0x41, - 0x29, 0x7d, 0x7e, 0xa3, 0x01, 0xf4, 0x9b, 0xa2, - 0x8c, 0xa6, 0xab, 0x24, 0xa0, 0x9e, 0xfd, 0xc4, - 0x2d, 0xc2, 0x95, 0xb4, 0xf9, 0xd4, 0xf4, 0x97, - 0x53, 0x5d, 0xe9, 0xe3, 0x47, 0xc3, 0xa8, 0x6b, - 0xbb, 0x27, 0x74, 0x6b, 0xfb, 0x26, 0xca, 0x96, - 0x76, 0x5b, 0x36, 0xe8, 0x87, 0xb5, 0xc5, 0x6a, - 0xc5, - }, - .octets_len = 73, - .valid = 1, - }, - { - .description = "zero x uncompressed point on sect571k1", - .nid = NID_sect571k1, - .octets = { - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, - }, - .octets_len = 145, - .valid = 1, - }, - { - .description = "zero x uncompressed point on sect571k1", - .nid = NID_sect571k1, - .octets = { - 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, - }, - .octets_len = 145, - .valid = 0, - }, - { - .description = "generic uncompressed point on sect571k1", - .nid = NID_sect571k1, - .octets = { - 0x04, 0x02, 0x2d, 0xf4, 0x72, 0x38, 0xc2, 0xbe, - 0x0d, 0xa4, 0xf1, 0xfc, 0xe8, 0x78, 0xe6, 0xad, - 0x5c, 0xaa, 0xd9, 0x7f, 0x7c, 0xa9, 0x4c, 0xe4, - 0xd2, 0xae, 0xba, 0xaa, 0x8c, 0x9d, 0x4c, 0xac, - 0x85, 0x00, 0xe1, 0xfa, 0x33, 0x73, 0x51, 0x52, - 0x5a, 0x4e, 0x75, 0x67, 0x1d, 0x0a, 0x2a, 0xd2, - 0x38, 0xb2, 0x9b, 0xe8, 0xec, 0xbe, 0x07, 0x8b, - 0xc0, 0x95, 0x77, 0xe9, 0x55, 0x0c, 0x6c, 0x0e, - 0x02, 0x3b, 0x34, 0xe2, 0xa8, 0x29, 0xd2, 0x97, - 0xd9, 0x05, 0xa2, 0x6f, 0xa8, 0x6f, 0x1c, 0x3a, - 0xf6, 0x12, 0x42, 0x1a, 0x26, 0x6e, 0x87, 0xf3, - 0x19, 0x04, 0x20, 0xa5, 0x29, 0x78, 0xee, 0xcf, - 0x91, 0x06, 0xd2, 0x5a, 0x62, 0x2a, 0x7f, 0x1d, - 0xa0, 0x7b, 0xb4, 0x31, 0x9c, 0xd2, 0x14, 0x60, - 0xf5, 0x9b, 0xea, 0x4a, 0x41, 0xad, 0x47, 0x72, - 0xf9, 0x01, 0xed, 0x7f, 0x5a, 0x27, 0x64, 0xa2, - 0x53, 0x4e, 0x18, 0x51, 0x33, 0xa8, 0x1e, 0x3a, - 0xc2, 0xe7, 0x2c, 0xe3, 0x63, 0x6d, 0x06, 0x29, - 0x28, - }, - .octets_len = 145, - .valid = 1, - }, - { - .description = - "generic uncompressed point on sect571k1 (flipped y_bit)", - .nid = NID_sect571k1, - .octets = { - 0x05, 0x02, 0x2d, 0xf4, 0x72, 0x38, 0xc2, 0xbe, - 0x0d, 0xa4, 0xf1, 0xfc, 0xe8, 0x78, 0xe6, 0xad, - 0x5c, 0xaa, 0xd9, 0x7f, 0x7c, 0xa9, 0x4c, 0xe4, - 0xd2, 0xae, 0xba, 0xaa, 0x8c, 0x9d, 0x4c, 0xac, - 0x85, 0x00, 0xe1, 0xfa, 0x33, 0x73, 0x51, 0x52, - 0x5a, 0x4e, 0x75, 0x67, 0x1d, 0x0a, 0x2a, 0xd2, - 0x38, 0xb2, 0x9b, 0xe8, 0xec, 0xbe, 0x07, 0x8b, - 0xc0, 0x95, 0x77, 0xe9, 0x55, 0x0c, 0x6c, 0x0e, - 0x02, 0x3b, 0x34, 0xe2, 0xa8, 0x29, 0xd2, 0x97, - 0xd9, 0x05, 0xa2, 0x6f, 0xa8, 0x6f, 0x1c, 0x3a, - 0xf6, 0x12, 0x42, 0x1a, 0x26, 0x6e, 0x87, 0xf3, - 0x19, 0x04, 0x20, 0xa5, 0x29, 0x78, 0xee, 0xcf, - 0x91, 0x06, 0xd2, 0x5a, 0x62, 0x2a, 0x7f, 0x1d, - 0xa0, 0x7b, 0xb4, 0x31, 0x9c, 0xd2, 0x14, 0x60, - 0xf5, 0x9b, 0xea, 0x4a, 0x41, 0xad, 0x47, 0x72, - 0xf9, 0x01, 0xed, 0x7f, 0x5a, 0x27, 0x64, 0xa2, - 0x53, 0x4e, 0x18, 0x51, 0x33, 0xa8, 0x1e, 0x3a, - 0xc2, 0xe7, 0x2c, 0xe3, 0x63, 0x6d, 0x06, 0x29, - 0x28, - }, - .octets_len = 145, - .valid = 0, - }, - { - .description = "zero x hybrid point on sect571k1", - .nid = NID_sect571k1, - .octets = { - 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, - }, - .octets_len = 145, - .valid = 1, - }, - { - .description = - "zero x hybrid point on sect571k1 (flipped y_bit)", - .nid = NID_sect571k1, - .octets = { - 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, - }, - .octets_len = 145, - .valid = 0, - }, - { - .description = "generic hybrid point on sect571k1", - .nid = NID_sect571k1, - .octets = { - 0x07, 0x02, 0x2d, 0xf4, 0x72, 0x38, 0xc2, 0xbe, - 0x0d, 0xa4, 0xf1, 0xfc, 0xe8, 0x78, 0xe6, 0xad, - 0x5c, 0xaa, 0xd9, 0x7f, 0x7c, 0xa9, 0x4c, 0xe4, - 0xd2, 0xae, 0xba, 0xaa, 0x8c, 0x9d, 0x4c, 0xac, - 0x85, 0x00, 0xe1, 0xfa, 0x33, 0x73, 0x51, 0x52, - 0x5a, 0x4e, 0x75, 0x67, 0x1d, 0x0a, 0x2a, 0xd2, - 0x38, 0xb2, 0x9b, 0xe8, 0xec, 0xbe, 0x07, 0x8b, - 0xc0, 0x95, 0x77, 0xe9, 0x55, 0x0c, 0x6c, 0x0e, - 0x02, 0x3b, 0x34, 0xe2, 0xa8, 0x29, 0xd2, 0x97, - 0xd9, 0x05, 0xa2, 0x6f, 0xa8, 0x6f, 0x1c, 0x3a, - 0xf6, 0x12, 0x42, 0x1a, 0x26, 0x6e, 0x87, 0xf3, - 0x19, 0x04, 0x20, 0xa5, 0x29, 0x78, 0xee, 0xcf, - 0x91, 0x06, 0xd2, 0x5a, 0x62, 0x2a, 0x7f, 0x1d, - 0xa0, 0x7b, 0xb4, 0x31, 0x9c, 0xd2, 0x14, 0x60, - 0xf5, 0x9b, 0xea, 0x4a, 0x41, 0xad, 0x47, 0x72, - 0xf9, 0x01, 0xed, 0x7f, 0x5a, 0x27, 0x64, 0xa2, - 0x53, 0x4e, 0x18, 0x51, 0x33, 0xa8, 0x1e, 0x3a, - 0xc2, 0xe7, 0x2c, 0xe3, 0x63, 0x6d, 0x06, 0x29, - 0x28, - }, - .octets_len = 145, - .valid = 1, - }, - { - .description = - "generic hybrid point on sect571k1 (flipped y_bit)", - .nid = NID_sect571k1, - .octets = { - 0x06, 0x02, 0x2d, 0xf4, 0x72, 0x38, 0xc2, 0xbe, - 0x0d, 0xa4, 0xf1, 0xfc, 0xe8, 0x78, 0xe6, 0xad, - 0x5c, 0xaa, 0xd9, 0x7f, 0x7c, 0xa9, 0x4c, 0xe4, - 0xd2, 0xae, 0xba, 0xaa, 0x8c, 0x9d, 0x4c, 0xac, - 0x85, 0x00, 0xe1, 0xfa, 0x33, 0x73, 0x51, 0x52, - 0x5a, 0x4e, 0x75, 0x67, 0x1d, 0x0a, 0x2a, 0xd2, - 0x38, 0xb2, 0x9b, 0xe8, 0xec, 0xbe, 0x07, 0x8b, - 0xc0, 0x95, 0x77, 0xe9, 0x55, 0x0c, 0x6c, 0x0e, - 0x02, 0x3b, 0x34, 0xe2, 0xa8, 0x29, 0xd2, 0x97, - 0xd9, 0x05, 0xa2, 0x6f, 0xa8, 0x6f, 0x1c, 0x3a, - 0xf6, 0x12, 0x42, 0x1a, 0x26, 0x6e, 0x87, 0xf3, - 0x19, 0x04, 0x20, 0xa5, 0x29, 0x78, 0xee, 0xcf, - 0x91, 0x06, 0xd2, 0x5a, 0x62, 0x2a, 0x7f, 0x1d, - 0xa0, 0x7b, 0xb4, 0x31, 0x9c, 0xd2, 0x14, 0x60, - 0xf5, 0x9b, 0xea, 0x4a, 0x41, 0xad, 0x47, 0x72, - 0xf9, 0x01, 0xed, 0x7f, 0x5a, 0x27, 0x64, 0xa2, - 0x53, 0x4e, 0x18, 0x51, 0x33, 0xa8, 0x1e, 0x3a, - 0xc2, 0xe7, 0x2c, 0xe3, 0x63, 0x6d, 0x06, 0x29, - 0x28, - }, - .octets_len = 145, - .valid = 0, - }, -#endif + /* XXX - now that sect571 is no longer tested, add another test? */ { .description = "point at infinity on secp256r1", .nid = NID_X9_62_prime256v1, @@ -897,9 +552,6 @@ main(int argc, char **argv) int failed = 0; failed |= test_random_points(); -#ifndef OPENSSL_NO_EC2M - failed |= test_hybrid_corner_case(); -#endif failed |= test_point_conversions(); return failed; -- 2.20.1