Class Blake2BHasher
Init/Update/Final for Blake2 hash.
Implements
Inherited Members
Namespace: Isopoh.Cryptography.Blake2b
Assembly: Isopoh.Cryptography.Blake2b.dll
Syntax
public class Blake2BHasher : Hasher, IDisposable
Constructors
| Edit this page View SourceBlake2BHasher(Blake2BConfig?, SecureArrayCall)
Initializes a new instance of the Blake2BHasher class.
Declaration
public Blake2BHasher(Blake2BConfig? config, SecureArrayCall secureArrayCall)
Parameters
| Type | Name | Description |
|---|---|---|
| Blake2BConfig | config | The configuration to use; may be null to use the default Blake2 configuration. |
| SecureArrayCall | secureArrayCall | Used to create SecureArray instances. |
Blake2BHasher(Blake2BConfig?, Memory<byte>)
Initializes a new instance of the Blake2BHasher class.
Declaration
public Blake2BHasher(Blake2BConfig? config, Memory<byte> blake2BHasherBuffer)
Parameters
| Type | Name | Description |
|---|---|---|
| Blake2BConfig | config | The configuration to use; may be null to use the default Blake2 configuration. |
| Memory<byte> | blake2BHasherBuffer | Must be at least BufferMinimumTotalSize + ( |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
Fields
| Edit this page View SourceBufferMinimumTotalSize
Gets the minimum total size in bytes of the Blake2BHasher buffer. This length plus the length of the optional Blake2BConfig.Key field is the total required size.
Declaration
public const int BufferMinimumTotalSize = 512
Field Value
| Type | Description |
|---|---|
| int |
NoKeyBufferMinimumTotalSize
Gets the minimum total size in bytes of the Blake2BHasher buffer. This length plus the length of the optional Blake2BConfig.Key field is the total required size.
Declaration
public const int NoKeyBufferMinimumTotalSize = 384
Field Value
| Type | Description |
|---|---|
| int |
Properties
| Edit this page View SourceIv
Gets the initialization vector used for the Blake2B hash.
Declaration
public ReadOnlySpan<ulong> Iv { get; }
Property Value
| Type | Description |
|---|---|
| ReadOnlySpan<ulong> |
Key
Gets the key used for the Blake2B hash.
Declaration
public ReadOnlySpan<byte> Key { get; }
Property Value
| Type | Description |
|---|---|
| ReadOnlySpan<byte> |
Methods
| Edit this page View SourceDispose(bool)
Disposes resources if disposing is true.
Declaration
protected override void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing | Set to true if disposing. |
Overrides
| Edit this page View SourceFinish()
Either returns Blake2BConfig.Result64ByteBuffer or a new buffer of Blake2BConfig.OutputSizeInBytes if no Result64ByteBuffer was given.
Declaration
public override Memory<byte> Finish()
Returns
| Type | Description |
|---|---|
| Memory<byte> | Either the final Blake2 hash or the Result64ByteBuffer. If Result64ByteBuffer is non-null and Blake2BConfig.OutputSizeInBytes is less than 64, then the actual Blake2 hash is the first OutputSizeInBytes of the Result64ByteBuffer buffer. |
Overrides
| Edit this page View SourceFinish(Span<byte>)
Finishes the hash and stores the results into hash. If a
Result64ByteBuffer.Result64ByteBuffer
was given, that will be loaded with the full hash. If the given hash
is longer than Blake2B.OutputLength, it will be padded
with zeros.
Declaration
public override Span<byte> Finish(Span<byte> hash)
Parameters
| Type | Name | Description |
|---|---|---|
| Span<byte> | hash | Loaded with the hash value. |
Returns
| Type | Description |
|---|---|
| Span<byte> | The passed in |
Overrides
| Edit this page View SourceInit()
Initialize the hasher. The hasher is initialized upon construction but this can be used to reinitialize in order to reuse the hasher.
Declaration
public override sealed void Init()
Overrides
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | When called after being disposed. |
Update(ReadOnlySpan<byte>)
Update the hasher with more bytes of data.
Declaration
public override void Update(ReadOnlySpan<byte> data)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | data | Buffer holding the data to update with. |
Overrides
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | When called after being disposed. |