=head1 NAME Crypt::Spritz - Crypt::CBC compliant Spritz encryption/hash/mac/aead/prng module =head1 SYNOPSIS use Crypt::Spritz; # keysize() is 32, but spritz accepts any key size # blocksize() is 16, but cna be anything $cipher = new Crypt::Twofish2 "a" x 32, Crypt::Twofish2::MODE_CBC; $crypted = $cipher->encrypt($plaintext); # - OR - $plaintext = $cipher->decrypt($crypted); =head1 DESCRIPTION This module implements the spritz spongelike function. Although it is C compliant you usually gain nothing by using that module (except generality, which is often a good thing), since C can work in either ECB or CBC mode itself. =over 4 =cut package Crypt::Spritz; use XSLoader; $VERSION = '0.0'; XSLoader::load __PACKAGE__, $VERSION; @Crypt::Spritz::CipherBase::ISA = @Crypt::Spritz::Hash::ISA = @Crypt::Spritz::PRNG::ISA = Crypt::Spritz::; @Crypt::Spritz::MAC::ISA = Crypt::Spritz::Hash::; @Crypt::Spritz::Cipher::XOR::ISA = @Crypt::Spritz::Cipher::ISA = @Crypt::Spritz::AEAD::ISA = @Crypt::Spritz::AEAD::XOR::ISA = Crypt::Spritz::CipherBase::; sub Crypt::Spritz::CipherBase::keysize () { 32 } sub Crypt::Spritz::CipherBase::blocksize () { 64 } *Crypt::Spritz::Hash::add = *Crypt::Spritz::PRNG::add = \&Crypt::Spritz::absorb; *Crypt::Spritz::PRNG::get = \&Crypt::Spritz::squeeze; *Crypt::Spritz::AEAD::XOR::new = *Crypt::Spritz::AEAD::new = \&Crypt::Spritz::MAC::new; *Crypt::Spritz::AEAD::XOR::finish = *Crypt::Spritz::AEAD::finish = \&Crypt::Spritz::Hash::finish; *Crypt::Spritz::AEAD::XOR::associated_data = *Crypt::Spritz::AEAD::associated_data = *Crypt::Spritz::AEAD::XOR::nonce = *Crypt::Spritz::AEAD::nonce = \&Crypt::Spritz::absborb_and_stop; =item keysize Returns the keysize, which is 32 (bytes). The Twofish2 cipher actually supports keylengths of 16, 24 or 32 bytes, but there is no way to communicate this to C. =item blocksize The blocksize for Twofish2 is 16 bytes (128 bits), which is somewhat unique. It is also the reason I need this module myself ;) =item $cipher = new $key [, $mode] Create a new C cipher object with the given key (which must be 128, 192 or 256 bits long). The additional C<$mode> argument is the encryption mode, either C (electronic cookbook mode, the default), C (cipher block chaining, the same that C does) or C (1-bit cipher feedback mode). ECB mode is very insecure (read a book on cryptography if you don't know why!), so you should probably use CBC mode. CFB1 mode is not tested and is most probably broken, so do not try to use it. In ECB mode you can use the same cipher object to encrypt and decrypt data. However, every change of "direction" causes an internal reordering of key data, which is quite slow, so if you want ECB mode and encryption/decryption at the same time you should create two seperate C objects with the same key. In CBC mode you have to use seperate objects for encryption/decryption in any case. The C-constants are not exported by this module, so you must specify them as C etc. (sorry for that). =item $cipher->encrypt($data) Encrypt data. The size of C<$data> must be a multiple of C (16 bytes), otherwise this function will croak. Apart from that, it can be of (almost) any length. =item $cipher->decrypt($data) The pendant to C in that it Icrypts data again. =back =head1 SEE ALSO L, L, L. =head1 SECURITY CONSIDERATIONS I also cannot guarantee for security. =head1 AUTHOR Marc Lehmann http://home.schmorp.de/ The actual twofish encryption is written in horribly microsoft'ish looking almost ansi-c by Doug Whiting. =cut 1;