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 BOff = 0, YOff = 0, halfLen = B.Length >> 1;

            for (int i = 2 * r; i > 0; --i)
            {
                Xor(X1, B, BOff, X2);

                Salsa20Engine.SalsaCore(8, X2, X1);
                Array.Copy(X1, 0, Y, YOff, 16);

                YOff  = halfLen + BOff - YOff;
                BOff += 16;
            }
        }
Ejemplo n.º 2
0
        private static void BlockMix(uint[] B, uint[] X1, uint[] X2, uint[] Y, int r)
        {
            global::System.Array.Copy((global::System.Array)B, B.Length - 16, (global::System.Array)X1, 0, 16);
            int num  = 0;
            int num2 = 0;
            int num3 = B.Length >> 1;

            for (int num4 = 2 * r; num4 > 0; num4--)
            {
                Xor(X1, B, num, X2);
                Salsa20Engine.SalsaCore(8, X2, X1);
                global::System.Array.Copy((global::System.Array)X1, 0, (global::System.Array)Y, num2, 16);
                num2 = num3 + num - num2;
                num += 16;
            }
            global::System.Array.Copy((global::System.Array)Y, 0, (global::System.Array)B, 0, Y.Length);
        }
Ejemplo n.º 3
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.º 4
0
 protected override void SetKey(byte[] keyBytes, byte[] ivBytes)
 {
     if (keyBytes.Length != 32)
     {
         throw new ArgumentException(AlgorithmName + " requires a 256 bit key");
     }
     base.SetKey(keyBytes, ivBytes);
     engineState[8] = Pack.LE_To_UInt32(ivBytes, 8);
     engineState[9] = Pack.LE_To_UInt32(ivBytes, 12);
     uint[] array = new uint[engineState.Length];
     Salsa20Engine.SalsaCore(20, engineState, array);
     engineState[1]  = array[0] - engineState[0];
     engineState[2]  = array[5] - engineState[5];
     engineState[3]  = array[10] - engineState[10];
     engineState[4]  = array[15] - engineState[15];
     engineState[11] = array[6] - engineState[6];
     engineState[12] = array[7] - engineState[7];
     engineState[13] = array[8] - engineState[8];
     engineState[14] = array[9] - engineState[9];
     engineState[6]  = Pack.LE_To_UInt32(ivBytes, 16);
     engineState[7]  = Pack.LE_To_UInt32(ivBytes, 20);
     ResetCounter();
 }