diff options
Diffstat (limited to 'test/crypto/crypto.js')
-rw-r--r-- | test/crypto/crypto.js | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/test/crypto/crypto.js b/test/crypto/crypto.js index 5668ead4..baeb759f 100644 --- a/test/crypto/crypto.js +++ b/test/crypto/crypto.js @@ -233,17 +233,18 @@ module.exports = () => describe('API functional testing', function() { }); describe('Encrypt and decrypt', function () { - let symmAlgos = Object.keys(openpgp.enums.symmetric); - symmAlgos = symmAlgos.filter(function(algo) { - return algo !== 'idea' && algo !== 'plaintext'; - }); + const symmAlgoNames = Object.keys(openpgp.enums.symmetric).filter( + algo => algo !== 'idea' && algo !== 'plaintext' + ); async function testCFB(plaintext) { - await Promise.all(symmAlgos.map(async function(algo) { + await Promise.all(symmAlgoNames.map(async function(algoName) { + const algo = openpgp.enums.write(openpgp.enums.symmetric, algoName); + const { blockSize } = crypto.getCipher(algo); const symmKey = await crypto.generateSessionKey(algo); - const IV = new Uint8Array(crypto.cipher[algo].blockSize); + const IV = new Uint8Array(blockSize); const symmencData = await crypto.mode.cfb.encrypt(algo, symmKey, util.stringToUint8Array(plaintext), IV, openpgp.config); - const text = util.uint8ArrayToString(await crypto.mode.cfb.decrypt(algo, symmKey, symmencData, new Uint8Array(crypto.cipher[algo].blockSize))); + const text = util.uint8ArrayToString(await crypto.mode.cfb.decrypt(algo, symmKey, symmencData, new Uint8Array(blockSize))); expect(text).to.equal(plaintext); })); } @@ -255,7 +256,7 @@ module.exports = () => describe('API functional testing', function() { }); it('Asymmetric using RSA with eme_pkcs1 padding', async function () { - const symmKey = await crypto.generateSessionKey('aes256'); + const symmKey = await crypto.generateSessionKey(openpgp.enums.symmetric.aes256); return crypto.publicKeyEncrypt(algoRSA, RSAPublicParams, symmKey).then(RSAEncryptedData => { return crypto.publicKeyDecrypt( algoRSA, RSAPublicParams, RSAPrivateParams, RSAEncryptedData @@ -266,7 +267,7 @@ module.exports = () => describe('API functional testing', function() { }); it('Asymmetric using Elgamal with eme_pkcs1 padding', async function () { - const symmKey = await crypto.generateSessionKey('aes256'); + const symmKey = await crypto.generateSessionKey(openpgp.enums.symmetric.aes256); return crypto.publicKeyEncrypt(algoElGamal, elGamalPublicParams, symmKey).then(ElgamalEncryptedData => { return crypto.publicKeyDecrypt( algoElGamal, elGamalPublicParams, elGamalPrivateParams, ElgamalEncryptedData |