diff options
Diffstat (limited to 'test/parallel/test-crypto-cipher-decipher.js')
-rw-r--r-- | test/parallel/test-crypto-cipher-decipher.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/parallel/test-crypto-cipher-decipher.js b/test/parallel/test-crypto-cipher-decipher.js index 8c9daa16e8..0a140cf9f4 100644 --- a/test/parallel/test-crypto-cipher-decipher.js +++ b/test/parallel/test-crypto-cipher-decipher.js @@ -113,3 +113,29 @@ testCipher2(Buffer.from('0123456789abcdef')); c.update('update', 'utf-8'); c.final('utf8'); // Should not throw. } + +// Regression tests for https://github.com/nodejs/node/issues/8236. +{ + const key = '0123456789abcdef'; + const plaintext = 'Top secret!!!'; + const c = crypto.createCipher('aes192', key); + var ciph = c.update(plaintext, 'utf16le', 'base64'); + ciph += c.final('base64'); + + var decipher = crypto.createDecipher('aes192', key); + + var txt; + assert.doesNotThrow(() => txt = decipher.update(ciph, 'base64', 'ucs2')); + assert.doesNotThrow(() => txt += decipher.final('ucs2')); + assert.strictEqual(txt, plaintext, 'decrypted result in ucs2'); + + decipher = crypto.createDecipher('aes192', key); + assert.doesNotThrow(() => txt = decipher.update(ciph, 'base64', 'ucs-2')); + assert.doesNotThrow(() => txt += decipher.final('ucs-2')); + assert.strictEqual(txt, plaintext, 'decrypted result in ucs-2'); + + decipher = crypto.createDecipher('aes192', key); + assert.doesNotThrow(() => txt = decipher.update(ciph, 'base64', 'utf-16le')); + assert.doesNotThrow(() => txt += decipher.final('utf-16le')); + assert.strictEqual(txt, plaintext, 'decrypted result in utf-16le'); +} |