Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 4 Encryption [ 4 0 marks ] Develop a program named MAC, which simulates a Message Authentication Code. This program should accept four parameters:
Question Encryption marks
Develop a program named MAC, which simulates a Message Authentication Code. This
program should accept four parameters: the option gen or "verify" the name of the AES
file, the input file, and the MAC file for generation or verification
The program will read an AES key that has been generated by the provided program,
RandomAESKeyGen. If the chosen option is "gen", it will calculate the SHA hash of the
input file, encrypt this hash using the AES key, and write the encrypted data to the specified
MAC file. If the chosen option is "verify", it will again calculate the SHA hash of the input
file and encrypt it using the AES key. The result will then be compared with the content of the
specified MAC file. If the two match, 'Verification: Successful! will be displayed; if not,
'Verification: Failed! will be displayed. For both options, the digest is displayed in base
format.
The RandomAESKeyGen program is provided for you, which generates a random AES key
and writes to the file specified in the input parameter.
Below are sample outputs from compiling and running the program.
javac aRandomAESKeyGenjava
javac aMACjava
java aRandomAESKeyGen myaes.key
java aMAC gen myaes.key notes.txt notes.txtmac
The digest is in base format: JkSYEkHrRBIlayDdISuGIQto
java aMAC verify myaes.key notes.txt notes.txtmac
The digest is in base format: JkSYEkHrRBIlayDdISuGIQto
Verification: Successful!
If the notes.txt is modified
java aMAC verify myaes.key notes.txt notes.txtmac
The digest is in base format: LkOaNojNXCBPcTwSRyzttIGM
Verification: Failed!
If the mode is incorrect
java aMAC verify myaes.key notes.txt notes.txtmac
Incorrect modeDevelop a program named MAC, which simulates a Message Authentication Code. This
program should accept four narameters: the option gen or "verify" the name of the
file, the input file, and the file for generation or verification
The program will read an AES key that has been generated by the provided program,
RandomAESKeyGen. If the chosen option is "gen", it will calculate the SHA hash of the
input file, encrypt this hash using the AES key, and write the encrypted data to the specified
MAC file. If the chosen option is "verify", it will again calculate the SHA hash of the input
file and encrypt it using the AES key. The result will then be compared with the content of the
specified MAC file. If the two match, 'Verification: Successful! will be displayed; if not,
'Verification: Failed! will be displayed. For both options, the digest is displayed in base
format.
The RandomAESKeyGen program is provided for you, which generates a random AES key
and writes to the file specified in the input parameter.
Below are sample outputs from compiling and running the program.javac aMACjavajava aMAC gen myaes.key notes.txt notes.txtmac
The digest is in base format: JkSYEkHrRBIlayDdISuGIQtoThe digest is in base format: JkSYEkHrRBIlayDdISuGIQto
Verification: Successful!
If the notes.txt is modifiedThe digest is in base format: LkOaNojNXCBPCTwSRyzttIGM
Verification: Failed!
If the mode is incorrect
java aMAC verify myaes.key notes.txt notes.txtmac
Incorrect mode
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