1 | =head1 NAME |
1 | =head1 NAME |
2 | |
2 | |
3 | Crypt::Spritz - Crypt::CBC compliant Spritz encryption/hash/mac/aead/prng module |
3 | Crypt::Spritz - Spritz stream cipher/hash/MAC/AEAD/CSPRNG module |
4 | |
4 | |
5 | =head1 SYNOPSIS |
5 | =head1 SYNOPSIS |
6 | |
6 | |
7 | use Crypt::Spritz; |
7 | use Crypt::Spritz; |
8 | |
8 | |
9 | # keysize() is 32, but spritz accepts any key size |
9 | # see the commented examples in their respective classes, |
10 | # blocksize() is 16, but cna be anything |
10 | # but basically |
11 | |
11 | |
12 | $cipher = new Crypt::Twofish2 "a" x 32, Crypt::Twofish2::MODE_CBC; |
12 | my $cipher = new Crypt::Spritz::Cipher::XOR $key, $iv; |
13 | |
|
|
14 | $crypted = $cipher->encrypt($plaintext); |
13 | $ciphertext = $cipher->crypt ($cleartext); |
15 | # - OR - |
14 | |
16 | $plaintext = $cipher->decrypt($crypted); |
15 | my $hasher = new Crypt::Spritz::Hash; |
|
|
16 | $hasher->add ($data); |
|
|
17 | $digest = $hasher->finish; |
|
|
18 | |
|
|
19 | my $hasher = new Crypt::Spritz::MAC $key; |
|
|
20 | $hasher->add ($data); |
|
|
21 | $mac = $hasher->finish; |
|
|
22 | |
|
|
23 | my $aead = new Crypt::Spritz::AEAD::XOR $key; |
|
|
24 | $aead->nonce ($counter); |
|
|
25 | $aead->associated_data ($header); |
|
|
26 | $ciphertext = $aead->crypt ($cleartext); |
|
|
27 | $mac = $aead->mac; |
|
|
28 | |
|
|
29 | my $prng = new Crypt::Spritz::PRNG $entropy; |
|
|
30 | $prng->add ($additional_entropy); |
|
|
31 | $keydata = $prng->get (32); |
17 | |
32 | |
18 | =head1 DESCRIPTION |
33 | =head1 DESCRIPTION |
19 | |
34 | |
20 | This module implements the Spritz spongelike function (with N=256), the |
35 | This module implements the Spritz spongelike function (with N=256), the |
21 | spiritual successor of RC4 developed by Ron Rivest and Jacob Schuldt. |
36 | spiritual successor of RC4 developed by Ron Rivest and Jacob Schuldt. |
… | |
… | |
32 | this might be reversed on an 8-bit-cpu) and the fact that it is totally |
47 | this might be reversed on an 8-bit-cpu) and the fact that it is totally |
33 | unproven in the field (as of this writing, the cipher was just a few |
48 | unproven in the field (as of this writing, the cipher was just a few |
34 | months old), so it can't be called production-ready. |
49 | months old), so it can't be called production-ready. |
35 | |
50 | |
36 | All the usual caveats regarding stream ciphers apply - never repeat |
51 | All the usual caveats regarding stream ciphers apply - never repeat |
37 | your key, never repeat your nonce etc. - you should have some basic |
52 | your key, never repeat your nonce and so on - you should have some basic |
38 | understanding of cryptography before using this cipher in your own |
53 | understanding of cryptography before using this cipher in your own |
39 | designs. |
54 | designs. |
40 | |
55 | |
41 | The Spritz base class is not meant for end users. To make usage simpler |
56 | The Spritz base class is not meant for end users. To make usage simpler |
42 | and safer, a number of convenience classes are provided for typical |
57 | and safer, a number of convenience classes are provided for typical |
… | |
… | |
495 | completely unproven. |
510 | completely unproven. |
496 | |
511 | |
497 | =head1 AUTHOR |
512 | =head1 AUTHOR |
498 | |
513 | |
499 | Marc Lehmann <schmorp@schmorp.de> |
514 | Marc Lehmann <schmorp@schmorp.de> |
500 | http://home.schmorp.de/ |
515 | http://software.schmorp.de/pkg/Crypt-Spritz |
501 | |
516 | |
502 | =cut |
517 | =cut |
503 | |
518 | |
504 | 1; |
519 | 1; |
505 | |
520 | |