mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
comment RSA
This commit is contained in:
parent
d501cc8d49
commit
19f7230a52
|
|
@ -13,6 +13,7 @@ using TLSharp.Core.MTProto;
|
||||||
using TLSharp.Core.MTProto.Crypto;
|
using TLSharp.Core.MTProto.Crypto;
|
||||||
using TLSharp.Core.Network;
|
using TLSharp.Core.Network;
|
||||||
using TLSharp.Core.Utils;
|
using TLSharp.Core.Utils;
|
||||||
|
using static TLSharp.Core.MTProto.Serializers;
|
||||||
|
|
||||||
namespace TlgListenerApplication
|
namespace TlgListenerApplication
|
||||||
{
|
{
|
||||||
|
|
@ -113,10 +114,12 @@ namespace TlgListenerApplication
|
||||||
{
|
{
|
||||||
nonceFromClient = binaryReader2.ReadBytes(16);
|
nonceFromClient = binaryReader2.ReadBytes(16);
|
||||||
servernonce = binaryReader2.ReadBytes(16);
|
servernonce = binaryReader2.ReadBytes(16);
|
||||||
var useless = binaryReader2.ReadBytes(13);
|
var p = binaryReader2.ReadBytes(4);
|
||||||
var ciphertext = binaryReader2.ReadBytes(500);
|
var q = binaryReader2.ReadBytes(8);
|
||||||
var newnoncetemp = new byte[32];
|
var targetFingerprint = binaryReader2.ReadBytes(8);
|
||||||
Array.Copy(ciphertext, ciphertext.Length - 32, newnoncetemp,0,32);
|
|
||||||
|
var ciphertext = Bytes.read(binaryReader2);
|
||||||
|
Array.Copy(ciphertext, ciphertext.Length - 32, newNonce, 0, 32);
|
||||||
//ciphertext.CopyTo(newnoncetemp, ciphertext.Length - 32);
|
//ciphertext.CopyTo(newnoncetemp, ciphertext.Length - 32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -177,10 +180,10 @@ namespace TlgListenerApplication
|
||||||
binaryWriter.Write(hashsum);
|
binaryWriter.Write(hashsum);
|
||||||
binaryWriter.Write(innerCode);
|
binaryWriter.Write(innerCode);
|
||||||
binaryWriter.Write(nonceFromClient);
|
binaryWriter.Write(nonceFromClient);
|
||||||
binaryWriter.Write(newNonce);
|
binaryWriter.Write(servernonce);
|
||||||
binaryWriter.Write(123456789);
|
binaryWriter.Write(123456789);
|
||||||
Serializers.Bytes.write(binaryWriter, new BigInteger(1, BitConverter.GetBytes(777)).ToByteArrayUnsigned());
|
Bytes.write(binaryWriter, new BigInteger(1, BitConverter.GetBytes(777)).ToByteArrayUnsigned());
|
||||||
Serializers.Bytes.write(binaryWriter, new BigInteger(1, BitConverter.GetBytes(888)).ToByteArrayUnsigned());
|
Bytes.write(binaryWriter, new BigInteger(1, BitConverter.GetBytes(888)).ToByteArrayUnsigned());
|
||||||
answer = memoryStream.ToArray();
|
answer = memoryStream.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -205,7 +208,7 @@ namespace TlgListenerApplication
|
||||||
binaryWriter.Write(innerCode);
|
binaryWriter.Write(innerCode);
|
||||||
binaryWriter.Write(newnonce);
|
binaryWriter.Write(newnonce);
|
||||||
binaryWriter.Write(nonceFromClient);
|
binaryWriter.Write(nonceFromClient);
|
||||||
binaryWriter.Write(newnonce);
|
binaryWriter.Write(hashnewnonce);
|
||||||
outputdata = memoryStream.ToArray();
|
outputdata = memoryStream.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,24 +62,29 @@ namespace TLSharp.Core.Auth
|
||||||
pqInnerDataWriter.Write(serverNonce);
|
pqInnerDataWriter.Write(serverNonce);
|
||||||
pqInnerDataWriter.Write(newNonce);
|
pqInnerDataWriter.Write(newNonce);
|
||||||
|
|
||||||
byte[] ciphertext = null;
|
//TODO--change by main version code----
|
||||||
byte[] targetFingerprint = null;
|
byte[] ciphertext = pqInnerData.ToArray();
|
||||||
foreach (byte[] fingerprint in fingerprints)
|
byte[] targetFingerprint = fingerprints[0];
|
||||||
{
|
|
||||||
ciphertext = RSA.Encrypt(BitConverter.ToString(fingerprint).Replace("-", string.Empty),
|
|
||||||
pqInnerData.GetBuffer(), 0, (int)pqInnerData.Position);
|
|
||||||
if (ciphertext != null)
|
|
||||||
{
|
|
||||||
targetFingerprint = fingerprint;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ciphertext == null)
|
|
||||||
{
|
//byte[] ciphertext = null;
|
||||||
throw new InvalidOperationException(
|
//byte[] targetFingerprint = null;
|
||||||
String.Format("not found valid key for fingerprints: {0}", String.Join(", ", fingerprints)));
|
//foreach (byte[] fingerprint in fingerprints)
|
||||||
}
|
//{
|
||||||
|
// ciphertext = RSA.Encrypt(BitConverter.ToString(fingerprint).Replace("-", string.Empty),
|
||||||
|
// pqInnerData.GetBuffer(), 0, (int)pqInnerData.Position);
|
||||||
|
// if (ciphertext != null)
|
||||||
|
// {
|
||||||
|
// targetFingerprint = fingerprint;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//if (ciphertext == null)
|
||||||
|
//{
|
||||||
|
// throw new InvalidOperationException(
|
||||||
|
// String.Format("not found valid key for fingerprints: {0}", String.Join(", ", fingerprints)));
|
||||||
|
//}
|
||||||
|
|
||||||
using (MemoryStream reqDHParams = new MemoryStream(1024))
|
using (MemoryStream reqDHParams = new MemoryStream(1024))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue