From 573ed263bc327a81d732a90e817e3adb8c113ed7 Mon Sep 17 00:00:00 2001 From: Lee Miller Date: Tue, 3 Jan 2023 06:17:21 +0200 Subject: [PATCH] Replace new Buffer() with Buffer.alloc() in lib/crypto - do it everywhere! --- lib/crypto.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/crypto.js b/lib/crypto.js index 5f419a8..420121c 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -104,15 +104,15 @@ var encrypted = exports.encrypted = { assert(buf.readUInt16BE(16, true) === SECP256K1_TYPE, "Bad curve type"); assert(buf.readUInt16BE(18, true) === 32, "Bad Rx length"); assert(buf.readUInt16BE(52, true) === 32, "Bad Ry length"); - var iv = new Buffer(16); + var iv = Buffer.alloc(16); buf.copy(iv, 0, 0, 16); - var ephemPublicKey = new Buffer(70); + var ephemPublicKey = Buffer.alloc(70); buf.copy(ephemPublicKey, 0, 16, 86); // NOTE(Kagami): We do copy instead of slice to protect against // possible source buffer modification by user. - var ciphertext = new Buffer(buf.length - 118); + var ciphertext = Buffer.alloc(buf.length - 118); buf.copy(ciphertext, 0, 86, buf.length - 32); - var mac = new Buffer(32); + var mac = Buffer.alloc(32); buf.copy(mac, 0, buf.length - 32); return { iv: iv,