Skip to content

Commit

Permalink
JsSIP.Utils.MD5() renamed to JsSIP.Utils.calculateMD5() (a more prope…
Browse files Browse the repository at this point in the history
…r name for a function).
  • Loading branch information
ibc committed Feb 20, 2013
1 parent 2d2255f commit 7f523cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/DigestAuthentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,23 @@ JsSIP.DigestAuthentication.prototype.authenticate = function(password) {
}

// HA1 = MD5(A1) = MD5(username:realm:password)
ha1 = JsSIP.Utils.MD5(this.username + ":" + this.realm + ":" + password);
ha1 = JsSIP.Utils.calculateMD5(this.username + ":" + this.realm + ":" + password);

if (this.qop === 'auth' || this.qop === null) {
// HA2 = MD5(A2) = MD5(method:digestURI)
ha2 = JsSIP.Utils.MD5(this.method + ":" + this.uri);
ha2 = JsSIP.Utils.calculateMD5(this.method + ":" + this.uri);

} else if (this.qop === 'auth-int') {
// HA2 = MD5(A2) = MD5(method:digestURI:MD5(entityBody))
ha2 = JsSIP.Utils.MD5(this.method + ":" + this.uri + ":" + JsSIP.Utils.MD5(this.body ? this.body : ""));
ha2 = JsSIP.Utils.calculateMD5(this.method + ":" + this.uri + ":" + JsSIP.Utils.calculateMD5(this.body ? this.body : ""));
}

if(this.qop === 'auth' || this.qop === 'auth-int') {
// response = MD5(HA1:nonce:nonceCount:credentialsNonce:qop:HA2)
this.response = JsSIP.Utils.MD5(ha1 + ":" + this.nonce + ":" + this.decimalToHex(this.nc) + ":" + this.cnonce + ":" + this.qop + ":" + ha2);
this.response = JsSIP.Utils.calculateMD5(ha1 + ":" + this.nonce + ":" + this.decimalToHex(this.nc) + ":" + this.cnonce + ":" + this.qop + ":" + ha2);
} else {
// response = MD5(HA1:nonce:HA2)
this.response = JsSIP.Utils.MD5(ha1 + ":" + this.nonce + ":" + ha2);
this.response = JsSIP.Utils.calculateMD5(ha1 + ":" + this.nonce + ":" + ha2);
}

return this.toString();
Expand Down
2 changes: 1 addition & 1 deletion src/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ JsSIP.Utils= {
},

// MD5 (Message-Digest Algorithm) http://www.webtoolkit.info
MD5: function(string) {
calculateMD5: function(string) {
function RotateLeft(lValue, iShiftBits) {
return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
}
Expand Down

0 comments on commit 7f523cc

Please sign in to comment.