]> Repositorios git - scryer-prolog.git/commitdiff
type test for salt in crypto_password_hash/3
authorMarkus Triska <[email protected]>
Sun, 17 May 2020 20:01:22 +0000 (22:01 +0200)
committerMarkus Triska <[email protected]>
Sun, 17 May 2020 20:01:22 +0000 (22:01 +0200)
src/prolog/lib/crypto.pl

index b93a9cff595f71d77f0da32ea855b4aee8e41961..be6b6b31bb24143db31c1a799e40f279f42286bc 100644 (file)
@@ -379,7 +379,7 @@ crypto_password_hash(Password0, Hash, Options) :-
         Algorithm = 'pbkdf2-sha512', % current default and only option
         option(algorithm(Algorithm), Options, Algorithm),
         (   member(salt(SaltBytes), Options) ->
-            true
+            must_be_bytes(SaltBytes, crypto_password_hash/2)
         ;   crypto_n_random_bytes(16, SaltBytes)
         ),
         '$crypto_password_hash'(Password, SaltBytes, Iterations, HashBytes),
@@ -601,8 +601,6 @@ encoding_bytes(utf8, Cs, Bs) :-
         ;   domain_error(encryption_encoding, Cs, crypto)
         ).
 
-char_code(Char, Code) :- atom_codes(Char, [Code]).
-
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Modular multiplicative inverse.