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

pack-priv Class KeccakDigest

extends Object
implements ExtendedDigest
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.internal.ExtendedDigest, org.bouncycastle.crypto.internal.Digest
Known Direct Subclasses
org.bouncycastle.crypto.fips.SHA3Digest, org.bouncycastle.crypto.fips.SHAKEDigest
Imports
org.bouncycastle.crypto.internal.ExtendedDigest, org.bouncycastle.util.Arrays

implementation of Keccak based on following KeccakNISTInterface.c from http://keccak.noekeon.org/

Following the naming conventions used in the C source code to enable easy review of the implementation.

Field Summary

Modifier and TypeField and Description
protected int
protected int
pack-priv long[]
C

pack-priv long[]
protected byte[]
protected byte[]
protected int
private static int[]
private static long[]
protected byte[]
protected int
protected boolean
protected byte[]
pack-priv long[]

Constructor Summary

AccessConstructor and Description
public
public
KeccakDigest(int bitLength)

public

Method Summary

Modifier and TypeMethod and Description
protected void
absorb(byte[] data, int off, long databitlen)

private void
private void
chi(long[] A)

private void
clearDataQueueSection(int off, int len)

public int
doFinal(byte[]
the array the digest is to be copied into.
out
,
int
the offset into the out array the digest is to start at.
outOff
)

Implements org.bouncycastle.crypto.internal.Digest.doFinal.

close the digest, producing the final digest value.
protected int
doFinal(byte[] out, int outOff, byte partialByte, int partialBits)

private void
fromBytesToWords(long[] stateAsWords, byte[] state)

private void
fromWordsToBytes(byte[] state, long[] stateAsWords)

public String
public int

Returns:

internal byte length of a block.
getByteLength
()

Implements org.bouncycastle.crypto.internal.ExtendedDigest.getByteLength.

Return the size of block that the compression function is applied to in bytes.
public int
getDigestSize()

Implements org.bouncycastle.crypto.internal.Digest.getDigestSize.

return the size, in bytes, of the digest produced by this message digest.
private void
init(int bitLength)

private void
initSponge(int rate, int capacity)

private void
iota(long[] A, int indexRound)

private void
KeccakAbsorb(byte[] byteState, byte[] data, int dataInBytes)

private void
KeccakExtract(byte[] byteState, byte[] data, int laneCount)

private void
KeccakExtract1024bits(byte[] byteState, byte[] data)

private static int[]
private static long[]
private void
keccakPermutation(byte[] state)

private void
keccakPermutationAfterXor(byte[] state, byte[] data, int dataLengthInBytes)

private void
private static boolean
LFSR86540(byte[] LFSR)

private void
private void
pi(long[] A)

public void
reset()

Implements org.bouncycastle.crypto.internal.Digest.reset.

reset the digest back to it's initial state.
private void
rho(long[] A)

protected void
squeeze(byte[] output, int offset, long outputLength)

private void
theta(long[] A)

public void
update(byte
the input byte to be entered.
in
)

Implements org.bouncycastle.crypto.internal.Digest.update.

update the message digest with a single byte.
public void
update(byte[]
the byte array containing the data.
in
,
int
the offset into the byte array where the data starts.
inOff
,
int
the length of the data.
len
)

Implements org.bouncycastle.crypto.internal.Digest.update.

update the message digest with a block of bytes.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bitsAvailableForSqueezingback to summary
protected int bitsAvailableForSqueezing
bitsInQueueback to summary
protected int bitsInQueue
Cback to summary
pack-priv long[] C
chiCback to summary
pack-priv long[] chiC
chunkback to summary
protected byte[] chunk
dataQueueback to summary
protected byte[] dataQueue
fixedOutputLengthback to summary
protected int fixedOutputLength
KeccakRhoOffsetsback to summary
private static int[] KeccakRhoOffsets
KeccakRoundConstantsback to summary
private static long[] KeccakRoundConstants
oneByteback to summary
protected byte[] oneByte
rateback to summary
protected int rate
squeezingback to summary
protected boolean squeezing
stateback to summary
protected byte[] state
tempAback to summary
pack-priv long[] tempA

Constructor Detail

