Bouncy Castle Cryptography Library 1.77.0

org.bouncycastle.crypto.digests
Class Blake2xsDigest

java.lang.Object
  |
  +--org.bouncycastle.crypto.digests.Blake2xsDigest
All Implemented Interfaces:
Digest, ExtendedDigest, Xof

public class Blake2xsDigest
extends java.lang.Object
implements Xof

Implementation of the eXtendable Output Function (XOF) BLAKE2xs.

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

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

BLAKE2xs is optimized for 32-bit platforms and produces digests of any size between 1 and 2^16-2 bytes. The length can also be unknown and then the maximum length will be 2^32 blocks of 32 bytes.


Field Summary
static int UNKNOWN_DIGEST_LENGTH
          Magic number to indicate an unknown length of digest
 
Constructor Summary
Blake2xsDigest()
          BLAKE2xs for hashing with unknown digest length
Blake2xsDigest(Blake2xsDigest digest)
           
Blake2xsDigest(int digestBytes)
           
Blake2xsDigest(int digestBytes, byte[] key)
          BLAKE2xs with key
Blake2xsDigest(int digestBytes, byte[] key, byte[] salt, byte[] personalization, CryptoServicePurpose purpose)
          BLAKE2xs with key, salt and personalization
Blake2xsDigest(int digestBytes, CryptoServicePurpose purpose)
          BLAKE2xs for hashing
 
Method Summary
 int doFinal(byte[] out, int outOffset)
          Close the digest, producing the final digest value.
 int doFinal(byte[] out, int outOff, int outLen)
          Close the digest, producing the final digest value.
 int doOutput(byte[] out, int outOff, int outLen)
          Start outputting the results of the final calculation for this digest.
 java.lang.String getAlgorithmName()
          Return the algorithm name.
 int getByteLength()
          Return the size in bytes of the internal buffer the digest applies its compression function to.
 int getDigestSize()
          Return the size in bytes of the digest produced by this message digest.
 long getUnknownMaxLength()
          Return the maximum size in bytes the digest can produce when the length is unknown
 void reset()
          Reset the digest back to its initial state.
 void update(byte in)
          Update the message digest with a single byte.
 void update(byte[] in, int inOff, int len)
          Update the message digest with a block of bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN_DIGEST_LENGTH

public static final int UNKNOWN_DIGEST_LENGTH
Magic number to indicate an unknown length of digest
Constructor Detail

Blake2xsDigest

public Blake2xsDigest()
BLAKE2xs for hashing with unknown digest length

Blake2xsDigest

public Blake2xsDigest(int digestBytes,
                      CryptoServicePurpose purpose)
BLAKE2xs for hashing
Parameters:
digestBytes - The desired digest length in bytes. Must be above 1 and less than 2^16-1

Blake2xsDigest

public Blake2xsDigest(int digestBytes)

Blake2xsDigest

public Blake2xsDigest(int digestBytes,
                      byte[] key)
BLAKE2xs with key
Parameters:
digestBytes - The desired digest length in bytes. Must be above 1 and less than 2^16-1
key - A key up to 32 bytes or null

Blake2xsDigest

public Blake2xsDigest(int digestBytes,
                      byte[] key,
                      byte[] salt,
                      byte[] personalization,
                      CryptoServicePurpose purpose)
BLAKE2xs with key, salt and personalization
Parameters:
digestBytes - The desired digest length in bytes. Must be above 1 and less than 2^16-1
key - A key up to 32 bytes or null
salt - 8 bytes or null
personalization - 8 bytes or null

Blake2xsDigest

public Blake2xsDigest(Blake2xsDigest digest)
Method Detail

getAlgorithmName

public java.lang.String getAlgorithmName()
Return the algorithm name.
Specified by:
getAlgorithmName in interface Digest
Returns:
the algorithm name

getDigestSize

public int getDigestSize()
Return the size in bytes of the digest produced by this message digest.
Specified by:
getDigestSize in interface Digest
Returns:
the size in bytes of the digest produced by this message digest.

getByteLength

public int getByteLength()
Return the size in bytes of the internal buffer the digest applies its compression function to.
Specified by:
getByteLength in interface ExtendedDigest
Returns:
byte length of the digest's internal buffer.

getUnknownMaxLength

public long getUnknownMaxLength()
Return the maximum size in bytes the digest can produce when the length is unknown
Returns:
byte length of the largest digest with unknown length

update

public void update(byte in)
Update the message digest with a single byte.
Specified by:
update in interface Digest
Parameters:
in - the input byte to be entered.

update

public void update(byte[] in,
                   int inOff,
                   int len)
Update the message digest with a block of bytes.
Specified by:
update in interface Digest
Parameters:
in - the byte array containing the data.
inOff - the offset into the byte array where the data starts.
len - the length of the data.

reset

public void reset()
Reset the digest back to its initial state. The key, the salt and the personal string will remain for further computations.
Specified by:
reset in interface Digest

doFinal

public int doFinal(byte[] out,
                   int outOffset)
Close the digest, producing the final digest value. The doFinal() call leaves the digest reset. Key, salt and personal string remain.
Specified by:
doFinal in interface Digest
Parameters:
out - the array the digest is to be copied into.
outOffset - the offset into the out array the digest is to start at.

doFinal

public int doFinal(byte[] out,
                   int outOff,
                   int outLen)
Close the digest, producing the final digest value. The doFinal() call leaves the digest reset. Key, salt, personal string remain.
Specified by:
doFinal in interface Xof
Parameters:
out - output array to write the output bytes to.
outOff - offset to start writing the bytes at.
outLen - the number of output bytes requested.

doOutput

public int doOutput(byte[] out,
                    int outOff,
                    int outLen)
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.
Specified by:
doOutput in interface Xof
Parameters:
out - output array to write the output bytes to.
outOff - offset to start writing the bytes at.
outLen - the number of output bytes requested.
Returns:
the number of bytes written

Bouncy Castle Cryptography Library 1.77.0