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

public Class KeccakDigest

extends Object
implements ExtendedDigest
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.ExtendedDigest, org.bouncycastle.crypto.Digest
Known Direct Subclasses
org.bouncycastle.crypto.digests.SHA3Digest, org.bouncycastle.crypto.digests.SHAKEDigest
Imports
org.bouncycastle.crypto.CryptoServiceProperties, .CryptoServicePurpose, .CryptoServicesRegistrar, .ExtendedDigest, org.bouncycastle.util.Arrays, .Pack

implementation of Keccak based on following KeccakNISTInterface.c from https://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 byte[]
protected int
private static long[]
protected final CryptoServicePurpose
protected int
protected boolean
protected long[]

Constructor Summary

AccessConstructor and Description
public
public
public
KeccakDigest(int bitLength)

public
KeccakDigest(int bitLength, CryptoServicePurpose purpose)

public

Method Summary

Modifier and TypeMethod and Description
protected void
absorb(byte data)

protected void
absorb(byte[] data, int off, int len)

protected void
absorbBits(int data, int bits)

protected CryptoServiceProperties
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.Digest.doFinal.

close the digest, producing the final digest value.

protected int
doFinal(byte[] out, int outOff, byte partialByte, int partialBits)

public String
public int

Returns:

internal byte length of a block.
getByteLength
()

Implements org.bouncycastle.crypto.ExtendedDigest.getByteLength.

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

public int
getDigestSize()

Implements org.bouncycastle.crypto.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)

private void
KeccakAbsorb(byte[] data, int off)

private void
private void
private void
public void
reset()

Implements org.bouncycastle.crypto.Digest.reset.

reset the digest back to it's initial state.

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

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

Implements org.bouncycastle.crypto.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.Digest.update.

update the message digest with a block of bytes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bitsInQueueback to summary
protected int bitsInQueue
dataQueueback to summary
protected byte[] dataQueue
fixedOutputLengthback to summary
protected int fixedOutputLength
KeccakRoundConstantsback to summary
private static long[] KeccakRoundConstants
purposeback to summary
protected final CryptoServicePurpose purpose
rateback to summary
protected int rate
squeezingback to summary
protected boolean squeezing
stateback to summary
protected long[] state

Constructor Detail

KeccakDigestback to summary
public KeccakDigest()
KeccakDigestback to summary
public KeccakDigest(CryptoServicePurpose purpose)
KeccakDigestback to summary
public KeccakDigest(int bitLength)
KeccakDigestback to summary
public KeccakDigest(int bitLength, CryptoServicePurpose purpose)
KeccakDigestback to summary
public KeccakDigest(KeccakDigest source)

Method Detail

absorbback to summary
protected void absorb(byte data)
absorbback to summary
protected void absorb(byte[] data, int off, int len)
absorbBitsback to summary
protected void absorbBits(int data, int bits)
cryptoServicePropertiesback to summary
protected CryptoServiceProperties cryptoServiceProperties()
doFinalback to summary
public int doFinal(byte[] out, int outOff)

Implements org.bouncycastle.crypto.Digest.doFinal.

Doc from org.bouncycastle.crypto.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)
getAlgorithmNameback to summary
public String getAlgorithmName()

Implements org.bouncycastle.crypto.Digest.getAlgorithmName.

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

return the algorithm name

Returns:String

the algorithm name

getByteLengthback to summary
public int getByteLength()

Implements org.bouncycastle.crypto.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.Digest.getDigestSize.

Doc from org.bouncycastle.crypto.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)
KeccakAbsorbback to summary
private void KeccakAbsorb(byte[] data, int off)
KeccakExtractback to summary
private void KeccakExtract()
KeccakPermutationback to summary
private void KeccakPermutation()
padAndSwitchToSqueezingPhaseback to summary
private void padAndSwitchToSqueezingPhase()
resetback to summary
public void reset()

Implements org.bouncycastle.crypto.Digest.reset.

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

reset the digest back to it's initial state.

squeezeback to summary
protected void squeeze(byte[] output, int offset, long outputLength)
updateback to summary
public void update(byte in)

Implements org.bouncycastle.crypto.Digest.update.

Doc from org.bouncycastle.crypto.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.Digest.update.

Doc from org.bouncycastle.crypto.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.