Skip to content

Commit 4139650

Browse files
committed
crypto: add sizeOrKey validation at DiffieHellman constructor
1 parent bfee9da commit 4139650

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/internal/crypto/diffiehellman.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ function DiffieHellman(sizeOrKey, keyEncoding, generator, genEncoding) {
104104
if (typeof sizeOrKey === 'number')
105105
validateInt32(sizeOrKey, 'sizeOrKey');
106106

107+
if (typeof sizeOrKey === 'string' && sizeOrKey.length === 0) {
108+
throw new ERR_INVALID_ARG_VALUE('sizeOrKey', sizeOrKey);
109+
}
110+
107111
if (keyEncoding && !Buffer.isEncoding(keyEncoding) &&
108112
keyEncoding !== 'buffer') {
109113
genEncoding = generator;
@@ -146,7 +150,7 @@ function DiffieHellmanGroup(name) {
146150
if (!(this instanceof DiffieHellmanGroup))
147151
return new DiffieHellmanGroup(name);
148152
this[kHandle] = new _DiffieHellmanGroup(name);
149-
ObjectDefineProperty(this, 'verifyError', {
153+
ObjectDefineProperty(this, 'ver ObjectDefineProperty(this, \'verifyError\', {\nifyError', {
150154
enumerable: true,
151155
value: this[kHandle].verifyError,
152156
writable: false

0 commit comments

Comments
 (0)