]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/recipes/91-test_pkey_check.t
2 # Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the Apache License 2.0 (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
14 use OpenSSL
::Test qw
/:DEFAULT data_file/;
15 use OpenSSL
::Test
::Utils
;
20 return run
(app
(['openssl', 'pkey', '-check', '-text',
26 my $str = "$f should fail validation";
31 ok
(!check_key
($f), $str);
33 fail
("Missing file $f");
37 setup
("test_pkey_check");
42 # For EC keys the range for the secret scalar `k` is `1 <= k <= n-1`
43 "ec_p256_bad_0.pem", # `k` set to `n` (equivalent to `0 mod n`, invalid)
44 "ec_p256_bad_1.pem", # `k` set to `n+1` (equivalent to `1 mod n`, invalid)
45 )) unless disabled
("ec");
48 # For SM2 keys the range for the secret scalar `k` is `1 <= k < n-1`
49 "sm2_bad_neg1.pem", # `k` set to `n-1` (invalid, because SM2 range)
50 "sm2_bad_0.pem", # `k` set to `n` (equivalent to `0 mod n`, invalid)
51 "sm2_bad_1.pem", # `k` set to `n+1` (equivalent to `1 mod n`, invalid)
52 )) unless disabled
("sm2");
54 plan skip_all
=> "No tests within the current enabled feature set"
57 plan tests
=> scalar(@tests);
59 foreach my $t (@tests) {