News for hackers. Stuff that matters.
Re:Rolling Your Own Crypto by pps43 on Tuesday December 20, 2016 @02:27PM (#13223060)
> Encrypt(data,key) and Decrypt(data,key) and be done.

That's the easy part. You can find a library that does exactly that, and only that. Will probably be just one file, not even a library [1].

But then you'll also need padding, MAC, signatures, key distribution, web of trust, etc.

[1] Example: https://github.com/dimview/speck_cipher

Re:Rolling Your Own Crypto by lvh on Tuesday December 20, 2016 @03:46PM (#13223752)
The linked repo is not a solution, single-file or otherwise. Speck is not only a weird and unusual block cipher to pick, it is more importantly only a block cipher. It does not let you encrypt more than a block size at a time, and it does not give you authentication! Both of those things are anything but trivial.

Furthermore, Speck has a variable block size between 32 and 128 bits. If you pick wrong, safe-looking things like CTR+HMAC-256 become unsafe (it's not hard to overflow a 32-bit counter).

Re:Rolling Your Own Crypto by pps43 on Tuesday December 20, 2016 @03:59PM (#13223905)
Well, it does Encrypt() and Decrypt(), which is what was asked. And it's not particularly difficult to pick 128 bit block size (after all, bigger is better).

The problem is, it's not nearly enough to just do Encrypt() and Decrypt(). Only when you see that, the benefits of a real crypto library NaCL become apparent.

Re:Rolling Your Own Crypto by lvh on Tuesday December 20, 2016 @04:14PM (#13224070)
It has things called "encrypt" and "decrypt", but it does not do anything a programmer could reasonably consider "encrypt" and "decrypt". If you don't authenticate your ciphertext, there's a decent chance your ciphertext won't remain secret. It doesn't give you an option for randomized encryption. Compare with Fernet: you get the same API, but you get to encrypt any message, and it's securely authenticated such that it stays secret. (secretbox is fine too; but it makes you pick a nonce).

Additionally, "bigger is better" is not a reasonable way to pick primitives. Defaults matter. Perf matters. From experience and stats, people pick according those two vectors a lot more often than they pick along the "bigger is better" axis. When's the last time you saw an RSA-16384 signature? AES-256 might have twice as big a number as AES-128, but how much faith do you have in that extended key expansion? You use AES-128 a lot more often than you use AES-256, and you definitely use RSA-2048 a lot more often than RSA-16384.

I don't think you can responsibly insist that this was an answer to the question. It is not a secure way to encrypt messages.

Re:Rolling Your Own Crypto by PeterisP on Tuesday December 20, 2016 @09:49PM (#13226441)
Well, that's kind of the point - the default Encrypt(data,key) should also implement padding, combine blocks for arbitrary length messages, and include MAC; so that it's reasonably secure out of the box with the default settings. Key distribution is a different issue, but doing the abovementioned things would be sufficient to ensure that you can just run Encrypt/Decrypt(data, key) and expect most of the common tampering attacks to be impossible.
Re:Rolling Your Own Crypto by tptacek on Tuesday December 20, 2016 @04:36PM (#13224277)
Why would you suggest someone investigating crypto for the first time use the NSA's lightweight cipher? That's a really weird recommendation.
Re:Rolling Your Own Crypto by pps43 on Tuesday December 20, 2016 @04:45PM (#13224375)
The point I was trying to make is that complexity is not in encrypt() and decrypt(). Those things can be very simple, yet cryptographically strong.

Complexity begins when you try doing something more involved than just symmetric block encryption.

Re:Rolling Your Own Crypto by tptacek on Tuesday December 20, 2016 @05:04PM (#13224565)
If by "symmetric block encryption" you mean "use the block permutation of the cipher directly", then nobody ever does that; the people who make the mistake of using the cipher's "Encrypt" and "Decrypt" are the ones who end up discovering that the default mode of a cipher is ECB.

I think I sort of see your point, but SPECK is a weird recommendation.

Re:Rolling Your Own Crypto by 77pt77 on Tuesday December 20, 2016 @05:03PM (#13224556)
Forget that.

How is the IV stored for example.

Re:Rolling Your Own Crypto by Rebelgecko on Tuesday December 20, 2016 @07:14PM (#13225628)
Block ciphers in ECB mode don't use an IV. If you were going to use this random crypto code on github (bad idea for various reasons), you'd want to wrap it in GCM or something similar (then you get to deal with IVs, tags, etc). I suppose part of the issue that people don't want to deal with (or don't see the need for) the added complexity of IVs and authentication.
Re:Rolling Your Own Crypto by tptacek on Tuesday December 20, 2016 @11:05PM (#13226707)
You can't just "wrap" SPECK in GCM-mode! In many of its configurations, it has a block too short to safely run GCM in.

Don't roll your own crypto.

Re:Rolling Your Own Crypto by Rebelgecko on Wednesday December 28, 2016 @10:18PM (#13275431)
By many configurations, do you mean with a block size ≠ 128 bits? I should've specified that when I posted (notwithstanding issues with rolling your own crypto)
Re:Rolling Your Own Crypto by WillSlim95 on Wednesday December 21, 2016 @12:11AM (#13226944)
Umm this is a bit off-topic , but I don't know how else to reach out. But I have been not able to access Star Fighters due to a certificate failure, could you please check it out or point me towards whom to contact,
Re:Rolling Your Own Crypto by tom_b on Wednesday December 21, 2016 @01:40PM (#13231500)
The founders wound it down. Thomas is threatening to actually do a write-up about the experience sometime (poke, poke).
Re:Rolling Your Own Crypto by tptacek on Wednesday December 21, 2016 @02:00PM (#13231659)
I really am doing it (I also really am publishing a bunch more challenges). I just had dinner with Patrick last night and talked about it a bit. I've got a lot on my plate at the moment, though.
Re:Rolling Your Own Crypto by tom_b on Wednesday December 21, 2016 @02:36PM (#13231947)
Cool - thanks to all three of you for Starfighter. I'm sad it didn't work out as envisioned. Looking forward to the eventual write-up when it fits into your time.
Re:Rolling Your Own Crypto by tptacek on Wednesday December 21, 2016 @03:32PM (#13232376)
We will for sure be taking another whack at this down the road, and in the meantime I'm pretty psyched to apply the same ideas again to a hiring practice I actually own (we'll surely be doing the same thing at Latacora); at least I'll get another finger-wagging blog post out of it!
Re:Rolling Your Own Crypto by pps43 on Tuesday December 20, 2016 @07:37PM (#13225772)
API is Encrypt(data,key) and Decrypt(data,key). There's no IV. It's just a block cipher.

Once you start adding things like CTR mode, MAC, etc. the API is no longer as simple.