Ch3-SecretKeyCryptography
Ch3-SecretKeyCryptography
Ch3-SecretKeyCryptography
net/publication/371641373
CITATIONS READS
0 1,134
1 author:
Asmelash Girmay
Mekelle University
6 PUBLICATIONS 1 CITATION
SEE PROFILE
All content following this page was uploaded by Asmelash Girmay on 19 June 2023.
Review on Cryptography
Cryptography has three-dimensions
1) Number of keys used
• Single key: symmetric/conventional/secret-key cryptography
• Two keys: asymmetric/public-key cryptography
• Zero key: hashing function
2) The way a plaintext to ciphertext conversion process
• Stream cipher
• Block cipher
3) Types of operations used for encryption – all encryption algorithms are based on:
• Substitution cipher: mono-alphabetic and poly-alphabetic
• Transposition cipher
Secret-key Cryptography
A secret key cryptography is commonly called conventional or symmetric cryptography. This type of
cryptography uses a shared secret key, by which a key is shared between the communicating parties. There
are two types of encipher processes, namely the stream ciphers and block ciphers. Conventional stream
ciphers such as Caesar, Shift, simple substitution, Playfair, Vigenere, and Hill. Conventional block ciphers
are those of modern ciphers such as S-DES, DES, AES, etc.
In addition to this, conventional cryptography algorithms operate in a substitution and transposition way.
Each of them will be discussed here below. In substitution conventional cryptography a plain letter is
substituted with a corresponding cipher letter. Whereas, in transposition conventional cryptography, a
ciphertext correspond of a given plaintext is generated by transposing, say, column wise or other way.
Substitution Cipher
A substitution cipher in which for a given key, each plaintext letter is substituted by one or more another
letter to create a ciphertext letter. For example, ‘A’ can be replaced with ‘F’ in throughout the encryption
process for monoalphabetic substitution, or changes with occurrence position for polyalphabetic
substitution. All in all, a plaintext letter is replaced with another letter that may or may not exist in the
plaintext arrangement. Example ciphers are one-time pad, Hill cipher, Vigenere Cipher, Beaufort Cipher,
Shift Cipher, etc.
D. Integrity Check
This is done by generating a fixed-length cryptographic checksum of the message to be sent. It is used to
protect accidental corruption of messages. Checksum works by breaking a message into fixed-length
blocks (for instance, 32-bit words) and adding them up.
• The sum is sent along with the message.
• The receiver repeats the operation and check with the sent checksum.
• If equal, integrity checked, otherwise message rejected.
However, cryptographic checksum unlike other checksums like CRC (Cyclic Redundancy Check) needs an
algorithm and secrete key. Given an algorithm and a key, the message produces fixed-length MAC
(Message Authentication Code). MAC sometimes called MIC (Message Integrity Code). MAC is popular,
whereas MIC is standard naming. A typical MAC is at least 48 bits long.
1. Caesar Cipher
The Caesar cipher, also known as a shift cipher, is one of the oldest and simplest cryptographic algorithms
for encryption and decryption of a message. It is a type of substitution cipher where each letter in the
original message (plaintext) is replaced with a third letter down in the alphabet. Here, the key is 3. Thus,
0 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
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
Table 1 Caesar cipher encryption/decryption shift of characters
Mathematically,
Let C be a cipher letter equivalence number, P be a plain letter equivalence number, and K be a key, i.e, 3.
As seen in table1, equivalent number for letter ‘T’ is 19. Using the key, 19+3 = 22. As 22 is number
equivalence of letter ‘W’, we can say that ‘T’ is encrypted as ‘W’. Thus, table1 is populated based on the
following general mathematical formula:
C = (P + K) mod 26
P = (C – K) mod 26
Encryption example: use table1 to encrypt the following plaintext.
• Plaintext: “I am a third year student”
• Ciphertext: “l dp d wklug bhdu vwxghqw”
2. Shift Cipher
In shift cipher, a random key between 0 and 25 is used. As a result, a plaintext letter is shifted around the
alphabet with the key. Thus, a Caesar cipher is a typical example of shift cipher with key = 3.
The Cipher Process
Encipher/encryption process
Input: plaintext
1) Convert a letter into its corresponding equivalence number, where A = 0, B = 1, …, Z = 25.
2) Calculate C = (P + K) mod 26, where K = key, C = cipher number, and P = plain number
3) Convert the number C into its corresponding equivalence letter 0 into A, 1 into B, ...
4) Repeat steps 1 – 3 for all letters in the plaintext.
Output: ciphertext
Decipher/decryption process
Input: ciphertext
1) Convert a letter into its corresponding equivalence number, where A = 0, B = 1, …, Z = 25.
2) Calculate P = (C - K) mod 26, where K = key, C = cipher number, and P = plain number
3) Convert the number P into its corresponding equivalence letter 0 into A, 1 into B, ...
4) Repeat steps 1 – 3 for all letters in the ciphertext.
Output: plaintext
Example: Assume, you agree with your friend to communicate securely using Shift cipher and key = 19.
Encipher the sentence “I need your help as soon as possible”. Use the above encryption process and send
the ciphertext to your friend.
• Plaintext: “I need your help as soon as possible”
• Formula: for each letter, C = (P + 19) mod 26
• Ciphertext: “b gxxw rhnk axei tl lhhg tl ihllbuex”
4. Playfair Cipher
In this scheme, pairs of letters are encrypted, instead of single letters as in the cases of the 1-3 ciphers.
In playfair cipher, initially a key table is created. The key table is a 5×5 grid of letters that acts as the key
for encrypting the plaintext. Each of the 25 letters must be unique and one letter of the alphabet (usually
J) is omitted from the table as we need only 25 letters instead of 26. If the plaintext contains J, then it is
replaced by I.
The sender and the receiver decide on a key, say “plants”. In a key table, the first letter (going left to right)
in the table is the phrase, excluding the duplicate letters. The rest of the table will be filled with the
remaining letters of the alphabet, in natural order. The key table for key = “plants” works out to be −
P L A N T
S B C D E
F G H I/J K
M O Q R U
V W X Y Z
Table 3 Playfair key table for key="plants"
Decrypting the Playfair cipher is as simple as doing the same process in reverse. Receiver has the same key
and can create the same key table, and then decrypt any messages made using that key.
5. Vigenere Cipher
This scheme of cipher uses a text string (or a word) as a key, which is then used for doing a number of
shifts on the plaintext. It is a poly-alphabetic cipher. For example, let’s assume the key is “word” Each
alphabet of the key is converted to its respective numeric value: In this case,
w → 22, o → 14, r → 17, and d → 3. Thus, the key is: 22 14 17 3.
The Cipher Process
1. The sender and the receiver decide on a key, say “word” is the key. Numeric representation of this
key is “22 14 17 3”.
2. The sender wants to encrypt the message, say “Meet me at MIT”. He will arrange plaintext and
numeric key as follows
Plaintext E E T M E A T M I T
Key 14 17 3 22 14 17 3 22 14 17
3. He now shifts each plaintext alphabet by the number written below it to create ciphertext as
shown below, use C = (P + K) mod 26.
Plaintext M E E T M E A T M I T
Key 22 14 17 3 22 14 17 3 22 14 17
Ciphertext I S V W I S R W I W K
4. Here, each plaintext character has been shifted by a different amount – and that amount is
determined by the key. The key must be less than or equal to the size of the message.
5. For decryption, the receiver uses the same key and shifts received ciphertext in reverse order to
obtain the plaintext. Use P = ((26 – K) + C) mod 26.
Ciphertext I S V W I S R W I W K
Key 22 14 17 3 22 14 17 3 22 14 17
Plaintext M E E T M E A T M I T
Generally, a plaintext letter, say ‘A’ can be encrypted with any key ‘A’ to ‘Z’. Here, ‘A’ is encrypted into ‘A’
if key = ‘A’, into ‘B’ if key = ‘B’, into ‘C’ if key = ‘C’, and so on. The same trend works for ‘B’ to ‘Z’. As a
result, a matrix of 26 X 26, aka Vigenere table (see table 4), is prepared for Vigenere encryption and
decryption process.
To encrypt a plaintext using the Vigenere table (see table 4), map a plain letter in column wise and key
letter row wise. Thus, the intersection would be taken as cipher letter.
Example: Encrypt a plaintext, “I put you the key under the table” with a key = “campus”.
Plain I p u t y o u t h e k e y u n d e r t h e t a b l e
Key c a m p u s c a m p u s c a m p u s c a m p u s c a
Cipher K p g i s g w t t t e w a u z s y j v h q i u t n e
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
A A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
B B C D E F G H I J K L M N O P Q R S T U V W X Y Z A
C C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
D D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
E E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
F F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
G G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
H H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
I I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
J J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
K K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
L L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
J
M M N O P Q R S T U V W X Y Z A B C D E F G H I J K
J L
N N O P Q R S T U V W X Y Z A B C D E F G H I J K
J L M
O O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
P P Q R S T U V W X Y Z A B C D E F G H I J K
J L M N O
Q Q R S T U V W X Y Z A B C D E F G H I J K
J L M N O P
R R S T U V W X Y Z A B C D E F G H I J K
J L M N O P Q
S S T U V W X Y Z A B C D E F G H I J K
J L M N O P Q R
T T U V W X Y Z A B C D E F G H I J K
J L M N O P Q R S
U U V W X Y Z A B C D E F G H I J K
J L M N O P Q R S T
V V W X Y Z A B C D E F G H I J K J L M N O P Q R S T U
W W X Y Z A B C D E F G H I J K J L M N O P Q R S T U V
X X Y Z A B C D E F G H I J K J L M N O P Q R S T U V W
Y Y Z A B C D E F G H I J K J L M N O P Q R S T U V W X
Z Z A B C D E F G H I J K J L M N O P Q R S T U V W X Y
Table
J 4 Vigenere table
7. Hill Cipher
Invented by Lester S. Hill in 1929. Hill cipher is a polygraphed substitution cipher based on linear algebra.
It uses matrix and columnar vector multiplication to mix up the plaintext. To create a cipher, Hill uses a
keyword as key.
The Encryption Process
1. Form a matrix of n by n using the key written from left to right towards the bottom.
10 4 18 10 ∗ 18 + 4 ∗ 7 208 0
SH => [ ]X( )=( )=( ) % 26 = ( ) = AI
24 10 7 24 ∗ 18 + 10 ∗ 7 502 8
10 4 14 10 ∗ 14 + 4 ∗ 22 228 20
OW => [ ]X( )=( )=( ) % 26 = ( ) = UK
24 10 22 24 ∗ 14 + 10 ∗ 22 556 10
10 4 12 10 ∗ 12 + 4 ∗ 4 136 6
ME => [ ]X( )=( )=( ) % 26 = ( ) = GQ
24 10 4 24 ∗ 12 + 10 ∗ 4 328 16
Therefore, the ciphertext of “Show me” with a key, “key” is “Aiuk gq”
Exercise 1:
• Use Hill cipher to decrypt the ciphertext “Ajuk gq” with a key = “key”.
• Use Hill cipher to encrypt a plaintext “Show me” with a key = “plaintext”.
o What difference from the above example do you get?
• How do two communicating parties secure their communication in unsecure channel? Please
discuss the way the parties communicate from different locations.
8. Beaufort Cipher
This cipher uses the same table as Vigenere cipher but has different algorithm to encrypt and decrypt a
message. This cipher considers the top most row as location of a plaintext, and the left most column as
location of a ciphertext.
Encryption Process
Key and plaintext are given as input. Then, follow the following procedures.
1. Locate the plaintext letter on the topmost horizontal row
2. Move down the column until you find the key letter
3. The leftmost letter of the row that the key letter is located is the ciphertext letter.
Example: C = ‘L’, key=’U’, and P will be the topmost letter in the column where ‘U’ along the row ‘J’ is
located, i.e., ‘J’.
Exercise 3: Decrypt the following ciphertext “DIMBUSQJKLUGXVUEWUMFWXIX” using a key = “lemon”.
Exercise 4: In Vigenere Cipher, a key is added with a plaintext to get a ciphertext. How about in the Beaufort
cipher?
Transposition Cipher
It is another type of cipher process, where letters in the plaintext are rearranged to create a corresponding
ciphertext. The letters of the plaintext are moved around. The actual plaintext alphabets are not replaced.
Example Ciphers such as simple columnar transposition, row transposition, double transposition, Rail
Fence cipher, etc. are transposition ciphers.
10 | P a g e Asmelash Girmay
Department of Information Technology
IT4201 Cryptography and Network Security
Chapter 3 – Secret Key Cryptography
Example: Encrypt a plaintext “why should I come to you” using a key = “yes”.
Y E S According to the rule above, we shall read the second column, and thus, “hhlcey”,
3 1 2 Then read off the third column, hence, “yodoto”,
w h y Finally, read the first column, which is, “wsuimou”
s h o Concatenating each output, the ciphertext can be constructed as
u l d “hhlcey yodoto wsuimou”
i c o
m e t
Exercise 6: Use a keyword “mahder” and columnar transformation cipher to encrypt
o y o a plaintext “why should I come to you”.
u
Decryption Process:
The second communicating party gets a ciphertext and already has the key. Thus, the ciphertext shall be
decrypted in order to get the original message. To decrypt the ciphertext,
11 | P a g e Asmelash Girmay
Department of Information Technology
IT4201 Cryptography and Network Security
Chapter 3 – Secret Key Cryptography
Example: encipher the plaintext “Cryptography is one of the thematic areas of IT” using a key “crypto”.
C R Y P T O C O P R T Y
1 4 6 3 5 2 1 2 3 4 5 6 Now, read off the ciphertext row-
C R Y P T O C O P R T Y wise from left to right down to the
G R A P H Y Rearrange columns in G Y P R H A bottom. Thus, the ciphertext is:
I S O N E O ascending order I O N S E O
F T H E T H F H E T T H
E M A T I C E C T M I A COPRTYGYPRHAIONSEOFHETTHEC
A R E A S O A O A R S E TMIAAOARSEFXXIXT
F I T F X X I X T
Exercise 1: Decipher the ciphertext in the example above with the key “crypto”.
5. Product Cipher
A cipher that involves two or more transformations to create a combined secure cipher to make it resistant
to cryptanalysis. For example, a cipher may involve combinations of substitution like S-box and
transposition/permutations like P-box. S-box and P-box are to be discussed later lessons. Here, neither
substitution alone nor transposition are secure because of language characteristics. For this, a cipher is
recommended to involve combination of them, for example:
• Two substitutions make a more complex substitution
• Two transpositions make a more complex transposition
• But a substitution followed by a transposition makes much harder cipher
Stream Cipher
One of the types of cipher processes where encryption and decryption is done one bit or byte at a time.
Example ciphers of this type are Vernam cipher and the others discussed above.
12 | P a g e Asmelash Girmay
Department of Information Technology
IT4201 Cryptography and Network Security
Chapter 3 – Secret Key Cryptography
Vernam Cipher
It is proposed by Gilbert Vernam in 1918 for binary string encoding. It encryption and decryption is done
using bit-wise XOR operation. Assume, Ci be ith ciphertext bit, Pi be ith plaintext bit, and Ki be ith key bit,
Ci = Pi Ki
Pi = Ci Ki
Example: P = 01101110, K = 11011001, C = P K = 10110111
Exercise 4: Decrypt the above ciphertext bits to get the original plaintext bits.
Cryptanalysis: The strength of the key lies in the length of the key.
Exercise 5: Discuss how strong is this cipher in detail.
Exercise 6: What it the concrete difference between double transposition and product cipher?
Rotor Machine
Rotor machine was used as a cryptographic systems product before modern ciphers were invented. This
machine was used in the world war 2 (WW2) by German Enigma, Allied Hagelin, Japanese Purple, etc. It
was implemented with a very complex varying substitution cipher using a series of cylinders, each giving
one substitution, which rotated and changed after each letter was encrypted. For example, with three
cylinders, we could have 263 = 17576 alphabets.
Steganography
An alternative way of hiding a plaintext to the encryption. It is the process of hiding the existence of a
message using only a subset of letters/words in a longer message marked in some way, using invisible inks,
in graphic images, sounds, videos, PDF files, etc. However, it has high overhead to hide relatively few
information bits.
13 | P a g e Asmelash Girmay
Department of Information Technology
IT4201 Cryptography and Network Security
Chapter 3 – Secret Key Cryptography
Block Cipher
The process of enciphering and deciphering multiple bits at once as a block, where each block is
enciphered independently. However, identical plaintext blocks produce identical ciphertext blocks. In this
cipher, each block plaintext is treated at once. Example of block ciphers are S-DES (Simplified Data
Encryption Standard), DES, Double DES (2DES), triple DES (3DES), International Data Encryption Algorithm
(IDEA), and AES (Advanced Encryption Standard). The DES family are based on Feistel cipher. What is
Feistel cipher, let’s discuss here below.
14 | P a g e Asmelash Girmay
Department of Information Technology
IT4201 Cryptography and Network Security
Chapter 3 – Secret Key Cryptography
Key Generation
Step 1: select a random key of 10-bits size, which only should be shared by between the communicating
parties. For example: 10011 00101
Step 2: put the selected key into the P10 table and permute the bits.
Input 1 2 3 4 5 6 7 8 9 10
Output 3 5 2 7 4 10 1 9 8 6
Table 5 S-DES P10 table
Input bits 1 0 0 1 1 0 0 1 0 1
Output bits 0 1 0 0 1 1 1 0 1 0
Table 6 Input key on S-DES P10 table
Input bits 1 0 0 1 0 1 0 1 0 1
Output bits 1 0 0 1 1 0 1 0
Table 8 Processed key bits on S-DES P8 table
The output is an 8-bits key, the first key (K1). Thus, K1 = 1001101 0
Step 6: since S-DES has two rounds for its cipher process, it needs to have two keys. The first key is already
generated in step 5. While the second key is to be generated on the next steps (6-8).
Go to the step 4 and take the output of the first-round halves: LH = 10010, RH=10101
Step 7: make two rounds on each half. The output is LH = 01010, RH=10110
15 | P a g e Asmelash Girmay
Department of Information Technology
IT4201 Cryptography and Network Security
Chapter 3 – Secret Key Cryptography
Step 8: Combine the two halves from step 7 and then put them into the P8 table (see table 3 above) to
generate the second key.
Input bits 0 1 0 1 0 1 0 1 1 0
Output bits 1 0 0 1 1 0 0 1
Table 9 Processed key bits on S-DES P8 table
Encryption Process
Let’s encrypt a plaintext to ciphertext with the following steps. For this, assume that a plaintext’s one
block is given as 0011 1001.
Step 1: Given plaintext block be 0011 1001
Step 2: Initial Permutation (IP8)
Put the plaintext block into IP8 table and permute the table.
16 | P a g e Asmelash Girmay
Department of Information Technology
IT4201 Cryptography and Network Security
Chapter 3 – Secret Key Cryptography
Input bit numbers 1 2 3 4 5 6 7 8
Permutated bit numbers 2 6 3 1 4 8 5 7
Table 10 S-DES IP8 table
Input bits 1 1 1 0
Expanded bits 0 1 1 1 1 1 0 1
Table 13 RH bits on S-DES EP table
Input bits 1 1 0 0
Output bits 1 0 0 1
Table 17 LH on P4 table
Output = 1001
Step 9: XOR the output with the permutated left half in step 3. 1001 ⊕ 0010 = 1011
Step 10: Combine the output in step 9 with the permutated right half in step 3. 1011 1110
Step 11: Once again, break the output into left half and right half bits. LH = 1011, RH = 1110
Step 12: Swap the halves. LH = 1110, RH = 1011, thus the output in this step is = 1110 1011
Step 13: Now let’s take these halves and once again start the same procedure from step 2 or initial
permutation. However, in this step, we are going to use the second key, K2. And put the output into IP-1
(IP inverse) table. What you get will be your final ciphertext. Let’s workout briefly as follows:
2. Apply EP for RH=1011, thus, output = 1101 0111
3. XOR the output = 1101 0111 with K2 = 1001 1001, 1101 0111 ⊕ 1001 1001 = 0100 1110
4. Split output into two halves and apply S-boxes, LH2 = 0100 and RH2 = 1110
a. LH2: 0100, row = 00 = 0, column = 10 = 2. S0 at 0 row and 2nd column is 11.
b. RH2: 1110, row = 10 = 2, column = 11 = 3. S1 at 2nd row and 3rd column is 00.
5. Combine the output and apply P4. Output = 1100. After permutated on P4 table = 1001
6. XOR the previous output with RH2 (see above), 1001 ⊕ 1110 = 0111
7. Rewrite the swapped result in step 13 by replacing the LH with the previous output, thus, 1101 0111
will be rewritten as 0111 0111
8. Finally, apply inverse initial permutation IP-1 to the previous output = 0111 0111.
IP-1
4 1 3 5 7 2 8 6
Table 18 S-DES inverse initial permutation (IP-1)
18 | P a g e Asmelash Girmay
Department of Information Technology
IT4201 Cryptography and Network Security
Chapter 3 – Secret Key Cryptography
Avalanche Effect
A desirable property of any encryption algorithm is that a small change in either the plaintext or the key
should produce a major change in the ciphertext.
Feistel Cipher
Horst Feistel devised the Feistel cipher based on the concept of invertible product cipher. Feistel cipher
implements the S-P network concept. It partitions input block into two halves which are processed through
multiple rounds which perform a substitution on left data half, based on round function of right half and
subkey, and then have permutation swapping halves. Essentially the same hardware or software is used
for both encryption and decryption, with just a slight change in how the keys are used. One layer of S-
boxes and the following P-box are used to form the round function. It has the following summarized
characteristics:
• It is not specific scheme of block cipher
• It is a design model, where many different block ciphers are derived
• A crypto algorithm designed based on Feistel cipher uses the same algorithm for both encryption
and decryption
• Input block to each round is divided into two halves, left half and right half
• In each round, right half goes through unchanged. Whereas left half goes through an operation
that depends on the right half and the key.
o Output of each round is L (+) f (R, K), where f (R, K) means encryption right half, R with
key, K.
• Each round uses different round keys
• The permutation step at the end of each round swaps the modified left half, L and unmodified
right half, R
19 | P a g e Asmelash Girmay
Department of Information Technology
IT4201 Cryptography and Network Security
Chapter 3 – Secret Key Cryptography
o Performance of the algorithm decreases
• Each round consists of substitution and permutation (transposition) as seen in figure 1.
• Number of rounds are specified by the respective algorithm
• Once the last round is completed then the two sub blocks, left, L and right, R are concatenated to
form the ciphertext block.
• The difficult here is to get the round function, f.
In the secret key cryptography, some block ciphers such as DES and its families (S-DES, 2DES, 3DES) follow
the Feistel cipher standard technique. Let’s summarize what each of the block ciphers look like including
those that do not follow the Feistel approach such as AES, IDEA, RC4, etc.
I am going to summarize the widely used and known symmetric block ciphers here below. P.S., the detailed
discussion of each of the algorithms is expected from each respective group in the course project.
20 | P a g e Asmelash Girmay
Department of Information Technology
IT4201 Cryptography and Network Security
Chapter 3 – Secret Key Cryptography
21 | P a g e Asmelash Girmay
Department of Information Technology
IT4201 Cryptography and Network Security
Chapter 3 – Secret Key Cryptography
• Key size used 168 bits. Here, three keys of size 56 bits each.
• Has three-times DES’s rounds, thus, round keys.
• Size of each round key is 48-bits like DES.
1
https://community.cisco.com/t5/security-documents/3des/ta-p/3113951
2
https://www.researchgate.net/figure/The-diagram-of-3DES-encryption-decryption-implementation_fig6_297310056
22 | P a g e Asmelash Girmay
Department of Information Technology
IT4201 Cryptography and Network Security
Chapter 3 – Secret Key Cryptography
3 https://www.researchgate.net/figure/The-basic-AES-128-cryptographic-architecture_fig1_230853805
4 https://en.wikipedia.org/wiki/International_Data_Encryption_Algorithm
23 | P a g e Asmelash Girmay
Department of Information Technology
IT4201 Cryptography and Network Security
Chapter 3 – Secret Key Cryptography
7. RC4
• RC4 is a stream cipher designed by Ron Rivest.
• It generates a one-time pad and applies it to a stream of plaintext with ⊕.
• It is extremely simple and fast.
• The key can be from 1 to 256 octets.
• RC4 keeps 258 octets of state information, 256 octets of which are a permutation of 0, 1, …, 255
that is initially computed from the key and then altered as each pad octet is generated.
5https://www.researchgate.net/figure/RC4-Stream-Cipher-This-mode-of-operation-makes-stream-ciphers-vulnerable-to-
several_fig1_260419842
24 | P a g e Asmelash Girmay
Department of Information Technology
IT4201 Cryptography and Network Security
Chapter 3 – Secret Key Cryptography
Cryptanalysis on ECB
• If the plaintext contains two identical blocks, the corresponding ciphertext blocks will be identical.
o This will give eavesdropper some information,
• Another, a man in the middle can rearrange blocks to modify blocks to his own advantage.
• Thus, it is rarely used to encrypt messages.
25 | P a g e Asmelash Girmay
Department of Information Technology
IT4201 Cryptography and Network Security
Chapter 3 – Secret Key Cryptography
• Decryption is also simple, because XOR is its own inverse.
Cryptanalysis on CBC
• The overhead is generating the IV and transmitting it. However, the cost of XOR is trivial compared
to the encryption
o Omitting the IV (replacing with 0) would not be adversely affected. However, if the same
message is being sent repeatedly, and then some parts of the message are changed some
other days, eavesdropper can detect the change, thus, alerted with the change what so
ever it is.
o The IV always changes even the same plaintext
1.3. K-Bit Output Feedback Mode (OFB)
Output feedback mode is stream cipher. Encryption is performed by XORing the message with one-time
pad generated by the OFB. The process:
• Let’s assume, the stream is created 64 bits at a time.
• To start, a random 64-bit IV (as in the CBC mode) is generated. Let’s call that b0.
• Then the b0 is encrypted with the key to get b1, which in turn encrypted to get b2, and so forth.
Thus, the resulting one-time pad is b0|b1|b2|b3|…
• To encrypt a message, XORing it with as many bits of the one-time pad as necessary.
• The result is transmitted along with the IV.
• The receiver computes the same one-time pad based on knowledge of the secret key and the IV.
• To decrypt the ciphertext, XORing with as many bits of the one-time pad as necessary.
26 | P a g e Asmelash Girmay
Department of Information Technology
IT4201 Cryptography and Network Security
Chapter 3 – Secret Key Cryptography
1.4. K-Bit Cipher Feedback Mode (CFB)
It is very similar to OFB, in that K-bits at a time are generated and XORed with K-bits of plaintext.
Exercise: Compare and contrast OFB with CFB.
1.5. Counter Mode (CTR)
It is very similar with OFB mode, in that one-time pad is generated and XORed with the data. It is however
different in that instead of chaining by encrypting each one-time pad block to get the next one, OFB
increments the IV and encrypts the result to get successive blocks of the one-time pad.
Cryptanalysis on CTR
• Like OFB, the cryptography can be pre-computed, and encryption is simple an XOR. But, like CBC,
you can decrypt the message starting at any point rather than being forced to start from the
beginning.
• This makes CTR an ideal model for applications.
• Like OFB, CTR loses security if different plaintext is encrypted with the same key and IV.
27 | P a g e Asmelash Girmay
Department of Information Technology
IT4201 Cryptography and Network Security
Chapter 3 – Secret Key Cryptography
To be continued…
28 | P a g e Asmelash Girmay
Department of Information Technology