Example #1
0
        private static unsafe void BlockMix
            (uint *B,       // 16*2*r
            int Boffset,
            uint *Bp,       // 16*2*r
            uint Bpoffset,
            uint *x,        // 16
            uint *y,        // 16*2*r -- unnecessary but it allows us to alias B and Bp
            uint *scratch1, // 16
            /*uint* scratch2, // 16 */
            int r)
        {
            int k = Boffset, m = 0, n = 16 * r;

            CopyExtensions.CopyMemory((byte *)(B + ((2 * r - 1) * 16)), (byte *)x, 16 * sizeof(uint));

            for (int i = 0; i < r; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    scratch1[j] = x[j] ^ B[j + k];
                }
                XSalsa20Engine.HSalsaUnsafe(8, scratch1, x);

                CopyExtensions.CopyMemory((byte *)x, (byte *)(y + m), 16 * sizeof(uint));

                k += 16;

                for (int j = 0; j < 16; j++)
                {
                    scratch1[j] = x[j] ^ B[j + k];
                }
                XSalsa20Engine.HSalsaUnsafe(8, scratch1, x);

                CopyExtensions.CopyMemory((byte *)x, (byte *)(y + m + n), 16 * sizeof(uint));
                k += 16;

                m += 16;
            }

            CopyExtensions.CopyMemory((byte *)y, (byte *)(Bp + Bpoffset), n * 2 * sizeof(uint));
        }
Example #2
0
 public static T Copy <T>(this T sourceItem) => CopyExtensions.Copy(sourceItem);