org.bouncycastle.crypto.engines
Class CamelliaEngine

java.lang.Object
  extended by org.bouncycastle.crypto.engines.CamelliaEngine
All Implemented Interfaces:
BlockCipher

public class CamelliaEngine
extends java.lang.Object
implements BlockCipher

Camellia - based on RFC 3713.


Field Summary
private  long _k1
           
private  long _k10
           
private  long _k11
           
private  long _k12
           
private  long _k13
           
private  long _k14
           
private  long _k15
           
private  long _k16
           
private  long _k17
           
private  long _k18
           
private  long _k19
           
private  long _k2
           
private  long _k20
           
private  long _k21
           
private  long _k22
           
private  long _k23
           
private  long _k24
           
private  long _k3
           
private  long _k4
           
private  long _k5
           
private  long _k6
           
private  long _k7
           
private  long _k8
           
private  long _k9
           
private  long _ke1
           
private  long _ke2
           
private  long _ke3
           
private  long _ke4
           
private  long _ke5
           
private  long _ke6
           
private  boolean _keyIs128
           
private  long _kw1
           
private  long _kw2
           
private  long _kw3
           
private  long _kw4
           
private static int BLOCK_SIZE
           
private  boolean initialised
           
private static long MASK32
           
private static long MASK8
           
private  byte[] SBOX1
           
private  byte[] SBOX2
           
private  byte[] SBOX3
           
private  byte[] SBOX4
           
private static long SIGMA1
           
private static long SIGMA2
           
private static long SIGMA3
           
private static long SIGMA4
           
private static long SIGMA5
           
private static long SIGMA6
           
 
Constructor Summary
CamelliaEngine()
           
 
Method Summary
private  long bytesToWord(byte[] src, int srcOff)
           
private  long f(long in, long ke)
           
private  long fl(long in, long ke)
           
private  long flInv(long in, long ke)
           
 java.lang.String getAlgorithmName()
          Return the name of the algorithm the cipher implements.
 int getBlockSize()
          Return the block size for this cipher (in bytes).
 void init(boolean forEncryption, CipherParameters params)
          Initialise the cipher.
private  long lRot128high(long a, long b, int rotation)
           
private  long lRot128low(long a, long b, int rotation)
           
private  int lRot32(int value, int rotation)
           
private  byte lRot8(byte value, int rotation)
           
 int processBlock(byte[] in, int inOff, byte[] out, int outOff)
          Process one block of input from the array in and write it to the out array.
private  int processBlock128(byte[] in, int inOff, byte[] out, int outOff)
           
private  int processBlock192or256(byte[] in, int inOff, byte[] out, int outOff)
           
 void reset()
          Reset the cipher.
private  void setKey(boolean forEncryption, byte[] key)
           
private  void wordToBytes(long word, byte[] dst, int dstOff)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

initialised

private boolean initialised

_keyIs128

private boolean _keyIs128

BLOCK_SIZE

private static final int BLOCK_SIZE
See Also:
Constant Field Values

MASK8

private static final long MASK8
See Also:
Constant Field Values

MASK32

private static final long MASK32
See Also:
Constant Field Values

SIGMA1

private static final long SIGMA1
See Also:
Constant Field Values

SIGMA2

private static final long SIGMA2
See Also:
Constant Field Values

SIGMA3

private static final long SIGMA3
See Also:
Constant Field Values

SIGMA4

private static final long SIGMA4
See Also:
Constant Field Values

SIGMA5

private static final long SIGMA5
See Also:
Constant Field Values

SIGMA6

private static final long SIGMA6
See Also:
Constant Field Values

_kw1

private long _kw1

_kw2

private long _kw2

_kw3

private long _kw3

_kw4

private long _kw4

_k1

private long _k1

_k2

private long _k2

_k3

private long _k3

_k4

private long _k4

_k5

private long _k5

_k6

private long _k6

_k7

private long _k7

_k8

private long _k8

_k9

private long _k9

_k10

private long _k10

_k11

private long _k11

_k12

private long _k12

_k13

private long _k13

_k14

private long _k14

_k15

private long _k15

_k16

private long _k16

_k17

private long _k17

_k18

private long _k18

_k19

private long _k19

_k20

private long _k20

_k21

private long _k21

_k22

private long _k22

_k23

private long _k23

_k24

private long _k24

_ke1

private long _ke1

_ke2

private long _ke2

_ke3

private long _ke3

_ke4

private long _ke4

_ke5

private long _ke5

_ke6

private long _ke6

SBOX1

private final byte[] SBOX1

SBOX2

private final byte[] SBOX2

SBOX3

private final byte[] SBOX3

SBOX4

private final byte[] SBOX4
Constructor Detail

CamelliaEngine

public CamelliaEngine()
Method Detail

setKey

private void setKey(boolean forEncryption,
                    byte[] key)

init

public void init(boolean forEncryption,
                 CipherParameters params)
          throws java.lang.IllegalArgumentException
Description copied from interface: BlockCipher
Initialise the cipher.

Specified by:
init in interface BlockCipher
Parameters:
forEncryption - if true the cipher is initialised for encryption, if false for decryption.
params - the key and other data required by the cipher.
Throws:
java.lang.IllegalArgumentException - if the params argument is inappropriate.

getAlgorithmName

public java.lang.String getAlgorithmName()
Description copied from interface: BlockCipher
Return the name of the algorithm the cipher implements.

Specified by:
getAlgorithmName in interface BlockCipher
Returns:
the name of the algorithm the cipher implements.

getBlockSize

public int getBlockSize()
Description copied from interface: BlockCipher
Return the block size for this cipher (in bytes).

Specified by:
getBlockSize in interface BlockCipher
Returns:
the block size for this cipher in bytes.

processBlock

public int processBlock(byte[] in,
                        int inOff,
                        byte[] out,
                        int outOff)
                 throws DataLengthException,
                        java.lang.IllegalStateException
Description copied from interface: BlockCipher
Process one block of input from the array in and write it to the out array.

Specified by:
processBlock in interface BlockCipher
Parameters:
in - the array containing the input data.
inOff - offset into the in array the data starts at.
out - the array the output data will be copied into.
outOff - the offset into the out array the output will start at.
Returns:
the number of bytes processed and produced.
Throws:
DataLengthException - if there isn't enough data in in, or space in out.
java.lang.IllegalStateException - if the cipher isn't initialised.

reset

public void reset()
Description copied from interface: BlockCipher
Reset the cipher. After resetting the cipher is in the same state as it was after the last init (if there was one).

Specified by:
reset in interface BlockCipher

lRot8

private byte lRot8(byte value,
                   int rotation)

lRot32

private int lRot32(int value,
                   int rotation)

lRot128high

private long lRot128high(long a,
                         long b,
                         int rotation)

lRot128low

private long lRot128low(long a,
                        long b,
                        int rotation)

fl

private long fl(long in,
                long ke)

flInv

private long flInv(long in,
                   long ke)

f

private long f(long in,
               long ke)

bytesToWord

private long bytesToWord(byte[] src,
                         int srcOff)

wordToBytes

private void wordToBytes(long word,
                         byte[] dst,
                         int dstOff)

processBlock128

private int processBlock128(byte[] in,
                            int inOff,
                            byte[] out,
                            int outOff)
                     throws DataLengthException,
                            java.lang.IllegalStateException
Throws:
DataLengthException
java.lang.IllegalStateException

processBlock192or256

private int processBlock192or256(byte[] in,
                                 int inOff,
                                 byte[] out,
                                 int outOff)
                          throws DataLengthException,
                                 java.lang.IllegalStateException
Throws:
DataLengthException
java.lang.IllegalStateException