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

public Class ParallelHash

extends Object
implements Xof, Digest
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.Digest, org.bouncycastle.crypto.Xof, org.bouncycastle.crypto.ExtendedDigest
Imports
org.bouncycastle.crypto.CryptoServicePurpose, .CryptoServicesRegistrar, .DataLengthException, .Digest, .Xof, org.bouncycastle.util.Arrays, .Strings

ParallelHash - a hash designed to support the efficient hashing of very long strings, by taking advantage of the parallelism available in modern processors with an optional XOF mode.

From NIST Special Publication 800-185 - SHA-3 Derived Functions:cSHAKE, KMAC, TupleHash and ParallelHash

Field Summary

Modifier and TypeField and Description
private final int
B

private final int
private final byte[]
private int
private final CSHAKEDigest
private final byte[]
private final CSHAKEDigest
private boolean
private static final byte[]
private int
private final int
private final CryptoServicePurpose

Constructor Summary

AccessConstructor and Description
public
ParallelHash(int
security strength (bits) of the underlying SHAKE function, 128 or 256.
bitLength
,
byte[]
the customization string - available for local use.
S
,
int
the blocksize (in bytes) for hashing.
B
)

Base constructor.

public
ParallelHash(int bitLength, byte[] S, int B, int outputSize)

public
ParallelHash(int bitLength, byte[] S, int B, int outputSize, CryptoServicePurpose purpose)

public

Method Summary

Modifier and TypeMethod and Description
private void
private void
compress(byte[] buf, int offSet, 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.Digest.doFinal.

close the digest, producing the final digest value.
public int
doFinal(byte[]
output array to write the output bytes to.
out
,
int
offset to start writing the bytes at.
outOff
,
int
the number of output bytes requested.
outLen
)

Implements org.bouncycastle.crypto.Xof.doFinal.

Output the results of the final calculation for this digest to outLen number of bytes.
public int
doOutput(byte[]
output array to write the output bytes to.
out
,
int
offset to start writing the bytes at.
outOff
,
int
the number of output bytes requested.
outLen
)

Implements org.bouncycastle.crypto.Xof.doOutput.

Start outputting the results of the final calculation for this digest.
public String
public int
getByteLength()

Implements org.bouncycastle.crypto.ExtendedDigest.getByteLength.

Return the size in bytes of the internal buffer the digest applies it's compression function to.
public int
getDigestSize()

Implements org.bouncycastle.crypto.Digest.getDigestSize.

return the size, in bytes, of the digest produced by this message digest.
public void
reset()

Implements org.bouncycastle.crypto.Digest.reset.

reset the digest back to it's initial state.
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.
private void
wrapUp(int outputSize)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

Bback to summary
private final int B
bitLengthback to summary
private final int bitLength
bufferback to summary
private final byte[] buffer
bufOffback to summary
private int bufOff
compressorback to summary
private final CSHAKEDigest compressor
compressorBufferback to summary
private final byte[] compressorBuffer
cshakeback to summary
private final CSHAKEDigest cshake
firstOutputback to summary
private boolean firstOutput
N_PARALLEL_HASHback to summary
private static final byte[] N_PARALLEL_HASH
nCountback to summary
private int nCount
outputLengthback to summary
private final int outputLength
purposeback to summary
private final CryptoServicePurpose purpose

Constructor Detail

ParallelHashback to summary
public ParallelHash(int bitLength, byte[] S, int B)

Base constructor.

Parameters
bitLength:int

security strength (bits) of the underlying SHAKE function, 128 or 256.

S:byte[]

the customization string - available for local use.

B:int

the blocksize (in bytes) for hashing.

ParallelHashback to summary
public ParallelHash(int bitLength, byte[] S, int B, int outputSize)
ParallelHashback to summary
public ParallelHash(int bitLength, byte[] S, int B, int outputSize, CryptoServicePurpose purpose)
ParallelHashback to summary
public ParallelHash(ParallelHash source)

Method Detail

compressback to summary
private void compress()
compressback to summary
private void compress(byte[] buf, int offSet, int len)
doFinalback to summary
public int doFinal(byte[] out, int outOff) throws DataLengthException, IllegalStateException

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
public int doFinal(byte[] out, int outOff, int outLen)

Implements org.bouncycastle.crypto.Xof.doFinal.

Doc from org.bouncycastle.crypto.Xof.doFinal.

Output the results of the final calculation for this digest to outLen number of bytes.

Parameters
out:byte[]

output array to write the output bytes to.

outOff:int

offset to start writing the bytes at.

outLen:int

the number of output bytes requested.

Returns:int

the number of bytes written

doOutputback to summary
public int doOutput(byte[] out, int outOff, int outLen)

Implements org.bouncycastle.crypto.Xof.doOutput.

Doc from org.bouncycastle.crypto.Xof.doOutput.

Start outputting the results of the final calculation for this digest. Unlike doFinal, this method will continue producing output until the Xof is explicitly reset, or signals otherwise.

Parameters
out:byte[]

output array to write the output bytes to.

outOff:int

offset to start writing the bytes at.

outLen:int

the number of output bytes requested.

Returns:int

the number of bytes written

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.

Doc from org.bouncycastle.crypto.ExtendedDigest.getByteLength.

Return the size in bytes of the internal buffer the digest applies it's compression function to.

Returns:int

byte length of the digests internal buffer.

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.

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.

updateback to summary
public void update(byte in) throws IllegalStateException

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) throws DataLengthException, IllegalStateException

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.

wrapUpback to summary
private void wrapUp(int outputSize)