Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

cryptix.jce.provider.cipher
Class Serpent  view Serpent download Serpent.java

java.lang.Object
  extended byjavax.crypto.CipherSpi
      extended bycryptix.jce.provider.cipher.BlockCipher
          extended bycryptix.jce.provider.cipher.Serpent

public final class Serpent
extends BlockCipher

A bit-slice implementation in Java of the Serpent cipher.

Serpent is a 128-bit 32-round block cipher with variable key lengths, including 128-, 192- and 256-bit keys conjectured to be at least as secure as three-key triple-DES.

Serpent was designed by Ross Anderson, Eli Biham and Lars Knudsen as a candidate algorithm for the NIST AES Quest.

References:

  1. Serpent: A New Block Cipher Proposal. This paper was published in the proceedings of the "Fast Software Encryption Workshop No. 5" held in Paris in March 1998. LNCS, Springer Verlag.

  2. Reference implementation of the standard Serpent cipher written in C by Frank Stajano.

Version:
$Revision: 1.5 $

Field Summary
private static int BLOCK_SIZE
           
private  boolean decrypt
           
private  int[] K
           
private static int PHI
           
private static int ROUNDS
           
private static byte[][] Sbox
          An array of 8 (number of rounds/4) S boxes.
 
Fields inherited from class cryptix.jce.provider.cipher.BlockCipher
 
Constructor Summary
Serpent()
           
 
Method Summary
private  void blockDecrypt(byte[] in, int inOffset, byte[] out, int outOffset)
          Decrypt exactly one block of ciphertext.
private  void blockEncrypt(byte[] in, int inOffset, byte[] out, int outOffset)
          Encrypt exactly one block of plaintext.
protected  void coreCrypt(byte[] in, int inOffset, byte[] out, int outOffset)
          Encrypt a given buffer.
protected  void coreInit(java.security.Key key, boolean decrypt)
           
private  void generateSubKeys(byte[] key)
          Expand a user-supplied key material into a session key.
 
Methods inherited from class cryptix.jce.provider.cipher.BlockCipher
clone, coreGetBlockSize, engineDoFinal, engineDoFinal, engineGetBlockSize, engineGetIV, engineGetKeySize, engineGetOutputSize, engineGetParameters, engineInit, engineInit, engineInit, engineSetMode, engineSetPadding, engineUpdate, engineUpdate
 
Methods inherited from class javax.crypto.CipherSpi
engineDoFinal, engineUnwrap, engineUpdate, engineWrap
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOCK_SIZE

private static final int BLOCK_SIZE
See Also:
Constant Field Values

ROUNDS

private static final int ROUNDS
See Also:
Constant Field Values

PHI

private static final int PHI
See Also:
Constant Field Values

decrypt

private boolean decrypt

K

private int[] K

Sbox

private static final byte[][] Sbox
An array of 8 (number of rounds/4) S boxes.

An S box is an array of 16 distinct quantities, each in the range 0-15. A value v at position p for a given S box, implies that if this S box is given on input a value p, it will return the value v. Original S box data below. We use a more compact encoding that is expanded in a static initializer. { 3, 8,15, 1,10, 6, 5,11,14,13, 4, 2, 7, 0, 9,12 }, // S0 {15,12, 2, 7, 9, 0, 5,10, 1,11,14, 8, 6,13, 3, 4 }, // S1 { 8, 6, 7, 9, 3,12,10,15,13, 1,14, 4, 0,11, 5, 2 }, // S2 { 0,15,11, 8,12, 9, 6, 3,13, 1, 2, 4,10, 7, 5,14 }, // S3 { 1,15, 8, 3,12, 0,11, 6, 2, 5, 4,10, 9,14, 7,13 }, // S4 {15, 5, 2,11, 4,10, 9,12, 0, 3,14, 8,13, 6, 7, 1 }, // S5 { 7, 2,12, 5, 8, 4, 6,11,14, 9, 1,15,13, 3,10, 0 }, // S6 { 1,13,15, 0,14, 8, 2,11, 7, 4,12,10, 9, 3, 5, 6 } // S7

Constructor Detail

Serpent

public Serpent()
Method Detail

coreInit

protected void coreInit(java.security.Key key,
                        boolean decrypt)
                 throws java.security.InvalidKeyException
Specified by:
coreInit in class BlockCipher

coreCrypt

protected void coreCrypt(byte[] in,
                         int inOffset,
                         byte[] out,
                         int outOffset)
Description copied from class: BlockCipher
Encrypt a given buffer. in and out can point to the same buffer if (outOffset == inOffset) || (outOffset >= (inOffset+coreGetBlockSize)) That is: the buffers may not partially overlap...

Specified by:
coreCrypt in class BlockCipher

generateSubKeys

private final void generateSubKeys(byte[] key)
Expand a user-supplied key material into a session key.


blockEncrypt

private final void blockEncrypt(byte[] in,
                                int inOffset,
                                byte[] out,
                                int outOffset)
Encrypt exactly one block of plaintext.


blockDecrypt

private final void blockDecrypt(byte[] in,
                                int inOffset,
                                byte[] out,
                                int outOffset)
Decrypt exactly one block of ciphertext.