File Coverage

blib/lib/Crypt/OpenToken/Cipher/AES128.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 3 3 100.0
total 24 24 100.0


line stmt bran cond sub pod time code
1             package Crypt::OpenToken::Cipher::AES128;
2              
3 2     2   15 use Moose;
  2         5  
  2         45  
4 2     2   15113 use Crypt::Rijndael;
  2         6  
  2         54  
5 2     2   11 use namespace::autoclean;
  2         4  
  2         16  
6              
7             with 'Crypt::OpenToken::Cipher';
8              
9 7     7 1 36 sub keysize { 16 }
10 9     9 1 44 sub iv_len { 16 }
11             sub cipher {
12 9     9 1 32 my ($self, $key, $iv) = @_;
13 9         145 my $crypto = Crypt::Rijndael->new($key, Crypt::Rijndael::MODE_CBC());
14 9         45 $crypto->set_iv($iv);
15 9         57 return $crypto;
16             }
17              
18             1;
19              
20             =head1 NAME
21              
22             Crypt::OpenToken::Cipher::AES128 - AES128 encryption support for OpenToken
23              
24             =head1 DESCRIPTION
25              
26             This library can be used by C<Crypt::OpenToken> to encrypt payloads using
27             AES-128 encryption.
28              
29             =head1 METHODS
30              
31             =over
32              
33             =item keysize()
34              
35             Returns the key size used for AES-128 encryption; 16 bytes.
36              
37             =item iv_len()
38              
39             Returns the length of the Initialization Vector needed for AES-128 encryption;
40             16 bytes.
41              
42             =item cipher($key, $iv)
43              
44             Returns a C<Crypt::CBC> compatible cipher the implements the AES-128
45             encryption.
46              
47             =back
48              
49             =head1 AUTHOR
50              
51             Graham TerMarsch (cpan@howlingfrog.com)
52              
53             =head1 COPYRIGHT & LICENSE
54              
55             C<Crypt::OpenToken> is Copyright (C) 2010, Socialtext, and is released under
56             the Artistic-2.0 license.
57              
58             =head1 SEE ALSO
59              
60             L<Crypt::OpenToken::Cipher>
61              
62             =cut