Crypt-DES_PP
view release on metacpan or search on metacpan
on big-endian machines, too. Thanks to schinder@pobox.com for
the bug report, thanks to Frank Naumann (fnaumann@freemint.de)
for giving me access to his big-endian MiNT machine for debugging.
2000-10-11 Guido Flohr <guido@freemint.de>
* DES_PP.ppm: Bumped version number to 0.06.
* test.pl:
Eval dependencies to other modules in single quotes, not in curly
braces to avoid the test to fail if Crypt::CBC is not present.
* t/cbcref.t:
Don't print a test number for bulk output when Crypt::CBC is not
present, so that Test::Harness doesn't get confused.
2000-10-11 Guido Flohr <guido@freemint.de>
* DES_PP.ppm: Bumped version number to 0.06.
* test.pl:
Eval dependencies to other modules in single quotes, not in curly
braces to avoid the test to fail if Crypt::CBC is not present.
* t/cbcref.t:
Don't print a test number for bulk output when Crypt::CBC is not
present, so that Test::Harness doesn't get confused.
2000-10-08 Guido Flohr <guido@freemint.de>
* DES_PP.ppm: Bumped version number to 0.05.
* MANIFEST: Added lib/Crypt/.cvsignore.
* lib/Crypt/.cvsignore: Initial revision.
* lib/Crypt/DES_PP.pod: Moved to DES_PP.ppm in top-level directory.
* DES_PP.ppm: Moved from lib/Crypt/DES_PP.pod here.
* test-xs: Initial revision.
* test.pl: Added benchmarks to run against XS version in CBC mode.
* Makefile.PL:
Changed suffix rule to a full rule for building lib/Crypt/DES_PP.pm.
* MANIFEST:
Moved lib/Crypt/DES_PP.pod to DES_PP.pm, renamed test-xs.pl to test-xs.
* test-xs.pl: Renamed to test-xs.
* lib/Crypt/DES_PP.pod: Bumped version number to 0.03.
=head1 DESCRIPTION
The Data Encryption Standard (DES), also known as Data Encryption
Algorithm (DEA) is a semi-strong encryption and decryption algorithm.
The module is 100 % compatible to Crypt::DES but is implemented
entirely in Perl. That means that you do not need a C compiler to
build and install this extension.
The module implements the Crypt::CBC interface. You are encouraged
to read the documentation for Crypt::CBC if you intend to use this
module for Cipher Block Chaining.
The minimum (and maximum) key size is 8 bytes. Shorter keys will
cause an exception, longer keys will get silently truncated. Data
is encrypted and decrypted in blocks of 8 bytes.
The module implements the Ultra-Fast-Crypt (UFC) algorithm as found
for example in the GNU libc. On the Perl side a lot has been done
in order to make the module as fast as possible (function inlining,
use integer, ...).
License (LGPL) version 2 or - at your choice - any later version,
see the file ``COPYING.LIB''.
The original C implementation of the Ultra-Fast-Crypt algorithm
was written by Michael Glad (glad@daimi.aau.dk) and has been donated to
the Free Software Foundation, Inc. It is covered by the GNU library
license version 2, see the file ``COPYING.LIB''.
=head1 SEE ALSO
Crypt::CBC(3), Crypt::DES(3), perl(1), m4(1).
=cut
Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
DESCRIPTION
The Data Encryption Standard (DES), also known as Data
Encryption Algorithm (DEA) is a semi-strong encryption and
decryption algorithm.
The module is 100 % compatible to Crypt::DES but is implemented
entirely in Perl. That means that you do not need a C compiler
to build and install this extension.
The module implements the Crypt::CBC interface. You are
encouraged to read the documentation for Crypt::CBC if you
intend to use this module for Cipher Block Chaining.
The minimum (and maximum) key size is 8 bytes. Shorter keys will
cause an exception, longer keys will get silently truncated.
Data is encrypted and decrypted in blocks of 8 bytes.
The module implements the Ultra-Fast-Crypt (UFC) algorithm as
found for example in the GNU libc. On the Perl side a lot has
been done in order to make the module as fast as possible
(function inlining, use integer, ...).
(guido@imperia.net). It is available under the terms of the
Lesser GNU General Public License (LGPL) version 2 or - at your
choice - any later version, see the file ``COPYING.LIB''.
The original C implementation of the Ultra-Fast-Crypt algorithm
was written by Michael Glad (glad@daimi.aau.dk) and has been
donated to the Free Software Foundation, Inc. It is covered by
the GNU library license version 2, see the file ``COPYING.LIB''.
SEE ALSO
Crypt::CBC(3), Crypt::DES(3), perl(1), m4(1).
lib/Crypt/DES_PP.pm view on Meta::CPAN
=head1 DESCRIPTION
The Data Encryption Standard (DES), also known as Data Encryption
Algorithm (DEA) is a semi-strong encryption and decryption algorithm.
The module is 100 % compatible to Crypt::DES but is implemented
entirely in Perl. That means that you do not need a C compiler to
build and install this extension.
The module implements the Crypt::CBC interface. You are encouraged
to read the documentation for Crypt::CBC if you intend to use this
module for Cipher Block Chaining.
The minimum (and maximum) key size is 8 bytes. Shorter keys will
cause an exception, longer keys will get silently truncated. Data
is encrypted and decrypted in blocks of 8 bytes.
The module implements the Ultra-Fast-Crypt (UFC) algorithm as found
for example in the GNU libc. On the Perl side a lot has been done
in order to make the module as fast as possible (function inlining,
use integer, ...).
lib/Crypt/DES_PP.pm view on Meta::CPAN
License (LGPL) version 2 or - at your choice - any later version,
see the file ``COPYING.LIB''.
The original C implementation of the Ultra-Fast-Crypt algorithm
was written by Michael Glad (glad@daimi.aau.dk) and has been donated to
the Free Software Foundation, Inc. It is covered by the GNU library
license version 2, see the file ``COPYING.LIB''.
=head1 SEE ALSO
Crypt::CBC(3), Crypt::DES(3), perl(1), m4(1).
=cut
Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
#! /usr/local/bin/perl -w
use strict;
use IO::File;
eval 'use Crypt::CBC 1.22';
print "1..2\n";
if ($@) {
print "ok # skipped in absence of Crypt::CBC 1.22 or higher\n"
x 2;
exit 0;
} else {
print "ok 1\n";
}
my $copying;
eval {
my $fh;
my $here = $0;
$fh = IO::File->new ("<$here/../COPYING.LIB")
or die;
$copying = <$fh>;
die unless defined $copying;
$fh->close;
my $key = 'Not very secret';
my $cipher;
$cipher = Crypt::CBC->new ($key, 'DES_PP')
or die;
my $result = $cipher->decrypt ($cipher->encrypt ($copying))
or die;
$result eq $copying or die;
};
print $@ ? "not ok 2\n" : "ok 2\n";
$cipher->decrypt($ciphertext);
}
my $t9 = new Benchmark;
my $td4 = timediff($t9,$t8);
my $ts4 = timestr($td4);
print "$ts4\nok 346\n";
}
}
print "\nTesting Cipher Block Chaining..\n";
eval 'use Crypt::CBC';
if(!$@) {
if($Crypt::CBC::VERSION < 1.22) {
$@ = "CBC mode requires Crypt::CBC version 1.22 or higher.";
} else {
my $cipher = new Crypt::CBC(pack("H*","0123456789ABCDEF"),"DES_PP");
my $ciphertext = $cipher->encrypt(pack("H*","37363534333231204E6F77206973207468652074696D6520666F722000"));
my $plaintext = $cipher->decrypt($ciphertext);
if($plaintext ne "7654321 Now is the time for \0") { print "not "; }
print "ok 347 - CBC Mode\n";
}
} # end no errors
if($@) {
print "Error (probably harmless):\n$@\n";
}
print "\nFinished with tests\n\n";
# Run in Cipher Block Chaining Mode.
use constant EIGHT_BYTE_BLOCKS => 20_000;
my $plaintext = PLAINTEXT x EIGHT_BYTE_BLOCKS;
my ($start, $end);
my $timediff = '';
my $des_driver = 'DES';
my $des_pp_driver = 'DES_PP';
# First pure Perl version.
print "Encrypting ", EIGHT_BYTE_BLOCKS << 3, " bytes in CBC mode...";
eval '
use Crypt::CBC;
my $cipher = Crypt::CBC->new (KEY, $des_pp_driver);
my $start = Benchmark->new;
$cipher->encrypt ($plaintext);
my $end = Benchmark->new;
$timediff = timestr timediff $end, $start;
';
print $@ ? " skipped (Crypt::CBC not loadable)\n" :
" done\n$timediff\n";
# Now the XS version.
print "XS-Version: Encrypting ", EIGHT_BYTE_BLOCKS << 3,
" bytes bytes in CBC mode...";
eval '
use Crypt::CBC;
my $cipher = Crypt::CBC->new (KEY, $des_driver);
my $start = Benchmark->new;
$cipher->encrypt ($plaintext);
my $end = Benchmark->new;
$timediff = timestr timediff $end, $start;
';
print $@ ? " skipped (Crypt::CBC or Crypt::DES not loadable)\n" :
" done\n$timediff\n";
$timediff = 0;
# Now with a non-cached key and 128 bytes of plaintext.
$plaintext = PLAINTEXT x 16;
print "Encrypting ", EIGHT_BYTE_BLOCKS,
" 128-byte-blocks in non-cached CBC mode...";
eval '
use Crypt::CBC;
my $start = Benchmark->new;
for (1 .. EIGHT_BYTE_BLOCKS >> 3) {
my $cipher = Crypt::CBC->new (KEY, $des_pp_driver);
$cipher->encrypt ($plaintext);
}
my $end = Benchmark->new;
$timediff = timestr timediff $end, $start;
';
print $@ ? " skipped (Crypt::CBC not loadable)\n" :
" done\n$timediff\n";
$timediff = 0;
$plaintext = PLAINTEXT x 16;
print "XS-Version: Encrypting ", EIGHT_BYTE_BLOCKS,
" 128-byte-blocks in non-cached CBC mode...";
eval '
use Crypt::CBC;
my $start = Benchmark->new;
for (1 .. EIGHT_BYTE_BLOCKS >> 3) {
my $cipher = Crypt::CBC->new (KEY, $des_driver);
$cipher->encrypt ($plaintext);
}
my $end = Benchmark->new;
$timediff = timestr timediff $end, $start;
';
print $@ ? " skipped (Crypt::CBC not loadable)\n" :
" done\n$timediff\n";
print "ok 1\n";
sub alarm_handler ($) {
my (undef, $endtime) = POSIX::times;
$elapsed = $endtime - $starttime;
die "alarm\n";
}
( run in 0.974 second using v1.01-cache-2.11-cpan-e1769b4cff6 )