Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | =head1 NAME |
2 | ||
3 | Crypt::Rijndael - Crypt::CBC compliant Rijndael encryption module | |
4 | ||
5 | =head1 SYNOPSIS | |
6 | ||
7 | use Crypt::Rijndael; | |
8 | ||
9 | # keysize() is 32, but 24 and 16 are also possible | |
10 | # blocksize() is 16 | |
11 | ||
12 | $cipher = new Crypt::Rijndael "a" x 32, Crypt::Rijndael::MODE_CBC; | |
13 | ||
14 | $cipher->set_iv($iv); | |
15 | $crypted = $cipher->encrypt($plaintext); | |
16 | # - OR - | |
17 | $plaintext = $cipher->decrypt($crypted); | |
18 | ||
19 | =head1 DESCRIPTION | |
20 | ||
21 | This module implements the Rijndael cipher, which has just been selected | |
22 | as the Advanced Encryption Standard. | |
23 | ||
24 | =over 4 | |
25 | ||
26 | =cut | |
27 | ||
28 | package Crypt::Rijndael; | |
29 | ||
30 | require DynaLoader; | |
31 | ||
32 | $VERSION = 0.04; | |
33 | @ISA = qw/DynaLoader/; | |
34 | ||
35 | bootstrap Crypt::Rijndael $VERSION; | |
36 | ||
37 | =item keysize | |
38 | ||
39 | Returns the keysize, which is 32 (bytes). The Rijndael cipher | |
40 | actually supports keylengths of 16, 24 or 32 bytes, but there is no | |
41 | way to communicate this to C<Crypt::CBC>. | |
42 | ||
43 | =item blocksize | |
44 | ||
45 | The blocksize for Rijndael is 16 bytes (128 bits), although the | |
46 | algorithm actually supports any blocksize that is any multiple of | |
47 | our bytes. 128 bits, is however, the AES-specified block size, | |
48 | so this is all we support. | |
49 | ||
50 | =item $cipher = new $key [, $mode] | |
51 | ||
52 | Create a new C<Crypt::Rijndael> cipher object with the given key | |
53 | (which must be 128, 192 or 256 bits long). The additional C<$mode> | |
54 | argument is the encryption mode, either C<MODE_ECB> (electronic | |
55 | codebook mode, the default), C<MODE_CBC> (cipher block chaining, the | |
56 | same that C<Crypt::CBC> does), C<MODE_CFB> (128-bit cipher feedback), | |
57 | C<MODE_OFB> (128-bit output feedback), or C<MODE_CTR> (counter mode). | |
58 | ||
59 | ECB mode is very insecure (read a book on cryptography if you dont | |
60 | know why!), so you should probably use CBC mode. | |
61 | ||
62 | =item $cipher->set_iv($iv) | |
63 | ||
64 | This allows you to change the initial value vector used by the | |
65 | chaining modes. It is not relevant for ECB mode. | |
66 | ||
67 | =item $cipher->encrypt($data) | |
68 | ||
69 | Encrypt data. The size of C<$data> must be a multiple of C<blocksize> | |
70 | (16 bytes), otherwise this function will croak. Apart from that, it | |
71 | can be of (almost) any length. | |
72 | ||
73 | =item $cipher->decrypt($data) | |
74 | ||
75 | Decrypts C<$data>. | |
76 | ||
77 | =back | |
78 | ||
79 | =head1 SEE ALSO | |
80 | ||
81 | L<Crypt::CBC>, http://www.csrc.nist.gov/encryption/aes/ | |
82 | ||
83 | =head1 BUGS | |
84 | ||
85 | Should EXPORT or EXPORT_OK the MODE constants. | |
86 | ||
87 | =head1 AUTHOR | |
88 | ||
89 | Rafael R. Sevilla <sevillar@team.ph.inter.net> | |
90 | ||
91 | The Rijndael Algorithm was developed by Vincent Rijmen and Joan Daemen, | |
92 | and has been selected as the US Government's Advanced Encryption Standard. | |
93 | ||
94 | =cut | |
95 | ||
96 | 1; | |
97 |