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.
| Modifier and Type | Field and Description |
|---|---|
| private long | blockPos
Keep track of the round number to detect the end of the digest after 2^32 blocks of 32 bytes. |
| private byte[] | buf
Digest of each round of the XOF |
| private int | bufPos
Current position for a round |
| private static final int | |
| private int | digestLength
Expected digest length for the xof. |
| private int | digestPos
Overall position of the digest. |
| private byte[] | h0
Digest of the root hash |
| private Blake2sDigest | hash
Root hash that will take the updates |
| private static final long | |
| private long | nodeOffset
Current node offset incremented by 1 every round. |
| private final CryptoServicePurpose | |
| public static final int | UNKNOWN_DIGEST_LENGTH
Magic number to indicate an unknown length of digest |
| Access | Constructor and Description |
|---|---|
| public | |
| public | Blake2xsDigest(int
The desired digest length in bytes. Must be above 1 and less than 2^16-1 digestBytes, CryptoServicePurpose purpose)BLAKE2xs for hashing |
| public | |
| public | Blake2xsDigest(int
The desired digest length in bytes. Must be above 1 and less than 2^16-1 digestBytes, byte[] A key up to 32 bytes or null key)BLAKE2xs with key |
| public | Blake2xsDigest(int
The desired digest length in bytes. Must be above 1 and less than 2^16-1 digestBytes, byte[] A key up to 32 bytes or null key, byte[] 8 bytes or null salt, byte[] 8 bytes or null personalization, CryptoServicePurpose purpose)BLAKE2xs with key, salt and personalization |
| public |
| Modifier and Type | Method and Description |
|---|---|
| private long | |
| private int | |
| 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. 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. Close the digest, producing the final digest value. |
| public int | Returns: the number of bytes writtenoutput 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. Start outputting the results of the final calculation for this digest. |
| public String | Returns: the algorithm nameImplements org. Return the algorithm name. |
| public int | Returns: byte length of the digest's internal buffer.Implements org. Return the size in bytes of the internal buffer the digest applies its compression function to. |
| public int | Returns: the size in bytes of the digest produced by this message digest.Implements org. Return the size in bytes of the digest produced by this message digest. |
| public long | Returns: byte length of the largest digest with unknown lengthReturn the maximum size in bytes the digest can produce when the length is unknown |
| public void | |
| public void | update(byte
the input byte to be entered. in)Implements org. 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. Update the message digest with a block of bytes. |
| blockPos | back to summary |
|---|---|
| private long blockPos Keep track of the round number to detect the end of the digest after 2^32 blocks of 32 bytes. | |
| buf | back to summary |
|---|---|
| private byte[] buf Digest of each round of the XOF | |
| bufPos | back to summary |
|---|---|
| private int bufPos Current position for a round | |
| DIGEST_LENGTH | back to summary |
|---|---|
| private static final int DIGEST_LENGTH | |
| digestLength | back to summary |
|---|---|
| private int digestLength Expected digest length for the xof. It can be unknown. | |
| digestPos | back to summary |
|---|---|
| private int digestPos Overall position of the digest. It is useful when the length is known in advance to get last block length. | |
| h0 | back to summary |
|---|---|
| private byte[] h0 Digest of the root hash | |
| hash | back to summary |
|---|---|
| private Blake2sDigest hash Root hash that will take the updates | |
| MAX_NUMBER_BLOCKS | back to summary |
|---|---|
| private static final long MAX_NUMBER_BLOCKS | |
| nodeOffset | back to summary |
|---|---|
| private long nodeOffset Current node offset incremented by 1 every round. | |
| purpose | back to summary |
|---|---|
| private final CryptoServicePurpose purpose | |
| UNKNOWN_DIGEST_LENGTH | back to summary |
|---|---|
| public static final int UNKNOWN_DIGEST_LENGTH Magic number to indicate an unknown length of digest | |
| Blake2xsDigest | back to summary |
|---|---|
| public Blake2xsDigest() BLAKE2xs for hashing with unknown digest length | |
| Blake2xsDigest | back to summary |
|---|---|
| public Blake2xsDigest(int digestBytes, CryptoServicePurpose purpose) BLAKE2xs for hashing
| |
| Blake2xsDigest | back to summary |
|---|---|
| public Blake2xsDigest(int digestBytes) | |
| Blake2xsDigest | back to summary |
|---|---|
| public Blake2xsDigest(int digestBytes, byte[] key) BLAKE2xs with key
| |
| Blake2xsDigest | back to summary |
|---|---|
| public Blake2xsDigest(int digestBytes, byte[] key, byte[] salt, byte[] personalization, CryptoServicePurpose purpose) BLAKE2xs with key, salt and personalization
| |
| Blake2xsDigest | back to summary |
|---|---|
| public Blake2xsDigest(Blake2xsDigest digest) | |
| computeNodeOffset | back to summary |
|---|---|
| private long computeNodeOffset() | |
| computeStepLength | back to summary |
|---|---|
| private int computeStepLength() | |
| doFinal | back to summary |
|---|---|
| public int doFinal(byte[] out, int outOffset) Implements org. Close the digest, producing the final digest value. The doFinal() call leaves the digest reset. Key, salt and personal string remain.
| |
| doFinal | back to summary |
|---|---|
| public int doFinal(byte[] out, int outOff, int outLen) Implements org. Close the digest, producing the final digest value. The doFinal() call leaves the digest reset. Key, salt, personal string remain.
| |
| doOutput | back to summary |
|---|---|
| public int doOutput(byte[] out, int outOff, int outLen) Implements org. 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.
| |
| getAlgorithmName | back to summary |
|---|---|
| public String getAlgorithmName() Implements org. Return the algorithm name.
| |
| getByteLength | back to summary |
|---|---|
| public int getByteLength() Implements org. Return the size in bytes of the internal buffer the digest applies its compression function to.
| |
| getDigestSize | back to summary |
|---|---|
| public int getDigestSize() Implements org. Return the size in bytes of the digest produced by this message digest.
| |
| getUnknownMaxLength | back to summary |
|---|---|
| public long getUnknownMaxLength() Return the maximum size in bytes the digest can produce when the length is unknown
| |
| reset | back to summary |
|---|---|
| public void reset() Implements org. Reset the digest back to its initial state. The key, the salt and the personal string will remain for further computations. | |
| update | back to summary |
|---|---|
| public void update(byte in) Implements org. Update the message digest with a single byte.
| |
| update | back to summary |
|---|---|
| public void update(byte[] in, int inOff, int len) Implements org. Update the message digest with a block of bytes.
| |