KeccakDigestback to summary
public KeccakDigest()
KeccakDigestback to summary
public KeccakDigest(int bitLength)
KeccakDigestback to summary
public KeccakDigest(KeccakDigest source)

Method Detail

absorbback to summary
protected void absorb(byte[] data, int off, long databitlen)
absorbQueueback to summary
private void absorbQueue()
chiback to summary
private void chi(long[] A)
clearDataQueueSectionback to summary
private void clearDataQueueSection(int off, int len)
doFinalback to summary
public int doFinal(byte[] out, int outOff)

Implements org.bouncycastle.crypto.internal.Digest.doFinal.

Doc from org.bouncycastle.crypto.internal.Digest.doFinal.

close the digest, producing the final digest value. The doFinal call leaves the digest reset.

Parameters
out:byte[]

the array the digest is to be copied into.

outOff:int

the offset into the out array the digest is to start at.

doFinalback to summary
protected int doFinal(byte[] out, int outOff, byte partialByte, int partialBits)
fromBytesToWordsback to summary
private void fromBytesToWords(long[] stateAsWords, byte[] state)
fromWordsToBytesback to summary
private void fromWordsToBytes(byte[] state, long[] stateAsWords)
getAlgorithmNameback to summary
public String getAlgorithmName()

Implements org.bouncycastle.crypto.internal.Digest.getAlgorithmName.

Doc from org.bouncycastle.crypto.internal.Digest.getAlgorithmName.

return the algorithm name

Returns:String

the algorithm name

getByteLengthback to summary
public int getByteLength()

Implements org.bouncycastle.crypto.internal.ExtendedDigest.getByteLength.

Return the size of block that the compression function is applied to in bytes.

Returns:int

internal byte length of a block.

getDigestSizeback to summary
public int getDigestSize()

Implements org.bouncycastle.crypto.internal.Digest.getDigestSize.

Doc from org.bouncycastle.crypto.internal.Digest.getDigestSize.

return the size, in bytes, of the digest produced by this message digest.

Returns:int

the size, in bytes, of the digest produced by this message digest.

initback to summary
private void init(int bitLength)
initSpongeback to summary
private void initSponge(int rate, int capacity)
iotaback to summary
private void iota(long[] A, int indexRound)
KeccakAbsorbback to summary
private void KeccakAbsorb(byte[] byteState, byte[] data, int dataInBytes)
KeccakExtractback to summary
private void KeccakExtract(byte[] byteState, byte[] data, int laneCount)
KeccakExtract1024bitsback to summary
private void KeccakExtract1024bits(byte[] byteState, byte[] data)
keccakInitializeRhoOffsetsback to summary
private static int[] keccakInitializeRhoOffsets()
keccakInitializeRoundConstantsback to summary
private static long[] keccakInitializeRoundConstants()
keccakPermutationback to summary
private void keccakPermutation(byte[] state)
keccakPermutationAfterXorback to summary
private void keccakPermutationAfterXor(byte[] state, byte[] data, int dataLengthInBytes)
keccakPermutationOnWordsback to summary
private void keccakPermutationOnWords(long[] state)
LFSR86540back to summary
private static boolean LFSR86540(byte[] LFSR)
padAndSwitchToSqueezingPhaseback to summary
private void padAndSwitchToSqueezingPhase()
piback to summary
private void pi(long[] A)
resetback to summary
public void reset()

Implements org.bouncycastle.crypto.internal.Digest.reset.

Doc from org.bouncycastle.crypto.internal.Digest.reset.

reset the digest back to it's initial state.

rhoback to summary
private void rho(long[] A)
squeezeback to summary
protected void squeeze(byte[] output, int offset, long outputLength)
thetaback to summary
private void theta(long[] A)
updateback to summary
public void update(byte in)

Implements org.bouncycastle.crypto.internal.Digest.update.

Doc from org.bouncycastle.crypto.internal.Digest.update.

update the message digest with a single byte.

Parameters
in:byte

the input byte to be entered.

updateback to summary
public void update(byte[] in, int inOff, int len)

Implements org.bouncycastle.crypto.internal.Digest.update.

Doc from org.bouncycastle.crypto.internal.Digest.update.

update the message digest with a block of bytes.

Parameters
in:byte[]

the byte array containing the data.

inOff:int

the offset into the byte array where the data starts.

len:int

the length of the data.