diff --git a/src/crypto/cmac.js b/src/crypto/cmac.js index 060b2efb..de0b9146 100644 --- a/src/crypto/cmac.js +++ b/src/crypto/cmac.js @@ -9,7 +9,7 @@ import { AES_CBC } from 'asmcrypto.js/src/aes/cbc/exports'; import util from '../util'; -const webCrypto = util.getWebCryptoAll(); +const webCrypto = util.getWebCrypto(); const nodeCrypto = util.getNodeCrypto(); const Buffer = util.getNodeBuffer(); @@ -75,7 +75,7 @@ export default async function CMAC(key) { } async function CBC(key) { - if (util.getWebCryptoAll() && key.length !== 24) { // WebCrypto (no 192 bit support) see: https://www.chromium.org/blink/webcrypto#TOC-AES-support + if (util.getWebCrypto() && key.length !== 24) { // WebCrypto (no 192 bit support) see: https://www.chromium.org/blink/webcrypto#TOC-AES-support key = await webCrypto.importKey('raw', key, { name: 'AES-CBC', length: key.length * 8 }, false, ['encrypt']); return async function(pt) { const ct = await webCrypto.encrypt({ name: 'AES-CBC', iv: zeroBlock, length: blockLength * 8 }, key, pt); diff --git a/src/crypto/eax.js b/src/crypto/eax.js index c5bc9ea2..d2b578a1 100644 --- a/src/crypto/eax.js +++ b/src/crypto/eax.js @@ -28,7 +28,7 @@ import { AES_CTR } from 'asmcrypto.js/src/aes/ctr/exports'; import CMAC from './cmac'; import util from '../util'; -const webCrypto = util.getWebCryptoAll(); +const webCrypto = util.getWebCrypto(); const nodeCrypto = util.getNodeCrypto(); const Buffer = util.getNodeBuffer(); @@ -49,7 +49,7 @@ async function OMAC(key) { } async function CTR(key) { - if (util.getWebCryptoAll() && key.length !== 24) { // WebCrypto (no 192 bit support) see: https://www.chromium.org/blink/webcrypto#TOC-AES-support + if (util.getWebCrypto() && key.length !== 24) { // WebCrypto (no 192 bit support) see: https://www.chromium.org/blink/webcrypto#TOC-AES-support key = await webCrypto.importKey('raw', key, { name: 'AES-CTR', length: key.length * 8 }, false, ['encrypt']); return async function(pt, iv) { const ct = await webCrypto.encrypt({ name: 'AES-CTR', counter: iv, length: blockLength * 8 }, key, pt); diff --git a/src/openpgp.js b/src/openpgp.js index f18ba753..ab3579d2 100644 --- a/src/openpgp.js +++ b/src/openpgp.js @@ -585,13 +585,13 @@ function onError(message, error) { /** * Check for native AEAD support and configuration by the user. Only * browsers that implement the current WebCrypto specification support - * native GCM. Native EAX is built on CTR and CBC, which all browsers - * support. OCB and CFB are not natively supported. + * native GCM. Native EAX is built on CTR and CBC, which current + * browsers support. OCB and CFB are not natively supported. * @returns {Boolean} If authenticated encryption should be used */ function nativeAEAD() { return config.aead_protect && ( ((config.aead_protect_version !== 4 || config.aead_mode === enums.aead.experimental_gcm) && util.getWebCrypto()) || - (config.aead_protect_version === 4 && config.aead_mode === enums.aead.eax && util.getWebCryptoAll()) + (config.aead_protect_version === 4 && config.aead_mode === enums.aead.eax && util.getWebCrypto()) ); } diff --git a/test/general/openpgp.js b/test/general/openpgp.js index c0974afe..4eada9bd 100644 --- a/test/general/openpgp.js +++ b/test/general/openpgp.js @@ -720,7 +720,7 @@ describe('OpenPGP.js public api tests', function() { }); tryTests('EAX mode (native)', tests, { - if: openpgp.util.getWebCryptoAll() || openpgp.util.getNodeCrypto(), + if: openpgp.util.getWebCrypto() || openpgp.util.getNodeCrypto(), beforeEach: function() { openpgp.config.use_native = true; openpgp.config.aead_protect = true; @@ -733,7 +733,7 @@ describe('OpenPGP.js public api tests', function() { }); tryTests('EAX mode (small chunk size)', tests, { - if: openpgp.util.getWebCryptoAll() || openpgp.util.getNodeCrypto(), + if: openpgp.util.getWebCrypto() || openpgp.util.getNodeCrypto(), beforeEach: function() { openpgp.config.use_native = true; openpgp.config.aead_protect = true;