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

public Class Blake2bDigest

extends Object
implements ExtendedDigest
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.ExtendedDigest, org.bouncycastle.crypto.Digest
Imports
org.bouncycastle.crypto.CryptoServicePurpose, .CryptoServicesRegistrar, .ExtendedDigest, .OutputLengthException, org.bouncycastle.util.Arrays, .Longs, .Pack

Implementation of the cryptographic hash function Blakbe2b.

Blake2b offers a built-in keying mechanism to be used directly for authentication ("Prefix-MAC") rather than a HMAC construction.

Blake2b offers a built-in support for a salt for randomized hashing and a personal string for defining a unique hash function for each application.

BLAKE2b is optimized for 64-bit platforms and produces digests of any size between 1 and 64 bytes.

Field Summary

Modifier and TypeField and Description
private static final long[]
private static final byte[][]
private static final int
private byte[]
private int
private long[]
private int
private int
private long
private long
private int
private int
private long[]
private boolean
private byte[]
private int
private int
private int
private long
private byte[]
private final CryptoServicePurpose
private static int
private byte[]
private long
private long

Constructor Summary

AccessConstructor and Description
public
public
Blake2bDigest(int
size of digest (in bits)
digestSize
)

Basic sized constructor - size in bits.

public
public
Blake2bDigest(int
size of the digest in bits
digestSize
,
CryptoServicePurpose
usage purpose.
purpose
)

Basic sized constructor with purpose.

public
Blake2bDigest(byte[]
A key up to 64 bytes or null
key
)

Blake2b for authentication ("Prefix-MAC mode").

public
Blake2bDigest(byte[] key, CryptoServicePurpose purpose)

public
Blake2bDigest(byte[]
A key up to 64 bytes or null
key
,
int
from 1 up to 64 bytes
digestLength
,
byte[]
16 bytes or null
salt
,
byte[]
16 bytes or null
personalization
)

Blake2b with key, required digest length (in bytes), salt and personalization.

public
Blake2bDigest(byte[] key, int digestLength, byte[] salt, byte[] personalization, CryptoServicePurpose purpose)

public
Blake2bDigest(byte[] key, byte[] param)

Method Summary

Modifier and TypeMethod and Description
public void
clearKey()

Overwrite the key if it is no longer used (zeroization)

public void
clearSalt()

Overwrite the salt (pepper) if it is secret and no longer used (zeroization)

private void
compress(byte[] message, int messagePos)

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.
outOffset
)

Implements org.bouncycastle.crypto.Digest.doFinal.

close the digest, producing the final digest value.

private void
G(long m1, long m2, int posA, int posB, int posC, int posD)

public String

Returns:

the algorithm name
getAlgorithmName
()

Implements org.bouncycastle.crypto.Digest.getAlgorithmName.

return the algorithm name

public int

Returns:

byte length of the digests internal buffer.
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

Returns:

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

Implements org.bouncycastle.crypto.Digest.getDigestSize.

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

private void
init()

private void
public void
reset()

Implements org.bouncycastle.crypto.Digest.reset.

Reset the digest back to it's initial state.

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

Implements org.bouncycastle.crypto.Digest.update.

update the message digest with a single byte.

