Generally speaking, ECB mode shouldn\'t be used. ECB seems to be more of a basic
ID: 647541 • Letter: G
Question
Generally speaking, ECB mode shouldn't be used. ECB seems to be more of a basic building block than anything else. Because I thought it would be interesting to experiment with encryption (this method isn't something I want to use in actual software for release), I came up with the following method for using ECB and want to know if it's any good:
1)Generate initialization vector -> IV.
2)SHA256 password -> key.
3)Join IV and key and run through SHA256 -> newKey.
4)Encrypt one block of plain text with newKey.
5)Run newKey through SHA256 -> newKey.
6)Goto 4 until done.
Is this any good at all? If not, what are some of the most immediate problems with this?
Explanation / Answer
What you have devised is no longer ECB.
ECB encrypts multiple blocks using the same key.
The reason we have modes of operation is so that we can encrypt multiple blocks using the same key in a way that is secure, that is identical blocks of plaintext do not encrypt to the same ciphertext block, among other properties.
What you have devised uses a different key for each block, which is derived from a master key, and requires a full invocation of SHA-256 for each block. This should be (see below) as secure as CBC mode, except that is is substantially, hilariously, slower.
The other performance issue you have is with random access. In order to get to later blocks, you need to derive the key for all prior blocks. If you want to start deriving key material before the data is available, you need to store it, lots of it, 1GB of plaintext takes 2GB of key material for AES-256.
One of the possible issues you will run into is that you need to create new key material for each block, and you need to save the key material in accessible memory in order to do that. Single key modes of operation allow the key material to be derived and stored in CPU registers, and stay out of regular system memory if the implementation and hardware supports it, which modern processors do.
So, while this may be secure from a ciphertext perspective, it will not be easy to secure from an implementation perspective. Add that to the crippling performance issues, and this has no advantages over CBC mode. Depending on plaintext and implementation, it may be less secure than ECB in practice.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.