SCHOOL OF COMPUTER SCIENCE AND ENGINEERING
B.Tech, Winter Semester , 2023-24
Course Code : BCSE309P Submission Date: 20-03-24
Course Name : Cryptography and Network Security Max. Marks :20
Faculty-In-
Charge: : Dr. N. Balaji Slot: L59+L60
1. Write a program to generate the key that is provided as input is expanded into an array of
forty-four 32-bit words, w[i]. Four distinct words (128 bits) serve as a round key for each
round; these are indicated in below algorithm
Key[16]=” abcdefghijklmnoz”;
KeyExpansion (byte key[16], word w[44])
{
word temp
for (i = 0; i < 4; i++)
w[i] = (key[2*i], key[2*i+1], key[2*i+2], key[2*i+3]);
print w[i];
for (i = 4; i < 44; i++)
{
temp = w[i − 1];
if (i mod 4 = 0)
temp =SubWord (RotWord (temp))
w[i] = w[i−4] ⊕ temp
print w[i];
}
}
2. Write the program to generate cipher text for the Message= “ AESisablockciphe” using below three
steps in sequence for each round. Perform 10 rounds of operation to produce the cipher text.
STEP 1. Substitution of the bytes
In the first step, the bytes of the block text are substituted based on rules dictated by predefined S-boxes (short
for substitution boxes).
STEP 2. Shifting the rows
Next comes the permutation step. In this step, all rows except the first are shifted by one, as shown below.
STEP 3. Mixing the columns
[ a0,0 ] [ 4 3 2 1 ] [ a0,0 ]
| a1,0 | | 5 2 5 4 | | a1,1 |
| a2,0 | = | 2 1 4 3 | | a2,2 |
[ a3,0 ] [ 5 1 2 2 ] [ a3,3 ]
S-Box for SubByte Table
For (i=0;i<16;i++)
{
For (j=0;j<16;j++)
{
S[i][j]=i*j;}}
3. Write the program to generate cipher text for the Plaintext= ”zxcv” using the given below diagram for one
round of operation and Key =”QWERTY”. Perform 8 rounds of operation to produce the cipher text and use
same key for all round.
int E[] ={ 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};
int P[] ={ 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};
use same S-Bosex for all eight block
For (i=0;i<4;i++)
{
For(j=0;j<16;j++)
{
X=i*j mod 16;
S[i][j]=X;
}}
4. Write a program to generate and print 16 keys using given logic.
Original key=” sdfghjkl”.
int P-box[] =
{
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
};
5. Write the program to generate cipher text for the plaintext= “ januarymarchuytr” using below four
steps in sequence for each round. Perform 8 rounds of operation to produce the cipher text
Step 1: X1 * K1
Step 2: X2 + K2
Step 3: X3 + K3
Step 4: X4 * K4
Algorithm
uses a fixed-length plaintext of 16 bits and
encrypts them in 4 chunks of 4 bits each
to produce 16 bits ciphertext.
The length of the key used is 16 bits.
The key is also divided into 4 blocks of 4 bits each.
Symbol Operation
* Multiplication modulo 24
+ Addition modulo 24
Use the given key for each round
K1 K2 K3 K4
Round 1 1101 1100 0110 1111
Round 2 0101 1001* 0001 1111
Round 3 1101 0110 0111 0011
Round 4 1111 0101 1001 0110
Round 5 0011 1100 1111 1110
Round 6 1111 1111 0011 0110
Round 7 1101 0110 0111 0011
Round 8 1111 0101 1001 0110