I assume you are missing this line from the client code:
byte[] cipherText = c.doFinal(msgByte);
Except for that, the most probable error is that servPubKey
and serverPrivateKey
does not match (i.e. they are not the two halves of the same RSA keypair).
A quick way to check that they match is to print servPubKey.getModulus() and serverPrivateKey.getModulus() and check that they are identical.
Rasmus Faber
2010-05-27 08:22:43