Package org.bouncycastle.crypto.digests
Class Blake2xsDigest
java.lang.Object
org.bouncycastle.crypto.digests.Blake2xsDigest
- All Implemented Interfaces:
Digest
,ExtendedDigest
,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
Modifier and TypeFieldDescriptionstatic final int
Magic number to indicate an unknown length of digest -
Constructor Summary
ConstructorDescriptionBLAKE2xs for hashing with unknown digest lengthBlake2xsDigest
(int digestBytes) Blake2xsDigest
(int digestBytes, byte[] key) BLAKE2xs with keyBlake2xsDigest
(int digestBytes, byte[] key, byte[] salt, byte[] personalization, CryptoServicePurpose purpose) BLAKE2xs with key, salt and personalizationBlake2xsDigest
(int digestBytes, CryptoServicePurpose purpose) BLAKE2xs for hashingBlake2xsDigest
(Blake2xsDigest digest) -
Method Summary
Modifier and TypeMethodDescriptionint
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.Return the algorithm name.int
Return the size in bytes of the internal buffer the digest applies its compression function to.int
Return the size in bytes of the digest produced by this message digest.long
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 Details
-
UNKNOWN_DIGEST_LENGTH
public static final int UNKNOWN_DIGEST_LENGTHMagic number to indicate an unknown length of digest- See Also:
-
-
Constructor Details
-
Blake2xsDigest
public Blake2xsDigest()BLAKE2xs for hashing with unknown digest length -
Blake2xsDigest
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-1key
- 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-1key
- A key up to 32 bytes or nullsalt
- 8 bytes or nullpersonalization
- 8 bytes or null
-
Blake2xsDigest
-
-
Method Details
-
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.
-