COMP4337/9337 -comp9337代写
时间:2025-03-01
1 of 4 COMP4337/9337 Securing Fixed and Wireless Network Lab 1: Introduction to Basic Cryptographic Mechanisms Due: Monday 3rd March 2025 9am AEDT Objectives This lab is designed to help the students to: • learn the basics of cryptography for hiding secret information from non-trusted peers, • implement DES algorithm using Python and • compare the performance of DES, AES, RSA, HMAC, and SHA-1 algorithms. Lab Overview The notion of cryptography consists of hiding secret information from non-trusted peers by mangling messages into unintelligible text that only trusted peers can rearrange/recover. In this lab, we will use and compare three different techniques commonly employed to hide or encrypt information: secret key cryptography (DES, AES), public key cryptography (RSA) and message digests (SHA-1). We provide a group of files (Please refer to the skeletoncode folder) as a reference on how to use certain built-in functions that we mention in this handout and that you can use in your implementations. These files are just skeletons that you should modify to obtain the expected results. A few test cases are also included for your `DES-CBC` implementation (e.g. test.txt and test.des) and a file with general descriptions of some built-in functions. Please refer to the skeletoncode folder. Assessment and Marking The submission link and the deadline will be available on the course website on WebCMS3. The marks will be made available within 2 weeks of the submission date. The details of the marks are as follows: • Total mark for Lab 1 is 100. These would be scaled down to 4 marks. o Lab Performance (20) o Report (40) o Code (40) • Students who do not attend the lab will lose the Lab performance marks. Please discuss with the lab tutors if there is a valid reason for not attending the lab. • Note: Lab performance involves tutor asking question, feedback, and comments about the activity while the lab is in progress. Hence, if a group is found to be cheating or submitting a work that does not match what the tutor observes of the team performance, then NO MARK will be awarded for that group. • The standard late penalty introduced under UNSW new assessment implementation procedure will be applied for this course. o 5% per day, o for all assessments where a penalty applies, 2 of 4 o capped at five days (120 hours) from the assessment deadline, after which a student cannot submit an assessment, and o no permitted variation. Submission Please follow these instructions to prepare a submission for this lab: 1. You are given the option to do this lab either individually or in a pair. If you opt to do in a pair, both team members will get equal marks. 2. Create a folder named Lab1 containing two subdirectories: code and report. 3. In code: • Include a copy of tempdes.py file. Name your file
_.des.py, where zid_1 and zid_2 are the zIDs of group members. For example: z1234567_z7654321.des.py. 4. In report, upload a written report with the following information: • On the first page, include the name of the group, student names and zIDs clearly. • Graphs showing: o DES encryption/decryption time, o AES encryption/decryption time, o RSA encryption/decryption time, o SHA-1 digest generation times, and o HMAC signature generation times. Note: In each of these graphs, the X-axis should plot the file sizes in units of bytes, and the Y-axis should plot time measurements in units of microseconds (µs). • Answer the following questions: o Compare DES and AES. Explain your observations. o Compare DES and RSA. Explain your observations. o Compare DES and SHA-1. Explain your observations. o Compare HMAC and SHA-1. Explain your observations. o Compare RSA encryption and decryption time. Explain your observations. 5. Create a tarball of the Lab1 folder and its contents and upload that file using give on WebCMS3. Only .tar file format is allowed. tar -cvf Lab1.tar Lab1/ Part A: DES encryption and decryption In this part of the lab, we will be coding a tool to encrypt and decrypt files using DES in Cipher Block Chaining (CBC) mode. tempdes.py is a skeleton file that encrypts/decrypts a fixed 64-bit block. In this lab, you will extend the skeleton code to take an arbitrarily sized input file and encrypt/decrypt it, by implementing the Cipher Block Chaining DES mode of operation. You must implement the CBC mode. You may use the built-in functions in tempdes.py. You can find information about DES-CBC in textbooks and online. You may want to check your work against the input file test.txt. If you have implemented the algorithm correctly and followed the instructions below you should get the output in 3 of 4 test.des. Check the output against test.des provided to see if it matches. You can find these files in skeletoncode/. Technical Requirements • Use the built-in functions that appear in tempdes.py. • Your result should take the following arguments: $ python tempdes.py iv key inputfile outputfile • The parameters description is as follows: o iv: the actual IV to use, represented as a string comprised only of hexadecimal digits. o key: the actual key to use, represented as a string comprised only of hexadecimal digits. o inputfile: input file name. o outputfile: output file name. • Example command to run the resulting code: $ python3 tempdes.py fedcba9876543210 40fedf386da13d57 test.txt mytest.des • Please note that to get the sample output files you need to use the key and IV given in the README file. • If any of the arguments is invalid, your code should return an error message to the user. Be sure to consider the case when the keys are invalid. Part B: Performance measures for various algorithms The final part of this lab consists of measuring the time taken by DES, AES, RSA, HMAC and SHA-1 algorithms to process files of different sizes. Please follow the following steps: 1. Generate text files with the following sizes: • For DES, AES, HMAC, and SHA-1 (in bytes): 16, 64, 512, 4096, 32768, 262144, 2097152, 16777204 • For RSA (in bytes): 2, 4, 8, 16, 32, 64 2. Encrypt and decrypt all the files using the DES function that you wrote. Measure the time it takes to encrypt and decrypt each of the files. To do this, you might want to use the Python timing functions. Add these timing functions to your specific implementation. 3. Repeat the above but instead of DES use AES. 4. Measure the time for RSA encryption and decryption for the file sizes listed in 1. To do this, make appropriate changes to the file temprsa.py. This skeleton code shows how to use built-in RSA encryption and decryption functions, but you will need to augment it to allow for reading from arbitrary files, and to insert necessary instrumentation code for timing purposes. 4 of 4 5. Measure the time for SHA-1 hash generation for the file sizes listed in 1. To do this, make appropriate changes to the file tempsha1.py. This skeleton code shows how to use built-in SHA-1 hashing functions, but you will need to augment it to allow for reading from arbitrary files, and to insert necessary instrumentation code for timing purposes. You are encouraged to test other hash functions from the library. 6. Measure the time for HMAC signature generation for the file sizes listed in 1. To do this, make appropriate changes to the file tempHMAC.py. This skeleton code shows how to use built-in HMAC functions, but you will need to augment it to allow for reading from arbitrary files, and to insert necessary instrumentation code for timing purposes. 7. Prepare a report of your observations in the format requested under Submission. 学霸联盟