0% found this document useful (0 votes)
52 views7 pages

Assignment 1-1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views7 pages

Assignment 1-1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

Revised Values Based on Adjusted Mobile Number

Mobile number: 3185574307

Using the digits as per the assignment instructions:

 iii = 4th digit = 5


 jjj = 5th digit = 5
 uuu = 8th digit = 3
 vvv = 9th digit = 0
 www = 10th digit = 7

Step 1: Define PPP and KKK in Hexadecimal

Calculating PPP and KKK:

1. P=ijP = ijP=ij (hexadecimal)


o Combine i=5i = 5i=5 and j=5j = 5j=5.
o P=55P = 55P=55 (hexadecimal).
2. K=uvwK = uvwK=uvw (hexadecimal)
o Combine u=3u = 3u=3, v=0v = 0v=0, and w=7w = 7w=7.
o K=307K = 307K=307 (hexadecimal).
3. Convert PPP and KKK to Binary
o P=55P = 55P=55 (hexadecimal) → Binary: 0101 0101
o K=307K = 307K=307 (hexadecimal) → Binary: 0011 0000 0111

Step 2: Derive the Cipher Key from KKK

We use the least significant 10 bits of K=307K = 307K=307 in binary (0011 0000 0111).

 Cipher Key = last 10 bits of 0011 0000 0111 → 1100 0001 11

Now, we have all the initial values set, so let's proceed with the encryption.

Part (a): Encrypting PPP Using S-DES


Step 1: Initial Permutation (IP)

 IP Table: [2, 6, 3, 1, 4, 8, 5, 7]
 Apply IP on P=01010101P = 0101 0101P=01010101:
o 2nd bit → 1
o 6th bit → 0
o 3rd bit → 0
o 1st bit → 0
o 4th bit → 1
o 8th bit → 1
o 5th bit → 0
o 7th bit → 1
 Result after IP: 1000 1011

Let’s denote this as PIP=10001011P_{IP} = 1000 1011PIP=10001011.

Step 2: Key Generation

1. P10 Permutation on the cipher key 1100 0001 11:


o P10 Table: [3, 5, 2, 7, 4, 10, 1, 9, 8, 6]
o Result after P10: 10100 11000
2. Left Shift each half by 1 bit:
o Left half (10100) becomes 01001
o Right half (11000) becomes 10001
3. P8 Permutation on 01001 10001 to create K1K_1K1:
o P8 Table: [6, 3, 7, 4, 8, 5, 10, 9]
o Result after P8: 1011 0010
o K1=10110010K_1 = 1011 0010K1=10110010
4. Second Left Shift each half by 2 bits:
o Left half (01001) becomes 00110
o Right half (10001) becomes 00110
5. P8 Permutation on 00110 00110 to create K2K_2K2:
o Result after P8: 0101 1110
o K2=01011110K_2 = 0101 1110K2=01011110

Step 3: Round 1 of S-DES (using K1K_1K1)

1. Expand and Permute (EP) the right half of PIP=10001011P_{IP} = 1000 1011PIP
=10001011:
o Right half: 1011
o EP Table: [4, 1, 2, 3, 2, 3, 4, 1]
o Expanded and permuted right half: 1101 1011
2. XOR with K1=10110010K_1 = 1011 0010K1=10110010:
o 1101 1011 XOR 1011 0010 = 0110 1001
3. S-Box Substitution on 0110 1001:
o Split into two 4-bit halves: 0110 and 1001
o S-box S0S_0S0 for 0110:
 Row = 10 (binary), Column = 11
 Output: 00
o S-box S1S_1S1 for 1001:
Row = 10, Column = 01

Output: 10

o Combined output: 0010
4. P4 Permutation on 0010:
o P4 Table: [2, 4, 3, 1]
o Permuted output: 0001
5. XOR with the left half of PIP=1000P_{IP} = 1000PIP=1000:
o 1000 XOR 0001 = 1001
6. Swap Halves:
o After swapping, we get: 1011 1001

Step 4: Round 2 of S-DES (using K2K_2K2)

1. Expand and Permute (EP) the right half 1001:


o Expanded and permuted: 1100 1100
2. XOR with K2=01011110K_2 = 0101 1110K2=01011110:
o 1100 1100 XOR 0101 1110 = 1001 0010
3. S-Box Substitution on 1001 0010:
o S-box S0S_0S0 for 1001 gives 10
o S-box S1S_1S1 for 0010 gives 11
o Combined output: 1011
4. P4 Permutation on 1011:
o Permuted output: 1110
5. XOR with the left half 1011:
o 1011 XOR 1110 = 0101
6. Result after Round 2:
o Left half: 0101
o Right half: 1001

