… | |
… | |
51 | if (keysize != 16 && keysize != 24 && keysize != 32) |
51 | if (keysize != 16 && keysize != 24 && keysize != 32) |
52 | croak ("wrong key length: key must be 128, 192 or 256 bits long"); |
52 | croak ("wrong key length: key must be 128, 192 or 256 bits long"); |
53 | if (mode != MODE_ECB && mode != MODE_CBC && mode != MODE_CFB1) |
53 | if (mode != MODE_ECB && mode != MODE_CBC && mode != MODE_CFB1) |
54 | croak ("illegal mode: mode must be MODE_ECB, MODE_2 or MODE_CFB1"); |
54 | croak ("illegal mode: mode must be MODE_ECB, MODE_2 or MODE_CFB1"); |
55 | |
55 | |
56 | Newz(0, RETVAL, 1, struct cryptstate); |
56 | Newz (0, RETVAL, 1, struct cryptstate); /* Newz required for defined IV */ |
57 | |
57 | |
58 | if (makeKey (&RETVAL->ki, DIR_ENCRYPT, keysize*8, SvPV_nolen(key)) != TRUE) |
58 | if (makeKey (&RETVAL->ki, DIR_ENCRYPT, keysize*8, SvPV_nolen(key)) != TRUE) |
59 | croak ("Crypt::Twofish2: makeKey failed, please report!"); |
59 | croak ("Crypt::Twofish2: makeKey failed, please report!"); |
60 | if (cipherInit (&RETVAL->ci, mode, 0) != TRUE) /* no IV supported (yet) */ |
60 | if (cipherInit (&RETVAL->ci, mode, 0) != TRUE) /* no IV supported (yet) */ |
61 | croak ("Crypt::Twofish2: makeKey failed, please report!"); |
61 | croak ("Crypt::Twofish2: makeKey failed, please report!"); |