Skip to content

Commit

Permalink
[security] Use crypto.randomBytes() to generate the masking key (#994)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgress454 authored and lpinca committed Feb 8, 2017
1 parent c7bb730 commit 1653db1
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/Sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

var events = require('events')
, util = require('util')
, crypto = require('crypto')
, EventEmitter = events.EventEmitter
, ErrorCodes = require('./ErrorCodes')
, bufferUtil = require('./BufferUtil').BufferUtil
Expand Down Expand Up @@ -315,10 +316,5 @@ function getArrayBuffer(data) {
}

function getRandomMask() {
return new Buffer([
~~(Math.random() * 255),
~~(Math.random() * 255),
~~(Math.random() * 255),
~~(Math.random() * 255)
]);
return crypto.randomBytes(4);
}

0 comments on commit 1653db1

Please sign in to comment.