/// <summary>
        /// Clear the authenticator and any associated fields
        /// </summary>
        /// <param name="showWarning"></param>
        private void clearAuthenticator(bool showWarning = true)
        {
            if (this.Authenticator.AuthenticatorData != null && showWarning == true)
            {
                DialogResult result = WinAuthForm.ConfirmDialog(this.Owner,
                                                                "This will clear the authenticator you have just created. "
                                                                + "If you have attached this authenticator to your account, you might not be able to login in the future." + Environment.NewLine + Environment.NewLine
                                                                + "Are you sure you want to continue?");
                if (result != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }

                this.Authenticator.AuthenticatorData = null;
            }

            newSerialNumberField.Text       = string.Empty;
            newSerialNumberField.SecretMode = true;
            newLoginCodeField.Text          = string.Empty;
            newLoginCodeField.SecretMode    = true;
            newRestoreCodeField.Text        = string.Empty;
            newRestoreCodeField.SecretMode  = true;
            allowCopyNewButton.Checked      = false;

            restoreEmailField.Text     = string.Empty;
            restorePasswordField.Text  = string.Empty;
            restoreDeviceIdField.Text  = string.Empty;
            restoreQuestion1Label.Text = string.Empty;
            restoreQuestion2Label.Text = string.Empty;
            restoreAnswer1Field.Text   = string.Empty;
            restoreAnswer2Field.Text   = string.Empty;
        }
Example #2
0
        /// <summary>
        /// Clear the authenticator and any associated fields
        /// </summary>
        /// <param name="showWarning"></param>
        private void clearAuthenticator(bool showWarning = true)
        {
            if (this.Authenticator.AuthenticatorData != null && showWarning == true)
            {
                DialogResult result = WinAuthForm.ConfirmDialog(this.Owner,
                                                                "这将清除您刚刚创建的验证器。 "
                                                                + "如果您已将此验证器附加到您的帐户,您可能无法在将来登录。" + Environment.NewLine + Environment.NewLine
                                                                + "你确定你要继续吗?");
                if (result != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }

                this.Authenticator.AuthenticatorData = null;
            }

            newAuthenticatorProgress.Visible = false;
            newAuthenticatorTimer.Enabled    = false;
            newSerialNumberField.Text        = string.Empty;
            newSerialNumberField.SecretMode  = true;
            newLoginCodeField.Text           = string.Empty;
            newLoginCodeField.SecretMode     = true;
            newRestoreCodeField.Text         = string.Empty;
            newRestoreCodeField.SecretMode   = true;
            allowCopyNewButton.Checked       = false;

            restoreSerialNumberField.Text = string.Empty;
            restoreRestoreCodeField.Text  = string.Empty;

            importPrivateKeyField.Text = string.Empty;
        }
Example #3
0
        /// <summary>
        /// Check the configuration with the current yubikey
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void yubikeyCheckButton_Click(object sender, EventArgs e)
        {
            if (WinAuthForm.ConfirmDialog(this,
                                          "Your YubiKey slot will now be verified. If it requires you to press the button, please press when the light starts flashing." + Environment.NewLine + Environment.NewLine + "Continue?",
                                          MessageBoxButtons.YesNo,
                                          MessageBoxIcon.Warning) != System.Windows.Forms.DialogResult.Yes)
            {
                return;
            }

            int slot = (yubiSlotToggle.Checked == true ? 2 : 1);

            try
            {
                byte[] challenge = Encoding.ASCII.GetBytes("WinAuth");
                // get the hash from the key
                byte[] hash = this.Yubikey.ChallengeResponse(slot, challenge);
            }
            catch (ApplicationException ex)
            {
                WinAuthForm.ErrorDialog(this, "The YubiKey test failed. Please check the configuration is for Challenge-Response in HMAC-SHA1 mode with Variable Input. (" + ex.Message + ")");
                return;
            }

            YubikeySlot = slot;

            WinAuthForm.ErrorDialog(this, "Your YubiKey has been successfully tested.");
        }
        /// <summary>
        /// Clear the authenticator and any associated fields
        /// </summary>
        /// <param name="showWarning"></param>
        private void clearAuthenticator(bool showWarning = true)
        {
            if (this.Authenticator.AuthenticatorData != null && showWarning == true)
            {
                DialogResult result = WinAuthForm.ConfirmDialog(this.Owner,
                                                                "这将清除您刚刚创建的验证器. "
                                                                + "如果您已将此验证器附加到您的帐户,您可能无法在将来登录." + Environment.NewLine + Environment.NewLine
                                                                + "你确定你要继续吗?");
                if (result != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }

                this.Authenticator.AuthenticatorData = null;
            }

            newSerialNumberField.Text       = string.Empty;
            newSerialNumberField.SecretMode = true;
            newLoginCodeField.Text          = string.Empty;
            newLoginCodeField.SecretMode    = true;
            newRestoreCodeField.Text        = string.Empty;
            newRestoreCodeField.SecretMode  = true;
            allowCopyNewButton.Checked      = false;

            restoreEmailField.Text     = string.Empty;
            restorePasswordField.Text  = string.Empty;
            restoreDeviceIdField.Text  = string.Empty;
            restoreQuestion1Label.Text = string.Empty;
            restoreQuestion2Label.Text = string.Empty;
            restoreAnswer1Field.Text   = string.Empty;
            restoreAnswer2Field.Text   = string.Empty;
        }
