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

public Class ElephantEngine

extends AEADBaseEngine
Class Inheritance
Imports
java.io.ByteArrayOutputStream, java.util.Arrays, org.bouncycastle.crypto.DataLengthException, .InvalidCipherTextException, .OutputLengthException

Elephant AEAD v2, based on the current round 3 submission, https://www.esat.kuleuven.be/cosic/elephant/ Reference C implementation: https://github.com/TimBeyne/Elephant

Specification

https://csrc.nist.gov/CSRC/media/Projects/lightweight-cryptography/documents/finalist-round/updated-spec-doc/elephant-spec-final.pdf

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
private static enum

Field Summary

Modifier and TypeField and Description
private final ByteArrayOutputStream
private byte[]
private int
private int
private final int
private final byte[]
private byte[]
private byte[]
private boolean
private byte[]
private int
private final int[]
private final byte[]
private byte
private ElephantEngine.State
private int
private int
private int
private byte[]
private byte[]
private final int
private int
private final ElephantEngine.ElephantParameters
private byte[]
private final byte[]
private final byte[]
private final byte[]
Inherited from org.bouncycastle.crypto.engines.AEADBaseEngine:
algorithmNameforEncryptioninitialAssociatedTextIV_SIZEKEY_SIZEmacMAC_SIZE

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
public int
doFinal(byte[]
space for any resulting output data.
output
,
int
offset into out to start copying the data at.
outOff
)

Implements org.bouncycastle.crypto.modes.AEADCipher.doFinal.

Finish the operation either appending or verifying the MAC at the end of the data.

public int
public int
getOutputSize(int
the length of the input.
len
)

Implements org.bouncycastle.crypto.modes.AEADCipher.getOutputSize.

return the size of the output buffer required for a processBytes plus a doFinal with an input of len bytes.

public int
getUpdateOutputSize(int
the length of the input.
len
)

Implements org.bouncycastle.crypto.modes.AEADCipher.getUpdateOutputSize.

return the size of the output buffer required for a processBytes an input of len bytes.

private int
index(int x, int y)

protected void
init(byte[] k, byte[] iv)

Implements abstract org.bouncycastle.crypto.engines.AEADBaseEngine.init.

private void
KeccakP200Round(byte[] state, int indexRound)

private void
lfsr_step(byte[] output, byte[] input)

private void
permutation(byte[] state)

public void
processAADByte(byte
the byte to be processed.
input
)

Implements org.bouncycastle.crypto.modes.AEADCipher.processAADByte.

Add a single byte to the associated data check.

public void
processAADBytes(byte[]
the input byte array.
input
,
int
the offset into the in array where the data to be processed starts.
inOff
,
int
the number of bytes to be processed.
len
)

Implements org.bouncycastle.crypto.modes.AEADCipher.processAADBytes.

Add a sequence of bytes to the associated data check.

private int
private void
processAADBytes(byte[] output)

public int
processBytes(byte[]
the input byte array.
input
,
int
the offset into the in array where the data to be processed starts.
inOff
,
int
the number of bytes to be processed.
len
,
byte[]
the output buffer the processed bytes go into.
output
,
int
the offset into the output byte array the processed data starts at.
outOff
)

Implements org.bouncycastle.crypto.modes.AEADCipher.processBytes.

process a block of bytes from in putting the result into out.

private int
processBytes(byte[] m, byte[] output, int outOff, int nb_it, int nblocks_m, int nblocks_c, int mlen, int nblocks_ad, boolean isDofinal)

protected void
private byte
ROL8(byte a, int offset)

private byte
rotl(byte b)

private void
xor_block(byte[] state, byte[] block, int bOff, int size)

Inherited from org.bouncycastle.crypto.engines.AEADBaseEngine:
getAlgorithmNamegetIVBytesSizegetKeyBytesSizegetMacinitprocessBytereset

Field Detail

