Org.BouncyCastle.Crypto.Engines.Salsa20Engine.setKey C# (CSharp) Метод

setKey() приватный Метод

private setKey ( byte keyBytes, byte ivBytes ) : void
keyBytes byte
ivBytes byte
Результат void
		private void setKey(byte[] keyBytes, byte[] ivBytes)
		{
			workingKey = keyBytes;
			workingIV  = ivBytes;

			index = 0;
			resetCounter();
			int offset = 0;
			byte[] constants;

			// Key
			engineState[1] = byteToIntLittle(workingKey, 0);
			engineState[2] = byteToIntLittle(workingKey, 4);
			engineState[3] = byteToIntLittle(workingKey, 8);
			engineState[4] = byteToIntLittle(workingKey, 12);

			if (workingKey.Length == 32)
			{
				constants = sigma;
				offset = 16;
			}
			else
			{
				constants = tau;
			}
	        
			engineState[11] = byteToIntLittle(workingKey, offset);
			engineState[12] = byteToIntLittle(workingKey, offset+4);
			engineState[13] = byteToIntLittle(workingKey, offset+8);
			engineState[14] = byteToIntLittle(workingKey, offset+12);
			engineState[0 ] = byteToIntLittle(constants, 0);
			engineState[5 ] = byteToIntLittle(constants, 4);
			engineState[10] = byteToIntLittle(constants, 8);
			engineState[15] = byteToIntLittle(constants, 12);
	        
			// IV
			engineState[6] = byteToIntLittle(workingIV, 0);
			engineState[7] = byteToIntLittle(workingIV, 4);
			engineState[8] = engineState[9] = 0;
	        
			initialised = true;
		}