kirm / sip.js

Session Initiation Protocol for node.js
MIT License
427 stars 171 forks source link

when nc is number,it will get wrong response #107

Closed mofelee closed 8 years ago

mofelee commented 8 years ago

// chrome request header
// Authorization: Digest username="aaa", realm="UTT", nonce="b2c3cd0e094b4a7e48a42efa0505e6e0", uri="/", algorithm=MD5, response="899640e29a53ea40f96940bda6686487", opaque="5ccc069c403ebaf9f0171e9517f40e41", qop=auth, nc=00000001, cnonce="4688e752b2a56392"
var ha1 = digest.calculateHA1({
    user: 'aaa',
    realm: 'UTT',
    password: 'bbb'
});

var response = digest.calculateDigest({
    ha1: ha1,
    nonce: 'b2c3cd0e094b4a7e48a42efa0505e6e0',
    nc: 00000001, // < ----- when nc is number
    cnonce: '4688e752b2a56392',
    qop: 'auth',
    method: 'GET',
    uri: '/'
})
console.log(response); // 351e522f103af77496f34467107f3c56

response = digest.calculateDigest({
    ha1: ha1,
    nonce: 'b2c3cd0e094b4a7e48a42efa0505e6e0',
    nc: '00000001', // < ----- when nc is string
    cnonce: '4688e752b2a56392',
    qop: 'auth',
    method: 'GET',
    uri: '/'
})
console.log(response); // 899640e29a53ea40f96940bda6686487
mofelee commented 8 years ago

i suggest to warning if nc is a number,because 00000001 === 1