From b575631bb03b455c9addbdb2cac5d392075d441e Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Wed, 6 Mar 2019 17:59:53 -0800 Subject: [PATCH] fix: bad assertion in crypto functions that use BN_bn2bin_padded (#17220) * chore: roll node in particular, this picks up electron/node#70a78f07b, which fixes an issue with incorrect usage of the BN_bn2bin_padded API in boringssl * fix tests --- DEPS | 2 +- spec/node-spec.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/DEPS b/DEPS index 35cc92e111..dbb0de8ce7 100644 --- a/DEPS +++ b/DEPS @@ -12,7 +12,7 @@ vars = { 'chromium_version': '73.0.3683.65', 'node_version': - 'fac6d766c143db8db05bb3b0c0871df8f032363c', + '70a78f07b1c4d53f3da462b08cef42a4ff8f949f', 'boto_version': 'f7574aa6cc2c819430c1f05e9a1a1a666ef8169b', 'pyyaml_version': '3.12', diff --git a/spec/node-spec.js b/spec/node-spec.js index fea62025c2..566e906a30 100644 --- a/spec/node-spec.js +++ b/spec/node-spec.js @@ -472,6 +472,21 @@ describe('node feature', () => { const iv = Buffer.from('fedcba9876543210', 'hex') require('crypto').createCipheriv('des-ede-cbc', key, iv) }) + + it('should not crash when getting an ECDH key', () => { + const ecdh = require('crypto').createECDH('prime256v1') + expect(ecdh.generateKeys()).to.be.an.instanceof(Buffer) + expect(ecdh.getPrivateKey()).to.be.an.instanceof(Buffer) + }) + + it('should not crash when generating DH keys or fetching DH fields', () => { + const dh = require('crypto').createDiffieHellman('modp15') + expect(dh.generateKeys()).to.be.an.instanceof(Buffer) + expect(dh.getPublicKey()).to.be.an.instanceof(Buffer) + expect(dh.getPrivateKey()).to.be.an.instanceof(Buffer) + expect(dh.getPrime()).to.be.an.instanceof(Buffer) + expect(dh.getGenerator()).to.be.an.instanceof(Buffer) + }) }) it('includes the electron version in process.versions', () => {