Example #5
0
 /// <summary>
 ///     Change the poller action
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void pollAction_SelectedIndexChanged(object sender, EventArgs e)
 {
     // display autoconfirm warning
     if (m_loaded &&
         pollAction.SelectedValue != null &&
         pollAction.SelectedValue is SteamClient.PollerAction &&
         ((SteamClient.PollerAction)pollAction.SelectedValue == SteamClient.PollerAction.AutoConfirm ||
          (SteamClient.PollerAction)pollAction.SelectedValue == SteamClient.PollerAction.SilentAutoConfirm) &&
         AutoWarned == false)
     {
         if (WinAuthForm.ConfirmDialog(this,
                                       "WARNING: Using auto-confirm will automatically confirm all new Confirmations on your "
                                       + "account. Do not use this unless you want to ignore trade confirmations." + Environment.NewLine +
                                       Environment.NewLine
                                       + "This WILL remove items from your inventory." + Environment.NewLine + Environment.NewLine
                                       + "Are you sure you want to continue?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
                                       MessageBoxDefaultButton.Button2) != DialogResult.Yes)
         {
             pollAction.SelectedIndex = 0;
         }
         else
         {
             AutoWarned = true;
         }
     }
 }
Example #6
0
        /// <summary>
        ///     Clear the authenticator and any associated fields
        /// </summary>
        /// <param name="showWarning"></param>
        private void clearAuthenticator(bool showWarning = true)
        {
            if (Authenticator.AuthenticatorData != null && showWarning)
            {
                var result = WinAuthForm.ConfirmDialog(Owner,
                                                       "This will clear the authenticator you have just created. "
                                                       + "If you have attached this authenticator to your account, you might not be able to login in the future." +
                                                       Environment.NewLine + Environment.NewLine
                                                       + "Are you sure you want to continue?");
                if (result != DialogResult.Yes)
                {
                    return;
                }

                Authenticator.AuthenticatorData = null;
            }

            newAuthenticatorProgress.Visible = false;
            newAuthenticatorTimer.Enabled    = false;
            newSerialNumberField.Text        = string.Empty;
            newSerialNumberField.SecretMode  = true;
            newLoginCodeField.Text           = string.Empty;
            newLoginCodeField.SecretMode     = true;
            newRestoreCodeField.Text         = string.Empty;
            newRestoreCodeField.SecretMode   = true;
            allowCopyNewButton.Checked       = false;

            restoreSerialNumberField.Text = string.Empty;
            restoreRestoreCodeField.Text  = string.Empty;

            importPrivateKeyField.Text = string.Empty;
        }
        /// <summary>
        /// Click the button to cancel all confirmations
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cancelAllButton_Click(object sender, EventArgs e)
        {
            if (WinAuthForm.ConfirmDialog(this, "This will CANCEL all your current trade confirmations." + Environment.NewLine + Environment.NewLine +
                                          "Are you sure you want to continue?",
                                          MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) != DialogResult.Yes)
            {
                return;
            }

            var cursor = Cursor.Current;

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                Application.DoEvents();

                cancelAllButton.Text     = "Stop";
                confirmAllButton.Enabled = false;
                closeButton.Enabled      = false;

                var rand     = new Random();
                var tradeIds = m_trades.Select(t => t.Id).Reverse().ToArray();
                for (var i = tradeIds.Length - 1; i >= 0; i--)
                {
                    DateTime start = DateTime.Now;

                    var result = RejectTrade(tradeIds[i]);
                    if (result == false)
                    {
                        break;
                    }
                    if (i != 0)
                    {
                        var duration = (int)DateTime.Now.Subtract(start).TotalMilliseconds;
                        var delay    = SteamClient.CONFIRMATION_EVENT_DELAY + rand.Next(SteamClient.CONFIRMATION_EVENT_DELAY / 2);                      // delay is 100%-150% of CONFIRMATION_EVENT_DELAY
                        if (delay > duration)
                        {
                            Thread.Sleep(delay - duration);
                        }
                    }
                }
            }
            finally
            {
                confirmAllButton.Enabled = true;
                closeButton.Enabled      = true;

                this.Authenticator.MarkChanged();

                Cursor.Current = cursor;
            }
        }
