diff options
| author | Azul <azul@riseup.net> | 2013-06-20 17:28:55 +0200 | 
|---|---|---|
| committer | Azul <azul@riseup.net> | 2013-06-24 12:33:03 +0200 | 
| commit | 394f9377e3a0686625225f8e58d74a682096310b (patch) | |
| tree | c184abec5ed1843c736b3fe060c525e637f5efc3 /src | |
| parent | 3328b20621265b0c50ed395ea890b267ab89109b (diff) | |
fix bug wrt zero padding of hashes
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; | 
