Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can you please do this in Python? I need help!! Here is the Starter Code: def expand(x): # imho this is the hardest of the
Can you please do this in Python? I need help!!
Here is the Starter Code: def expand(x): # imho this is the hardest of the functions pass def s1(x): assert x>=0 and x> 6 r0 = x & 0b111111 """ 110011101010 110011101010 >> 6 = 110011 # removed 6 LSBs 110011101010 & 000000111111 = 000000101010 = 0b101010 # removed the 6 MSBs """ r1 = f(r0, subkey(key, rnd)) ^ l0 l1 = r0 return l1 = 0 and x= 0 and key Write a program that performs the simplified DES-type algorithm presented in Section 4.2 of the textbook. Your program must implement a product cipher containing five rounds. 6 12 + Lo RO E 6 8 4 4 S1 S2 L1 R1 3 3 6 One round of encryption f-function Expander: the expansion algorithm is defined by table [1, 2, 4, 3, 4, 3, 5, 6]. Example: If the input to the expander is 110011 (base-2), the output is 11000011 (base-2). = Key schedule: The algorithm uses a 9-bits key. Subkeys are derived by extracting eight bits from the master key. Ki is determined by the 8 bits starting as position i of the key schedule, wrapping around at the end of needed. In other words, given K=101100101 (base-2), K4 10010110 (base-2). Bits are numbered starting with the most significant bit of the key at index 1, continuing to the least significant bit at index 8. S-Boxes: The first bit of the S-box determines the row; the latter three determine the column S-Box 1 000 001010 011100101110 111 0 101 0101001110011 100111 000 1 001 100 110 010000111 101011 S-Box 2 ooo 001010 011100101110111 0 100 000 110 101111 001 011010 1/101 011000 111 110 0101001100 Test your program using input 0b11100100110 (0x726) with master key Ob10011001 (0x99). If implemented correctly, your program should produce ciphertext Ob1111111000 (0x3f8). For reference; your S-boxes can be implemented as follows: = private static final int sbox1[] [] { {0b101, 0b010, 05001, 0b110, 0b011, 0b100, 0b111, 06000}, // row 0 {Ob001, 0b100, 0b110, 0b010, 05000, 0b111, 0b101, 0b011} // row 1 }; private static final int sbox2[] [] { {0b100, Ob000, 0b110, 0b101, 0b111, Ob001, 0b011, 0b010}, // row 0 {0b101, 0b011, 0b000, 0b111, 0b110, 0b010, Ob001, 0b100} // row 1 }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started