Ejemplo n.º 1
0
        private static void BlockMix(uint[] B, uint[] X1, uint[] X2, uint[] Y, int r)
        {
            Array.Copy(B, B.Length - 16, X1, 0, 16);
            int num  = 0;
            int num2 = 0;
            int num3 = B.Length >> 1;

            for (int i = 2 * r; i > 0; i--)
            {
                SCrypt.Xor(X1, B, num, X2);
                Salsa20Engine.SalsaCore(8, X2, X1);
                Array.Copy(X1, 0, Y, num2, 16);
                num2 = num3 + num - num2;
                num += 16;
            }
            Array.Copy(Y, 0, B, 0, Y.Length);
        }
Ejemplo n.º 2
0
        private static void SMix(uint[] B, int BOff, int N, int r)
        {
            int num = r * 32;

            uint[]   array  = new uint[16];
            uint[]   array2 = new uint[16];
            uint[]   array3 = new uint[num];
            uint[]   array4 = new uint[num];
            uint[][] array5 = new uint[N][];
            try
            {
                Array.Copy(B, BOff, array4, 0, num);
                for (int i = 0; i < N; i++)
                {
                    array5[i] = (uint[])array4.Clone();
                    SCrypt.BlockMix(array4, array, array2, array3, r);
                }
                uint num2 = (uint)(N - 1);
                for (int j = 0; j < N; j++)
                {
                    uint num3 = array4[num - 16] & num2;
                    SCrypt.Xor(array4, array5[(int)((UIntPtr)num3)], 0, array4);
                    SCrypt.BlockMix(array4, array, array2, array3, r);
                }
                Array.Copy(array4, 0, B, BOff, num);
            }
            finally
            {
                SCrypt.ClearAll(array5);
                SCrypt.ClearAll(new Array[]
                {
                    array4,
                    array,
                    array2,
                    array3
                });
            }
        }
Ejemplo n.º 3
0
 public static byte[] Generate(byte[] P, byte[] S, int N, int r, int p, int dkLen)
 {
     return(SCrypt.MFcrypt(P, S, N, r, p, dkLen));
 }