Extend pwhashing with limits

In the EQC tests, we generate limits at random and verify things work.
This commit is contained in:
Jesper Louis Andersen 2020-02-05 13:41:19 +01:00
parent dea9ce62ed
commit 1cb2c3a2a2
2 changed files with 5 additions and 7 deletions

View File

@ -13,10 +13,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- sign - sign
- Implement missing EQC tests - Implement missing EQC tests
- Generichash
- Multi-part generic hash
- pwhash
- Extend with limit for ops and memory as well.
## [Unreleased] ## [Unreleased]

View File

@ -762,12 +762,14 @@ pwhash_str_verify(PasswdHash, Passwd) ->
end. end.
prop_pwhash_str_verify() -> prop_pwhash_str_verify() ->
?FORALL({Passwd}, ?FORALL({Passwd, OLimit, MLimit},
{?FAULT_RATE(1, 40, g_iodata())}, {?FAULT_RATE(1, 40, g_iodata()),
elements([interactive, moderate, sensitive]),
elements([interactive, moderate, sensitive])},
begin begin
case v_iodata(Passwd) of case v_iodata(Passwd) of
true -> true ->
Ascii = enacl:pwhash_str(Passwd), Ascii = enacl:pwhash_str(Passwd, OLimit, MLimit),
S = enacl:pwhash_str_verify(Ascii, Passwd), S = enacl:pwhash_str_verify(Ascii, Passwd),
equals(S, true); equals(S, true);
false -> false ->