Reputation:
I am working on some cryptology revision exercises for university (in preparation for an exam) and this question has me puzzled:
Most block cipher implementations treat S-boxes as lookup tables. DES uses 8 S-boxes which each take in 6 bits and output 4 bits. AES uses only one S-box which takes in 8 bits and outputs 8 bits. How much storage is required in each case?
I... have no idea? I'm not sure exactly what this question is asking. I feel like I may be missing some concept about storage and s-boxes?
If anyone could shed some light on this, it would be great! Thanks.
Upvotes: 1
Views: 3662
Reputation: 23731
Seems a bit of a strange question, but here's how I think I'd approach it:
If implemented as a lookup-table, it's basically just an array with the "lookup" just being indexing into the array.
The number of array elements must therefore correspond to the number of distinct values that the input can take, e.g. if the S-box input is 8-bit, then there are 28 = 256 possible input values.
The size of the array elements themselves correspond to the number of output bits. Now, we generally can't define arrays with elements smaller than 8-bits (1 byte), but we'll presume that it's possible to encode the outputs such that we can construct an array with no "wasted" space (as would occur if we had to store say, a 4-bit value in an 8-bit array element).
With this in mind we should be able to calculate the storage as follows:
Storage (in bytes) = Number of S-boxes x 2Number of input bits x (Number of output bits / 8)
So:
DES = 8 x 26 x (4 / 8) = 256 bytes
AES = 1 x 28 x (8 / 8) = 256 bytes
Upvotes: 3