Suppose users A and B exchange message P in a publickey syst

Suppose users A and B exchange message P in a public-key system (like RSA) using the following protocol: A signs P using A\'s private key, K_Ad, and sends the message to B along with plaintext giving both A\'s and B\'s identity: (A, B, P, signK_Ad(P)) = M. B verifies A\'s signature by using A\'s public key K_Ae and computing verK_Ae (signK_AD(P)) = P and replies to A with (B, A, P, signK_Bd(P)) where K_Bd is B\'s private key. Explain why each of the following properties is either true or why it is false. If a property is false, suggest a way to fix it. You can assume that A and B can get each other\'s verification keys and that they can be sure that the keys are owned by the claimed owners. The signatures are authentic (each user did sign the message). The signatures are not reusable (cannot be replayed). The signed document is unalterable (integrity).

Solution

import java.io.DataInputStream; import java.io.IOException; import java.math.BigInteger; import java.util.Random; public class RSA { private BigInteger p; private BigInteger q; private BigInteger N; private BigInteger phi; private BigInteger e; private BigInteger d; private int bitlength = 1024; private Random r; public RSA() { r = new Random(); p = BigInteger.probablePrime(bitlength, r); q = BigInteger.probablePrime(bitlength, r); N = p.multiply(q); phi = p.subtract(BigInteger.ONE).multiply(q.subtract(BigInteger.ONE)); e = BigInteger.probablePrime(bitlength / 2, r); while (phi.gcd(e).compareTo(BigInteger.ONE) > 0 && e.compareTo(phi) < 0) { e.add(BigInteger.ONE); } d = e.modInverse(phi); } public RSA(BigInteger e, BigInteger d, BigInteger N) { this.e = e; this.d = d; this.N = N; } @SuppressWarnings(\"deprecation\") public static void main(String[] args) throws IOException { RSA rsa = new RSA(); DataInputStream in = new DataInputStream(System.in); String teststring; System.out.println(\"Enter the plain text:\"); teststring = in.readLine(); System.out.println(\"Encrypting String: \" + teststring); System.out.println(\"String in Bytes: \" + bytesToString(teststring.getBytes())); // encrypt byte[] encrypted = rsa.encrypt(teststring.getBytes()); // decrypt byte[] decrypted = rsa.decrypt(encrypted); System.out.println(\"Decrypting Bytes: \" + bytesToString(decrypted)); System.out.println(\"Decrypted String: \" + new String(decrypted)); } private static String bytesToString(byte[] encrypted) { String test = \"\"; for (byte b : encrypted) { test += Byte.toString(b); } return test; } // Encrypt message public byte[] encrypt(byte[] message) { return (new BigInteger(message)).modPow(e, N).toByteArray(); } // Decrypt message public byte[] decrypt(byte[] message) { return (new BigInteger(message)).modPow(d, N).toByteArray(); } }
 Suppose users A and B exchange message P in a public-key system (like RSA) using the following protocol: A signs P using A\'s private key, K_Ad, and sends the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site