aadDataback to summary
private final ByteArrayOutputStream aadData
adlenback to summary
private int adlen
adOffback to summary
private int adOff
BLOCK_SIZEback to summary
private final int BLOCK_SIZE
bufferback to summary
private final byte[] buffer
current_maskback to summary
private byte[] current_mask
expanded_keyback to summary
private byte[] expanded_key
initialisedback to summary
private boolean initialised
inputMessageback to summary
private byte[] inputMessage
inputOffback to summary
private int inputOff
KeccakRhoOffsetsback to summary
private final int[] KeccakRhoOffsets
KeccakRoundConstantsback to summary
private final byte[] KeccakRoundConstants
lfsrIVback to summary
private byte lfsrIV
m_stateback to summary
private ElephantEngine.State m_state
messageLenback to summary
private int messageLen
nb_itsback to summary
private int nb_its
nBitsback to summary
private int nBits
next_maskback to summary
private byte[] next_mask
npubback to summary
private byte[] npub
nRoundsback to summary
private final int nRounds
nSBoxback to summary
private int nSBox
parametersback to summary
private final ElephantEngine.ElephantParameters parameters
previous_maskback to summary
private byte[] previous_mask
previous_outputMessageback to summary
private final byte[] previous_outputMessage
sBoxLayerback to summary
private final byte[] sBoxLayer
tag_bufferback to summary
private final byte[] tag_buffer

Constructor Detail

ElephantEngineback to summary
public ElephantEngine(ElephantEngine.ElephantParameters parameters)

Method Detail

checkAadback to summary
private void checkAad()
doFinalback to summary
public int doFinal(byte[] output, int outOff) throws IllegalStateException, InvalidCipherTextException

Implements org.bouncycastle.crypto.modes.AEADCipher.doFinal.

Doc from org.bouncycastle.crypto.modes.AEADCipher.doFinal.

Finish the operation either appending or verifying the MAC at the end of the data.

Parameters
output:byte[]

space for any resulting output data.

outOff:int

offset into out to start copying the data at.

Returns:int

number of bytes written into out.

Annotations
@Override
Exceptions
IllegalStateException:
if the cipher is in an inappropriate state.
InvalidCipherTextException:
if the MAC fails to match.
getBlockSizeback to summary
public int getBlockSize()
getOutputSizeback to summary
public int getOutputSize(int len)

Implements org.bouncycastle.crypto.modes.AEADCipher.getOutputSize.

Doc from org.bouncycastle.crypto.modes.AEADCipher.getOutputSize.

return the size of the output buffer required for a processBytes plus a doFinal with an input of len bytes.

The returned size may be dependent on the initialisation of this cipher and may not be accurate once subsequent input data is processed - this method should be invoked immediately prior to a call to final processing of input data and a call to doFinal(byte[], int).

Parameters
len:int

the length of the input.

Returns:int

the space required to accommodate a call to processBytes and doFinal with len bytes of input.

Annotations
@Override
getUpdateOutputSizeback to summary
public int getUpdateOutputSize(int len)

Implements org.bouncycastle.crypto.modes.AEADCipher.getUpdateOutputSize.

Doc from org.bouncycastle.crypto.modes.AEADCipher.getUpdateOutputSize.

return the size of the output buffer required for a processBytes an input of len bytes.

The returned size may be dependent on the initialisation of this cipher and may not be accurate once subsequent input data is processed - this method should be invoked immediately prior to input data being processed.

Parameters
len:int

the length of the input.

Returns:int

the space required to accommodate a call to processBytes with len bytes of input.

Annotations
@Override
indexback to summary
private int index(int x, int y)
initback to summary
protected void init(byte[] k, byte[] iv) throws IllegalArgumentException

Implements abstract org.bouncycastle.crypto.engines.AEADBaseEngine.init.

Annotations
@Override
KeccakP200Roundback to summary
private void KeccakP200Round(byte[] state, int indexRound)
lfsr_stepback to summary
private void lfsr_step(byte[] output, byte[] input)
permutationback to summary
private void permutation(byte[] state)
processAADByteback to summary
public void processAADByte(byte input)

Implements org.bouncycastle.crypto.modes.AEADCipher.processAADByte.

Doc from org.bouncycastle.crypto.modes.AEADCipher.processAADByte.

Add a single byte to the associated data check.
If the implementation supports it, this will be an online operation and will not retain the associated data.

Parameters
input:byte

the byte to be processed.

