Cryptex icon indicating copy to clipboard operation
Cryptex copied to clipboard

Fix issue with AES 256 breaking when running in Electron

Open superical opened this issue 4 years ago • 4 comments

The name used for the AES 256 algorithm will break Cryptex when used in Electron 73. It seems like the fix to this issue is by changing the algorithm name to aes-256-cbc for the crypto package to work. Otherwise, an "Unknown Cipher" error message will be thrown.

This PR attempts to detect whether the environment is Electron or not. If it is, we will use aes-256-cbc as the algorithm name. Otherwise, we will use aes256 in a regular Node environment.

superical avatar Oct 31 '19 06:10 superical

@TomFrost It would be great if I could have this PR reviewed and merged because this will help many Electron projects to continue using Cryptex. Thanks!

superical avatar Oct 31 '19 06:10 superical

Hi @superical, thanks for this! It looks like the only thing necessary to fix the build is npm run format. I can run that when I'm home, but if you'd like to add that then I can merge and release now.

TomFrost avatar Nov 04 '19 15:11 TomFrost

Actually, circling back, is the issue that electron doesn't include/blocks the aes256 cipher? I'm curious why that doesn't work if Node, ultimately, is what's supplying the ciphers.

If possible, it might make sense to use https://nodejs.org/api/crypto.html#crypto_crypto_getciphers to make the determination, rather than sniffing for signs of electron.

TomFrost avatar Nov 04 '19 15:11 TomFrost

@TomFrost I agree that it makes more sense to use that. I will check on that and probably update the PR again very soon.

superical avatar Nov 05 '19 12:11 superical