程序代写代做代考 algorithm Java graph 2020/11/16 Instructions for Problem 1 of HW 2: 2020F CS -306-A

2020/11/16 Instructions for Problem 1 of HW 2: 2020F CS -306-A
Instructions for Problem 1 of HW 2
# (CS-306) Homework #2 – Problem 1
## Instructions
Given the provided support code in Java, implement a secret-key message authentication code that employs only a block cipher (and no other cryptographic primitive) to authenticate messages of any size in a bandwidth-efficient manner.
You are provided with the skeleton for an implementation of a MAC application in Java. You must implement the mac() and verify() methods in the Mac.java file and demonstrate that they are correct.
In addition to your program, you should include in your write-up of your assignment the following information:
1) A description and justification of the algorithm you used to implement your MAC as well as a brief discussion of any existing vulnerabilities and made assumptions.
2) The MAC tag of the default message using the default key (in hexidecimal).
## Useful Methods
Some methods are provided to you in the MacSkeleton class that will assist in the development of a MAC algorithm. Namely:
* **byte[] pad(byte[] message, int blockSz)**: Pads a message out to blockSz (in bytes). The pad is in the form 1000… If the message is a multiple of blockSz, an extra block is added to the end.
* **byte[] xor(byte[] a, byte[] b)**: Performs a bitwise XOR on two byte arrays and returns the result.
* **int getBlockSize()**: Returns the block size of the cipher in bytes.
* **byte[] encryptBlock(byte[] block, Key key)** Takes a single block of plaintext and encrypts it using the key. Returns the ciphertext.
## Running Your Project
The main function takes 3 optional arguments: message, key, and tag (in that order). If none are specified, a test message and key are MAC’d, and the resulting tag is run through the verify algorithm (which should succeed). The tag is printed to the console in hex form.
If the first argument is supplied, it is used as the message. If the second argument is supplied, then it is used as the key. Finally, if the third argument is supplied, it is used as a tag to be verified against the message and key from arguments 1 and 2.
Examples:
https://sit.instructure.com/courses/39000/pages/instructions-for-problem-1-of-hw-2 1/2

2020/11/16 Instructions for Problem 1 of HW 2: 2020F CS -306-A
Mac the default message with the default key: * java -cp *.jar stevens.cs306.mac.Main
Mac a different message, but still with the default key:
* java -cp *.jar stevens.cs306.mac.Main “My Test Message”
Mac a different message with a different key:
* java -cp *.jar stevens.cs306.mac.Main “My Test Message” “MyTestKey”
Verify a message/tag pair with key “MyTestKey”
* java -cp *.jar stevens.cs306.mac.Main “My Test Message” “MyTestKey” “1EC6C5F1A3D9C4D4880779C8113999EA”
https://sit.instructure.com/courses/39000/pages/instructions-for-problem-1-of-hw-2 2/2