3

Firstly I'm not a crypto expert, however I know how to use algorithms that other people have defined before in practical usages, that is, as long as they live up to their promises.

The thing is that I need certain utilities:

  1. Generate Public/Private Key pair of x length, get them as binary; and be able to process content with it.
  2. Some hashing algorithm that consumes a lot of memory and takes its time; I don't need speed, I need safety. (I'm pretty sure they'll use dumb passwords)
  3. An symmetric encryption algorithm that generates ciphertext based on a password (hash) that must be quite strong as well.

My current answers have been:

  1. OpenSSL RSA algorithms.
  2. Scrypt (thinking about changing to argon2 due to great documentation and wrappers)
  3. OpenSSL AES CBC

But then you go here and there on the internet and they say that, scrypt is broken, use bcrypt, no argon2 https://github.com/P-H-C/phc-winner-argon2 is the new thing, OpenSSL has security bugs, better use LibreSSL, no use libsodium. etc... etc...

So what'd the best options be?... I need to secure highly sensitive data.

Also I'll probably be using Node.js wrappers because I need results fast, as I need to make a demonstration.

  • there is no best, and security is an ongoing battle, but your current choices are fine. – dandavis Jun 25 '16 at 6:56
  • "and they say that, scrypt is broken" where does it say that? – Maarten Bodewes Jun 28 '16 at 17:38
  • @MaartenBodewes blog.ircmaxell.com/2014/03/why-i-dont-recommend-scrypt.html you can find articles everywhere about everything against/pro... just googling. :) since I'm no crypto expert I can't judge who is right and who isn't. – Onza Jun 29 '16 at 9:15
  • @Onza I generally take IRCmaxell's opinions seriously. Although I cannot directly verify his claims I presume they are correct. The underlying PBKDF2 function isn't void of issues either. There is a good reason why there was a password hashing competition... – Maarten Bodewes Jun 29 '16 at 9:46
  • @MaartenBodewes there are a lot of claims of the same caliber out there on the internet. So how does argon2 compare? – Onza Jun 29 '16 at 14:29
3

One of the biggest issues that you face is not the algorithms you choose, but how you implement using them. There are many good algorithms for various purposes, and virtually any of them, improperly applied, can result in a disastrously broken cryptosystem.

This is one of the reasons people offer advice like "use libsodium" because libraries like libsodium abstract most of the decisions that you might get wrong.

However, to answer the question that you asked specifically, regarding algorithms:

  1. Asymmetric encryption: User RSA-OAEP.

  2. Password hashing algorithm or KBKDF for symmetric encryption: Use bcrypt.

  3. Symmetric encryption: An AEAD cipher. I know OpenSSL has AES-GCM. You might also find ChaCha20-Poly1305. Or you could use libsodium.

One specific point to reiterate about item 3...Don't use the password directly as the key. Use bcrypt (or another suitable KBKDF) to generate a proper key, in a properly slow manner. You may already know this, but it's worth pointing out for future readers.

Another critical point - Even with all of the best algorithms, and the proper implementation, key management is a crucial component of the system. If you don't think hard enough about secure key storage and management, everything else could be for naught.

  • I'm still not convinced about bcrypt because it's too fast and my users "are going to choose dumb passwords" that's certain, because this system is not an standard password system where I have to do a quick check on a db but rather they download a file and try to decrypt it I need at least to take at least 4/5 seconds on a standard device. But thanks for advice :D – Onza Aug 10 '16 at 8:09
  • The bcrypt has adjustable work factor which really is number of rounds exponent (that is, if work factor is 11, the number of rounds is 2^11 or 2048). Push that to around 13-15 and bcrypt will be slow enough no matter which CPU you have. – Mikko Rantalainen Jul 6 '18 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.