Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpbcgr.RdpbcgrServerDecoder.ParseSecurityExchange C# (CSharp) Method

ParseSecurityExchange() private method

Parse TS_SECURITY_PACKET (parser index is updated according to parsed length)
private ParseSecurityExchange ( RdpbcgrServerSessionContext serverSessionContext, byte data, int &currentIndex ) : TS_SECURITY_PACKET
serverSessionContext RdpbcgrServerSessionContext the server session context
data byte data to be parsed
currentIndex int current parser index
return TS_SECURITY_PACKET
        private TS_SECURITY_PACKET ParseSecurityExchange(
            RdpbcgrServerSessionContext serverSessionContext,
            byte[] data,
            ref int currentIndex)
        {
            TS_SECURITY_PACKET secExchangeData = new TS_SECURITY_PACKET();
            secExchangeData.length = ParseUInt32(data, ref currentIndex, false);

            byte[] encryptedRandom = GetBytes(data, ref currentIndex, (int)secExchangeData.length);

            byte[] decryptedRandom = RdpbcgrUtility.DecryptClientRandom(
                encryptedRandom,
                serverSessionContext.ServerPrivateExponent,
                serverSessionContext.ServerModulus);

            if (decryptedRandom.Length != ConstValue.CLIENT_RANDOM_NUMBER_SIZE)
            {
                Array.Resize<byte>(ref decryptedRandom, ConstValue.CLIENT_RANDOM_NUMBER_SIZE);
            }

            int startIndex = 0;
            //secExchangeData.clientRandom =
            //    GetBytes(decryptedRandom, ref startIndex, (int)secExchangeData.length - 40);
            secExchangeData.clientRandom =
                GetBytes(decryptedRandom, ref startIndex, decryptedRandom.Length);

            return secExchangeData;
        }
RdpbcgrServerDecoder