internal byte[] EncryptWithSessionKey(byte[] data)
        {
            byte[] pbData = new byte[data.Length];
            Array.Copy((Array)data, 0, (Array)pbData, 0, data.Length);
            int length = pbData.Length;

            if (!PSCryptoNativeUtils.CryptEncrypt(this.hSessionKey, IntPtr.Zero, true, 0U, pbData, ref length, data.Length))
            {
                for (int index = 0; index < pbData.Length; ++index)
                {
                    pbData[index] = (byte)0;
                }
                pbData = new byte[length];
                Array.Copy((Array)data, 0, (Array)pbData, 0, data.Length);
                length = data.Length;
                this.CheckStatus(PSCryptoNativeUtils.CryptEncrypt(this.hSessionKey, IntPtr.Zero, true, 0U, pbData, ref length, pbData.Length));
            }
            byte[] numArray = new byte[length];
            Array.Copy((Array)pbData, 0, (Array)numArray, 0, length);
            return(numArray);
        }
Пример #2
0
        internal byte[] EncryptWithSessionKey(byte[] data)
        {
            byte[] destinationArray = new byte[data.Length];
            Array.Copy(data, 0, destinationArray, 0, data.Length);
            int length = destinationArray.Length;

            if (!PSCryptoNativeUtils.CryptEncrypt(this.hSessionKey, IntPtr.Zero, true, 0, destinationArray, ref length, data.Length))
            {
                for (int i = 0; i < destinationArray.Length; i++)
                {
                    destinationArray[i] = 0;
                }
                destinationArray = new byte[length];
                Array.Copy(data, 0, destinationArray, 0, data.Length);
                length = data.Length;
                bool flag = PSCryptoNativeUtils.CryptEncrypt(this.hSessionKey, IntPtr.Zero, true, 0, destinationArray, ref length, destinationArray.Length);
                this.CheckStatus(flag);
            }
            byte[] buffer2 = new byte[length];
            Array.Copy(destinationArray, 0, buffer2, 0, length);
            return(buffer2);
        }