Encrypting username and password using openssl_encrypt on client side?

时间:2016-04-04 18:22:05

标签: php ios encryption openssl php-openssl

I make API for PHP website and I need to send a login and user password in encrypted form. I chose the following method to decrypt:

$decrypted = openssl_decrypt($user_login, 'bf-ecb', $client_id);

Where $user_login is a string like a 'login:password'. The $client_id know my site and client application. Client is likely to be an application on iPhone. Are normal encryption algorithm I chose, and will not be any problems on the client side with the encoding of user name and password?

1 个答案:

答案 0 :(得分:1)

  

我选择的是普通加密算法吗?用户名和密码编码在客户端不会出现任何问题吗?

您可能需要使用类似WebCrypto的内容来确保客户端可以使用已接受和已实现的加密算法。您可能需要polyfill

从更大的角度来看,你有两个问题需要解决。首先是网络安全模型。在Web安全模型中,拦截是一个有效的用例。其次是违反服务器安全性和密码列表。

<强> 拦截

第一个问题是由于W3C的理念,你对破碎的视觉无能为力。使用Public Key Pinning with Overrides,网络安全模型的基本缺陷变得非常清晰。覆盖适应拦截,网络人员努力淡化和掩盖行为。

您的直接防御是像您一样放置额外的安全控制。也就是说,使用加密,因此闯入者无法使用用户名和纯文本密码。 WebCrypto可以帮助您,因此您无需polyfill

但是,有一个潜在的问题。拦截器可以允许加密的用户名和密码通过,然后在返回到客户端时捕获cookie或令牌。所以你也需要保护cookie。

需要保护用户名,密码和cookie免受重播攻击。您不希望攻击者获取加密的用户名和密码,然后在以后重播以获取经过身份验证的会话。所以听起来它也需要盐或nonce。

数据泄露

可以通过遵循服务器端密码存储的最佳实践来修复第二个问题。为此,请参阅OWASP的Password Storage Cheat SheetSecure Password Storage Threat Model

相关问题