Crypt-DES_EDE3-0.01/0040755000076400007640000000000007350547023013166 5ustar btrottusersCrypt-DES_EDE3-0.01/README0100644000076400007640000000131507350544722014046 0ustar btrottusers$Id: README,v 1.1.1.1 2001/09/15 03:24:02 btrott Exp $ This is Crypt::DES_EDE3, a module implementing Triple-DES EDE (encrypt-decrypt-encrypt) encryption and decryption. PREREQUISITES * Crypt::DES INSTALLATION Crypt::DES_EDE3 installation is straightforward. If your cpan shell is set up, you should just be able to do % perl -MCPAN -e 'install Crypt::DES_EDE3' If you don't like that, you can download the distribution; the latest version on CPAN can be found in ftp://ftp.cpan.org/pub/CPAN/authors/id/B/BT/BTROTT/ Download it, unpack it, then build it as per the usual: % perl Makefile.PL % make && make test Then install it: % make install Benjamin Trott / ben@rhumba.pair.com Crypt-DES_EDE3-0.01/Makefile.PL0100644000076400007640000000061007350544722015135 0ustar btrottusers# $Id: Makefile.PL,v 1.1.1.1 2001/09/15 03:24:02 btrott Exp $ use ExtUtils::MakeMaker; use strict; WriteMakefile( NAME => 'Crypt::DES_EDE3', DISTNAME => 'Crypt-DES_EDE3', VERSION_FROM => 'lib/Crypt/DES_EDE3.pm', AUTHOR => 'Benjamin Trott ', ABSTRACT => 'Triple-DES EDE encryption/decryption', PREREQ_PM => { 'Crypt::DES' => 0, }, ); Crypt-DES_EDE3-0.01/Changes0100644000076400007640000000031407350546777014473 0ustar btrottusers$Id: Changes,v 1.2 2001/09/15 03:41:51 btrott Exp $ Revision history for Crypt::DES_EDE3 0.01 2001.09.14 - Initial distribution, extracted from Crypt::OpenPGP and Convert::PEM distributions. Crypt-DES_EDE3-0.01/MANIFEST0100644000076400007640000000010207350547017014310 0ustar btrottusersChanges MANIFEST Makefile.PL README lib/Crypt/DES_EDE3.pm test.pl Crypt-DES_EDE3-0.01/test.pl0100644000076400007640000000110307350546460014476 0ustar btrottusers# $Id: test.pl,v 1.2 2001/09/15 03:38:24 btrott Exp $ use strict; use Test; use Crypt::DES_EDE3; use strict; BEGIN { plan tests => 7 } my $des = Crypt::DES_EDE3->new( pack 'H64', '0123456789ABCDEF' x 4 ); ok($des); ok($des->keysize, 24); my $enc = $des->encrypt( _checkbytes() ); ok($enc); my $dec = $des->decrypt($enc); ok($dec); ok( vec($dec, 0, 8) == vec($dec, 2, 8) ); ok( vec($dec, 1, 8) == vec($dec, 3, 8) ); ok( vec($dec, 5, 8) == 0 ); sub _checkbytes { my($check1, $check2) = (chr int rand 255, chr int rand 255); "$check1$check2$check1$check2\0\0\0\0"; } Crypt-DES_EDE3-0.01/lib/0040755000076400007640000000000007350547023013734 5ustar btrottusersCrypt-DES_EDE3-0.01/lib/Crypt/0040755000076400007640000000000007350547023015035 5ustar btrottusersCrypt-DES_EDE3-0.01/lib/Crypt/DES_EDE3.pm0100644000076400007640000000526707350546725016565 0ustar btrottusers# $Id: DES_EDE3.pm,v 1.2 2001/09/15 03:41:09 btrott Exp $ package Crypt::DES_EDE3; use strict; use Crypt::DES; use vars qw( $VERSION ); $VERSION = '0.01'; sub new { my $class = shift; my $ede3 = bless {}, $class; $ede3->init(@_); } sub keysize { 24 } sub blocksize { 8 } sub init { my $ede3 = shift; my($key) = @_; for my $i (1..3) { $ede3->{"des$i"} = Crypt::DES->new(substr $key, 8*($i-1), 8); } $ede3; } sub encrypt { my($ede3, $block) = @_; $ede3->{des3}->encrypt( $ede3->{des2}->decrypt( $ede3->{des1}->encrypt($block) ) ); } sub decrypt { my($ede3, $block) = @_; $ede3->{des1}->decrypt( $ede3->{des2}->encrypt( $ede3->{des3}->decrypt($block) ) ); } 1; __END__ =head1 NAME Crypt::DES_EDE3 - Triple-DES EDE encryption/decryption =head1 SYNOPSIS use Crypt::DES_EDE3; my $ede3 = Crypt::DES_EDE3->new($key); $ede3->encrypt($block); =head1 DESCRIPTION I implements DES-EDE3 encryption. This is triple-DES encryption where an encrypt operation is encrypt-decrypt-encrypt, and decrypt is decrypt-encrypt-decrypt. This implementation uses I to do its dirty DES work, and simply provides a wrapper around that module: setting up the individual DES ciphers, initializing the keys, and performing the encryption/decryption steps. DES-EDE3 encryption requires a key size of 24 bytes. You're probably best off not using this module directly, as the I and I methods expect 8-octet blocks. You might want to use the module in conjunction with I, for example. This would be DES-EDE3-CBC, or triple-DES in outer CBC mode. =head1 USAGE =head2 $ede3 = Crypt::DES_EDE3->new($key) Creates a new I object (really, a collection of three DES ciphers), and initializes each cipher with part of I<$key>, which should be at least 24 bytes. If it's longer than 24 bytes, the extra bytes will be ignored. Returns the new object. =head2 $ede3->encrypt($block) Encrypts an 8-byte block of data I<$block> using the three DES ciphers in an encrypt-decrypt-encrypt operation. Returns the encrypted block. =head2 $ede3->decrypt($block) Decrypts an 8-byte block of data I<$block> using the three DES ciphers in a decrypt-encrypt-decrypt operation. Returns the decrypted block. =head2 $ede3->blocksize Returns the block size (8). =head2 $ede3->keysize Returns the key size (24). =head1 LICENSE Crypt::DES_EDE3 is free software; you may redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR & COPYRIGHTS Crypt::DES_EDE3 is Copyright 2001 Benjamin Trott, ben@rhumba.pair.com. All rights reserved. =cut