Skip to content

Commit a27e4de

Browse files
authored
Merge pull request #31 from TwoTenPvP/cryptography-2
Cryptography 2
2 parents cf34bc3 + ec0ba47 commit a27e4de

File tree

8 files changed

+541
-17
lines changed

8 files changed

+541
-17
lines changed

MLAPI/Data/NetworkedClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ public class NetworkedClient
88
public int ClientId;
99
public GameObject PlayerObject;
1010
public List<NetworkedObject> OwnedObjects = new List<NetworkedObject>();
11+
public byte[] AesKey;
1112
}
1213
}

MLAPI/Data/NetworkingConfiguration.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class NetworkingConfiguration
1313
public List<string> MessageTypes = new List<string>();
1414
public List<string> PassthroughMessageTypes = new List<string>();
1515
internal HashSet<ushort> RegisteredPassthroughMessageTypes = new HashSet<ushort>();
16+
public HashSet<int> EncryptedChannels = new HashSet<int>();
1617
public List<string> RegisteredScenes = new List<string>();
1718
public int MessageBufferSize = 65535;
1819
public int ReceiveTickrate = 64;
@@ -28,11 +29,12 @@ public class NetworkingConfiguration
2829
public byte[] ConnectionData = new byte[0];
2930
public float SecondsHistory = 5;
3031
public bool HandleObjectSpawning = true;
31-
//TODO
32-
public bool CompressMessages = false;
33-
//Should only be used for dedicated servers and will require the servers RSA keypair being hard coded into clients in order to exchange a AES key
34-
//TODO
35-
public bool EncryptMessages = false;
32+
33+
public bool EnableEncryption = true;
34+
public bool SignKeyExchange = true;
35+
public string RSAPrivateKey = "<RSAKeyValue><Modulus>vBEvOQki/EftWOgwh4G8/nFRvcDJLylc8P7Dhz5m/hpkkNtAMzizNKYUrGbs7sYWlEuMYBOWrzkIDGOMoOsYc9uCi+8EcmNoHDlIhK5yNfZUexYBF551VbvZ625LSBR7kmBxkyo4IPuA09fYCHeUFm3prt4h6aTD0Hjc7ZsJHUU=</Modulus><Exponent>EQ==</Exponent><P>ydgcrq5qLJOdDQibD3m9+o3/dkKoFeCC110dnMgdpEteCruyBdL0zjGKKvjjgy3XTSSp43EN591NiXaBp0JtDw==</P><Q>7obHrUnUCsSHUsIJ7+JOrupcGrQ0XaYcQ+Uwb2v7d2YUzwZ46U4gI9snfD2J0tc3DGEh3v3G0Q8q7bxEe3H4aw==</Q><DP>L34k3c6vkgSdbHp+1nb/hj+HZx6+I0PijQbZyolwYuSOmR0a1DGjA1bzVWe9D86NAxevgM9OkOjG8yrxVIgZqQ==</DP><DQ>OB+2gyBuIKa2bdNNodrlVlVC2RtXnZB/HwjAGjeGdnJfP8VJoE6eJo3rLEq3BG7fxq1xYaUfuLhGVg4uOyngGQ==</DQ><InverseQ>o97PimYu58qH5eFmySRCIsyhBr/tK2GM17Zd9QQPJZRSorrhIJn1m6gwQ/G5aJLIM/3Yl04CoyqmQGsPXMzW2w==</InverseQ><D>CxAR1i22w4vCquB7U0Pd8Nl9R2Wxez6rHTwpnoszPB+rkAzlqKj7e5FMgpykhoQfciKPyWqQZKkAeTMIRbN56JinvpAt5POId/28HDd5xjGymHE81k3RzoHqzQXFIOF1TSYKUWzjPPF/TU4nn7auD4i6lOODATsMqtLr5DRBN/0=</D></RSAKeyValue>"; //CHANGE THESE FOR PRODUCTION!
36+
public string RSAPublicKey = "<RSAKeyValue><Modulus>vBEvOQki/EftWOgwh4G8/nFRvcDJLylc8P7Dhz5m/hpkkNtAMzizNKYUrGbs7sYWlEuMYBOWrzkIDGOMoOsYc9uCi+8EcmNoHDlIhK5yNfZUexYBF551VbvZ625LSBR7kmBxkyo4IPuA09fYCHeUFm3prt4h6aTD0Hjc7ZsJHUU=</Modulus><Exponent>EQ==</Exponent></RSAKeyValue>"; //CHANGE THESE FOR PRODUCTION!
37+
3638
public bool AllowPassthroughMessages = true;
3739
public bool EnableSceneSwitching = false;
3840

@@ -72,8 +74,7 @@ public byte[] GetConfig(bool cache = true)
7274
}
7375
}
7476
writer.Write(HandleObjectSpawning);
75-
writer.Write(CompressMessages);
76-
writer.Write(EncryptMessages);
77+
writer.Write(EnableEncryption);
7778
writer.Write(AllowPassthroughMessages);
7879
writer.Write(EnableSceneSwitching);
7980
}

MLAPI/MLAPI.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
4545
</PropertyGroup>
4646
<ItemGroup>
47+
<Reference Include="IntXLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1744b76c74eaee1e, processorArchitecture=MSIL">
48+
<HintPath>..\packages\IntX.1.0.1.0\lib\net20\IntXLib.dll</HintPath>
49+
</Reference>
4750
<Reference Include="System" />
4851
<Reference Include="System.Core" />
4952
<Reference Include="System.Xml.Linq" />
@@ -62,6 +65,9 @@
6265
<Compile Include="Data\TrackedPointData.cs" />
6366
<Compile Include="MonoBehaviours\Prototyping\NetworkedAnimator.cs" />
6467
<Compile Include="MonoBehaviours\Prototyping\NetworkedNavMeshAgent.cs" />
68+
<Compile Include="NetworkingManagerComponents\CryptographyHelper.cs" />
69+
<Compile Include="NetworkingManagerComponents\DiffieHellman.cs" />
70+
<Compile Include="NetworkingManagerComponents\EllipticCurve.cs" />
6571
<Compile Include="NetworkingManagerComponents\LagCompensationManager.cs" />
6672
<Compile Include="MonoBehaviours\Core\NetworkedBehaviour.cs" />
6773
<Compile Include="Data\NetworkedClient.cs" />
@@ -79,5 +85,8 @@
7985
<Compile Include="Data\ClientIdKey.cs" />
8086
<Compile Include="NetworkingManagerComponents\MessageChunker.cs" />
8187
</ItemGroup>
88+
<ItemGroup>
89+
<None Include="packages.config" />
90+
</ItemGroup>
8291
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
8392
</Project>

0 commit comments

Comments
 (0)