密码哈希:PBKDF2(使用 sha512 x 1000)与 Bcrypt

发布于 2024-10-07 13:45:46 字数 321 浏览 0 评论 0原文

我一直在阅读有关 Gawker 事件的文章,并且出现了几篇有关仅使用 bcrypt 进行哈希的文章密码,我想确保我的散列机制足够安全,以避免切换到另一种方法。在我当前的应用程序中,我选择了使用 sha2-512 和至少 1000 次迭代的 PBKDF2 实现。

我可以询问有关使用 PBKDF2 与 Bcrypt 的意见以及我是否应该实施更改?

I've been reading about the Gawker incident and several articles have cropped up regarding only using bcrypt to hash passwords and I want to make sure my hashing mechanism is secure enough to avoid switching to another method. In my current application I have opted for a PBKDF2 implementation utilising sha2-512 and a minimum of 1000 iterations.

Can I ask for opinions on using PBKDF2 vs Bcrypt and whether or not I should implement a change?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷清清 2024-10-14 13:45:46

从 2022 年开始,最好切换到内存困难的函数,例如 scrypt 或 Argon2。 Bcrypt 也可能是一种选择,但它并不难记忆。

至于 PBKDF2,在 2000 年就建议使用 1000 次迭代,现在您可能想要更多。

另外,使用 bcrypt 时应该更加小心:

还值得注意的是,虽然 bcrypt 对于大多数类型的密码都比 PBKDF2 更强,但它在长密码方面却落后了;这是因为 bcrypt 无法使用超过前 55 个字符的密码,而我们的估计成本和 NIST 的 .
密码熵的估计表明 bcrypt 的 55 个字符限制并不存在
目前可能会导致问题,依赖于
最好建议 bcrypt 要么解决此限制(例如,通过“预哈希”密码短语以使其适合 55 个字符的限制),要么采取措施
防止用户在第 56 个及后续密码中放置过多的密码熵
字符(例如,通过要求网站用户在输入框中输入密码
框只能容纳 55 个字符)。

来自 scrypt 论文 [PDF]

也就是说,还有 scrypt

如果没有上述 scrypt 论文中的表格,任何比较都是不完整的:

估计 1 年内破解密码的硬件成本。

使用的 PBKDF2-HMAC-SHA256 的迭代计数为 86,000 和 4,300,000。

As of 2022, it's best to switch to a memory-hard function, such as scrypt or Argon2. Bcrypt could also be an option, but it's not memory-hard.

As for PBKDF2, the recommendation to use 1000 iterations was made in year 2000, now you'd want much more.

Also, you should take more care when using bcrypt:

It is also worth noting that while bcrypt is stronger than PBKDF2 for most types of passwords, it falls behind for long passphrases; this results from bcrypt’s inability to use more than the first 55 characters of a passphrase While our estimated costs and NIST’s .
estimates of passphrase entropy suggest that bcrypt’s 55-character limitation is not
likely to cause problems at the present time, implementors of systems which rely on
bcrypt might be well-advised to either work around this limitation (e.g., by “prehashing” a passphrase to make it fit into the 55-character limit) or to take steps to
prevent users from placing too much password entropy in the 56th and subsequent
characters (e.g., by asking users of a website to type their password into an input
box which only has space for 55 characters).

From scrypt paper [PDF]

That said, there's also scrypt.

Any comparisons would be incomplete without the table from the scrypt paper mentioned above:

Estimated cost of hardware to crack a password in 1 year.

Iteration counts for PBKDF2-HMAC-SHA256 used there are 86,000 and 4,300,000.

甜`诱少女 2024-10-14 13:45:46

评论(回复:标题):

  • 除非必须,否则不要使用加密(可逆)来存储密码。
  • 由于您提供了哈希(不可逆)选项作为替代方案,我认为您不需要可逆性。

关于使用 PBKDF2 与 Bcrypt 的意见
我是否应该实施
改变?

我的意见:

使用 PBKDF2 而不是 Bcrypt。 (我只是对SHA比Blofish更有信心,没有任何理由)

至于你是否应该“实施改变”,我不知道你在问什么。

编辑以更清楚地将加密/散列讨论与陈述我的偏好w/r/t算法分开。

Comment (re: the title):

  • Don't use encryption (reversible) to store passwords unless you MUST.
  • Since you presented a hashing (non-reversible) option as an alternative, I assume you don't need reversibility.

opinions on using PBKDF2 vs Bcrypt and
whether or not I should implement a
change?

My opinion:

Use PBKDF2 over Bcrypt. (I just have more faith in SHA than Blofish, for no reason)

As for whether you should 'implement a change', I don't know what you are asking.

Edited to more clearly separate the encryption / hashing discussion from stating my preferences w/r/t algorithm.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文