Skip to content

Commit ddc4554

Browse files
committed
Removed legacy RSA code and expanded on XML comments for EncryptionBuffer
1 parent 2f83820 commit ddc4554

File tree

2 files changed

+6
-31
lines changed

2 files changed

+6
-31
lines changed

MLAPI/Data/NetworkConfig.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,15 @@ public class NetworkConfig
6464
[HideInInspector]
6565
internal string PlayerPrefabName;
6666
/// <summary>
67-
/// The size of the receive message buffer. This is the max message size.
67+
/// The size of the receive message buffer. This is the max message size including any MLAPI overheads.
6868
/// </summary>
6969
public int MessageBufferSize = 1024;
7070
/// <summary>
7171
/// The size of the encryption buffer, this is the buffer where messages will be decrypted to.
72+
/// If you plan on encrypting everything and you are pushing limits wth the MessageBufferSize already.
73+
/// Note that Encryption might add a few extra bytes of padding and 16 bytes for the IV, if authentication is also enabled
74+
/// 32 extra bytes will be used for the SHA256 hash of the HMAC.
75+
/// Note that authentication without encryption will not use this buffer at all.
7276
/// </summary>
7377
public int EncryptionBufferSize = 265;
7478
/// <summary>

MLAPI/MonoBehaviours/Core/NetworkingManager.cs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ internal set
147147
/// </summary>
148148
public event CustomMessageDelegete OnIncommingCustomMessage;
149149
public string ConnectedHostname { get; private set; }
150+
internal byte[] clientAesKey;
150151
internal static event Action OnSingletonReady;
151152

152153
internal void InvokeOnIncommingCustomMessage(uint clientId, Stream stream)
@@ -194,13 +195,6 @@ public void SendCustomMessage(uint clientId, Stream stream, string channel = "ML
194195
InternalMessageHandler.Send(clientId, MLAPIConstants.MLAPI_CUSTOM_MESSAGE, channel, stream, SecuritySendFlags.None);
195196
}
196197

197-
internal byte[] clientAesKey;
198-
199-
/// <summary>
200-
/// An inspector bool that acts as a Trigger for regenerating RSA keys. Should not be used outside Unity editor.
201-
/// </summary>
202-
public bool RegenerateRSAKeys = false;
203-
204198
private void OnValidate()
205199
{
206200
if (NetworkConfig == null)
@@ -244,30 +238,7 @@ private void OnValidate()
244238
if (LogHelper.CurrentLogLevel <= LogLevel.Normal) LogHelper.LogWarning("Only one networked prefab can be marked as a player prefab");
245239
}
246240
else NetworkConfig.PlayerPrefabName = NetworkConfig.NetworkedPrefabs.Find(x => x.playerPrefab == true).name;
247-
248-
}
249-
250-
/*
251-
if (!NetworkConfig.EnableEncryption)
252-
{
253-
RegenerateRSAKeys = false;
254-
}
255-
else
256-
{
257-
if (RegenerateRSAKeys)
258-
{
259-
#if !DISABLE_CRYPTOGRAPHY
260-
using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
261-
{
262-
rsa.PersistKeyInCsp = false;
263-
NetworkConfig.RSAPrivateKey = rsa.ToXmlString(true);
264-
NetworkConfig.RSAPublicKey = rsa.ToXmlString(false);
265-
}
266-
#endif
267-
RegenerateRSAKeys = false;
268-
}
269241
}
270-
*/
271242
}
272243

273244
private object Init(bool server)

0 commit comments

Comments
 (0)