# Required key size for an ideal cipher with a 32 bit block size

For an ideal block cipher, what size key would be required when the cipher has a 32-bit block size?

• Well, of course a 32-bit block size cipher... Or do you talk about the key? Ciphers with this small block size are only secure in a very limited way. If you don't keep this in mind, even the longest key would not help you. 128 bit should be enough for the key, but it's hard to give a firm answer without more informations. – Nova Apr 2 '15 at 19:05
• @Nova I think the title was misleading, the question did indeed mention the key. asdfhjk, please re-read your question before posting. – Maarten Bodewes Apr 2 '15 at 19:21
• I suspect this is a homework question aimed at establishing why we can't construct an ideal cipher for even modest block sizes. asdfhjk: For a cipher to be ideal, you need one key for each possible permutation. So how many strings are in the set {0, 1}^32? How many permutations are there on a set of this size? – Seth Apr 3 '15 at 22:53

The size of the key depends on the security level you want, it is not possible to say "you need exactly $n$ key bits if you have a block size of $m$ bits".
Let's assume that for an ideal cipher, a block size of 32 bits means $2^{32}$ possible input values which can be permuted in $(2^{32})!$ ways. That means you would have at most $\log_2(2^{32}!)$ key bits, to avoid equivalent keys. This is a lot, and in practice only a (very!) tiny fraction of that amount of bits would be used. In fact, one could argue that this upper bound on the key size is so ridiculously large that it's almost meaningless.
• $\log_2(2^{32}!)\approx131,242,625,471$ bit. Storing that key for would require slightly less than 16GiB. It is quite easy to make a program implementing such a theoretically perfect 32-bit block cipher; the challenging thing is to make it bearably fast. – fgrieu Apr 3 '15 at 7:06