Skip to content

Commit

Permalink
Merge pull request openpgpjs#593 from laurinenas/inform-user-invalid-…
Browse files Browse the repository at this point in the history
…numBits-size

Add a console error when numBits param too low
  • Loading branch information
Bart Butler committed Feb 8, 2018
2 parents d146f79 + b5d10ff commit 1033c48
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/openpgp.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ export function generateKey({ userIds=[], passphrase, numBits=2048, unlocked=fal
userIds = formatUserIds(userIds);
const options = {userIds, passphrase, numBits, unlocked, keyExpirationTime, curve};

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);
}
Expand Down

0 comments on commit 1033c48

Please sign in to comment.