crypto-utils / keygrip

Key signing and verification for rotated credentials
MIT License
931 stars 49 forks source link

Unsafe encryption & decryption #27

Closed veeti closed 6 years ago

veeti commented 8 years ago

Using a cryptographically random and unique initialization vector for each message is absolutely essential. The library should not let users encrypt without one: preferably, don't let the user choose at all and generate a new IV for them every time.

In addition, encrypted messages are not authenticated at all.

The encryption & decryption scheme provided by this library is very dangerous and should not be released in this state. Please take a look at something like Fernet on how to implement this securely, and only provide a higher level API to users.

dougwilson commented 8 years ago

Hi @veeti, I 100% agree with your statement, thus why this module has not been published to npm yet. This module was adopted by crypto-utils to give it life, but there hasn't been a lot of time. I think it would be most helpful if you could provide pull requests to fix the behavior, or at least outline the specific changes you want. This issue doesn't really help explain any more than how I already feel about the current code, so I'm not sure what you are specifically looking for.

You'll find the existing published version does not have any encypt/decrypt functionality.

veeti commented 8 years ago

Hey @dougwilson, I can certainly work on a pull request. Let's make sure we're on the same page. Here's what I would do:

Let me know what you think.

jonathanong commented 8 years ago

preferably, don't let the user choose at all and generate a new IV for them every time.

AES-256-CBC is a sane default as long as it is properly used. (AES-GCM would be ideal, but I don't think older versions of OpenSSL or Node support it).

these sound good to me. i was struggling with understanding how that all works which is why i was looking for reviewers. making them optional also made the API more convoluted. few options is better.

jonathanong commented 8 years ago

@veeti would you like to make a PR?

jonathanong commented 8 years ago

https://github.com/csquared/fernet.js looks good to me, except it has all this fluff for browser usage that wouldn't be applicable to us and has all these global options that are no bueno

veeti commented 8 years ago

Sorry, I forgot all about this. I could work on a PR soon.

frederikhors commented 6 years ago

Any news on this after 2+ years?

dougwilson commented 6 years ago

The encryption and decryption was never published to npm and does not exist in the code base.