![]() |
![]()
| ![]() |
![]()
NAMECrypt::Argon2 - Perl interface to the Argon2 key derivation functions VERSIONversion 0.022 SYNOPSISuse Crypt::Argon2 qw/argon2id_pass argon2_verify/; sub add_pass { my ($user, $password) = @_; my $salt = get_random(16); my $encoded = argon2id_pass($password, $salt, 3, '32M', 1, 16); store_password($user, $encoded); } sub check_password { my ($user, $password) = @_; my $encoded = fetch_encoded($user); return argon2_verify($encoded, $password); } DESCRIPTIONThis module implements the Argon2 key derivation function, which is suitable to convert any password into a cryptographic key. This is most often used to for secure storage of passwords but can also be used to derive a encryption key from a password. It offers variable time and memory costs as well as output size. To find appropriate parameters, the bundled program "argon2-calibrate" can be used. FUNCTIONSargon2_pass($type, $password, $salt, $t_cost, $m_factor, $parallelism, $tag_size)This function processes the $password with the given $salt and parameters. It encodes the resulting tag and the parameters as a password string (e.g. "$argon2id$v=19$m=65536,t=2,p=1$c29tZXNhbHQ$wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA").
argon2_verify($encoded, $password)This verifies that the $password matches $encoded. All parameters and the tag value are extracted from $encoded, so no further arguments are necessary. argon2_raw($type, $password, $salt, $t_cost, $m_factor, $parallelism, $tag_size)This function processes the $password with the given $salt and parameters much like "argon2_pass", but returns the binary tag instead of a formatted string. argon2id_pass($password, $salt, $t_cost, $m_factor, $parallelism, $tag_size)argon2i_pass($password, $salt, $t_cost, $m_factor, $parallelism, $tag_size)argon2d_pass($password, $salt, $t_cost, $m_factor, $parallelism, $tag_size)This function processes the $password much like "argon2_pass" does, but the $type argument is set like the function name. argon2id_verify($encoded, $password)argon2i_verify($encoded, $password)argon2d_verify($encoded, $password)This verifies that the $password matches $encoded and the given type. All parameters and the tag value are extracted from $encoded, so no further arguments are necessary. argon2id_raw($password, $salt, $t_cost, $m_factor, $parallelism, $tag_size)argon2i_raw($password, $salt, $t_cost, $m_factor, $parallelism, $tag_size)argon2d_raw($password, $salt, $t_cost, $m_factor, $parallelism, $tag_size)This function processes the $password much like "argon2_raw" does, but the $type argument is set like the function name. argon2_needs_rehash($encoded, $type, $t_cost, $m_cost, $parallelism, $output_length, $salt_length)This function checks if a password-encoded string needs a rehash. It will return true if the $type (valid values are "argon2i", "argon2id" or "argon2d"), $t_cost, $m_cost, $parallelism, $output_length or $salt_length arguments mismatches any of the parameters of the password-encoded hash. argon2_typesThis returns all supported argon2 subtypes. Currently that's 'argon2id', 'argon2i' and 'argon2d'. ACKNOWLEDGEMENTSThis module is based on the reference implementation as can be found at <https://github.com/P-H-C/phc-winner-argon2>. SEE ALSOYou will also need a good source of randomness to generate good salts. Some possible solutions include:
Implementations of other similar algorithms include:
AUTHORLeon Timmermans <leont@cpan.org> COPYRIGHT AND LICENSEThis software is Copyright (c) 2013 by Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, Samuel Neves, Thomas Pornin and Leon Timmermans. This is free software, licensed under: The Apache License, Version 2.0, January 2004
|