I'm making a socket program having key exchanging algorithm. This algorithm is very similar with SSL key exchanging in between web browser and web server. These are the steps in this algorithm.
- Server makes a socket with client.
- If the socket was established, server generates rsa public key, private key, and sends public key to client.
- Client receives rsa public key from server, and also generates rsa public key, private key, and sends public key to server.
- Server receives rsa public key from server.
- Server generates AES secret key, type is string.
- Server encrypt AESkey with client's rsa public key.
In this step, i have an error.
Because the type of key server received from client is not RSA Public Key, but byte array.
How can i change byte array to RSA Public key?
or is there the other way to restore RSA public key? like key Factory method in java?