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

Should the cipher-object be created with an IV? #1

Closed
letharion opened this issue Jun 19, 2017 · 5 comments
Closed

Should the cipher-object be created with an IV? #1

letharion opened this issue Jun 19, 2017 · 5 comments
Labels

Comments

@letharion
Copy link

I'll start by saying I'm not a crypto expert by any means.

However, it was pointed out on HN that the encrypt function doesn't use an IV when initializing the cipher object, and the node documention explicitly says

"In line with OpenSSL's recommendation to use pbkdf2 instead of EVP_BytesToKey it is recommended that developers derive a key and IV on their own using crypto.pbkdf2() and to use crypto.createCipheriv() to create the Cipher object."

Since the official docs appears to recommend against crypto.createCipher() I figured it was worth bringing up.

@iangcarroll
Copy link

To be clear: if two ciphertexts use the same IV across ciphertexts with CTR, you basically have no encryption, as C1^C2=P1^P2, where Cs are the ciphertexts and Ps are the plaintexts.

@gradientsky
Copy link

IV doesn't have to be secure, but it has to be securely random on every re-encryption.

@stouset
Copy link

stouset commented Jun 20, 2017

@sgdread Technically for CTR mode, it only needs to be unique and not necessarily random or unpredictable — it's a nonce, not an IV.

@HainaLi
Copy link
Owner

HainaLi commented Jun 21, 2017

This is an important implementation issue! I'm currently traveling and will try to push a fix out asap.

@HainaLi
Copy link
Owner

HainaLi commented Jun 26, 2017

Thanks for your input. The issue is fixed with ef8bc9a.

We also changed the block cipher mode of operation to GCM. The encryption (and decryption code) are moved to utils.js line 19.

@HainaLi HainaLi closed this as completed Jun 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants