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.7 by root, Sat Jan 10 09:20:24 2015 UTC vs.
Revision 1.13 by root, Tue Jun 30 01:24:43 2015 UTC

80 80
81package Crypt::Spritz; 81package Crypt::Spritz;
82 82
83use XSLoader; 83use XSLoader;
84 84
85$VERSION = '0.1'; 85$VERSION = 1.01;
86 86
87XSLoader::load __PACKAGE__, $VERSION; 87XSLoader::load __PACKAGE__, $VERSION;
88 88
89@Crypt::Spritz::ISA = Crypt::Spritz::Base::; 89@Crypt::Spritz::ISA = Crypt::Spritz::Base::;
90 90
117 117
118=head2 THE Crypt::Spritz CLASS 118=head2 THE Crypt::Spritz CLASS
119 119
120This class implements most of the Spritz primitives. To use it effectively 120This class implements most of the Spritz primitives. To use it effectively
121you should understand them, for example, by reading the L<Spritz 121you should understand them, for example, by reading the L<Spritz
122paper/http://people.csail.mit.edu/rivest/pubs/RS14.pdf>, especially 122paper|http://people.csail.mit.edu/rivest/pubs/RS14.pdf>, especially
123pp. 5-6. 123pp. 5-6.
124 124
125The Spritz primitive corresponding to the Perl method is given as 125The Spritz primitive corresponding to the Perl method is given as
126comment. 126comment.
127 127
442These methods are provided for L<Crypt::CBC> compatibility and simply 442These methods are provided for L<Crypt::CBC> compatibility and simply
443return C<32> and C<64>, respectively. 443return C<32> and C<64>, respectively.
444 444
445Note that it is pointless to use Spritz with L<Crypt::CBC>, as Spritz is 445Note that it is pointless to use Spritz with L<Crypt::CBC>, as Spritz is
446not a block cipher and already provides an appropriate mode. 446not a block cipher and already provides an appropriate mode.
447
448=back
449
450
451=head2 THE Crypt::Spritz::Cipher CLASS
452
453This class is pretty much the same as the C<Crypt::Spritz::Cipher::XOR>
454class, with two differences: first, it implements the "standard" Spritz
455encryption algorithm, and second, while this variant is easier to analyze
456mathematically, there is little else to recommend it for, as it is slower,
457and requires lots of code duplication code.
458
459So unless you need to be compatible with another implementation that does
460not offer the XOR variant, stick to C<Crypt::Spritz::Cipher::XOR>.
461
462All the methods from C<Crypt::Spritz::Cipher::XOR> are available, except
463C<crypt>, which has been replaced by separate C<encrypt> and C<decrypt>
464methods:
465
466=over 4
467
468=item $encrypted = $cipher->encrypt ($cleartext)
469
470=item $cleartext = $cipher->decrypt ($encrypted)
471
472Really the same as C<Crypt::Spritz::Cipher::XOR>, except you need separate
473calls and code for encryption and decryption.
447 474
448=back 475=back
449 476
450 477
451=head2 THE Crypt::Spritz::AEAD::XOR CLASS 478=head2 THE Crypt::Spritz::AEAD::XOR CLASS
582 } 609 }
583 610
584=back 611=back
585 612
586 613
614=head2 THE Crypt::Spritz::AEAD CLASS
615
616This class is pretty much the same as the C<Crypt::Spritz::AEAD::XOR>
617class, with two differences: first, it implements the "standard" Spritz
618encryption algorithm, and second, while this variant is easier to analyze
619mathematically, there is little else to recommend it for, as it is slower,
620and requires lots of code duplication code.
621
622So unless you need to be compatible with another implementation that does
623not offer the XOR variant, stick to C<Crypt::Spritz::AEAD::XOR>.
624
625All the methods from C<Crypt::Spritz::AEAD::XOR> are available, except
626C<crypt>, which has been replaced by separate C<encrypt> and C<decrypt>
627methods:
628
629=over 4
630
631=item $encrypted = $cipher->encrypt ($cleartext)
632
633=item $cleartext = $cipher->decrypt ($encrypted)
634
635Really the same as C<Crypt::Spritz::AEAD::XOR>, except you need separate
636calls and code for encryption and decryption, but you have the same
637limitations on usage.
638
639=back
640
641
642=head1 SECURITY CONSIDERATIONS
643
644At the time of this writing, Spritz has not been through a lot of
645cryptanalysis - it might get broken tomorrow. That's true for any crypto
646algo, but the probability is quite a bit higher with Spritz. Having said
647that, Spritz is almost certainly safer than RC4 at this time.
648
649Nevertheless, I wouldn't protect something very expensive with it. I also
650would be careful about timing attacks.
651
652Regarding key lengths - as has been pointed out, traditional symmetric key
653lengths (128 bit, 256 bit) work fine. Longer keys will be overkill, but
654you can expect keys up to about a kilobit to be effective. Longer keys are
655safe to use, they will simply be a waste of time.
656
657
658=head1 PERFORMANCE
659
660As a cipher/prng, Spritz is reasonably fast (about 100MB/s on 2014 era
661hardware, for comparison, AES will be more like 200MB/s).
662
663For key setup, ivs, hashing, nonces and so on, Spritz is very slow (about
6645MB/s on 2014 era hardware, which does SHA-256 at about 200MB/s).
665
666
667=head1 SUPPORT FOR THE PERL MULTICORE SPECIFICATION
668
669This module supports the perl multicore specification
670(L<http://perlmulticore.schmorp.de/>) for all encryption/decryption
671(non-aead > 4000 octets, aead > 400 octets), hashing/absorbing (> 400
672octets) and squeezing/prng (> 4000 octets) functions.
673
674
587=head1 SEE ALSO 675=head1 SEE ALSO
588 676
589L<http://people.csail.mit.edu/rivest/pubs/RS14.pdf>. 677L<http://people.csail.mit.edu/rivest/pubs/RS14.pdf>.
590 678
591=head1 SECURITY CONSIDERATIONS 679=head1 SECURITY CONSIDERATIONS

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines