Is it possible to replace randomized salts with user iterative hashing?

In the process of building what I would hope is a properly designed authentication mechanism, I found a lot of materials that indicate that:

  • user passwords must be salty.
  • the salt used should be random enough and generated for each user
  • ... therefore salt must be stored with a user record in order to support user password verification.

I completely agree with the first and second points, but it seems that there is an easy workaround for this. Instead of making an equivalent (here's the pseudocode):

salt = random();
hashedPassword = hash(salt . password);
storeUserRecord(username, hashedPassword, salt);

Why not use a username hash as a salt? This gives a salt region that is well distributed (roughly) random, and each individual salt is as complex as your salt function. Even better, you do not need to store salt in the database - just update it during authentication. More pseudo codes:

salt = hash(username);
hashedPassword = hash(salt . password);
storeUserRecord(username, hashedPassword);

(Of course, the hashexamples above should be something reasonable, like SHA-512 or another powerful hash.)

This seems reasonable to me, given that (little) I know about cryptography, but the fact that this simplification by widely recommended practice makes me wonder if there is any obvious reason why I went astray that I didn’t I know.

, , . , . TheRook: , CWE. , : hash (username) - ?

EDIT 2 , ; biffabacon ( , , , , ), .

+3
6

, . , . , , , , , . , , jsmith ( jsmith). , , .

(username) : , , 1000 , , -; 6000 6000 . 32- , 2 ^ 32 4,2 . . , (, ( )),

+6

. , , . , , : .

. , , ( !) .

+7

, . parallelism , ; , .

, . , , . ( ) ( , ). , .

- , . , .

( ) : , . : , ; - . ( , "bob", , , , , ). ( - - , "bob" ).

; , . , , ( , ).

+5

, , . , , , - , / ( , , - 8 char ). , , : root, administrator, bob, mary... . , , apache, ftp .. .

: , .

, . , , .

+1

2 , . - CWE-759, , . , CWE-760: . , , CWE-760,

. base256. , . , SHA256 256- . , .

, , .

?

, . , . 2 . 2 , . , - . , . , SQL Injeciton , .

, , , , . . , mysql file_priv , , .

+1

. - ( , ), , , + . - , , . , , , , , .

. ,

  H(password.username.appsalt)

-

  h1 = H(password.appsalt1.username.password)
  h2 = H(password.appsalt2.username.password)
  h3 = H(password.appsalt3.username.password)
  H(h1.H(h2.H(h3))))

( H() - , '.' - .) , .

I think multiple hashes are a good idea, even if you store random hashes in the user authentication table. Again, this will not have a noticeable effect on your application, but will make it much more difficult for an attacker.

0
source

Source: https://habr.com/ru/post/1743326/


All Articles