问题描述
我的功能如下:
pbkdf2($raw_pw,$salt,1000,128)
1000是通过次数,而128是密钥大小.该函数返回一个二进制密钥,我使用base64将其存储在数据库中.
1000 is the number of passes, and 128 is the key size. The function returns a binary key which I use base64 to store it in the database.
我的问题是:使用sha512的pbkdf2的推荐密钥大小和盐大小是多少?
My question is: what's the recommended keysize and salt size for pbkdf2 using sha512?
密钥大小为32的密钥是否和密钥大小为128的密钥一样安全?
will a keysize of 32 be just as secure as a keysize of 128?
推荐答案
1000是迭代次数,而不是通过次数. 128是末尾的长度.
1000 is the number of iterations, not passes. 128 Is the length at the end.
根据维基百科(以及我自己对密码学的一点了解),您应该使用128位(或您要求的32位).生成的密钥的大小等于发生哈希冲突的机会.使用256(就像WPA2一样)或512应该不是问题,对于您的CPU/内存/其他也不是问题.
According to Wikipedia (and my own little knowledge about cryptography) you should use more than 128 bits (or 32 as you're asking). The size of the resulting key is equivalent to the chance for a hash collision. Using 256 (as WPA2 does) or 512 should not be a problem, also not a problem for your CPU/memory/whatever.
与pbkdf2的其他集成相比,也有1000个非常小的迭代.您可以轻松地使用5000或10000(如iOS4),这可能会导致处理时间增加10毫秒左右,但会使密钥更坚固(请参阅:可能的攻击者还必须运行10k迭代.这可能会改变他所需的时间) 1天至10天,或1个月至近1年.
Also 1000 is, compared to other integrations of pbkdf2, a very small amount of iterations. You can easily use 5000 or 10000 (like iOS4) which might result in something like 10ms more processing time but makes a way more stronger key (see: a possible attacker has also to run the 10k iterations. This might change the time he needs from 1 day to 10 days, or 1 month to almost 1 year).
这篇关于PBKDF2建议的密钥大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!