mirror of
https://github.com/Crypto-Notepad/Crypto-Notepad.git
synced 2026-03-11 08:55:25 +00:00
Returned missing backward compatibility for decryption with custom salt.
This commit is contained in:
parent
31a8838919
commit
e500c95f5d
6 changed files with 53 additions and 6 deletions
|
|
@ -162,6 +162,9 @@
|
||||||
<setting name="passwordGeneratorNumberOfStrings" serializeAs="String">
|
<setting name="passwordGeneratorNumberOfStrings" serializeAs="String">
|
||||||
<value>10</value>
|
<value>10</value>
|
||||||
</setting>
|
</setting>
|
||||||
|
<setting name="TheSalt" serializeAs="String">
|
||||||
|
<value />
|
||||||
|
</setting>
|
||||||
</Crypto_Notepad.Properties.Settings>
|
</Crypto_Notepad.Properties.Settings>
|
||||||
</userSettings>
|
</userSettings>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
||||||
|
|
@ -204,16 +204,19 @@ public static async Task<string> Decrypt(string cipherText, string password, str
|
||||||
{
|
{
|
||||||
// Metadata parsing error
|
// Metadata parsing error
|
||||||
DialogResult result = MessageBox.Show("Unable to parse file metadata.\nAttempt to open anyway?\n(May result in a \'Incorrect Key\' error if the salt is wrong.)",
|
DialogResult result = MessageBox.Show("Unable to parse file metadata.\nAttempt to open anyway?\n(May result in a \'Incorrect Key\' error if the salt is wrong.)",
|
||||||
"Missing or Corrupted Metadata", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk);
|
"Missing or Corrupted Metadata", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
|
||||||
if (result == DialogResult.Yes)
|
if (result == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
// Default initialization vector from builds v1.1.2 and older
|
// Default initialization vector from builds v1.1.2 and older
|
||||||
const string default_IV = "16CHARSLONG12345";
|
const string default_IV = "16CHARSLONG12345";
|
||||||
|
|
||||||
initialVectorBytes = Encoding.ASCII.GetBytes(default_IV);
|
initialVectorBytes = Encoding.ASCII.GetBytes(default_IV);
|
||||||
saltValueBytes = Encoding.ASCII.GetBytes(salt);
|
saltValueBytes = Encoding.ASCII.GetBytes(salt);
|
||||||
}
|
}
|
||||||
else { return null; }
|
else
|
||||||
|
{
|
||||||
|
PublicVar.metadataCorrupt = true;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -78,8 +78,30 @@ private async Task DecryptAES()
|
||||||
toolbarPanel.Enabled = false;
|
toolbarPanel.Enabled = false;
|
||||||
richTextBox.ReadOnly = true;
|
richTextBox.ReadOnly = true;
|
||||||
string openedFileText = await reader.ReadToEndAsync();
|
string openedFileText = await reader.ReadToEndAsync();
|
||||||
richTextBox.Text = await AES.Decrypt(openedFileText, TypedPassword.Value, null, settings.HashAlgorithm,
|
if (string.IsNullOrEmpty(settings.TheSalt))
|
||||||
Convert.ToInt32(settings.PasswordIterations), Convert.ToInt32(settings.KeySize)); ;
|
{
|
||||||
|
richTextBox.Text = await AES.Decrypt(openedFileText, TypedPassword.Value, null, settings.HashAlgorithm,
|
||||||
|
Convert.ToInt32(settings.PasswordIterations), Convert.ToInt32(settings.KeySize));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string currentRichTextBoxText = richTextBox.Text;
|
||||||
|
richTextBox.Text = await AES.Decrypt(openedFileText, TypedPassword.Value, settings.TheSalt, settings.HashAlgorithm,
|
||||||
|
Convert.ToInt32(settings.PasswordIterations), Convert.ToInt32(settings.KeySize));
|
||||||
|
if (PublicVar.metadataCorrupt)
|
||||||
|
{
|
||||||
|
PublicVar.openFileName = Path.GetFileName(filePath);
|
||||||
|
PublicVar.metadataCorrupt = false;
|
||||||
|
mainMenu.Enabled = true;
|
||||||
|
toolbarPanel.Enabled = true;
|
||||||
|
richTextBox.ReadOnly = false;
|
||||||
|
UseWaitCursor = false;
|
||||||
|
richTextBox.ResumeDrawing();
|
||||||
|
richTextBox.Text = currentRichTextBoxText;
|
||||||
|
richTextBox.Modified = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Text = Path.GetFileName(openFileDialog.FileName) + " – " + PublicVar.appName;
|
Text = Path.GetFileName(openFileDialog.FileName) + " – " + PublicVar.appName;
|
||||||
filePath = openFileDialog.FileName;
|
filePath = openFileDialog.FileName;
|
||||||
|
|
@ -1904,6 +1926,7 @@ private void VariablesMainMenu_Click(object sender, EventArgs e)
|
||||||
Debug.WriteLine("okPressed: " + PublicVar.okPressed);
|
Debug.WriteLine("okPressed: " + PublicVar.okPressed);
|
||||||
Debug.WriteLine("RichTextBox.Modified: " + richTextBox.Modified);
|
Debug.WriteLine("RichTextBox.Modified: " + richTextBox.Modified);
|
||||||
Debug.WriteLine("EditorMenuStrip: " + contextMenu.Enabled);
|
Debug.WriteLine("EditorMenuStrip: " + contextMenu.Enabled);
|
||||||
|
Debug.WriteLine("metadataCorrupt: " + PublicVar.metadataCorrupt);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ static class PublicVar
|
||||||
public static bool messageBoxCenterParent = false;
|
public static bool messageBoxCenterParent = false;
|
||||||
public const string appName = "Crypto Notepad";
|
public const string appName = "Crypto Notepad";
|
||||||
public static string openFileName;
|
public static string openFileName;
|
||||||
|
public static bool metadataCorrupt = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class TypedPassword
|
static class TypedPassword
|
||||||
|
|
|
||||||
14
Crypto Notepad/Properties/Settings.Designer.cs
generated
14
Crypto Notepad/Properties/Settings.Designer.cs
generated
|
|
@ -662,6 +662,7 @@ public string passwordGeneratorLength {
|
||||||
}
|
}
|
||||||
|
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("10")]
|
[global::System.Configuration.DefaultSettingValueAttribute("10")]
|
||||||
public string passwordGeneratorNumberOfStrings {
|
public string passwordGeneratorNumberOfStrings {
|
||||||
|
|
@ -672,5 +673,18 @@ public string passwordGeneratorNumberOfStrings {
|
||||||
this["passwordGeneratorNumberOfStrings"] = value;
|
this["passwordGeneratorNumberOfStrings"] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||||
|
public string TheSalt {
|
||||||
|
get {
|
||||||
|
return ((string)(this["TheSalt"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["TheSalt"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,8 +149,11 @@
|
||||||
<Setting Name="passwordGeneratorLength" Provider="PortableSettingsProvider" Type="System.String" Scope="User">
|
<Setting Name="passwordGeneratorLength" Provider="PortableSettingsProvider" Type="System.String" Scope="User">
|
||||||
<Value Profile="(Default)">40</Value>
|
<Value Profile="(Default)">40</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="passwordGeneratorNumberOfStrings" Type="System.String" Scope="User">
|
<Setting Name="passwordGeneratorNumberOfStrings" Provider="PortableSettingsProvider" Type="System.String" Scope="User">
|
||||||
<Value Profile="(Default)">10</Value>
|
<Value Profile="(Default)">10</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting Name="TheSalt" Provider="PortableSettingsProvider" Type="System.String" Scope="User">
|
||||||
|
<Value Profile="(Default)" />
|
||||||
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
||||||
Loading…
Reference in a new issue