Question: Given the provided support code in Java, implement a secure secret-key message authentication code that employs only a block cipher (and no other cryptographic primitive)
Given the provided support code in Java, implement a secure 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. In particular, as specified in the provided instructions:
(1) Implement the mac() and verify() methods. (20%)
(2) Demonstrate that they are correct by providing the MAC tag (in hexidecimal) of the specified default message using the specified default key. (10%)
(3) Explain which of the MAC algorithms covered in class you implemented and why. What are the domain-extension features of your algorithm in relation to its security? (10%)
Hint: Does your implementation securely handle messages of fixed size, messages of any size, or messages of any fixed size?
==============================================
package stevens.cs396.mac;
import java.security.Key;
// Implement this class public class Mac extends MacSkeleton {
/** * Implement the mac and verify methods. Mac should take a message and a * key (generated by the generate method) and return a tag. Verify should * take a message, tag, and key -- and authenticate that the tag corresponds * to the message/tag pair by returning true or false. * * The following methods have been made available to you through the * MacSkeleton class: * * byte[] xor(byte[] a, byte[] b) :: XOR two byte arrays. Returns result * byte[] pad(byte[] message, int blockSz) :: pads message to blockSz * byte[] encryptBlock(byte[] block, Key key) :: Encrypts a single block * int getBlockSize() :: Returns the block size of the cipher */
/** * Creates a message authentication tag for a message with a given key. * @param message The message to generate a MAC for * @param key A secret key to use for MAC'ing the message * @return A valid tag for the message */ public byte[] mac(byte[] message, Key key) { // TODO return null; }
/** * Authenticates a message/tag pair with a key. Returns true if the pair * is authentic, else false. * @param message message to authenticate * @param tag a MAC tag to authenticate with the message * @param key secret key to authenticate the tag with */ public boolean verify(byte[] message, byte[] tag, Key key) { // TODO return false; }
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
