SubnauticaNitrox / Nitrox

An open-source, multiplayer modification for the game Subnautica.
GNU General Public License v3.0
1.74k stars 1.05k forks source link

Packet encryption using RSA #1996

Open Measurity opened 1 year ago

Measurity commented 1 year ago

Describe the issue

Packets should be encrypted using symmetric encryption for privacy with reasonable speed. The password/key for the symmetric encryption is provided using an asymmetric encryption like RSA. This process is called envelope encryption.

How to implement

  1. Each server should generate a unique asymmetric private/public key pair (per save file?).
  2. The server announces only the public key when a client joins.
  3. The client will then generate a unique password that should be used for all packet encryption going forward, and encrypt it using the public key from server. Then the client sends the RSA encrypted symmetric encryption password to the server.
  4. A confirmation packet is sent to verify that the symmetric encryption is understood by both client and server using the client-side generated password.

If a client rejoins, the steps are repeated as-is. The client does not need to remember the public key since it might be changed in the future by server.

Further improvements and side notes

killzoms commented 1 year ago

On Steam we can get an ID that is unique to each steam account that we can use, while on Epic Games... I believe there is a similar method. BUT Microsoft Store does not have this feature, Discord SDK might however

tornac1234 commented 1 year ago

We could probably make an auth portal or smth that could even accept google authentication

RokeJulianLockhart commented 1 year ago

https://github.com/SubnauticaNitrox/Nitrox/issues/1996#issuecomment-1454803697

@tornac1234, Google OAuth is unavailable in some countries. Something more resilient (albeit basic) like OpenID might be better...?