[perl] add SHA3 digest algorithms

This commit is contained in:
Michael Rash 2016-10-04 22:16:34 -04:00
parent f5509bcd0c
commit d287d14283
2 changed files with 18 additions and 2 deletions

View File

@ -31,6 +31,8 @@ our @DIGEST_TYPES = qw(
FKO_DIGEST_SHA256
FKO_DIGEST_SHA384
FKO_DIGEST_SHA512
FKO_DIGEST_SHA3_256
FKO_DIGEST_SHA3_512
);
# HMAC digest types tag list.
@ -43,6 +45,8 @@ our @HMAC_DIGEST_TYPES = qw(
FKO_HMAC_SHA256
FKO_HMAC_SHA384
FKO_HMAC_SHA512
FKO_HMAC_SHA3_256
FKO_HMAC_SHA3_512
);
# Encryption types tag list.
@ -233,6 +237,8 @@ use constant {
FKO_DIGEST_SHA256 => 3,
FKO_DIGEST_SHA384 => 4,
FKO_DIGEST_SHA512 => 5,
FKO_DIGEST_SHA3_256 => 6,
FKO_DIGEST_SHA3_512 => 7,
# HMAC digest types
FKO_HMAC_INVALID_DATA => -1,
@ -242,6 +248,8 @@ use constant {
FKO_HMAC_SHA256 => 3,
FKO_HMAC_SHA384 => 4,
FKO_HMAC_SHA512 => 5,
FKO_HMAC_SHA3_256 => 6,
FKO_HMAC_SHA3_512 => 7,
# Encryption types
FKO_ENCRYPTION_INVALID_DATA => -1,

View File

@ -10,7 +10,7 @@
#
use FKO;
use Test::More tests => 533;
use Test::More tests => 537;
# Test spa data support vars
#
@ -151,8 +151,16 @@ $err = $f1->digest_type(FKO::FKO_DIGEST_MD5);
ok($err == FKO::FKO_SUCCESS, 'f1 set digest to md5');
is($f1->digest_type(), FKO::FKO_DIGEST_MD5, 'verify set digest md5');
$err = $f1->digest_type(FKO::FKO_DIGEST_SHA3_256);
ok($err == FKO::FKO_SUCCESS, 'f1 set digest to sha3_256');
is($f1->digest_type(), FKO::FKO_DIGEST_SHA3_256, 'verify set digest sha3_256');
$err = $f1->hmac_type(FKO::FKO_HMAC_SHA3_512);
ok($err == FKO::FKO_SUCCESS, 'f1 set HMAC digest to sha3_512');
is($f1->hmac_type(), FKO::FKO_HMAC_SHA3_512, 'verify set HMAC digest sha3_512');
$err = $f1->hmac_type($tsd_hmac_digest_type);
ok($err == FKO::FKO_SUCCESS, 'f1 set set HMAC digest to sha512');
ok($err == FKO::FKO_SUCCESS, 'f1 set HMAC digest to sha512');
is($f1->hmac_type(), $tsd_hmac_digest_type, 'verify set HMAC digest sha512');
my $tts = $f1->timestamp();