Answered step by step
Verified Expert Solution
Link Copied!

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 4 Encryption [40 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-1 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-1 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 base64
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 a2\RandomAESKeyGen.java
> javac a2\MAC.java
> java a2.RandomAESKeyGen my_aes.key
> java a2.MAC gen my_aes.key notes.txt notes.txt.mac
The digest is (in base64 format): JkSYEkH5rRBIlayDdI1SuGI4Qto=
> java a2.MAC verify my_aes.key notes.txt notes.txt.mac
The digest is (in base64 format): JkSYEkH5rRBIlayDdI1SuGI4Qto=
Verification: Successful!
If the notes.txt is modified
> java a2.MAC verify my_aes.key notes.txt notes.txt.mac
The digest is (in base64 format): Lk/Oa44NojNXCBPcTwSRyzttIGM=
Verification: Failed!
If the mode is incorrect
> java a2.MAC verify my_aes.key notes.txt notes.txt.mac
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 ?bar((?bar(A))ES)
file, the input file, and the ?bar(?bar(M))AC 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-1 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-1 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 64
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 a2\MAC.javajava a2.MAC gen my_aes.key notes.txt notes.txt.mac
The digest is (in base64 format): JkSYEkH5rRBIlayDdI1SuGI4Qto=The digest is (in base64 format): JkSYEkH5rRBIlayDdI1SuGI4Qto=
Verification: Successful!
If the notes.txt is modifiedThe digest is (in base64 format): Lk/Oa44NojNXCBPCTwSRyzttIGM=
Verification: Failed!
If the mode is incorrect
> java a2.MAC verify my_aes.key notes.txt notes.txt.mac
Incorrect mode
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

Weights of Dollar Coins 99% confidence; n = 20, s = 0.04111 g.

Answered: 1 week ago

Question

List the different categories of international employees. page 642

Answered: 1 week ago

Question

Explain the legal environments impact on labor relations. page 590

Answered: 1 week ago