Package 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
Fields Modifier and Type Field Description static int
UNKNOWN_DIGEST_LENGTH
Magic number to indicate an unknown length of digest
-
Constructor Summary
Constructors Constructor Description Blake2xsDigest()
BLAKE2xs for hashing with unknown digest lengthBlake2xsDigest(int digestBytes)
BLAKE2xs for hashingBlake2xsDigest(int digestBytes, byte[] key)
BLAKE2xs with keyBlake2xsDigest(int digestBytes, byte[] key, byte[] salt, byte[] personalization)
BLAKE2xs with key, salt and personalizationBlake2xsDigest(Blake2xsDigest digest)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 unknownvoid
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.
-
-
-
Field Detail
-
UNKNOWN_DIGEST_LENGTH
public static final int UNKNOWN_DIGEST_LENGTH
Magic number to indicate an unknown length of digest- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Blake2xsDigest
public Blake2xsDigest()
BLAKE2xs for hashing with unknown digest length
-
Blake2xsDigest
public Blake2xsDigest(int digestBytes)
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, byte[] key)
BLAKE2xs with key- Parameters:
digestBytes
- The desired digest length in bytes. Must be above 1 and less than 2^16-1key
- A key up to 32 bytes or null
-
Blake2xsDigest
public Blake2xsDigest(int digestBytes, byte[] key, byte[] salt, byte[] personalization)
BLAKE2xs with key, salt and personalization- Parameters:
digestBytes
- The desired digest length in bytes. Must be above 1 and less than 2^16-1key
- A key up to 32 bytes or nullsalt
- 8 bytes or nullpersonalization
- 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 interfaceDigest
- 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 interfaceDigest
- 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 interfaceExtendedDigest
- 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.
-
update
public void update(byte[] in, int inOff, int len)
Update the message digest with a block of bytes.
-
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.
-
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.
-
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.
-
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.
-
-