Note that there are some explanatory texts on larger screens.

plurals
  1. POPassword salts: prepending vs. appending
    primarykey
    data
    text
    <p>I just looked at the implementation of password hashing in Django and noticed <a href="http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/models.py#L16" rel="noreferrer">that it prepends the salt</a>, so the hash is created like <code>sha1(salt + password)</code>, for example.</p> <p>In my opinion, salts are good for two purposes</p> <ol> <li><p>Preventing rainbow table lookups</p> <p>Alright, prepending/appending the salt doesn't really make a difference for rainbow tables.</p></li> <li><p><strong>Hardening against brute-force/dictionary attacks</strong></p> <p><em>This is what my question is about.</em> If someone wants to attack a single password from a stolen password database, he needs to try a lot of passwords (e.g. dictionary words or [A-Za-z0-9] permutations).</p> <p>Let's assume my password is "abcdef", the salt is "salt" and the attacker tries all [a-z]{6} passwords.</p> <p>With a prepended salt, one must calculate <code>hash("salt")</code>, store the hash algorithm's state and then go on from that point for each permutation. That is, going through all permutations would take 26^6 copy-hash-algorithm's-state-struct operations and 26^6 <code>hash(permutation of [a-z]{6})</code> operations. As copying the hash algorithm's state is freakin fast, the salt hardly adds any complexity here, no matter how long it is.</p> <p>But, with an appended salt, the attacker must calculate <code>hash(permutation of [a-z]{6} + salt)</code> for each permutation, leading to 26^10 hash operations. So obviously, <em>appending</em> salts adds complexity depending on the salt length.</p></li> </ol> <p>I don't believe this is for historical reasons because Django is rather new. So what's the sense in <em>prepending</em> salts?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload