Add choice of ops and mem limits to pwhash
This commit is contained in:
+17
-1
@@ -102,6 +102,7 @@
|
||||
shorthash/2,
|
||||
|
||||
%% No Tests!
|
||||
pwhash/4,
|
||||
pwhash_str/3,
|
||||
|
||||
%% EQC
|
||||
@@ -343,10 +344,25 @@ generichash_final({hashstate, HashSize, HashState}) ->
|
||||
%% @doc pwhash/2 hash a password
|
||||
%%
|
||||
%% This function generates a fixed size salted hash of a user defined password.
|
||||
%% Defaults to interactive/interactive limits.
|
||||
%% @end
|
||||
-spec pwhash(iodata(), binary()) -> {ok, binary()} | {error, term()}.
|
||||
pwhash(Password, Salt) ->
|
||||
enacl_nif:crypto_pwhash(Password, Salt).
|
||||
pwhash(Password, Salt, interactive, interactive).
|
||||
|
||||
%% @doc pwhash/4 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) -> {ok, binary()} | {error, term()}
|
||||
when
|
||||
Password :: iodata(),
|
||||
Salt :: binary(),
|
||||
Ops :: pwhash_limit(),
|
||||
Mem :: pwhash_limit().
|
||||
pwhash(Password, Salt, Ops, Mem) ->
|
||||
enacl_nif:crypto_pwhash(Password, Salt, Ops, Mem).
|
||||
|
||||
%% @doc pwhash_str/1 generates a ASCII encoded hash of a password
|
||||
%%
|
||||
|
||||
+2
-2
@@ -132,7 +132,7 @@
|
||||
|
||||
%% Password Hashing - Argon2 Algorithm
|
||||
-export([
|
||||
crypto_pwhash/2,
|
||||
crypto_pwhash/4,
|
||||
crypto_pwhash_str/3,
|
||||
crypto_pwhash_str_verify/2
|
||||
]).
|
||||
@@ -188,7 +188,7 @@ crypto_generichash_init(_HashSize, _Key) -> erlang:nif_error(nif_not_loaded).
|
||||
crypto_generichash_update(_HashSize, _HashState, _Message) -> erlang:nif_error(nif_not_loaded).
|
||||
crypto_generichash_final(_HashSize, _HashState) -> erlang:nif_error(nif_not_loaded).
|
||||
|
||||
crypto_pwhash(_Password, _Salt) -> erlang:nif_error(nif_not_loaded).
|
||||
crypto_pwhash(_Password, _Salt, _Ops, _Mem) -> 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