Esempio n. 1
0
 protected override void SetKey(byte[] keyBytes, byte[] ivBytes)
 {
     if (keyBytes.Length != 32)
     {
         throw new ArgumentException(this.AlgorithmName + " requires a 256 bit key");
     }
     base.SetKey(keyBytes, ivBytes);
     this.engineState[8] = Pack.LE_To_UInt32(ivBytes, 8);
     this.engineState[9] = Pack.LE_To_UInt32(ivBytes, 12);
     uint[] array = new uint[this.engineState.Length];
     Salsa20Engine.SalsaCore(20, this.engineState, array);
     this.engineState[1]  = array[0] - this.engineState[0];
     this.engineState[2]  = array[5] - this.engineState[5];
     this.engineState[3]  = array[10] - this.engineState[10];
     this.engineState[4]  = array[15] - this.engineState[15];
     this.engineState[11] = array[6] - this.engineState[6];
     this.engineState[12] = array[7] - this.engineState[7];
     this.engineState[13] = array[8] - this.engineState[8];
     this.engineState[14] = array[9] - this.engineState[9];
     this.engineState[6]  = Pack.LE_To_UInt32(ivBytes, 16);
     this.engineState[7]  = Pack.LE_To_UInt32(ivBytes, 20);
     this.ResetCounter();
 }
Esempio n. 2
0
 protected override void SetKey(byte[] keyBytes, byte[] ivBytes)
 {
     //IL_0017: Unknown result type (might be due to invalid IL or missing references)
     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();
 }
Esempio n. 3
0
 protected virtual void GenerateKeyStream(byte[] output)
 {
     Salsa20Engine.SalsaCore(this.rounds, this.engineState, this.x);
     Pack.UInt32_To_LE(this.x, output, 0);
 }