package dslab.crypto; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; /** * domain object for the message rsa_encrypt(ok ) */ public class ClientChallengeMessage { private final byte[] challenge; private final SecretKeySpec key; private final IvParameterSpec initializationVector; public ClientChallengeMessage(byte[] challenge, SecretKeySpec key, IvParameterSpec iv) { //Assignment: "In our implementation, challenges are 32 byte" var challengeLength = challenge.length; if (challengeLength != 32) throw new IllegalArgumentException("Challenge should be 32 byte, was " + challengeLength); this.challenge = challenge; //Assignment: "AES initialization vectors are 16 byte random numbers" var ivLength = iv.getIV().length; if (ivLength != 16) throw new IllegalArgumentException("Initialization vector should be 16 bytes, was " + ivLength); this.initializationVector = iv; this.key = key; } public byte[] getChallenge() { return challenge; } public SecretKeySpec getKey() { return key; } public IvParameterSpec getInitializationVector() { return initializationVector; } }