Skip to content

Commit

Permalink
Add button to manage encryption
Browse files Browse the repository at this point in the history
Force double-confirmation of passkeys
  • Loading branch information
geel9 committed Nov 28, 2015
1 parent f6e2a7e commit 7d54013
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 30 deletions.
17 changes: 7 additions & 10 deletions Steam Desktop Authenticator/LoginForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ private void btnSteamLogin_Click(object sender, EventArgs e)
this.Close();
return;
break;

case LoginResult.BadRSA:
case LoginResult.GeneralFailure:
this.Close();
return;
break;
}
}

Expand Down Expand Up @@ -128,16 +134,7 @@ private void btnSteamLogin_Click(object sender, EventArgs e)
string passKey = null;
if (manifest.Entries.Count == 0)
{
InputForm newEncryptionForm = new InputForm("Please enter an encryption passkey. Leave blank or hit cancel to not encrypt (VERY INSECURE).");
newEncryptionForm.ShowDialog();
if (!newEncryptionForm.Canceled && newEncryptionForm.txtBox.Text.Length > 0)
{
passKey = newEncryptionForm.txtBox.Text;
}
else
{
MessageBox.Show("WARNING: You chose to not encrypt your files. Doing so imposes a security risk for yourself. If an attacker were to gain access to your computer, they could completely lock you out of your account and steal all your items.");
}
passKey = manifest.PromptSetupPassKey("Please enter an encryption passkey. Leave blank or hit cancel to not encrypt (VERY INSECURE).");
}
else if (manifest.Entries.Count > 0 && manifest.Encrypted)
{
Expand Down
27 changes: 20 additions & 7 deletions Steam Desktop Authenticator/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions Steam Desktop Authenticator/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,16 @@ private void loadAccountsList()
return;
}
}

btnManageEncryption.Text = "Manage Encryption";
}
else
{
btnManageEncryption.Text = "Setup Encryption";
}

btnManageEncryption.Enabled = mManifest.Entries.Count > 0;

allAccounts = mManifest.GetAllAccounts(passKey);

if (allAccounts.Length > 0)
Expand Down Expand Up @@ -157,5 +165,56 @@ private void btnDelete_Click(object sender, EventArgs e)
MessageBox.Show("Authenticator unable to be removed.");
}
}

private void btnManageEncryption_Click(object sender, EventArgs e)
{
if (mManifest.Encrypted)
{
InputForm currentPassKeyForm = new InputForm("Enter current passkey", true);
currentPassKeyForm.ShowDialog();

if (currentPassKeyForm.Canceled)
return;

string curPassKey = currentPassKeyForm.txtBox.Text;

InputForm changePassKeyForm = new InputForm("Enter new passkey, or leave blank to remove encryption.");
changePassKeyForm.ShowDialog();

if (changePassKeyForm.Canceled)
return;

InputForm changePassKeyForm2 = new InputForm("Confirm new passkey, or leave blank to remove encryption.");
changePassKeyForm2.ShowDialog();
if (changePassKeyForm2.Canceled)
return;

string newPassKey = changePassKeyForm.txtBox.Text;
string confirmPassKey = changePassKeyForm2.txtBox.Text;

if (newPassKey != confirmPassKey)
{
MessageBox.Show("Passkeys do not match.");
return;
}

if (newPassKey.Length == 0)
newPassKey = null;

string action = newPassKey == null ? "remove" : "change";
if (!mManifest.ChangeEncryptionKey(curPassKey, newPassKey))
MessageBox.Show("Unable to " + action + " passkey.");
else
{
MessageBox.Show("Passkey successfully " + action + "d.");
this.loadAccountsList();
}
}
else
{
mManifest.PromptSetupPassKey();
this.loadAccountsList();
}
}
}
}
52 changes: 39 additions & 13 deletions Steam Desktop Authenticator/Manifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,8 @@ private static Manifest _generateNewManifest(bool scanDir = false)
if (newManifest.Entries.Count > 0)
{
newManifest.Save();

InputForm askForPasskey = new InputForm("This version of SDA has encryption. Please enter a passkey below, or hit cancel to remain unencrypted");
askForPasskey.ShowDialog();
if (askForPasskey.Canceled || askForPasskey.txtBox.Text.Length == 0)
{
MessageBox.Show("WARNING: You chose to not encrypt your files. Doing so imposes a security risk for yourself. If an attacker were to gain access to your computer, they could completely lock you out of your account and steal all your items.");
}
else
{
string passKey = askForPasskey.txtBox.Text;
newManifest.ChangeEncryptionKey(null, passKey);
}
newManifest.PromptSetupPassKey("This version of SDA has encryption. Please enter a passkey below, or hit cancel to remain unencrypted");
}

}
}

Expand All @@ -126,6 +114,44 @@ private static Manifest _generateNewManifest(bool scanDir = false)
return null;
}

public string PromptSetupPassKey(string initialPrompt = "Enter passkey, or hit cancel to remain unencrypted.")
{
InputForm newPassKeyForm = new InputForm(initialPrompt);
newPassKeyForm.ShowDialog();
if (newPassKeyForm.Canceled || newPassKeyForm.txtBox.Text.Length == 0)
{
MessageBox.Show("WARNING: You chose to not encrypt your files. Doing so imposes a security risk for yourself. If an attacker were to gain access to your computer, they could completely lock you out of your account and steal all your items.");
return null;
}

InputForm newPassKeyForm2 = new InputForm("Confirm new passkey.");
newPassKeyForm2.ShowDialog();
if (newPassKeyForm2.Canceled)
{
MessageBox.Show("WARNING: You chose to not encrypt your files. Doing so imposes a security risk for yourself. If an attacker were to gain access to your computer, they could completely lock you out of your account and steal all your items.");
return null;
}

string newPassKey = newPassKeyForm.txtBox.Text;
string confirmPassKey = newPassKeyForm2.txtBox.Text;

if (newPassKey != confirmPassKey)
{
MessageBox.Show("Passkeys do not match.");
return null;
}

if (!this.ChangeEncryptionKey(null, newPassKey))
{
MessageBox.Show("Unable to set passkey.");
return null;
}
else
MessageBox.Show("Passkey successfully set.");

return newPassKey;
}

public SteamAuth.SteamGuardAccount[] GetAllAccounts(string passKey = null)
{
if (passKey == null && this.Encrypted) return new SteamGuardAccount[0];
Expand Down

0 comments on commit 7d54013

Please sign in to comment.