fix: crash in crypto.createDiffieHellman (#27674)

This commit is contained in:
Shelley Vohr
2021-02-10 22:10:40 +00:00
committed by GitHub
parent 87064e5b5e
commit 9063e84b7c
2 changed files with 45 additions and 27 deletions

View File

@@ -303,6 +303,20 @@ describe('node feature', () => {
expect(cipherText).to.equal(result);
}
});
it('does not crash when using crypto.diffieHellman() constructors', () => {
const crypto = require('crypto');
crypto.createDiffieHellman('abc');
crypto.createDiffieHellman('abc', 2);
// Needed to test specific DiffieHellman ctors.
// eslint-disable-next-line no-octal
crypto.createDiffieHellman('abc', Buffer.from([02]));
// eslint-disable-next-line no-octal
crypto.createDiffieHellman('abc', '123');
});
});
describe('process.stdout', () => {