Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpbcgr.TS_FP_UPDATE_PDU.ToBytes C# (CSharp) Method

ToBytes() public method

public ToBytes ( ) : byte[]
return byte[]
        public override byte[] ToBytes()
        {
            List<byte> totalBuffer = new List<byte>();

            byte[] fpOutputdata = EncodeFpOutputData();
            byte[] encryptedData = null;
            byte[] signature = null;

            if (serverSessionContext.RdpEncryptionLevel != EncryptionLevel.ENCRYPTION_LEVEL_NONE && serverSessionContext.RdpEncryptionLevel != EncryptionLevel.ENCRYPTION_LEVEL_LOW)
            {
                if (serverSessionContext.RdpEncryptionLevel == EncryptionLevel.ENCRYPTION_LEVEL_FIPS
                    && fipsInformation.padlen == 0)
                {
                    fipsInformation.padlen = (byte)(ConstValue.TRIPLE_DES_PAD
                                           - (fpOutputdata.Length % ConstValue.TRIPLE_DES_PAD));
                }

                // encryptionFlags (2 bits): A higher 2-bit field containing the flags
                // that describe the cryptographic parameters of the PDU.
                bool isSalted = ((fpOutputHeader >> 6) &
                                 (int)encryptionFlags_Values.FASTPATH_INPUT_SECURE_CHECKSUM)
                                 == (int)encryptionFlags_Values.FASTPATH_INPUT_SECURE_CHECKSUM;
                serverSessionContext.ServerEncrypt(fpOutputdata, isSalted, out encryptedData, out signature);
                if (dataSignature == null)
                {
                    dataSignature = signature;
                }
            }
            else
            {
                encryptedData = fpOutputdata;
            }

            byte[] fpHeaderData = EncodeFpHeaderData(encryptedData.Length);

            RdpbcgrEncoder.EncodeBytes(totalBuffer, fpHeaderData);
            RdpbcgrEncoder.EncodeBytes(totalBuffer, encryptedData);

            byte[] encodedBytes = RdpbcgrUtility.ToBytes(totalBuffer);

            // ToDo: Ugly dump message code here
            // ETW Provider Dump Code
            bool isEncrypted = serverSessionContext.RdpEncryptionLevel != EncryptionLevel.ENCRYPTION_LEVEL_NONE && serverSessionContext.RdpEncryptionLevel != EncryptionLevel.ENCRYPTION_LEVEL_LOW;
            RdpbcgrUtility.ETWProviderDump(this.GetType().Name, encodedBytes, isEncrypted, fpOutputdata);

            return totalBuffer.ToArray();
        }