diff options
author | tb <> | 2024-11-24 10:13:16 +0000 |
---|---|---|
committer | tb <> | 2024-11-24 10:13:16 +0000 |
commit | 4c908616aa50e22645747c285720f6f2addd285c (patch) | |
tree | 6608b0422a07e27678d36227594c61815b7c60c1 /src | |
parent | d0bd014cdc526e4c2c4d4a2c7cc7cc089664a114 (diff) | |
download | openbsd-4c908616aa50e22645747c285720f6f2addd285c.tar.gz openbsd-4c908616aa50e22645747c285720f6f2addd285c.tar.bz2 openbsd-4c908616aa50e22645747c285720f6f2addd285c.zip |
Disable regression tests for small builtin curves
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/ec/ec_asn1_test.c | 8 | ||||
-rw-r--r-- | src/regress/lib/libcrypto/ecdh/ecc_cdh.c | 4 | ||||
-rw-r--r-- | src/regress/lib/libcrypto/ecdh/ecdhtest.c | 4 | ||||
-rw-r--r-- | src/regress/lib/libcrypto/wycheproof/wycheproof.go | 18 |
4 files changed, 29 insertions, 5 deletions
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 @@ | |||
1 | /* $OpenBSD: ec_asn1_test.c,v 1.29 2024/11/08 12:35:26 tb Exp $ */ | 1 | /* $OpenBSD: ec_asn1_test.c,v 1.30 2024/11/24 10:13:16 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2017, 2021 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2017, 2021 Joel Sing <jsing@openbsd.org> |
4 | * Copyright (c) 2024 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2024 Theo Buehler <tb@openbsd.org> |
@@ -1035,6 +1035,7 @@ static const struct ec_private_key { | |||
1035 | int oct_len; | 1035 | int oct_len; |
1036 | uint8_t oct[256]; | 1036 | uint8_t oct[256]; |
1037 | } ec_private_keys[] = { | 1037 | } ec_private_keys[] = { |
1038 | #ifdef ENABLE_SMALL_CURVES | ||
1038 | { | 1039 | { |
1039 | .name = "secp112r1", | 1040 | .name = "secp112r1", |
1040 | .der_len = 64, | 1041 | .der_len = 64, |
@@ -1272,6 +1273,7 @@ static const struct ec_private_key { | |||
1272 | 0xdc, | 1273 | 0xdc, |
1273 | }, | 1274 | }, |
1274 | }, | 1275 | }, |
1276 | #endif /* ENABLE_SMALL_CURVES */ | ||
1275 | { | 1277 | { |
1276 | .name = "secp224k1", | 1278 | .name = "secp224k1", |
1277 | .der_len = 107, | 1279 | .der_len = 107, |
@@ -1519,6 +1521,7 @@ static const struct ec_private_key { | |||
1519 | 0x9c, 0x6b, 0xce, 0xc4, 0x8e, | 1521 | 0x9c, 0x6b, 0xce, 0xc4, 0x8e, |
1520 | }, | 1522 | }, |
1521 | }, | 1523 | }, |
1524 | #ifdef ENABLE_SMALL_CURVES | ||
1522 | { | 1525 | { |
1523 | .name = "prime192v1", | 1526 | .name = "prime192v1", |
1524 | .der_len = 97, | 1527 | .der_len = 97, |
@@ -1627,6 +1630,7 @@ static const struct ec_private_key { | |||
1627 | 0xd3, | 1630 | 0xd3, |
1628 | }, | 1631 | }, |
1629 | }, | 1632 | }, |
1633 | #endif /* ENABLE_SMALL_CURVES */ | ||
1630 | { | 1634 | { |
1631 | .name = "prime239v1", | 1635 | .name = "prime239v1", |
1632 | .der_len = 115, | 1636 | .der_len = 115, |
@@ -1790,6 +1794,7 @@ static const struct ec_private_key { | |||
1790 | 0xe3, | 1794 | 0xe3, |
1791 | }, | 1795 | }, |
1792 | }, | 1796 | }, |
1797 | #ifdef ENABLE_SMALL_CURVES | ||
1793 | { | 1798 | { |
1794 | .name = "wap-wsg-idm-ecid-wtls6", | 1799 | .name = "wap-wsg-idm-ecid-wtls6", |
1795 | .der_len = 64, | 1800 | .der_len = 64, |
@@ -2080,6 +2085,7 @@ static const struct ec_private_key { | |||
2080 | 0xc7, | 2085 | 0xc7, |
2081 | }, | 2086 | }, |
2082 | }, | 2087 | }, |
2088 | #endif /* ENABLE_SMALL_CURVES */ | ||
2083 | { | 2089 | { |
2084 | .name = "brainpoolP224r1", | 2090 | .name = "brainpoolP224r1", |
2085 | .der_len = 110, | 2091 | .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 @@ | |||
1 | /* $OpenBSD: ecc_cdh.c,v 1.2 2023/07/16 08:25:41 tb Exp $ */ | 1 | /* $OpenBSD: ecc_cdh.c,v 1.3 2024/11/24 10:13:16 tb Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2023 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2023 Theo Buehler <tb@openbsd.org> |
@@ -40,6 +40,7 @@ static const struct ecc_cdh_test { | |||
40 | const char *pub_y; | 40 | const char *pub_y; |
41 | const char *want; | 41 | const char *want; |
42 | } ecc_cdh_tests[] = { | 42 | } ecc_cdh_tests[] = { |
43 | #ifdef ENABLE_SMALL_CURVES | ||
43 | { | 44 | { |
44 | .nid = NID_X9_62_prime192v1, | 45 | .nid = NID_X9_62_prime192v1, |
45 | .peer_x = "42ea6dd9969dd2a61fea1aac7f8e98edcc896c6e55857cc0", | 46 | .peer_x = "42ea6dd9969dd2a61fea1aac7f8e98edcc896c6e55857cc0", |
@@ -265,6 +266,7 @@ static const struct ecc_cdh_test { | |||
265 | .pub_y = "58ea42edbeeafca9ff44cfd7f29abd2cbde7626d79e422c9", | 266 | .pub_y = "58ea42edbeeafca9ff44cfd7f29abd2cbde7626d79e422c9", |
266 | .want = "72e88f3ea67d46d46dbf83926e7e2a6b85b54536741e6d2c", | 267 | .want = "72e88f3ea67d46d46dbf83926e7e2a6b85b54536741e6d2c", |
267 | }, | 268 | }, |
269 | #endif /* ENABLE_SMALL_CURVES */ | ||
268 | 270 | ||
269 | { | 271 | { |
270 | .nid = NID_secp224r1, | 272 | .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 @@ | |||
1 | /* $OpenBSD: ecdhtest.c,v 1.20 2023/07/16 07:34:07 tb Exp $ */ | 1 | /* $OpenBSD: ecdhtest.c,v 1.21 2024/11/24 10:13:16 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
4 | * | 4 | * |
@@ -174,12 +174,14 @@ static const struct ecdh_kat_test { | |||
174 | const char *want; | 174 | const char *want; |
175 | } ecdh_kat_tests[] = { | 175 | } ecdh_kat_tests[] = { |
176 | /* Keys and shared secrets from RFC 5114 */ | 176 | /* Keys and shared secrets from RFC 5114 */ |
177 | #ifdef ENABLE_SMALL_CURVES | ||
177 | { | 178 | { |
178 | .nid = NID_X9_62_prime192v1, | 179 | .nid = NID_X9_62_prime192v1, |
179 | .keya = "323fa3169d8e9c6593f59476bc142000ab5be0e249c43426", | 180 | .keya = "323fa3169d8e9c6593f59476bc142000ab5be0e249c43426", |
180 | .keyb = "631f95bb4a67632c9c476eee9ab695ab240a0499307fcf62", | 181 | .keyb = "631f95bb4a67632c9c476eee9ab695ab240a0499307fcf62", |
181 | .want = "ad420182633f8526bfe954acda376f05e5ff4f837f54febe", | 182 | .want = "ad420182633f8526bfe954acda376f05e5ff4f837f54febe", |
182 | }, | 183 | }, |
184 | #endif | ||
183 | { | 185 | { |
184 | .nid = NID_secp224r1, | 186 | .nid = NID_secp224r1, |
185 | .keya = "b558eb6c288da707bbb4f8fbae2ab9e9cb62e3bc5c7573e2" | 187 | .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 @@ | |||
1 | /* $OpenBSD: wycheproof.go,v 1.160 2024/05/22 14:03:24 tb Exp $ */ | 1 | /* $OpenBSD: wycheproof.go,v 1.161 2024/11/24 10:13:16 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018,2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2018,2023 Joel Sing <jsing@openbsd.org> |
4 | * Copyright (c) 2018,2019,2022-2024 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2018,2019,2022-2024 Theo Buehler <tb@openbsd.org> |
@@ -641,6 +641,14 @@ func nidFromString(ns string) (int, error) { | |||
641 | return -1, fmt.Errorf("unknown NID %q", ns) | 641 | return -1, fmt.Errorf("unknown NID %q", ns) |
642 | } | 642 | } |
643 | 643 | ||
644 | func skipSmallCurve(nid int) bool { | ||
645 | switch C.int(nid) { | ||
646 | case C.NID_secp160k1, C.NID_secp160r1, C.NID_secp160r2, C.NID_secp192k1, C.NID_X9_62_prime192v1: | ||
647 | return true | ||
648 | } | ||
649 | return false | ||
650 | } | ||
651 | |||
644 | var evpMds = map[string]*C.EVP_MD{ | 652 | var evpMds = map[string]*C.EVP_MD{ |
645 | "SHA-1": C.EVP_sha1(), | 653 | "SHA-1": C.EVP_sha1(), |
646 | "SHA-224": C.EVP_sha224(), | 654 | "SHA-224": C.EVP_sha224(), |
@@ -1637,6 +1645,9 @@ func (wtg *wycheproofTestGroupECDH) run(algorithm string, variant testVariant) b | |||
1637 | if err != nil { | 1645 | if err != nil { |
1638 | log.Fatalf("Failed to get nid for curve: %v", err) | 1646 | log.Fatalf("Failed to get nid for curve: %v", err) |
1639 | } | 1647 | } |
1648 | if skipSmallCurve(nid) { | ||
1649 | return true | ||
1650 | } | ||
1640 | 1651 | ||
1641 | success := true | 1652 | success := true |
1642 | for _, wt := range wtg.Tests { | 1653 | for _, wt := range wtg.Tests { |
@@ -1786,6 +1797,9 @@ func (wtg *wycheproofTestGroupECDSA) run(algorithm string, variant testVariant) | |||
1786 | if err != nil { | 1797 | if err != nil { |
1787 | log.Fatalf("Failed to get nid for curve: %v", err) | 1798 | log.Fatalf("Failed to get nid for curve: %v", err) |
1788 | } | 1799 | } |
1800 | if skipSmallCurve(nid) { | ||
1801 | return true | ||
1802 | } | ||
1789 | ecKey := C.EC_KEY_new_by_curve_name(C.int(nid)) | 1803 | ecKey := C.EC_KEY_new_by_curve_name(C.int(nid)) |
1790 | if ecKey == nil { | 1804 | if ecKey == nil { |
1791 | log.Fatal("EC_KEY_new_by_curve_name failed") | 1805 | log.Fatal("EC_KEY_new_by_curve_name failed") |
@@ -2750,7 +2764,7 @@ func main() { | |||
2750 | 2764 | ||
2751 | testc = newTestCoordinator() | 2765 | testc = newTestCoordinator() |
2752 | 2766 | ||
2753 | skipNormal := regexp.MustCompile(`_(ecpoint|p1363|sect\d{3}[rk]1)_`) | 2767 | skipNormal := regexp.MustCompile(`_(ecpoint|p1363|sect\d{3}[rk]1|secp(160|192))_`) |
2754 | 2768 | ||
2755 | for _, test := range tests { | 2769 | for _, test := range tests { |
2756 | tvs, err := filepath.Glob(filepath.Join(testVectorPath, test.pattern)) | 2770 | tvs, err := filepath.Glob(filepath.Join(testVectorPath, test.pattern)) |