如何设计系统以允许加密的迁移? [英] How to design system to allow migration of encryption?

查看:168
本文介绍了如何设计系统以允许加密的迁移?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置一个系统,我允许将加密密码(哈希密码)从一个系统迁移到另一个系统。我该怎么办?说2个月下来,我发现一个加密是10倍,当前的哈希函数已被证明毫无疑问,完全是脆弱的。我将如何将用户密码从一种类型的哈希迁移到另一种类型(更好的一种)。

解决方案

使用以下技术,您可以慢慢地从一种方法迁移到另一种方法。我不能保证其质量,所以请用一粒盐(双关不当)。



例如,考虑下面的表,存储用户:

  id名称密码salt hashmethod 
-------------------- ------------------------
1 alice ABC52 ... ABD ... md5
2 bob 28DHF ... Z + d ... sha1
...

说你的哈希方法是md5,你想用更安全的 sha1 替换它,这就是你所做的:




  • 用户登录后,使用新的方法(sha1)和salt来填写密码。

    • a)如果找到匹配(相应的用户名和密码和方法sha1),则会记录用户。

    • b)如果一个匹配是找到:

      • 1)使用旧的方法(md5)和salt进行散列。

        • a)如果找到匹配(相应的用户名和密码和方法md5),则使用新的方法(sha1)和salt,并相应地更新数据库。该用户被记录。

        • b)如果找到匹配项,凭证无效,用户未登录。






此迁移可能需要很长时间,因此要加快速度,您应该通过电子邮件通知用户要求他们登录或更改密码。



希望它有帮助。


I want to set up a system where I am allow to migrate encrypted password (hash password), from one system to another. How would i do this?

Say 2 month down the line, i found a encryption that is 10 times better and the current hash function has been proven without a doubt, totally vulnerable. How would I go about migrating user password from one type of hash to another (the better one).

解决方案

You can slowly migrate from a method to another using the following technique. I cannot guarantee its quality so please take it with a grain of salt (pun not intended).

For example, consider the following table, that stores users:

id    name    password    salt    hashmethod
--------------------------------------------
1     alice   ABC52...    ABD...  md5
2     bob     28DHF...    Z+d...  sha1
...

Say that your outdated hash method is md5 and you want to replace it with the more secure sha1, this is what you do:

  • A user logs in, you hash its password with the new method (sha1) and salt.
    • a) If a match is found (corresponding username and password and method sha1), the user is logged.
    • b) If a match is not found:
      • 1) You hash with the old method (md5) and salt.
        • a) If a match is found (corresponding username and password and method md5), you hash the password with the new method (sha1) and salt, and update the database accordingly. The user is logged.
        • b) If a match is not found, the credentials are invalid and the user is not logged.

This migration can take a long time, so to speed it up you should e-mail your users asking them to log in or change their passwords.

Hope it helps.

这篇关于如何设计系统以允许加密的迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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