core/crypto/argon2id
argon2id
Types
1Parameters
Parameters :: struct {
memory_size: u32,
passes: u32,
parallelism: u32,
}SourceParameters is an Argon2id parameter set.
Constants
7MAX_INPUT_SIZE
MAX_INPUT_SIZE :: (1 << 32) - 1SourceImplementation based on the RFC, Monocypher (CC0-1.0), and the reference code (CC0-1.0). MAX_INPUT_SIZE is the mamximum size of the various inputs (password, salt, secret, ad) in bytes.
MAX_PARALLELISM
MAX_PARALLELISM :: (1 << 24) - 1SourceMAX_PARALLELISM is the maximum allowed parallelism.
MAX_TAG_SIZE
MAX_TAG_SIZE :: (1 << 32) - 1SourceMAX_TAG_SIZE is the maximum digest size in bytes.
MIN_PARALLELISM
MIN_PARALLELISM :: 1SourceMIN_PARALLELISM is the minimum allowed parallelism.
MIN_TAG_SIZE
MIN_TAG_SIZE :: 4SourceMIN_TAG_SIZE is the minimum digest size in bytes.
RECOMMENDED_SALT_SIZE
RECOMMENDED_SALT_SIZE :: 16SourceRECOMMENDNED_SALT_SIZE is the recommended salt size in bytes.
RECOMMENTED_TAG_SIZE
RECOMMENTED_TAG_SIZE :: 32SourceRECOMMENDED_TAG_SIZE is the recommended tag size in bytes.
Variables
4PARAMS_OWASP
PARAMS_OWASP :: Parameters = Parameters{
memory_size = 19 * 1024, // 19 MiB
passes = 2,
parallelism = 1,
}SourcePARAMS_OWASP is one of the recommended parameter set from the OWASP Password Storage Cheat Sheet (as of 2026/02). The cheat sheet contains additional variations to this parameter set with various trade-offs between memory_size and passes that are intended to provide equivalent security.
See: https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html
PARAMS_OWASP_SMALL
PARAMS_OWASP_SMALL :: Parameters = Parameters{
memory_size = 7 * 1024, // 7 MiB
passes = 5,
parallelism = 1,
}SourcePARAMS_OWASP_SMALL is equivalent in strength to PARAMS_OWASP, but trades off less memory use for more CPU usage.
PARAMS_RFC9106
PARAMS_RFC9106 :: Parameters = Parameters{
memory_size = 2 * 1024 * 1024, // 2 GiB
passes = 1,
parallelism = 4,
}SourcePARAMS_RFC9106 is the first recommended "uniformly safe" parameter set per RFC 9106.
PARAMS_RFC9106_SMALL
PARAMS_RFC9106_SMALL :: Parameters = Parameters{
memory_size = 64 * 1024, // 64 MiB
passes = 3,
parallelism = 4,
}SourcePARAMS_RFC9106_SMALL is the second recommended "uniformly safe" parameter set per RFC 9106 tailored for memory constrained environments.
Procedures
1derive
derive :: proc(
parameters: ^Parameters,
password: []u8,
salt: []u8,
dst: []u8,
secret: []u8,
ad: []u8,
sanitize: untyped boolean = true,
allocator: mem.Allocator = context.allocator,
) -> (mem.Allocator_Error)Sourcederive invokes Argon2id with the specified parameter set and inputs, and outputs the derived key to dst.