Some notes related to this assignment.

Double Password Authentication

Few things to keep in mind in this exercise (mainly with regards to DataInputStream/DataOutputStream class:

Client Server
out.writeInt(digestValue.length);
out.write(digestValue);
out.flush();

//digestValue is of type byte[]

int length = in.readInt();
byte[] protected = new byte[length];
in.readFully(protected);

//reads the number of bytes equal to length of protected

MessageDigest.isEqual(recomputedDigest, receivedDigest);

 

ElGamal Signature

Keys

Signing message m

Verifying the signature

(y^a).(a^b) mod p = g^m mod p

Note "(y^a).(a^b) mod p" is equivalent to "[(y^a) mod p] [(a^b) mod p] mod p"

Some issues

BigInteger pOne = BigInteger.valueOf(1);

BigInteger pMinusOne = p.substract(pOne)  // where p is the random number

loop {

BigInteger k = new BigInterger (???);  // check existing code of this type

                    } until k is relatively prime to (p-1)

To check "BigInteger k is relatively prime to BigInteger p" you can do the following:

                    k.gcd(pMinusOne).equals(pOne) == true;