Beispiel #1
0
        public override int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
        {
            byte[] block = new byte[inputCount];
            Array.ConstrainedCopy(inputBuffer, inputOffset, block, 0, inputCount);

            // initialize
            block = InitializeBlock(block);

            // apply rounds
            BlockEncoder blockEncoder = new BlockEncoder(keySchedule);

            block = blockEncoder.Encode(block, rounds);
            block.CopyTo(outputBuffer, outputOffset);

            return(inputCount);
        }
Beispiel #2
0
        public override int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
        {
            byte[] block = new byte[inputCount];
            Array.ConstrainedCopy(inputBuffer, inputOffset, block, 0, inputCount);

            //Un-init plans
            List <IWordEncoder> plan = CreateUninitializationPlan(block);

            // Decode rounds
            BlockEncoder blockEncoder = new BlockEncoder(keySchedule);

            block = blockEncoder.Decode(block, rounds);

            // Un-init block
            BitArray decoded = new BitArray(block);

            plan.ForEach((IWordEncoder decoder) => {
                decoded = decoder.Decode(decoded);
            });
            decoded.CopyTo(block, 0);
            block.CopyTo(outputBuffer, outputOffset);

            return(inputCount);
        }