]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
[test][pkey_check] Add more invalid SM2 key tests
authorNicola Tuveri <nic.tuv@gmail.com>
Tue, 10 Nov 2020 10:28:52 +0000 (12:28 +0200)
committerNicola Tuveri <nic.tuv@gmail.com>
Fri, 8 Jan 2021 21:59:02 +0000 (23:59 +0200)
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/13359)

test/recipes/91-test_pkey_check.t
test/recipes/91-test_pkey_check_data/sm2_bad_0.pem [new file with mode: 0644]
test/recipes/91-test_pkey_check_data/sm2_bad_1.pem [new file with mode: 0644]
test/recipes/91-test_pkey_check_data/sm2_bad_neg1.pem [moved from test/recipes/91-test_pkey_check_data/sm2_bad_max.pem with 100% similarity]

index c85ab5c3773c923c2953a95372ba4f5df9fd54a0..4dce838d1f11b4f10e489f31e8a8c23cf28ca9be 100644 (file)
@@ -46,7 +46,9 @@ push(@tests, (
 
 push(@tests, (
     # For SM2 keys the range for the secret scalar `k` is `1 <= k < n-1`
-    "sm2_bad_max.pem", # `k` set to `n-1` (invalid, because SM2 range)
+    "sm2_bad_neg1.pem", # `k` set to `n-1` (invalid, because SM2 range)
+    "sm2_bad_0.pem", # `k` set to `n` (equivalent to `0 mod n`, invalid)
+    "sm2_bad_1.pem", # `k` set to `n+1` (equivalent to `1 mod n`, invalid)
     )) unless disabled("sm2");
 
 plan skip_all => "No tests within the current enabled feature set"
diff --git a/test/recipes/91-test_pkey_check_data/sm2_bad_0.pem b/test/recipes/91-test_pkey_check_data/sm2_bad_0.pem
new file mode 100644 (file)
index 0000000..5ad2bd1
--- /dev/null
@@ -0,0 +1,4 @@
+-----BEGIN PRIVATE KEY-----
+MEECAQAwEwYHKoZIzj0CAQYIKoEcz1UBgi0EJzAlAgEBBCD////+////////////
+////cgPfayHGBStTu/QJOdVBIw==
+-----END PRIVATE KEY-----
diff --git a/test/recipes/91-test_pkey_check_data/sm2_bad_1.pem b/test/recipes/91-test_pkey_check_data/sm2_bad_1.pem
new file mode 100644 (file)
index 0000000..d094d4d
--- /dev/null
@@ -0,0 +1,4 @@
+-----BEGIN PRIVATE KEY-----
+MEECAQAwEwYHKoZIzj0CAQYIKoEcz1UBgi0EJzAlAgEBBCD////+////////////
+////cgPfayHGBStTu/QJOdVBJA==
+-----END PRIVATE KEY-----