Sean Quixote wrote:Quicky question on cryptography:
So, I know little to nothing about it, though it's one of the higher-ups on my long list of intellectual curiosities. I'd just like to quickly expose an idea that I've always had to scrutiny from people more knowledgeable/intelligent than me:
I'm told that basically every encryption is crackable, all that's required is time and knowhow, and a good algorithm preferably requires lots of both. But what about stacked or nested algorithms? That is, say instead of relying on one single algorithm that you consider a "good" one, why not use MANY? Then, a hacker would be faced with multiple layers of encryption, and hell you could even have an algorithm that assigns a random number to represent all of your algorithms and then yet another to pick another random number that picks which algorithm is the one that's actually hiding your encrypted information. Then, it at least seems to me that, if you have enough separate algorithms at your disposal then the whole prospect of just choosing which algorithm to try to crack, becomes a mathematical clusterfuck of impossibility.
This is the first time I've ever actually written (and thus fully thought) out this idea, and another thought finally ocurrs to me. Either I'm right, and implementing such a system would be a complete mindfuck for hackers to deal with, or just the other way around: it would be a complete mindfuck to code in the first place and therefore impossible to implement.
All block ciphers are basically multiple rounds of a simple cipher. Let's take serpent as an example, it does an XOR, substitution using 4x4 bit s-boxes (essentially 16 element arrays of all integers from 0-15), and then a linear transformation so that each output bit is dependent on each input bit. Do this once, cryptanalysis is trivial. However, after 32 rounds of this it is strong (the best known attack on serpent only breaks 12 rounds, but is still infeasible).
If you were going to combine a bunch of weak algorithms, you should just choose a bunch of algorithms and run them in the same order no matter what. This simplifies cryptanalysis which allows security to be proven against current techniques. Remember, it's only strong against modern techniques if the best cryptanalysts can't break it. Adding too much randomness and no one can analyze the entire cipher and you run into the possibility of weak keys. Also, you need to use a good key stretching algorithm so that each cipher gets a unique subkey.
That said, keep in mind that cryptanalysts will not be cracking each cipher individually, but cracking the cipher as a whole. You can do this just by looking at inputs and outputs. So you do need to put thought into the choice of your algorithms to minimize various characteristics that a cryptanalyst can use.
I think a more interesting technique is to use multiple strong ciphers, alternating stream and block ciphers that have been well studied and have not been broken. Most attacks use known or chosen plaintexts, and if you encrypt with a stream cipher and then a block cipher (even encrypting in ECB mode it is fine if it is already encrypted with a stream cipher) it makes those attacks significantly more difficult.