File Coverage

blib/lib/Digest/CMAC.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 23 23 100.0


line stmt bran cond sub pod time code
1             package Digest::CMAC;
2              
3 17     17   449544 use base qw(Digest::OMAC::Base);
  17         48  
  17         28687  
4              
5 17     17   121 use strict;
  17         35  
  17         619  
6             #use warnings;
7 17     17   90 use Carp;
  17         33  
  17         1172  
8 17     17   90 use MIME::Base64;
  17         33  
  17         1083  
9              
10 17     17   89 use vars qw($VERSION);
  17         31  
  17         1801  
11              
12             $VERSION = '0.04';
13              
14             sub _lu2 {
15 14     14   1051 my ( $self, $blocksize, $L, $Lu ) = @_;
16 14         1062 $self->_lu( $blocksize, $Lu );
17             }
18              
19             1;
20             __END__
21              
22             =head1 NAME
23              
24             Digest::CMAC - The One-key CBC MAC message authentication code.
25              
26             =head1 SYNOPSIS
27              
28             use Digest::CMAC;
29             my $omac1 = Digest::CMAC->new($key);
30            
31             $omac1->add($data);
32            
33             my $binary_tag = $omac1->digest;
34             my $hex_tag = $omac1->hexdigest;
35             my $base64_tag = $omac1->b64digest;
36              
37             =head1 DESCRIPTION
38              
39             This module implements OMAC1 blockcipher-based message authentication code for perl. For OMAC1/OMAC. Check http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html. Here is an excerpt of that page
40              
41             =over 4
42              
43             OMAC is a blockcipher-based message authentication code designed and analyzed by me and Kaoru Kurosawa.
44              
45             OMAC is a simple variant of the CBC MAC (Cipher Block Chaining Message Authentication Code). OMAC stands for One-Key CBC MAC.
46              
47             OMAC allows and is secure for messages of any bit length (while the CBC MAC is only secure on messages of one fixed length, and the length must be a multiple of the block length). Also, the efficiency of OMAC is highly optimized. It is almost as efficient as the CBC MAC.
48              
49             "NIST Special Publication 800-38B Recommendation for Block Cipher Modes of Operation: the CMAC Mode for Authentication" has been finalized on May 18, 2005. This Recommendation specifies CMAC, which is equivalent to OMAC (OMAC1).
50              
51             =back 4
52              
53             Like many block-cipher's Crypt:: modules like L<Crypt::Rijndael>, and L<MIME::Base64>.
54              
55             =head1 METHODS
56              
57             =over 4
58              
59             =item new
60              
61             my $omac1 = Digest::CMAC->new($key [, $cipher]);
62              
63             This creates a new Digest::CMAC object, using $key.
64              
65             $cipher is 'Crypt::Rijndael'(default), 'Crypt::Misty1', Crypt::Blowfish', or whatever blockcipher you like. $key is fixed length string that blockcipher demands.
66              
67             =item add
68              
69             $omac1->add($message,...);
70              
71             The $message provided as argument are appended to the message we calculate the MAC. The return value is the $cmac object itself;
72              
73             =item reset
74              
75             $omac1->reset;
76              
77             This is just an alias for $cmac->new;
78              
79             =item digest
80              
81             my $digest = $omac1->digest;
82              
83             Return the binary authentication code for the message. The returned string will be blockcipher's block size.
84              
85             =item hexdigest
86              
87             my $digest = $omac1->hexdigest;
88              
89             Same as $cmac->digest, but will return the digest in hexadecimal form.
90              
91             =item b64digest
92              
93             Same as $omac1->digest, but will return the digest as a base64 encoded string.
94              
95             =back
96              
97             =head1 SEE ALSO
98              
99             L<Crypt::Rijndael>,
100             http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/omac.html,
101             http://www.csrc.nist.gov/publications/nistpubs/800-38B/SP_800-38B.pdf
102              
103             =head1 AUTHOR
104              
105             OMAC designed and analyzed by
106             Tetsu Iwata and Kaoru Kurosawa
107              
108             "Crypt::CMAC" was written by
109             Hiroyuki OYAMA <oyama@module.jp>
110              
111             OMAC2 support added by Yuval Kogman
112              
113             =head1 COPYRIGHT AND LICENSE
114              
115             Copyright (C) 2006 by Hiroyuki OYAMA, 2007 by Hiroyuki OYAMA, Yuval Kogman
116              
117             This library is free software; you can redistribute it and/or modify
118             it under the same terms as Perl itself, either Perl version 5.8.6 or,
119             at your option, any later version of Perl 5 you may have available.
120              
121             =cut