Crypt-Blowfish-2.14/0000755000175000017500000000000012173566160012461 5ustar dspdspCrypt-Blowfish-2.14/MANIFEST0000644000175000017500000000027410344040650013602 0ustar dspdspCOPYRIGHT Blowfish.pm Blowfish.xs MANIFEST README Changes Makefile.PL _blowfish.c blowfish.h test.pl typemap META.yml Module meta-data (added by MakeMaker) Crypt-Blowfish-2.14/Changes0000644000175000017500000000340012173566140013747 0ustar dspdspRevision history for Perl extension Crypt::Blowfish. 2.14 23 Jul 2013 - quick mod to keep META.yml current 2.13 23 Jul 2013 - updated SvUPGRADE to a statement - patched for WIN64 2.12 04 Mar 2010 - updated Changes to mesh with revision. 2.11 Feb 2010 - patched _blowfish.c to stop spurious warnings. - updated POD 2.10 Fri Dec 02 07:36:18 EST 2005 - updated the README file to remove the reference to CBC_R - no longer available. - updated the README file to include performance results for G4/1.2GHz PPC Mac OS X 10.4.X 2.09 Tue Nov 13 01:28:26 EST 2001 - changed keysize back to 0 apparently setting keysize to 8 triggered a bad hack in Crypt::CBC which resulted in OpenSRS breaking. the "bad hack" in question is: $ks = $cipher =~ /blowfish/i ? 56 : 8 unless $ks > 0; ... anyway.. fixed. 2.08 Tue Oct 30 23:29:25 EST 2001 - added two new functions: min_keysize and max_keysize these allow modules like Crypt::CBC_IL and Crypt::CBC_R to use variable key lengths with CBC modes. - cleaned up test.pl - updated README 2.07 Thu Nov 30 02:59:29 EST 2000 - minor change in XS - additions to reported platforms 2.06 Tue Jul 04 15:35:34 EST 2000 - Win32 tested using VC++5.0, all tests passed on NT4/SP5 2.05 Tue Jul 04 14:42:13 EST 2000 - non-public - code-cleanup - initial Win32 support 2.04 Wed May 17 21:42:54 EST 2000 - non-public - code cleanup 2.03 Tue Feb 29 17:19:48 EST 2000 - added small patch from LDS to Blowfish.xs 2.02 Sun Feb 13 21:49:58 EST 2000 - added speed tests, fixed HP-UX functionality - cleaned up code - added README 2.01 Fri Feb 11 19:35:27 EST 2000 - solidified XS support and extracted from original package. 2.00 Sun Sep 5 21:07:48 EST 1999 - original version; created by h2xs 1.19 Crypt-Blowfish-2.14/README0000644000175000017500000001653711336310231013337 0ustar dspdspThis is Crypt::Blowfish version 2.11, an XS-based implementation of the Blowfish cryptography algorithm designed by Bruce Schneier. It's designed to take full advantage of Crypt::CBC when desired. Blowfish keys may be up to 448 bits (56 bytes) long. This module builds on nearly every platform that Perl itself does (see Notes for exceptions). Prerequisites ------------- For the full test suite to run, Crypt::CBC, version 1.22 or higher is required (recommended is 1.25 or higher), however this module is not mandatory for standalone Blowfish use. Installing Crypt::Blowfish -------------------------- nothing unusual: 1. perl Makefile.PL 2. make 3. make test 4. make install Notes ----- This module has been tested successfully against the following: Linux 2.0.X (x86) Linux 2.2.X (x86, PPC, Alpha, m68k) Linux 2.4.X (x86) Solaris 2.5.1 and 2.7 (SPARC) FreeBSD 3.3 and 3.4 (x86), 4.0 (alpha) HP-UX B.10.20 DEC OSF 5.0 AIX spbuild 3 4 Win32 (NT4/SP5, using VC++5.0/VC++6.0) OpenVMS (DEC C V6.0-001 / Alpha V7.1-2 with MMK make utility) Mac OS X 10.4.X Perl 5.004_01, 5.004_04, 5.005_03, 5.6.0, 5.6.1, 5.8.* Please send other successful OS/platform combinations to: amused@pobox.com . Thanks. Patches for MacOS welcomed. Being an XS implimentation, Crypt::Blowfish is exceptionally faster than Blowfish_PP (a pure Perl implimentation). Internal testing displayed a difference of 400 times faster when doing complete cipher generation and encryption. Using a cached cipher resulted in 25 times faster than the pure Perl implimentation. (all machines idled prior to tests below) In the case where this module won't build for you, please try the Crypt::Blowfish_PP module - the Pure Perl implimentation. Thanks to Thomas Kratz for the Win32 fixup and VMS report. Thanks to Sandro Bonazzola for prompting code cleanup. Performance ----------- Typical results on a P4 3.0GHz Linux machine: Under: Perl-v5.10.0: Running standard mode speed tests.. encrypting with non-cached cipher 5,000 cycles: 0 wallclock secs ( 0.36 usr + 0.00 sys = 0.36 CPU) Running standard mode speed tests.. decrypting with non-cached cipher 5,000 cycles: 1 wallclock secs ( 0.35 usr + 0.00 sys = 0.35 CPU) Running standard mode speed tests.. encrypting with cached cipher 10,000 cycles: 0 wallclock secs ( 0.05 usr + 0.00 sys = 0.05 CPU) Running standard mode speed tests.. decrypting with cached cipher 10,000 cycles: 0 wallclock secs ( 0.04 usr + 0.00 sys = 0.04 CPU) Typical results on a PII-400 Linux machine: Under Perl-5.005_03: Running standard mode speed tests.. encrypting with non-cached cipher 5,000 cycles: 4 wallclock secs ( 3.92 usr + 0.03 sys = 3.95 CPU) Running standard mode speed tests.. decrypting with non-cached cipher 5,000 cycles: 4 wallclock secs ( 3.96 usr + 0.01 sys = 3.97 CPU) Running standard mode speed tests.. encrypting with cached cipher 10,000 cycles: 0 wallclock secs ( 0.22 usr + 0.00 sys = 0.22 CPU) Running standard mode speed tests.. decrypting with cached cipher 10,000 cycles: 1 wallclock secs ( 0.21 usr + 0.00 sys = 0.21 CPU) Typical results from a 270Mhz UltraSPARC IIi (Ultra5 workstation) Under Perl-5.005_03 Running standard mode speed tests.. encrypting with non-cached cipher 5,000 cycles: 5 wallclock secs ( 4.05 usr + 0.11 sys = 4.16 CPU) Running standard mode speed tests.. decrypting with non-cached cipher 5,000 cycles: 4 wallclock secs ( 4.06 usr + 0.12 sys = 4.18 CPU) Running standard mode speed tests.. encrypting with cached cipher 10,000 cycles: 0 wallclock secs ( 0.60 usr + 0.00 sys = 0.60 CPU) Running standard mode speed tests.. decrypting with cached cipher 10,000 cycles: 1 wallclock secs ( 0.63 usr + 0.00 sys = 0.63 CPU) Typical results from a PIII-550 Linux machine: Under Perl-5.005_03 Running standard mode speed tests.. encrypting with non-cached cipher 5,000 cycles: 3 wallclock secs ( 2.95 usr + 0.00 sys = 2.95 CPU) Running standard mode speed tests.. decrypting with non-cached cipher 5,000 cycles: 3 wallclock secs ( 2.93 usr + 0.00 sys = 2.93 CPU) Running standard mode speed tests.. encrypting with cached cipher 10,000 cycles: 0 wallclock secs ( 0.17 usr + 0.00 sys = 0.17 CPU) Running standard mode speed tests.. decrypting with cached cipher 10,000 cycles: 0 wallclock secs ( 0.16 usr + 0.00 sys = 0.16 CPU) Typical results from AIX machine: Under Perl-5.004_01 Running standard mode speed tests.. encrypting with non-cached cipher 5,000 cycles: 13 secs (11.77 usr 0.08 sys = 11.85 cpu) Running standard mode speed tests.. decrypting with non-cached cipher 5,000 cycles: 19 secs (11.98 usr 0.04 sys = 12.02 cpu) Running standard mode speed tests.. encrypting with cached cipher 10,000 cycles: 2 secs ( 1.11 usr 0.00 sys = 1.11 cpu) Running standard mode speed tests.. decrypting with cached cipher 10,000 cycles: 1 secs ( 1.04 usr 0.00 sys = 1.04 cpu) Typical results for Alpha PCA56 (533Mhz) Linux machine: Under Perl-5.005_03 Running standard mode speed tests.. encrypting with non-cached cipher 5,000 cycles: 3 wallclock secs ( 2.68 usr + 0.01 sys = 2.69 CPU) Running standard mode speed tests.. decrypting with non-cached cipher 5,000 cycles: 3 wallclock secs ( 2.71 usr + 0.01 sys = 2.73 CPU) Running standard mode speed tests.. encrypting with cached cipher 10,000 cycles: 0 wallclock secs ( 0.52 usr + 0.00 sys = 0.52 CPU) Running standard mode speed tests.. decrypting with cached cipher 10,000 cycles: 1 wallclock secs ( 0.58 usr + 0.00 sys = 0.58 CPU) Typical results for m68k (33Mhz 68040) Linux machine: Under Perl-5.005_03 Running standard mode speed tests.. encrypting with non-cached cipher 5,000 cycles: 104 wallclock secs (97.26 usr + 2.50 sys = 99.76 CPU) Running standard mode speed tests.. decrypting with non-cached cipher 5,000 cycles: 102 wallclock secs (97.37 usr + 1.77 sys = 99.14 CPU) Running standard mode speed tests.. encrypting with cached cipher 10,000 cycles: 8 wallclock secs ( 7.20 usr + 0.09 sys = 7.29 CPU) Running standard mode speed tests.. decrypting with cached cipher 10,000 cycles: 7 wallclock secs ( 7.37 usr + 0.04 sys = 7.41 CPU) Typical results for x86/PPro (dual 200Mhz PPro) Windows machine: Under Perl-5.005_02 Running standard mode speed tests.. encrypting with non-cached cipher 5,000 cycles: 8 wallclock secs ( 8.27 usr + 0.00 sys = 8.27 CPU) Running standard mode speed tests.. decrypting with non-cached cipher 5,000 cycles: 9 wallclock secs ( 8.25 usr + 0.00 sys = 8.25 CPU) Running standard mode speed tests.. encrypting with cached cipher 10,000 cycles: 0 wallclock secs ( 0.69 usr + 0.00 sys = 0.69 CPU) Running standard mode speed tests.. decrypting with cached cipher 10,000 cycles: 1 wallclock secs ( 0.69 usr + 0.00 sys = 0.69 CPU) Typical results for G4/1.2Ghz Mac OS X 10.4.X iBook: Under Perl-5.8.6 built for darwin-thread-multi-2level Running standard mode speed tests.. encrypting with non-cached cipher 5,000 cycles: 1 wallclock secs ( 0.60 usr + 0.00 sys = 0.60 CPU) Running standard mode speed tests.. decrypting with non-cached cipher 5,000 cycles: 0 wallclock secs ( 0.59 usr + 0.01 sys = 0.60 CPU) Running standard mode speed tests.. encrypting with cached cipher 10,000 cycles: 0 wallclock secs ( 0.11 usr + 0.00 sys = 0.11 CPU) Running standard mode speed tests.. decrypting with cached cipher 10,000 cycles: 1 wallclock secs ( 0.10 usr + 0.00 sys = 0.10 CPU) Dave Paris - W3Works, LLC Crypt-Blowfish-2.14/test.pl0000644000175000017500000001524507213651174014003 0ustar dspdspBEGIN { push @INC, qw(. .. ../lib ../../lib ../../../lib) } package Crypt::Blowfish; require Exporter; require DynaLoader; @ISA = (Exporter, DynaLoader); bootstrap Crypt::Blowfish; use Benchmark qw(timediff timestr); use strict; use Carp; sub usage { my ($package, $filename, $line, $subr) = caller(1); $Carp::CarpLevel = 2; croak "Usage: $subr(@_)"; } sub blocksize { 8; } sub keysize { 56; } sub new { usage("new Blowfish key") unless @_ == 2; my $type = shift; my $self = {}; bless $self, $type; $self->{'ks'} = Crypt::Blowfish::init(shift); $self; } sub encrypt { usage("encrypt data[8 bytes]") unless @_ == 2; my $self = shift; my $data = shift; Crypt::Blowfish::crypt($data, $data, $self->{'ks'}, 0); $data; } sub decrypt { usage("decrypt data[8 bytes]") unless @_ == 2; my $self = shift; my $data = shift; Crypt::Blowfish::crypt($data, $data, $self->{'ks'}, 1); $data; } package main; # # '6162636465666768696a6b6c6d6e6f707172737475767778797a', # '424c4f5746495348', '324ed0fef413a203', # # '57686f206973204a6f686e2047616c743f', 'fedcba9876543210', 'cc91732b8022f684') # # "Ayn Rand" FEDCBA9876543210 e113f4102cfcce43 # print "1..11\n"; my $key = pack("H*", "6162636465666768696a6b6c6d6e6f707172737475767778797a"); my $in = pack("H*", "424c4f5746495348"); my $out = pack("H*", "324ed0fef413a203"); my $cipher = new Crypt::Blowfish $key; print "not " unless ($cipher->encrypt($in) eq $out); print "ok 1\n"; my $key = pack("H*", "57686f206973204a6f686e2047616c743f"); my $in = pack("H*", "fedcba9876543210"); my $out = pack("H*", "cc91732b8022f684"); my $cipher = new Crypt::Blowfish $key; print "not " unless ($cipher->decrypt($out) eq $in); print "ok 2\n"; my $key = "Ayn Rand"; substr($key, 3, 1) = pack("C", ord(substr($key, 3, 1))+128); substr($key, 7, 1) = pack("C", ord(substr($key, 7, 1))+128); my $in = pack("H*", "fedcba9876543210"); my $out = pack("H*", "e113f4102cfcce43"); my $cipher = new Crypt::Blowfish $key; print "not " unless ($cipher->encrypt($in) eq $out); print "ok 3\n"; my $key = pack("H*", "0000000000000000"); my $in = pack("H*", "0000000000000000"); my $out = pack("H*", "4EF997456198DD78"); my $cipher = new Crypt::Blowfish $key; print "not " unless($cipher->encrypt($in) eq $out); print "ok 4\n"; my $key = pack("H*", "FFFFFFFFFFFFFFFF"); my $in = pack("H*", "0000000000000000"); my $out = pack("H*", "F21E9A77B71C49BC"); my $cipher = new Crypt::Blowfish $key; print "not " unless ($cipher->decrypt($out) eq $in); print "ok 5\n"; my $key = pack("H*", "FFFFFFFFFFFFFFFF"); my $in = pack("H*", "FFFFFFFFFFFFFFFF"); my $out = pack("H*", "51866FD5B85ECB8A"); my $cipher = new Crypt::Blowfish $key; print "not " unless ($cipher->encrypt($in) eq $out); print "ok 6\n"; my $key = pack("H*", "3000000000000000"); my $in = pack("H*", "1000000000000001"); my $out = pack("H*", "7D856F9A613063F2"); my $cipher = new Crypt::Blowfish $key; print "not " unless ($cipher->encrypt($in) eq $out); print "ok 7\n"; my $key = pack("H*", "1111111111111111"); my $in = pack("H*", "1111111111111111"); my $out = pack("H*", "2466DD878B963C9D"); my $cipher = new Crypt::Blowfish $key; print "not " unless ($cipher->encrypt($in) eq $out); print "ok 8\n"; my $key = pack("H*", "584023641ABA6176"); my $in = pack("H*", "004BD6EF09176062"); my $out = pack("H*", "452031C1E4FADA8E"); my $cipher = new Crypt::Blowfish $key; print "not " unless ($cipher->encrypt($in) eq $out); print "ok 9\n"; my $key = pack("H*", "0101010101010101"); my $in = pack("H*", "0123456789ABCDEF"); my $out = pack("H*", "FA34EC4847B268B2"); my $cipher = new Crypt::Blowfish $key; print "not " unless ($cipher->encrypt($in) eq $out); print "ok 10\n"; { print "\nRunning standard mode speed tests.. encrypting with non-cached cipher\n"; my $t0 = new Benchmark; for(1..5000){ my $key = pack("H*", "0101010101010101"); my $in = pack("H*", "0123456789ABCDEF"); my $out = pack("H*", "FA34EC4847B268B2"); my $cipher = new Crypt::Blowfish $key; $cipher->encrypt($in); } my $t1 = new Benchmark; my $td = Benchmark::timediff($t1,$t0); my $ts = Benchmark::timestr($td); print "5,000 cycles: $ts\n"; }; # end standard mode (encrypt) speed test non-cached cipher { print "\nRunning standard mode speed tests.. decrypting with non-cached cipher\n"; my $t0 = new Benchmark; for(1..5000){ my $key = pack("H*", "0101010101010101"); my $in = pack("H*", "0123456789ABCDEF"); my $out = pack("H*", "FA34EC4847B268B2"); my $cipher = new Crypt::Blowfish $key; $cipher->decrypt($out); } my $t1 = new Benchmark; my $td = Benchmark::timediff($t1,$t0); my $ts = Benchmark::timestr($td); print "5,000 cycles: $ts\n"; }; # end standard mode (decrypt) speed test non-cached cipher my $key = pack("H*", "0101010101010101"); my $cipher = new Crypt::Blowfish $key; { print "\nRunning standard mode speed tests.. encrypting with cached cipher\n"; my $t0 = new Benchmark; for(1..10000){ my $in = pack("H*", "0123456789ABCDEF"); my $out = pack("H*", "FA34EC4847B268B2"); $cipher->encrypt($in); } my $t1 = new Benchmark; my $td = Benchmark::timediff($t1,$t0); my $ts = Benchmark::timestr($td); print "10,000 cycles: $ts\n"; }; # end standard mode (encrypt) speed test cached cipher { print "\nRunning standard mode speed tests.. decrypting with cached cipher\n"; my $t0 = new Benchmark; for(1..10000){ my $in = pack("H*", "0123456789ABCDEF"); my $out = pack("H*", "FA34EC4847B268B2"); $cipher->decrypt($out); } my $t1 = new Benchmark; my $td = Benchmark::timediff($t1,$t0); my $ts = Benchmark::timestr($td); print "10,000 cycles: $ts\n"; }; # end standard mode (decrypt) speed test cached cipher 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*","0123456789ABCDEFF0E1D2C3B4A59687"),"Blowfish"); my $ciphertext = $cipher->encrypt(pack("H*","37363534333231204E6F77206973207468652074696D6520666F722000")); my $plaintext = $cipher->decrypt($ciphertext); if($plaintext eq "7654321 Now is the time for \0") { print "ok 11 - CBC Mode\n"; } else { print unpack("H*",$plaintext) . " :decrypted\n"; print unpack("H*","7654321 Now is the time for \0") . " :orig\n"; print "not ok 11 - CBC Mode failed\n"; } } } # end no errors if($@) { print "Error (probably harmless):\n$@\n"; } Crypt-Blowfish-2.14/blowfish.h0000644000175000017500000000034307051223464014443 0ustar dspdsp#include typedef unsigned char bf_cblock[8]; int blowfish_make_bfkey(char * key_string, int keylength, char * bfkey); void blowfish_crypt_8bytes(bf_cblock source, bf_cblock dest, char * bfkey, short direction); Crypt-Blowfish-2.14/Makefile.PL0000644000175000017500000000055007130427322014424 0ustar dspdsp#! /usr/local/bin/perl use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile being created. WriteMakefile( 'NAME' => 'Crypt::Blowfish', 'DISTNAME' => 'Crypt-Blowfish', 'VERSION_FROM' => 'Blowfish.pm', 'OBJECT' => 'Blowfish.o _blowfish.o', 'dist' => {COMPRESS=>'gzip', SUFFIX=>'gz'} ); Crypt-Blowfish-2.14/_blowfish.c0000644000175000017500000005031512173522327014602 0ustar dspdsp /* * blowfish.c : Source code for the Blowfish block cipher * * Part of the Python Cryptography Toolkit, version 1.0.0 * * Copyright (C) 1995, A.M. Kuchling * * Distribute and use freely; there are no restrictions on further * dissemination and usage except those imposed by the laws of your * country of residence. * */ /*************************************************************************/ /* File: bf.c Blowfish cipher by Bruce Schneier, Code by Bryan Olson, based partly on Schneier's. Improvements and ongoing mantenance by Dave Paris */ #include /* Define IntU32 to be an unsigned in 32 bits long */ typedef unsigned int IntU32 ; typedef unsigned char IntU8 ; #define NROUNDS 16 /* Define IntP to be an integer which is the same size as a pointer. */ #ifdef _WIN64 typedef unsigned long long IntP ; #else typedef unsigned long IntP ; #endif typedef struct { IntU32 p[2][NROUNDS+2], sbox[4][256] ; } BFkey_type ; /* File bfinit.h Data to initialize P and S in BlowFish. */ static IntU32 p_init[NROUNDS+2] = { 608135816UL, 2242054355UL, 320440878UL, 57701188UL, 2752067618UL, 698298832UL, 137296536UL, 3964562569UL, 1160258022UL, 953160567UL, 3193202383UL, 887688300UL, 3232508343UL, 3380367581UL, 1065670069UL, 3041331479UL, 2450970073UL, 2306472731UL } ; static IntU32 s_init[4][256] = { {3509652390UL, 2564797868UL, 805139163UL, 3491422135UL, 3101798381UL, 1780907670UL, 3128725573UL, 4046225305UL, 614570311UL, 3012652279UL, 134345442UL, 2240740374UL, 1667834072UL, 1901547113UL, 2757295779UL, 4103290238UL, 227898511UL, 1921955416UL, 1904987480UL, 2182433518UL, 2069144605UL, 3260701109UL, 2620446009UL, 720527379UL, 3318853667UL, 677414384UL, 3393288472UL, 3101374703UL, 2390351024UL, 1614419982UL, 1822297739UL, 2954791486UL, 3608508353UL, 3174124327UL, 2024746970UL, 1432378464UL, 3864339955UL, 2857741204UL, 1464375394UL, 1676153920UL, 1439316330UL, 715854006UL, 3033291828UL, 289532110UL, 2706671279UL, 2087905683UL, 3018724369UL, 1668267050UL, 732546397UL, 1947742710UL, 3462151702UL, 2609353502UL, 2950085171UL, 1814351708UL, 2050118529UL, 680887927UL, 999245976UL, 1800124847UL, 3300911131UL, 1713906067UL, 1641548236UL, 4213287313UL, 1216130144UL, 1575780402UL, 4018429277UL, 3917837745UL, 3693486850UL, 3949271944UL, 596196993UL, 3549867205UL, 258830323UL, 2213823033UL, 772490370UL, 2760122372UL, 1774776394UL, 2652871518UL, 566650946UL, 4142492826UL, 1728879713UL, 2882767088UL, 1783734482UL, 3629395816UL, 2517608232UL, 2874225571UL, 1861159788UL, 326777828UL, 3124490320UL, 2130389656UL, 2716951837UL, 967770486UL, 1724537150UL, 2185432712UL, 2364442137UL, 1164943284UL, 2105845187UL, 998989502UL, 3765401048UL, 2244026483UL, 1075463327UL, 1455516326UL, 1322494562UL, 910128902UL, 469688178UL, 1117454909UL, 936433444UL, 3490320968UL, 3675253459UL, 1240580251UL, 122909385UL, 2157517691UL, 634681816UL, 4142456567UL, 3825094682UL, 3061402683UL, 2540495037UL, 79693498UL, 3249098678UL, 1084186820UL, 1583128258UL, 426386531UL, 1761308591UL, 1047286709UL, 322548459UL, 995290223UL, 1845252383UL, 2603652396UL, 3431023940UL, 2942221577UL, 3202600964UL, 3727903485UL, 1712269319UL, 422464435UL, 3234572375UL, 1170764815UL, 3523960633UL, 3117677531UL, 1434042557UL, 442511882UL, 3600875718UL, 1076654713UL, 1738483198UL, 4213154764UL, 2393238008UL, 3677496056UL, 1014306527UL, 4251020053UL, 793779912UL, 2902807211UL, 842905082UL, 4246964064UL, 1395751752UL, 1040244610UL, 2656851899UL, 3396308128UL, 445077038UL, 3742853595UL, 3577915638UL, 679411651UL, 2892444358UL, 2354009459UL, 1767581616UL, 3150600392UL, 3791627101UL, 3102740896UL, 284835224UL, 4246832056UL, 1258075500UL, 768725851UL, 2589189241UL, 3069724005UL, 3532540348UL, 1274779536UL, 3789419226UL, 2764799539UL, 1660621633UL, 3471099624UL, 4011903706UL, 913787905UL, 3497959166UL, 737222580UL, 2514213453UL, 2928710040UL, 3937242737UL, 1804850592UL, 3499020752UL, 2949064160UL, 2386320175UL, 2390070455UL, 2415321851UL, 4061277028UL, 2290661394UL, 2416832540UL, 1336762016UL, 1754252060UL, 3520065937UL, 3014181293UL, 791618072UL, 3188594551UL, 3933548030UL, 2332172193UL, 3852520463UL, 3043980520UL, 413987798UL, 3465142937UL, 3030929376UL, 4245938359UL, 2093235073UL, 3534596313UL, 375366246UL, 2157278981UL, 2479649556UL, 555357303UL, 3870105701UL, 2008414854UL, 3344188149UL, 4221384143UL, 3956125452UL, 2067696032UL, 3594591187UL, 2921233993UL, 2428461UL, 544322398UL, 577241275UL, 1471733935UL, 610547355UL, 4027169054UL, 1432588573UL, 1507829418UL, 2025931657UL, 3646575487UL, 545086370UL, 48609733UL, 2200306550UL, 1653985193UL, 298326376UL, 1316178497UL, 3007786442UL, 2064951626UL, 458293330UL, 2589141269UL, 3591329599UL, 3164325604UL, 727753846UL, 2179363840UL, 146436021UL, 1461446943UL, 4069977195UL, 705550613UL, 3059967265UL, 3887724982UL, 4281599278UL, 3313849956UL, 1404054877UL, 2845806497UL, 146425753UL, 1854211946UL}, { 1266315497UL, 3048417604UL, 3681880366UL, 3289982499UL, 2909710000UL, 1235738493UL, 2632868024UL, 2414719590UL, 3970600049UL, 1771706367UL, 1449415276UL, 3266420449UL, 422970021UL, 1963543593UL, 2690192192UL, 3826793022UL, 1062508698UL, 1531092325UL, 1804592342UL, 2583117782UL, 2714934279UL, 4024971509UL, 1294809318UL, 4028980673UL, 1289560198UL, 2221992742UL, 1669523910UL, 35572830UL, 157838143UL, 1052438473UL, 1016535060UL, 1802137761UL, 1753167236UL, 1386275462UL, 3080475397UL, 2857371447UL, 1040679964UL, 2145300060UL, 2390574316UL, 1461121720UL, 2956646967UL, 4031777805UL, 4028374788UL, 33600511UL, 2920084762UL, 1018524850UL, 629373528UL, 3691585981UL, 3515945977UL, 2091462646UL, 2486323059UL, 586499841UL, 988145025UL, 935516892UL, 3367335476UL, 2599673255UL, 2839830854UL, 265290510UL, 3972581182UL, 2759138881UL, 3795373465UL, 1005194799UL, 847297441UL, 406762289UL, 1314163512UL, 1332590856UL, 1866599683UL, 4127851711UL, 750260880UL, 613907577UL, 1450815602UL, 3165620655UL, 3734664991UL, 3650291728UL, 3012275730UL, 3704569646UL, 1427272223UL, 778793252UL, 1343938022UL, 2676280711UL, 2052605720UL, 1946737175UL, 3164576444UL, 3914038668UL, 3967478842UL, 3682934266UL, 1661551462UL, 3294938066UL, 4011595847UL, 840292616UL, 3712170807UL, 616741398UL, 312560963UL, 711312465UL, 1351876610UL, 322626781UL, 1910503582UL, 271666773UL, 2175563734UL, 1594956187UL, 70604529UL, 3617834859UL, 1007753275UL, 1495573769UL, 4069517037UL, 2549218298UL, 2663038764UL, 504708206UL, 2263041392UL, 3941167025UL, 2249088522UL, 1514023603UL, 1998579484UL, 1312622330UL, 694541497UL, 2582060303UL, 2151582166UL, 1382467621UL, 776784248UL, 2618340202UL, 3323268794UL, 2497899128UL, 2784771155UL, 503983604UL, 4076293799UL, 907881277UL, 423175695UL, 432175456UL, 1378068232UL, 4145222326UL, 3954048622UL, 3938656102UL, 3820766613UL, 2793130115UL, 2977904593UL, 26017576UL, 3274890735UL, 3194772133UL, 1700274565UL, 1756076034UL, 4006520079UL, 3677328699UL, 720338349UL, 1533947780UL, 354530856UL, 688349552UL, 3973924725UL, 1637815568UL, 332179504UL, 3949051286UL, 53804574UL, 2852348879UL, 3044236432UL, 1282449977UL, 3583942155UL, 3416972820UL, 4006381244UL, 1617046695UL, 2628476075UL, 3002303598UL, 1686838959UL, 431878346UL, 2686675385UL, 1700445008UL, 1080580658UL, 1009431731UL, 832498133UL, 3223435511UL, 2605976345UL, 2271191193UL, 2516031870UL, 1648197032UL, 4164389018UL, 2548247927UL, 300782431UL, 375919233UL, 238389289UL, 3353747414UL, 2531188641UL, 2019080857UL, 1475708069UL, 455242339UL, 2609103871UL, 448939670UL, 3451063019UL, 1395535956UL, 2413381860UL, 1841049896UL, 1491858159UL, 885456874UL, 4264095073UL, 4001119347UL, 1565136089UL, 3898914787UL, 1108368660UL, 540939232UL, 1173283510UL, 2745871338UL, 3681308437UL, 4207628240UL, 3343053890UL, 4016749493UL, 1699691293UL, 1103962373UL, 3625875870UL, 2256883143UL, 3830138730UL, 1031889488UL, 3479347698UL, 1535977030UL, 4236805024UL, 3251091107UL, 2132092099UL, 1774941330UL, 1199868427UL, 1452454533UL, 157007616UL, 2904115357UL, 342012276UL, 595725824UL, 1480756522UL, 206960106UL, 497939518UL, 591360097UL, 863170706UL, 2375253569UL, 3596610801UL, 1814182875UL, 2094937945UL, 3421402208UL, 1082520231UL, 3463918190UL, 2785509508UL, 435703966UL, 3908032597UL, 1641649973UL, 2842273706UL, 3305899714UL, 1510255612UL, 2148256476UL, 2655287854UL, 3276092548UL, 4258621189UL, 236887753UL, 3681803219UL, 274041037UL, 1734335097UL, 3815195456UL, 3317970021UL, 1899903192UL, 1026095262UL, 4050517792UL, 356393447UL, 2410691914UL, 3873677099UL, 3682840055UL}, { 3913112168UL, 2491498743UL, 4132185628UL, 2489919796UL, 1091903735UL, 1979897079UL, 3170134830UL, 3567386728UL, 3557303409UL, 857797738UL, 1136121015UL, 1342202287UL, 507115054UL, 2535736646UL, 337727348UL, 3213592640UL, 1301675037UL, 2528481711UL, 1895095763UL, 1721773893UL, 3216771564UL, 62756741UL, 2142006736UL, 835421444UL, 2531993523UL, 1442658625UL, 3659876326UL, 2882144922UL, 676362277UL, 1392781812UL, 170690266UL, 3921047035UL, 1759253602UL, 3611846912UL, 1745797284UL, 664899054UL, 1329594018UL, 3901205900UL, 3045908486UL, 2062866102UL, 2865634940UL, 3543621612UL, 3464012697UL, 1080764994UL, 553557557UL, 3656615353UL, 3996768171UL, 991055499UL, 499776247UL, 1265440854UL, 648242737UL, 3940784050UL, 980351604UL, 3713745714UL, 1749149687UL, 3396870395UL, 4211799374UL, 3640570775UL, 1161844396UL, 3125318951UL, 1431517754UL, 545492359UL, 4268468663UL, 3499529547UL, 1437099964UL, 2702547544UL, 3433638243UL, 2581715763UL, 2787789398UL, 1060185593UL, 1593081372UL, 2418618748UL, 4260947970UL, 69676912UL, 2159744348UL, 86519011UL, 2512459080UL, 3838209314UL, 1220612927UL, 3339683548UL, 133810670UL, 1090789135UL, 1078426020UL, 1569222167UL, 845107691UL, 3583754449UL, 4072456591UL, 1091646820UL, 628848692UL, 1613405280UL, 3757631651UL, 526609435UL, 236106946UL, 48312990UL, 2942717905UL, 3402727701UL, 1797494240UL, 859738849UL, 992217954UL, 4005476642UL, 2243076622UL, 3870952857UL, 3732016268UL, 765654824UL, 3490871365UL, 2511836413UL, 1685915746UL, 3888969200UL, 1414112111UL, 2273134842UL, 3281911079UL, 4080962846UL, 172450625UL, 2569994100UL, 980381355UL, 4109958455UL, 2819808352UL, 2716589560UL, 2568741196UL, 3681446669UL, 3329971472UL, 1835478071UL, 660984891UL, 3704678404UL, 4045999559UL, 3422617507UL, 3040415634UL, 1762651403UL, 1719377915UL, 3470491036UL, 2693910283UL, 3642056355UL, 3138596744UL, 1364962596UL, 2073328063UL, 1983633131UL, 926494387UL, 3423689081UL, 2150032023UL, 4096667949UL, 1749200295UL, 3328846651UL, 309677260UL, 2016342300UL, 1779581495UL, 3079819751UL, 111262694UL, 1274766160UL, 443224088UL, 298511866UL, 1025883608UL, 3806446537UL, 1145181785UL, 168956806UL, 3641502830UL, 3584813610UL, 1689216846UL, 3666258015UL, 3200248200UL, 1692713982UL, 2646376535UL, 4042768518UL, 1618508792UL, 1610833997UL, 3523052358UL, 4130873264UL, 2001055236UL, 3610705100UL, 2202168115UL, 4028541809UL, 2961195399UL, 1006657119UL, 2006996926UL, 3186142756UL, 1430667929UL, 3210227297UL, 1314452623UL, 4074634658UL, 4101304120UL, 2273951170UL, 1399257539UL, 3367210612UL, 3027628629UL, 1190975929UL, 2062231137UL, 2333990788UL, 2221543033UL, 2438960610UL, 1181637006UL, 548689776UL, 2362791313UL, 3372408396UL, 3104550113UL, 3145860560UL, 296247880UL, 1970579870UL, 3078560182UL, 3769228297UL, 1714227617UL, 3291629107UL, 3898220290UL, 166772364UL, 1251581989UL, 493813264UL, 448347421UL, 195405023UL, 2709975567UL, 677966185UL, 3703036547UL, 1463355134UL, 2715995803UL, 1338867538UL, 1343315457UL, 2802222074UL, 2684532164UL, 233230375UL, 2599980071UL, 2000651841UL, 3277868038UL, 1638401717UL, 4028070440UL, 3237316320UL, 6314154UL, 819756386UL, 300326615UL, 590932579UL, 1405279636UL, 3267499572UL, 3150704214UL, 2428286686UL, 3959192993UL, 3461946742UL, 1862657033UL, 1266418056UL, 963775037UL, 2089974820UL, 2263052895UL, 1917689273UL, 448879540UL, 3550394620UL, 3981727096UL, 150775221UL, 3627908307UL, 1303187396UL, 508620638UL, 2975983352UL, 2726630617UL, 1817252668UL, 1876281319UL, 1457606340UL, 908771278UL, 3720792119UL, 3617206836UL, 2455994898UL, 1729034894UL, 1080033504UL}, { 976866871UL, 3556439503UL, 2881648439UL, 1522871579UL, 1555064734UL, 1336096578UL, 3548522304UL, 2579274686UL, 3574697629UL, 3205460757UL, 3593280638UL, 3338716283UL, 3079412587UL, 564236357UL, 2993598910UL, 1781952180UL, 1464380207UL, 3163844217UL, 3332601554UL, 1699332808UL, 1393555694UL, 1183702653UL, 3581086237UL, 1288719814UL, 691649499UL, 2847557200UL, 2895455976UL, 3193889540UL, 2717570544UL, 1781354906UL, 1676643554UL, 2592534050UL, 3230253752UL, 1126444790UL, 2770207658UL, 2633158820UL, 2210423226UL, 2615765581UL, 2414155088UL, 3127139286UL, 673620729UL, 2805611233UL, 1269405062UL, 4015350505UL, 3341807571UL, 4149409754UL, 1057255273UL, 2012875353UL, 2162469141UL, 2276492801UL, 2601117357UL, 993977747UL, 3918593370UL, 2654263191UL, 753973209UL, 36408145UL, 2530585658UL, 25011837UL, 3520020182UL, 2088578344UL, 530523599UL, 2918365339UL, 1524020338UL, 1518925132UL, 3760827505UL, 3759777254UL, 1202760957UL, 3985898139UL, 3906192525UL, 674977740UL, 4174734889UL, 2031300136UL, 2019492241UL, 3983892565UL, 4153806404UL, 3822280332UL, 352677332UL, 2297720250UL, 60907813UL, 90501309UL, 3286998549UL, 1016092578UL, 2535922412UL, 2839152426UL, 457141659UL, 509813237UL, 4120667899UL, 652014361UL, 1966332200UL, 2975202805UL, 55981186UL, 2327461051UL, 676427537UL, 3255491064UL, 2882294119UL, 3433927263UL, 1307055953UL, 942726286UL, 933058658UL, 2468411793UL, 3933900994UL, 4215176142UL, 1361170020UL, 2001714738UL, 2830558078UL, 3274259782UL, 1222529897UL, 1679025792UL, 2729314320UL, 3714953764UL, 1770335741UL, 151462246UL, 3013232138UL, 1682292957UL, 1483529935UL, 471910574UL, 1539241949UL, 458788160UL, 3436315007UL, 1807016891UL, 3718408830UL, 978976581UL, 1043663428UL, 3165965781UL, 1927990952UL, 4200891579UL, 2372276910UL, 3208408903UL, 3533431907UL, 1412390302UL, 2931980059UL, 4132332400UL, 1947078029UL, 3881505623UL, 4168226417UL, 2941484381UL, 1077988104UL, 1320477388UL, 886195818UL, 18198404UL, 3786409000UL, 2509781533UL, 112762804UL, 3463356488UL, 1866414978UL, 891333506UL, 18488651UL, 661792760UL, 1628790961UL, 3885187036UL, 3141171499UL, 876946877UL, 2693282273UL, 1372485963UL, 791857591UL, 2686433993UL, 3759982718UL, 3167212022UL, 3472953795UL, 2716379847UL, 445679433UL, 3561995674UL, 3504004811UL, 3574258232UL, 54117162UL, 3331405415UL, 2381918588UL, 3769707343UL, 4154350007UL, 1140177722UL, 4074052095UL, 668550556UL, 3214352940UL, 367459370UL, 261225585UL, 2610173221UL, 4209349473UL, 3468074219UL, 3265815641UL, 314222801UL, 3066103646UL, 3808782860UL, 282218597UL, 3406013506UL, 3773591054UL, 379116347UL, 1285071038UL, 846784868UL, 2669647154UL, 3771962079UL, 3550491691UL, 2305946142UL, 453669953UL, 1268987020UL, 3317592352UL, 3279303384UL, 3744833421UL, 2610507566UL, 3859509063UL, 266596637UL, 3847019092UL, 517658769UL, 3462560207UL, 3443424879UL, 370717030UL, 4247526661UL, 2224018117UL, 4143653529UL, 4112773975UL, 2788324899UL, 2477274417UL, 1456262402UL, 2901442914UL, 1517677493UL, 1846949527UL, 2295493580UL, 3734397586UL, 2176403920UL, 1280348187UL, 1908823572UL, 3871786941UL, 846861322UL, 1172426758UL, 3287448474UL, 3383383037UL, 1655181056UL, 3139813346UL, 901632758UL, 1897031941UL, 2986607138UL, 3066810236UL, 3447102507UL, 1393639104UL, 373351379UL, 950779232UL, 625454576UL, 3124240540UL, 4148612726UL, 2007998917UL, 544563296UL, 2244738638UL, 2330496472UL, 2058025392UL, 1291430526UL, 424198748UL, 50039436UL, 29584100UL, 3605783033UL, 2429876329UL, 2791104160UL, 1057563949UL, 3255363231UL, 3075367218UL, 3463963227UL, 1469046755UL, 985887462UL} } ; /* sLb(s,n) allows us to subsript s by byte offsets, which allows us to avoid a subscript scaling. */ #define sub(s,n) *((IntU32 *)((IntP)s+(n))) /* Below is one BlowFish round including the F function */ #define round(l,r,n) \ l ^= P[n]; \ r ^= ( (sub(S[0],l>>22 & 0x3fc) + sub(S[1],l>>14 & 0x3fc)) \ ^ sub(S[2],l>>6 & 0x3fc) ) +S[3][l & 0xff] /* This function requires the block to be two 32 bit integers, in whatever endian form the machine uses. On little endian machines use crypt_8bytes() on user data. make_bfkey should call crypt_block on either endian machine. Pass direction 0 to encrypt, 1 to decrypt. */ static void crypt_block(block, bfkey, direction) IntU32 block[2]; BFkey_type *bfkey; short direction; { register IntU32 left, right, (*S)[256], *P ; left = block[0] ; right = block[1] ; S = bfkey->sbox ; P = bfkey->p[direction] ; round( left, right, 0 ) ; round( right, left, 1 ) ; round( left, right, 2 ) ; round( right, left, 3 ) ; round( left, right, 4 ) ; round( right, left, 5 ) ; round( left, right, 6 ) ; round( right, left, 7 ) ; round( left, right, 8 ) ; round( right, left, 9 ) ; round( left, right, 10 ) ; round( right, left, 11 ) ; round( left, right, 12 ) ; round( right, left, 13 ) ; round( left, right, 14 ) ; round( right, left, 15 ) ; left = left ^ P[NROUNDS] ; right = right ^ P[NROUNDS+1] ; block[0] = right ; block[1] = left ; } /* The following should be allignment and endian independent. I have not tested it on a little-endian machine. It takes the input block from source, and puts the output in dest. They can be the same. It takes the same direction parameter as crypt_block(). */ void blowfish_crypt_8bytes(source, dest, bfkey, direction) IntU8 *source, *dest; BFkey_type *bfkey; short direction; { IntU32 block[2] ; block[0] = source[3] | source[2]<<8 | source[1]<<16 | source[0]<<24 ; block[1] = source[7] | source[6]<<8 | source[5]<<16 | source[4]<<24 ; crypt_block( block, bfkey, direction ) ; dest[0]= block[0]>>24 ; dest[1]= block[0]>>16 & 0xff ; dest[2]= block[0]>>8 & 0xff ; dest[3]= block[0] & 0xff ; dest[4]= block[1]>>24 ; dest[5]= block[1]>>16 & 0xff ; dest[6]= block[1]>> 8 & 0xff ; dest[7]= block[1] & 0xff ; } /* make_bfkey() takes the address of the key data as a char*, and the length of the key in bytes. It generates and returns a pointer to an object of BFkey_type, which can be passed to the crypt functions. It does some simple testing of the init data and crypt routine, and returns 0 on error. */ int blowfish_make_bfkey(key_string, keylength, bfkey) unsigned char *key_string; int keylength; BFkey_type *bfkey; { int i, j, k ; IntU32 dspace[2], checksum=0 ; /* Copy constant initial data to P vector */ for( i=0 ; ip[0][i] = p_init[i] ; bfkey->p[1][NROUNDS+1-i] = p_init[i] ; checksum = (checksum<<1 | checksum>>31)+p_init[i] ; } /* Copy constant initial data to sboxes */ for( i=0 ; i<4 ; ++i ) for( j=0 ; j<256 ; ++j ) { bfkey->sbox[i][j] = s_init[i][j] ; checksum = ((checksum*13)<<11 | (checksum*13)>>21) + s_init[i][j] ; } /* Test init data. */ if( checksum != 0x55861a61 ) { strncpy((char *)bfkey, "Bad initialization data",24); return -1; } dspace[0] = 0 ; dspace[1] = 0 ; /* Test the crypt_block() routine. */ for( i=0 ; i<10 ; ++i ) crypt_block( dspace, bfkey, 0 ) ; checksum = dspace[0] ; for( i=0 ; i<10 ; ++i ) crypt_block( dspace, bfkey, 1 ) ; if( (checksum!=0xaafe4ebd) || dspace[0] || dspace[1] ) { strncpy((char *)bfkey, "Error in crypt_block routine",29); return -1; } /* Xor key string into encryption key vector */ j = 0 ; for (i=0 ; ip)[0][i] ^= data; } for (i = 0 ; ip[0][i] = dspace[0] ; bfkey->p[1][NROUNDS+1-i] = dspace[0] ; bfkey->p[0][i+1] = dspace[1] ; bfkey->p[1][NROUNDS-i] = dspace[1] ; } for ( i=0 ; i<4 ; ++i ) for ( j=0 ; j<256 ; j+=2 ) { crypt_block( dspace, bfkey, 0 ) ; bfkey->sbox[i][j] = dspace[0] ; bfkey->sbox[i][j+1] = dspace[1] ; } return 0; } Crypt-Blowfish-2.14/Blowfish.pm0000644000175000017500000001124112173566071014574 0ustar dspdsppackage Crypt::Blowfish; require Exporter; require DynaLoader; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); @ISA = qw(Exporter DynaLoader); # @ISA = qw(Exporter DynaLoader Crypt::BlockCipher); # Items to export into callers namespace by default @EXPORT = qw(); # Other items we are prepared to export if requested @EXPORT_OK = qw( blocksize keysize min_keysize max_keysize new encrypt decrypt ); $VERSION = '2.14'; bootstrap Crypt::Blowfish $VERSION; use strict; use Carp; sub usage { my ($package, $filename, $line, $subr) = caller(1); $Carp::CarpLevel = 2; croak "Usage: $subr(@_)"; } sub blocksize { 8; } # /* byte my shiny metal.. */ sub keysize { 0; } # /* we'll leave this at 8 .. for now. */ sub min_keysize { 8; } sub max_keysize { 56; } sub new { usage("new Blowfish key") unless @_ == 2; my $type = shift; my $self = {}; bless $self, $type; $self->{'ks'} = Crypt::Blowfish::init(shift); return $self; } sub encrypt { usage("encrypt data[8 bytes]") unless @_ == 2; my ($self,$data) = @_; Crypt::Blowfish::crypt($data, $data, $self->{'ks'}, 0); return $data; } sub decrypt { usage("decrypt data[8 bytes]") unless @_ == 2; my ($self,$data) = @_; Crypt::Blowfish::crypt($data, $data, $self->{'ks'}, 1); return $data; } 1; __END__ # # Parts Copyright (C) 1995, 1996 Systemics Ltd (http://www.systemics.com/) # New Parts Copyright (C) 1999, 2001 W3Works, LLC (http://www.w3works.com/) # All rights reserved. # =head1 NAME Crypt::Blowfish - Perl Blowfish encryption module =head1 SYNOPSIS use Crypt::Blowfish; my $cipher = new Crypt::Blowfish $key; my $ciphertext = $cipher->encrypt($plaintext); my $plaintext = $cipher->decrypt($ciphertext); You probably want to use this in conjunction with a block chaining module like Crypt::CBC. =head1 DESCRIPTION Blowfish is capable of strong encryption and can use key sizes up to 56 bytes (a 448 bit key). You're encouraged to take advantage of the full key size to ensure the strongest encryption possible from this module. Crypt::Blowfish has the following methods: =over 4 blocksize() keysize() encrypt() decrypt() =back =head1 FUNCTIONS =over 4 =item blocksize Returns the size (in bytes) of the block cipher. Crypt::Blowfish doesn't return a key size due to its ability to use variable-length keys. More accurately, it shouldn't, but it does anyway to play nicely with others. =item new my $cipher = new Crypt::Blowfish $key; This creates a new Crypt::Blowfish BlockCipher object, using $key, where $key is a key of C bytes (minimum of eight bytes). =item encrypt my $cipher = new Crypt::Blowfish $key; my $ciphertext = $cipher->encrypt($plaintext); This function encrypts $plaintext and returns the $ciphertext where $plaintext and $ciphertext must be of C bytes. (hint: Blowfish is an 8 byte block cipher) =item decrypt my $cipher = new Crypt::Blowfish $key; my $plaintext = $cipher->decrypt($ciphertext); This function decrypts $ciphertext and returns the $plaintext where $plaintext and $ciphertext must be of C bytes. (hint: see previous hint) =back =head1 EXAMPLE my $key = pack("H16", "0123456789ABCDEF"); # min. 8 bytes my $cipher = new Crypt::Blowfish $key; my $ciphertext = $cipher->encrypt("plaintex"); # SEE NOTES print unpack("H16", $ciphertext), "\n"; =head1 PLATFORMS Please see the README document for platforms and performance tests. =head1 NOTES The module is capable of being used with Crypt::CBC. You're encouraged to read the perldoc for Crypt::CBC if you intend to use this module for Cipher Block Chaining modes. In fact, if you have any intentions of encrypting more than eight bytes of data with this, or any other block cipher, you're going to need B type of block chaining help. Crypt::CBC tends to be very good at this. If you're not going to encrypt more than eight bytes, your data B be B eight bytes long. If need be, do your own padding. "\0" as a null byte is perfectly valid to use for this. =head1 SEE ALSO Crypt::CBC, Crypt::DES, Crypt::IDEA Bruce Schneier, I, 1995, Second Edition, published by John Wiley & Sons, Inc. =head1 COPYRIGHT The implementation of the Blowfish algorithm was developed by, and is copyright of, A.M. Kuchling. Other parts of the perl extension and module are copyright of Systemics Ltd ( http://www.systemics.com/ ). Code revisions, updates, and standalone release are copyright 1999-2010 W3Works, LLC. =head1 AUTHOR Original algorithm, Bruce Shneier. Original implementation, A.M. Kuchling. Original Perl implementation, Systemics Ltd. Current maintenance by W3Works, LLC. Current revision and maintainer: Dave Paris Crypt-Blowfish-2.14/COPYRIGHT0000644000175000017500000000637007051666273013767 0ustar dspdspThis perl extension includes software developed by, and copyright of, A.M. Kuchling. Other parts of the library are covered by the following licence: Copyright (C) 1995, 1996 Systemics Ltd (http://www.systemics.com/) Modifications and Current Implimentation Copyright (C) 2000 W3Works, LLC. All rights reserved. Current implimentation contains modifications made by W3Works, LLC. The modifications remain copyright of W3Works, LLC and attribution for these modification should be made to W3Works, LLC. These modifications and this copyright must remain with this package. Additions to the Restrictions set out below are: 1. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product inculdes software developed by W3Works, LLC (http://www.w3works.com) NO ADDITIONAL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXTENDED BY THIS DISTRIBUTION. Any subsequent derrivations of this package must retainl this copyright. Original Copyright Below This library and applications are FREE FOR COMMERCIAL AND NON-COMMERCIAL USE as long as the following conditions are adhered to. Copyright remains with Systemics Ltd, and as such any Copyright notices in the code are not to be removed. If this code is used in a product, Systemics should be given attribution as the author of the parts used. This can be in the form of a textual message at program startup or in documentation (online or textual) provided with the package. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by Systemics Ltd (http://www.systemics.com/) THIS SOFTWARE IS PROVIDED BY SYSTEMICS LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The licence and distribution terms for any publically available version or derivative of this code cannot be changed. i.e. this code cannot simply be copied and put under another distribution licence [including the GNU Public Licence.] Crypt-Blowfish-2.14/Blowfish.xs0000644000175000017500000000316012173522123014601 0ustar dspdsp/* * Copyright (C) 1995, 1996 Systemics Ltd (http://www.systemics.com/) * * Code Modfifications Copyright (C) 2000 W3Works, LLC (http://www.w3works.co/) * All rights reserved. */ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "blowfish.h" /* thanks to LDS */ #ifndef sv_undef #define sv_undef PL_sv_undef #endif MODULE = Crypt::Blowfish PACKAGE = Crypt::Blowfish PREFIX = blowfish_ PROTOTYPES: DISABLE char * blowfish_init(key) unsigned char * key = NO_INIT STRLEN key_len = NO_INIT CODE: { /* * What should this length be??? */ char ks[8192]; key = (unsigned char *) SvPV(ST(0), key_len); if (key_len < 8 || key_len > 56) croak("Invalid length key"); if (blowfish_make_bfkey(key, key_len, ks)) croak("Error creating key schedule"); ST(0) = sv_2mortal(newSVpv(ks, sizeof(ks))); } void blowfish_crypt(input, output, ks, dir) char * input = NO_INIT SV * output char * ks = NO_INIT STRLEN input_len = NO_INIT STRLEN output_len = NO_INIT STRLEN ks_len = NO_INIT int dir CODE: { input = (char *) SvPV(ST(0), input_len); if (input_len != 8) croak("input must be 8 bytes long"); ks = (char *) SvPV(ST(2), ks_len); if (output == &sv_undef) output = sv_newmortal(); output_len = 8; (SvUPGRADE(output, SVt_PV)); /* blowfish_crypt_8bytes(input, SvGROW(output, 8), ks, dir); */ /* HP-UX (HP cc) fix below, thanks Addi! */ blowfish_crypt_8bytes( (unsigned char*)input, (unsigned char*)SvGROW(output, 8), ks, (short)dir); SvCUR_set(output, output_len); *SvEND(output) = '\0'; (void) SvPOK_only(output); SvTAINT(output); ST(0) = output; } Crypt-Blowfish-2.14/META.yml0000644000175000017500000000073312173566160013735 0ustar dspdsp--- #YAML:1.0 name: Crypt-Blowfish version: 2.14 abstract: ~ author: [] license: unknown distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: {} no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.55_02 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 Crypt-Blowfish-2.14/typemap0000644000175000017500000000001007051223464014046 0ustar dspdspTYPEMAP