Click here to get back home

RFC: Crypt::Skip32 [try 3]

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
RFC: Crypt::Skip32 [try 3] Eric Hammond 09-24-2007
Posted by Eric Hammond on September 24, 2007, 12:51 am
Please log in for more thread options
I'm planning to upload this new module for distribution on the CPAN.
Feedback welcomed.

NAME
Crypt::Skip32 - 32-bit block cipher based on Skipjack

SYNOPSIS
use Crypt::Skip32;

my $cipher = new Crypt::Skip32 $key;
my $ciphertext = $cipher->encrypt($plaintext);
my $plaintext = $cipher->decrypt($ciphertext);

DESCRIPTION
Skip32 is a 80-bit key, 32-bit block cipher based on
Skipjack. The Perl code for the algorithm is a direct
translation from C to Perl of skip32.c by Greg Rose found
here:

http://www.qualcomm.com.au/PublicationsDocs/skip32.c

This cipher can be handy for scrambling small (32-bit) values
when you would like to obscure them while keeping the
encrypted output size small (32 bits).

One example where Skip32 has been useful: You have numeric
database record ids which increment sequentially. You would
like to use them in URLs, but you don't want to make it
obvious how many X's you have in the database by putting the
ids directly in the URLs.

You can use Skip32 to scramble ids and put the resulting
32-bit value in URLs (perhaps as 8 hex digits or some other
shorter encoding). When a user requests a URL, you can
unscramble the id to retrieve the object from the database.

Warning: A 32-bit value can only go a little over 4 billion
(American). Plan ahead if what you need to encrypt might
eventually go over this limit.

FUNCTIONS
new
my $cipher = new Crypt::Skip32 $key;

Creates a new Crypt::Skip32 block cipher object, using
$key, where $key is a key of "keysize" (10) bytes.

encrypt
my $ciphertext = $cipher->encrypt($plaintext);

Encrypt $plaintext and return the $ciphertext. The
$plaintext must be of "blocksize" (4) bytes.

decrypt
my $plaintext = $cipher->decrypt($ciphertext);

Decrypt $ciphertext and return the $plaintext. The
$ciphertext must be of "blocksize" (4) bytes.

blocksize
my $blocksize = $cipher->blocksize;
my $blocksize = Crypt::Skip32->blocksize;

Returns the size (in bytes) of the block cipher. This is
always 4 bytes (for 32 bits).

keysize
my $keysize = $cipher->keysize;
my $keysize = Crypt::Skip32->keysize;

Returns the size (in bytes) of the key. This is always 10
bytes.

EXAMPLE
use Crypt::Skip32;

my $key = pack("H20", "112233445566778899AA");
my $cipher = new Crypt::Skip32 $key;

my $plaintext1 = pack("N", 3493209676);
my $ciphertext = $cipher->encrypt($plaintext1);
print "scrambled 3493209676 -> 0x",
unpack("H8", $ciphertext), "\n";

my $plaintext2 = $cipher->decrypt($ciphertext);
die "something went horribly wrong"
unless $plaintext2 eq $plaintext1;

print "blocksize: ", $cipher->blocksize, " bytes \n";
print "keysize: ", $cipher->keysize, " bytes \n";

CAVEATS
This initial alpha Perl implementation of SKIP32 has not been
extentively reviewed by cryptographic experts, nor has it
been tested extensively on many different platforms. It is
recommended that this code not be used for applications which
require a high level of security. Reviewers and testers
welcomed.

TODO
This version of Skip32 is implemented entirely in Perl. Since
there is a free C implementation of the algorithm, this
should probably be made available with XS or Inline::C so
that it can run a bit faster.

SEE ALSO
The original Skip32 implementation in C by Greg Rose:

http://www.qualcomm.com.au/PublicationsDocs/skip32.c

The 80-bit key, 64-bit block Skipjack cipher created by the
NSA (Perl code maintained by Julius C. Duque):

Crypt::Skipjack

AUTHOR
Perl code maintained by Eric Hammond
<eric dash cpan at thinksome dot com>
http://www.anvilon.com

Original Skip32 C code written 1999-04-27 by Greg Rose, based
on an implementation of the Skipjack algorithm written by
Panu Rissanen.

COPYRIGHT AND LICENSE
(C) Copyright 2007, Eric Hammond

This library is free software; you can redistribute it and/or
modify it under the same terms as Perl itself, either Perl
version 5.8.8 or, at your option, any later version of Perl 5
you may have available.

The C version of Skip32 by Greg Rose (see below) is
explicitly "not copyright, no rights reserved". Even so,
permission was requested and granted to make a Perl version
available on the CPAN.

ORIGINAL C SOURCE
/* SKIP32 -- 32 bit block cipher based on SKIPJACK. Written
by Greg Rose, QUALCOMM Australia, 1999/04/27.

In common: F-table, G-permutation, key schedule.
Different: 24 round feistel structure.
Based on: Unoptimized test implementation of SKIPJACK
algorithm

SKIPJACK and KEA Algorithm Specifications
Version 2.0
29 May 1998

Not copyright, no rights reserved.
*/
[...]


Posted by Mumia W. on September 24, 2007, 1:29 am
Please log in for more thread options
On 09/23/2007 11:51 PM, Eric Hammond wrote:
> I'm planning to upload this new module for distribution on the CPAN.
> Feedback welcomed.
>
> NAME
> Crypt::Skip32 - 32-bit block cipher based on Skipjack
> [...]

It looks interesting.

Don't expect comments to come in all at once--especially for weekend posts.

Most people wont have any comments at all, and many people killfile all
Google Groups posts.

Similar ThreadsPosted
RFC: Crypt::Skip32 - 32-bit block cipher based on Skipjack September 23, 2007, 6:15 am
Crypt::DH Crypt::Random install problem May 9, 2005, 5:25 am
Crypt::Tea becomes Crypt::Tea_JS January 17, 2005, 1:14 pm
Crypt::RC5 128 April 5, 2006, 10:31 am
Crypt::RSA March 10, 2007, 6:43 pm
(ANNOUNCE) Crypt::FileHandle October 24, 2004, 12:08 am
Des::Crypt Will not Compile On Solaris 8 Using GCC December 7, 2005, 2:58 pm
Crypt::SSLeay + OpenSSL 0.9.8 July 21, 2006, 5:31 am
Crypt::SSLEay for Windows March 7, 2007, 1:08 am
Crypt:DES make problem on Solaris 9 March 10, 2005, 12:39 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap