bcrypt日志轮次与哈希迭代

时间:2015-02-18 05:30:48

标签: grails spring-security bcrypt

我刚刚开始使用Grails 2.4.4 / Spring Security 2.0-RC4(插件)应用。我使用的是Grails 2.3.11 / Spring Security 1.2.7.3中的相同安全配置:

grails.plugin.springsecurity.password.algorithm = 'bcrypt'
grails.plugin.springsecurity.password.bcrypt.logrounds = 31

它在启动时挂起 - 或者我认为。真的,它只是开始花费相当长的时间开始,当日志轮在20多岁。使用上一个应用程序,设置为31时没有延迟。在比较文档后,我注意到2.0插件有一个新的配置选项:

Property                    Default Description
password.hash.iterations    10000   the number of iterations which will be executed on the hashed password/salt.

然后我挖掘了代码,看来2.0不再依赖于jbcrypt,而是依赖于Spring实现(org.springframework.security.crypto.bcrypt)。

我认为这与速度上的差异有关,但我不了解bcrypt或实现的差异,足以比较它们。有人能说清楚这个吗?是什么让它们等同?这就是我想要的,还是我的旧应用程序不安全?

1 个答案:

答案 0 :(得分:2)

password.hash.iterations选项不适用于bcrypt,但会与其他哈希算法一起使用,例如SHA-256。

请注意,bcrypt logrounds与迭代不同。迭代次数= 2 log_rounds 。示例:12个logrounds = 4096(2 12 )次迭代。

如果计算速度很快,很可能不会应用31个bcrypt loground。

更新:旧的jbcrypt版本有overflow bug,其中设置为31会导致零(0)次迭代,而不是2 31 !来自同一问题的.NET端口has suffered