【问题标题】:How to securely store a password without hashes?如何在没有哈希的情况下安全地存储密码?
【发布时间】:2017-07-26 12:20:35
【问题描述】:

我想有一种方法来验证用户(引入他的密码),而无需将该密码存储为纯文本或什至是它的哈希值。

我该怎么做?

拥有一个用户密钥可以加密的控制字符串并将其与我存储的加密字符串进行比较是否安全?

【问题讨论】:

  • “没有将该密码存储为纯文本甚至是哈希” - 为什么?
  • 安全原因
  • 哈希不就是这样工作的吗?
  • 如果您在Information Security提问,您可能会得到更好的答案
  • 我投票决定将此问题作为离题结束,因为它属于另一个 stackexchange 站点,可能是 infosec 或 crypto,具体取决于所寻求讨论的风格。

标签: authentication hash cryptography passwords


【解决方案1】:

根据 NIST(美国国家标准与技术研究院):

使用散列函数,使用随机盐在 HMAC 上迭代大约 100 毫秒,然后将盐与散列一起保存。使用PBKDF2password_hashBcrypt等函数和类似函数。关键是让攻击者花费大量时间通过蛮力寻找密码。

见:How to store your users’ passwords safely

摘自 Jim Fenton 的演讲“迈向更好的密码要求” 基于 NIST SP 800-63-3 草案文档“数字认证指南”的信息

做:

Require an 8 character min, >64 max with no truncation or 6 random digits  
Use a dictionary to disallow common passwords against a dictionary list of 10M compromised passwords  
Allow all printing characters (Unicode optional) + spaces but MAY canonicalize spaces out  
Best to accept Unicode, including emojis (1 “character”/code point) ?  
Limit failed authentication attempts to 100 in 30-day period per account  
Offer option to display the secret while typing rather than dots or asterisks  

Storing passwords:  
    Hash with 32-bit random salt using  key derivation function such as  
    PBKDF2 with SHA-1, SHA-2 family, SHA-3 family  
    with at least 10,000 iterations  

不要:

Require composition rules  
Allow hints  
Require routine password expiration  
Save plain or hashed versions with or without seeding  

请参阅:Toward Better Password Requirements Jim Fenton。

【讨论】:

    【解决方案2】:

    请参阅 Zaph 的回答,了解您需要做什么。我将添加更多背景以防万一。

    事实证明,以加密形式存储密码不如存储正确完成的密码哈希安全。这是因为加密密码被设计为使用正确的密钥进行未加密,并且加密算法不一定依赖于慢速作为其防御暴力攻击的方法之一。

    但是设计了正确完成的密码哈希算法,因此您无法从哈希中获取密码,并且密码哈希算法设计确实使用哈希速度(即使其变慢)作为对尝试查找的部分防御通过蛮力散列每个可能的密码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多