Allow specifying algorithm for pwhash
This commit is contained in:
+19
-1
@@ -116,6 +116,8 @@
|
||||
shorthash_size/0,
|
||||
shorthash/2,
|
||||
|
||||
pwhash/5,
|
||||
|
||||
pwhash/4,
|
||||
pwhash_str/3,
|
||||
|
||||
@@ -395,6 +397,7 @@ generichash_final(State) ->
|
||||
enacl_nif:crypto_generichash_final(State).
|
||||
|
||||
-type pwhash_limit() :: interactive | moderate | sensitive | pos_integer().
|
||||
-type pwhash_alg() :: default | argon2i13 | argon2id13 | pos_integer().
|
||||
%% @doc pwhash/2 hash a password
|
||||
%%
|
||||
%% This function generates a fixed size salted hash of a user defined password.
|
||||
@@ -416,7 +419,22 @@ pwhash(Password, Salt) ->
|
||||
Ops :: pwhash_limit(),
|
||||
Mem :: pwhash_limit().
|
||||
pwhash(Password, Salt, Ops, Mem) ->
|
||||
enacl_nif:crypto_pwhash(Password, Salt, Ops, Mem).
|
||||
enacl_nif:crypto_pwhash(Password, Salt, Ops, Mem, default).
|
||||
|
||||
%% @doc pwhash/5 hash a password
|
||||
%%
|
||||
%% This function generates a fixed size salted hash of a user defined password given Ops and Mem
|
||||
%% limits.
|
||||
%% @end
|
||||
-spec pwhash(Password, Salt, Ops, Mem, Alg) -> binary()
|
||||
when
|
||||
Password :: iodata(),
|
||||
Salt :: binary(),
|
||||
Ops :: pwhash_limit(),
|
||||
Mem :: pwhash_limit(),
|
||||
Alg :: pwhash_alg().
|
||||
pwhash(Password, Salt, Ops, Mem, Alg) ->
|
||||
enacl_nif:crypto_pwhash(Password, Salt, Ops, Mem, Alg).
|
||||
|
||||
%% @doc pwhash_str/1 generates a ASCII encoded hash of a password
|
||||
%%
|
||||
|
||||
+2
-2
@@ -147,7 +147,7 @@
|
||||
|
||||
%% Password Hashing - Argon2 Algorithm
|
||||
-export([
|
||||
crypto_pwhash/4,
|
||||
crypto_pwhash/5,
|
||||
crypto_pwhash_str/3,
|
||||
crypto_pwhash_str_verify/2
|
||||
]).
|
||||
@@ -238,7 +238,7 @@ crypto_secretstream_xchacha20poly1305_init_pull(_Header, _Key) -> erlang:nif_err
|
||||
crypto_secretstream_xchacha20poly1305_pull(_Ref, _CipherText, _AD) -> erlang:nif_error(nif_not_loaded).
|
||||
crypto_secretstream_xchacha20poly1305_rekey(_Ref) -> erlang:nif_error(nif_not_loaded).
|
||||
|
||||
crypto_pwhash(_Password, _Salt, _Ops, _Mem) -> erlang:nif_error(nif_not_loaded).
|
||||
crypto_pwhash(_Password, _Salt, _Ops, _Mem, _Alg) -> erlang:nif_error(nif_not_loaded).
|
||||
crypto_pwhash_str(_Password, _Ops, _Mem) -> erlang:nif_error(nif_not_loaded).
|
||||
crypto_pwhash_str_verify(_HashedPassword, _Password) -> erlang:nif_error(nif_not_loaded).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user