openssl Frage zu rsa und aes
-
hallo,
ich habe vor einen simplen Server und Clienten zu schreiben. Die Struktur habe ich mir vom Minecraft-Server abgeschaut. Hier mal der Ablauf:
Client connects to server
C->S 0x02 handshake
S->C 0xFD encryption request - server sends its public key and 4 random bytes
Client generates symmetric key (shared secret)
Client authenticates via session.minecraft.net
Client encrypts these 4 bytes with the servers public key.
C->S 0xFC encryption response - client encrypts shared secret with server's public key and sends along with encrypted 4 bytes
Server checks that the encrypted bytes match
Server decrypts shared secret with its private key
Server checks player authenticity via session.minecraft.net
S->C 0xFC encryption response - empty payload meaning two zero length byte arrays and two zero shorts
Server enables AES stream encryption
Client enables AES stream encryptionMein Problem ist jetzt wie ich den symmetric key(shared secret) erstelle. Das RSA Keypair habe ich schon erstellt und den privaten Schlüssel extrahiert.
Die openssl docu ist sehr "cryptisch" und ich konnte bis jetzt kein Beispiel hierfür finden
Hat jemand Tutorials oder ein Codebeispiel?
-
Ich bin jetzt etwas weiter.
Der public key ist im asn.1 Format und ich habe ihn so zum Clienten geschickt. Jetzt möchte ich die 4 random bytes die auch vom Server geschickt wurden mit dem public key verschlüsseln.
Allerdings habe ich Probleme den public key im vorligenden Format zum Verschlüsseln zu verwenden.