… | |
… | |
12 | $crypted = $cipher->encrypt($plaintext); |
12 | $crypted = $cipher->encrypt($plaintext); |
13 | # - OR - |
13 | # - OR - |
14 | $plaintext = $cipher->decrypt($crypted); |
14 | $plaintext = $cipher->decrypt($crypted); |
15 | |
15 | |
16 | DESCRIPTION |
16 | DESCRIPTION |
17 | This module implements thw twofish cipher in a less braindamaged (read: |
17 | This module implements the twofish cipher in a less braindamaged (read: |
18 | slow and ugly) way than the existing "Crypt::Twofish" module. |
18 | slow and ugly) way than the existing "Crypt::Twofish" module. |
19 | |
19 | |
20 | Although it is "Crypt::CBC" compliant you usually gain nothing by using |
20 | Although it is "Crypt::CBC" compliant you usually gain nothing by using |
21 | that module (except generality), since "Crypt::Twofish2" can work in |
21 | that module (except generality, which is often a good thing), since |
22 | either ECB or CBC mode. |
22 | "Crypt::Twofish2" can work in either ECB or CBC mode itself. |
23 | |
23 | |
24 | keysize |
24 | keysize |
25 | Returns the keysize, which is 32 (bytes). The Twofish2 cipher |
25 | Returns the keysize, which is 32 (bytes). The Twofish2 cipher |
26 | actually supports keylengths of 16, 24 or 32 bytes, but there is no |
26 | actually supports keylengths of 16, 24 or 32 bytes, but there is no |
27 | way to communicate this to "Crypt::CBC". |
27 | way to communicate this to "Crypt::CBC". |
… | |
… | |
30 | The blocksize for Twofish2 is 16 bytes (128 bits), which is somewhat |
30 | The blocksize for Twofish2 is 16 bytes (128 bits), which is somewhat |
31 | unique. It is also the reason I need this module myself ;) |
31 | unique. It is also the reason I need this module myself ;) |
32 | |
32 | |
33 | $cipher = new $key [, $mode] |
33 | $cipher = new $key [, $mode] |
34 | Create a new "Crypt::Twofish2" cipher object with the given key |
34 | Create a new "Crypt::Twofish2" cipher object with the given key |
35 | (which must be 128, 192 or 256 bits long). The additional "$mode" |
35 | (which must be 128, 192 or 256 bits long). The additional $mode |
36 | argument is the encryption mode, either "MODE_ECB" (electronic |
36 | argument is the encryption mode, either "MODE_ECB" (electronic |
37 | cookbook mode, the default), "MODE_CBC" (cipher block chaining, the |
37 | cookbook mode, the default), "MODE_CBC" (cipher block chaining, the |
38 | same that "Crypt::CBC" does) or "MODE_CFB1" (1-bit cipher feedback |
38 | same that "Crypt::CBC" does) or "MODE_CFB1" (1-bit cipher feedback |
39 | mode). |
39 | mode). |
40 | |
40 | |
… | |
… | |
53 | |
53 | |
54 | The "MODE_*"-constants are not exported by this module, so you must |
54 | The "MODE_*"-constants are not exported by this module, so you must |
55 | specify them as "Crypt::Twofish2::MODE_CBC" etc. (sorry for that). |
55 | specify them as "Crypt::Twofish2::MODE_CBC" etc. (sorry for that). |
56 | |
56 | |
57 | $cipher->encrypt($data) |
57 | $cipher->encrypt($data) |
58 | Encrypt data. The size of "$data" must be a multiple of "blocksize" |
58 | Encrypt data. The size of $data must be a multiple of "blocksize" |
59 | (16 bytes), otherwise this function will croak. Apart from that, it |
59 | (16 bytes), otherwise this function will croak. Apart from that, it |
60 | can be of (almost) any length. |
60 | can be of (almost) any length. |
61 | |
61 | |
62 | $cipher->decrypt($data) |
62 | $cipher->decrypt($data) |
63 | The pendant to "encrypt" in that it *de*crypts data again. |
63 | The pendant to "encrypt" in that it *de*crypts data again. |
64 | |
64 | |
65 | SEE ALSO |
65 | SEE ALSO |
66 | the Crypt::CBC manpage, the Crypt::Twofish manpage. |
66 | Crypt::CBC, Crypt::Twofish. |
67 | |
67 | |
68 | BUGS |
68 | BUGS |
69 | Should EXPORT or EXPORT_OK the MODE constants. |
69 | Should EXPORT or EXPORT_OK the MODE constants. |
70 | |
|
|
71 | The testsuite does not check wether the encrypted valued are correct. |
|
|
72 | |
70 | |
73 | There should be a way to access initial IV contents :( |
71 | There should be a way to access initial IV contents :( |
74 | |
72 | |
75 | Although I tried to make the original twofish code portable, I can't say |
73 | Although I tried to make the original twofish code portable, I can't say |
76 | how much I did succeed. The code tries to be portable itself, and I hope |
74 | how much I did succeed. The code tries to be portable itself, and I hope |
77 | I got the endianness issues right. The code is also copyright |
75 | I got the endianness issues right. The code is also copyright |
78 | Counterpane Systems, no license accompanied it, so using it might |
76 | Counterpane Systems, no license accompanied it, so using it might |
79 | actually be illegal ;) |
77 | actually be illegal ;) |
80 | |
78 | |
|
|
79 | I also cannot guarantee for security, but the module is used quite a |
|
|
80 | bit, so there are no obvious bugs left. |
|
|
81 | |
81 | AUTHOR |
82 | AUTHOR |
82 | Marc Lehmann <pcg@goof.com> |
83 | Marc Lehmann <pcg@goof.com> |
83 | http://www.goof.com/pcg/marc/ |
84 | http://www.goof.com/pcg/marc/ |
84 | |
85 | |
85 | The actualy twofish encryption is written in horribly microsoft'ish looking |
86 | The actual twofish encryption is written in horribly microsoft'ish looking |
86 | almost ansi-c by Doug Whiting. |
87 | almost ansi-c by Doug Whiting. |
87 | |
88 | |