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