Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.2 KiB

  1. package Digest::HMAC_SHA1;
  2. $VERSION="1.00";
  3. use strict;
  4. use Digest::SHA1 qw(sha1);
  5. use Digest::HMAC qw(hmac);
  6. # OO interface
  7. use vars qw(@ISA);
  8. @ISA=qw(Digest::HMAC);
  9. sub new
  10. {
  11. my $class = shift;
  12. $class->SUPER::new($_[0], "Digest::SHA1", 64);
  13. }
  14. # Functional interface
  15. require Exporter;
  16. *import = \&Exporter::import;
  17. use vars qw(@EXPORT_OK);
  18. @EXPORT_OK=qw(hmac_sha1 hmac_sha1_hex);
  19. sub hmac_sha1
  20. {
  21. hmac($_[0], $_[1], \&sha1, 64);
  22. }
  23. sub hmac_sha1_hex
  24. {
  25. unpack("H*", &hmac_sha1)
  26. }
  27. 1;
  28. __END__
  29. =head1 NAME
  30. Digest::HMAC_SHA1 - Keyed-Hashing for Message Authentication
  31. =head1 SYNOPSIS
  32. # Functional style
  33. use Digest::HMAC_SHA1 qw(hmac_sha1 hmac_sha1_hex);
  34. $digest = hmac_sha1($data, $key);
  35. print hmac_sha1_hex($data, $key);
  36. # OO style
  37. use Digest::HMAC_SHA1;
  38. $hmac = Digest::HMAC_SHA1->new($key);
  39. $hmac->add($data);
  40. $hmac->addfile(*FILE);
  41. $digest = $hmac->digest;
  42. $digest = $hmac->hexdigest;
  43. $digest = $hmac->b64digest;
  44. =head1 DESCRIPTION
  45. This module provide HMAC-SHA-1 hashing.
  46. =head1 SEE ALSO
  47. L<Digest::HMAC>, L<Digest::SHA1>, L<Digest::HMAC_MD5>
  48. =head1 AUTHOR
  49. Gisle Aas <[email protected]>
  50. =cut