Top Description Fields Constructors Methods
org.bouncycastle.crypto.engines

public Class LEAEngine

extends Object
implements BlockCipher
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.BlockCipher
Imports
org.bouncycastle.crypto.BlockCipher, .CipherParameters, .CryptoServicesRegistrar, .DataLengthException, .OutputLengthException, org.bouncycastle.crypto.constraints.DefaultServiceProperties, org.bouncycastle.crypto.params.KeyParameter, org.bouncycastle.util.Integers, .Pack

LEA Cipher engine.

Field Summary

Modifier and TypeField and Description
private static final int
BASEROUNDS

Base number of rounds.

private static final int
BLOCKSIZE

BlockSize.

private static final int[]
DELTA

Delta values.

private boolean
forEncryption

Are we encrypting?

private static final int
KEY0

keyIndex0.

private static final int
KEY1

keyIndex1.

private static final int
KEY2

keyIndex2.

private static final int
KEY3

keyIndex3.

private static final int
KEY4

keyIndex4.

private static final int
KEY5

keyIndex5.

private static final int
MASK128

Mask for mod 4.

private static final int
MASK256

Mask for mod 8.

private static final int
NUMWORDS

Number of words in state.

private static final int
NUMWORDS128

Number of words in 128-bit key.

private static final int
NUMWORDS192

Number of words in 192-bit key.

private static final int
NUMWORDS256

Number of words in 256-bit key.

private static final int
ROT1

Rotate1.

private static final int
ROT11

Rotate11.

private static final int
ROT13

Rotate13.

private static final int
ROT17

Rotate17.

private static final int
ROT3

Rotate3.

private static final int
ROT5

Rotate5.

private static final int
ROT6

Rotate6.

private static final int
ROT9

Rotate9.

private final int[]
theBlock

The work buffer.

private int[][]
theRoundKeys

The round keys.

private int
theRounds

The # of rounds.

Constructor Summary

AccessConstructor and Description
public
LEAEngine()

Constructor.

Method Summary

Modifier and TypeMethod and Description
private static int

Returns:

the length
bufLength
(final byte[]
the buffer
pBuffer
)

Obtain buffer length (allowing for null).

private static void
checkBuffer(final byte[]
the buffer
pBuffer
,
final int
the offset
pOffset
,
final boolean
is this an output buffer?
pOutput
)

Check buffer.

private int

Returns:

the bytes processed
decryptBlock
(final byte[]
the input buffer
pInput
,
final int
the input offset
pInOff
,
final byte[]
the output offset
pOutput
,
final int
the output offset
pOutOff
)

Decrypt a block.

private void
decryptRound(final int
the round#
pRound
)

Decrypt a round.

private int

Returns:

the bytes processed
encryptBlock
(final byte[]
the input buffer
pInput
,
final int
the input offset
pInOff
,
final byte[]
the output offset
pOutput
,
final int
the output offset
pOutOff
)

Encrypt a block.

private void
encryptRound(final int
the round#
pRound
)

Encrypt a round.

private void
generate128RoundKeys(final int[]
the working keys
pWork
)

Generate the round keys from 128-bit key.

private void
generate192RoundKeys(final int[]
the working keys
pWork
)

Generate the round keys from 192-bit key.

private void
generate256RoundKeys(final int[]
the working keys
pWork
)

Generate the round keys from 256-bit key.

private void
generateRoundKeys(final byte[]
the key
pKey
)

Generate the round keys.

public String
getAlgorithmName()

Implements org.bouncycastle.crypto.BlockCipher.getAlgorithmName.

Return the name of the algorithm the cipher implements.

public int
getBlockSize()

Implements org.bouncycastle.crypto.BlockCipher.getBlockSize.

Return the block size for this cipher (in bytes).

public void
init(final boolean
if true the cipher is initialised for encryption, if false for decryption.
pEncrypt
,
final CipherParameters
the key and other data required by the cipher.
pParams
)

