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

Replace deprecated crypto methods #72

Closed
wants to merge 1 commit into from
Closed

Replace deprecated crypto methods #72

wants to merge 1 commit into from

Conversation

MattMattV
Copy link

I wanted to fix sindresorhus/electron-store#67, but the fix had to be done here.

Since the README states :

Note that this is not intended for security purposes, since the encryption key would be easily found inside a plain-text Node.js app.

I permitted myself to use a non-random IV.

Test results Node 11.15.0

Test results on Node 11.15.0

Node 10.15.3

Test results on Node 10.15.3

Node 8.16.0

Test results on Node 8.16.0

Also I would be very grateful if you could indicate me the next step so I can help you resolve sindresorhus/electron-store#67

Thanks in advance !

@@ -211,7 +211,10 @@ class Conf {

if (this.encryptionKey) {
try {
const decipher = crypto.createDecipher(encryptionAlgorithm, this.encryptionKey);
const iv = Buffer.alloc(16);
const key = crypto.pbkdf2Sync(this.encryptionKey, iv.toString(), 10000, 32, 'sha512');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will break existing uses where the encryptionKey is not using pbkdf2Sync.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to my tries and by nodejs/node#16746 it may impossible to make this upgrade without any harm since key patrameter in createCipherkv method require fixed length, so any previous key that does not match createCipherIv criteria will produce an error 😕

@sindresorhus sindresorhus changed the title refactor: replacing deprecated crypto methods Replace deprecated crypto methods May 30, 2019
@sindresorhus
Copy link
Owner

Closing this in favor of #76

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

Successfully merging this pull request may close these issues.

Replace deprecated crypto.createDecipher usage with crypto.createDecipheriv
2 participants