public void
update(byte[]
the byte array containing the data.
message
,
int
the offset into the byte array where the data starts.
offset
,
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

blake2b_IVback to summary
private static final long[] blake2b_IV
blake2b_sigmaback to summary
private static final byte[][] blake2b_sigma
BLOCK_LENGTH_BYTESback to summary
private static final int BLOCK_LENGTH_BYTES
bufferback to summary
private byte[] buffer
bufferPosback to summary
private int bufferPos
chainValueback to summary
private long[] chainValue
depthback to summary
private int depth
digestLengthback to summary
private int digestLength
f0back to summary
private long f0
f1back to summary
private long f1
fanoutback to summary
private int fanout
innerHashLengthback to summary
private int innerHashLength
internalStateback to summary
private long[] internalState
isLastNodeback to summary
private boolean isLastNode
keyback to summary
private byte[] key
keyLengthback to summary
private int keyLength
leafLengthback to summary
private int leafLength
nodeDepthback to summary
private int nodeDepth
nodeOffsetback to summary
private long nodeOffset
personalizationback to summary
private byte[] personalization
purposeback to summary
private final CryptoServicePurpose purpose
ROUNDSback to summary
private static int ROUNDS
saltback to summary
private byte[] salt
t0back to summary
private long t0
t1back to summary
private long t1

Constructor Detail

Blake2bDigestback to summary
public Blake2bDigest()
Blake2bDigestback to summary
public Blake2bDigest(int digestSize)

Basic sized constructor - size in bits.

Parameters
digestSize:int

size of digest (in bits)

Blake2bDigestback to summary
public Blake2bDigest(Blake2bDigest digest)
Blake2bDigestback to summary
public Blake2bDigest(int digestSize, CryptoServicePurpose purpose)

Basic sized constructor with purpose.

Parameters
digestSize:int

size of the digest in bits

purpose:CryptoServicePurpose

usage purpose.

Blake2bDigestback to summary
public Blake2bDigest(byte[] key)

Blake2b for authentication ("Prefix-MAC mode"). After calling the doFinal() method, the key will remain to be used for further computations of this instance. The key can be overwritten using the clearKey() method.

Parameters
key:byte[]

A key up to 64 bytes or null

Blake2bDigestback to summary
public Blake2bDigest(byte[] key, CryptoServicePurpose purpose)
Blake2bDigestback to summary
public Blake2bDigest(byte[] key, int digestLength, byte[] salt, byte[] personalization)

Blake2b with key, required digest length (in bytes), salt and personalization. After calling the doFinal() method, the key, the salt and the personal string will remain and might be used for further computations with this instance. The key can be overwritten using the clearKey() method, the salt (pepper) can be overwritten using the clearSalt() method.

Parameters
key:byte[]

A key up to 64 bytes or null

digestLength:int

from 1 up to 64 bytes

salt:byte[]

16 bytes or null

personalization:byte[]

16 bytes or null

Blake2bDigestback to summary
public Blake2bDigest(byte[] key, int digestLength, byte[] salt, byte[] personalization, CryptoServicePurpose purpose)
Blake2bDigestback to summary
public Blake2bDigest(byte[] key, byte[] param)

Method Detail

clearKeyback to summary
public void clearKey()

Overwrite the key if it is no longer used (zeroization)

clearSaltback to summary
public void clearSalt()

Overwrite the salt (pepper) if it is secret and no longer used (zeroization)

compressback to summary
private void compress(byte[] message, int messagePos)
doFinalback to summary
public int doFinal(byte[] out, int outOffset)

Implements org.bouncycastle.crypto.Digest.doFinal.

close the digest, producing the final digest value. The doFinal call leaves the digest reset. Key, salt and personal string remain.

Parameters
out:byte[]

the array the digest is to be copied into.

outOffset:int

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

Gback to summary
private void G(long m1, long m2, int posA, int posB, int posC, int posD)
getAlgorithmNameback to summary
public String getAlgorithmName()

Implements 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 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.

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()
initializeInternalStateback to summary
private void initializeInternalState()
resetback to summary
public void reset()

Implements org.bouncycastle.crypto.Digest.reset.

Reset the digest back to it's initial state. The key, the salt and the personal string will remain for further computations.

setAsLastNodeback to summary
protected void setAsLastNode()
updateback to summary
public void update(byte b)

Implements org.bouncycastle.crypto.Digest.update.

update the message digest with a single byte.

Parameters
b:byte

the input byte to be entered.

updateback to summary
public void update(byte[] message, int offset, int len)

Implements org.bouncycastle.crypto.Digest.update.

update the message digest with a block of bytes.

Parameters
message:byte[]

the byte array containing the data.

offset:int

the offset into the byte array where the data starts.

len:int

the length of the data.