Encryption scheme advice please!
Hi all,
I am trying to implement a client/server messaging scheme over a network socket.
I have never performed any kind of encryption before, so this is my first try!
I am currently trying to get it to work with the following scheme in order to establish communication using symmetric encryption:
1) server generates a "RSA/ECB/PKCS1Padding" asymmetric key pair (for each client) with a 512-bit key size.
2) server sends the serialised public key part of this pair and an md5 hash of the public key to the client
3) client verifies the public key with the hash and deserialises it into a PublicKey object.
4) client generates a symmetric key (128-bit "AES/None/NoPadding") and IV (128-bit, using SecureRandom "SHA1PRNG")
5) client sends symmetric key and IV to server, encrypted asymmetrically using servers' public key, and a hash as above
6) communication can now continue back and forth with symmetric encryption.
I have the following questions:
a) is this scheme any good?!
b) should I incorporate signatures for any of these messages? if so, where?
c) my attempts to implement signatures ("MD5withRSA") always returns false when I attempt to verify. The sender creates a signature of the message using the senders private key. The recipient attempts to verify the signature with the public key part of the pair. What am I doing wrong?!
d) have I chosen suitable algorithms, i.e. "RSA/ECB/PKCS1Padding", "AES/None/NoPadding" and "MD5withRSA"? And the key sizes?
e) presumably, if I implement signatures, I don't also have to produce hashes, since the signatures always contain a hash? If this is the case, how do I verify the content of the message, since I can't access the hash part of the signature in order to compare? The signature itself only authenticates the message - is that right?
Any help with any of this is much appreciated - why do things like this have to be so complicated?!
Thanks in advance!

