如何存储和验证从 PIN/密码中随机选择的数字 [英] How to store and verify digits chosen at random from a PIN/Password

查看:19
本文介绍了如何存储和验证从 PIN/密码中随机选择的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个用户的 6 位 PIN(或 n 字符字符串),并且我希望验证从 PIN(或 x 字符)中随机选择的 3 位数字作为登录"过程的一部分,我将如何存储数据库中的 PIN 或某些加密/散列版本的 PIN,以便我可以验证用户身份?

想法:

  1. 将 PIN 码存储在可翻转的(对称或非对称)加密方式,解密用于数字校验.
  2. 存储 PIN 的一系列散列排列,以针对某些ID,链接到随机选择数字,例如:
    • ID:123 = 数字 1、2、3 的哈希
    • ID:416 = 数字 4、1、6 的哈希

问题:

  1. 密钥安全性:假设密钥是'受保护',并且该应用程序不是财务上也不是很挑剔,但是是大容量".
  2. 创建一个散列的宽数排列都是令人望而却步的高存储空间(16bytes x 几个排列)和耗时可能过大

还有其他选择、问题或改进吗?

是的:我知道以可逆方式存储密码/PIN 是有争议的",理想情况下不应该这样做.

更新

只是为了澄清:1. 随机数字是我正在考虑避免键盘记录器的一种方案.2. 重试次数不能超过限制次数.3. 其他元素有助于保护和验证访问.

解决方案

  • 密钥已受保护"
  • 该应用既不财务也不高关键,
  • 该应用是大容量".
  • 创建一个宽数的哈希排列都是令人望而却步的高存储空间(16bytes x 几个排列)和耗时可能矫枉过正
  • 随机数字是我的一个方案考虑避免使用键盘记录器.
  • 无法尝试更多重试次数有限.
  • 其他元素有助于确保安全和验证访问权限.

您似乎在争论以明文形式存储 PIN.我说去吧.您基本上是在描述一种质询-响应身份验证方法,服务器端的明文存储对于该用例来说很常见.

类似的东西是一次性键盘或密钥矩阵.不同之处在于用户必须随身携带/携带键盘才能访问.这样做的好处是,只要您的密钥分发足够安全,您就不会受到键盘记录器的攻击.<​​/p>

如果您想让矩阵/焊盘的暴露不会单独造成损害,请让用户在焊盘上使用一个短的(3-4 位数字)PIN,并保留您的敏感锁定机制.

矩阵示例:

 1 2 3 4 5 6 7 8一个 ;k j l k a s gB f q 3 n 0 8 u 0C 1 2 8 例如 8 -

挑战可能是:输入您的 PIN,然后输入矩阵中方框 B3 中的字符."

响应可能是:98763

If I have a users 6 digit PIN (or n char string) and I wish to verify say 3 digits chosen at random from the PIN (or x chars) as part of a 'login' procedure, how would I store the PIN in a database or some encrypted/hashed version of the PIN in such a way that I could verify the users identity?

Thoughts:

  1. Store the PIN in a reversible (symmetrically or asymmetrically) encrypted manner, decrypt for digit checks.
  2. Store a range of hashed permutations of the PIN against some ID, which links to the 'random digits' selected, eg:
    • ID: 123 = Hash of Digits 1, 2, 3
    • ID: 416 = Hash of Digits 4, 1, 6

Issues:

  1. Key security: Assume that the key is 'protected' and that the app is not financial nor highly critical, but is 'high-volume'.
  2. Creating a wide-number number of hash permutations is both prohibitively high-storage (16bytes x several permutations) and time-consuming probably overkill

Are there any other options, issues or refinements?

Yes: I know storing passwords/PINs in a reversible manner is 'contentious' and ideally shouldn't be done.

Update

Just for clarification: 1. Random digits is a scheme I am considering to avoid key-loggers. 2. It is not possible to attempt more than a limited number of retries. 3. Other elements help secure and authenticate access.

解决方案

  • The key is 'protected'
  • The app is not financial nor highly critical,
  • The app is 'high-volume'.
  • Creating a wide-number number of hash permutations is both prohibitively high-storage (16bytes x several permutations) and time-consuming probably overkill
  • Random digits is a scheme I am considering to avoid key-loggers.
  • It is not possible to attempt more than a limited number of retries.
  • Other elements help secure and authenticate access.

You seem to be arguing for storing the PIN in the clear. I say go for it. You're basically describing a challenge-response authentication method, and cleartext storage on the server side is common for that use-case.

Something similar to this is a one-time-pad, or a secret key matrix. The difference is that the user has to keep / have the pad with them to access. The benefit is that as long as you get the key distribution sufficiently secure, you're very safe from keyloggers.

If you want to make it so that exposure of the matrix / pad doesn't cause compromise alone, have the user use a short (3-4 number) PIN with the pad, and keep your sensitive locking mechanism.

Example of a matrix:

  1  2  3  4  5  6  7  8
A ;  k  j  l  k  a  s  g
B f  q  3  n  0  8  u  0
C 1  2  8  e  g  u  8  -

A challenge might be: "Enter your PIN, and then the character from square B3 from your matrix."

The response might be: 98763

这篇关于如何存储和验证从 PIN/密码中随机选择的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