diff options
author | Azul <azul@riseup.net> | 2013-06-20 17:28:55 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2013-06-20 17:28:55 +0200 |
commit | 4c53d48b0df6754d03a2f0cfa5e1ac36410062c5 (patch) | |
tree | c184abec5ed1843c736b3fe060c525e637f5efc3 /src | |
parent | cc31045a9215ea255ab686040fce804859aadde7 (diff) |
fix bug wrt zero padding of hashesdevelop
Diffstat (limited to 'src')
-rw-r--r-- | src/srp_session.js | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/srp_session.js b/src/srp_session.js index b1b6014..f895f4a 100644 --- a/src/srp_session.js +++ b/src/srp_session.js @@ -121,11 +121,15 @@ srp.Session = function(login, password) { hexString += Astr; hexString += Bstr; hexString += K - M = SHA256(hex2a(hexString)); + M = removeLeading0(SHA256(hex2a(hexString))); //M2 = H(A, M, K) - M2 = SHA256(hex2a(Astr + M + K)); + M2 = removeLeading0(SHA256(hex2a(Astr + M + K))); }; + this.getS = function() { + return S; + } + this.getM = function() { return M; } @@ -161,8 +165,19 @@ srp.Session = function(login, password) { return retstring; }; + function removeLeading0(hex) { + if (hex[0] == "0") { + return hex.substr(1); + } else { + return hex; + } + } + function hex2a(hex) { var str = ''; + if(hex.length % 2) { + hex = "0" + hex; + } for (var i = 0; i < hex.length; i += 2) str += String.fromCharCode(parseInt(hex.substr(i, 2), 16)); return str; |