aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDaiki Ueno <dueno@redhat.com>2020-10-26 13:23:14 +0100
committerTomas Mraz <tmraz@fedoraproject.org>2020-12-02 16:46:46 +0100
commitc39f43534d4f359bdfee617f70f89b114c9f2cca (patch)
tree3049586263b57fce903d7b9019ed49c2632303f0 /test
parentb03da688a223c18b5a10b5a66abe229bbb590133 (diff)
downloadopenssl-c39f43534d4f359bdfee617f70f89b114c9f2cca.tar.gz
openssl dgst: add option to specify output length for XOF
This adds the -xoflen option to control the output length of the XOF algorithms, such as SHAKE128 and SHAKE256. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/13245)
Diffstat (limited to 'test')
-rw-r--r--test/recipes/20-test_dgst.t18
1 files changed, 16 insertions, 2 deletions
diff --git a/test/recipes/20-test_dgst.t b/test/recipes/20-test_dgst.t
index 4c29877e62..0c19c029a0 100644
--- a/test/recipes/20-test_dgst.t
+++ b/test/recipes/20-test_dgst.t
@@ -17,7 +17,7 @@ use OpenSSL::Test::Utils;
setup("test_dgst");
-plan tests => 6;
+plan tests => 7;
sub tsignverify {
my $testtext = shift;
@@ -111,8 +111,22 @@ subtest "HMAC generation with `dgst` CLI" => sub {
my @hmacdata = run(app(['openssl', 'dgst', '-sha256', '-hmac', '123456',
$testdata, $testdata]), capture => 1);
chomp(@hmacdata);
- my $expected = qr/HMAC-SHA256\([^\)]*data.bin\)= 6f12484129c4a761747f13d8234a1ff0e074adb34e9e9bf3a155c391b97b9a7c/;
+ my $expected = qr/HMAC-SHA256\(\Q$testdata\E\)= 6f12484129c4a761747f13d8234a1ff0e074adb34e9e9bf3a155c391b97b9a7c/;
ok($hmacdata[0] =~ $expected, "HMAC: Check HMAC value is as expected ($hmacdata[0]) vs ($expected)");
ok($hmacdata[1] =~ $expected,
"HMAC: Check second HMAC value is consistent with the first ($hmacdata[1]) vs ($expected)");
};
+
+subtest "Custom length XOF digest generation with `dgst` CLI" => sub {
+ plan tests => 2;
+
+ my $testdata = srctop_file('test', 'data.bin');
+ #Digest the data twice to check consistency
+ my @xofdata = run(app(['openssl', 'dgst', '-shake128', '-xoflen', '64',
+ $testdata, $testdata]), capture => 1);
+ chomp(@xofdata);
+ my $expected = qr/SHAKE128\(\Q$testdata\E\)= bb565dac72640109e1c926ef441d3fa64ffd0b3e2bf8cd73d5182dfba19b6a8a2eab96d2df854b647b3795ef090582abe41ba4e0717dc4df40bc4e17d88e4677/;
+ ok($xofdata[0] =~ $expected, "XOF: Check digest value is as expected ($xofdata[0]) vs ($expected)");
+ ok($xofdata[1] =~ $expected,
+ "XOF: Check second digest value is consistent with the first ($xofdata[1]) vs ($expected)");
+};