📜 ⬆️ ⬇️

SRP-6: authentication without sending a password

As promised in the next topic , where the bike was told, I post the description of the SRP RFC2945 algorithm - the method of registering and authenticating users in a secure way over an insecure channel. That's just in the process of preparing the article, I discovered a more recent version of the protocol, SRP-6 , along with the implementation, and therefore decided to throw away my archaic developments on SRP-3, and just give references to the implementation of the new version.

The Secure Remote Password (SRP) protocol describes the establishment of a secure connection using a login and password pair for authentication, in which the password is used only during the registration and authentication phase and only on the client side. Due to the use of a scheme close to Diffie-Hellman, SRP provides secure user password authentication without the need to transfer this password, and even having a complete exchange record over the channel, we do not receive sufficient information to authenticate this user. Also, if the server is compromised and the entire database of logins from the server side flows “to the people”, the attacker will not be able to authenticate any of the users.x

So, the general scheme of user authentication using abbreviated SRP exchanges is as follows:

As a result, the authentication process requires 2 requests to the server and the presence of any software client on the user side. Once again I pay attention, on first of all protection from server side. The server gives as little information as possible, producing first checks at home. Therefore, an attacker who has s and v may present himself as a server, but cannot be an intermediary .

To implement the login, you can use the classic login form + password, onSubmit which is authenticated.
If there is no javascript on the client side, the form will be sent “as is”, which will transmit the password via an insecure channel, but will allow you to authenticate even from “stupid” clients (by simulating all the actions of the “user” on the server).
In the case of the presence of JS, authentication is implemented by sending two special forms using AJAX techniques, performing calculations between them.
')
However, if the site is not required to work without JS (for example, a fallback is not possible at all, too complicated, we don’t drag on the time and effort of developers), it seems to me more reasonable to implement such a scheme: the fields are not in shape at all, after from the login field, the password field is blocked for a while, and the ajax spinner is drawn next to it. After receiving the salt for the user from the server, the password field is unlocked and you can enter the password there.
The sense in separation is necessary to give JS time for calculations. Still, there is quite a lot of mathematics with large numbers. When I investigated this question on SRP-3 using SHA1 (about five years ago), using 512bit keys turned out to be too slow - up to 30 seconds to calculate to confirm the password. At the same time, the entire browser UI [especially IE6;)] is blocked for the duration of the calculation. The solution could be calculations using a continuation (starting the calculation in slices via setTimeout (), keeping the context between calls) or taking calculations in flash / java. And java is preferable in terms of computation speed, and flash in terms of the likelihood of accessibility by the user.

The important point is that the server can respond with salt to any username given to it, in order not to give information about the existence of the specified user in its database, but then the salt for non-existent users should be calculated using an algorithm based on username, and this algorithm should be saved in secret, or to be unrepeatable without any secret information on the server side. Simply put, it is necessary that the salt based on the username cannot be distinguished from the completely random salt of real users.

Another very important to understand that the algorithm does not protect against phishing. A fake website can easily produce an identical-looking page, which will also have login and password fields, up to simulation simulation, calculating, for example, the sum of a series of numbers from 1 to 1e12 through a one-liner , actually sending the password “as is” to the attacker's server . That is why it seems to me that using a signed Java authenticator is more attractive - when faking, it will be necessary to simulate the signature on the authorizer's Java applet ... That, in general, using human laziness and inattention is still possible.

Ready-made implementations of SRP on JS can be found at the links:

Read more on the topic can and should:

Source: https://habr.com/ru/post/121021/


All Articles