Class Blake2xsDigest
- Namespace
- Org.BouncyCastle.Crypto.Digests
- Assembly
- BouncyCastle.Cryptography.dll
Implementation of the eXtendable Output Function (XOF) BLAKE2xs. 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.
public sealed class Blake2xsDigest : IXof, IDigest
- Inheritance
-
Blake2xsDigest
- Implements
- Inherited Members
Remarks
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.
Constructors
Blake2xsDigest()
Initializes a new instance of Blake2xsDigest for hashing an unknown digest length.
public Blake2xsDigest()
Blake2xsDigest(Blake2xsDigest)
Constructs a new instance of Blake2xsDigest from another Blake2xsDigest./>.
public Blake2xsDigest(Blake2xsDigest digest)
Parameters
digestBlake2xsDigestThe original instance of Blake2xsDigest that is copied.
Blake2xsDigest(int)
Initializes a new instance of Blake2xsDigest with a given digest size.
public Blake2xsDigest(int digestBytes)
Parameters
digestBytesintThe desired digest length in bytes. Must be above 1 and less than 2^16-1.
Blake2xsDigest(int, byte[])
Initializes a new instance of Blake2bDigest with a key and given digest length.
After calling the DoFinal(byte[], int) method, the key will remain to be used for further computations of this instance.public Blake2xsDigest(int digestBytes, byte[] key)
Parameters
digestBytesintThe desired digest length in bytes. Must be above 1 and less than 2^16-1.
keybyte[]A key up to 32 bytes or null.
Blake2xsDigest(int, byte[], byte[], byte[])
Initializes a new instance of Blake2xsDigest with a key, required digest length (in bytes), salt and personalization.
public Blake2xsDigest(int digestBytes, byte[] key, byte[] salt, byte[] personalization)
Parameters
digestBytesintThe desired digest length in bytes. Must be above 1 and less than 2^16-1.
keybyte[]A key up to 32 bytes or null.
saltbyte[]A 8 bytes or null salt.
personalizationbyte[]A 8 bytes or null personalization.
Exceptions
Fields
UnknownDigestLength
public const int UnknownDigestLength = 65535
Field Value
Properties
AlgorithmName
The algorithm name.
public string AlgorithmName { get; }
Property Value
Methods
BlockUpdate(byte[], int, int)
Update the message digest with a block of bytes.
public void BlockUpdate(byte[] input, int inOff, int inLen)
Parameters
inputbyte[]The byte array containing the data.
inOffintThe offset into the byte array where the data starts.
inLenintThe length of the data.
BlockUpdate(ReadOnlySpan<byte>)
Update the message digest with a span of bytes.
public void BlockUpdate(ReadOnlySpan<byte> input)
Parameters
inputReadOnlySpan<byte>The span containing the data.
DoFinal(byte[], int)
Close the digest, producing the final digest value.
public int DoFinal(byte[] output, int outOff)
Parameters
outputbyte[]The byte array the digest is to be copied into.
outOffintThe offset into the byte array the digest is to start at.
Returns
- int
The number of bytes written.
Remarks
The DoFinal(byte[], int) call leaves the digest reset. Key, salt and personal string remain.
DoFinal(Span<byte>)
Close the digest, producing the final digest value.
public int DoFinal(Span<byte> output)
Parameters
Returns
- int
The number of bytes written.
Remarks
The DoFinal(Span<byte>) call leaves the digest reset. Key, salt and personal string remain.
GetByteLength()
Return the size in bytes of the internal buffer the digest applies it's compression function to.
public int GetByteLength()
Returns
- int
The byte length of the digests internal buffer.
GetDigestSize()
Return the size, in bytes, of the digest produced by this message digest.
public int GetDigestSize()
Returns
- int
The size, in bytes, of the digest produced by this message digest.
GetUnknownMaxLength()
Return the maximum size in bytes the digest can produce when the length is unknown
public long GetUnknownMaxLength()
Returns
- long
The byte length of the largest digest with unknown length
Output(byte[], int, int)
Start outputting the results of the final calculation for this digest. Unlike DoFinal(byte[], int), this method will continue producing output until the Xof is explicitly reset, or signals otherwise.
public int Output(byte[] output, int outOff, int outLen)
Parameters
outputbyte[]The output array to write the output bytes to.
outOffintThe offset to start writing the bytes at.
outLenintThe number of output bytes requested.
Returns
- int
The number of bytes written.
Output(Span<byte>)
Start outputting the results of the final calculation for this digest. Unlike DoFinal(Span<byte>), this method will continue producing output until the Xof is explicitly reset, or signals otherwise.
public int Output(Span<byte> output)
Parameters
Returns
- int
The number of bytes written.
OutputFinal(byte[], int, int)
Close the digest, producing the final digest value.
public int OutputFinal(byte[] output, int outOff, int outLen)
Parameters
outputbyte[]The output array to write the output bytes to.
outOffintThe offset to start writing the bytes at.
outLenintThe number of output bytes requested.
Returns
- int
The number of bytes written.
Remarks
The OutputFinal(byte[], int, int) call leaves the digest reset. Key, salt and personal string remain.
OutputFinal(Span<byte>)
Close the digest, producing the final digest value.
public int OutputFinal(Span<byte> output)
Parameters
Returns
- int
The number of bytes written.
Remarks
The OutputFinal(Span<byte>) call leaves the digest reset. Key, salt and personal string remain.
Reset()
Reset the digest back to it's initial state. The key, the salt and the personalization will remain for further computations.
public void Reset()
Update(byte)
Update the message digest with a single byte.
public void Update(byte b)
Parameters
bbyte