async partial void ProcessEachInitIvExpand2(InitIvExpand2 initIvExpand2) { var ctx = context; if (ctx is null) { throw new InvalidOperationException("context should be set"); } ctx.PacketHandler.ReceivedFinalInitAck(); var(publicKey, privateKey) = TsCrypt.GenerateTemporaryKey(); var ekBase64 = Convert.ToBase64String(publicKey); var toSign = new byte[86]; Array.Copy(publicKey, 0, toSign, 0, 32); var beta = Convert.FromBase64String(initIvExpand2.Beta); Array.Copy(beta, 0, toSign, 32, 54); var sign = TsCrypt.Sign(ctx.ConnectionDataFull.Identity.PrivateKey, toSign); var proof = Convert.ToBase64String(sign); await ClientEk(ekBase64, proof); var result = ctx.TsCrypt.CryptoInit2(initIvExpand2.License, initIvExpand2.Omega, initIvExpand2.Proof, initIvExpand2.Beta, privateKey); if (!result) { ChangeState(ctx, TsClientStatus.Disconnected, CommandError.Custom($"Failed to calculate shared secret: {result.Error}")); return; } await DefaultClientInit(ctx); }
partial void ProcessEachInitIvExpand2(InitIvExpand2 initIvExpand2) { packetHandler.ReceivedFinalInitAck(); var(publicKey, privateKey) = TsCrypt.GenerateTemporaryKey(); var ekBase64 = Convert.ToBase64String(publicKey); var toSign = new byte[86]; Array.Copy(publicKey, 0, toSign, 0, 32); var beta = Convert.FromBase64String(initIvExpand2.Beta); Array.Copy(beta, 0, toSign, 32, 54); var sign = TsCrypt.Sign(connectionDataFull.Identity.PrivateKey, toSign); var proof = Convert.ToBase64String(sign); ClientEk(ekBase64, proof); var result = tsCrypt.CryptoInit2(initIvExpand2.License, initIvExpand2.Omega, initIvExpand2.Proof, initIvExpand2.Beta, privateKey); if (!result) { DisconnectInternal(context, CommandError.Custom($"Failed to calculate shared secret: {result.Error}")); return; } DefaultClientInit(); }