summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl0/lib/Crypt/IDEA.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlperl0/lib/Crypt/IDEA.pm')
-rwxr-xr-xMaster/tlpkg/tlperl0/lib/Crypt/IDEA.pm85
1 files changed, 85 insertions, 0 deletions
diff --git a/Master/tlpkg/tlperl0/lib/Crypt/IDEA.pm b/Master/tlpkg/tlperl0/lib/Crypt/IDEA.pm
new file mode 100755
index 00000000000..d204859e34f
--- /dev/null
+++ b/Master/tlpkg/tlperl0/lib/Crypt/IDEA.pm
@@ -0,0 +1,85 @@
+#! /usr/local/bin/perl -w
+
+#
+# Copyright (C) 1995, 1996 Systemics Ltd (http://www.systemics.com/)
+# All rights reserved.
+#
+
+package Crypt::IDEA;
+
+require Exporter;
+require DynaLoader;
+
+@ISA = (Exporter, DynaLoader);
+
+# Items to export into callers namespace by default
+@EXPORT = qw();
+
+# Other items we are prepared to export if requested
+@EXPORT_OK = qw();
+
+bootstrap Crypt::IDEA;
+
+
+package IDEA;
+
+$VERSION="1.08";
+
+use strict;
+use Carp;
+
+sub usage
+{
+ my ($mess, $package, $filename, $line, $subr);
+ ($mess) = @_;
+ ($package, $filename, $line, $subr) = caller(1);
+ $Carp::CarpLevel = 2;
+ croak "Usage: $package\::$subr - $mess";
+}
+
+
+sub blocksize { 8; }
+sub keysize { 16; }
+
+sub new
+{
+ usage("new IDEA key") unless @_ == 2;
+
+ my $type = shift; my $self = {}; bless $self, $type;
+
+ $self->{'ks'} = Crypt::IDEA::expand_key(shift);
+
+ $self;
+}
+
+sub encrypt
+{
+ usage("encrypt data[8 bytes]") unless @_ == 2;
+
+ my $self = shift;
+ my $data = shift;
+
+ Crypt::IDEA::crypt($data, $data, $self->{'ks'});
+
+ $data;
+}
+
+sub decrypt
+{
+ usage("decrypt data[8 bytes]") unless @_ == 2;
+
+ my $self = shift;
+ my $data = shift;
+
+ #
+ # Cache Decrypt key schedule
+ #
+ $self->{'dks'} = Crypt::IDEA::invert_key($self->{'ks'})
+ unless exists $self->{'dks'};
+
+ Crypt::IDEA::crypt($data, $data, $self->{'dks'});
+
+ $data;
+}
+
+1;