Chapter 3 Symmetric Key Algorithms and AES
Chapter 3 Symmetric Key Algorithms and AES
Symmetric Key
Algorithms and AES
3.1 Introduction
We have discussed the basic concepts of cryptography, encryption and decryption. Computers perform
encryption quite easily and fast. Symmetric key cryptography has been quite popular over a number of
years. Of late, asymmetric key cryptography is equally popular. However, as we shall study later, most
practical implementations use a combination of symmetric and asymmetric key cryptography.
In this chapter, we shall look at the various aspects of symmetric key cryptography. We shall discuss
the various types and modes of symmetric key algorithms. We shall also examine uses of chaining.
This chapter also discusses a number of symmetric key algorithms in great detail. We go to the last bit
of explanation, which should make the reader understand how these algorithms work. The algorithms
discussed here are: DES (and its variations), IDEA, RC4, RC5 and Blowfish. We also touch upon the
Rijndael algorithm, which is approved by the US Government as the Advanced Encryption Standard
(AES).
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
After reading this chapter, the reader will have a complete understanding of how symmetric key
encryption works. However, if the reader is not very keen in understanding the minute details of the
algorithms, the relevant sections can be skipped without any loss of continuity.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
88 Cryptography and Network Security
Stream Cipher technique involves the encryption of one plain text byte at a time. The
decryption also happens one byte at a time.
Another interesting property of XOR is that when used twice, it produces the original data. For
example, suppose we have two binary numbers A = 101 and B = 110. We now want to perform an XOR
operation on A and B to produce a third number C, i.e.:
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 89
C = A XOR B
Thus, we will have:
C = 101 XOR 110
= 011
Now, if we perform C XOR A, we will get B. That is:
B = 011 XOR 101
= 110
Similarly, if we perform C XOR B, we will get A. That is:
A = 011 XOR 110
= 101
This reversibility of XOR operations has many implications in cryptographic algorithms, as we shall
notice.
XOR is reversible – when used twice, it produces the original values. This is useful in
cryptography.
Block Ciphers In Block Ciphers, rather than encrypting one byte at a time, a block of bytes is
encrypted at one go. Suppose we have a plain text FOUR_AND_FOUR that needs to be encrypted.
Using block cipher, FOUR could be encrypted first, followed by _AND_ and finally FOUR. Thus, one
block of characters gets encrypted at a time.
During decryption, each block would be translated back to the original form. In actual practice, the
communication takes place only in bits. Therefore, FOUR actually means binary equivalent of the
ASCII characters FOUR. After any algorithm encrypts these, the resultant bits are converted back into
their ASCII equivalents. Therefore, we get funny symbols such as Vfa%, etc. In actual practice, their
binary equivalents are received, which are decrypted back into binary equivalent of ASCII FOUR. This
is shown in Fig. 3.4.
An obvious problem with block ciphers is repeating text. For repeating text patterns, the same cipher
is generated. Therefore, it could give a clue to the cryptanalyst regarding the original plain text. The
cryptanalyst can look for repeating strings and try to break them. If she succeeds in doing so, there is a
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
danger that a relatively large portion of the original message is broken into and therefore, the entire
message can then be revealed with more effort. Even if the cryptanalyst cannot guess the remaining
words, suppose she changes all debit to credit and vice versa in a funds transfer message, it could cause
havoc! To deal with this problem, block ciphers are used in chaining mode, as we shall study later. In
this approach, the previous block of cipher text is mixed with the current block, so as to obscure the
cipher text, thus avoiding repeated patterns of blocks with the same content.
Block Cipher technique involves encryption of one block of text at a time. Decryption also
takes one block of encrypted text at a time.
Practically, the blocks used in block cipher generally contain 64 bits or more. As we have seen, stream
ciphers encrypt one byte at a time. This can be very time consuming and actually unnecessary in real life.
That is why block ciphers are used more often in computer-based cryptographic algorithms as compared
to stream ciphers. Consequently, we will focus our attention on block ciphers with reference to algorithm
modes. However, as we shall see, two of the block cipher algorithm modes can also be implemented as
stream cipher modes.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
90 Cryptography and Network Security
Group Structures When discussing an algorithm, many times a question arises, as to whether it is a
group. The elements of the group are the cipher text blocks with each possible key. Grouping, thus,
means how many times the plain text is scrambled in various ways to generate the cipher text.
Concepts of Confusion and Diffusion Claude Shannon introduced the concepts of confusion and
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
diffusion, which are significant from the perspective of the computer-based cryptographic techniques.
Confusion is a technique of ensuring that a cipher text gives no clue about the original plain text. This
is to try and thwart the attempts of a cryptanalyst to look for patterns in the cipher text, so as to deduce
the corresponding plain text. We already know how to achieve confusion: it is achieved by means of the
substitution techniques discussed earlier.
Diffusion increases the redundancy of the plain text by spreading it across rows and columns. We
have already seen that this can be achieved by using the transposition techniques (also called as
permutation techniques).
Stream cipher relies only on confusion. Block cipher uses both confusion and diffusion. We leave the
question of why this is the case, to the reader.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 91
based security algorithms. There are four important algorithm modes, namely, Electronic Code Book
(ECB), Cipher Block Chaining (CBC), Cipher Feedback (CFB) and Output Feedback (OFB). This
is shown in Fig. 3.5. The first two modes operate on block cipher, whereas the latter two modes are block
cipher modes, which can be used as if they are working on stream cipher.
Apart from this, we also discuss a variation of the OFB mode, called as Counter (CTR).
Algorithm Modes
Electronic Code Book (ECB) Mode Electronic Code Book (ECB) is the simplest mode of
operation. Here, the incoming plain text message is divided into blocks of 64 bits each. Each such block
is then encrypted independently of the other blocks. For all blocks in a message, the same key is used for
encryption. This process is shown in Fig. 3.6.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
92 Cryptography and Network Security
Cipher Block Chaining (CBC) Mode We saw that in the case of ECB, within a given message (i.e.
for a given key), a plain text block always produces the same cipher text block. Thus, if a block of plain
text occurs more than once in the input, the corresponding cipher text block will also occur more than
once in the output, thus providing some clues to a cryptanalyst. To overcome this problem, the Cipher
Block Chaining (CBC) mode ensures that even if a block of plain text repeats in the input, these two (or
more) identical plain text blocks yield totally different cipher text blocks in the output. For this, a
feedback mechanism is used, as we shall learn in the following paragraphs.
Chaining adds a feedback mechanism to a block cipher. In Cipher Block Chaining (CBC), the results
of the encryption of the previous block are fed back into the encryption of the current block. That is, each
block is used to modify the encryption of the next block. Thus, each block of cipher text is dependent on
the corresponding current input plain text block, as well as all the previous plain text blocks.
The encryption process of CBC is depicted in Fig. 3.8 and described thereafter.
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
•••
Key Encrypt Key Encrypt Key Encrypt
1. As shown in the figure, the first step receives two inputs: the first block of plain text and a random
block of text, called as Initialization Vector (IV).
(a) The IV has no special meaning: it is simply used to make each message unique. Since the
value of IV is randomly generated, the likelihood of it repeating in two different messages
is quite rare. Consequently, IV helps in making the cipher text somewhat unique or at least
quite different from all the other cipher texts in a different message. Interestingly, it is not
mandatory to keep IV secret – it can be known to everybody. This seems slightly
concerning and confusing. However, if we re-look at the operation of CBC, we will realize
that IV is simply one of the two inputs to the first encryption step. The output of Step 1 is
Cipher text block 1, which is also one of the two inputs to the second encryption step. In
other words, Cipher text block 1 is also an IV for Step 2! Similarly, Cipher text block 2 is
also an IV for Step 3 and so on. Since all these cipher text blocks will be sent to the
receiver, we are actually anyway sending all IVs for Step 2 onwards! Thus, there is no
special reason why the IV for Step 1 should be kept secret. It is the key used for encryption
is what needs to be kept secret. However, in practice, for maximum security, both the key
and the IV are kept secret.
(b) The first block of cipher text and IV are combined using XOR and then encrypted using a
key to produce the first cipher text block. The first cipher text block is then provided as a
feedback to the next plain text block, as explained below.
2. In the second step, the second plain text block is XORed with the output of Step 1, i.e. the first
cipher text block. It is then encrypted with the same key, as used in Step 1. This produces cipher
text block 2.
3. In the third step, the third plain text block is XORed with the output of Step 2, i.e. the second cipher
text block. It is then encrypted with the same key, as used in Step 1.
4. This process continues for all the remaining plain text blocks of the original message.
Remember that the IV is used only in the first plain text block. However, the same key is used for
encryption of all plain text blocks.
The decryption process works as follows.
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
1. The Cipher text block 1 is passed through the decryption algorithm using the same key, which was
used during the encryption process for all the plain text blocks. The output of this step is then
XORed with the IV. This process yields Plain text block 1.
2. In Step 2, the Cipher text block 2 is decrypted and its output is XORed with Cipher text block 1,
which yields Plain text block 2.
3. This process continues for all the Cipher text blocks in the encrypted message.
The decryption process is shown in Fig. 3.9.
Appendix A provides some more mathematical details about the CBC mode.
Cipher Feedback (CFB) Mode Not all applications can work with blocks of data. Security is also
required in applications that are character-oriented. For instance, an operator can be typing keystrokes at
a terminal, which need to be immediately transmitted across the communications link in a secure
manner, i.e. by using encryption. In such situations, stream cipher must be used. The Cipher Feedback
(CFB) mode is useful in such cases. In this mode, data is encrypted in units that are smaller (e.g. they
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
94 Cryptography and Network Security
•••
Key Decrypt Key Decrypt Key Decrypt
IV
could be of size 8 bits, i.e. the size of a character typed by an operator) than a defined block size (which
is usually 64 bits).
Let us understand how CFB mode works, assuming that we are dealing with j bits at a time (as we
have seen, usually, but not always, j = 8). Since CFB is slightly more complicated as compared to the
first two cryptography modes, we shall study CFB in a step-by-step fashion.
Step 1: Like CBC, a 64-bit Initialization Vector (IV) is used in the case of CFB mode. The IV is kept
in a shift register. It is encrypted in the first step to produce a corresponding 64-bit IV cipher text. This is
shown in Fig. 3.10.
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
IV Encrypt Encrypted IV
Key
Step 2: Now, the leftmost (i.e. the most significant) j bits of the encrypted IV are XORed with the first
j bits of the plain text. This produces the first portion of cipher text (say C) as shown in Fig. 3.11. C is
then transmitted to the receiver.
Step 3: Now, the bits of IV (i.e. the contents of the shift register containing IV) are shifted left by j
positions. Thus the rightmost j positions of the shift register now contain unpredictable data. These
rightmost j positions are now filled with C. This is shown in Fig. 3.12.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 95
XOR
Cipher text 1
(C)
Left shift IV by j
positions IV
Step 4: Now, Steps 1 through 3 continue until all the plain text units are encrypted. That is, the
following Steps repeat:
• IV is encrypted.
• The leftmost j bits resulting from this encryption process are XORed with the next j bits of the
plain text.
• The resulting cipher text portion (i.e. the next j bits of cipher text) is sent to the receiver.
• The shift register containing the IV is left-shifted by j bits.
• The j bits of the cipher text are inserted from right into the shift register containing the IV.
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
Figure 3.13 shows the overall conceptual view of the CFB mode.
At the receiver’s end, the decryption process is pretty similar, with minor changes. We shall not
discuss it.
Output Feedback (OFB) Mode The Output Feedback (OFB) mode is extremely similar to the
CFB. The only difference is that in the case of CFB, the cipher text is fed into the next stage of
encryption process. But in the case of OFB, the output of the IV encryption process is fed into the next
stage of encryption process. Therefore, we shall not describe the details of OFB and instead, shall simply
draw the block diagram of the OFB process, as shown in Fig. 3.14. The same details as discussed in CFB
apply here, excepting the change, as pointed out above.
Let us summarize the key advantage of the OFB mode. In simple terms, we can state that in this mode,
if there are errors in individual bits, they remain errors in individual bits and do not corrupt the whole
message. That is, bit errors do not get propagated. If a cipher text bit Ci is in error, only the decrypted
value corresponding to this bit, i.e. Pi is wrong. Other bits are not affected. Remember that in contrast to
this, in the CFB mode, the cipher text bit Ci is fed back as input to the shift register and would corrupt the
other bits in the message!
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
96 Cryptography and Network Security
IV IV IV
(Shift register) (Shift register) (Shift register)
•••
IV IV IV
(Shift register) (Shift register) (Shift register)
•••
Counter (CTR) Mode The Counter (CTR) mode is quite similar to the OFB mode, with one
variation. It uses sequence numbers called as counters as the inputs to the algorithm. After each block is
encrypted, to fill the register, the next counter value is used. Usually, a constant is used as the initial
counter value and is incremented (usually by 1) for every iteration. The size of the counter block is the
same as that of the plain text block.
For encryption, the counter is encrypted and then XORed with the plain text block to get the cipher
text. No chaining process is used. On the other hand, for decryption, the same sequence of counters is
used. Here, each encrypted counter is XORed with the corresponding cipher text block to obtain the
original plain text block.
The overall operation of the Counter mode is shown in Fig. 3.15 and Fig. 3.16.
The encryption or decryption process in Counter can be done in parallel on multiple text blocks, since
no chaining is involved. This can make the execution speed of Counter faster. Multiprocessing systems
can take advantage of this feature to introduce features that help reduce the overall processing time. Pre-
processing can be achieved to prepare the output of the encryption boxes that input to the XOR
operations. The Counter mode mandates implementation of the encryption process only and not of the
decryption process.
Table 3.1 summarizes the key features of the various algorithm modes.
Table 3.2 summarizes the key advantages and disadvantages of the various modes.
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 99
Security-related The same key can be XOR of plain text Plain text patterns Plain text patterns
advantages used for encrypting with previous are hidden. are hidden.
multiple messages. cipher text block
hides the plain text. The same key can The same key can
be used for encryp- be used for
The same key can ting multiple encrypting multiple
be used for encryp- messages, by using messages, by using
ting multiple a different IV. a different IV.
messages.
Input to the block Input to the block
cipher is randomized. cipher is
randomized.
Problems related Size of cipher text Size of cipher text Size of cipher text Size of cipher text
to effectiveness is more than the is more than the is the same as that is the same as that
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
plain text size by plain text size by of the plain text of the plain text
one padding block. one block. size. size.
The first problem here is that of key agreement or key distribution. The problem is: in the first place,
how do two parties agree on a key? One solution is that somebody from the sender’s end physically
visits the receiver and hand over the key. Another way is to courier a paper on which the key is written.
Both are not exactly very convenient. A third way is to send the key over the network to B and ask for the
confirmation. But then, if an intruder gets the message, he can interpret all the subsequent ones!
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
100 Cryptography and Network Security
Sender Receiver
(A) (B)
Network
Plain Cipher Cipher Plain
text text text text
Encrypt Decrypt
with with
symmetric symmetric
key key
The second problem is equally serious. Since the same key is used for encryption and decryption, one
key per communicating parties is required. Suppose A wants to securely communicate with B and also
with C. Clearly, there must be one key for all communications between A and B; and there must be
another, distinct key for all communications between A and C. The same key as used by A and B cannot
be used for communications between A and C. Otherwise, there is a chance that C can interpret
messages going between A and B or B can do the same for messages going between A and C! Since the
Internet has thousands of merchants selling products to hundreds of thousands of buyers, using this
scheme would be impractical because every buyer-seller combination would need a separate key!
Regardless, because these drawbacks can be overcome using intelligent solutions as we shall see and
also because symmetric key cryptography has several advantages as well, it is widely used in practice.
However, we shall first discuss the most popular computed-based symmetric key cryptographic
algorithms and think about solving the problems associated when we discuss asymmetric key
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
cryptography subsequently.
The origins of DES go back to 1972, when in the US, the National Bureau of Standards (NBS), now
known as the National Institute of Standards and Technology (NIST) embarked upon a project for
protecting the data in computers and computer communications. They wanted to develop a single
cryptographic algorithm. After two years, NBS realized that IBM’s Lucifer could be considered as a
serious candidate, rather than developing a fresh algorithm from scratch. After a few discussions, in
1975, the NBS published the details of the algorithm. Towards the end of 1976, the US Federal
Government decided to adopt this algorithm and soon, it was renamed as Data Encryption Standard
(DES). Soon, other bodies also recognized and adopted DES as a cryptographic algorithm.
before the DES process even starts, every eighth bit of the key is discarded to produce a 56-bit key. That
is, bit positions 8, 16, 24, 32, 40, 48, 56 and 64 are discarded. This is shown in Fig. 3.19 with shaded bit
positions indicating discarded bits. (Before discarding, these bits can be used for parity checking to
ensure that the key does not contain any errors.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
th
Fig. 3.19 Discarding of every 8 bit of the original key (Shaded bit positions are discarded)
Thus, the discarding of every 8th bit of the key produces a 56-bit key from the original 64-bit key, as
shown in Fig. 3.20.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
102 Cryptography and Network Security
Initial Permutation
Step 2
(IP)
Final Permutation
Step 5
(FP)
Initial Permutation (IP) As we have noted, the Initial Permutation (IP) happens only once and it
happens before the first round. It suggests how the transposition in IP should proceed, as shown in
Fig. 3.22. For example, it says that the IP replaces the first bit of the original plain text block with the 58th
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 103
Bit position in the plain text block To be overwritten with the contents of this bit position
1 58
2 60
3 42
.. ..
64 7
bit of the original plain text block, the second bit with the 50th bit of the original plain text block and so
on. This is nothing but jugglery of bit positions of the original plain text block.
The complete transposition table used by IP is shown in Fig. 3.23. This table (and all others in this
chapter) should be read from left to right, top to bottom. For instance, we have noted that 58 in the first
position indicates that the contents of the 58th bit in the original plain text block will overwrite the
contents of the 1st bit position, during IP. Similarly, 1 is shown at the 40th position in the table, which
means that the first bit will overwrite the 40th bit in the original plain text block. The same rule applies
for all the other bit positions.
58 50 42 34 26 18 10 2 60 52 44 36 28 20 12 4
62 54 46 38 30 22 14 6 64 56 48 40 32 24 16 8
57 49 41 33 25 17 9 1 59 51 43 35 27 19 11 3
61 53 45 37 29 21 13 5 63 55 47 39 31 23 15 7
Rounds Each of the 16 rounds, in turn, consists of the broad level steps outlined in Fig. 3.24.
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
Key Transformation
Expansion Permutation
S-Box Substitution
P-Box Permutation
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
104 Cryptography and Network Security
Round 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Number of key
1 1 2 2 2 2 2 2 1 2 2 2 2 2 2 1
bits shifted
14 17 11 24 1 5 3 28 15 6 21 10
23 19 12 4 26 8 16 7 27 20 13 2
41 52 31 37 47 55 30 40 51 45 33 48
44 49 39 56 34 53 46 42 50 36 29 32
Because of this compression permutation technique, a different subset of key bits is used in each
round. That makes DES not so easy to crack.
Step 2: Expansion permutation Recall that after Initial Permutation, we had two 32-bit plain text
areas, called as Left Plain Text (LPT) and Right Plain Text (RPT). During expansion permutation, the
RPT is expanded from 32 bits to 48 bits. Besides increasing the bit size from 32 to 48, the bits are
permuted as well, hence the name expansion permutation. This happens as follows:
1. The 32-bit RPT is divided into 8 blocks, with each block consisting of 4 bits. This is shown in
Fig. 3.27.
2. Next, each 4-bit block of the previous step is then expanded to a corresponding 6-bit block. That is,
per 4-bit block, 2 more bits are added. What are these two bits? They are actually the repeated first
and the fourth bits of the 4-bit block. The second and the third bits are written down as they were in
the input. This is shown in Fig. 3.28. Note that the first bit inputted is outputted to the second
output position and also repeats in output position 48. Similarly, the 32nd input bit is found in the
47th output position as well as in the first output position.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 105
···
1 2 3 4 5 6 7 8 ... 29 30 31 32
1 2 3 4 5 6 7 8 9 10 11 12 43 44 45 46 47 48
Clearly, this process results into expansion as well as permutation of the input bits while creating the
output.
As we can see, the first input bit goes into the second and the 48th output positions. The second input
bit goes into the third output position and so on. Consequently, we will observe that the expansion
permutation has actually used the table shown in Fig. 3.29.
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
32 1 2 3 4 5 4 5 6 7 8 9
8 9 10 11 12 13 12 13 14 15 16 17
16 17 18 19 20 21 20 21 22 23 24 25
24 25 26 27 28 29 28 29 30 31 32 1
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
106 Cryptography and Network Security
S-box Substitution
14 4 13 1 2 15 11 8 3 10 6 12 5 9 0 7
0 15 7 4 14 2 13 1 10 6 12 11 9 5 3 8
4 1 14 8 13 6 2 11 15 12 9 7 3 10 5 0
15 12 8 2 4 9 1 7 5 11 3 14 10 0 6 13
15 1 8 14 6 11 3 4 9 7 2 13 12 0 5 10
3 13 4 7 15 2 8 14 12 0 1 10 6 9 11 5
0 14 7 11 10 4 13 1 5 8 12 6 9 3 2 15
13 8 10 1 3 15 4 2 11 6 7 12 0 5 14 9
10 0 9 14 6 3 15 5 1 13 12 7 11 4 2 8
13 7 0 9 3 4 6 10 2 8 5 14 12 11 15 1
13 6 4 9 8 15 3 0 11 1 2 12 5 10 14 7
1 10 13 0 6 9 8 7 4 15 14 3 11 5 2 12
7 13 14 3 0 6 9 10 1 2 8 5 11 12 4 15
13 8 11 5 6 15 0 3 4 7 2 12 1 10 14 9
10 6 9 0 12 11 7 13 15 1 3 14 5 2 8 4
3 15 0 6 10 1 13 8 9 4 5 11 12 7 2 14
2 12 4 1 7 10 11 6 8 5 3 15 13 0 14 9
14 11 2 12 4 7 13 1 5 0 15 10 3 9 8 6
4 2 1 11 10 13 7 8 15 9 12 5 6 3 0 14
11 8 12 7 1 14 2 13 6 15 0 9 10 4 5 3
12 1 10 15 9 2 6 8 0 13 3 4 14 7 5 11
10 15 4 2 7 12 9 5 6 1 13 14 0 11 3 8
9 14 15 5 2 8 12 3 7 0 4 10 1 13 11 6
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
4 3 2 12 9 5 15 10 11 14 1 7 6 0 8 13
4 11 2 14 15 0 8 13 3 12 9 7 5 10 6 1
13 0 11 7 4 9 1 10 14 3 5 12 2 15 8 6
1 4 11 13 12 3 7 14 10 15 6 8 0 5 9 2
6 11 13 8 1 4 10 7 9 5 0 15 14 2 3 12
13 2 8 4 6 15 11 1 10 9 3 14 5 0 12 7
1 15 13 8 10 3 7 4 12 5 6 11 0 14 9 2
7 11 4 1 9 12 14 2 0 6 10 13 15 3 5 8
2 1 14 7 4 10 8 13 15 12 9 0 3 5 6 11
The 6-bit input indicates which row and column and therefore, which intersection is to be selected
thus, determining the 4-bit output. How is it done? Let us assume that the six bits of a S-box are indicated
by b1, b2, b3, b4, b5 and b6. Now, bits b1 and b6 are combined to form a two-bit number. Two bits can
store any decimal number between 0 (binary 00) and 3 (binary 11). This specifies the row number. The
remaining four bits b2, b3, b4, b5 make up a four-bit number, which specifies the column number
between decimal 0 (binary 0000) and 15 (binary 1111). Thus, the 6-bit input automatically selects the
row number and column number for the selection of the output. This is shown in Fig. 3.33.
b1 b2 b3 b4 b5 b6
1 0 1 1 0 1
1 0 1 1 0 1
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
The output of each S-box is then combined to form a 32-bit block, which is given to the last stage of
a round, the P-box Permutation, as discussed next.
Step 4: P-box permutation The output of S-box consists of 32 bits. These 32 bits are permuted using
a P-box. This straightforward permutation mechanism involves simple permutation (i.e. replacement of
each bit with another bit, as specified in the P-box table, without any expansion or compression). This is
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 109
called as P-box Permutation. The P-box is shown in Fig. 3.35. For example, a 16 in the first block
indicates that the bit at position 16 of the original input moves to bit at position 1 in the output and a 10
in the block number 16 indicates that the bit at the position 10 of the original input moves to bit at the
position 16 in the output.
16 7 20 21 29 12 28 17 1 15 23 26 5 18 31 10
2 8 24 14 32 27 3 9 19 13 30 6 22 11 4 25
32-bit Left Plain Text (LPT) Block 32-bit Right Plain Text (RPT) Block
1. Key Transformation
(not involved directly)
2. Expansion Permutation
3. S-box Substitution
4. P-box Permutation
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
XOR
32-bit Left Plain Text (LPT) Block 32-bit Right Plain Text (RPT) Block
Next round
Final Permutation At the end of the 16 rounds, the Final Permutation is performed (only once).
This is a simple transposition, based on Fig. 3.37. For instance, the 40th input bit takes the position of the
1st output bit and so on.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
110 Cryptography and Network Security
40 8 48 16 56 24 64 32 39 7 47 15 55 23 63 31
38 6 46 14 54 22 62 30 37 5 45 13 53 21 61 29
36 4 44 12 52 20 60 28 35 3 43 11 51 19 59 27
34 2 42 10 50 18 58 26 33 1 41 9 49 17 57 25
Analyzing DES
Use of S-boxes The tables used for substitution, i.e. the S-boxes, in DES are kept secret by IBM. IBM
maintains that it took them over 17 person years to come up with the internal design of the S-boxes. Over
the years, suspicion has grown that there is some vulnerability in this aspect of DES, intentional (so that
the government agencies could secretly open encrypted messages) or otherwise. Several studies keep
appearing, which suggest that there is some scope for attacks on DES via the S-boxes. However, no
concrete example has emerged till date.
Key length We have mentioned earlier that any cryptographic system has two important aspects: the
cryptographic algorithm and the key. The inner workings of the DES algorithm (which we have
discussed earlier) are completely known to the general public. Therefore, the strength of DES lies only in
the other aspect - its key, which must be secret.
As we know, DES uses 56-bit keys. (Interestingly, the original proposal was to make use of 112-bit
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
keys.) Thus, there are 256 possible keys (which is roughly equal to 7.2 x 1016 keys). Thus, it seems that a
brute-force attack on DES is impractical. Even if we assume that to obtain the correct key, only half of
the possible keys (i.e. the half of the key space) needs to be examined and tried out, a single computer
performing one DES encryption per microsecond would require more than 1,000 years to break DES.
Differential and Linear cryptanalysis In 1990, Eli Biham and Adi Shamir introduced the concept
of differential cryptanalysis. This method looks at pairs of cipher text whose plain texts have particular
differences. The technique analyses the progress of these differences as the plain texts travel through the
various rounds of DES. The idea is to choose pairs of plain text with fixed differences. The two plain
texts can be chosen at random, as long as they satisfy specific difference conditions (which can be as
simple as XOR). Then, using the differences in the resulting cipher texts, assign different likelihood to
different keys. As more and more cipher text pairs are analysed, the correct key emerges.
Invented by Mitsuru Matsui, the linear cryptanalysis attack is based on linear approximations. If we
XOR some plain text bits together, XOR some cipher text bits together and then XOR the result, we will
get a single bit, which is the XOR of some of the key bits.
The descriptions of these attacks are quite complex and we will not discuss them here.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 111
Timing attacks Timing attacks refer more to asymmetric key cryptography. However, they can also
apply to symmetric key cryptography. The idea is simple: observe how long it takes for the
cryptographic algorithm to decrypt different blocks of cipher text. The idea is to try and obtain either the
plain text or the key used for encryption by observing these timings. In general, it would take different
amounts of time to decrypt different sized cipher text blocks.
Double DES Double DES is quite simple to understand. Essentially, it does twice what DES
normally does only once. Double DES uses two keys, say K1 and K2. It first performs DES on the
original plain text using K1 to get the encrypted text. It again performs DES on the encrypted text, but
this time with the other key, i.e. K2. The final output is the encryption of encrypted text (i.e. the original
plain text encrypted twice with two different keys). This is shown in Fig. 3.38.
K1 K2
algorithms as well. However, in the case of DES, it is already quite popular, therefore, we have discussed
this in the context of DES. It should also be quite simple to imagine that the decryption process would
work in exactly the reverse order, as shown in Fig. 3.39.
K2 K1
If we use a key of just 1 bit, there are two possible keys (0 and 1). If we use a 2-bit key, there are four
possible key values (00, 01, 10 and 11). In general, if we use an n-bit key, the cryptanalyst has to perform
2n operations to try out all the possible keys. If we use two different keys, each consisting of n bits, the
cryptanalyst would need 22n attempts to crack the key. Therefore, on the face of it, we may think that
since the cryptanalysis for the basic version of DES requires a search of 256 keys, Double DES would
require a key search of (22*56) i.e. 2128 keys. However, it is not quite true. Merkle and Hellman
introduced the concept of the meet-in-the-middle attack. This attack involves encryption from one end,
decryption from the other and matching the results in the middle, hence the name meet-in-the-middle
attack. Let us understand how it works.
Suppose that the cryptanalyst knows two basic pieces of information: P (a plain text block) and C (the
corresponding final cipher text block) for a message. We know that the relations shown in Fig. 3.40 are
true for P and C, if we are using Double DES. The mathematical equivalents of these are also shown. The
result of the first encryption is called as T and is denoted as T = EK1 (P) [i.e. encrypt the block P with key
K1]. After this encrypted block is encrypted with another key K2, we denote the result as C =
EK2(EK1(P)) [i.e. encrypt the already encrypted block T, with a different key K2 and call the final cipher
text as C].
Temporary
P Encrypt Encrypt C
result (T)
K1 K2
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 113
P
Table of
cipher
Possible Keys text (T)
(Key = K1)
00 Result = T
01 Result = T
Encrypt
10 Result = T
11 Result = T
To summarize:
• In the first step, the cryptanalyst was calculating the value of T from the left hand side (i.e. encrypt
P with K1 to find T). Thus, here T = EK1(P).
• In the second step, the cryptanalyst was finding the value of T from the right hand side (i.e. decrypt
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
114 Cryptography and Network Security
Clearly, this attack is possible, but requires a lot of memory. For an algorithm that uses 64-bit plain
text blocks and 56-bit keys, we would need 256 64-bit blocks to store the table of T in memory (there is
no point in storing it on the disk, as it would be too slow and defeat the very purpose of the attack). This
is equivalent to 1017 bytes, which is too high for the next few generations of computers!
Triple DES Although the meet-in-the-middle attack on Double DES is not quite practical yet, in
cryptography, it is always better to take the minimum possible chances. Consequently, Double DES
seemed inadequate, paving the way for Triple DES. As we can imagine, Triple DES is DES – three
times. It comes in two flavours: one that uses three keys and the other that uses two keys. We will study
both, one-by-one.
• Triple DES with three keys The idea of Triple DES with three keys is illustrated in Fig. 3.43. As
we can see, the plain text block P is first encrypted with a key K1, then encrypted with a second key K2
and finally with a third key, K3, where K1, K2 and K3 are all different from each other.
K2 K3
form of equation as C = EK3(EK2(EK1(P))). However, Triple DES with three keys also has the drawback
of requiring 56 x 3 = 168 bits for the key, which can be slightly difficult to have in practical situations. A
workaround suggested by Tuchman uses just two keys for Triple DES. Here, the algorithm works as
follows:
1. Encrypt the plain text with key K1. Thus, we have EK1(P).
2. Decrypt the output of Step 1 above with key K2. Thus, we have DK2(EK1(P)).
3. Finally, encrypt the output of Step 2 again with key K1. Thus, we have EK1(DK2(EK1(P))).
This is shown in Fig. 3.44.
To decrypt the cipher text C and obtain the original plain text P, we need to perform the operation P =
DK1(EK2(DK1(C))).
There is no special meaning attached to the second step of decryption. Its only significance is that it
allows Triple DES to work with two, rather than three keys. This is also called as Encrypt-Decrypt-
Encrypt (EDE) mode. Triple DES with two keys is not susceptible to the meet in the middle attack,
unlike Double DES as K1 and K2 alternate here.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 115
K2 K1
Although it is quite strong, IDEA is not as popular as DES for two primary reasons. Firstly, it is
patented unlike DES and therefore, must be licensed before it can be used in commercial applications
Secondly DES has a long history and track record as compared to IDEA. However one popular email
privacy technology known as Pretty Good Privacy (PGP) is based on IDEA.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
116 Cryptography and Network Security
consists of 128 bits. In each round, six sub-keys are generated from the original key. Each of the sub-
keys consists of 16 bits. (Do not worry if you do not understand this. We shall discuss this in great detail
soon). These six sub-keys are applied to the four input blocks P1 to P4. Thus, for the first round, we will
have the six keys K1 to K6. For the second round, we will have keys K7 to K12. Finally, for the eighth
round, we will have keys K43 to K48. The final step consists of an Output Transformation, which uses
just four sub-keys (K49 to K52). The final output produced is the output produced by the Output
Transformation step, which is four blocks of cipher text named C1 to C4 (each consisting of 16 bits).
These are combined to form the final 64-bit cipher text block.
K1
.
Round 1 .
K6
K7
.
Round 2 .
K12
···
K43
.
Round 8 .
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
K48
K49
.
Output Transformation .
K52
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 117
Rounds We have mentioned that there are 8 rounds in IDEA. Each round involves a series of
operations on the four data blocks using six keys. At a broad level, these steps can be described as shown
in Fig. 3.46. As we can see, these steps perform a lot of mathematical actions. There are multiplications,
additions and XOR operations.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
118 Cryptography and Network Security
Note that we have put an asterisk in front of the words Add and Multiply, causing them to be shown as
Add* and Multiply*, respectively. The reason behind this is that these are not mere additions and
multiplications. Instead, these are addition modulo 216 (i.e. addition modulo 65536) and multiplication
modulo 216 + 1 (i.e. multiplication modulo 65537), respectively. [For those who are not conversant with
modulo arithmetic, if a and b are two integers, then a mod b is the remainder of the division a/b. Thus, for
example, 5 mod 2 is 1 (because the remainder of 5/2 is 1) and 5 mod 3 is 2 (because the remainder of 5/
3 is 2)].
Why is this required in IDEA and what does this mean? 1111111100000000
Let us examine the case of the normal binary addition with
an example. Suppose that we are in round 2 of IDEA.
Further, let us assume that P2 = 1111111100000000 and 1111111111000001
K2 = 1111111111000001. First, simply add them (and not
add* them!) and see what happens. The operation would
look like as shown in Fig. 3.47. 11111111011000001
As we can see, the normal addition will produce a
number that consists of 17 bits (i.e.11111111011000001). Fig. 3.47 Binary addition of two 16-bit
However, remember that we have only 16 bit positions numbers
available for the output of Round 2. Therefore, we must reduce this number (which is 130753 in
decimal) to a 16-bit number. For this, we take modulo 65536 of this. 130753 modulo 65536
yields 65217, which is 1111111011000001 in binary and is a 16-bit number, which fits well in our
scheme.
This should explain why modulo arithmetic is required in IDEA. It simply ensures that even if the
result of an addition or multiplication of two 16-bit numbers contains more than 16 bits, we bring it back
to 16 bits.
Let us now re-look at the details of one round in a more symbolic fashion, as shown in Fig. 3.48. It
conveys the same meaning as the earlier diagram, but is more symbolic than verbose in nature. We have
depicted the same steps as earlier. The input blocks are shown as P1 to P4, the sub-keys are denoted by
K1 to K6 and the output of this step is denoted by R1 to R4 (and not C1 to C4, because this is not the final
cipher text – it is an intermediate output, which will be processed in further rounds as well as in the
Output Transformation Step).
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
Sub-key Generation for a Round We have been talking about sub-keys in our discussion quite
frequently. As we mentioned, each of the eight rounds makes use of six sub-keys (so, 8 ¥ 6 = 48 sub-keys
are required for the rounds) and the final Output Transformation uses four sub-keys (making a total of 48
+ 4 = 52 sub-keys overall). From an input key of 128 bits, how are these 52 sub-keys generated? Let us
understand this with the explanation for the first two rounds. Based on the understanding of the sub-key
generation process for the first two rounds, we will later tabulate the sub-key generation for all the
rounds.
• First round We know that the initial key consists of 128 bits, from which 6 sub-keys K1 to K6 are
generated for the first round. Since K1 to K6 consist of 16 bits each, out of the original 128 bits, the first
96 bits (6 sub-keys ¥ 16 bits per sub-key) are used for the first round. Thus, at the end of the first round,
bits 97-128 of the original key are unused. This is shown in Fig. 3.49.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 119
P1 P2 P3 P4
K1 Multiply* Add* K3
K2 Add* Multiply* K4
XOR
XOR
K5 Multiply*
Add*
Multiply* K6
Add* XOR
XOR
XOR XOR
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
R1 R2 R3 R4
• Second round In the second round, firstly, the 32 unused bits (i.e. bits 97-128) of the first round are
used. We know that each round requires 6 sub-keys K1 to K6, each of 16 bits, making a total of 96 bits.
Thus, for the second round, we still require (96 – 32 = 64) more bits. However, we have already
exhausted all the 128 bits of the original key. How do we now get the remaining 64 bits? For this, IDEA
employs the technique of key shifting. At this stage, the original key is shifted left circularly by 25 bits.
That is, the 26th bit of the original key moves to the first position and becomes the first bit after the shift
and the 25th bit of the original key moves to the last position and becomes the 128th bit after the shift. The
whole process is shown in Fig. 3.50.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
120 Cryptography and Network Security
These 32 bits are used now. Bits 97-112 become K1. bits
Unused (Bits 97-128)
113-128 become K2. The key is exhausted now.
Sub-keys K1 and K2 are ready for round 2. Now, the original key is
exhausted. It is circular-left shifted by 25 bits.
Fig. 3.50 Circular-left key shift and its use in sub-key generation for round 2
We can now see that the second round uses the bits 97-128 of the first round, and after a 25-bit shift
bits 1-64. For the third round, we then use the remaining bits, i.e. bits 65-128 (i.e. a total of 64 bits).
Again a shift on 25 bits occurs, and post this shifting, bits 1-32 are used in the third round, and so on.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 121
Thus, is every round, 96 bits are obtained in the same manner, and this is how a 128-bit Key is divided
into 96-bit subkeys.
1 Bit positions 1-96 of the initial 128-bit key would be used. This would give us 6 sub-keys K1 to K6
for Round 1. Key bits 97 to 128 are available for the next round.
2 Key bits 97 to 128 make up sub-keys K1 and K2 for this round. A 25-bit shift on the original key
happens, as explained. Post this shifting; the first 64 bits are used as sub-keys K3 to K6 for this
round. This leaves bits 65 to 128 unused for the next round.
3 Unused key bits 65 to 128 are used as sub-keys K1 to K4 of this round. Upon key exhaustion,
another 25-bit shift happens, and bits 1 to 32 of the shifted key are used as sub-keys K5 and K6.
This leaves bits 33 to 128 unused for the next round.
4 Bits 33 to 128 are used for this round, which is perfectly adequate. No bits are unused at this stage.
After this, the current key is again shifted.
5 This is similar to Round 1. Bit positions 1-96 of the current 128-bit key would be used. This would
give us 6 sub-keys K1 to K6 for Round 1. Key bits 97 to 128 are available for the next round.
6 Key bits 97 to 128 make up sub-keys K1 and K2 for this round. A 25-bit shift on the original key
happens, as explained. Post this shifting; the first 64 bits are used as sub-keys K3 to K6 for this
round. This leaves bits 65 to 128 unused for the next round.
7 Unused key bits 65 to 128 are used as sub-keys K1 to K4 of this round. Upon key exhaustion,
another 25-bit shift happens, and bits 1 to 32 of the shifted key are used as sub-keys K5 and K6.
This leaves bits 33 to 128 unused for the next round.
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
8 Bits 33 to 128 are used for this round, which is perfectly adequate. No bits are unused at this stage.
After this, the current key is again shifted for the Output Transformation round.
At the end of the last round, we have no unused bits. They are used in the Output Transformation.
Output Transformation The Output Transformation is a one-time operation. It takes place at the
end of the 8th round. The input to the Output Transformation is, of course, the output of the 8th round.
This is, as usual, a 64-bit value divided into four sub-blocks (say R1 to R4, each consisting of 16 bits).
Also, four sub-keys are applied here and not six. We will describe the key generation process for the
Output Transformation later. For now, we shall assume that four 16-bit sub-keys K1 to K4 are available
to the Output Transformation. The process of the Output Transformation is described in Fig. 3.51.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
122 Cryptography and Network Security
R1 R2 R3 R4
K1 Multiply* Add* K3
K2 Add* Multiply* K4
C1 C2 C3 C4
Sub-key Generation for the Output Transformation The process for the sub-key generation for
the Output Transformation is exactly similar to the sub-key generation process for the eight rounds.
Recall that at the end of the eighth and the final round, the key was exhausted. Hence, the key is again
shifted by 25 bits. Post this shift operation, the first 64 bits of the key are taken, and are called as sub-
keys K1 to K4 for the final output Transformation round.
IDEA Decryption The decryption process is exactly the same as the encryption process. There are
some alterations in the generation and pattern of sub-keys. The decryption sub-keys are actually
inverses of the encryption sub-keys. We shall not discuss this any further, as the basic concepts remain
the same.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 123
The Strength of IDEA IDEA uses a 128-bit key, which is double than the key size of DES. Thus, to
break into IDEA, 2128 (i.e. 1038) encryption operations would be required. As before, even if we assume
that to obtain the correct key, only half of the possible keys (i.e. the half of the key space) needs to be
examined and tried out, a single computer performing one IDEA encryption per microsecond would
require more than 5400000000000000000000000 years to break IDEA!
3.6 RC4
3.6.1 Background
RC4 was designed by Ron Rivest of RSA Security in 1987. The official name for this algorithm is
“Rivest Cipher 4”. However, because of its ease of reference, the acronym RC4 has stuck.
RC4 is a stream cipher. This means that the encryption happens byte-by-byte. However, this can be
changed to bit-by-bit encryption (or to a size other than a byte/bit).
RC4 was initially kept secret. However, in September 1994, a description of the algorithm was
anonymously posted to the Cypherpunks mailing list. Thereafter, it was posted on the sci.crypt
newsgroup and from there to many other Internet sites. Because the algorithm is now well known, it is no
longer a secret. However, we should note that there is a trademark associated with the name “RC4”.
An interesting remark says that “The current status seems to be that unofficial implementations are
legal, but cannot use the RC4 name.”
RC4 has become part of some widely used encryption techniques and standards, including Wireless
Equivalent Privacy (WEP) and WPA for wireless cards and TLS. What has made its wide deployment
possible is its speed and simplicity of design. Implementations in both software and hardware are
possible. RC4 does not consume many resources.
3.6.2 Description
RC4 generates a pseudorandom stream of bits called as keystream. This is combined with the plain text
using XOR for encryption. Even decryption is performed in a similar manner.
Let us understand this in more detail in the following paragraphs..
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
There is a variable length key consisting of 1 to 256 bytes (or 8 to 2048 bits). This key is used to
initialize a 256-byte state vector with elements identified as S[0].S[1]. ...., S[255]. To perform
encryption or decryption operation, one of these 256 bytes of S is selected and processed. We will call
the resulting output as k. After this, the entries in S are permuted once again.
Overall, there are two processes involved: (a) Initialization of S and (b) Stream generation. We
describe these as follows:
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
124 Cryptography and Network Security
// Now copy the contents of the current position of the K array into T. If K is exhausted, loop back
// to get the values of the K array from the un-exhausted portion of K.
T [i] = K [i mod keylen];
A small Java program shown in Fig. 3.53 implements this logic. Here, we have considered that the K
array contains 10 elements, i.e. keylen is 10.
int[] S, T, K;
S = new int [255];
T = new int [255];
K = new int [255];
int i;
int keylen = 10;
After this, the T array is used to produce initial permutation of S. For this purpose, a loop executes,
iterating i from 0 to 255. In each case, the byte at the position S[i] is swapped with another byte in the S
array, as per an arrangement decided by T[i]. For this purpose, the following logic is used:
j = 0;
for i = 0 to 255
j = (j + S [i] + T [i]) mod 256;
swap (S [i], S [j]);
Note that this is just a permutation. The values of S are simply being rearranged, not changed. The
corresponding Java portion is shown in Fig. 3.54.
Stream Generation Now that the S array is ready with the above initializations and permutations,
the initial key array K is discarded. Now, we need to again loop for i = 0 to 255. In each step, we swap S
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 125
// Initial permutation of S
int j = 0, temp;
[i] with another byte in S, as per the mechanism decided by the implementation of S. Once we exhaust
the 255 positions, we need to restart at S[0].
The logic is as follows:
i = 0;
j = 0;
while (true)
i = (i + 1) mod 256;
j = (j + S [i]) mod 256;
swap (S [i], S [j]);
t = (S [i] + S [j]) mod 256;
k = S [t];
After this, for encryption, k is XORed with the next byte of the plain text. For decryption, k is XORed
with the next byte of the cipher text.
Some vulnerability has been found in RC4, hence it is not recommended for new applications.
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
3.7 RC5
3.7.1 Background and History
RC5 is a symmetric key block encryption algorithm developed by Ron Rivest. The main features of RC5
are that it is quite fast as it uses only the primitive computer operations (such as addition, XOR, shift,
etc). It allows for a variable number of rounds and a variable bit-size key to add to the flexibility.
Different applications that demand varying security needs can set these values accordingly. Another
important aspect is that RC5 requires less memory for execution and is, therefore, suitable not only for
desktop computers, but also for smart cards and other devices that have a small memory capacity. It has
been incorporated into the RSA Data Security Incorporation’s products such as BSAFE, JSAFE and S/
MAIL.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
126 Cryptography and Network Security
Principles of Operation At first, RC5 appears to be complicated because of the notations used.
However, it is actually quite simple to understand. Rather than getting into notations, we shall first
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
illustrate the working of RC5 using Fig. 3.55. As shown in the figure, there is one initial operation
consisting of two steps (shown shaded), then a number of rounds. As we have noted, the number of
rounds (r) can vary from 0 to 255.
For simplicity, we shall assume that we are working on an input plain block with size 64 bits. The
same principles operation will apply to other block sizes, in general.
In the first two steps of the one-time initial operation, the input plain text is divided into two 32-bit
blocks A and B. The first two sub-keys (we shall later see how they are generated) S[0] and S[1] are
added to A and B, respectively. This produces C and D respectively and marks the end of the one-time
operation.
Then, the rounds begin. In each round, there are following operations:
• Bit-wise XOR
• Left circular-shift
• Addition with the next sub-key, for both C and D – This is the addition operation first and then the
result of the addition mod 2w (since w = 32 here, we have 232) is performed.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 127
Increment i by 1.
Call F as C
(i.e. C = F) No Check:
Call H as D Is i > r?
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
(i.e. D = H)
Yes
Stop
If we observe the operations shown in the figure carefully, we will note that the output of one block is
fed back as the input to another block, making the whole logic quite complicated to decipher.
Let us now look at the algorithm details in step-by-step fashion in the next few sections.
One-time Initial Operation We will first take a look at the one-time initial operation, as shown in
Fig. 3.56. This consists of two simple steps: first, the input plain text is divided into two equal-sized
blocks, A and B. Then the first sub-key, i.e. S[0] is added to A and the second sub-key, i.e. S[1] is added
to B. These operations are mod 232, as we have noted and produce C and D, respectively.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
128 Cryptography and Network Security
A B
A B
S[0] + + S[1]
C D
Details of One Round Now, we observe the results for the first round. The process for the first
round will apply for further rounds. Therefore, we shall not discuss those rounds separately.
Step 1: XOR C and D In the first step of each round, C and D are XORed together to form E, as
shown in Fig. 3.57.
C D
XOR
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
Step 2: Circular-left shift E Now, E is circular-left shifted by D positions, as shown in Fig. 3.58.
D F
XOR
Step 5: Circular-left shift G This step is similar to Step 2. Here, G is circular-left shifted by F
positions, as shown in Figure 3.61.
G
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
i = i + 1
If i < r
Call F as C again
Call H as D again
Go back to step 1
Else
Stop
End-if
Mathematical Representation Interestingly, all these operations (one-time initial operation and all
the rounds) in RC5 can be signified mathematically in a very cryptic fashion, as shown in Fig. 3.64. Note
that <<< means circular-left shift.
A = A + S[0]
B = B + S[1]
For i = 1 to r
A = ((A XOR B) <<< B) + S[2i]
B = ((B XOR A) <<< A) + S[2i + 1]
Next i
Furthermore, we will also write the mathematical representation of RC5 decryption process as shown
in Fig. 3.65 and leave its verification as an exercise. Note that >>> means circular right-shift.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 131
Sub-key Creation Let us now examine the sub-key creation process in RC5. This is a two-step
process.
1. In the first step, the sub-keys (denoted by S[0], S[1], …) are generated.
2. The original key is called as L. In the second step, the sub-keys (S[0], S[1], …) are mixed with the
corresponding sub-portions of the original key (i.e. L[0], L[1], …).
This is shown in Fig. 3.66.
3.8 Blowfish
3.8.1 Introduction
Blowfish was developed by Bruce Schneier and has the reputation of being a very strong symmetric key
cryptographic algorithm. According to Schneier, Blowfish was designed with the following objectives
in mind.
• Fast – Blowfish encryption rate on 32-bit microprocessors is 26 clock cycles per byte.
• Compact – Blowfish can execute in less than 5 kb memory.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
132 Cryptography and Network Security
Set S[0] = P
Calculate A = S[i – 1] + Q
S[i] = B
Increment i by 1
Yes Check:
Is i < 2(r + 1) - 1?
No
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
Stop
S[0] = P
For i = 1 to 2 (r + 1) – 1
S[i] = (S[i – 1] + Q) mod 232
Next i
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 133
i = j = 0
A = B = 0
i = (i + 1) mod 2 (r + 1)
j = (j + 1) mod c
End-do
Mode Description
RC5 block cipher This is also called as Electronic Codebook (ECB) mode. It involves encryption
of fixed-size input blocks consisting of 2w bits into cipher text block of the same
length.
RC5-CBC This is the Cipher Chaining Block for RC5. In this, plain text messages whose
length is equal to a multiple of the RC5 block size (i.e. multiple of 2w bits) are
encrypted. This mode offers better security, as the same plain text blocks in the
input produce different cipher text blocks in the output.
RC5-CBC-Pad This is a modified version of CBC. Here, the input can be of any length. The
cipher text is longer than the plain text by at the most the size of a single RC5
block. To handle length mismatches, padding is used. This makes the length of a
message equal to a multiple of 2w bits. The length of the original message is
considered to be a specific number of integer number of bytes. Padding of length
1 to bb bytes is added to the end of the message. How many such padding bytes
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
• Simple – Blowfish uses only primitive operations, such as addition, XOR and table lookup,
making its design and implementation simple.
• Secure – Blowfish has a variable key length up to a maximum of 448 bits long, making it both
flexible and secure.
Blowfish suits applications where the key remains constant for a long time (e.g. communications link
encryption), but not where the key changes frequently (e.g. packet switching).
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
134 Cryptography and Network Security
3.8.2 Operation
Blowfish encrypts 64-bit blocks with a variable-length key. It contains two parts, as follows.
• Subkey generation: This process converts the key up to 448 bits long to sub-keys totaling
4168 bits.
• Data encryption: This process involves the iteration of a simple function 16 times. Each round
contains a key-dependent permutation and key- and data-dependent substitution.
We shall now discuss these two parts.
Subkey Generation Let us understand the important aspects of the subkey generation process step-
by-step.
(i) Blowfish makes use of a very large number of subkeys. These keys have to be ready before
encryption and decryption happen. The key size ranges from 32 bits to 448 bits. In other words, the
key size ranges from 1 to 14 words, each comprising word of 32 bits. These keys are stored in an
array, as follows:
K1, K2, …, Kn where each block contains 32 bits
(ii) We then have the concept of a P-array, consisting of 18 32-bit subkeys:
P1, P2… P18
Creation of the P-array is described subsequently.
(iii) Four S-boxes, each containing 256 32-bit entries:
S1,0, S1,1 …, S1,255
S2,0, S2,1 …, S2,255
S3,0, S3,1 …, S3,255
S4,0, S4,1 …, S4,255
Creation of the S-boxes is described subsequently.
Now let us examine how all this information is used to generate subkeys.
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
(i) Initialize the P-array first, followed by the four S-boxes, with a fixed string. Schneier recommends
the usage of the bits of the fractional part (in hexadecimal form) of the constant pi (p) for this
purpose. Thus, we will have:
P1 = 243F6A88
P2 = 85A308D3
….
S4,254 = 578FDFE3
S4,255 = 3AC372E6
(ii) Do a bitwise XOR of P1 with K1, P2 with K2, etc, until P18. This works fine till P14 and K14. At
this stage, the key array (K) is exhausted. Hence, for P15 to P18, reuse K1 to K4. In other words,
do the following:
P1 = P1 XOR K1
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 135
P2 = P2 XOR K2
….
P14 = P14 XOR K14
P15 = P15 XOR K1
P16 = P16 XOR K2
P17 = P17 XOR K3
P18 = P18 XOR K4
(iii) Now take a 64-bit block, with all the 64 bits initialized to value of 0. Use the above P-arrays and S-
boxes above (the P-arrays and S-boxes are called as subkeys) to run the Blowfish encryption
process (described in the next section) on the 64-bit all-zero block. In other words, to generate the
subkeys themselves, the Blowfish algorithm is used. It is needless to say that once the final
subkeys are ready, the Blowfish algorithm would be used to encrypt the actual plain text.
This step would produce 64-bit cipher text. Divide this into two 32-bit blocks and replace the
original values of P1 and P2 with these 32-bit block values, respectively.
(iv) Encrypt the output of Step (iii) above using Blowfish with the modified subkeys. The resulting
output would again consist of 64 bits. As before, divide this into two blocks of 32 bits each. Now,
replace P3 and P4 with the contents of these two cipher text blocks.
(v) In the same manner, replace all the remaining P-arrays (i.e. P5 through P18) and then all the
elements of the four S-boxes, in order. In each step, the output of the previous step is fed to the
Blowfish algorithm to generate the next two 32-bit blocks of the subkey (i.e. P5 and P6, followed
by P7 and P8, etc).
In all, 521 iterations of the Blowfish algorithm are required to generate all P-arrays and S-boxes.
Data Encryption and Decryption The encryption of a 64-bit block plain text input X is shown in an
algorithmic fashion in Fig. 3.70. We use the P-arrays and S-boxes during the encryption and decryption
processes.
1. Divide X into two blocks: XL and XR, of equal sizes. Thus, both XL
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
2. For i = 1 to 16
XL = XL XOR Pi
XR = F (XL) XOR XR
Swap XL, XR
Next i
4. XL = XL XOR P18.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
136 Cryptography and Network Security
P1 (32 bits)
XOR F XOR
P2 (32 bits)
XOR F XOR
13 more rounds
32 bits 32 bits
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 137
8 bits 32 bits
S-box 1
XOR
32 bits
8 bits
32-bit S-box 2 XOR
XL block
8 bits 32 bits
S-box 4
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
138 Cryptography and Network Security
13 more rounds
P3 (32 bits)
XOR F XOR
32 bits 32 bits
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
(i) Symmetric and parallel structure – This gives the implementers of the algorithm a lot of flexibility.
It also stands up well against cryptanalysis attacks.
(ii) Adapted to modern processors – The algorithm works well with modern processors (Pentium,
RISC, parallel).
(iii) Suited to smart cards – The algorithm can work well with smart cards.
Rijndael supports key lengths and plain text block sizes from 128 bits to 256 bits, in the steps of
32 bits. The key length and the length of the plain text blocks need to be selected independently. AES
mandates that the plain text block size must be 182 bits and key size should be 128, 192 or 256 bits. In
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 139
general, two versions of AES are used: 128-bit plain text block combined with 128-bit key block and
128-bit plain text block with 256-bit key block.
Since the 128-bit plain text block and 128-bit key length are likely to pair as a commercial standard,
we will examine that case only. Other principles remain the same. Since 128 bits give a possible key
range of 2128 or 3 x 1038 keys, Andrew Tanenbaum outlines the strength of this key range in his un-
imitable style:
Even if NSA manages to build a machine with 1 billion parallel procesors, each being able to
evaluate one key per picosecond, it would take such a machine about 1010 years to search the
key space. By then the sun would have burned out, so the folks then present will have to read
the results by candlelight.
3.9.2 Operation
The basics of Rijndael are in a mathematical concept called as Galois field theory. For the current
discussion, we will keep those concepts out and try and figure out how the algorithm itself works at a
conceptual level.
Similar to the way DES functions, Rijndael also uses the basic techniques of substitution and
transposition (i.e. permutation). The key size and the plain text block size decide how many rounds need
to be executed. The minimum number of rounds is 10 (when key-size and the plain text block size are
each 128 bits) and the maximum number of rounds is 14. One key differentiator between DES and
Rijndael is that all the Rijndael operations involve entire byte and not individual bits of a byte. This
provides for more optimized hardware and software implementation of the algorithm.
Figure 3.74 describes the steps in Rijndael at a high level.
(a) Expand the 16-byte key to get the actual Key block to be used.
(b) Do one time initialization of the 16-byte plain text block (called as State).
(b) Rotate row k of the plain text block (i.e. state) by k bytes.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
140 Cryptography and Network Security
(a) Expand the 16-byte Key to get the Actual Key Block to be Used The inputs to the algorithm
are the key and the plain text, as usual. The key size is 16 bytes, in this case. This Step expands this 16-
byte key into 11 arrays, each array contains 4 rows and 4 columns. Conceptually, the key expansion
process can be depicted as shown in Fig. 3.75.
16-byte key
16-byte key
Copied, as is
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 141
// First copy all the 16 input key blocks into first four words of output key
for (i = 0; i < 4; i++) {
W [i] = K [4*i], K [4*i + 1], K [4*i + 2], K [4*i + 3];
}
if (i mod 4 == 0)
tmp = Substitute (Rotate (temp)) XOR Constant [i/4];
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
(i) Function Rotate performs a circular left shift on the contents of the word by one byte. Thus, if an
input word contains four bytes numbered [B1, B2, B3, B4]; then the output word would contain
[B2, B3, B4, B1].
(ii) Function Substitute performs a byte substitution on each byte of the input word. For this purpose,
it uses an S-box, shown in Fig. 3.79.
Y
0 1 2 3 4 5 6 7 8 9 a b c d e f
0 63 7c 77 7b f2 6b 6f c5 30 01 67 2b fe d7 ab 76
1 ca 82 c9 7d fa 59 47 f0 ad d4 a2 af 9c a4 72 c0
2 b7 fd 93 26 36 3f f7 cc 34 a5 e5 f1 71 d8 31 15
3 04 c7 23 c3 18 96 05 9a 07 12 80 e2 eb 27 b2 75
4 09 83 2c 1a 1b 6e 5a a0 52 3b d6 b3 29 e3 2f 84
5 53 d1 00 ed 20 fc b1 5b 6a cb be 39 4a 4c 58 cf
6 d0 ef aa fb 43 4d 33 85 45 f9 02 7f 50 3c 9f a8
7 51 a3 40 8f 92 9d 38 f5 bc b6 da 21 10 ff f3 d2
X
8 cd 0c 13 ec 5f 97 44 17 c4 a7 7e 3d 64 5d 19 73
9 60 81 4f dc 22 2a 90 88 46 ee b8 14 de 5e 0b db
a e0 32 3a 0a 49 06 24 5c c2 d3 ac 62 91 95 e4 79
b e7 c8 37 6d 8d d5 4e a9 6c 56 f4 ea 65 7a ae 08
c ba 78 25 2e 1c a6 b4 c6 e8 dd 74 1f 4b bd 8b 8a
d 70 3e b5 66 48 03 f6 0e 61 35 57 b9 86 c1 1d 9e
e e1 f8 98 11 69 d9 8e 94 9b 1e 87 e9 ce 55 28 df
f 8c a1 89 0d bf e6 42 68 41 99 2d 0f b0 54 bb 16
Round number 1 2 3 4 5 6 7 8 9 10
Value of constant to be used in Hex 01 02 04 08 10 20 40 80 1B 36
Fig. 3.80 Values of constants per round, to be used in the Constant function
Let us understand how the whole thing works, with an example.
1. Suppose that our original unexpanded 4-word (i.e. 16-byte) key is as shown in Fig. 3.81.
Byte position 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
(Decimal)
Value (Hex) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 143
2. In the first four rounds, the original 4-word input key would be copied into the first 4-word output
key, as per our algorithm step as follows:
// First copy all the 16 input key blocks into first four words of output key
f o r (i = 0; i < 4; i++) {
W [ i ] = K [4*i], K [4*i + 1], K [4*i + 2], K [4*i + 3];
}
Thus, the first 4 words of the output key (i.e. from W [0] to W [3]) would contain values as shown
in Fig. 3.82. This is constructed from the input 4-word (i.e. 16-byte) key as follows:
(a) Firstly, the first four bytes, i.e. one word, of the input key, namely 00 01 02 03 is copied
into the first word of the output key W [0].
(b) Now, the next four bytes of the input key, i.e. 04 05 06 07 would be copied into the second
word of the output key, i.e. W [1].
Needless to say, W [2] and W [3] would get populated with the remaining contents of the input key
bytes, as shown in the figure.
00 01 02 03 04 05 06 07 08 00 0A 0B 0C 0D 0E 0F ? ? ? ?
Fig. 3.82 Key expansion example – Step 2 – Filling of first 4 output key words
3. Now let us understand how the next word of the output key block, i.e. W [4] is populated. For this
purpose, the following algorithm would be executed:
// Now populate the remaining output key words (i.e. W5 to W43)
f o r (i = 4; i < 44; i++) {
tmp = W [i 1];
i f (i mod 4 == 0)
tmp = Substitute (Rotate (temp)) XOR Constant [i/4];
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
144 Cryptography and Network Security
need to pad this with three more bytes, all set to 00. Therefore, our constant value is 01 00 00 00.
So, we have:
D7 AB 76 FE
XOR
10 00 00 00
= D6 AB 76 FE
Thus, our new tmp value is D6 AB 76 FE.
• Finally, we need to XOR this tmp value with W [i – 4], i.e. with W [4 – 4], i.e. with W [0]. Thus, we
have:
D6 AB 76 FE
XOR
00 01 02 03
= D6 AA 74 FD
Thus, W [4] = D6 AA 74 FD.
We can use the same logic to derive the remaining expanded key blocks (W [5] to W [44]).
(b) Do One Time Initialization of the 16-byte Plain Text Block (Called as State) This step is
relatively simple. Here, the 16-byte plain text block is copied into a two-dimensional 4 ¥ 4 array called
as state. The order of copying is in the column order. That is, the first four bytes of the plain text block
get copied into the first column of the state array, the next four bytes of the plain text block get copied
into the second column of the state array and so on. This is shown in Fig. 3.83 for every byte (numbered
from B1 to B16).
B1 B5 B9 B13
B2 B6 B10 B14
B3 B7 B11 B15
B4 B8 B12 B16
State array
Fig. 3.83 Copying of the input text block into state array
(c) XOR the State with the Key block Now, the first 16 bytes (i.e. four words W [0], W [1], W [2]
and W [3]) of the expanded key are XORed into the 16-byte state array (B1 to B16 shown above). Thus,
every byte in the state array is replaced by the XOR of itself and the corresponding byte in the expanded
key.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 145
At this stage, the initialization is complete and we are ready for rounds.
(a) Apply S-box to Each of the Plain Text Bytes. This step is very straightforward. The contents
of the state array are looked up into the S-box. Byte by byte substitution is done to replace the contents
of the state array with the respective entries in the S-box. Note that only one S-box is used, unlike DES,
which has multiple S-boxes.
(b) Rotate Row k of the Plain Text Block (i.e. state) by k Bytes. Here, each of the four rows of
the state array are rotated to the left. Row 0 is rotated 0 bytes (i.e. not rotated at all), row 1 is rotated by
1 byte, row 2 is rotated 2 bytes and row 2 is rotated 3 bytes. This helps in diffusion of data. Thus, if the
original 16 bytes of the state array contain values 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 then the
rotate operation would change the values as follows:
Original array Modified array
1 5 9 13 1 5 9 13
2 6 10 14 6 10 14 2
3 7 11 15 11 15 3 7
4 8 12 16 16 4 8 12
(c) Perform a Mix Columns Operation Now, each column is mixed independent of the other.
Matrix multiplication is used. The output of this step is the matrix multiplication of the old values and a
constant matrix.
This is perhaps the most complex step to understand and also to explain. Nevertheless, we will make
an attempt! This is based on a nice article by Adam Berent.
There are two aspects of this step. The first explains which parts of the state are multiplied against
which parts of the matrix. The second explains how this multiplication is implemented over what’s
called as a Galois Field.
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
(c.1) Matrix Multiplication We know that the state is arranged into a 4 ¥ 4 matrix.
The multiplication is performed one column at a time (i.e. on 4 bytes at a time). Each value in the
column is eventually multiplied against every value of the matrix (i.e. 16 total multiplications are
performed). The results of these multiplications are XORed together to produce only 4 resulting bytes
for the next state. We together have 4 bytes input, 16 multiplications, 12 XORs and 4 bytes output. The
multiplication is performed one matrix row at a time against each value of a state column.
For example, consider that our matrix is as shown in Fig. 3.84.
2 3 1 1
1 2 3 1
1 1 2 3
3 1 1 2
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
146 Cryptography and Network Security
Next, let us imagine that the 16-byte state array is as shown in Fig. 3.85.
b1 b5 b9 b13
b2 b6 b10 b14
b3 b7 b11 b15
b4 b8 b12 b16
manner:
b1 = (b1 * 2) XOR (b2*3) XOR (b3*1) XOR (b4*1)
b2 = (b1 * 1) XOR (b2*2) XOR (b3*3) XOR (b4*1)
b3 = (b1 * 1) XOR (b2*1) XOR (b3*2) XOR (b4*3)
b4 = (b1 * 3) XOR (b2*1) XOR (b3*1) XOR (b4*2)
(b1= specifies the first byte of the state)
The second column will be multiplied against the second row of the matrix in the following manner.
b5 = (b5 * 2) XOR (b6*3) XOR (b7*1) XOR (b8*1)
b6 = (b5 * 1) XOR (b6*2) XOR (b7*3) XOR (b8*1)
b7 = (b5 * 1) XOR (b6*1) XOR (b7*2) XOR (b8*3)
b8 = (b5 * 3) XOR (b6*1) XOR (b7*1) XOR (b8*2)
And so on until all columns of the state are exhausted.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 147
(c.2) Galois Field Multiplication The multiplication mentioned above is performed over a Galois
Field. The mathematics behind this is quite complex and beyond the scope of the current text. However,
we will discuss the implementation of the multiplication, which can be done quite easily with the use of
the following two tables, shown in hexadecimal formats. Refer to Fig. 3.86 and Fig. 3.87.
0 1 2 3 4 5 6 7 8 9 A B C D E F
0 01 03 05 0F 11 33 55 FF 1A 2E 72 96 A1 F8 13 35
1 5F E1 38 48 D8 73 95 A4 F7 02 06 0A 1E 22 66 AA
2 E5 34 5C E4 37 59 EB 26 6A BE D9 70 90 AB E6 31
3 53 F5 04 0C 14 3C 44 CC 4F D1 68 B8 D3 6E B2 CD
4 4C D4 67 A9 E0 3B 4D D7 62 A6 F1 08 18 28 78 88
5 83 9E B9 D0 6B BD DC 7F 81 98 B3 CE 49 DB 76 9A
6 B5 C4 57 F9 10 30 50 F0 0B 1D 27 69 BB D6 61 A3
7 FE 19 2B 7D 87 92 AD EC 2F 71 93 AE E9 20 60 A0
8 FB 16 3A 4E D2 6D B7 C2 5D E7 32 56 FA 15 3F 41
9 C3 5E E2 3D 47 C9 40 C0 5B ED 2C 74 9C BF DA 75
A 9F BA D5 64 AC EF 2A 7E 82 9D BC DF 7A 8E 89 80
B 9B B6 C1 58 E8 23 65 AF EA 25 6F B1 C8 43 C5 54
C FC 1F 21 63 A5 F4 07 09 1B 2D 77 99 B0 CB 46 CA
D 45 CF 4A DE 79 8B 86 91 A8 E3 3E 42 C6 51 F3 0E
E 12 36 5A EE 29 7B 8D 8C 8F 8A 85 94 A7 F2 0D 17
F 39 4B DD 7C 84 97 A2 FD 1C 24 6C B4 C7 52 F6 01
0 1 2 3 4 5 6 7 8 9 A B C D E F
0 00 19 01 32 02 1A C6 4B C7 1B 68 33 EE DF 03
1 64 04 E0 0E 34 8D 81 EF 4C 71 08 C8 F8 69 1C C1
2 7D C2 1D B5 F9 B9 27 6A 4D E4 A6 72 9A C9 09 78
3 65 2F 8A 05 21 0F E1 24 12 F0 82 45 35 93 DA 8E
4 96 8F DB BD 36 D0 CE 94 13 5C D2 F1 40 46 83 38
5 66 DD FD 30 BF 06 8B 62 B3 25 E2 98 22 88 91 10
6 7E 6E 48 C3 A3 B6 1E 42 3A 6B 28 54 FA 85 3D BA
7 2B 79 0A 15 9B 9F 5E CA 4E D4 AC E5 F3 73 A7 57
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
8 AF 58 A8 50 F4 EA D6 74 4F AE E9 D5 E7 E6 AD E8
9 2C D7 75 7A EB 16 0B F5 59 CB 5F B0 9C A9 51 A0
A 7F 0C F6 6F 17 C4 49 EC D8 43 1F 2D A4 76 7B B7
B CC BB 3E 5A FB 60 B1 86 3B 52 A1 6C AA 55 29 9D
C 97 B2 87 90 61 BE DC FC BC 95 CF CD 37 3F 5B D1
D 53 39 84 3C 41 A2 6D 47 14 2A 9E 5D 56 F2 D3 AB
E 44 11 92 D9 23 20 2E 89 B4 7C B8 26 77 99 E3 A5
F 67 4A ED DE C5 31 FE 18 0D 63 8C 80 C0 F7 70 07
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
148 Cryptography and Network Security
vertical index. For example if the two Hex values being multiplied are AF * 8 we first lookup L (AF)
index which returns B7 and then lookup L (08) which returns 4B. Once the L table lookup is complete
we can then simply add the numbers together. The only trick being that if the addition result is greater
than FF, we subtract FF from the addition result. For example B7+4B= 102. Because 102 > FF, we
perform: 102-FF which gives us 03.
The last step is to look up the addition result on the E table. Again we take the first digit to look up the
vertical index and the second digit to look up the horizontal index.
For example E(03)=0F. Therefore, the result of multiplying AF * 8 over a Galois Field is 0F.
(d) XOR the State with the Key Block. This Step XORs the key for this round into the state array.
For decryption, the process can be executed in the reverse order. There is another option, though. The
same encryption process, run with some different table values, can also perform decryption.
SUMMARY
G In symmetric key cryptography, the sender and the receiver share a single key and the same key is
used for both encryption and decryption.
G Some of the important symmetric key cryptographic algorithms are DES (and its variations),
IDEA, RC4, RC5 and Blowfish.
G An algorithm type defines what size of plain text should be encrypted in each step of the algorithm.
G There are two main types of algorithms: stream cipher and block cipher.
G In stream cipher, each bit/byte of text is encrypted/decrypted individually.
G In block cipher, a block of text is encrypted/decrypted at a time.
G An algorithm mode defines the details of the cryptographic algorithm, once the type is decided.
G Confusion is a technique of ensuring that a cipher text gives no clue about the original plain text.
G Diffusion increases the redundancy of the plain text by spreading it across rows and columns.
G There are four important algorithm modes: Electronic Code Book (ECB), Cipher Block Chaining
(CBC), Cipher Feedback (CFB) and Output Feedback (OFB).
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 149
G The Counter (CTR) mode is quite similar to the OFB mode, with one variation. It uses sequence
numbers called as counters as the inputs to the algorithm. After each block is encrypted, to fill the
register, the next counter value is used.
G There are two problems in symmetric key encryption: problem of key exchange and one key is
required per communication pair.
G The Data Encryption Standard (DES), also called as the Data Encryption Algorithm (DEA) by
ANSI and DEA-1 by ISO, has been a cryptographic algorithm used for over two decades. Of late,
DES has been found vulnerable against very powerful attacks, therefore, the popularity of DES has
been slightly on the decline.
G DES is a block cipher. It encrypts data in blocks of size 64 bits each. That is, 64 bits of plain text
goes as the input to DES, which produces 64 bits of cipher text. The same algorithm and key are
used for encryption and decryption, with minor differences. The key length is 56 bits.
G In 1990, Eli Biham and Adi Shamir introduced the concept of differential cryptanalysis. This
method looks at pairs of cipher text whose plain texts have particular differences. The technique
analyses the progress of these differences as the plain texts travel through the various rounds of
DES.
G Invented by Mitsuru Matsui, the linear cryptanalysis attack is based on linear approximations. If
we XOR some plain text bits together, XOR some cipher text bits together and then XOR the
result, we will get a single bit, which is the XOR of some of the key bits.
G Timing attacks refer more to asymmetric key cryptography. However, they can also apply to
symmetric key cryptography. The idea is simple: observe how long it takes for the cryptographic
algorithm to decrypt different blocks of cipher text. The idea is to try and obtain either the plain
text or the key used for encryption by observing these timings.
G Two main variations of DES have emerged, which are Double DES and Triple DES.
G Double DES is quite simple to understand. Essentially, it does twice what DES normally does only
once. Double DES uses two keys.
G Merkle and Hellman introduced the concept of the meet-in-the-middle attack. This attack involves
encryption from one end, decryption from the other and matching the results in the middle, hence
the name meet-in-the-middle attack.
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
G Triple DES is DES – three times. It comes in two flavours: one that uses three keys and the other
that uses two keys.
G The International Data Encryption Algorithm (IDEA) is perceived as one of the strongest
cryptographic algorithms.
G IDEA is a block cipher. Like DES, it also works on 64-bit plain text blocks. The key is longer, and
consists of 128 bits. IDEA is reversible like DES, that is, the same algorithm is used for encryption
and decryption. Also, IDEA uses both diffusion and confusion for encryption.
G RC4 was designed by Ron Rivest of RSA Security in 1987. The official name for this algorithm is
“Rivest Cipher 4”. However, because of its ease of reference, the acronym RC4 has stuck.
G RC4 is a stream cipher. This means that the encryption happens byte-by-byte. However, this can be
changed to bit-by-bit encryption (or to a size other than a byte/bit).
G RC5 is a symmetric key block encryption algorithm developed by Ron Rivest. The main features
of RC5 are that it is quite fast as it uses only the primitive computer operations (such as addition,
XOR, shift, etc). It allows for a variable number of rounds and a variable bit-size key to add to the
flexibility.
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
150 Cryptography and Network Security
G Blowfish was developed by Bruce Schneier and has the reputation of being a very strong
symmetric key cryptographic algorithm.
G Blowfish encrypts 64-bit blocks with a variable-length key.
G In the 1990s, the US Government wanted to standardize a cryptographic algorithm, which was to
be used universally by them. It was to be called as the Advanced Encryption Standard (AES).
Many proposals were submitted and after a lot of debate, an algorithm called as Rijndael was
accepted.
G Rijndael supports key lengths and plain text block sizes from 128 bits to 256 bits, in the Steps of
32 bits. The key length and the length of the plain text blocks need to be selected independently.
AES mandates that the plain text block size must be 182 bits and key size should be 128, 192 or
256 bits. In general, two versions of AES are used: 128-bit plain text block combined with 128-bit
key block and 128-bit plain text block with 256-bit key block.
PRACTICE SET
MULTIPLE-CHOICE QUESTIONS
1. In , one bit of plain text is encrypted at a time.
(a) stream cipher (b) block cipher
(c) both stream and block cipher (d) none of the above
2. In , one block of plain text is encrypted at a time.
(a) stream cipher (b) block cipher
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
Symmetric Key Algorithms and AES 151
(c) both stream and block cipher (d) none of the above
3. increases the redundancy of plain text.
(a) Confusion (b) Diffusion
(c) Both confusion and diffusion (d) Neither confusion nor diffusion
4. works on block mode.
(a) CFB (b) OFB
(c) CCB (d) CBC
5. DES encrypts blocks of bits.
(a) 32 (b) 56
(c) 64 (d) 128
6. There are rounds in DES.
(a) 8 (b) 10
(c) 14 (d) 16
7. is based on the IDEA algorithm.
(a) S/MIME (b) PGP
(c) SET (d) SSL
8. The actual algorithm in the AES encryption scheme is .
(a) Blowfish (b) IDEA
(c) Rijndael (d) RC4
9. The Blowfish algorithm executes the algorithm for subkey generation.
(a) Blowfish (b) IDEA
(c) Rijndael (d) RC4
10. In AES, the 16-byte key is expanded into .
(a) 200 bytes (b) 78 bytes
(c) 176 bytes (d) 184 bytes
11. In IDEA, the key size is .
(a) 128 bytes (b) 128 bits
(c) 256 bytes (d) 256 bits
Copyright © 2007. Tata McGraw-Hill. All rights reserved.
12. In the algorithm, once the initial key of 1-256 bytes is used to create a transformed
key, the original key is discarded.
(a) Blowfish (b) IDEA
(c) Rijndael (d) RC4
13. There are encryption rounds in RC5.
(a) 8 (b) 12
(c) 16 (d) 20
14. The RC5 block cipher mode is also called as .
(a) RC5 block cipher (b) RC5-CBC
(c) RC5-CBC-Pad (d) RC5-CTS
15. The step ensures that plain text is not vulnerable in block cipher mode.
(a) encryption (b) round
(c) initial (d) chaining
Kahate, Atul. Cryptography and Network Security, Tata McGraw-Hill, 2007. ProQuest Ebook Central,
http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121458.
Created from inflibnet-ebooks on 2021-09-21 06:14:45.
152 Cryptography and Network Security
EXERCISES
1. Distinguish between stream and block ciphers.
2. Discuss the idea of algorithm modes with detailed explanation of at least two of them.
3. Write a note on the security and possible vulnerabilities of the various algorithm modes.
4. What is an Initialization Vector (IV)? What is its significance?
5. What are the problems with symmetric key encryption?
6. What is the idea behind meet-in-the-middle attack?
7. Explain the main concepts in DES.
8. How can the same key be reused in triple DES?
9. Explain the principles of the IDEA algorithm.
10. Distinguish between differential and linear cryptanalysis.
11. Explain the subkey generation in the Blowfish algorithm.
12. Explain the usage of the S array in the case of the RC4 algorithm.
13. Discuss how encryption happen in RC5.
14. How does the one-time initialization step work in AES?
15. Explain the steps in the various rounds of AES.
DESIGN/PROGRAMMING EXERCISES
1. Write a C program to implement the DES algorithm logic.
2. Write the same program as in Step 1, in Java.
3. Write a Java program that contains functions, which accept a key and input text to be encrypted/
decrypted. This program should use the key to encrypt/decrypt the input by using the triple DES
algorithm. Make use of Java cryptography package.
4. Write a C program to implement the Blowfish algorithm.
5. Write the same program in VB.NET.
Copyright © 2007. Tata McGraw-Hill. All rights reserved.