public NetCryptoProviderBase(NetPeer peer, SymmetricAlgorithm algo)
     : base(peer)
 {
     m_algorithm = algo;
     m_algorithm.GenerateKey();
     m_algorithm.GenerateIV();
 }
        /// <summary>
        /// 16 byte key
        /// </summary>
        public NetXtea(NetPeer peer, byte[] key, int rounds)
            : base(peer)
        {
            if (key.Length < c_keySize)
                throw new NetException("Key too short!");

            m_numRounds = rounds;
            m_sum0 = new uint[m_numRounds];
            m_sum1 = new uint[m_numRounds];
            uint[] tmp = new uint[8];

            int num2;
            int index = num2 = 0;
            while (index < 4)
            {
                tmp[index] = BitConverter.ToUInt32(key, num2);
                index++;
                num2 += 4;
            }
            for (index = num2 = 0; index < 32; index++)
            {
                m_sum0[index] = ((uint)num2) + tmp[num2 & 3];
                num2 += -1640531527;
                m_sum1[index] = ((uint)num2) + tmp[(num2 >> 11) & 3];
            }
        }
예제 #3
0
 internal NetConnection(NetPeer peer, NetEndPoint remoteEndPoint)
 {
     m_peer = peer;
     m_peerConfiguration = m_peer.Configuration;
     m_status = NetConnectionStatus.None;
     m_outputtedStatus = NetConnectionStatus.None;
     m_visibleStatus = NetConnectionStatus.None;
     m_remoteEndPoint = remoteEndPoint;
     m_sendChannels = new NetSenderChannelBase[NetConstants.NumTotalChannels];
     m_receiveChannels = new NetReceiverChannelBase[NetConstants.NumTotalChannels];
     m_queuedOutgoingAcks = new NetQueue<NetTuple<NetMessageType, int>>(4);
     m_queuedIncomingAcks = new NetQueue<NetTuple<NetMessageType, int>>(4);
     m_statistics = new NetConnectionStatistics(this);
     m_averageRoundtripTime = -1.0f;
     m_currentMTU = m_peerConfiguration.MaximumTransmissionUnit;
 }
 public NetTripleDESEncryption(NetPeer peer)
     : base(peer, new TripleDESCryptoServiceProvider())
 {
 }
 /// <summary>
 /// String to hash for key
 /// </summary>
 public NetXtea(NetPeer peer, string key)
     : this(peer, NetUtility.ComputeSHAHash(Encoding.UTF8.GetBytes(key)), 32)
 {
 }
 /// <summary>
 /// 16 byte key
 /// </summary>
 public NetXtea(NetPeer peer, byte[] key)
     : this(peer, key, 32)
 {
 }
 /// <summary>
 /// NetXorEncryption constructor
 /// </summary>
 public NetXorEncryption(NetPeer peer, byte[] key)
     : base(peer)
 {
     m_key = key;
 }
예제 #8
0
 /// <summary>
 /// Constructor
 /// </summary>
 public NetEncryption(NetPeer peer)
 {
     if (peer == null)
         throw new NetException("Peer must not be null");
     m_peer = peer;
 }
 public NetRC2Encryption(NetPeer peer)
     : base(peer, new RC2CryptoServiceProvider())
 {
 }
		public NetAESEncryption(NetPeer peer)
#if UNITY
			: base(peer, new RijndaelManaged())
#else
			: base(peer, new AesCryptoServiceProvider())
 public NetReceiverChannelBase(NetConnection connection)
 {
     m_connection = connection;
     m_peer = connection.m_peer;
 }
 public NetCryptoProviderEncryption(NetPeer peer)
     : base(peer)
 {
 }
예제 #13
0
 /// <summary>
 /// NetUPnP constructor
 /// </summary>
 public NetUPnP(NetPeer peer)
 {
     m_peer = peer;
     m_discoveryResponseDeadline = double.MinValue;
 }
예제 #14
0
        internal void Discover(NetPeer peer)
        {
            string str =
            "M-SEARCH * HTTP/1.1\r\n" +
            "HOST: 239.255.255.250:1900\r\n" +
            "ST:upnp:rootdevice\r\n" +
            "MAN:\"ssdp:discover\"\r\n" +
            "MX:3\r\n\r\n";

            m_discoveryResponseDeadline = NetTime.Now + 6.0; // arbitrarily chosen number, router gets 6 seconds to respond
            m_status = UPnPStatus.Discovering;

            byte[] arr = System.Text.Encoding.UTF8.GetBytes(str);

            m_peer.LogDebug("Attempting UPnP discovery");
            peer.Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
            peer.RawSend(arr, 0, arr.Length, new NetEndPoint(NetUtility.GetBroadcastAddress(), 1900));
            peer.Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, false);
        }
 public NetTripleDESEncryption(NetPeer peer, string key)
     : base(peer, new TripleDESCryptoServiceProvider())
 {
     SetKey(key);
 }
 public NetRC2Encryption(NetPeer peer, string key)
     : base(peer, new RC2CryptoServiceProvider())
 {
     SetKey(key);
 }
 public NetTripleDESEncryption(NetPeer peer, byte[] data, int offset, int count)
     : base(peer, new TripleDESCryptoServiceProvider())
 {
     SetKey(data, offset, count);
 }
 /// <summary>
 /// NetBlockEncryptionBase constructor
 /// </summary>
 public NetBlockEncryptionBase(NetPeer peer)
     : base(peer)
 {
     m_tmp = new byte[BlockSize];
 }
 /// <summary>
 /// NetXorEncryption constructor
 /// </summary>
 public NetXorEncryption(NetPeer peer, string key)
     : base(peer)
 {
     m_key = Encoding.UTF8.GetBytes(key);
 }
예제 #20
0
		/// <summary>
		/// Create XTEA symmetrical encryption object from sessionValue
		/// </summary>
		public static NetXtea CreateEncryption(NetPeer peer, byte[] sessionValue)
		{
			var hash = NetUtility.ComputeSHAHash(sessionValue);
			
			var key = new byte[16];
			for(int i=0;i<16;i++)
			{
				key[i] = hash[i];
				for (int j = 1; j < hash.Length / 16; j++)
					key[i] ^= hash[i + (j * 16)];
			}

			return new NetXtea(peer, key);
		}