Language:EN
Pages: 12
Words: 1455
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
then the expansion permutation process expands the

Then the expansion permutation process expands the bit rpt bits

For the second part of this lab, using your original plaintext and key values, you should calculate the value of round two by hand, (ie computing all steps in a DES round) using the value of X and the sub-keys as given by the DES Calculator, and verify that you obtain the same value of X as the trace shows at the start of round three. You will find this relatively simple if you use a scientific calculator with the ability to enter and display numbers in various bases and to perform logical operations (eg. the Windows Calculator in Scientific Mode, or kcalc on Linux).

Plaintext: be480047cce655db

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 the expansion permutation, the RPT is expanded from 32 bits to 48 bits. Bits are permuted as well hence called as expansion permutation. This happens as the 32 bit RPT is divided into 8 blocks, with each block consisting of 4 bits. Then, each 4 bit block of the previous step is then expanded to a corresponding 6 bit block, i.e., per 4 bit block, 2 more bits are added.

This process results into expansion as well as permutation of the input bit while creating output. Key transformation process compresses the 56-bit key to 48 bits. Then the expansion permutation process expands the 32-bit RPT to 48-bits. Now the 48-bit key is XOR with 48-bit RPT and resulting output is given to the next step, which is the S-Box substitution.

'1' : "0001",

'2' : "0010",

'7' : "0111",

'8' : "1000",

'D' : "1101",

'E' : "1110",

return bin

# Binary to hexadecimal conversion

"0011" : '3',

"0100" : '4',

"1001" : '9',

"1010" : 'A',

"1111" : 'F' }

hex = ""

ch = ch + s[i + 2]

ch = ch + s[i + 3]

binary1 = binary

decimal, i, n = 0, 0, 0

i += 1

return decimal

div = len(res) / 4

div = int(div)

# Permute function to rearrange the bits

def permute(k, arr, n):

# shifting the bits towards left by nth shifts

def shift_left(k, nth_shifts):

s = s + k[0]

k = s

ans = ""

for i in range(len(a)):

return ans

# Table of Position of 64 bits at initail level: Initial Permutation Table

57, 49, 41, 33, 25, 17, 9, 1,

59, 51, 43, 35, 27, 19, 11, 3,

6 , 7 , 8 , 9 , 8 , 9 , 10, 11,

12, 13, 12, 13, 14, 15, 16, 17,

per = [ 16, 7, 20, 21,

29, 12, 28, 17,

19, 13, 30, 6,

22, 11, 4, 25 ]

[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],

[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],

[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],

[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],

[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],

final_perm = [ 40, 8, 48, 16, 56, 24, 64, 32,

39, 7, 47, 15, 55, 23, 63, 31,

34, 2, 42, 10, 50, 18, 58, 26,

33, 1, 41, 9, 49, 17, 57, 25 ]

print("After inital permutation", bin2hex(pt))

# Splitting

right_expanded = permute(right, exp_d, 48)

# XOR RoundKey[i] and right_expanded

row = bin2dec(int(xor_x[j * 6] + xor_x[j * 6 + 5]))

col = bin2dec(int(xor_x[j * 6 + 1] + xor_x[j * 6 + 2] + xor_x[j * 6 + 3] + xor_x[j * 6 + 4]))

# XOR left and sbox_str

result = xor(left, sbox_str)

print("Round ", i + 1, " ", bin2hex(left), " ", bin2hex(right), " ", rk[i])

# Combination

pt = "123456ABCD132536"

key = "9f4f190e284c81cf"

keyp = [57, 49, 41, 33, 25, 17, 9,

1, 58, 50, 42, 34, 26, 18,

14, 6, 61, 53, 45, 37, 29,

21, 13, 5, 28, 20, 12, 4 ]

2, 2, 2, 2,

1, 2, 2, 2,

23, 19, 12, 4, 26, 8,

16, 7, 27, 20, 13, 2,

# Splitting

left = key[0:28] # rkb for RoundKeys in binary

# Shifting the bits by nth shifts by checking from shift table

left = shift_left(left, shift_table[i])

round_key = permute(combine_str, key_comp, 48)

rkb.append(round_key)

print("Decryption")

rkb_rev = rkb[::-1]

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : Desmond Hendry

PageId: DOCEBDA0F1