Beispiel #1
0
        public void Serialize(ref redBuffer Buffer, SteamClient Client)
        {
            Byte[] IV  = new Byte[24];
            Byte[] Key = new Byte[24];
            Byte[] EncryptedData;

            // The boring stuff.
            Buffer.WriteUInt64(_TransactionID);
            Buffer.WriteUInt64(_XUID);
            Buffer.WriteUInt64(_Username);
            Buffer.WriteUInt32(_Type);
            Buffer.WriteUInt32(_Seed);
            Buffer.WriteUInt32(_IP);

            // Generate the IV and key.
            IV  = SteamCrypto.CalculateIV(_Seed);
            Key = SteamCrypto.CalculateIV(Client.SessionID);

            // Resize the buffers to keep 3DES happy.
            Array.Resize <Byte>(ref IV, 8);
            Array.Resize <Byte>(ref _Data, _Data.Length + (8 - _Data.Length % 8));

            // Create a new buffer and encrypt the data.
            EncryptedData = new Byte[_Data.Length];
            EncryptedData = SteamCrypto.Encrypt(_Data, Key, IV);

            // Write the encrypted data to the packet.
            Buffer.WriteBlob(EncryptedData);
        }
Beispiel #2
0
        public void CreatePacket(UInt64 TransactionID, UInt32 Result, redBuffer Data, SteamClient Client)
        {
            _TransactionID = TransactionID;
            _XUID          = Client.XUID;
            _Username      = SteamCrypto.fnv1_hash(Client.Username);
            _Type          = Result;
            _Seed          = (UInt32)(new Random((Int32)DateTime.Now.Ticks).Next());
            _IP            = (UInt32)Client.GetIP().Address; // We will only use ipv4 so we ignore that it's deprecated.

            _Data = new Byte[Data.Length()];
            Array.Copy(Data.GetBuffer(), _Data, Data.Length());
        }
Beispiel #3
0
        public static UInt32 FindClient(Byte[] Username)
        {
            try
            {
                var Query = (from Client in Clients
                             where (SteamCrypto.fnv1_hash(Client.Value.Username) == SteamCrypto.fnv1_hash(Username))
                             select Client.Key).ToList();

                if (Query.Count >= 1)
                {
                    return(Query[0]);
                }
            }
            catch (Exception e)
            {
            }
            return(0xFFFFFFFF);
        }
Beispiel #4
0
        public void Deserialize(redBuffer Buffer, SteamClient Client)
        {
            Byte[] IV            = new Byte[24];
            Byte[] Key           = new Byte[24];
            Byte[] EncryptedData = new Byte[1];

            // Read the packet.
            Buffer.ReadUInt64(ref _TransactionID);
            Buffer.ReadUInt64(ref _XUID);
            Buffer.ReadUInt64(ref _Username);
            Buffer.ReadUInt32(ref _Type);
            Buffer.ReadUInt32(ref _Seed);
            Buffer.ReadUInt32(ref _IP);
            Buffer.ReadBlob(ref EncryptedData);

            // Generate the IV and key.
            IV  = SteamCrypto.CalculateIV(_Seed);
            Key = SteamCrypto.CalculateIV(Client.SessionID);
            Array.Resize <Byte>(ref IV, 8);

            // Create a new buffer and encrypt the data.
            _Data = new Byte[EncryptedData.Length];
            _Data = SteamCrypto.Decrypt(EncryptedData, Key, IV);
        }