@@ -0,0 +1,1635 @@
+package backend;%0A%0Aimport java.io.FileInputStream;%0Aimport java.io.FileNotFoundException;%0Aimport java.io.IOException;%0A%0Apublic class MutualAuthentication %7B%0A%09ByteUtils util = new ByteUtils();%0A%09ConstantValues CV = new ConstantValues();%0A%09%0A%09int NOUNCE_LENGTH = 16;%0A%09%0A%09public MutualAuthentication()%7B%0A%09%09%0A%09%7D%0A%09%0A%09/**%0A%09 * Rental Terminal Authentication:%0A%09 * 1. Read RT Certificate from file%0A%09 * 2. Generate Nonce%0A%09 * 3. Combine those two and split them into two package%0A%09 * 4. Received 2 package from smartcard%0A%09 * 5. %0A%09 */%0A%09%0A%09public void RentalTerminalMutualAuth()%7B%0A%09%09%0A%09%09byte%5B%5D rtCert = readFiles(%22RTCert%22);  //Read Certificate for Rental Terminal%0A%09%09byte%5B%5D nounce = util.GenerateRandomBytes(NOUNCE_LENGTH); //generate nonces%0A%09%09%0A%09%09//Split the certificate into two package%0A%09%09byte%5B%5D pack1 = new byte%5BCV.PUBMODULUS + 1%5D;%0A%09%09System.arraycopy(rtCert, 0, pack1, 0, pack1.length); %0A%09%09byte%5B%5D pack2 = new byte%5BCV.SIG_LENGTH + NOUNCE_LENGTH%5D;%0A%09%09System.arraycopy(rtCert, CV.PUBMODULUS+1, pack2, 0, CV.SIG_LENGTH);%0A%09%09System.arraycopy(nounce, 0, pack2, CV.SIG_LENGTH, nounce.length);%0A%09%09%0A%09%7D%0A%09%0A%09public static void main(String%5B%5D args) %7B%0A%09%09MutualAuthentication ma = new MutualAuthentication();%0A%09%09ma.RentalTerminalMutualAuth();%0A%09%7D%0A%09%0A%09private byte%5B%5D readFiles(String filename) %7B%0A%09%09FileInputStream file;%0A%09%09byte%5B%5D bytes = null;%0A%09%09try %7B%0A%09%09%09file = new FileInputStream(filename);%0A%09%09%09bytes = new byte%5Bfile.available()%5D;%0A%09%09%09file.read(bytes);%0A%09%09%09file.close();%0A%09%09%7D catch (FileNotFoundException e) %7B%0A%09%09%09// TODO Auto-generated catch block%0A%09%09%09e.printStackTrace();%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09// TODO Auto-generated catch block%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%09return bytes;%0A%09%7D%0A%0A%7D%0A

add class for mutual auth