Combined result after Round 2: 0101 1001

Step 5: Inverse Initial Permutation (IP⁻¹)

Apply IP⁻¹ to get the final ciphertext.

 IP⁻¹ Table: [4, 1, 3, 5, 7, 2, 8, 6]


 Apply IP⁻¹ on 0101 1001:
o 4th bit → 0
o 1st bit → 1
o 3rd bit → 0
o 5th bit → 1
o 7th bit → 1
o 2nd bit → 0
o 8th bit → 1
o 6th bit → 1
Final Ciphertext in Binary: 0101 1001

Final Ciphertext in Hexadecimal: 59

Part (b): Decryption Process

For decryption, follow the steps in reverse order. Let me know if you’d like the full decryption
steps as well!

4o

You said:

do it
ChatGPT said:

ChatGPT

Let’s continue by performing the decryption of the ciphertext obtained from Part (a), which was
0101 1001 (binary) or 59 (hexadecimal).

Decryption of Ciphertext Using S-DES

In S-DES decryption, we apply the same steps as encryption but in reverse order, using
K2K_2K2 in the first round and K1K_1K1 in the second round.

Given Data Recap:

 Ciphertext from Part (a): 0101 1001 (binary)


 Subkeys:
o K1=10110010K_1 = 1011 0010K1=10110010
o K2=01011110K_2 = 0101 1110K2=01011110

Step 1: Initial Permutation (IP) on Ciphertext

 IP Table: [2, 6, 3, 1, 4, 8, 5, 7]
 Ciphertext: 0101 1001

Applying the IP on 0101 1001:

 2nd bit → 1
 6th bit → 1
 3rd bit → 0
 1st bit → 0
 4th bit → 1
 8th bit → 1
 5th bit → 1
 7th bit → 0

Result after IP: 1100 1011

Let’s denote this as CIP=11001011C_{IP} = 1100 1011CIP=11001011.

Step 2: Round 1 (using K2K_2K2)

Split CIPC_{IP}CIP into Left and Right Halves

 Left half: 1100


 Right half: 1011

1. Expand and Permute (EP) the right half 1011:

 EP Table: [4, 1, 2, 3, 2, 3, 4, 1]
 Expanded and permuted right half: 1101 1011

2. XOR with K2=01011110K_2 = 0101 1110K2=01011110:

 1101 1011 XOR 0101 1110 = 1000 0101

3. S-Box Substitution on 1000 0101:

 Split into two 4-bit halves: 1000 and 0101


 S-box S0S_0S0 for 1000:
o Row = 10, Column = 00
o Output: 10
 S-box S1S_1S1 for 0101:
o Row = 01, Column = 01
o Output: 01
 Combined output: 1001

4. P4 Permutation on 1001:

 P4 Table: [2, 4, 3, 1]
 Permuted output: 0011
5. XOR with the left half 1100:

 1100 XOR 0011 = 1111

Result after Round 1:

 Left half becomes 1111


 Right half remains 1011 (no swap is needed in decryption)

Combined result after Round 1: 1111 1011

Step 3: Round 2 (using K1K_1K1)

1. Expand and Permute (EP) the right half 1011:

 Expanded and permuted: 1101 1011

2. XOR with K1=10110010K_1 = 1011 0010K1=10110010:

 1101 1011 XOR 1011 0010 = 0110 1001

3. S-Box Substitution on 0110 1001:

 S-box S0S_0S0 for 0110 gives 00


 S-box S1S_1S1 for 1001 gives 10
 Combined output: 0010

4. P4 Permutation on 0010:

 Permuted output: 0001

5. XOR with the left half 1111:

 1111 XOR 0001 = 1110

Result after Round 2:

 Left half: 1110


 Right half: 1011

Combined result after Round 2: 1110 1011


Step 4: Inverse Initial Permutation (IP⁻¹)

Apply the inverse IP (IP⁻¹) to get the decrypted plaintext.

 IP⁻¹ Table: [4, 1, 3, 5, 7, 2, 8, 6]


 Apply IP⁻¹ on 1110 1011:
o 4th bit → 1
o 1st bit → 1
o 3rd bit → 1
o 5th bit → 0
o 7th bit → 0
o 2nd bit → 1
o 8th bit → 1
o 6th bit → 0

Decrypted Plaintext in Binary: 0101 0101

Decrypted Plaintext in Hexadecimal: 55

You might also like