4 ms·
> 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 jus
by pps43 10y ago
> 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 https://github.com/dimview/speck_cipher
- PeterisP 10y agoWell, 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.
- lvh 10y agoThe 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).
- pps43 10y agoWell, 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.
- lvh 10y agoIt 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.
- tptacek 10y agoWhy would you suggest someone investigating crypto for the first time use the NSA's lightweight cipher? That's a really weird recommendation.
- pps43 10y agoThe 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.
- tptacek 10y agoIf 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.
- 77pt77 10y agoForget that. How is the IV stored for example.
- Rebelgecko 10y agoBlock 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.
- tptacek 10y agoYou 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.
- WillSlim95 10y agoUmm 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,
- tom_b 10y agoThe founders wound it down. Thomas is threatening to actually do a write-up about the experience sometime (poke, poke).
- tptacek 10y agoI 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.