Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong final block length after ugprading Google Chrome 131.0.6778.6 #64

Open
oliverhuynh opened this issue Nov 14, 2024 · 3 comments
Open

Comments

@oliverhuynh
Copy link

Is anyone meet following error or only me?

node:internal/crypto/cipher:199
  const ret = this[kHandle].final();
                            ^

Error: error:1C80006B:Provider routines::wrong final block length
    at Decipheriv.final (node:internal/crypto/cipher:199:29)
    at decrypt (/home/oliver/localprojects/read_cookie/node_modules/chrome-cookies-secure/index.js:41:19)
    at Statement.<anonymous> (/home/oliver/localprojects/read_cookie/node_modules/chrome-cookies-secure/index.js:416:23) {
  library: 'Provider routines',
  reason: 'wrong final block length',
  code: 'ERR_OSSL_WRONG_FINAL_BLOCK_LENGTH'
}

I would be thankful for any hints to get this fixed

@oliverhuynh oliverhuynh changed the title wrong final block length after ugprading Chrome wrong final block length after ugprading Google Chrome 131.0.6778.6 Nov 14, 2024
@elzii
Copy link

elzii commented Nov 15, 2024

+1

Related: Crypto bumped to 0.10. Fixable via similar method to this: https://stackoverflow.com/questions/21292142/decrypting-aes256-with-node-js-returns-wrong-final-block-length

@maelp
Copy link

maelp commented Dec 7, 2024

Same here

@maelp
Copy link

maelp commented Dec 7, 2024

Would this work?

function decrypt(key, encryptedData) {

	var decipher,
		decoded,
		final,
		padding,
		iv = new Buffer.from(new Array(KEYLENGTH + 1).join(' '), 'binary', 'utf-8');

	decipher = crypto.createDecipheriv('aes-128-cbc', key, iv);
	decipher.setAutoPadding(false);

	encryptedData = encryptedData.slice(3);

	decoded = decipher.update(encryptedData, 'binary', 'utf-8');

	final = decipher.final('utf-8');
	final.copy(decoded, decoded.length - 1);

	padding = decoded[decoded.length - 1];
	if (padding) {
		decoded = decoded.slice(0, decoded.length - padding);
	}

	return decoded.toString('utf8');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants