-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Open
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.cryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.
Description
This also affects Decipher methods.
Here's an example:
const { createCipheriv, randomBytes } = require('crypto');
const cipher = createCipheriv('aes-256-cbc', randomBytes(32), randomBytes(16));
cipher.update('test', 'utf-8', 'bad');Gives an internal assertion:
Error [ERR_INTERNAL_ASSERTION]: Cannot change encoding
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
final has the same issue:
const { createCipheriv, randomBytes } = require('crypto');
const cipher = createCipheriv('aes-256-cbc', randomBytes(32), randomBytes(16));
cipher.update('test', 'utf-8', 'utf-8');
cipher.final('bad');Other issue:
const { createCipheriv, randomBytes } = require('crypto');
const cipher = createCipheriv('aes-256-cbc', randomBytes(32), randomBytes(16));
let result = cipher.update('test', 'bad', 'hex');
result += cipher.final('hex');
console.log(result);Gives no error at all for the wrong input encoding.
@nodejs/crypto
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.cryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.