Annotations
@Override
processAADBytesback to summary
public void processAADBytes(byte[] input, int inOff, int len)

Implements org.bouncycastle.crypto.modes.AEADCipher.processAADBytes.

Doc from org.bouncycastle.crypto.modes.AEADCipher.processAADBytes.

Add a sequence of bytes to the associated data check.
If the implementation supports it, this will be an online operation and will not retain the associated data.

Parameters
input:byte[]

the input byte array.

inOff:int

the offset into the in array where the data to be processed starts.

len:int

the number of bytes to be processed.

Annotations
@Override
processAADBytesback to summary
private int processAADBytes()
processAADBytesback to summary
private void processAADBytes(byte[] output)
processBytesback to summary
public int processBytes(byte[] input, int inOff, int len, byte[] output, int outOff) throws DataLengthException

Implements org.bouncycastle.crypto.modes.AEADCipher.processBytes.

Doc from org.bouncycastle.crypto.modes.AEADCipher.processBytes.

process a block of bytes from in putting the result into out.

Parameters
input:byte[]

the input byte array.

inOff:int

the offset into the in array where the data to be processed starts.

len:int

the number of bytes to be processed.

output:byte[]

the output buffer the processed bytes go into.

outOff:int

the offset into the output byte array the processed data starts at.

Returns:int

the number of bytes written to out.

Annotations
@Override
Exceptions
DataLengthException:
if the output buffer is too small.
processBytesback to summary
private int processBytes(byte[] m, byte[] output, int outOff, int nb_it, int nblocks_m, int nblocks_c, int mlen, int nblocks_ad, boolean isDofinal)
resetback to summary
protected void reset(boolean clearMac)

Overrides org.bouncycastle.crypto.engines.AEADBaseEngine.reset.

ROL8back to summary
private byte ROL8(byte a, int offset)
rotlback to summary
private byte rotl(byte b)
xor_blockback to summary
private void xor_block(byte[] state, byte[] block, int bOff, int size)
org.bouncycastle.crypto.engines back to summary

public final Enum ElephantEngine.ElephantParameters

extends Enum<ElephantEngine.ElephantParameters>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final ElephantEngine.ElephantParameters
public static final ElephantEngine.ElephantParameters
public static final ElephantEngine.ElephantParameters

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ElephantEngine.ElephantParameters
public static ElephantEngine.ElephantParameters[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

elephant160back to summary
public static final ElephantEngine.ElephantParameters elephant160
elephant176back to summary
public static final ElephantEngine.ElephantParameters elephant176
elephant200back to summary
public static final ElephantEngine.ElephantParameters elephant200

Constructor Detail

ElephantParametersback to summary
private ElephantParameters()

Method Detail

valueOfback to summary
public static ElephantEngine.ElephantParameters valueOf(String name)
valuesback to summary
public static ElephantEngine.ElephantParameters[] values()
org.bouncycastle.crypto.engines back to summary

private final Enum ElephantEngine.State

extends Enum<ElephantEngine.State>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final ElephantEngine.State
public static final ElephantEngine.State
public static final ElephantEngine.State
public static final ElephantEngine.State
public static final ElephantEngine.State
public static final ElephantEngine.State
public static final ElephantEngine.State
public static final ElephantEngine.State
public static final ElephantEngine.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ElephantEngine.State
public static ElephantEngine.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

DecAadback to summary
public static final ElephantEngine.State DecAad
DecDataback to summary
public static final ElephantEngine.State DecData
DecFinalback to summary
public static final ElephantEngine.State DecFinal
DecInitback to summary
public static final ElephantEngine.State DecInit
EncAadback to summary
public static final ElephantEngine.State EncAad
EncDataback to summary
public static final ElephantEngine.State EncData
EncFinalback to summary
public static final ElephantEngine.State EncFinal
EncInitback to summary
public static final ElephantEngine.State EncInit
Uninitializedback to summary
public static final ElephantEngine.State Uninitialized

Constructor Detail

Stateback to summary
private State()

Method Detail

valueOfback to summary
public static ElephantEngine.State valueOf(String name)
valuesback to summary
public static ElephantEngine.State[] values()