Open
Description
Version
18.1.0
Platform
Microsoft Windows NT 10.0.19044.0 x64
Subsystem
crypto
What steps will reproduce the bug?
Run the following code:
import crypto from 'crypto';
let cipher = crypto.createCipheriv('AES-256-CBC-HMAC-SHA256', crypto.randomBytes(32), crypto.randomBytes(16));
let encrypted = cipher.update('My beautiful data', 'utf8', 'hex');
encrypted += cipher.final('hex');
How often does it reproduce? Is there a required condition?
This only reproduces when using:
- aes-128-cbc-hmac-sha1
- aes-128-cbc-hmac-sha256
- aes-256-cbc-hmac-sha1
- aes-256-cbc-hmac-sha256
What is the expected behavior?
On Node 17.1.0:
d8d390a8554e2ca579a1946447c8144509495f521458996db711dd6c9595080d
What do you see instead?
node:internal/crypto/cipher:180
const ret = this[kHandle].update(data, inputEncoding);
^
Error: Trying to add data in unsupported state
at Cipheriv.update (node:internal/crypto/cipher:180:29)
at file:///C:/Users/myuser/Documents/GitHub/something/test/playground.js:22:24
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:409:24)
at async loadESM (node:internal/process/esm_loader:85:5)
at async handleMainPromise (node:internal/modules/run_main:61:12)
Additional information
It seems to work on LTS and above (tested until 17.1.0), but not on V18.