Skip to content

Commit

Permalink
[DISF-1700] Fix SRP missing implementation
Browse files Browse the repository at this point in the history
Following the RFC2945, if A % N is zero, the server must abort the authentication.
  • Loading branch information
sducamp committed Aug 31, 2023
1 parent 304482d commit 4750f07
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/session.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/session.min.js.map

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions lib/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,19 @@ define(['srp', 'jquery', 'otp', 'crypto-js'], function (Srp, jQuery, Otp, Crypto
* Valide la clef retournée par le serveur.
*/
validateKey: function () {
var that = this;
let that = this,
M1 = "";

try {
M1 = this.srp.getM1String();
} catch (e) {
that.promise.reject();
}

jQuery.post(
config.tipi_url + 'session/login',
{
M1: this.srp.getM1String()
M1: M1
}
).done(function (data) {
if (data.M2 && data.M2 === that.srp.getM2String()) {
Expand Down
4 changes: 4 additions & 0 deletions lib/srp.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ define(['bignum', 'crypto-js'], function (Bn, CryptoJS) {
* @returns {bignum} S
*/
getS: function () {
if (this.getA().mod(this.N).toString() === "0") {
throw new Error('invalid client-supplied \'A\', A % N == 0');
}

if (this.S === undefined) {
// B - kg ** x
this.S = this.getB().modSub(
Expand Down

0 comments on commit 4750f07

Please sign in to comment.