1package Digest::SHA;
2
3require 5.003000;
4
5use strict;
6use warnings;
7use vars qw($VERSION @ISA @EXPORT_OK $errmsg);
8use Fcntl qw(O_RDONLY O_RDWR);
9use integer;
10
11$VERSION = '6.02';
12
13require Exporter;
14@ISA = qw(Exporter);
15@EXPORT_OK = qw(
16	$errmsg
17	hmac_sha1	hmac_sha1_base64	hmac_sha1_hex
18	hmac_sha224	hmac_sha224_base64	hmac_sha224_hex
19	hmac_sha256	hmac_sha256_base64	hmac_sha256_hex
20	hmac_sha384	hmac_sha384_base64	hmac_sha384_hex
21	hmac_sha512	hmac_sha512_base64	hmac_sha512_hex
22	hmac_sha512224	hmac_sha512224_base64	hmac_sha512224_hex
23	hmac_sha512256	hmac_sha512256_base64	hmac_sha512256_hex
24	sha1		sha1_base64		sha1_hex
25	sha224		sha224_base64		sha224_hex
26	sha256		sha256_base64		sha256_hex
27	sha384		sha384_base64		sha384_hex
28	sha512		sha512_base64		sha512_hex
29	sha512224	sha512224_base64	sha512224_hex
30	sha512256	sha512256_base64	sha512256_hex);
31
32# Inherit from Digest::base if possible
33
34eval {
35	require Digest::base;
36	push(@ISA, 'Digest::base');
37};
38
39# The following routines aren't time-critical, so they can be left in Perl
40
41sub new {
42	my($class, $alg) = @_;
43	$alg =~ s/\D+//g if defined $alg;
44	if (ref($class)) {	# instance method
45		if (!defined($alg) || ($alg == $class->algorithm)) {
46			sharewind($class);
47			return($class);
48		}
49		return shainit($class, $alg) ? $class : undef;
50	}
51	$alg = 1 unless defined $alg;
52	return $class->newSHA($alg);
53}
54
55BEGIN { *reset = \&new }
56
57sub add_bits {
58	my($self, $data, $nbits) = @_;
59	unless (defined $nbits) {
60		$nbits = length($data);
61		$data = pack("B*", $data);
62	}
63	$nbits = length($data) * 8 if $nbits > length($data) * 8;
64	shawrite($data, $nbits, $self);
65	return($self);
66}
67
68sub _bail {
69	my $msg = shift;
70
71	$errmsg = $!;
72	$msg .= ": $!";
73	require Carp;
74	Carp::croak($msg);
75}
76
77{
78	my $_can_T_filehandle;
79
80	sub _istext {
81		local *FH = shift;
82		my $file = shift;
83
84		if (! defined $_can_T_filehandle) {
85			local $^W = 0;
86			my $istext = eval { -T FH };
87			$_can_T_filehandle = $@ ? 0 : 1;
88			return $_can_T_filehandle ? $istext : -T $file;
89		}
90		return $_can_T_filehandle ? -T FH : -T $file;
91	}
92}
93
94sub _addfile {
95	my ($self, $handle) = @_;
96
97	my $n;
98	my $buf = "";
99
100	while (($n = read($handle, $buf, 4096))) {
101		$self->add($buf);
102	}
103	_bail("Read failed") unless defined $n;
104
105	$self;
106}
107
108sub addfile {
109	my ($self, $file, $mode) = @_;
110
111	return(_addfile($self, $file)) unless ref(\$file) eq 'SCALAR';
112
113	$mode = defined($mode) ? $mode : "";
114	my ($binary, $UNIVERSAL, $BITS) =
115		map { $_ eq $mode } ("b", "U", "0");
116
117		## Always interpret "-" to mean STDIN; otherwise use
118		##	sysopen to handle full range of POSIX file names.
119		## If $file is a directory, force an EISDIR error
120		##	by attempting to open with mode O_RDWR
121
122	local *FH;
123	$file eq '-' and open(FH, '< -')
124		or sysopen(FH, $file, -d $file ? O_RDWR : O_RDONLY)
125			or _bail('Open failed');
126
127	if ($BITS) {
128		my ($n, $buf) = (0, "");
129		while (($n = read(FH, $buf, 4096))) {
130			$buf =~ tr/01//cd;
131			$self->add_bits($buf);
132		}
133		_bail("Read failed") unless defined $n;
134		close(FH);
135		return($self);
136	}
137
138	binmode(FH) if $binary || $UNIVERSAL;
139	if ($UNIVERSAL && _istext(*FH, $file)) {
140		$self->_addfileuniv(*FH);
141	}
142	else { $self->_addfilebin(*FH) }
143	close(FH);
144
145	$self;
146}
147
148sub getstate {
149	my $self = shift;
150
151	my $alg = $self->algorithm or return;
152	my $state = $self->_getstate or return;
153	my $nD = $alg <= 256 ?  8 :  16;
154	my $nH = $alg <= 256 ? 32 :  64;
155	my $nB = $alg <= 256 ? 64 : 128;
156	my($H, $block, $blockcnt, $lenhh, $lenhl, $lenlh, $lenll) =
157		$state =~ /^(.{$nH})(.{$nB})(.{4})(.{4})(.{4})(.{4})(.{4})$/s;
158	for ($alg, $H, $block, $blockcnt, $lenhh, $lenhl, $lenlh, $lenll) {
159		return unless defined $_;
160	}
161
162	my @s = ();
163	push(@s, "alg:" . $alg);
164	push(@s, "H:" . join(":", unpack("H*", $H) =~ /.{$nD}/g));
165	push(@s, "block:" . join(":", unpack("H*", $block) =~ /.{2}/g));
166	push(@s, "blockcnt:" . unpack("N", $blockcnt));
167	push(@s, "lenhh:" . unpack("N", $lenhh));
168	push(@s, "lenhl:" . unpack("N", $lenhl));
169	push(@s, "lenlh:" . unpack("N", $lenlh));
170	push(@s, "lenll:" . unpack("N", $lenll));
171	join("\n", @s) . "\n";
172}
173
174sub putstate {
175	my($class, $state) = @_;
176
177	my %s = ();
178	for (split(/\n/, $state)) {
179		s/^\s+//;
180		s/\s+$//;
181		next if (/^(#|$)/);
182		my @f = split(/[:\s]+/);
183		my $tag = shift(@f);
184		$s{$tag} = join('', @f);
185	}
186
187	# H and block may contain arbitrary values, but check everything else
188	grep { $_ == $s{'alg'} } (1,224,256,384,512,512224,512256) or return;
189	length($s{'H'}) == ($s{'alg'} <= 256 ? 64 : 128) or return;
190	length($s{'block'}) == ($s{'alg'} <= 256 ? 128 : 256) or return;
191	{
192		no integer;
193		for (qw(blockcnt lenhh lenhl lenlh lenll)) {
194			0 <= $s{$_} or return;
195			$s{$_} <= 4294967295 or return;
196		}
197		$s{'blockcnt'} < ($s{'alg'} <= 256 ? 512 : 1024) or return;
198	}
199
200	my $packed_state = (
201		pack("H*", $s{'H'}) .
202		pack("H*", $s{'block'}) .
203		pack("N",  $s{'blockcnt'}) .
204		pack("N",  $s{'lenhh'}) .
205		pack("N",  $s{'lenhl'}) .
206		pack("N",  $s{'lenlh'}) .
207		pack("N",  $s{'lenll'})
208	);
209
210	return $class->new($s{'alg'})->_putstate($packed_state);
211}
212
213sub dump {
214	my $self = shift;
215	my $file = shift;
216
217	my $state = $self->getstate or return;
218	$file = "-" if (!defined($file) || $file eq "");
219
220	local *FH;
221	open(FH, "> $file") or return;
222	print FH $state;
223	close(FH);
224
225	return($self);
226}
227
228sub load {
229	my $class = shift;
230	my $file = shift;
231
232	$file = "-" if (!defined($file) || $file eq "");
233
234	local *FH;
235	open(FH, "< $file") or return;
236	my $str = join('', <FH>);
237	close(FH);
238
239	$class->putstate($str);
240}
241
242eval {
243	require XSLoader;
244	XSLoader::load('Digest::SHA', $VERSION);
245	1;
246} or do {
247	require DynaLoader;
248	push @ISA, 'DynaLoader';
249	Digest::SHA->bootstrap($VERSION);
250};
251
2521;
253__END__
254
255=head1 NAME
256
257Digest::SHA - Perl extension for SHA-1/224/256/384/512
258
259=head1 SYNOPSIS
260
261In programs:
262
263		# Functional interface
264
265	use Digest::SHA qw(sha1 sha1_hex sha1_base64 ...);
266
267	$digest = sha1($data);
268	$digest = sha1_hex($data);
269	$digest = sha1_base64($data);
270
271	$digest = sha256($data);
272	$digest = sha384_hex($data);
273	$digest = sha512_base64($data);
274
275		# Object-oriented
276
277	use Digest::SHA;
278
279	$sha = Digest::SHA->new($alg);
280
281	$sha->add($data);		# feed data into stream
282
283	$sha->addfile(*F);
284	$sha->addfile($filename);
285
286	$sha->add_bits($bits);
287	$sha->add_bits($data, $nbits);
288
289	$sha_copy = $sha->clone;	# make copy of digest object
290	$state = $sha->getstate;	# save current state to string
291	$sha->putstate($state);		# restore previous $state
292
293	$digest = $sha->digest;		# compute digest
294	$digest = $sha->hexdigest;
295	$digest = $sha->b64digest;
296
297From the command line:
298
299	$ shasum files
300
301	$ shasum --help
302
303=head1 SYNOPSIS (HMAC-SHA)
304
305		# Functional interface only
306
307	use Digest::SHA qw(hmac_sha1 hmac_sha1_hex ...);
308
309	$digest = hmac_sha1($data, $key);
310	$digest = hmac_sha224_hex($data, $key);
311	$digest = hmac_sha256_base64($data, $key);
312
313=head1 ABSTRACT
314
315Digest::SHA is a complete implementation of the NIST Secure Hash Standard.
316It gives Perl programmers a convenient way to calculate SHA-1, SHA-224,
317SHA-256, SHA-384, SHA-512, SHA-512/224, and SHA-512/256 message digests.
318The module can handle all types of input, including partial-byte data.
319
320=head1 DESCRIPTION
321
322Digest::SHA is written in C for speed.  If your platform lacks a
323C compiler, you can install the functionally equivalent (but much
324slower) L<Digest::SHA::PurePerl> module.
325
326The programming interface is easy to use: it's the same one found
327in CPAN's L<Digest> module.  So, if your applications currently
328use L<Digest::MD5> and you'd prefer the stronger security of SHA,
329it's a simple matter to convert them.
330
331The interface provides two ways to calculate digests:  all-at-once,
332or in stages.  To illustrate, the following short program computes
333the SHA-256 digest of "hello world" using each approach:
334
335	use Digest::SHA qw(sha256_hex);
336
337	$data = "hello world";
338	@frags = split(//, $data);
339
340	# all-at-once (Functional style)
341	$digest1 = sha256_hex($data);
342
343	# in-stages (OOP style)
344	$state = Digest::SHA->new(256);
345	for (@frags) { $state->add($_) }
346	$digest2 = $state->hexdigest;
347
348	print $digest1 eq $digest2 ?
349		"whew!\n" : "oops!\n";
350
351To calculate the digest of an n-bit message where I<n> is not a
352multiple of 8, use the I<add_bits()> method.  For example, consider
353the 446-bit message consisting of the bit-string "110" repeated
354148 times, followed by "11".  Here's how to display its SHA-1
355digest:
356
357	use Digest::SHA;
358	$bits = "110" x 148 . "11";
359	$sha = Digest::SHA->new(1)->add_bits($bits);
360	print $sha->hexdigest, "\n";
361
362Note that for larger bit-strings, it's more efficient to use the
363two-argument version I<add_bits($data, $nbits)>, where I<$data> is
364in the customary packed binary format used for Perl strings.
365
366The module also lets you save intermediate SHA states to a string.  The
367I<getstate()> method generates portable, human-readable text describing
368the current state of computation.  You can subsequently restore that
369state with I<putstate()> to resume where the calculation left off.
370
371To see what a state description looks like, just run the following:
372
373	use Digest::SHA;
374	print Digest::SHA->new->add("Shaw" x 1962)->getstate;
375
376As an added convenience, the Digest::SHA module offers routines to
377calculate keyed hashes using the HMAC-SHA-1/224/256/384/512
378algorithms.  These services exist in functional form only, and
379mimic the style and behavior of the I<sha()>, I<sha_hex()>, and
380I<sha_base64()> functions.
381
382	# Test vector from draft-ietf-ipsec-ciph-sha-256-01.txt
383
384	use Digest::SHA qw(hmac_sha256_hex);
385	print hmac_sha256_hex("Hi There", chr(0x0b) x 32), "\n";
386
387=head1 UNICODE AND SIDE EFFECTS
388
389Perl supports Unicode strings as of version 5.6.  Such strings may
390contain wide characters, namely, characters whose ordinal values are
391greater than 255.  This can cause problems for digest algorithms such
392as SHA that are specified to operate on sequences of bytes.
393
394The rule by which Digest::SHA handles a Unicode string is easy
395to state, but potentially confusing to grasp: the string is interpreted
396as a sequence of byte values, where each byte value is equal to the
397ordinal value (viz. code point) of its corresponding Unicode character.
398That way, the Unicode string 'abc' has exactly the same digest value as
399the ordinary string 'abc'.
400
401Since a wide character does not fit into a byte, the Digest::SHA
402routines croak if they encounter one.  Whereas if a Unicode string
403contains no wide characters, the module accepts it quite happily.
404The following code illustrates the two cases:
405
406	$str1 = pack('U*', (0..255));
407	print sha1_hex($str1);		# ok
408
409	$str2 = pack('U*', (0..256));
410	print sha1_hex($str2);		# croaks
411
412Be aware that the digest routines silently convert UTF-8 input into its
413equivalent byte sequence in the native encoding (cf. utf8::downgrade).
414This side effect influences only the way Perl stores the data internally,
415but otherwise leaves the actual value of the data intact.
416
417=head1 NIST STATEMENT ON SHA-1
418
419NIST acknowledges that the work of Prof. Xiaoyun Wang constitutes a
420practical collision attack on SHA-1.  Therefore, NIST encourages the
421rapid adoption of the SHA-2 hash functions (e.g. SHA-256) for applications
422requiring strong collision resistance, such as digital signatures.
423
424ref. L<http://csrc.nist.gov/groups/ST/hash/statement.html>
425
426=head1 PADDING OF BASE64 DIGESTS
427
428By convention, CPAN Digest modules do B<not> pad their Base64 output.
429Problems can occur when feeding such digests to other software that
430expects properly padded Base64 encodings.
431
432For the time being, any necessary padding must be done by the user.
433Fortunately, this is a simple operation: if the length of a Base64-encoded
434digest isn't a multiple of 4, simply append "=" characters to the end
435of the digest until it is:
436
437	while (length($b64_digest) % 4) {
438		$b64_digest .= '=';
439	}
440
441To illustrate, I<sha256_base64("abc")> is computed to be
442
443	ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0
444
445which has a length of 43.  So, the properly padded version is
446
447	ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0=
448
449=head1 EXPORT
450
451None by default.
452
453=head1 EXPORTABLE FUNCTIONS
454
455Provided your C compiler supports a 64-bit type (e.g. the I<long
456long> of C99, or I<__int64> used by Microsoft C/C++), all of these
457functions will be available for use.  Otherwise, you won't be able
458to perform the SHA-384 and SHA-512 transforms, both of which require
45964-bit operations.
460
461I<Functional style>
462
463=over 4
464
465=item B<sha1($data, ...)>
466
467=item B<sha224($data, ...)>
468
469=item B<sha256($data, ...)>
470
471=item B<sha384($data, ...)>
472
473=item B<sha512($data, ...)>
474
475=item B<sha512224($data, ...)>
476
477=item B<sha512256($data, ...)>
478
479Logically joins the arguments into a single string, and returns
480its SHA-1/224/256/384/512 digest encoded as a binary string.
481
482=item B<sha1_hex($data, ...)>
483
484=item B<sha224_hex($data, ...)>
485
486=item B<sha256_hex($data, ...)>
487
488=item B<sha384_hex($data, ...)>
489
490=item B<sha512_hex($data, ...)>
491
492=item B<sha512224_hex($data, ...)>
493
494=item B<sha512256_hex($data, ...)>
495
496Logically joins the arguments into a single string, and returns
497its SHA-1/224/256/384/512 digest encoded as a hexadecimal string.
498
499=item B<sha1_base64($data, ...)>
500
501=item B<sha224_base64($data, ...)>
502
503=item B<sha256_base64($data, ...)>
504
505=item B<sha384_base64($data, ...)>
506
507=item B<sha512_base64($data, ...)>
508
509=item B<sha512224_base64($data, ...)>
510
511=item B<sha512256_base64($data, ...)>
512
513Logically joins the arguments into a single string, and returns
514its SHA-1/224/256/384/512 digest encoded as a Base64 string.
515
516It's important to note that the resulting string does B<not> contain
517the padding characters typical of Base64 encodings.  This omission is
518deliberate, and is done to maintain compatibility with the family of
519CPAN Digest modules.  See L</"PADDING OF BASE64 DIGESTS"> for details.
520
521=back
522
523I<OOP style>
524
525=over 4
526
527=item B<new($alg)>
528
529Returns a new Digest::SHA object.  Allowed values for I<$alg> are 1,
530224, 256, 384, 512, 512224, or 512256.  It's also possible to use
531common string representations of the algorithm (e.g. "sha256",
532"SHA-384").  If the argument is missing, SHA-1 will be used by
533default.
534
535Invoking I<new> as an instance method will reset the object to the
536initial state associated with I<$alg>.  If the argument is missing,
537the object will continue using the same algorithm that was selected
538at creation.
539
540=item B<reset($alg)>
541
542This method has exactly the same effect as I<new($alg)>.  In fact,
543I<reset> is just an alias for I<new>.
544
545=item B<hashsize>
546
547Returns the number of digest bits for this object.  The values are
548160, 224, 256, 384, 512, 224, and 256 for SHA-1, SHA-224, SHA-256,
549SHA-384, SHA-512, SHA-512/224 and SHA-512/256, respectively.
550
551=item B<algorithm>
552
553Returns the digest algorithm for this object.  The values are 1,
554224, 256, 384, 512, 512224, and 512256 for SHA-1, SHA-224, SHA-256,
555SHA-384, SHA-512, SHA-512/224, and SHA-512/256, respectively.
556
557=item B<clone>
558
559Returns a duplicate copy of the object.
560
561=item B<add($data, ...)>
562
563Logically joins the arguments into a single string, and uses it to
564update the current digest state.  In other words, the following
565statements have the same effect:
566
567	$sha->add("a"); $sha->add("b"); $sha->add("c");
568	$sha->add("a")->add("b")->add("c");
569	$sha->add("a", "b", "c");
570	$sha->add("abc");
571
572The return value is the updated object itself.
573
574=item B<add_bits($data, $nbits)>
575
576=item B<add_bits($bits)>
577
578Updates the current digest state by appending bits to it.  The
579return value is the updated object itself.
580
581The first form causes the most-significant I<$nbits> of I<$data>
582to be appended to the stream.  The I<$data> argument is in the
583customary binary format used for Perl strings.
584
585The second form takes an ASCII string of "0" and "1" characters as
586its argument.  It's equivalent to
587
588	$sha->add_bits(pack("B*", $bits), length($bits));
589
590So, the following two statements do the same thing:
591
592	$sha->add_bits("111100001010");
593	$sha->add_bits("\xF0\xA0", 12);
594
595Note that SHA-1 and SHA-2 use I<most-significant-bit ordering>
596for their internal state.  This means that
597
598	$sha3->add_bits("110");
599
600is equivalent to
601
602	$sha3->add_bits("1")->add_bits("1")->add_bits("0");
603
604=item B<addfile(*FILE)>
605
606Reads from I<FILE> until EOF, and appends that data to the current
607state.  The return value is the updated object itself.
608
609=item B<addfile($filename [, $mode])>
610
611Reads the contents of I<$filename>, and appends that data to the current
612state.  The return value is the updated object itself.
613
614By default, I<$filename> is simply opened and read; no special modes
615or I/O disciplines are used.  To change this, set the optional I<$mode>
616argument to one of the following values:
617
618	"b"	read file in binary mode
619
620	"U"	use universal newlines
621
622	"0"	use BITS mode
623
624The "U" mode is modeled on Python's "Universal Newlines" concept, whereby
625DOS and Mac OS line terminators are converted internally to UNIX newlines
626before processing.  This ensures consistent digest values when working
627simultaneously across multiple file systems.  B<The "U" mode influences
628only text files>, namely those passing Perl's I<-T> test; binary files
629are processed with no translation whatsoever.
630
631The BITS mode ("0") interprets the contents of I<$filename> as a logical
632stream of bits, where each ASCII '0' or '1' character represents a 0 or
6331 bit, respectively.  All other characters are ignored.  This provides
634a convenient way to calculate the digest values of partial-byte data
635by using files, rather than having to write separate programs employing
636the I<add_bits> method.
637
638=item B<getstate>
639
640Returns a string containing a portable, human-readable representation
641of the current SHA state.
642
643=item B<putstate($str)>
644
645Returns a Digest::SHA object representing the SHA state contained
646in I<$str>.  The format of I<$str> matches the format of the output
647produced by method I<getstate>.  If called as a class method, a new
648object is created; if called as an instance method, the object is reset
649to the state contained in I<$str>.
650
651=item B<dump($filename)>
652
653Writes the output of I<getstate> to I<$filename>.  If the argument is
654missing, or equal to the empty string, the state information will be
655written to STDOUT.
656
657=item B<load($filename)>
658
659Returns a Digest::SHA object that results from calling I<putstate> on
660the contents of I<$filename>.  If the argument is missing, or equal to
661the empty string, the state information will be read from STDIN.
662
663=item B<digest>
664
665Returns the digest encoded as a binary string.
666
667Note that the I<digest> method is a read-once operation. Once it
668has been performed, the Digest::SHA object is automatically reset
669in preparation for calculating another digest value.  Call
670I<$sha-E<gt>clone-E<gt>digest> if it's necessary to preserve the
671original digest state.
672
673=item B<hexdigest>
674
675Returns the digest encoded as a hexadecimal string.
676
677Like I<digest>, this method is a read-once operation.  Call
678I<$sha-E<gt>clone-E<gt>hexdigest> if it's necessary to preserve
679the original digest state.
680
681=item B<b64digest>
682
683Returns the digest encoded as a Base64 string.
684
685Like I<digest>, this method is a read-once operation.  Call
686I<$sha-E<gt>clone-E<gt>b64digest> if it's necessary to preserve
687the original digest state.
688
689It's important to note that the resulting string does B<not> contain
690the padding characters typical of Base64 encodings.  This omission is
691deliberate, and is done to maintain compatibility with the family of
692CPAN Digest modules.  See L</"PADDING OF BASE64 DIGESTS"> for details.
693
694=back
695
696I<HMAC-SHA-1/224/256/384/512>
697
698=over 4
699
700=item B<hmac_sha1($data, $key)>
701
702=item B<hmac_sha224($data, $key)>
703
704=item B<hmac_sha256($data, $key)>
705
706=item B<hmac_sha384($data, $key)>
707
708=item B<hmac_sha512($data, $key)>
709
710=item B<hmac_sha512224($data, $key)>
711
712=item B<hmac_sha512256($data, $key)>
713
714Returns the HMAC-SHA-1/224/256/384/512 digest of I<$data>/I<$key>,
715with the result encoded as a binary string.  Multiple I<$data>
716arguments are allowed, provided that I<$key> is the last argument
717in the list.
718
719=item B<hmac_sha1_hex($data, $key)>
720
721=item B<hmac_sha224_hex($data, $key)>
722
723=item B<hmac_sha256_hex($data, $key)>
724
725=item B<hmac_sha384_hex($data, $key)>
726
727=item B<hmac_sha512_hex($data, $key)>
728
729=item B<hmac_sha512224_hex($data, $key)>
730
731=item B<hmac_sha512256_hex($data, $key)>
732
733Returns the HMAC-SHA-1/224/256/384/512 digest of I<$data>/I<$key>,
734with the result encoded as a hexadecimal string.  Multiple I<$data>
735arguments are allowed, provided that I<$key> is the last argument
736in the list.
737
738=item B<hmac_sha1_base64($data, $key)>
739
740=item B<hmac_sha224_base64($data, $key)>
741
742=item B<hmac_sha256_base64($data, $key)>
743
744=item B<hmac_sha384_base64($data, $key)>
745
746=item B<hmac_sha512_base64($data, $key)>
747
748=item B<hmac_sha512224_base64($data, $key)>
749
750=item B<hmac_sha512256_base64($data, $key)>
751
752Returns the HMAC-SHA-1/224/256/384/512 digest of I<$data>/I<$key>,
753with the result encoded as a Base64 string.  Multiple I<$data>
754arguments are allowed, provided that I<$key> is the last argument
755in the list.
756
757It's important to note that the resulting string does B<not> contain
758the padding characters typical of Base64 encodings.  This omission is
759deliberate, and is done to maintain compatibility with the family of
760CPAN Digest modules.  See L</"PADDING OF BASE64 DIGESTS"> for details.
761
762=back
763
764=head1 SEE ALSO
765
766L<Digest>, L<Digest::SHA::PurePerl>
767
768The Secure Hash Standard (Draft FIPS PUB 180-4) can be found at:
769
770L<http://csrc.nist.gov/publications/drafts/fips180-4/Draft-FIPS180-4_Feb2011.pdf>
771
772The Keyed-Hash Message Authentication Code (HMAC):
773
774L<http://csrc.nist.gov/publications/fips/fips198/fips-198a.pdf>
775
776=head1 AUTHOR
777
778	Mark Shelor	<mshelor@cpan.org>
779
780=head1 ACKNOWLEDGMENTS
781
782The author is particularly grateful to
783
784	Gisle Aas
785	H. Merijn Brand
786	Sean Burke
787	Chris Carey
788	Alexandr Ciornii
789	Chris David
790	Jim Doble
791	Thomas Drugeon
792	Julius Duque
793	Jeffrey Friedl
794	Robert Gilmour
795	Brian Gladman
796	Jarkko Hietaniemi
797	Adam Kennedy
798	Mark Lawrence
799	Andy Lester
800	Alex Muntada
801	Steve Peters
802	Chris Skiscim
803	Martin Thurn
804	Gunnar Wolf
805	Adam Woodbury
806
807"who by trained skill rescued life from such great billows and such thick
808darkness and moored it in so perfect a calm and in so brilliant a light"
809- Lucretius
810
811=head1 COPYRIGHT AND LICENSE
812
813Copyright (C) 2003-2018 Mark Shelor
814
815This library is free software; you can redistribute it and/or modify
816it under the same terms as Perl itself.
817
818L<perlartistic>
819
820=cut
821