Skip to content

Commit 1653db1

Browse files
sgress454lpinca
authored andcommitted
[security] Use crypto.randomBytes() to generate the masking key (#994)
1 parent c7bb730 commit 1653db1

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/Sender.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
var events = require('events')
88
, util = require('util')
9+
, crypto = require('crypto')
910
, EventEmitter = events.EventEmitter
1011
, ErrorCodes = require('./ErrorCodes')
1112
, bufferUtil = require('./BufferUtil').BufferUtil
@@ -315,10 +316,5 @@ function getArrayBuffer(data) {
315316
}
316317

317318
function getRandomMask() {
318-
return new Buffer([
319-
~~(Math.random() * 255),
320-
~~(Math.random() * 255),
321-
~~(Math.random() * 255),
322-
~~(Math.random() * 255)
323-
]);
319+
return crypto.randomBytes(4);
324320
}

0 commit comments

Comments
 (0)