KDF用来从不安全的密码中生成安全的密码,实际上相当于加了个随机数salt,这样就使即使用户拥有相同的密码,依然有不同的加密结果。
In cryptography, a key derivation function (or KDF) derives one or more secret keys from a secret value such as a master key or other known information such as a password or passphrase using a pseudo-random function.[1][2] Keyed cryptographic hash functions are popular examples of pseudo-random functions used for key derivation.[3]
----------------------------------------------how salt works----------------------------------------------------------
Usually, when the user registers, you will generate a random value to become the salt. Then, in the user database, you store the user's name, salt, and hash generated using the password and salt (and whatever else is relevant for a user table).
Note that doing it this way allows each user to have a unique salt. Each user having a unique salt greatly increases attack difficulty. An attacker is forced to do a brute-force attack per user instead of precomputing per-password-scheme rainbow tables (no salts) or a per-database rainbow table (a system-wide salt). It is still your responsibility to make sure the brute force attack is actually slow enough to be costly to an attacker in these days of massively parallel GPU hash implementations.
Ideally, an attacker would not even be able to see the salt on the database, but it does not have to be private if worse comes to worse.
没有评论:
发表评论