sl@0
|
1 |
#
|
sl@0
|
2 |
# Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
# All rights reserved.
|
sl@0
|
4 |
# This component and the accompanying materials are made available
|
sl@0
|
5 |
# under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
# which accompanies this distribution, and is available
|
sl@0
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
#
|
sl@0
|
9 |
# Initial Contributors:
|
sl@0
|
10 |
# Nokia Corporation - initial contribution.
|
sl@0
|
11 |
#
|
sl@0
|
12 |
# Contributors:
|
sl@0
|
13 |
#
|
sl@0
|
14 |
# Description:
|
sl@0
|
15 |
#
|
sl@0
|
16 |
|
sl@0
|
17 |
package Digest::HMAC_MD2;
|
sl@0
|
18 |
$VERSION="1.01";
|
sl@0
|
19 |
|
sl@0
|
20 |
use strict;
|
sl@0
|
21 |
use Digest::MD2 qw(md2);
|
sl@0
|
22 |
use Digest::HMAC qw(hmac);
|
sl@0
|
23 |
|
sl@0
|
24 |
# OO interface
|
sl@0
|
25 |
use vars qw(@ISA);
|
sl@0
|
26 |
@ISA=qw(Digest::HMAC);
|
sl@0
|
27 |
sub new
|
sl@0
|
28 |
{
|
sl@0
|
29 |
my $class = shift;
|
sl@0
|
30 |
$class->SUPER::new($_[0], "Digest::MD2", 16);
|
sl@0
|
31 |
}
|
sl@0
|
32 |
|
sl@0
|
33 |
# Functional interface
|
sl@0
|
34 |
require Exporter;
|
sl@0
|
35 |
*import = \&Exporter::import;
|
sl@0
|
36 |
use vars qw(@EXPORT_OK);
|
sl@0
|
37 |
@EXPORT_OK=qw(hmac_md2 hmac_md2_hex);
|
sl@0
|
38 |
|
sl@0
|
39 |
sub hmac_md2
|
sl@0
|
40 |
{
|
sl@0
|
41 |
hmac($_[0], $_[1], \&md2, 16);
|
sl@0
|
42 |
}
|
sl@0
|
43 |
|
sl@0
|
44 |
sub hmac_md2_hex
|
sl@0
|
45 |
{
|
sl@0
|
46 |
unpack("H*", &hmac_md2)
|
sl@0
|
47 |
}
|
sl@0
|
48 |
|
sl@0
|
49 |
1;
|
sl@0
|
50 |
|
sl@0
|
51 |
__END__
|
sl@0
|
52 |
|
sl@0
|
53 |
=head1 NAME
|
sl@0
|
54 |
|
sl@0
|
55 |
Digest::HMAC_MD2 - Keyed-Hashing for Message Authentication
|
sl@0
|
56 |
|
sl@0
|
57 |
=head1 SYNOPSIS
|
sl@0
|
58 |
|
sl@0
|
59 |
# Functional style
|
sl@0
|
60 |
use Digest::HMAC_MD2 qw(hmac_md2 hmac_md2_hex);
|
sl@0
|
61 |
$digest = hmac_md2($data, $key);
|
sl@0
|
62 |
print hmac_md2_hex($data, $key);
|
sl@0
|
63 |
|
sl@0
|
64 |
# OO style
|
sl@0
|
65 |
use Digest::HMAC_MD2;
|
sl@0
|
66 |
$hmac = Digest::HMAC_MD2->new($key);
|
sl@0
|
67 |
|
sl@0
|
68 |
$hmac->add($data);
|
sl@0
|
69 |
$hmac->addfile(*FILE);
|
sl@0
|
70 |
|
sl@0
|
71 |
$digest = $hmac->digest;
|
sl@0
|
72 |
$digest = $hmac->hexdigest;
|
sl@0
|
73 |
$digest = $hmac->b64digest;
|
sl@0
|
74 |
|
sl@0
|
75 |
=head1 DESCRIPTION
|
sl@0
|
76 |
|
sl@0
|
77 |
This module provide HMAC-MD2 hashing.
|
sl@0
|
78 |
|
sl@0
|
79 |
=head1 SEE ALSO
|
sl@0
|
80 |
|
sl@0
|
81 |
L<Digest::HMAC>, L<Digest::MD2>, L<Digest::HMAC_SHA1>
|
sl@0
|
82 |
|
sl@0
|
83 |
=head1 AUTHOR
|
sl@0
|
84 |
|
sl@0
|
85 |
Jon Thackray, from Gisle Aas <gisle@aas.no>'s MD5 code
|
sl@0
|
86 |
|
sl@0
|
87 |
=cut
|