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

Quick Search    Search Deep

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

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

public final class MARS
extends BlockCipher

MARS is an AES candidate submitted by IBM.

MARS was designed by Carolynn Burwick, Don Coppersmith, Edward D'Avignon, Rosario Gennaro, Shai Halevi, Charanjit Jutla, Stephen M. Matyas Jr., Luke O'Connor, Mohammad Peyravian, David Safford, and Nevenko Zunic.

Please note that this is the 'amended' 2nd round version.

Version:
$Revision: 1.3 $

Field Summary
(package private) static int BLOCK_SIZE
           
private  boolean decrypt
          Encrypt (false) or decrypt mode (true)
private  int[] K
          Subkeys (40).
(package private) static int ROUNDS
           
private static int[] S
          MARS S-box
 
Fields inherited from class cryptix.jce.provider.cipher.BlockCipher
 
Constructor Summary
MARS()
           
 
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 static int[] E(int in, int key1, int key2)
           
private  void generateSubKeys(byte[] key)
          Expand a session key into 40 MARS subkeys in int[] this.K .
private static int maskFrom(int x)
          Generate a bit-mask M from x.
private static int rotl(int arg, int amount)
          Rotate left an int by the specified amount.
 
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

static final int BLOCK_SIZE
See Also:
Constant Field Values

ROUNDS

static final int ROUNDS
See Also:
Constant Field Values

S

private static final int[] S
MARS S-box


decrypt

private boolean decrypt
Encrypt (false) or decrypt mode (true)


K

private final int[] K
Subkeys (40).

Constructor Detail

MARS

public MARS()
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 session key into 40 MARS subkeys in int[] this.K .


maskFrom

private static int maskFrom(int x)
Generate a bit-mask M from x. Bit M{i}=1 iff x{i} belongs to a sequence of 10 consecutive 0's or 1's in x, and also 2 <= i <= 30 and x{i-1} = w{i} = w{i+1}. Code taken from the MARS implementation in C/C++ by Dr. B. R. Gladman (brian.gladman@btinternet.com). This is used during key expansion.


rotl

private static int rotl(int arg,
                        int amount)
Rotate left an int by the specified amount.


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.


E

private static int[] E(int in,
                       int key1,
                       int key2)