summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2020-09-14 16:13:54 +0100
committerDmitry Belyavskiy <beldmit@gmail.com>2020-09-17 11:12:08 +0300
commit7fc6168b6f5d0f696b610a88004ef79ed0eaa2ba (patch)
treecbc0b890920eaac4b784b7e685e96c1bdb962ab1
parentd8025f4ac002f6de775a8c3c7936036d0722eed6 (diff)
Test HMAC output from the dgst CLI
We run two HMAC operations on the same file and confirm that both provide us with the expected values. Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> (Merged from https://github.com/openssl/openssl/pull/12850)
-rw-r--r--test/recipes/20-test_dgst.t16
1 files changed, 15 insertions, 1 deletions
diff --git a/test/recipes/20-test_dgst.t b/test/recipes/20-test_dgst.t
index 0b7ab2d5d1..9dcf6d31a2 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 => 5;
+plan tests => 6;
sub tsignverify {
my $testtext = shift;
@@ -102,3 +102,17 @@ SKIP: {
srctop_file("test","tested448pub.pem"));
};
}
+
+subtest "HMAC generation with `dgst` CLI" => sub {
+ plan tests => 2;
+
+ my $testdata = srctop_file('test', 'data.txt');
+ #HMAC the data twice to check consistency
+ my @hmacdata = run(app(['openssl', 'dgst', '-sha256', '-hmac', '123456',
+ $testdata, $testdata]), capture => 1);
+ chomp(@hmacdata);
+ my $expected = qr/HMAC-SHA256\([^\)]*data.txt\)= 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)");
+};