Subject: | Block-Size Argument not Documented in POD |
Hi Gisle,
The "new", "hmac", and "hmac_hex" functions take an optional block_size argument as the final parameter. However, this argument isn't documented in the POD for Digest::HMAC; rather, it's necessary to study the module code to discover it.
The following program illustrates why the block_size parameter is critical when using stronger hash algorithms such as SHA-384/512:
###################################################
use strict;
use warnings;
use Digest::SHA qw(sha384 hmac_sha384_hex);
use Digest::HMAC qw(hmac_hex);
my $key = "she who must be obeyed";
my $data = "go to the window";
my ($r1, $r2);
$r1 = hmac_sha384_hex($data, $key);
$r2 = hmac_hex($data, $key, \&sha384);
print "$r1\n$r2 ... ", $r1 eq $r2 ? "ok" : "not ok", "\n";
$r1 = hmac_sha384_hex($data, $key);
$r2 = hmac_hex($data, $key, \&sha384, 128);
print "$r1\n$r2 ... ", $r1 eq $r2 ? "ok" : "not ok", "\n";
###################################################
Perhaps the Digest module could introduce something like a "blocksize" method so that all conforming modules could be written to automatically supply this information. Just a thought.
Regards, Mark