Show / Hide Table of Contents

Class Argon2Config

Holds configuration needed to perform an Argon2 hash.

Inheritance
object
Argon2Config
Implements
ICloneable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Isopoh.Cryptography.Argon2
Assembly: Isopoh.Cryptography.Argon2.dll
Syntax
public sealed class Argon2Config : ICloneable

Properties

| Edit this page View Source

AssociatedData

Gets or sets the associated data used in the password hash. This should be from zero to 32 bytes long if it is there at all.

Declaration
public byte[]? AssociatedData { get; set; }
Property Value
Type Description
byte[]
| Edit this page View Source

ClearPassword

Gets or sets a value indicating whether to clear the password as soon as it is no longer needed.

Declaration
public bool ClearPassword { get; set; }
Property Value
Type Description
bool
Remarks

If true and the configuration has a password, the configuration cannot be used more than once without resetting the password (unless you want an all zero password).

| Edit this page View Source

ClearSecret

Gets or sets a value indicating whether to clear the secret as soon as it is no longer needed.

Declaration
public bool ClearSecret { get; set; }
Property Value
Type Description
bool
Remarks

If true and the configuration has a secret, the configuration cannot be used more than once without resetting the secret (unless you want an all zero secret).

| Edit this page View Source

HashLength

Gets or sets the hash length to output. Minimum of 4. Default 32.

Declaration
public int HashLength { get; set; }
Property Value
Type Description
int
| Edit this page View Source

KeyIdentifier

Gets or sets the key identifier used in the password hash. This should be from 0 to 8 bytes long if it is there at all.

Declaration
public byte[]? KeyIdentifier { get; set; }
Property Value
Type Description
byte[]
| Edit this page View Source

Lanes

Gets or sets the lanes used in the password hash. Minimum of 1. Defaults to 4.

Declaration
public int Lanes { get; set; }
Property Value
Type Description
int
Remarks

This describes the maximum parallelism that can be achieved. Each "lane" can be processed individually in its own thread. Setting Threads to a value greater than one when there is more than one lane will allow the use of multiple cores to speed up hashing.

| Edit this page View Source

MemoryCost

Gets or sets the memory cost used in the password hash. Minimum of 1. Defaults to 65536.

Declaration
public int MemoryCost { get; set; }
Property Value
Type Description
int
Remarks

This translates into a target count of memory blocks to use for hashing. A memory block is 1024 bytes so the default 65536 is for a 64MB hash.

If this value is less than 2*SyncPointCount*Lanes, than 2*SyncPointCount*Lanes will be used.

If this value is not a multiple of SyncPointCount*Lanes, then it is rounded down to a multiple of SyncPointCount*Lanes.

| Edit this page View Source

Password

Gets or sets the password to hash.

Declaration
public byte[]? Password { get; set; }
Property Value
Type Description
byte[]
| Edit this page View Source

Salt

Gets or sets the salt used in the password hash. If not set, a random 16-byte salt is generated. A supplied salt must be at least 8 bytes.

Declaration
public byte[]? Salt { get; set; }
Property Value
Type Description
byte[]
| Edit this page View Source

Secret

Gets or sets the secret used in the password hash.

Declaration
public byte[]? Secret { get; set; }
Property Value
Type Description
byte[]
| Edit this page View Source

SecureArrayCall

Gets or sets the methods that get called to secure arrays. Defaults to SecureArray.DefaultCall.

Declaration
public SecureArrayCall SecureArrayCall { get; set; }
Property Value
Type Description
SecureArrayCall
| Edit this page View Source

Threads

Gets or sets the threads used in the password hash. Minimum of 1. Defaults to 1.

Declaration
public int Threads { get; set; }
Property Value
Type Description
int
Remarks

This value makes no difference in the result. A value greater than one causes that many threads to get spawned to do the work on top of the main thread that orchestrates which thread does what work.

Lanes defines the maximum parallelism that can be achieved. Setting Threads to a value greater than Lanes will not result in more than Lanes threads running.

| Edit this page View Source

TimeCost

Gets or sets the time cost used in the password hash. Minimum of 1. Defaults to 3.

Declaration
public int TimeCost { get; set; }
Property Value
Type Description
int
Remarks

This is the number of iterations to perform. There are attacks on the Argon2Version.Sixteen with less than three iterations (if I'm reading the paper correctly). So, use a value greater than 3 here if you are not using Argon2Version.Nineteen.

| Edit this page View Source

Type

Gets or sets the Argon2 type. Default to hybrid.

Declaration
public Argon2Type Type { get; set; }
Property Value
Type Description
Argon2Type
| Edit this page View Source

Version

Gets or sets the Argon2 version used in the password hash. Defaults to Argon2Version.Nineteen (0x13).

Declaration
public Argon2Version Version { get; set; }
Property Value
Type Description
Argon2Version
| Edit this page View Source

WorkingBufferLength

Gets the number of ulongs in the working buffer.

Declaration
public int WorkingBufferLength { get; }
Property Value
Type Description
int
Remarks

This depends on Threads, Lanes, MemoryCost, and Type in a pretty messy way.

The minimum value is 512 (for 4KB of working buffer). The default value is 19,456 (for 152KB of working buffer). The maximum value is much, much larger.

Methods

| Edit this page View Source

Clone()

Declaration
public object Clone()
Returns
Type Description
object

Implements

ICloneable

Extension Methods

DecodeExtension.DecodeString(Argon2Config, string, out SecureArray<byte>?)
EncodeExtension.EncodeString(Argon2Config, Span<byte>)
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX