Repository navigation
Conversation
* Stop using the user's keys directly for signing and encryption. Instead, derive three different contextual subkeys: one for signing the user's payloads, one for encrypting the user's payloads and one for authenticating the resulting ciphertexts. PBKDF2 is used, as it is available in the standard library. A static salt and low iteration count are sufficient, as the user is expected to bring their own securely generated key(s). Also added a one-line Node command for generating secure keys to the README. * Completely rewrote the previous encryption logic, which was completely broken and unsafe. 256-bit AES is now used in CBC mode with PKCS#7 padding. Random initialization vectors are generated. The resulting IV and ciphertext are authenticated using HMAC-SHA256. * Removed the user API for changing the used cipher or hash. This is more effort than it is worth and makes implementation more difficult. The defaults are sufficient choices for anyone. * Also overhauled the test suite, as it was previously order-dependent and individual tests couldn't be run on their own.
|
Awesome, @veeti, I really appreciate it! It is a large-ish PR, so will take a bit to go over, but will definitely do! One thing you may want to consider as well is what will the upgrade path from 1.x to this new 2.x be, just in case you haven't thought much about it, while I get to looking this over. |
|
@dougwilson What can I do to help push this PR along and release a 2.0 version? I'd love to use this module, but in the 1.0 state I'm afraid I'd end up just writing my own wrappers when a OSS project would be better. |
d97219e to
bbc81ae
Compare
|
Hi, this functionality looks ideal for something I'm working on. How can I help out to get this release-ready? |
|
Resolve merge conflicts, pass the CI, and break apart into smaller PRs that can more easily be reviewed and discussed. The OP never responded with anything, so I'm just closing this as stale. Someone is welcome to take up the mantle on the three points above. |
I promised to submit a PR ages ago, but here it finally goes. This is a first shot at it so any feedback would be appreciated.
Stop using the user's keys directly for signing and encryption. Instead, derive three different contextual subkeys: one for signing the user's payloads, one for encrypting the user's payloads and one for authenticating the resulting ciphertexts.
PBKDF2 is used, as it is available in the standard library. A static salt and low iteration count are sufficient, as the user is expected to bring their own securely generated key(s).
Also added a one-line Node command for generating secure keys to the README.
Completely rewrote the previous encryption logic, which was completely broken and unsafe. 256-bit AES is now used in CBC mode with PKCS#7 padding. Random initialization vectors are generated. The resulting IV and ciphertext are authenticated using HMAC-SHA256.
Removed the user API for changing the used cipher or hash. This is more effort than it is worth and makes implementation more difficult. The defaults are sufficient choices for anyone.
Also overhauled the test suite, as it was previously order-dependent and individual tests couldn't be run on their own.
Some considerations: