Fix: use worker for CFB w/ webcrypto support
This commit is contained in:
parent
c8569e0cd5
commit
f4fc274f14
|
@ -158,7 +158,7 @@ export function decryptKey({ privateKey, passphrase }) {
|
||||||
export function encrypt({ data, publicKeys, privateKeys, passwords, filename, armor=true }) {
|
export function encrypt({ data, publicKeys, privateKeys, passwords, filename, armor=true }) {
|
||||||
checkData(data); publicKeys = toArray(publicKeys); privateKeys = toArray(privateKeys); passwords = toArray(passwords);
|
checkData(data); publicKeys = toArray(publicKeys); privateKeys = toArray(privateKeys); passwords = toArray(passwords);
|
||||||
|
|
||||||
if (!util.getWebCrypto() && asyncProxy) { // use web worker if web crypto apis are not supported
|
if (!useAEAD() && asyncProxy) { // use web worker if web crypto apis are not supported
|
||||||
return asyncProxy.delegate('encrypt', { data, publicKeys, privateKeys, passwords, filename, armor });
|
return asyncProxy.delegate('encrypt', { data, publicKeys, privateKeys, passwords, filename, armor });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ export function encrypt({ data, publicKeys, privateKeys, passwords, filename, ar
|
||||||
export function decrypt({ message, privateKey, publicKeys, sessionKey, password, format='utf8' }) {
|
export function decrypt({ message, privateKey, publicKeys, sessionKey, password, format='utf8' }) {
|
||||||
checkMessage(message); publicKeys = toArray(publicKeys);
|
checkMessage(message); publicKeys = toArray(publicKeys);
|
||||||
|
|
||||||
if (!util.getWebCrypto() && asyncProxy) { // use web worker if web crypto apis are not supported
|
if (!useAEAD() && asyncProxy) { // use web worker if web crypto apis are not supported
|
||||||
return asyncProxy.delegate('decrypt', { message, privateKey, publicKeys, sessionKey, password, format });
|
return asyncProxy.delegate('decrypt', { message, privateKey, publicKeys, sessionKey, password, format });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,3 +473,12 @@ function onError(message, error) {
|
||||||
// rethrow new high level error for api users
|
// rethrow new high level error for api users
|
||||||
throw new Error(message + ': ' + error.message);
|
throw new Error(message + ': ' + error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for AES-GCM support and configuration by the user. Note that only browsers that
|
||||||
|
* implement the current WebCrypto specification support AES-GCM.
|
||||||
|
* @return {Boolean} If authenticated encryption should be used
|
||||||
|
*/
|
||||||
|
function useAEAD() {
|
||||||
|
return util.getWebCrypto() && config.aead_protect;
|
||||||
|
}
|
|
@ -450,7 +450,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get native Web Cryptography api, only the current versioon of the spec.
|
* Get native Web Cryptography api, only the current version of the spec.
|
||||||
* The default configuration is to use the api when available. But it can
|
* The default configuration is to use the api when available. But it can
|
||||||
* be deactivated with config.useNative
|
* be deactivated with config.useNative
|
||||||
* @return {Object} The SubtleCrypto api or 'undefined'
|
* @return {Object} The SubtleCrypto api or 'undefined'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user