Implements org.bouncycastle.crypto.BlockCipher.init.

Initialise the cipher.

private static int

Returns:

the left of an index
leftIndex
(final int
the index
pIndex
)

Return the left of an index.

public int
processBlock(final byte[]
the array containing the input data.
pInput
,
final int
offset into the in array the data starts at.
pInOff
,
final byte[]
the array the output data will be copied into.
pOutput
,
final int
the offset into the out array the output will start at.
pOutOff
)

Implements org.bouncycastle.crypto.BlockCipher.processBlock.

Process one block of input from the array in and write it to the out array.

public void
reset()

Implements org.bouncycastle.crypto.BlockCipher.reset.

Reset the cipher.

private static int

Returns:

the left of an index
rightIndex
(final int
the index
pIndex
)

Return the left of an index.

private static int

Returns:

the rotated value
rol32
(final int
the value to rotate
pValue
,
final int
the # of bits to rotate
pBits
)

rotate left.

private static int

Returns:

the rotated value
ror32
(final int
the value to rotate
pValue
,
final int
the # of bits to rotate
pBits
)

rotate right.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BASEROUNDSback to summary
private static final int BASEROUNDS

Base number of rounds.

BLOCKSIZEback to summary
private static final int BLOCKSIZE

BlockSize.

DELTAback to summary
private static final int[] DELTA

Delta values.

forEncryptionback to summary
private boolean forEncryption

Are we encrypting?

KEY0back to summary
private static final int KEY0

keyIndex0.

KEY1back to summary
private static final int KEY1

keyIndex1.

KEY2back to summary
private static final int KEY2

keyIndex2.

KEY3back to summary
private static final int KEY3

keyIndex3.

KEY4back to summary
private static final int KEY4

keyIndex4.

KEY5back to summary
private static final int KEY5

keyIndex5.

MASK128back to summary
private static final int MASK128

Mask for mod 4.

MASK256back to summary
private static final int MASK256

Mask for mod 8.

NUMWORDSback to summary
private static final int NUMWORDS

Number of words in state.

NUMWORDS128back to summary
private static final int NUMWORDS128

Number of words in 128-bit key.

NUMWORDS192back to summary
private static final int NUMWORDS192

Number of words in 192-bit key.

NUMWORDS256back to summary
private static final int NUMWORDS256

Number of words in 256-bit key.

ROT1back to summary
private static final int ROT1

Rotate1.

ROT11back to summary
private static final int ROT11

Rotate11.

ROT13back to summary
private static final int ROT13

Rotate13.

ROT17back to summary
private static final int ROT17

Rotate17.

ROT3back to summary
private static final int ROT3

Rotate3.

ROT5back to summary
private static final int ROT5

Rotate5.

ROT6back to summary
private static final int ROT6

Rotate6.

ROT9back to summary
private static final int ROT9

Rotate9.

theBlockback to summary
private final int[] theBlock

The work buffer.

theRoundKeysback to summary
private int[][] theRoundKeys

The round keys.

theRoundsback to summary
private int theRounds

The # of rounds.

Constructor Detail

LEAEngineback to summary
public LEAEngine()

Constructor.

Method Detail

bufLengthback to summary
private static int bufLength(final byte[] pBuffer)

Obtain buffer length (allowing for null).

Parameters
pBuffer:byte[]

the buffer

Returns:int

the length

checkBufferback to summary
private static void checkBuffer(final byte[] pBuffer, final int pOffset, final boolean pOutput)

Check buffer.

Parameters
pBuffer:byte[]

the buffer

pOffset:int

the offset

pOutput:boolean

is this an output buffer?

decryptBlockback to summary
private int decryptBlock(final byte[] pInput, final int pInOff, final byte[] pOutput, final int pOutOff)

Decrypt a block.

Parameters
pInput:byte[]

the input buffer

pInOff:int

the input offset

pOutput:byte[]

the output offset

pOutOff:int

the output offset

