]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/recipes/20-test_rand_config.t
2 # Copyright 2019-2020 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
::Utils
;
16 setup
("test_rand_config");
19 { drbg
=> 'HASH-DRBG',
20 digest
=> 'SHA2-512/256',
22 expected
=> ["HASH-DRBG", "digest: 'SHA2-512/256'"],
23 desc
=> 'HASH-DRBG SHA2-512/256' },
25 { drbg
=> 'HASH-DRBG',
28 expected
=> ["HASH-DRBG", "digest: 'SHA3-512'"],
29 desc
=> 'HASH-DRBG SHA3/512' },
31 { drbg
=> 'HMAC-DRBG',
34 expected
=> ["HMAC-DRBG", "mac: HMAC", "digest: 'SHA3-256'"],
35 desc
=> 'HMAC-DRBG SHA3/256' },
37 { cipher
=> 'AES-128-CTR',
38 expected
=> ["CTR-DRBG", "cipher: 'AES-128-CTR'"],
39 desc
=> 'CTR-DRBG AES-128 no DRBG' },
40 { expected
=> ["CTR-DRBG", "cipher: 'AES-256-CTR'"],
41 desc
=> 'CTR-DRBG AES-256 defaults' },
46 cipher
=> 'ARIA-128-CTR',
48 expected
=> ["CTR-DRBG", "cipher: 'ARIA-128-CTR'"],
49 desc
=> 'CTR-DRBG ARIA-128' },
52 cipher
=> 'ARIA-128-CTR',
54 expected
=> ["CTR-DRBG", "cipher: 'ARIA-128-CTR'"],
55 desc
=> 'CTR-DRBG ARIA-256' },
58 push @rand_tests, @aria_tests unless disabled
("aria");
60 plan tests
=> scalar @rand_tests;
62 my $contents =<<'CONFIGEND';
63 openssl_conf = openssl_init
66 random = random_section
71 foreach (@rand_tests) {
72 my $tmpfile = 'rand_config.cfg';
73 open(my $cfg, '>', $tmpfile) or die "Could not open file";
76 print $cfg "random = $_->{drbg}\n";
79 print $cfg "cipher = $_->{cipher}\n";
82 print $cfg "digest = $_->{digest}\n"
86 $ENV{OPENSSL_CONF
} = $tmpfile;
88 ok
(comparelines
($_->{expected
}), $_->{desc
});
91 # Check that the stdout output contains the expected values.
93 my @lines = run
(app
(["openssl", "list", "--random-instances"]),
97 if ( !grep( /$_/, @lines ) ) {
98 print "Cannot find: $_\n";