Exemple #1
0
        public static void XTSChainDecrypt(KeyValuePairList <SymmetricAlgorithm, byte[]> algorithmChain, ulong dataUnitIndex, byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
        {
            Array.Copy(inputBuffer, inputOffset, outputBuffer, outputOffset, inputCount);

            KeyValuePairList <SymmetricAlgorithm, byte[]> reversedChain = new KeyValuePairList <SymmetricAlgorithm, byte[]>();

            reversedChain.AddRange(algorithmChain);
            reversedChain.Reverse();

            foreach (KeyValuePair <SymmetricAlgorithm, byte[]> algorithm in reversedChain)
            {
                byte[] key1 = new byte[32];
                byte[] key2 = new byte[32];
                Array.Copy(algorithm.Value, 0, key1, 0, 32);
                Array.Copy(algorithm.Value, 32, key2, 0, 32);

                XTSDecrypt(algorithm.Key, key1, key2, dataUnitIndex, outputBuffer, outputOffset, inputCount, outputBuffer, outputOffset);
            }
        }