Fixed DiffieHellman issues
This commit is contained in:
parent
a7dfddf621
commit
bd4b685e84
@ -580,8 +580,8 @@ namespace MLAPI
|
|||||||
byte[] aesKey = new byte[0];
|
byte[] aesKey = new byte[0];
|
||||||
if(NetworkConfig.EnableEncryption)
|
if(NetworkConfig.EnableEncryption)
|
||||||
{
|
{
|
||||||
ushort diffiePublicSize = reader.ReadUInt16();
|
ushort diffiePublicSize = messageReader.ReadUInt16();
|
||||||
byte[] diffiePublic = reader.ReadBytes(diffiePublicSize);
|
byte[] diffiePublic = messageReader.ReadBytes(diffiePublicSize);
|
||||||
diffieHellmanPublicKeys.Add(clientId, diffiePublic);
|
diffieHellmanPublicKeys.Add(clientId, diffiePublic);
|
||||||
/*
|
/*
|
||||||
EllipticDiffieHellman diffieHellman = new EllipticDiffieHellman(EllipticDiffieHellman.DEFAULT_CURVE, EllipticDiffieHellman.DEFAULT_GENERATOR, EllipticDiffieHellman.DEFAULT_ORDER);
|
EllipticDiffieHellman diffieHellman = new EllipticDiffieHellman(EllipticDiffieHellman.DEFAULT_CURVE, EllipticDiffieHellman.DEFAULT_GENERATOR, EllipticDiffieHellman.DEFAULT_ORDER);
|
||||||
@ -619,8 +619,8 @@ namespace MLAPI
|
|||||||
|
|
||||||
if (NetworkConfig.EnableEncryption)
|
if (NetworkConfig.EnableEncryption)
|
||||||
{
|
{
|
||||||
ushort keyLength = reader.ReadUInt16();
|
ushort keyLength = messageReader.ReadUInt16();
|
||||||
clientAesKey = clientDiffieHellman.GetSharedSecret(reader.ReadBytes(keyLength));
|
clientAesKey = clientDiffieHellman.GetSharedSecret(messageReader.ReadBytes(keyLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
float netTime = messageReader.ReadSingle();
|
float netTime = messageReader.ReadSingle();
|
||||||
|
@ -85,7 +85,7 @@ namespace MLAPI.NetworkingManagerComponents
|
|||||||
{
|
{
|
||||||
v.GetInternalState(out uint[] digits, out bool negative);
|
v.GetInternalState(out uint[] digits, out bool negative);
|
||||||
byte[] b = DigitConverter.ToBytes(digits);
|
byte[] b = DigitConverter.ToBytes(digits);
|
||||||
byte[] b1 = new byte[b.Length];
|
byte[] b1 = new byte[b.Length + 1];
|
||||||
Array.Copy(b, b1, b.Length);
|
Array.Copy(b, b1, b.Length);
|
||||||
b1[b.Length] = (byte)(negative ? 1 : 0);
|
b1[b.Length] = (byte)(negative ? 1 : 0);
|
||||||
return b1;
|
return b1;
|
||||||
@ -98,7 +98,7 @@ namespace MLAPI.NetworkingManagerComponents
|
|||||||
uint[] u = DigitConverter.FromBytes(b1);
|
uint[] u = DigitConverter.FromBytes(b1);
|
||||||
return new IntX(u, b[b.Length - 1]==1);
|
return new IntX(u, b[b.Length - 1]==1);
|
||||||
}
|
}
|
||||||
public static bool BitAt(this uint[] data, long index) => (data[index/8]&(1<<(int)(index%8)))!=0;
|
public static bool BitAt(this uint[] data, long index) => (data[index / 32] & (1 << (int)(index % 32))) != 0;
|
||||||
public static IntX Abs(this IntX i) => i < 0 ? -i : i;
|
public static IntX Abs(this IntX i) => i < 0 ? -i : i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user