RFC: Crypt::Skip32 [try 3]

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'm planning to upload this new module for distribution on the CPAN.
Feedback welcomed.

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

      use Crypt::Skip32;

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

    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


    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.

          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.

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

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

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

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

          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).

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

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

      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";

    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

    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.

    The original Skip32 implementation in C by Greg Rose:


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


    Perl code maintained by Eric Hammond
    <eric dash cpan at thinksome dot com>

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

    (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.

    /* 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

       SKIPJACK and KEA Algorithm Specifications
       Version 2.0
       29 May 1998

       Not copyright, no rights reserved.

Re: RFC: Crypt::Skip32 [try 3]

On 09/23/2007 11:51 PM, Eric Hammond wrote:
Quoted text here. Click to load it

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.

Site Timeline