Skip to content

Commit

Permalink
Merge pull request #746 from tejasmanohar/fix/node_6_crypto_binary
Browse files Browse the repository at this point in the history
specify data encoding type 'binary' at hash#update
  • Loading branch information
3rd-Eden authored Jun 13, 2016
2 parents dc93694 + 04ccdf7 commit f0c5699
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/WebSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ function initAsClient(address, protocols, options) {
// begin handshake
var key = new Buffer(options.value.protocolVersion + '-' + Date.now()).toString('base64');
var shasum = crypto.createHash('sha1');
shasum.update(key + '258EAFA5-E914-47DA-95CA-C5AB0DC85B11');
shasum.update(key + '258EAFA5-E914-47DA-95CA-C5AB0DC85B11', 'binary');
var expectedServerKey = shasum.digest('base64');

var agent = options.value.agent;
Expand Down
6 changes: 3 additions & 3 deletions lib/WebSocketServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function handleHybiUpgrade(req, socket, upgradeHead, cb) {
// calc key
var key = req.headers['sec-websocket-key'];
var shasum = crypto.createHash('sha1');
shasum.update(key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11");
shasum.update(key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11", 'binary');
key = shasum.digest('base64');

var headers = [
Expand Down Expand Up @@ -421,9 +421,9 @@ function handleHixieUpgrade(req, socket, upgradeHead, cb) {
n >> 24 & 0xFF,
n >> 16 & 0xFF,
n >> 8 & 0xFF,
n & 0xFF));
n & 0xFF), 'binary');
});
md5.update(nonce.toString('binary'));
md5.update(nonce.toString('binary'), 'binary');

socket.setTimeout(0);
socket.setNoDelay(true);
Expand Down
6 changes: 3 additions & 3 deletions test/testserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function validServer(server, req, socket) {
// calc key
var key = req.headers['sec-websocket-key'];
var shasum = crypto.createHash('sha1');
shasum.update(key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11");
shasum.update(key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11", 'binary');
key = shasum.digest('base64');

var headers = [
Expand Down Expand Up @@ -113,7 +113,7 @@ function invalidRequestHandler(server, req, socket) {
// calc key
var key = req.headers['sec-websocket-key'];
var shasum = crypto.createHash('sha1');
shasum.update(key + "bogus");
shasum.update(key + "bogus", 'binary');
key = shasum.digest('base64');

var headers = [
Expand Down Expand Up @@ -142,7 +142,7 @@ function closeAfterConnectHandler(server, req, socket) {
// calc key
var key = req.headers['sec-websocket-key'];
var shasum = crypto.createHash('sha1');
shasum.update(key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11");
shasum.update(key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11", 'binary');
key = shasum.digest('base64');

var headers = [
Expand Down

0 comments on commit f0c5699

Please sign in to comment.