Merge pull request #593 from laurinenas/inform-user-invalid-numBits-size

Add a console error when numBits param too low
This commit is contained in:
Bart Butler 2018-02-08 10:51:21 -08:00 committed by GitHub
commit c2a7ea2a20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
}