From d1f4ed1a54ca4e873f52ca8145edc53b122f5207 Mon Sep 17 00:00:00 2001 From: Vlad Frolov Date: Sun, 12 Dec 2021 18:32:26 -0300 Subject: [PATCH] fix: avoid getting into an infinite loop when the specified `ephemPrivateKey` is invalid --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index a63218b..98e15ee 100644 --- a/index.js +++ b/index.js @@ -211,7 +211,7 @@ exports.encrypt = function(publicKeyTo, msg, opts) { // There is a very unlikely possibility that it is not a valid key while(!isValidPrivateKey(ephemPrivateKey)) { - ephemPrivateKey = opts.ephemPrivateKey || crypto.randomBytes(32); + ephemPrivateKey = crypto.randomBytes(32); } ephemPublicKey = getPublic(ephemPrivateKey); resolve(derive(ephemPrivateKey, publicKeyTo));