AES Modes
AES Modes
AES Modes
The modes of operation of block ciphers are configuration methods that allow those
ciphers to work with large data streams, without the risk of compromising the provided
security.
It is not recommended, however it is possible while working with block ciphers, to use
the same secret key bits for encrypting the same plaintext parts. Using one
deterministic algorithm for a number of identical input data, results in some number
of identical ciphertext blocks.
This is a very dangerous situation for the cipher's users. An intruder would be able
to get much information by knowing the distribution of identical message parts, even
if he would not be able to break the cipher and discover the original messages.
Luckily, there exist ways to blur the cipher output. The idea is to mix the plaintext
blocks (which are known) with the ciphertext blocks (which have been just created),
and to use the result as the cipher input for the next blocks. As a result, the user avoids
creating identical output ciphertext blocks from identical plaintext data. These
modifications are called the block cipher modes of operations.
The bitmap image encrypted using DES and the same secret key. The ECB mode was
used for the left image and the more complicated CBC mode was used for the right
image.
A message that is encrypted using the ECB mode should be extended until a size that is
equal to an integer multiple of the single block length. A popular method of aligning
the length of the last block is about appending an additional bit equal to 1 and then
filling the rest of the block with bits equal to 0. It allows to determine precisely the end
of the original message. There exist more methods of aligning the message size.
Apart from revealing the hints regarding the content of plaintext, the ciphers that are
used in ECB mode are also more vulnerable to replay attacks.
Encryption in CBC mode can only be performed by using one thread. Despite this
disadvantage, this is a very popular way of using block ciphers. CBC mode is used
in many applications.
During decrypting of a ciphertext block, one should add XOR the output data received
from the decryption algorithm to the previous ciphertext block. Because the receiver
knows all the ciphertext blocks just after obtaining the encrypted message, he can
decrypt the message using many threads simultaneously.
A message that is to be encrypted using the CBC mode, should be extended till the size
that is equal to an integer multiple of a single block length (similarly, as in the case of
using the ECB mode).
In the example presented above, if the intruder is able to predict that the
vector IV1 will be used by the attacked system to produce the response c1, they can
guess which one of the two encrypted messages m0 or m1 is carried by the response c1.
This situation breaks the rule that the intruder shouldn't be able to distinguish between
two ciphertexts even if they have chosen both plaintexts. Therefore, the attacked
system is vulnerable to chosen-plaintext attacks.
If the vector IV is generated based on non-random data, for example the user
password, it should be encrypted before use. One should use a separate secret key for
this activity.
The initialization vector IV should be changed after using the secret key a number
of times. It can be shown that even properly created IV used too many times, makes
the system vulnerable to chosen-plaintext attacks. For AES cipher it is estimated to be
248 blocks, while for 3DES it is about 216 plaintext blocks.
In the PCBC mode both encryption and decryption can be performed using only
one thread at a time.
As opposed to the previous block cipher modes, the encrypted message doesn't need
to be extended till the size that is equal to an integer multiple of a single block length.
The CTR mode is also known as the SIC mode (Segment Integer Counter).
Security of the CTR mode
As in the case of the CBC mode, one should change the secret key after using it for
encrypting a number of sent messages. It can be proved that the CTR mode generally
provides quite good security and that the secret key needs to be changed less often
than in the CBC mode.
For example, for the AES cipher the secret key should be changed after about
264 plaintext blocks.