Class DecodeExtension
Extension to decode Argon2 hash strings.
Inherited Members
Namespace: Isopoh.Cryptography.Argon2
Assembly: Isopoh.Cryptography.Argon2.dll
Syntax
public static class DecodeExtension
Methods
| Edit this page View SourceArgon2RequiredBufferLengths(string)
Finds the buffer lengths required given an Argon2 hash string.
Declaration
public static (int KeyIdLength, int AssociatedDataLength, int SaltLength, int HashLength) Argon2RequiredBufferLengths(this string str)
Parameters
| Type | Name | Description |
|---|---|---|
| string | str | The Argon2 hash string. |
Returns
| Type | Description |
|---|---|
| (int KeyIdLength, int AssociatedDataLength, int SaltLength, int HashLength) | A tuple of required buffer lengths for: key id, associated data, salt, and hash. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentException |
|
DecodeString(Argon2Config, string, out SecureArray<byte>?)
Decodes an Argon2 hash string into an Argon2 class instance.
Declaration
public static bool DecodeString(this Argon2Config config, string str, out SecureArray<byte>? hash)
Parameters
| Type | Name | Description |
|---|---|---|
| Argon2Config | config | The configuration to populate with the data found in |
| string | str | The string to decode. |
| SecureArray<byte> | hash | Loaded with the hash found in |
Returns
| Type | Description |
|---|---|
| bool | True on success; false otherwise. |
Remarks
Expected format:
$argon2<T>[$v=<(16|19)>]$m=<num>,t=<num>,p=<num>[,keyid=<bin>][,data=<bin>][$<bin>[$<bin>]].
where <T> is either 'd', 'i', or 'id'. <num> is a decimal integer (positive, fits in an 'unsigned long'), and <bin> is Base64-encoded data (no '=' padding characters, no newline or whitespace). The 'keyid' is a binary identifier for a key (recommended up to 8 bytes); 'data' is associated data (recommended up to 32 bytes). When the 'keyid' is empty, then it is omitted from the output. Same for 'data'.
The last two binary chunks (encoded in Base64) are, in that order, the salt and the output. Both are optional, but you cannot have an output without a salt. The binary salt length is recommended to be between 8 and 48 bytes. The output length recommended to always be exactly 32 bytes.
Lengths for keyid, data, salt, and output are recommended as per the pfc-sf-spec, in actuality, Argon2 allows any lengths for those values although verifiers that verify against the pfc-sf-spec will fail out-of-specification lengths.
DecodeString(Argon2Memory, string)
Decodes an Argon2 hash string into an Argon2 class instance.
Declaration
public static void DecodeString(this Argon2Memory memory, string hash)
Parameters
| Type | Name | Description |
|---|---|---|
| Argon2Memory | memory | The Argon2Memory> to populate with the data found in |
| string | hash | The string to decode. |
Remarks
Expected format:
$argon2<T>[$v=<(16|19)>]$m=<num>,t=<num>,p=<num>[,keyid=<bin>][,data=<bin>][$<bin>[$<bin>]].
where <T> is either 'd', 'i', or 'id'. <num> is a decimal integer (positive, fits in an 'unsigned long'), and <bin> is Base64-encoded data (no '=' padding characters, no newline or whitespace). The 'keyid' is a binary identifier for a key (recommended up to 8 bytes); 'data' is associated data (recommended up to 32 bytes). When the 'keyid' is empty, then it is omitted from the output. Same for 'data'.
The last two binary chunks (encoded in Base64) are, in that order, the salt and the output. Both are optional, but you cannot have an output without a salt. The binary salt length is recommended to be between 8 and 48 bytes. The output length recommended to always be exactly 32 bytes.
Lengths for keyid, data, salt, and output are recommended as per the pfc-sf-spec, in actuality, Argon2 allows any lengths for those values although verifiers that verify against the pfc-sf-spec will fail out-of-specification lengths.