是否值得在客户端散列密码 [英] Is it worth hashing passwords on the client side

查看:24
本文介绍了是否值得在客户端散列密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想安装登录系统时,我总是将给定密码的 MD5 与其在服务器端用户表中的值进行比较.

When I want to put a login system in place, I always compare the MD5 of the given password with its value in the users table on the server side.

然而,我的一个朋友告诉我,一个清晰"的密码可以被网络软件嗅探.

However, a friend of mine told me that a "clear" password could be sniffed by a network software.

所以我的问题是:在客户端散列密码是个好主意吗?它比在服务器端散列更好吗?

So my question is: is it a good idea to hash the password on the client side? Is it better than hashing it on the server side?

推荐答案

基本上,你的朋友是对的.但是在客户端简单地散列密码只是只是比将它作为纯文本提交给服务器更好.可以侦听您的纯文本密码的人当然也能够侦听散列密码,并使用这些捕获的散列他/她自己对您的服务器进行身份验证.

Basically, your friend is right. But simply hashing the password on the client side is only just better than submitting it as plain text to the server. Someone, who can listen for your plain text passwords is certainly also able to listen for hashed passwords, and use these captured hashes him/herself to authenticate against your server.

就此而言,更安全的身份验证协议通常会跳过许多圈子,以确保这种重放攻击不起作用,通常是通过允许客户端选择一堆随机位,这些位是散列在一起的用密码,也明文的提交给服务器.

For this matter, more secure authentication protocols usually jump through a number of hoops in order to make sure, that such a replay attack cannot work, usually, by allowing the client to select a bunch of random bits, which are hashed along with the password, and also submitted in the clear to the server.

在服务器上:

  • 生成一些随机数
  • 将这些位(以明文形式)发送给客户端

在客户端:

  • 生成一些随机位
  • 连接密码、服务器的随机位和客户端的随机位
  • 生成上述哈希值
  • 向服务器提交随机位(以明文形式)和散列

因为服务器知道它自己的随机信息以及客户端的随机位(它以明文形式获取它们),所以它可以执行基本相同的转换.该协议确保,只要双方每次生成不同的噪声位",在此对话中侦听的任何人都可以稍后使用该信息使用记录的信息进行错误的身份验证(除非使用了非常弱的算法......),执行握手.

As the server knows its own random information as well as the client's random bits (it got them as clear text), it can perform essentially the same transformation. This protocol makes sure, that nobody listening in this conversation can use the information later to authenticate falsely using the information recorded (unless a very weak algorithm was used...), as long as both parties generate different "noise bits" each time, the hand shake is performed.

编辑所有这些都容易出错且乏味,而且有些难以正确处理(阅读:安全).如果可能,请考虑使用已由知识渊博的人编写的身份验证协议实现(与我不同!以上只是我前段时间阅读的一本书的记忆.)您通常不想自己编写.

Edit All of this is error prone and tedious and somewhat hard to get right (read: secure). If ever possible, consider using authentication protocol implementations already written by knowledgeable people (unlike me! The above is only from memory of a book I read some time ago.) You really don't want to write this yourself usually.

这篇关于是否值得在客户端散列密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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