You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (!certificate.HasPrivateKey) throw new CryptographicException("[MLAPI] No private key was found in server certificate. Unable to sign key exchange");
685
685
RSACryptoServiceProvider rsa = certificate.PrivateKey as RSACryptoServiceProvider;
686
-
DSACryptoServiceProvider dsa = certificate.PrivateKey as DSACryptoServiceProvider;
687
686
688
687
if (rsa != null)
689
688
{
690
-
hailWriter.WriteByteArray(rsa.SignData(diffieHellmanPublicPart, new SHA256Managed()));
691
-
}
692
-
else if (dsa != null)
693
-
{
694
-
using (SHA256Managed sha = new SHA256Managed())
689
+
using (SHA256CryptoServiceProvider sha = new SHA256CryptoServiceProvider())
RSACryptoServiceProvider rsa = certificate.PublicKey.Key as RSACryptoServiceProvider;
140
-
DSACryptoServiceProvider dsa = certificate.PublicKey.Key as DSACryptoServiceProvider;
141
120
142
121
if (rsa != null)
143
122
{
144
-
if (!rsa.VerifyData(diffieHellmanPublic, new SHA256Managed(), diffieHellmanPublicSignature))
123
+
using (SHA256CryptoServiceProvider sha = new SHA256CryptoServiceProvider())
145
124
{
146
-
//Man in the middle.
147
-
if (LogHelper.CurrentLogLevel <= LogLevel.Normal) if (LogHelper.CurrentLogLevel <= LogLevel.Normal) LogHelper.LogWarning("Signature doesnt match for the key exchange public part. Disconnecting");
148
-
netManager.DisconnectClient(clientId);
149
-
return;
150
-
}
151
-
}
152
-
else if (dsa != null)
153
-
{
154
-
using (SHA256Managed sha = new SHA256Managed())
155
-
{
156
-
if (!dsa.VerifySignature(sha.ComputeHash(diffieHellmanPublic), diffieHellmanPublicSignature))
if (LogHelper.CurrentLogLevel <= LogLevel.Normal) if (LogHelper.CurrentLogLevel <= LogLevel.Normal) LogHelper.LogWarning("Signature doesnt match for the key exchange public part. Disconnecting");
130
+
if (LogHelper.CurrentLogLevel <= LogLevel.Normal) if (LogHelper.CurrentLogLevel <= LogLevel.Normal) LogHelper.LogWarning("Signature length doesnt match for the key exchange public part. Disconnecting");
160
131
netManager.DisconnectClient(clientId);
161
132
return;
162
133
}
134
+
for (int i = 0; i < clientHash.Length; i++)
135
+
{
136
+
if (clientHash[i] != serverHash[i])
137
+
{
138
+
//Man in the middle.
139
+
if (LogHelper.CurrentLogLevel <= LogLevel.Normal) if (LogHelper.CurrentLogLevel <= LogLevel.Normal) LogHelper.LogWarning("Signature doesnt match for the key exchange public part. Disconnecting");
140
+
netManager.DisconnectClient(clientId);
141
+
return;
142
+
}
143
+
}
163
144
}
164
145
}
146
+
else
147
+
{
148
+
throw new CryptographicException("[MLAPI] Only RSA certificates are supported. No valid RSA key was found");
0 commit comments