Table of Contents

Argon2Parameters Class

Definition

Namespace
Bodu.Security.Cryptography
Assembly
Bodu.Security.Cryptography.dll
Package
Bodu.Security.Cryptography 1.2.0
Source
Argon2Parameters.cs

Specifies the cost and auxiliary inputs for an Argon2 key-derivation or password-hashing operation, as defined by RFC 9106.

public sealed record Argon2Parameters : IEquatable<Argon2Parameters>
Inheritance
Argon2Parameters
Implements
Inherited Members
Extension Methods

Remarks

The three cost parameters - MemoryKiB, Iterations, and Parallelism - have no universally safe defaults and must be chosen for the deployment. RFC 9106, Section 4 gives recommended settings; a common starting point for interactive password hashing is 64 MiB of memory, three iterations, and a parallelism of four.

The optional Secret (a server-side "pepper") and AssociatedData are folded into the pre-hashing digest. They are not stored in the PHC encoded string and must be supplied again at verification time.

Constructors

Argon2Parameters()

public Argon2Parameters()

Properties

AssociatedData

Gets the optional associated data X, or null when none is used.

public byte[]? AssociatedData { get; init; }

Property Value

byte[]

The associated data bytes, or null.

Iterations

Gets the number of passes over memory (the RFC 9106 parameter t).

public required int Iterations { get; init; }

Property Value

int

The iteration count.

MemoryKiB

Gets the amount of memory to fill, in kibibytes (the RFC 9106 parameter m).

public required int MemoryKiB { get; init; }

Property Value

int

The memory size in kibibytes.

Parallelism

Gets the degree of parallelism - the number of independent lanes (the RFC 9106 parameter p).

public required int Parallelism { get; init; }

Property Value

int

The number of lanes.

Secret

Gets the optional secret key K (a server-side pepper), or null when none is used.

public byte[]? Secret { get; init; }

Property Value

byte[]

The secret key bytes, or null.

TagLength

Gets the length of the derived tag, in bytes (the RFC 9106 parameter T).

public int TagLength { get; init; }

Property Value

int

The tag length in bytes. The default is 32.

Version

Gets the Argon2 version code folded into the pre-hashing digest.

public int Version { get; init; }

Property Value

int

The version code; either 0x10 or 0x13. The default is 0x13.

Methods

Equals(Argon2Parameters?)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(Argon2Parameters? other)

Parameters

other Argon2Parameters

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Operators

operator ==(Argon2Parameters?, Argon2Parameters?)

public static bool operator ==(Argon2Parameters? left, Argon2Parameters? right)

Parameters

left Argon2Parameters
right Argon2Parameters

Returns

bool

operator !=(Argon2Parameters?, Argon2Parameters?)

public static bool operator !=(Argon2Parameters? left, Argon2Parameters? right)

Parameters

left Argon2Parameters
right Argon2Parameters

Returns

bool

Applies to

ProductVersions
.NET8, 10