Show / Hide Table of Contents

Class Blake2BCore

The core of the Blake2 hash.

Inheritance
object
Blake2BCore
Implements
IDisposable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Isopoh.Cryptography.Blake2b
Assembly: Isopoh.Cryptography.Blake2b.dll
Syntax
public class Blake2BCore : IDisposable

Constructors

| Edit this page View Source

Blake2BCore(SecureArrayCall, LockMemoryPolicy)

Initializes a new instance of the Blake2BCore class.

Declaration
public Blake2BCore(SecureArrayCall secureArrayCall, LockMemoryPolicy lockMemory = LockMemoryPolicy.BestEffort)
Parameters
Type Name Description
SecureArrayCall secureArrayCall

The methods that get called to secure arrays. A null value defaults to SecureArray.DefaultCall.

LockMemoryPolicy lockMemory

Used to set locking strategy for buffers used in creating the hash. The memory will always be zeroed prior to destruction. The memory is also always pinned so the CLR can't move it and leave extraneous copies floating around in RAM.

| Edit this page View Source

Blake2BCore(Memory<byte>)

Initializes a new instance of the Blake2BCore class.

Declaration
public Blake2BCore(Memory<byte> blake2BCoreBuffer)
Parameters
Type Name Description
Memory<byte> blake2BCoreBuffer

Used to perform the Blake2b operations. Must be at least BufferTotalSize bytes long.

Fields

| Edit this page View Source

BufferTotalSize

Gets the total size of the buffer needed to do Blake2BCore operations.

Declaration
public const int BufferTotalSize = 320
Field Value
Type Description
int

Methods

| Edit this page View Source

BytesToUInt64(ReadOnlySpan<byte>, int)

Convert a big-endian buffer into a ulong.

Declaration
public static ulong BytesToUInt64(ReadOnlySpan<byte> buf, int offset)
Parameters
Type Name Description
ReadOnlySpan<byte> buf

Buffer holding an 8-byte big-endian ulong.

int offset

Offset into the buffer to start reading the ulong.

Returns
Type Description
ulong

The parsed ulong.

Remarks

No checking is done to verify that an 8-byte value can be read from buf at offset.

| Edit this page View Source

Dispose()

Release unmanaged resources.

Declaration
public void Dispose()
| Edit this page View Source

Dispose(bool)

Dispose pattern Dispose method.

Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

True to dispose; false otherwise (when calling from destructor).

| Edit this page View Source

HashCore(ReadOnlySpan<byte>)

Update the hash state.

Declaration
public void HashCore(ReadOnlySpan<byte> data)
Parameters
Type Name Description
ReadOnlySpan<byte> data

Data to use to update the hash state.

| Edit this page View Source

HashFinal()

Return the hash.

Declaration
public byte[] HashFinal()
Returns
Type Description
byte[]

The 64-byte hash.

Exceptions
Type Condition
InvalidOperationException

If Initialize(ReadOnlySpan<ulong>) was not called.

| Edit this page View Source

HashFinal(bool)

Return the hash.

Declaration
public byte[] HashFinal(bool isEndOfLayer)
Parameters
Type Name Description
bool isEndOfLayer

True to signal the last node of a layer in tree-hashing mode; false otherwise.

Returns
Type Description
byte[]

The 64-byte hash.

Exceptions
Type Condition
InvalidOperationException

If Initialize(ReadOnlySpan<ulong>) was not called.

| Edit this page View Source

HashFinal(byte[])

Compute the hash.

Declaration
public byte[] HashFinal(byte[] hash)
Parameters
Type Name Description
byte[] hash

Loaded with the hash.

Returns
Type Description
byte[]

hash.

| Edit this page View Source

HashFinal(byte[], bool)

Compute the hash.

Declaration
public byte[] HashFinal(byte[] hash, bool isEndOfLayer)
Parameters
Type Name Description
byte[] hash

Loaded with the hash.

bool isEndOfLayer

True to signal the last node of a layer in tree-hashing mode; false otherwise.

Returns
Type Description
byte[]

hash.

Exceptions
Type Condition
InvalidOperationException

If Initialize(ReadOnlySpan<ulong>) was not called.

ArgumentException

When .Length != 64.

| Edit this page View Source

HashFinal(Span<byte>)

Compute the hash.

Declaration
public Span<byte> HashFinal(Span<byte> hash)
Parameters
Type Name Description
Span<byte> hash

Loaded with the hash.

Returns
Type Description
Span<byte>

hash.

| Edit this page View Source

HashFinal(Span<byte>, bool)

Compute the hash.

Declaration
public Span<byte> HashFinal(Span<byte> hash, bool isEndOfLayer)
Parameters
Type Name Description
Span<byte> hash

Loaded with the hash. Must be 64 bytes.

bool isEndOfLayer

True to signal the last node of a layer in tree-hashing mode; false otherwise.

Returns
Type Description
Span<byte>

hash.

Exceptions
Type Condition
InvalidOperationException

If Initialize(ReadOnlySpan<ulong>) was not called.

ArgumentException

When .Length != 64.

| Edit this page View Source

Initialize(ReadOnlySpan<ulong>)

Initialize the hash.

Declaration
public void Initialize(ReadOnlySpan<ulong> config)
Parameters
Type Name Description
ReadOnlySpan<ulong> config

8-element configuration array.

| Edit this page View Source

UInt64ToBytes(ulong, Span<byte>, int)

Store a ulong into a byte buffer as big-endian.

Declaration
public static void UInt64ToBytes(ulong value, Span<byte> buf, int offset)
Parameters
Type Name Description
ulong value

The ulong to store.

Span<byte> buf

The buffer to load the 8-byte value into.

int offset

The offset to start value at in buf.

Remarks

No checking is done to validate the buffer can store value at offset.

Implements

IDisposable
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX