Beispiel #1
0
 public static CPacketHeader CreateHeader(Byte Packet, Int32 iBlockAmount)
 {
     try
     {
         CPacketHeader Header = new CPacketHeader();
         Header.Packet_Ident = CUtilities.RandomString(8);
         Header.Packet       = Packet;
         Header.Block_Amount = iBlockAmount;
         return(Header);
     }
     catch { }
     return(null);
 }
Beispiel #2
0
        public bool SendRSAAuth()
        {
            try
            {
                if (String.IsNullOrEmpty(this.Public_Key))
                {
#if DEBUG
                    Console.WriteLine(CConstants.InvalidPublicKey);
#endif
                    return(false);
                }

                String strAuthString = CUtilities.RandomString(CUtilities.RandomInt(8, 16));

                byte[] arr_bRandomString = UnicodeEncoding.Unicode.GetBytes(strAuthString);

                if (arr_bRandomString == null)
                {
                    return(false);
                }

                arr_bRandomString = CRSA.Encrypt(arr_bRandomString, this.Public_Key, 2048);

                if (arr_bRandomString == null)
                {
#if DEBUG
                    Console.WriteLine(CConstants.SendRSAAuth_RSAEncrypt_FAILED);
#endif
                    return(false);
                }

                CPacket KeyPacket = MasterClient.CreatePacket((Byte)MASTER_PACKET.LOGIN_KEY, Convert.ToBase64String(arr_bRandomString));

                if (MasterClient.SendPacket(KeyPacket))
                {
                    this.AuthString = strAuthString;
                    return(true);
                }
            }
            catch
            {
            }
            return(false);
        }