这个过程有多安全?
我将使用这种方法来存储我的密码:
- 用户输入密码
- 应用程序使用随机数对密码加盐
- 然后使用加盐密码使用某种加密算法进行加密 随机选择的数据数组(由预定义的字符/字节表组成)
- 为了简单起见,它可以仅使用数字表,因此在数字的情况下,随机数组将只是足够长的整数/大整数。
- 然后我存储在数据库盐(修改值)和加密数组中
要检查密码有效性:
- 获取给定密码
- 从数据库读取盐并计算解密密钥
- 尝试解密加密数组
- 如果成功(以数学平均值表示)逐字节比较解密值
- 它是否仅包含已知表中的字符/字节。例如它是整数/大整数吗?如果是这样 - 密码视为有效
您对此过程有何看法?
简而言之,它是使用哈希函数的一种替代方案......
在这种方法中,加密算法将用于计算不可逆值。
编辑
# Encrypt/decrypt function that works like this:
KEY=HASH(PASSWORD)
CYPHERTEXT = ENCRYPT(PLAINTEXT, KEY)
PLAINTEXT = DECRYPT(CYPHERTEXT, KEY)
# Encrypting the password when entered
KEY=HASH(PASSWORD)+SALT or HASH(PASSWORD+SALT)
ARRAY={A1, A2,... AI}
SOME_TABLE=RANDOM({ARRAY})
ENCRYPTED_TABLE = ENCRYPT(SOME_TABLE, KEY + SALT)
# Checking validity
DECRYPT(ENCRYPTED_TABLE, PASSWORD + SALT) == SOME_TABLE
if(SOME_TABLE contains only {ARRAY} elements) = VALID
else INVALID
I'm going to use this kind of approach to store my password:
- User enters password
- Application salts password with random number
- Then with salted password encrypt with some encryption algorithm randomly selected array of data (consisting from predefined table of chars/bytes)
- for simplicity it can be used just table of digits, so in case of digits random array would be simply be long enough integer/biginteger.
- Then I store in DB salt (modified value) and encrypted array
To check password validity:
- Getting given password
- Read salt from DB and calculate decrypt key
- Try to decrypt encrypted array
- If successfull (in mathematical mean) compare decrypted value byte by byte
- does it contains only chars/bytes from known table. For instance is it integer/biginteger? If so - password counts as valid
What do you think about this procedure?
In a few words, it's a kind of alternative to using hash functions...
In this approach encryption algorithm is about to be used for calculation of non-inversible value.
EDIT
# Encrypt/decrypt function that works like this:
KEY=HASH(PASSWORD)
CYPHERTEXT = ENCRYPT(PLAINTEXT, KEY)
PLAINTEXT = DECRYPT(CYPHERTEXT, KEY)
# Encrypting the password when entered
KEY=HASH(PASSWORD)+SALT or HASH(PASSWORD+SALT)
ARRAY={A1, A2,... AI}
SOME_TABLE=RANDOM({ARRAY})
ENCRYPTED_TABLE = ENCRYPT(SOME_TABLE, KEY + SALT)
# Checking validity
DECRYPT(ENCRYPTED_TABLE, PASSWORD + SALT) == SOME_TABLE
if(SOME_TABLE contains only {ARRAY} elements) = VALID
else INVALID
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据您所写的内容,我假设您想要执行以下操作:
首先:没有理智的人会在生产系统中使用这样的自制方案。因此,如果您正在考虑在现实世界中实际实施这一点,请返回。甚至不要尝试自己编写代码,使用经过验证的软件库来实现广泛接受的算法。
现在,如果您想将其视为一种智力练习,您可以这样开始:
如果您假设攻击者知道方程式的所有部分,除了实际密码之外。因此,想要检索密码的攻击者已经知道加密文本、明文和密码的一部分。
成功的机会将取决于实际的加密方案,也可能取决于链接模式。
我自己不是密码分析师,但不用想太多,我就感觉可能有很多攻击角度。
From what you write I assume you want to do the following:
First off: No sane person would use such a homemade scheme in a production system. So if you were thinking about actually implementing this in the real world, please go back. Don't even try to write the code yourself, use a proven software library that implements widely accepted algorithms.
Now, if you want to think about it as a mental exercise, you could start off like this:
If you should assume that an attacker will know all the parts of the equation, except the actual password. The attacker, who wants to retrieve the password, will therefore already know the encrypted text, the plaintext AND part of the password.
The chance of success will depend on the actual encryption scheme, and maybe the chaining mode.
I'm not a cryptanalyst myself, but without thinking about it too much I have the feeling that there could be a number of angles of attack.
所提出的方案充其量只是比简单存储密码和盐的散列安全性稍差一些。
这是因为加密步骤只是增加了一小部分恒定的时间来检查每个哈希值是否正确;但同时它还引入了等效哈希的类,因为
ARRAY
有多种可能的排列将被识别为有效。The proposed scheme is, at best, slightly less secure than simply storing the hash of the password and salt.
This is because the encryption step simply adds a small constant amount of time to checking if each hash value is correct; but at the same time it also introduces classes of equivalent hashes, since there are multiple possible permutations of
ARRAY
that will be recognised as valid.每次有人登录时,您都必须对每个密码进行暴力加密。
除非您事先知道密码是什么,否则无法完成此操作。
只需对密码加盐(和多个哈希)。
You would have to brute force the encryption on every password every time someone logs in.
This can't be done unless you know what the password is before hand.
Just salt (And multiple hash) the password.