Stream vs Block Ciphers Explained
Stream vs Block Ciphers Explained
A stream cipher is one that encrypts a digital data stream one bit or one byte at a time. Examples
of classical stream ciphers are the auto keyed Vigenère cipher and the Vernam cipher. A block
cipher is one in which a block of plaintext is treated as a whole and used to produce a ciphertext
block of equal length. Typically, a block size of 64 or 128 bits is used. Using some of the modes
of operation explained in Chapter 6, a block cipher can be used to achieve the same effect as a
stream cipher.
- Speed of transformation. Because each symbol is encrypted without regard for any other
plaintext symbols, each symbol can be encrypted as soon as it is read. Thus, the time to encrypt a
symbol depends only on the encryption algorithm itself, not on the time it takes to receive more
plaintext.
- Low error propagation. Because each symbol is separately encoded, an error in the encryption
process affects only that character.
- Low diffusion. Each symbol is separately enciphered. Therefore, all the information of that
symbol is contained in one symbol of the ciphertext.
- High diffusion. Information from the plain-text is diffused into several ciphertext symbols. One
ciphertext block may depend on several plaintext letters.
- Slowness of encryption. The person or machine using a block cipher must wait until an entire
block of plaintext symbols has been received before starting the encryption process.
itn
Figure 3.2 depicts the structure proposed by Feistel. The inputs to the encryption algorithm are a
plaintext block of length 2w bits and a key K. The plaintext block is divided into two halves, L0
and R0. The two halves of the data pass through n rounds of processing and then combine to
produce the ciphertext block. Each round i has as inputs Li-1 and Ri-1, derived from the previous
round, as well as a subkey Ki, derived from the overall K. In general, the subkeys Ki are
different from K and from each other.
al
ep
itn
which has subsequently enjoyed widespread use internationally. The algorithm was initially
controversial, with classified design elements, a relatively short key length, and suspicions about
ep
a National Security Agency (NSA) backdoor. DES consequently came under intense academic
scrutiny, and motivated the modern understanding of block ciphers and their cryptanalysis. DES
itn
Description: DES is the block cipher - an algorithm that takes a fixed-length string of plaintext
bits and transforms it through a series of complicated operations into another ciphertext bitstring
of the same length. In the case of DES, the block size is 64 bits. DES also uses a key to
customize the transformation, so that decryption can supposedly only be performed by those who
know the particular key used to encrypt. The key consists of 64 bits; however, only 56 of these
are actually used by the algorithm. Eight bits are used solely for checking parity, and are
thereafter discarded. Hence the effective key length is 56 bits, and it is usually quoted as such.
Structure: The algorithm's overall structure is shown in Figure below there are 16 identical stages
of processing, termed rounds. There is also an initial and final permutation, termed IP and FP
(see appendix for IP and FP scheme), which are inverses (IP "undoes" the action of FP, and vice
versa). IP and FP have almost no cryptographic significance, but were apparently included in
order to facilitate loading blocks in and out of mid-1970s hardware, as well as to make DES run
slower in software.
Before the main rounds, the block is divided into two 32-bit halves and processed alternately;
this criss-crossing is known as the Feistel scheme. The Feistel structure ensures that decryption
and encryption are very similar processes - the only difference is that the subkeys are applied in
the reverse order when decrypting. The rest of the algorithm is identical. This greatly simplifies
implementation, particularly in hardware, as there is no need for separate
encryption and decryption algorithms.
Each of the eight S-boxes replaces its six input bits with four output bits
according to a non-linear transformation, provided in the form of a
ep
lookup table (see appendix for table). The S-boxes provide the core of
itn
Key Schedule: Figure below illustrates the key schedule for encryption - the algorithm which
generates the subkeys. Initially, 56 bits of the key are selected from the
initial 64 by Permuted Choice 1, PC-1(see appendix for PC1) - the
remaining eight bits are either discarded or used as parity check bits.
The 56 bits are then divided into two 28-bit halves; each half is
thereafter treated separately. In successive rounds, both halves are
rotated left by one or two bits specified for each round (see appendix for
key rotation schedule), and then 48 subkey bits are selected by
Permuted Choice 2, PC-2(see appendix for PC2) - 24 bits from the left
half, and 24 from the right. The rotations (denoted by "<<<" in the
diagram) mean that a different set of bits is used in each subkey; each
bit is used in approximately 14 out of the 16 subkeys.
The key schedule for decryption is similar - the subkeys are in reverse
order compared to encryption. Apart from that change, the process is the
same as for encryption.
Weak and Semi-Weak Keys: There are sixteen DES keys that are not
suggested for use. However the probability of getting such keys is very
small as given by 16/256. The sixteen weak keys are keys with all ones,
all zeroes, alternating zeroes and ones, and alternating ones and zeroes
for two 28 bits parts of the key generated when PC-1 is used.
Although more information has been published on the cryptanalysis of DES than any other block
cipher, the most practical attack to date is still a brute force approach. Various minor
cryptanalytic properties are known, and three theoretical attacks are possible which, while having
a theoretical complexity less than a brute force attack, require an unrealistic amount of known or
chosen plaintext to carry out, and are not a concern in practice. In spite of all the criticism and
weaknesses of DES, there is no known example of anyone actually suffering monetary losses
because of DES security limitations.
Brute force attack: For any cipher, the most basic way of attack is brute force - trying every
possible key. The length of the key gives the number of possible keys, and hence the feasibility
of this approach. For DES, questions were raised about the adequacy of its key size early on,
even before it was adopted as a standard, and it was the small key size, rather than theoretical
cryptanalysis, which dictated a need for a replacement algorithm. It is known that the NSA
encouraged, if not persuaded, IBM to reduce the key size from 128 to 64 bits, and from there to
56 bits; this is often taken as an indication that the NSA thought it would be able to break keys of
this length even in the mid-1970s.
The Rijndael proposal for AES defined a cipher in which the block length and the key length can
al
be independently specified to be 128, 192, or 256 bits. The AES specification uses the same
three key size alternatives but limits the block length to 128 bits. A number of AES parameters
ep
This figure shows the overall structure of AES. The input to the encryption and decryption
algorithms is a single 128-bit block. In FIPS PUB 197, this block is depicted as a square matrix
al
of bytes. This block is copied into the State array, which is modified at each stage of encryption
or decryption. After the final stage, State is copied to an output matrix.
ep
itn
The structure of AES is quite simple. For both encryption and decryption, the cipher begins with
an AddRoundKey stage, followed by nine rounds that each includes all four stages, followed by
a tenth round of three stages as shown in figure 1 above.
al
ep
itn
b) ShiftRows Transformation
The forward shift row transformation, called ShiftRows, is depicted in Figure below. The first
row of State is not altered. For the second row, a 1-byte circular left shift is performed. For the
third row, a 2-byte circular left shift is performed. For the fourth row, a 3-byte circular left shift
is performed. The following is an example of ShiftRows:
c) MixColumns Transformation
The forward mix column transformation, called MixColumns, operates on each column
individually. Each byte of a column is mapped into a new value that is a function of all four
bytes in that column.
al
ep
itn
The AES key expansion algorithm takes as input a 4-word (16-byte) key and produces a linear
array of 44 words (176 bytes). This is sufficient to provide a 4-word round key for the initial
AddRoundKey stage and each of the 10 rounds of the cipher. The following pseudocode
describes the expansion:
KeyExpansion (byte key[16], word w[44])
{
word temp
for (i = 0; i < 4; i++)
w[i] = (key[4*i], key[4*i+1],key[4*i+2],key[4*i+3]);
al
In cryptography, the IDEA is a block cipher designed by Xuejia Lai and James Massey and was
first described in 1991. The algorithm was intended as a replacement for the Data Encryption
al
Standard.
ep
itn
K1 K2 K3 K4 K5 K6 K7 K8
Round Operations: It has been mentioned above that IDEA uses 8 full rounds and 1 half round.
al
We now break the 8 full round and make it 16 rounds such that there are total 17 rounds where 9
odd rounds (1, 3, …., 17) are identical and 8 even rounds (2, 4, ….,16) are identical. Each odd
ep
Even Round: Even round is bit complicated then the odd round. There are four input sub-blocks
(Xa, Xb, Xc, and Xd) from the previous round and two subkeys (Ke and Kf). In even rounds first
and second input sub-blocks are subjected to XOR operation to get single 16 bits output (say,
Yin) and third and fourth input sub-blocks are subjected to XOR operation to get single 16 bits
output (say, Zin). Yin and Zin are fed to mangler function along with Ke, and Kf to get outputs
Yout and Zout, where Yout is XOR’ed with Xa and Xb, to get first two input sub-blocks for next
round and Zout is XOR’ed with Xc and Xd, to get last two input sub-blocks for next round.
Algebraic expressions for even round can be written as:
Yin = Xa Xb; Zin = Xc Xd; Yout = ((Ke Yin) Zin) Kf; Zout = (Ke Yin) Yout;
Xa = Xa Yout; Xb = Xb Yout; Xc = Xb Zout; Xd = Xd Zout; (see figure above)
Security: The designers analyzed IDEA to measure its strength against differential cryptanalysis
and concluded that it is immune under certain assumptions. No successful linear or algebraic
weaknesses have been reported. Some classes of weak keys have been found but these are of
little concern in practice, being so rare as to be unnecessary to avoid explicitly. As of 2004, the
best attack which applies to all keys can break IDEA reduced to 5 rounds (the full IDEA cipher
uses 8.5 rounds).
Modes of Operations
A mode of operation is a technique for enhancing the effect of a cryptographic algorithm or
adapting the algorithm for an application, such as applying a block cipher to a sequence of data
blocks or a data stream. The four modes are intended to cover virtually all the possible
applications of encryption for which a block cipher could be used.
because of the chaining mechanism of CBC, it is an appropriate mode for encrypting messages
of length greater than b bits.
al
The DES scheme is essentially a block cipher technique that uses b-bit blocks. However, it is
possible to convert DES into a stream cipher, using either the cipher feedback (CFB) or the
itn
al
ep
itn
Old questions
1. How many rounds are used in AES and what does the number of rounds depend on?
2. What are the steps that go into the construction of the 16*16 S-box lookup table for AES
algorithm?
3. What are the characteristics of a stream cipher?
al
ep
itn