Returns:int

the bytes processed

decryptRoundback to summary
private void decryptRound(final int pRound)

Decrypt a round.

Parameters
pRound:int

the round#

encryptBlockback to summary
private int encryptBlock(final byte[] pInput, final int pInOff, final byte[] pOutput, final int pOutOff)

Encrypt a block.

Parameters
pInput:byte[]

the input buffer

pInOff:int

the input offset

pOutput:byte[]

the output offset

pOutOff:int

the output offset

Returns:int

the bytes processed

encryptRoundback to summary
private void encryptRound(final int pRound)

Encrypt a round.

Parameters
pRound:int

the round#

generate128RoundKeysback to summary
private void generate128RoundKeys(final int[] pWork)

Generate the round keys from 128-bit key.

Parameters
pWork:int[]

the working keys

generate192RoundKeysback to summary
private void generate192RoundKeys(final int[] pWork)

Generate the round keys from 192-bit key.

Parameters
pWork:int[]

the working keys

generate256RoundKeysback to summary
private void generate256RoundKeys(final int[] pWork)

Generate the round keys from 256-bit key.

Parameters
pWork:int[]

the working keys

generateRoundKeysback to summary
private void generateRoundKeys(final byte[] pKey)

Generate the round keys.

Parameters
pKey:byte[]

the key

getAlgorithmNameback to summary
public String getAlgorithmName()

Implements org.bouncycastle.crypto.BlockCipher.getAlgorithmName.

Doc from org.bouncycastle.crypto.BlockCipher.getAlgorithmName.

Return the name of the algorithm the cipher implements.

Returns:String

the name of the algorithm the cipher implements.

getBlockSizeback to summary
public int getBlockSize()

Implements org.bouncycastle.crypto.BlockCipher.getBlockSize.

Doc from org.bouncycastle.crypto.BlockCipher.getBlockSize.

Return the block size for this cipher (in bytes).

Returns:int

the block size for this cipher in bytes.

initback to summary
public void init(final boolean pEncrypt, final CipherParameters pParams)

Implements org.bouncycastle.crypto.BlockCipher.init.

Doc from org.bouncycastle.crypto.BlockCipher.init.

Initialise the cipher.

Parameters
pEncrypt:boolean

if true the cipher is initialised for encryption, if false for decryption.

pParams:CipherParameters

the key and other data required by the cipher.

leftIndexback to summary
private static int leftIndex(final int pIndex)

Return the left of an index.

Parameters
pIndex:int

the index

Returns:int

the left of an index

processBlockback to summary
public int processBlock(final byte[] pInput, final int pInOff, final byte[] pOutput, final int pOutOff)

Implements org.bouncycastle.crypto.BlockCipher.processBlock.

Doc from org.bouncycastle.crypto.BlockCipher.processBlock.

Process one block of input from the array in and write it to the out array.

Parameters
pInput:byte[]

the array containing the input data.

pInOff:int

offset into the in array the data starts at.

pOutput:byte[]

the array the output data will be copied into.

pOutOff:int

the offset into the out array the output will start at.

Returns:int

the number of bytes processed and produced.

resetback to summary
public void reset()

Implements org.bouncycastle.crypto.BlockCipher.reset.

Doc from org.bouncycastle.crypto.BlockCipher.reset.

Reset the cipher. After resetting the cipher is in the same state as it was after the last init (if there was one).

rightIndexback to summary
private static int rightIndex(final int pIndex)

Return the left of an index.

Parameters
pIndex:int

the index

Returns:int

the left of an index

rol32back to summary
private static int rol32(final int pValue, final int pBits)

rotate left.

Parameters
pValue:int

the value to rotate

pBits:int

the # of bits to rotate

Returns:int

the rotated value

ror32back to summary
private static int ror32(final int pValue, final int pBits)

rotate right.

Parameters
pValue:int

the value to rotate

pBits:int

the # of bits to rotate

Returns:int

the rotated value