Example #8
0
 /// <summary>
 ///     Handle cancel button with warning
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cancelButton_Click(object sender, EventArgs e)
 {
     if (Authenticator.AuthenticatorData != null)
     {
         var result = WinAuthForm.ConfirmDialog(Owner,
                                                "WARNING: Your authenticator has not been saved." + Environment.NewLine + Environment.NewLine
                                                + "If you have added this authenticator to your online account, you will not be able to login in the future, and you need to click YES to save it." +
                                                Environment.NewLine + Environment.NewLine
                                                + "Do you want to save this authenticator?", MessageBoxButtons.YesNoCancel);
         if (result == DialogResult.Yes)
         {
             DialogResult = DialogResult.OK;
         }
         else if (result == DialogResult.Cancel)
         {
             DialogResult = DialogResult.None;
         }
     }
 }
Example #9
0
 /// <summary>
 ///     Press the form's cancel button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cancelButton_Click(object sender, EventArgs e)
 {
     if (Authenticator.AuthenticatorData != null)
     {
         var result = WinAuthForm.ConfirmDialog(Owner,
                                                "You have created a new authenticator. "
                                                + "If you have attached this authenticator to your account, you might not be able to login in the future." +
                                                Environment.NewLine + Environment.NewLine
                                                + "Do you want to save this authenticator?", MessageBoxButtons.YesNoCancel);
         if (result == DialogResult.Yes)
         {
             DialogResult = DialogResult.OK;
         }
         else if (result == DialogResult.Cancel)
         {
             DialogResult = DialogResult.None;
         }
     }
 }
Example #10
0
 /// <summary>
 /// Press the form's cancel button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cancelButton_Click(object sender, EventArgs e)
 {
     if (this.Authenticator.AuthenticatorData != null)
     {
         DialogResult result = WinAuthForm.ConfirmDialog(this.Owner,
                                                         "您已创建一个新的身份验证器。"
                                                         + "如果您已将此验证器附加到您的帐户,您可能无法在将来登录。" + Environment.NewLine + Environment.NewLine
                                                         + "你想保存这个验证器?", MessageBoxButtons.YesNoCancel);
         if (result == System.Windows.Forms.DialogResult.Yes)
         {
             this.DialogResult = System.Windows.Forms.DialogResult.OK;
             return;
         }
         else if (result == System.Windows.Forms.DialogResult.Cancel)
         {
             this.DialogResult = System.Windows.Forms.DialogResult.None;
             return;
         }
     }
 }
Example #11
0
 /// <summary>
 /// Handle cancel button with warning
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cancelButton_Click(object sender, EventArgs e)
 {
     if (this.Authenticator.AuthenticatorData != null)
     {
         DialogResult result = WinAuthForm.ConfirmDialog(this.Owner,
                                                         "警告: 您的验证器尚未保存." + Environment.NewLine + Environment.NewLine
                                                         + "如果您已将此验证程序添加到在线帐户,您将无法在以后登录,并且您需要单击“是”以保存它。" + Environment.NewLine + Environment.NewLine
                                                         + "你想保存这个验证器吗?", MessageBoxButtons.YesNoCancel);
         if (result == System.Windows.Forms.DialogResult.Yes)
         {
             this.DialogResult = System.Windows.Forms.DialogResult.OK;
             return;
         }
         else if (result == System.Windows.Forms.DialogResult.Cancel)
         {
             this.DialogResult = System.Windows.Forms.DialogResult.None;
             return;
         }
     }
 }
