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

Quick Search    Search Deep

Class MARS  view MARS download

  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.

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


static final int BLOCK_SIZE
See Also:
Constant Field Values


static final int ROUNDS
See Also:
Constant Field Values


private static final int[] S
MARS S-box


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


private final int[] K
Subkeys (40).

Constructor Detail


public MARS()
Method Detail


protected void coreInit( key,
                        boolean decrypt)
Specified by:
coreInit in class BlockCipher


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


private final 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. 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 ( This is used during key expansion.


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


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


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


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