From 1d287cd9a95c9290370a21bb2addb0fa7a824c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20Laurin=C4=97nas?= Date: Wed, 11 Oct 2017 18:48:51 +0300 Subject: [PATCH] Add a console error when numBits param too low --- src/openpgp.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/openpgp.js b/src/openpgp.js index 5a2a5e5a..614a5825 100644 --- a/src/openpgp.js +++ b/src/openpgp.js @@ -100,6 +100,10 @@ export function destroyWorker() { export function generateKey({ userIds=[], passphrase, numBits=2048, unlocked=false, keyExpirationTime=0 } = {}) { const options = formatUserIds({ userIds, passphrase, numBits, unlocked, keyExpirationTime }); + if (util.getWebCryptoAll() && numBits < 2048) { + throw new Error('numBits should be 2048 or 4096, found: ' + numBits); + } + if (!util.getWebCryptoAll() && asyncProxy) { // use web worker if web crypto apis are not supported return asyncProxy.delegate('generateKey', options); }