Beispiel #1
0
 protected override void OnPasswordHash(ref MyControlSendPasswordHashMsg message, ulong sender)
 {
     base.OnPasswordHash(ref message, sender);
     if (!this.IsPasswordProtected || string.IsNullOrEmpty(MySandboxGame.ConfigDedicated.ServerPasswordHash))
     {
         this.SendJoinResult(sender, JoinResult.OK, 0UL);
     }
     else
     {
         byte[] passwordHash = message.PasswordHash;
         byte[] buffer2      = Convert.FromBase64String(MySandboxGame.ConfigDedicated.ServerPasswordHash);
         if ((passwordHash == null) || (passwordHash.Length != buffer2.Length))
         {
             this.RejectUserWithWrongPassword(sender);
         }
         else
         {
             for (int i = 0; i < buffer2.Length; i++)
             {
                 if (buffer2[i] != passwordHash[i])
                 {
                     this.RejectUserWithWrongPassword(sender);
                     return;
                 }
             }
             base.ResetWrongPasswordCounter(sender);
             this.SendJoinResult(sender, JoinResult.OK, 0UL);
         }
     }
 }
Beispiel #2
0
 public void SendPasswordHash(string password)
 {
     if (string.IsNullOrEmpty(this.m_serverPasswordSalt))
     {
         MyLog.Default.Error("Empty password salt on the server.", Array.Empty <object>());
     }
     else
     {
         byte[] salt = Convert.FromBase64String(this.m_serverPasswordSalt);
         MyControlSendPasswordHashMsg message = new MyControlSendPasswordHashMsg {
             PasswordHash = new Rfc2898DeriveBytes(password, salt, 0x2710).GetBytes(20)
         };
         base.SendControlMessage <MyControlSendPasswordHashMsg>(base.ServerId, ref message, true);
     }
 }
Beispiel #3
0
 protected virtual void OnPasswordHash(ref MyControlSendPasswordHashMsg message, ulong sender)
 {
 }