comment RSA

This commit is contained in:
meysam navaei 2018-02-25 00:16:54 +03:30
parent d501cc8d49
commit 19f7230a52
2 changed files with 33 additions and 25 deletions

View file

@ -13,6 +13,7 @@ using TLSharp.Core.MTProto;
using TLSharp.Core.MTProto.Crypto;
using TLSharp.Core.Network;
using TLSharp.Core.Utils;
using static TLSharp.Core.MTProto.Serializers;
namespace TlgListenerApplication
{
@ -113,10 +114,12 @@ namespace TlgListenerApplication
{
nonceFromClient = binaryReader2.ReadBytes(16);
servernonce = binaryReader2.ReadBytes(16);
var useless = binaryReader2.ReadBytes(13);
var ciphertext = binaryReader2.ReadBytes(500);
var newnoncetemp = new byte[32];
Array.Copy(ciphertext, ciphertext.Length - 32, newnoncetemp,0,32);
var p = binaryReader2.ReadBytes(4);
var q = binaryReader2.ReadBytes(8);
var targetFingerprint = binaryReader2.ReadBytes(8);
var ciphertext = Bytes.read(binaryReader2);
Array.Copy(ciphertext, ciphertext.Length - 32, newNonce, 0, 32);
//ciphertext.CopyTo(newnoncetemp, ciphertext.Length - 32);
}
}
@ -177,10 +180,10 @@ namespace TlgListenerApplication
binaryWriter.Write(hashsum);
binaryWriter.Write(innerCode);
binaryWriter.Write(nonceFromClient);
binaryWriter.Write(newNonce);
binaryWriter.Write(servernonce);
binaryWriter.Write(123456789);
Serializers.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(777)).ToByteArrayUnsigned());
Bytes.write(binaryWriter, new BigInteger(1, BitConverter.GetBytes(888)).ToByteArrayUnsigned());
answer = memoryStream.ToArray();
}
}
@ -205,7 +208,7 @@ namespace TlgListenerApplication
binaryWriter.Write(innerCode);
binaryWriter.Write(newnonce);
binaryWriter.Write(nonceFromClient);
binaryWriter.Write(newnonce);
binaryWriter.Write(hashnewnonce);
outputdata = memoryStream.ToArray();
}
}

View file

@ -62,24 +62,29 @@ namespace TLSharp.Core.Auth
pqInnerDataWriter.Write(serverNonce);
pqInnerDataWriter.Write(newNonce);
byte[] ciphertext = null;
byte[] targetFingerprint = null;
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;
}
}
//TODO--change by main version code----
byte[] ciphertext = pqInnerData.ToArray();
byte[] targetFingerprint = fingerprints[0];
if (ciphertext == null)
{
throw new InvalidOperationException(
String.Format("not found valid key for fingerprints: {0}", String.Join(", ", fingerprints)));
}
//byte[] ciphertext = null;
//byte[] targetFingerprint = null;
//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))
{