Esempio n. 1
0
		public PacketCrypt(byte[] sessionKey)
		{
			var encryptHash = s_encryptServerDataHMAC.ComputeHash(sessionKey);
			var decryptHash = s_decryptClientDataHMAC.ComputeHash(sessionKey);

			// Used by the client to decrypt packets sent by the server
			//var decryptServerData = new ARC4(encryptHash); // CLIENT-SIDE
			// Used by the server to decrypt packets sent by the client
			decryptClientData = new ARC4(decryptHash); // SERVER-SIDE
			// Used by the server to encrypt packets sent to the client
			encryptServerData = new ARC4(encryptHash); // SERVER-SIDE
			// Used by the client to encrypt packets sent to the server
			//var encryptClientData = new ARC4(decryptHash); // CLIENT-SIDE

			// Use the 2 encryption objects to generate a common starting point
			var syncBuffer = new byte[DropN];
			encryptServerData.Process(syncBuffer, 0, syncBuffer.Length);
			//encryptClientData.Process(syncBuffer, 0, syncBuffer.Length);

			// Use the 2 decryption objects to generate a common starting point
			syncBuffer = new byte[DropN];
			//decryptServerData.Process(syncBuffer, 0, syncBuffer.Length);
			decryptClientData.Process(syncBuffer, 0, syncBuffer.Length);
		}