node-steam-appticket
node-steam-appticket copied to clipboard
Asynchronous error is not handled gracefully
Here's the triggered asynchronous error:
Error: error:1C80006B:Provider routines::wrong final block length
at Decipheriv._flush (node:internal/crypto/cipher:156:29)
at Decipheriv.final [as _final] (node:internal/streams/transform:128:10)
at prefinish (node:internal/streams/writable:916:14)
at finishMaybe (node:internal/streams/writable:930:5)
at Writable.end (node:internal/streams/writable:845:5)
at exports.symmetricDecrypt (/workspace/node_modules/@doctormckay/steam-crypto/index.js:80:10)
at Object.parseEncryptedAppTicket (/workspace/node_modules/steam-appticket/dist/components/parseEncryptedAppTicket.js:21:48)
Wrapping try-catch around AppTicket.parseEncryptedAppTicket does not work because the internal function from crypto does not handle the asychronous method gracefully. I also managed to simulate the error by using the code from SteamCrypto.symmetricDecrypt. Here's the code snippet to trigger the same error:
try {
const key = Buffer.alloc(32, 1);
const input = Buffer.alloc(255, 0xff); // Not multiple of 16
// Simulate the same process with a broken data.
const Crypto = require('crypto');
var aesIv = Crypto.createDecipheriv('aes-256-ecb', key, '');
aesIv.setAutoPadding(false);
aesIv.end(input.slice(0, 16));
var iv = aesIv.read();
var aesData = Crypto.createDecipheriv('aes-256-cbc', key, iv);
aesData.end(input.slice(16));
var plaintext = aesData.read();
} catch (err) {
console.error('Caught OpenSSL error:', err);
}
Based on this doc, aesData.end throws error asynchronously. I believe this has to be rewritten again to work synchronously.