Example #12
0
        /// <summary>
        /// Configure the Yubikey
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void yubiSecretUpdateButton_Click(object sender, EventArgs e)
        {
            if (yubiSecretField.Text.Trim().Length == 0)
            {
                WinAuthForm.ErrorDialog(this, "Please enter a secret phase or password");
                return;
            }

            if (WinAuthForm.ConfirmDialog(this,
                                          "This will overwrite any existing data on your YubiKey.\n\nAre you sure you want to continue?",
                                          MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != System.Windows.Forms.DialogResult.Yes)
            {
                return;
            }

            int  slot  = (yubiSlotToggle.Checked == true ? 2 : 1);
            bool press = yubiPressToggle.Checked;

            // bug in YubiKey 3.2.x (and below?) where using keypress doesn't always work
            // see http://forum.yubico.com/viewtopic.php?f=26&t=1571
            if (press == true &&
                (this.Yubikey.Info.Status.VersionMajor < 3 ||
                 (this.Yubikey.Info.Status.VersionMajor == 3 && this.Yubikey.Info.Status.VersionMinor <= 3)))
            {
                if (WinAuthForm.ConfirmDialog(this,
                                              "This is a known issue using \"Require button press\" with YubiKeys that have firmware version 3.3 and below. It can cause intermittent problems when reading the Challenge-Response. You can contact Yubico and may be able to get a free replacement.\n\nDo you want to continue anyway?",
                                              MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }
            }

            // calculate the actual key. This is a byte version of the string, salt="mnemonic"(+user password TBD), PBKDF 2048 times, return 20byte/160bit key
            byte[] bytes = Encoding.UTF8.GetBytes(yubiSecretField.Text.Trim());
            string salt  = "mnemonic";

            byte[]             saltbytes = Encoding.UTF8.GetBytes(salt);
            Rfc2898DeriveBytes kg        = new Rfc2898DeriveBytes(bytes, saltbytes, YUBIKEY_PBKDF2_ITERATIONS);

            byte[] key = kg.GetBytes(YUBIKEY_PBKDF2_KEYSIZE);

            try
            {
                this.Yubikey.SetChallengeResponse(slot, key, key.Length, press);
            }
            catch (YubKeyException ex)
            {
                WinAuthForm.ErrorDialog(this, ex.Message, ex);
                return;
            }

            if (press == true)
            {
                if (WinAuthForm.ConfirmDialog(this,
                                              "Your YubiKey slot will now be verified. Please click its button when it flashes." + Environment.NewLine + Environment.NewLine + "Continue?",
                                              MessageBoxButtons.YesNo,
                                              MessageBoxIcon.Warning) != System.Windows.Forms.DialogResult.Yes)
                {
                    WinAuthForm.ErrorDialog(this, "Your YubiKey has been updated. Please verify it before continuing.");
                    return;
                }
            }

            // perform the test encryption/decryption using the yubi
            try
            {
                string challenge = "WinAuth";
                string plain     = Authenticator.ByteArrayToString(Encoding.ASCII.GetBytes(challenge));
                Authenticator.PasswordTypes passwordType = (slot == 1 ? Authenticator.PasswordTypes.YubiKeySlot1 : Authenticator.PasswordTypes.YubiKeySlot2);
                string encrypted = Authenticator.EncryptSequence(plain, passwordType, null, this.Yubikey);
                plain = Authenticator.DecryptSequence(encrypted, passwordType, null, this.Yubikey);
                string response = Encoding.ASCII.GetString(Authenticator.StringToByteArray(plain));
                if (challenge != response)
                {
                    throw new ApplicationException("verification failed");
                }
            }
            catch (ApplicationException ex)
            {
                WinAuthForm.ErrorDialog(this, "The YubiKey test failed. Please try configuring it again or doing it manually. (" + ex.Message + ")");
                return;
            }

            YubikeySlot = slot;

            WinAuthForm.ErrorDialog(this, "Your YubiKey has been successfully updated.");
        }