ZenVirZan":3lwlkxbb said:
so this 'secure connection' is what i'm trying to work out
do i need to use existing libraries or something for it?
It's a rather complex subject. For a hobby system; I'm not sure even I would bother. Easiest way would be "RSA encryption", there's likely a library for that (
here's a tiny one written in C). There's a few out there.
I might write my own for fun, actually. Always seemed like a neat little computer science task.
https://en.wikipedia.org/wiki/RSA_(cryptosystem)#Code
The way it works is; the public keys are exchanged over the network in plain-text, anyone can look at these, that's perfectly fine.
If I want to send a secure message from A to B then A needs to use B's public key to encrypt the message. The encrypted message can now be sent to B (anyone can look at this, it's encrypted so it should be nonsense). B now uses its private key (that it hasn't sent to ANYONE, it must never leave B!) to decrypt the message it received from A. Secure transmission completed.
RSA doesn't protect from man-in-the-middle attacks, where an attacker sits between A and B, pretends to be A, pretends to be B and decrypts, reads, re-encrypts the messages as they come. SSL certificates is an attempt to protect from this (and are even more of a headache to set-up, for a game it might not be worth it).
The best security is always let one of the big boys handle the authentication. Facebook auth, Google sign-in, etc. These are a pain to implement also, but they're the best way to handle authentication (let someone else with lots of money and lots more at stake handle it).