From 4c908616aa50e22645747c285720f6f2addd285c Mon Sep 17 00:00:00 2001 From: tb <> Date: Sun, 24 Nov 2024 10:13:16 +0000 Subject: Disable regression tests for small builtin curves --- src/regress/lib/libcrypto/ec/ec_asn1_test.c | 8 +++++++- src/regress/lib/libcrypto/ecdh/ecc_cdh.c | 4 +++- src/regress/lib/libcrypto/ecdh/ecdhtest.c | 4 +++- src/regress/lib/libcrypto/wycheproof/wycheproof.go | 18 ++++++++++++++++-- 4 files changed, 29 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/regress/lib/libcrypto/ec/ec_asn1_test.c b/src/regress/lib/libcrypto/ec/ec_asn1_test.c index e8758ee259..b1eabdbfb1 100644 --- a/src/regress/lib/libcrypto/ec/ec_asn1_test.c +++ b/src/regress/lib/libcrypto/ec/ec_asn1_test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_asn1_test.c,v 1.29 2024/11/08 12:35:26 tb Exp $ */ +/* $OpenBSD: ec_asn1_test.c,v 1.30 2024/11/24 10:13:16 tb Exp $ */ /* * Copyright (c) 2017, 2021 Joel Sing * Copyright (c) 2024 Theo Buehler @@ -1035,6 +1035,7 @@ static const struct ec_private_key { int oct_len; uint8_t oct[256]; } ec_private_keys[] = { +#ifdef ENABLE_SMALL_CURVES { .name = "secp112r1", .der_len = 64, @@ -1272,6 +1273,7 @@ static const struct ec_private_key { 0xdc, }, }, +#endif /* ENABLE_SMALL_CURVES */ { .name = "secp224k1", .der_len = 107, @@ -1519,6 +1521,7 @@ static const struct ec_private_key { 0x9c, 0x6b, 0xce, 0xc4, 0x8e, }, }, +#ifdef ENABLE_SMALL_CURVES { .name = "prime192v1", .der_len = 97, @@ -1627,6 +1630,7 @@ static const struct ec_private_key { 0xd3, }, }, +#endif /* ENABLE_SMALL_CURVES */ { .name = "prime239v1", .der_len = 115, @@ -1790,6 +1794,7 @@ static const struct ec_private_key { 0xe3, }, }, +#ifdef ENABLE_SMALL_CURVES { .name = "wap-wsg-idm-ecid-wtls6", .der_len = 64, @@ -2080,6 +2085,7 @@ static const struct ec_private_key { 0xc7, }, }, +#endif /* ENABLE_SMALL_CURVES */ { .name = "brainpoolP224r1", .der_len = 110, diff --git a/src/regress/lib/libcrypto/ecdh/ecc_cdh.c b/src/regress/lib/libcrypto/ecdh/ecc_cdh.c index 0333cf1e87..0ab031276d 100644 --- a/src/regress/lib/libcrypto/ecdh/ecc_cdh.c +++ b/src/regress/lib/libcrypto/ecdh/ecc_cdh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecc_cdh.c,v 1.2 2023/07/16 08:25:41 tb Exp $ */ +/* $OpenBSD: ecc_cdh.c,v 1.3 2024/11/24 10:13:16 tb Exp $ */ /* * Copyright (c) 2023 Theo Buehler @@ -40,6 +40,7 @@ static const struct ecc_cdh_test { const char *pub_y; const char *want; } ecc_cdh_tests[] = { +#ifdef ENABLE_SMALL_CURVES { .nid = NID_X9_62_prime192v1, .peer_x = "42ea6dd9969dd2a61fea1aac7f8e98edcc896c6e55857cc0", @@ -265,6 +266,7 @@ static const struct ecc_cdh_test { .pub_y = "58ea42edbeeafca9ff44cfd7f29abd2cbde7626d79e422c9", .want = "72e88f3ea67d46d46dbf83926e7e2a6b85b54536741e6d2c", }, +#endif /* ENABLE_SMALL_CURVES */ { .nid = NID_secp224r1, diff --git a/src/regress/lib/libcrypto/ecdh/ecdhtest.c b/src/regress/lib/libcrypto/ecdh/ecdhtest.c index 7d7bbf5465..2f726ecb50 100644 --- a/src/regress/lib/libcrypto/ecdh/ecdhtest.c +++ b/src/regress/lib/libcrypto/ecdh/ecdhtest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecdhtest.c,v 1.20 2023/07/16 07:34:07 tb Exp $ */ +/* $OpenBSD: ecdhtest.c,v 1.21 2024/11/24 10:13:16 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -174,12 +174,14 @@ static const struct ecdh_kat_test { const char *want; } ecdh_kat_tests[] = { /* Keys and shared secrets from RFC 5114 */ +#ifdef ENABLE_SMALL_CURVES { .nid = NID_X9_62_prime192v1, .keya = "323fa3169d8e9c6593f59476bc142000ab5be0e249c43426", .keyb = "631f95bb4a67632c9c476eee9ab695ab240a0499307fcf62", .want = "ad420182633f8526bfe954acda376f05e5ff4f837f54febe", }, +#endif { .nid = NID_secp224r1, .keya = "b558eb6c288da707bbb4f8fbae2ab9e9cb62e3bc5c7573e2" diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go index ddd37030d4..8f0dfc8b2e 100644 --- a/src/regress/lib/libcrypto/wycheproof/wycheproof.go +++ b/src/regress/lib/libcrypto/wycheproof/wycheproof.go @@ -1,4 +1,4 @@ -/* $OpenBSD: wycheproof.go,v 1.160 2024/05/22 14:03:24 tb Exp $ */ +/* $OpenBSD: wycheproof.go,v 1.161 2024/11/24 10:13:16 tb Exp $ */ /* * Copyright (c) 2018,2023 Joel Sing * Copyright (c) 2018,2019,2022-2024 Theo Buehler @@ -641,6 +641,14 @@ func nidFromString(ns string) (int, error) { return -1, fmt.Errorf("unknown NID %q", ns) } +func skipSmallCurve(nid int) bool { + switch C.int(nid) { + case C.NID_secp160k1, C.NID_secp160r1, C.NID_secp160r2, C.NID_secp192k1, C.NID_X9_62_prime192v1: + return true + } + return false +} + var evpMds = map[string]*C.EVP_MD{ "SHA-1": C.EVP_sha1(), "SHA-224": C.EVP_sha224(), @@ -1637,6 +1645,9 @@ func (wtg *wycheproofTestGroupECDH) run(algorithm string, variant testVariant) b if err != nil { log.Fatalf("Failed to get nid for curve: %v", err) } + if skipSmallCurve(nid) { + return true + } success := true for _, wt := range wtg.Tests { @@ -1786,6 +1797,9 @@ func (wtg *wycheproofTestGroupECDSA) run(algorithm string, variant testVariant) if err != nil { log.Fatalf("Failed to get nid for curve: %v", err) } + if skipSmallCurve(nid) { + return true + } ecKey := C.EC_KEY_new_by_curve_name(C.int(nid)) if ecKey == nil { log.Fatal("EC_KEY_new_by_curve_name failed") @@ -2750,7 +2764,7 @@ func main() { testc = newTestCoordinator() - skipNormal := regexp.MustCompile(`_(ecpoint|p1363|sect\d{3}[rk]1)_`) + skipNormal := regexp.MustCompile(`_(ecpoint|p1363|sect\d{3}[rk]1|secp(160|192))_`) for _, test := range tests { tvs, err := filepath.Glob(filepath.Join(testVectorPath, test.pattern)) -- cgit v1.2.3-55-g6feb