DES Python 1. Objective The objective is to make sure: ● You are familiar with the principles of Computer Security and Symmetric Key Encryption. ● Given the description of the Security Algorithm, you...

1 answer below »

The objective of this assignment is to make sure given the description of the Security Algorithm, you can implement the Data Encryption Standard (DES). The program specifications and requirements are attached below.








DES Python 1. Objective The objective is to make sure: ● You are familiar with the principles of Computer Security and Symmetric Key Encryption. ● Given the description of the Security Algorithm, you can implement the Data Encryption Standard. ● You are familiar with the way data is stored in computers and can work with bitwise data 2. Specifications Python has a cryptography and a des module, and several third party libraries that implement the DES. However, the objective of this assignment is to make sure you understand the DES algorithm by implementing it yourself. To that end, you are restricted to the standard Python libraries, and are not allowed any of the Python Cryptography libraries or other third party libraries. Also, the cryptographic algorithms have to work efficiently and close to the hardware storage of data to have any hope of working without taking a noticeably long time. To this end, your solution should work with the data bits, instead of storing each data bit in an integer in the form of a list or using string formatting or any other built-in library that uses internal lists. Doing so will result in a loss of 40 points. We’re also aware that the required implementation here changes some of the aspects of the DES algorithm and essentially makes it less secure. ● Write a function called encrypt. This function will take 2 arguments, the plaintext and the key, and return the ciphertext (5 points). ● Write a function called decrypt. This function will take 2 arguments - the ciphertext and the key and return the plaintext (5 points). ● Write a function called DES. This function will take 2 arguments - a number and a key. It will them implement one iteration of DES, that includes the following: 1. Key Scheduling using PC-2. PC-2 is a method of making a new 48 bit key from a 56 bit key using a predetermined sequence. For each round, do a cyclic left shift of the 56-bit key, and then apply PC-2. (10 points) 2. Perform an initial permutation of the 64 bit text. (5 points) 3. Apply 16 iterations of the round function. Each round consists of a) Splitting the number into 32 bit halves. (5 points) b) The left half for the next round is the right half. (5 points) c) Then, apply an expansion permutation to the right half to expand it to 48 bits. (5 points) d) XOR with the round key (5 points) e) Use an S-box (given on slide 17 of the DES slides) to shrink it back down to 32 bits. (5 points) f) Use an intermediary permutation (5 points) item Finally, XOR with the left half to get the right half for the next round. (5 points) The block diagram below shows the sequence of operations in each round 4. Finally, exchange the left and right halves one last time and then perform a final permutation. (5 points) 5. The details of the initial, final, intermediary permutations and the PC-2 for key scheduling can be found here: https://en.wikipedia. org/wiki/DES_supplementary_material We will not be using PC- 1. We will use only 1 S-box instead of 8. We will only circular left shift the key by 1 bit (as a 56 bit value) for all rounds. We will not be using key scheduling. ● Both the encrypt and decrypt functions should divide the text into 8 character (64 bit blocks) and then construct a 64 bit integer using the concatenated ASCII values of the substrings. Pad with 0s if the substring is not 8 characters long. (10 points) For example, “Hello Wo” should become 0100100001100101011011000110110001101111001000000101011101101111 https://en.wikipedia. https://en.wikipedia. ● Apply the DES function to each block. For each value returned by the DES function, separate each 64 bit number into 8 characters and concatenate them into a string using the 8 bit numbers as ASCII values. Then, put the substring together to get the result string. This should be done for both encryption and decryption. ● Return the result string. (10 points) ● In the main function, seed the random number generator using the current system time. (5 points) ● Ask for strings from the user. For each string, generate a 56 bit key, call the functions and print the ciphertext, and the decrypted plaintext. Repeat until the User types “Exit”. (5 points) ● The input will always be ASCII strings. You do not have to check for that. ● Pad with 0’s if the string length is not a multiple of 8. This would help on the decryption end, since you do not have to manually insert the end of the string character. ● Make sure you follow Python coding conventions and add comments to your code (5 points) 3. Sample Run DES Implementation: Enter text to encrypt ("Exit" to quit): This is a sample DES test Encrypted text: z.J..#...M.x7.98f Decrypted text: This is a sample DES test Next text ("Exit" to quit): SmittyWerbenJeagerManJensen. He was number 1 Encrypted text: w....v"~.? T...l.Fn e* r0 Decrypted text: SmittyWerbenJeagerManJensen. He was number 1 Next text ("Exit to quit"): Exit 4. General Instructions . ● Call your file DES.py with all your code. ● If we have listed a specification and allocated points for it, you will lose points if that particular item is missing from your code, even if it is trivial. ● Your outputs will be different from mine depending on the random key.. ● Your program should load and run without issues. Every interpretation error will result in a loss of 5 points each. ● You are restricted to standard Python (built-ins). Use of any other libraries would result in loss of 10 points per library. ● Testing your program thoroughly is a part of writing good code. We give you sample runs to make sure you match our output requirements and to get a general idea of how we would test your code.
Answered 6 days AfterOct 29, 2021

Answer To: DES Python 1. Objective The objective is to make sure: ● You are familiar with the principles of...

Swapnil answered on Nov 04 2021
131 Votes
94954/__pycache__/decrypt.cpython-39.pyc
94954/__pycache__/encrypt.cpython-39.pyc
94954/decrypt.py

def decrypt( ciphertext, key):
res = ""
for i in range(len(ciphertext)):
characters = ciphertext[i]
if (characters.isupper()):
res += chr((ord(characters) +...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here