NAME
Tea.pm - Perl module to implement TEA, the Tiny Encryption Algorithm
SYNOPSIS
Usage: use Tea; $key = 'PUFgob$*LKDF D)(F IDD&P?/'; $ascii_ciphertext = &encrypt ($plaintext, $key); ... $plaintext_again = &decrypt ($ascii_ciphertext, $key); ... $signature = &asciidigest ($text);
In CGI scripts: use Crypt::Tea; print &tea_in_javascript; # now the browser can encrypt & decrypt ! $key = &get_password_from_some_database; ... # get JavaScript to ask the user for a password &encrypt_and_write ($lots_of_html, $key, $windowname);
# and then to get FORM data back...
print '<FORM onSubmit="opener.encrypt_and_submit(this, opener.key)">';
print '<INPUT TYPE="hidden" NAME="htauth_t">';
# and
%htauth_t = split("\0", decrypt($DAT{htauth_t}, $key));
# These manoeuvres are utilised by CGI::Htauth.pm q.v.
DESCRIPTION
This module implements TEA, the Tiny Encryption Algorithm, and some Modes of Use, in Perl and JavaScript.
The $key is a sufficiently longish string; at least 17 random 8-bit bytes for single encryption.
Version: #VERSION#
(c) Peter J Billam 1998, covered by the GPL Gnu Public Licence
SUBROUTINES
- encrypt( $plaintext, $key );
-
Encrypts with CBC (Cipher Block Chaining)
- decrypt( $ciphertext, $key );
-
Decrypts with CBC (Cipher Block Chaining)
- binary2ascii( $a_binary_string );
-
Provide an ascii text encoding of the binary argument. If Tea.pm is not being invoked from a GCI script, the ascii is split into lines of 72 characters.
- ascii2binary( $an_ascii_string );
- asciidigest( $a_string );
-
Returns an asciified binary signature of the argument.
- tea_in_javascript();
-
Returns a compatible implementation of TEA in JavaScript, for use in CGI scripts to communicate with browsers.
AUTHOR
Peter J Billam <peter@pjb.com.au>
CREDITS
Based on TEA, as described in http://www.cl.cam.ac.uk/ftp/papers/djw-rmn/djw-rmn-tea.html , and on some help from Applied Cryptography by Bruce Schneier as regards the modes of use.
SEE ALSO
http://www.pjb.com.au/, CGI::Htauth.pm, perl(1).