1Rijndael(3) User Contributed Perl Documentation Rijndael(3)
2
3
4
6 Crypt::Rijndael - Crypt::CBC compliant Rijndael encryption module
7
9 use Crypt::Rijndael;
10
11 # keysize() is 32, but 24 and 16 are also possible
12 # blocksize() is 16
13
14 $cipher = Crypt::Rijndael->new( "a" x 32, Crypt::Rijndael::MODE_CBC() );
15
16 $cipher->set_iv($iv);
17 $crypted = $cipher->encrypt($plaintext);
18 # - OR -
19 $plaintext = $cipher->decrypt($crypted);
20
22 This module implements the Rijndael cipher, which has just been
23 selected as the Advanced Encryption Standard.
24
25 keysize
26 Returns the keysize, which is 32 (bytes). The Rijndael cipher
27 actually supports keylengths of 16, 24 or 32 bytes, but there is no
28 way to communicate this to "Crypt::CBC".
29
30 blocksize
31 The blocksize for Rijndael is 16 bytes (128 bits), although the
32 algorithm actually supports any blocksize that is any multiple of
33 our bytes. 128 bits, is however, the AES-specified block size, so
34 this is all we support.
35
36 $cipher = Crypt::Rijndael->new( $key [, $mode] )
37 Create a new "Crypt::Rijndael" cipher object with the given key
38 (which must be 128, 192 or 256 bits long). The additional $mode
39 argument is the encryption mode, either "MODE_ECB" (electronic
40 codebook mode, the default), "MODE_CBC" (cipher block chaining, the
41 same that "Crypt::CBC" does), "MODE_CFB" (128-bit cipher feedback),
42 "MODE_OFB" (128-bit output feedback), or "MODE_CTR" (counter mode).
43
44 ECB mode is very insecure (read a book on cryptography if you dont
45 know why!), so you should probably use CBC mode.
46
47 $cipher->set_iv($iv)
48 This allows you to change the initial value vector used by the
49 chaining modes. It is not relevant for ECB mode.
50
51 $cipher->encrypt($data)
52 Encrypt data. The size of $data must be a multiple of "blocksize"
53 (16 bytes), otherwise this function will croak. Apart from that, it
54 can be of (almost) any length.
55
56 $cipher->decrypt($data)
57 Decrypts $data.
58
59 Encryption modes
60 Use these constants to select the cipher type:
61
62 MODE_CBC - Cipher Block Chaining
63 MODE_CFB - Cipher feedback
64 MODE_CTR - Counter mode
65 MODE_ECB - Electronic cookbook mode
66 MODE_OFB - Output feedback
67 MODE_PCBC - ignore this one for now :)
68
70 Crypt::CBC, http://www.csrc.nist.gov/encryption/aes/
71
73 Should EXPORT or EXPORT_OK the MODE constants.
74
76 Currently maintained by brian d foy, "<bdfoy@cpan.org>".
77
78 Original code by Rafael R. Sevilla.
79
80 The Rijndael Algorithm was developed by Vincent Rijmen and Joan Daemen,
81 and has been selected as the US Government's Advanced Encryption
82 Standard.
83
85 This code is in Github:
86
87 git://github.com/briandfoy/crypt-rijndael.git
88
90 This software is licensed under the Lesser GNU Public License. See the
91 included COPYING file for details.
92
93
94
95perl v5.12.0 2010-01-17 Rijndael(3)