安全发送纯文本密码? [英] Securely send a Plain Text password?

查看:114
本文介绍了安全发送纯文本密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iOS的应用程序,让用户填写他们的密码。然后,密码将使用POST或GET发布到我网站上的PHP页面。 (它必须是明文,因为它在脚本中使用。)



除了HTTPS,有没有办法保护密码?在Obj-C中加密,然后在PHP中解密?



注意:用户名不发送...只有密码发布到服务器。 >

编辑:
为了澄清,David Stratton是正确的...我试图防止公共场所的恶意嗅探器只是读出明文密码,因为它们被发布到

解决方案

挑战回应大纲



假设你有单向散列函数 abc (实际使用 md5 sha1 一种用于PHP的密码强大的散列算法见: password_hash )。



您存储在数据库中的密码是 abc(password + salt) code>(分别存储 salt



服务器生成随机挑战挑战并将其发送给客户端(使用 salt )并计算预期响应: abc(challenge + abc(password + salt))



客户端然后计算: abc(user_password + salt)并应用挑战获取 abc(challenge + abc(user_password + salt)),发送到服务器,服务器可以方便地验证有效性。



这是安全的,因为:




  • 密码永远不会以明文形式发送,或以明文方式存储

  • 发送的哈希值每次更改(缓解重播攻击)



有一些问题:



你怎么知道要发送什么盐?那么,我从来没有真正找到一个解决方案,但是使用确定性算法将用户名转换成盐解决了这个问题。如果算法不是确定性的,攻击者可能会弄清楚哪个用户名存在,哪些不存在。这确实需要你有一个用户名。或者,您可以只有一个静态盐,但是我不了解密码学来评估该实施的质量。


I'm working on an application for iOS which will have the user fill out their password. The password will then be posted to a PHP page on my site using either POST or GET. (It must be plaintext because it is used in a script.)

Besides HTTPS, is there any way to secure the password? Encrypt it in Obj-C and then decrypt it in PHP?

NOTE: The username is not sent... only the password is posted to the server.

EDIT: To clarify, David Stratton is correct... I'm trying to prevent malicious sniffers in public locations from simply reading clear text passwords as they are posted to the server.

解决方案

Challenge response outline

Lets assume you have one-way hash function abc (in practice use md5 or sha1 a cryptographically strong hashing algorithm for PHP see: password_hash).

The password you store in your database is abc(password + salt) (store the salt separately)

The server generates a random challenge challenge and sends it to the client (with the salt) and calculates the expected response: abc(challenge + abc(password + salt))

The client then calculates: abc(user_password + salt) and applies the challenge to get abc(challenge + abc(user_password + salt)), that is sent to the server and the server can easily verify validity.

This is secure because:

  • The password is never sent in plaintext, or stored in plaintext
  • The hash value that is sent changes every time (mitigates replay attack)

There are some issues:

How do you know what salt to send? Well, I've never really found a solution for this, but using a deterministic algorithm to turn a username into a salt solves this problem. If the algorithm isn't deterministic an attacker could potentially figure out which username exists and which do not. This does require you to have a username though. Alternatively you could just have a static salt, but I don't know enough about cryptography to assess the quality of that implementation.

这篇关于安全发送纯文本密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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