ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Crypt-Spritz/Spritz.pm
(Generate patch)

Comparing Crypt-Spritz/Spritz.pm (file contents):
Revision 1.4 by root, Sat Jan 10 07:10:46 2015 UTC vs.
Revision 1.5 by root, Sat Jan 10 07:19:24 2015 UTC

1=head1 NAME 1=head1 NAME
2 2
3Crypt::Spritz - Crypt::CBC compliant Spritz encryption/hash/mac/aead/prng module 3Crypt::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
20This module implements the Spritz spongelike function (with N=256), the 35This module implements the Spritz spongelike function (with N=256), the
21spiritual successor of RC4 developed by Ron Rivest and Jacob Schuldt. 36spiritual successor of RC4 developed by Ron Rivest and Jacob Schuldt.
32this might be reversed on an 8-bit-cpu) and the fact that it is totally 47this might be reversed on an 8-bit-cpu) and the fact that it is totally
33unproven in the field (as of this writing, the cipher was just a few 48unproven in the field (as of this writing, the cipher was just a few
34months old), so it can't be called production-ready. 49months old), so it can't be called production-ready.
35 50
36All the usual caveats regarding stream ciphers apply - never repeat 51All the usual caveats regarding stream ciphers apply - never repeat
37your key, never repeat your nonce etc. - you should have some basic 52your key, never repeat your nonce and so on - you should have some basic
38understanding of cryptography before using this cipher in your own 53understanding of cryptography before using this cipher in your own
39designs. 54designs.
40 55
41The Spritz base class is not meant for end users. To make usage simpler 56The Spritz base class is not meant for end users. To make usage simpler
42and safer, a number of convenience classes are provided for typical 57and safer, a number of convenience classes are provided for typical
495completely unproven. 510completely 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
5041; 5191;
505 520

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines