In: Computer Science
Give two ways to encrypt a partial block cipher. Your first method should result in ciphertext that is the size of a complete block, while your second method should not expand the data. Discuss any possible security concerns for your two methods.
The two encryption types for partial block cipher are
(1) ECB (Electronic Codebook) Mode
It is the simplest mode of encryption. Each plaintext block is
encrypted separately. Similarly, each ciphertext block is decrypted
separately. Thus, it is possible to encrypt and decrypt by using
many threads simultaneously. However, in this mode the created
ciphertext is not blurred.
A typical example of weakness of encryption using ECB mode is
encoding a bitmap image (for example a .bmp file). Even a strong
encryption algorithm used in ECB mode cannot blur efficiently the
plaintext.
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.
(2) CTR (Counter) Mode
Using the CTR mode makes block cipher way of working similar to a
stream cipher. As in the OFB mode, keystream bits are created
regardless of content of encrypting data blocks. In this mode,
subsequent values of an increasing counter are added to a nonce
value (the nonce means a number that is unique: number used once)
and the results are encrypted as usual. The nonce plays the same
role as initialization vectors in the previous modes.
It is one of the most popular block ciphers modes of operation.
Both encryption and decryption can be performed using many threads
at the same time.
If one bit of a plaintext or ciphertext message is damaged, only one corresponding output bit is damaged as well. Thus, it is possible to use various correction algorithms to restore the previous value of damaged parts of received messages.
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.