Exemplo n.º 1
0
 public void Encrypt(byte[] data, int start, int count)
 {
     if (Status == AuthStatus.Ready)
     {
         encryptionStream.Process(data, start, count);
     }
 }
Exemplo n.º 2
0
 public void Decrypt(byte[] data, int start, int count)
 {
     if (Initialised)
     {
         decryptClientData.Process(data, start, count);
     }
 }
Exemplo n.º 3
0
 public void Encrypt(byte[] data, int start, int count)
 {
     if (Initialised)
     {
         encryptServerData.Process(data, start, count);
     }
 }
Exemplo n.º 4
0
 public byte[] Encrypt(PacketOut packet)
 {
     byte[] data = packet.ToArray();
     Log.Info("[SERVER PRE-ENCRYPT]", this.DumpData(data));
     encryption.Process(data, 4, data.Length - 4);
     return(data);
 }
Exemplo n.º 5
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);
    }
Exemplo n.º 6
0
        public PacketIn Decrypt(PacketIn packet)
        {
            byte[] data = packet.ToArray();
            decryption.Process(data, 4, data.Length - 4);
            PacketIn result = new PacketIn(data, 0, data.Length);

            result.Size   = result.GetUint32Reversed();
            result.Opcode = result.GetUint32Reversed();
            Log.Info("[CLIENT POST-ENCRYPT]", this.DumpData(data));
            return(result);
        }
Exemplo n.º 7
0
        public static void Initialize(byte[] sessionKey)
        {
            // create RC4-drop[1024] stream
            encryptionStream = new ARC4(outputHMAC.ComputeHash(sessionKey));
            encryptionStream.Process(new byte[1024], 0, 1024);

            // create RC4-drop[1024] stream
            decryptionStream = new ARC4(inputHMAC.ComputeHash(sessionKey));
            decryptionStream.Process(new byte[1024], 0, 1024);

            Status = AuthStatus.Ready;
        }
Exemplo n.º 8
0
        public PacketIn Decrypt(PacketIn packet)
        {
            byte[] data = packet.ToArray();
            decryption.Process(data, 4, data.Length - 4);
            PacketIn result = new PacketIn(data, 0, data.Length);

            result.Size   = result.GetUint32Reversed();
            result.Opcode = result.GetUint32Reversed();
            Console.Write("Dcrptd:");
            for (int i = 0; i < result.ToArray().Length; i++)
            {
                Console.Write(" " + result.ToArray()[i]);
            }
            Console.WriteLine();
            return(result);
        }
Exemplo n.º 9
0
        public void Send(byte[] buffer, int bufferSize)
        {
            //TODO: Move so not generic code but realm only code
            if (Encrypt != null && bufferSize >= 4)
            {
                Encrypt.Process(buffer, 0, 4);
            }

            SocketAsyncEventArgs ev = new SocketAsyncEventArgs();

            ev.SetBuffer(buffer, 0, bufferSize);
            ev.Completed += AsyncSendEvent;

            if (!_sock.SendAsync(ev))
            {
                OnSend(ev);
            }
        }
Exemplo n.º 10
0
 public byte[] Encrypt(PacketOut packet)
 {
     byte[] data = packet.ToArray();
     encryption.Process(data, 4, data.Length - 4);
     return(data);
 }