Table of Contents

Class KeccakDigest

Namespace
Org.BouncyCastle.Crypto.Digests
Assembly
BouncyCastle.Cryptography.dll

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

public class KeccakDigest : IDigest, IMemoable
Inheritance
KeccakDigest
Implements
Derived
Inherited Members

Remarks

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

Constructors

KeccakDigest()

public KeccakDigest()

KeccakDigest(KeccakDigest)

public KeccakDigest(KeccakDigest source)

Parameters

source KeccakDigest

KeccakDigest(int)

public KeccakDigest(int bitLength)

Parameters

bitLength int

Fields

bitsInQueue

protected int bitsInQueue

Field Value

int

dataQueue

protected byte[] dataQueue

Field Value

byte[]

fixedOutputLength

protected int fixedOutputLength

Field Value

int

rate

protected int rate

Field Value

int

squeezing

protected bool squeezing

Field Value

bool

Properties

AlgorithmName

The algorithm name.

public virtual string AlgorithmName { get; }

Property Value

string

Methods

Absorb(byte)

protected void Absorb(byte data)

Parameters

data byte

Absorb(byte[], int, int)

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

Parameters

data byte[]
off int
len int

Absorb(ReadOnlySpan<byte>)

protected void Absorb(ReadOnlySpan<byte> data)

Parameters

data ReadOnlySpan<byte>

AbsorbBits(int, int)

protected void AbsorbBits(int data, int bits)

Parameters

data int
bits int

BlockUpdate(byte[], int, int)

Update the message digest with a block of bytes.

public virtual void BlockUpdate(byte[] input, int inOff, int len)

Parameters

input byte[]

The byte array containing the data.

inOff int

The offset into the byte array where the data starts.

len int

BlockUpdate(ReadOnlySpan<byte>)

Update the message digest with a span of bytes.

public virtual void BlockUpdate(ReadOnlySpan<byte> input)

Parameters

input ReadOnlySpan<byte>

The span containing the data.

Copy()

Produce a copy of this object with its configuration and in its current state.

public virtual IMemoable Copy()

Returns

IMemoable

Remarks

The returned object may be used simply to store the state, or may be used as a similar object starting from the copied state.

DoFinal(byte[], int)

Close the digest, producing the final digest value.

public virtual int DoFinal(byte[] output, int outOff)

Parameters

output byte[]

The byte array the digest is to be copied into.

outOff int

The offset into the byte array the digest is to start at.

Returns

int

The number of bytes written.

Remarks

This call leaves the digest reset.

DoFinal(byte[], int, byte, int)

protected virtual int DoFinal(byte[] output, int outOff, byte partialByte, int partialBits)

Parameters

output byte[]
outOff int
partialByte byte
partialBits int

Returns

int

DoFinal(Span<byte>)

Close the digest, producing the final digest value.

public virtual int DoFinal(Span<byte> output)

Parameters

output Span<byte>

The span the digest is to be copied into.

Returns

int

The number of bytes written.

Remarks

This call leaves the digest reset.

GetByteLength()

public virtual int GetByteLength()

Returns

int

GetDigestSize()

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

public virtual int GetDigestSize()

Returns

int

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

Reset()

Reset the digest back to its initial state.

public virtual void Reset()

Reset(IMemoable)

Restore a copied object state into this object.

public virtual void Reset(IMemoable other)

Parameters

other IMemoable

an object originally {@link #copy() copied} from an object of the same type as this instance.

Remarks

Implementations of this method should try to avoid or minimise memory allocation to perform the reset.

Exceptions

InvalidCastException

if the provided object is not of the correct type.

MemoableResetException

if the other parameter is in some other way invalid.

Squeeze(byte[], int, long)

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

Parameters

output byte[]
offset int
outputLength long

Squeeze(Span<byte>)

protected void Squeeze(Span<byte> output)

Parameters

output Span<byte>

Update(byte)

Update the message digest with a single byte.

public virtual void Update(byte input)

Parameters

input byte

The input byte to be entered.