diff --git a/Build/KeePassLibSD_Distrib/KeePassLibSD.dll b/Build/KeePassLibSD_Distrib/KeePassLibSD.dll index b4eb0bd..b4a7e27 100644 Binary files a/Build/KeePassLibSD_Distrib/KeePassLibSD.dll and b/Build/KeePassLibSD_Distrib/KeePassLibSD.dll differ diff --git a/Build/KeePassLib_Distrib/KeePassLib.dll b/Build/KeePassLib_Distrib/KeePassLib.dll index 0b8797d..961d4e7 100644 Binary files a/Build/KeePassLib_Distrib/KeePassLib.dll and b/Build/KeePassLib_Distrib/KeePassLib.dll differ diff --git a/Docs/Chm/help/base/cmdline.html b/Docs/Chm/help/base/cmdline.html index 1c16d89..fa5e78a 100644 --- a/Docs/Chm/help/base/cmdline.html +++ b/Docs/Chm/help/base/cmdline.html @@ -64,8 +64,8 @@ security reasons (the operating system allows reading the command line options of other applications).

-

When passing the -pw-stdin option, KeePass ≥ 1.24 and ≥ 2.20 -read the password from the StdIn stream.

+

When passing the -pw-stdin option, KeePass +reads the password from the StdIn stream.

Key file. For supplying the key file location, the -keyfile: switch diff --git a/Docs/History.txt b/Docs/History.txt index 56e5a9d..61575d6 100644 --- a/Docs/History.txt +++ b/Docs/History.txt @@ -1,3 +1,25 @@ +2012-10-04: 2.20.1 +- Improved support for images with DPI resolutions different + from the DPI resolution of the display device +- {GOOGLECHROME} placeholder: updated detection code to also + support the latest versions of Chrome +- The option to lock on remote control mode changes now + additionally watches for remote connects and disconnects +- Improved Windows registry accesses +- Improved behavior when the user deletes the system temporary + directory +- On Unix-like systems, KeePass now stores most of its + temporary files in a private temporary directory (preferably + in $XDG_RUNTIME_DIR) +- Added detection support for the following web browsers on + Unix-like systems: Rekonq, Midori and Dooble +- KeePass does not try to set the WM_CLASS property on Mac OS X + systems anymore +- Modified some icons to work around unsupported PNG + transparency keys in Mono +- Various code optimizations +- Minor other improvements + 2012-09-08: 2.20 - Header data in KDBX files is now authenticated (to prevent silent data corruption attacks; thanks to P. Gasti and K. B. diff --git a/Ext/DeprecatedSources/AppConfigEx.cs b/Ext/DeprecatedSources/AppConfigEx.cs deleted file mode 100644 index 7d29452..0000000 --- a/Ext/DeprecatedSources/AppConfigEx.cs +++ /dev/null @@ -1,632 +0,0 @@ -/* - KeePass Password Safe - The Open-Source Password Manager - Copyright (C) 2003-2009 Dominik Reichl - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#if KeePassLibSD -using System; -using System.Collections.Generic; -using System.Text; -using System.IO; -using System.Xml; -using System.Reflection; -using System.Diagnostics; - -using KeePassLib; - -#if KeePassLibSD -using KeePassLibSD; -#endif - -namespace KeePassLib.Utility -{ - ///

- /// Implements a cascading configuration class (singleton). Application settings - /// are first tried to be loaded from the global configuration file. If the - /// requested configuration key isn't found, it is loaded from the user - /// configuration file (stored in the user directory). - /// - public static class AppConfigEx - { - private static SortedDictionary m_cfgCurrent = - new SortedDictionary(); - - private static bool m_bModified = false; - - private static string m_strGlobalConfigFile = null; - private static string m_strUserConfigFile = null; - private static string m_strCreateDir = null; - - private static string m_strBaseName = null; - - private const string RootElementName = "Configuration"; - private const string ConfigItemElement = "Item"; - private const string ConfigItemName = "Name"; - private const string ConfigItemValue = "Value"; - - private const string ValTrue = "True"; - private const string ValFalse = "False"; - - /// - /// Get/set the base name for the configuration. If this property is - /// null, the class constructs names based on the current - /// assembly and the product name. - /// - public static string BaseName - { - get { return m_strBaseName; } - - set - { - m_strBaseName = value; - - m_strGlobalConfigFile = null; // Invalidate paths - m_strUserConfigFile = null; - m_strCreateDir = null; - } - } - - /// - /// Load configuration. This method will load configuration information - /// from several different files (global configuration file in application - /// directory, configuration file in user directory, etc.) and mix them - /// into one in-memory configuration pool. - /// Base name for the configuration files and - /// directories. For example, this could be "KeePass". - /// - public static void Load() - { - GetConfigPaths(); - - SortedDictionary dictGlobal; - LoadFile(m_strGlobalConfigFile, out dictGlobal); - Debug.Assert(dictGlobal != null); - - SortedDictionary dictUser; - LoadFile(m_strUserConfigFile, out dictUser); - Debug.Assert(dictUser != null); - - // Combine global and user options. Global options override user options. - m_cfgCurrent = dictGlobal; - foreach(KeyValuePair kvp in dictUser) - { - if(!m_cfgCurrent.ContainsKey(kvp.Key)) - m_cfgCurrent[kvp.Key] = kvp.Value; - } - - m_bModified = false; - } - - private static void GetConfigPaths() - { - if(m_strGlobalConfigFile == null) - { - Assembly asm = Assembly.GetExecutingAssembly(); - Debug.Assert(asm != null); if(asm == null) return; - -#if !KeePassLibSD - string strFile = null; - - try { strFile = asm.Location; } - catch(Exception) { } - - if((strFile == null) || (strFile.Length == 0)) - strFile = UrlUtil.FileUrlToPath(asm.GetName().CodeBase); -#else - string strFile = UrlUtil.FileUrlToPath(asm.GetName().CodeBase); -#endif - Debug.Assert(strFile != null); if(strFile == null) return; - - if((m_strBaseName == null) || (m_strBaseName.Length == 0)) - { - // Remove assembly extension - if(strFile.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) - strFile = strFile.Substring(0, strFile.Length - 4); - else if(strFile.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) - strFile = strFile.Substring(0, strFile.Length - 4); - } - else // Base name != null - { - strFile = UrlUtil.GetFileDirectory(strFile, true) + m_strBaseName; - } - - m_strGlobalConfigFile = strFile + ".config.xml"; - } - - if(m_strUserConfigFile == null) - { - string strBaseDirName = PwDefs.ShortProductName; - if((m_strBaseName != null) && (m_strBaseName.Length > 0)) - strBaseDirName = m_strBaseName; - - string strUserDir; - try - { - strUserDir = Environment.GetFolderPath( - Environment.SpecialFolder.ApplicationData); - } - catch(Exception) - { - strUserDir = UrlUtil.GetFileDirectory(UrlUtil.FileUrlToPath( - Assembly.GetExecutingAssembly().GetName().CodeBase), true); - } - - if((!strUserDir.EndsWith(new string(Path.DirectorySeparatorChar, 1))) && - (!strUserDir.EndsWith("\\")) && (!strUserDir.EndsWith("/"))) - { - strUserDir += new string(Path.DirectorySeparatorChar, 1); - } - - m_strCreateDir = strUserDir + strBaseDirName; - m_strUserConfigFile = m_strCreateDir + Path.DirectorySeparatorChar + - strBaseDirName + ".config.xml"; - } - } - - private static void EnsureAppDataDirAvailable() - { - Debug.Assert(m_strCreateDir != null); - if(m_strCreateDir == null) return; - - if(!Directory.Exists(m_strCreateDir)) - { - try { Directory.CreateDirectory(m_strCreateDir); } - catch(Exception) { Debug.Assert(false); } - } - } - - private static bool LoadFile(string strFile, out SortedDictionary vConfig) - { - XmlDocument doc = new XmlDocument(); - XmlNode xmlField; - string strValue; - - vConfig = new SortedDictionary(); - - try { doc.Load(strFile); } - catch(Exception) { return false; } - - XmlElement el = doc.DocumentElement; - if(el == null) return false; - if(el.Name != RootElementName) return false; - if(el.ChildNodes.Count <= 0) return true; - - foreach(XmlNode xmlChild in el.ChildNodes) - { - Debug.Assert(xmlChild != null); if(xmlChild == null) continue; - - xmlField = xmlChild.Attributes.GetNamedItem(ConfigItemName); - if(xmlField == null) continue; - - strValue = xmlChild.InnerText; - if(strValue != null) vConfig[xmlField.Value] = strValue; - else vConfig[xmlField.Value] = string.Empty; - } - - return true; - } - - /// - /// Save the current configuration to files. File cascading is - /// handled by this function. This function first tries to write - /// to the global configuration file, if this fails it tries the - /// configuration file in the user's application directory. - /// - /// Returns true, if the configuration was saved - /// successfully, false otherwise. - public static bool Save() - { - if(m_bModified == false) return true; - - GetConfigPaths(); - - if(SaveFile(m_strGlobalConfigFile)) return true; - - EnsureAppDataDirAvailable(); - if(SaveFile(m_strUserConfigFile)) return true; - - return false; - } - - private static bool SaveFile(string strFile) - { - if(strFile == null) return false; - - XmlTextWriter xtw; - try { xtw = new XmlTextWriter(strFile, Encoding.UTF8); } - catch(Exception) { return false; } - Debug.Assert(xtw != null); if(xtw == null) return false; - - xtw.WriteStartDocument(); - xtw.WriteWhitespace("\r\n"); - xtw.WriteStartElement(RootElementName); - xtw.WriteWhitespace("\r\n"); - - Debug.Assert(m_cfgCurrent != null); - foreach(KeyValuePair kvp in m_cfgCurrent) - { - xtw.WriteWhitespace("\t"); - xtw.WriteStartElement(ConfigItemElement); - xtw.WriteAttributeString(ConfigItemName, kvp.Key); - - // xtw.WriteAttributeString(ConfigItemValue, kvp.Value); - xtw.WriteString(kvp.Value); - - xtw.WriteEndElement(); - xtw.WriteWhitespace("\r\n"); - } - - xtw.WriteEndElement(); - xtw.WriteWhitespace("\r\n"); - xtw.WriteEndDocument(); - xtw.Close(); - - return true; - } - - /// - /// Get the status of the global configuration file. - /// - /// Returns true if you can write to the - /// global configuration file. - public static bool HasWriteAccessToGlobal() - { - GetConfigPaths(); - - StreamWriter sw = null; - try { sw = File.AppendText(m_strGlobalConfigFile); } - catch(Exception) { } - - if(sw != null) - { - sw.Close(); - return true; - } - - return false; - } - - /// - /// Get a configuration string. - /// - /// Name of the configuration item. - /// Configuration item value. Returns an empty string ("") if - /// the named item could not be found. - /// Thrown if - /// is null. - public static string GetValue(string strField) - { - Debug.Assert(strField != null); if(strField == null) throw new ArgumentNullException(); - - string str; - if(m_cfgCurrent.TryGetValue(strField, out str)) return str; - - return string.Empty; - } - - /// - /// Get a configuration string. - /// - /// Name of the configuration item. - /// Default string to return if the named item - /// doesn't exist. May be null. - /// Configuration item value. Returns - /// if the configuration item doesn't exist. - public static string GetValue(string strField, string strDefault) - { - Debug.Assert(strField != null); if(strField == null) throw new ArgumentNullException(); - - string str; - if(m_cfgCurrent.TryGetValue(strField, out str)) return str; - - return strDefault; - } - - /// - /// Get a configuration string. - /// - /// Key/value pair. Key = field name, value = default - /// value to return if the key isn't found. - /// Configuration item value or the default value. - public static string GetValue(KeyValuePair kvp) - { - string str; - if(m_cfgCurrent.TryGetValue(kvp.Key, out str)) return str; - - return kvp.Value; - } - - /// - /// Set a configuration item's value. The item is created if it doesn't - /// exist yet. It is overwritten if it exists already. - /// - /// Name of the configuration entry. - /// Value of the configuration entry. - /// Thrown if one of - /// the parameters is null. - public static void SetValue(string strField, string strValue) - { - Debug.Assert(strField != null); // Exception will be thrown by GetValue - Debug.Assert(strValue != null); if(strValue == null) throw new ArgumentNullException(); - - string strExisting = GetValue(strField, null); - - if(strExisting == null) // Key doesn't exist yet - { - m_cfgCurrent[strField] = strValue; - m_bModified = true; - } - else // strExisting != null, i.e. key exists already - { - if(!strValue.Equals(strExisting)) - { - m_cfgCurrent[strField] = strValue; - m_bModified = true; - } - } - } - - public static void SetValue(KeyValuePair kvpField, string strValue) - { - SetValue(kvpField.Key, strValue); - } - - /// - /// Get a boolean value from the current configuration. - /// - /// Name of the field to get. - /// Default value that is returned - /// if the specified field doesn't exist. - /// Returns boolean value. - public static bool GetBool(string strField, bool bDefaultIfNotFound) - { - Debug.Assert(strField != null); if(strField == null) throw new ArgumentNullException(); - - string str; - if(m_cfgCurrent.TryGetValue(strField, out str)) - { - if(str.Equals(ValTrue)) return true; - if(str.Equals(ValFalse)) return false; - } - - return bDefaultIfNotFound; - } - - public static bool GetBool(KeyValuePair kvp) - { - Debug.Assert((kvp.Value == ValTrue) || (kvp.Value == ValFalse)); - - string str; - if(m_cfgCurrent.TryGetValue(kvp.Key, out str)) - { - if(str.Equals(ValTrue)) return true; - if(str.Equals(ValFalse)) return false; - } - - return (kvp.Value == ValTrue); - } - - /// - /// Set a configuration item's value. - /// - /// Name of the item. - /// Value of the item. - public static void SetValue(string strField, bool bValue) - { - SetValue(strField, bValue ? ValTrue : ValFalse); - } - - public static void SetValue(KeyValuePair kvpField, bool bValue) - { - SetValue(kvpField.Key, bValue); - } - - /// - /// Get an integer value from the current configuration. - /// - /// Name of the configuration item. - /// Default value that is returned if - /// the specified item cannot be found. - /// An integer. - /// Thrown if - /// is null. - public static int GetInt(string strField, int nDefaultIfNotFound) - { - Debug.Assert(strField != null); - if(strField == null) throw new ArgumentNullException("strField"); - - string str; - if(m_cfgCurrent.TryGetValue(strField, out str)) - { - int nValue; - if(StrUtil.TryParseInt(str, out nValue)) return nValue; - } - - return nDefaultIfNotFound; - } - - public static int GetInt(KeyValuePair kvp) - { - int nValue; - string str; - if(m_cfgCurrent.TryGetValue(kvp.Key, out str)) - { - if(StrUtil.TryParseInt(str, out nValue)) return nValue; - else { Debug.Assert(false); } - } - - if(StrUtil.TryParseInt(kvp.Value, out nValue)) return nValue; - else { Debug.Assert(false); } - - return 0; - } - - /// - /// Get an unsigned integer value from the current configuration. - /// - /// Name of the configuration item. - /// Default value that is returned if - /// the specified item cannot be found. - /// An unsigned integer. - /// Thrown if - /// is null. - public static uint GetUInt(string strField, uint uDefaultIfNotFound) - { - Debug.Assert(strField != null); - if(strField == null) throw new ArgumentNullException("strField"); - - string str; - if(m_cfgCurrent.TryGetValue(strField, out str)) - { - uint uValue; - if(StrUtil.TryParseUInt(str, out uValue)) return uValue; - } - - return uDefaultIfNotFound; - } - - public static uint GetUInt(KeyValuePair kvp) - { - uint uValue; - string str; - if(m_cfgCurrent.TryGetValue(kvp.Key, out str)) - { - if(StrUtil.TryParseUInt(str, out uValue)) return uValue; - else { Debug.Assert(false); } - } - - if(StrUtil.TryParseUInt(kvp.Value, out uValue)) return uValue; - else { Debug.Assert(false); } - - return 0; - } - - /// - /// Get an unsigned long integer value from the current configuration. - /// - /// Name of the configuration item. - /// Default value that is returned if - /// the specified item cannot be found. - /// An unsigned long integer. - /// Thrown if - /// is null. - public static ulong GetULong(string strField, ulong uDefaultIfNotFound) - { - Debug.Assert(strField != null); - if(strField == null) throw new ArgumentNullException("strField"); - - string str; - if(m_cfgCurrent.TryGetValue(strField, out str)) - { - ulong uValue; - if(StrUtil.TryParseULong(str, out uValue)) return uValue; - } - - return uDefaultIfNotFound; - } - - public static ulong GetULong(KeyValuePair kvp) - { - ulong uValue; - string str; - if(m_cfgCurrent.TryGetValue(kvp.Key, out str)) - { - if(StrUtil.TryParseULong(str, out uValue)) return uValue; - else { Debug.Assert(false); } - } - - if(StrUtil.TryParseULong(kvp.Value, out uValue)) return uValue; - else { Debug.Assert(false); } - - return 0; - } - - /// - /// Set a configuration item's value. - /// - /// Name of the configuration item. - /// Value of the configuration item. - public static void SetValue(string strField, int nValue) - { - SetValue(strField, nValue.ToString()); - } - - public static void SetValue(KeyValuePair kvpField, int nValue) - { - SetValue(kvpField.Key, nValue.ToString()); - } - - /// - /// Set a configuration item's value. - /// - /// Name of the configuration item. - /// Value of the configuration item. - public static void SetValue(string strField, uint uValue) - { - SetValue(strField, uValue.ToString()); - } - - public static void SetValue(KeyValuePair kvpField, uint uValue) - { - SetValue(kvpField.Key, uValue.ToString()); - } - - /// - /// Set a configuration item's value. - /// - /// Name of the configuration item. - /// Value of the configuration item. - public static void SetValue(string strField, ulong uValue) - { - SetValue(strField, uValue.ToString()); - } - - public static void SetValue(KeyValuePair kvpField, ulong uValue) - { - SetValue(kvpField.Key, uValue.ToString()); - } - - /// - /// Remove all fields indexed by a prefix and consecutive numbers. - /// All fields starting with the prefix will be removed. Index - /// is zero-based. - /// - /// Field prefix. - /// First index. - public static void RemoveIndexedItems(string strFieldPrefix, uint uStartIndex) - { - uint uPos = uStartIndex; - string strField; - - while(true) - { - strField = strFieldPrefix + uPos.ToString(); - - if(GetValue(strField, null) != null) - { - m_cfgCurrent.Remove(strField); - Debug.Assert(GetValue(strField, null) == null); - - ++uPos; - } - else break; - } - } - } -} - -#endif // KeePassLibSD diff --git a/Ext/DeprecatedSources/AppPolicy.txt b/Ext/DeprecatedSources/AppPolicy.txt deleted file mode 100644 index db4c3cc..0000000 --- a/Ext/DeprecatedSources/AppPolicy.txt +++ /dev/null @@ -1,147 +0,0 @@ - /// - /// Application policy settings - /// - public static class AppPolicy - { - private static bool[] m_vCurPolicyFlags = new bool[(int)AppPolicyFlag.Count]; - private static bool[] m_vNewPolicyFlags = new bool[(int)AppPolicyFlag.Count]; - - private static string PolicyToString(AppPolicyFlag flag) - { - string str = KPRes.Feature + @": "; - - switch(flag) - { - case AppPolicyFlag.Plugins: - str += KPRes.Plugins; - break; - case AppPolicyFlag.Export: - str += KPRes.Export; - break; - case AppPolicyFlag.Import: - str += KPRes.Import; - break; - case AppPolicyFlag.Print: - str += KPRes.Print; - break; - case AppPolicyFlag.SaveDatabase: - str += KPRes.SaveDatabase; - break; - case AppPolicyFlag.AutoType: - str += KPRes.AutoType; - break; - case AppPolicyFlag.CopyToClipboard: - str += KPRes.Clipboard; - break; - case AppPolicyFlag.DragDrop: - str += KPRes.DragDrop; - break; - case AppPolicyFlag.ChangeMasterKey: - str += KPRes.ChangeMasterKey; - break; - case AppPolicyFlag.EditTriggers: - str += KPRes.TriggersEdit; - break; - case AppPolicyFlag.UnhidePasswords: - str += KPRes.UnhidePasswords; - break; - default: - Debug.Assert(false); - str += KPRes.Unknown + "."; - break; - } - - str += MessageService.NewLine + KPRes.Description + @": "; - - switch(flag) - { - case AppPolicyFlag.Plugins: - str += KPRes.PolicyPluginsDesc; - break; - case AppPolicyFlag.Export: - str += KPRes.PolicyExportDesc; - break; - case AppPolicyFlag.Import: - str += KPRes.PolicyImportDesc; - break; - case AppPolicyFlag.Print: - str += KPRes.PolicyPrintDesc; - break; - case AppPolicyFlag.SaveDatabase: - str += KPRes.PolicySaveDatabaseDesc; - break; - case AppPolicyFlag.AutoType: - str += KPRes.PolicyAutoTypeDesc; - break; - case AppPolicyFlag.CopyToClipboard: - str += KPRes.PolicyClipboardDesc; - break; - case AppPolicyFlag.DragDrop: - str += KPRes.PolicyDragDropDesc; - break; - case AppPolicyFlag.ChangeMasterKey: - str += KPRes.PolicyChangeMasterKey; - break; - case AppPolicyFlag.EditTriggers: - str += KPRes.PolicyTriggersEditDesc; - break; - case AppPolicyFlag.UnhidePasswords: - str += KPRes.UnhidePasswordsDesc; - break; - default: - Debug.Assert(false); - str += KPRes.Unknown + "."; - break; - } - - return str; - } - - public static string RequiredPolicyMessage(AppPolicyFlag flag) - { - string str = KPRes.PolicyDisallowed + MessageService.NewParagraph; - str += KPRes.PolicyRequiredFlag + ":" + MessageService.NewLine; - str += PolicyToString(flag); - - return str; - } - - public static void CurrentAllowAll(bool bAllow) - { - for(int i = 0; i < (int)AppPolicyFlag.Count; ++i) - m_vCurPolicyFlags[i] = m_vNewPolicyFlags[i] = bAllow; - } - - public static void CurrentAllow(AppPolicyFlag flag, bool bAllow) - { - m_vCurPolicyFlags[(int)flag] = m_vNewPolicyFlags[(int)flag] = bAllow; - } - - public static void NewAllow(AppPolicyFlag flag, bool bAllow) - { - m_vNewPolicyFlags[(int)flag] = bAllow; - } - - public static bool NewIsAllowed(AppPolicyFlag flag) - { - return m_vNewPolicyFlags[(int)flag]; - } - - public static bool IsAllowed(AppPolicyFlag flag) - { - return m_vCurPolicyFlags[(int)flag]; - } - - public static bool Try(AppPolicyFlag flag) - { - bool bAllowed = m_vCurPolicyFlags[(int)flag]; - - if(bAllowed == false) - { - string strMsg = RequiredPolicyMessage(flag); - MessageService.ShowWarning(strMsg); - } - - return bAllowed; - } - } diff --git a/Ext/DeprecatedSources/EntryTemplates.cs b/Ext/DeprecatedSources/EntryTemplates.cs deleted file mode 100644 index 1a2dc3a..0000000 --- a/Ext/DeprecatedSources/EntryTemplates.cs +++ /dev/null @@ -1,226 +0,0 @@ -/* - KeePass Password Safe - The Open-Source Password Manager - Copyright (C) 2003-2009 Dominik Reichl - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; -using System.Windows.Forms; -using System.Diagnostics; - -using KeePass.Forms; -using KeePass.Resources; - -using KeePassLib; -using KeePassLib.Security; - -namespace KeePass.Util -{ - internal sealed class EntryTemplateItem - { - private bool m_bProtected = false; - private string m_strItemName = string.Empty; - - public bool Protected - { - get { return m_bProtected; } - } - - public string Name - { - get { return m_strItemName; } - } - - public EntryTemplateItem(string strItemName, bool bProtected) - { - if(strItemName == null) throw new ArgumentNullException("strItemName"); - m_strItemName = strItemName; - m_bProtected = bProtected; - } - } - - internal sealed class EntryTemplate - { - private string m_strName = string.Empty; - private Image m_imgSmallIcon = null; - private EntryTemplateItem[] m_pItems = null; - - public string Name - { - get { return m_strName; } - } - - public Image SmallIcon - { - get { return m_imgSmallIcon; } - } - - public EntryTemplateItem[] Items - { - get { return m_pItems; } - } - - public EntryTemplate(string strName, Image imgSmallIcon, EntryTemplateItem[] pEntries) - { - if(strName == null) throw new ArgumentNullException("strName"); - if(pEntries == null) throw new ArgumentNullException("pEntries"); - - m_strName = strName; - m_imgSmallIcon = imgSmallIcon; - m_pItems = pEntries; - } - } - - public static class EntryTemplates - { - private static List m_vTemplates = new List(); - - private static ToolStripSplitButton m_btnItemsHost = null; - private static List m_vToolStripItems = new List(); - - public static void Init(ToolStripSplitButton btnHost) - { - if(btnHost == null) throw new ArgumentNullException("btnHost"); - m_btnItemsHost = btnHost; - - ToolStripSeparator tsSep = new ToolStripSeparator(); - m_btnItemsHost.DropDownItems.Add(tsSep); - m_vToolStripItems.Add(tsSep); - - EntryTemplates.AddItem(BankAccount); - EntryTemplates.AddItem(PersonalContact); - } - - private static void AddItem(EntryTemplate et) - { - m_vTemplates.Add(et); - - ToolStripMenuItem tsmi = new ToolStripMenuItem(et.Name); - tsmi.Click += OnEntryTemplatesExecute; - m_btnItemsHost.DropDownItems.Add(tsmi); - - if(et.SmallIcon != null) tsmi.Image = et.SmallIcon; - else tsmi.Image = KeePass.Properties.Resources.B16x16_KGPG_Key1; - - m_vToolStripItems.Add(tsmi); - } - - public static void Clear() - { - m_vTemplates.Clear(); - - foreach(ToolStripItem tsmi in m_vToolStripItems) - { - tsmi.Click -= OnEntryTemplatesExecute; - m_btnItemsHost.DropDownItems.Remove(tsmi); - } - - m_vToolStripItems.Clear(); - } - - private static void OnEntryTemplatesExecute(object sender, EventArgs e) - { - ToolStripMenuItem tsmi = sender as ToolStripMenuItem; - if(tsmi == null) { Debug.Assert(false); return; } - - string strName = tsmi.Text; - foreach(EntryTemplate et in m_vTemplates) - { - if(et.Name == strName) - { - CreateEntry(et); - break; - } - } - } - - private static void CreateEntry(EntryTemplate et) - { - if(Program.MainForm.ActiveDatabase.IsOpen == false) - { - Debug.Assert(false); - return; - } - - PwGroup pgContainer = Program.MainForm.GetSelectedGroup(); - if(pgContainer == null) - pgContainer = Program.MainForm.ActiveDatabase.RootGroup; - - PwEntry pe = new PwEntry(true, true); - - // pe.Strings.Set(PwDefs.TitleField, new ProtectedString( - // Program.MainForm.Database.MemoryProtection.ProtectTitle, - // et.Name)); - - foreach(EntryTemplateItem eti in et.Items) - pe.Strings.Set(eti.Name, new ProtectedString(eti.Protected, string.Empty)); - - PwEntryForm pef = new PwEntryForm(); - pef.InitEx(pe, PwEditMode.AddNewEntry, Program.MainForm.ActiveDatabase, - Program.MainForm.ClientIcons, true); - - if(pef.ShowDialog() == DialogResult.OK) - { - pgContainer.AddEntry(pe, true); - - // Program.MainForm.UpdateEntryList(null, true); - // Program.MainForm.UpdateUIState(true); - Program.MainForm.UpdateUI(false, null, false, null, true, null, true); - } - else Program.MainForm.UpdateUI(false, null, false, null, false, null, false); - } - - private static readonly EntryTemplate BankAccount = new EntryTemplate( - KPRes.BankAccount, null, new EntryTemplateItem[]{ - new EntryTemplateItem(KPRes.TAccountNumber, false), - new EntryTemplateItem(KPRes.TAccountType, false), - new EntryTemplateItem(KPRes.BranchCode, false), - new EntryTemplateItem(KPRes.RoutingCode, false), - new EntryTemplateItem(KPRes.SortCode, false), - new EntryTemplateItem(KPRes.Iban, false), - new EntryTemplateItem(KPRes.SwiftCode, false), - new EntryTemplateItem(KPRes.BranchTel, false), - new EntryTemplateItem(KPRes.TAccountInfoTel, false), - new EntryTemplateItem(KPRes.BranchHours, false), - new EntryTemplateItem(KPRes.TAccountNames, false), - new EntryTemplateItem(KPRes.MinBalance, false), - new EntryTemplateItem(KPRes.TransfersOf, false), - new EntryTemplateItem(KPRes.Frequency, false) - }); - - private static readonly EntryTemplate PersonalContact = new EntryTemplate( - KPRes.Contact, null, new EntryTemplateItem[]{ - new EntryTemplateItem(KPRes.JobTitle, false), - new EntryTemplateItem(KPRes.Department, false), - new EntryTemplateItem(KPRes.Company, false), - new EntryTemplateItem(KPRes.WorkTel, false), - new EntryTemplateItem(KPRes.EMail, false), - new EntryTemplateItem(KPRes.HomeTel, false), - new EntryTemplateItem(KPRes.MobileTel, false), - new EntryTemplateItem(KPRes.Pager, false), - new EntryTemplateItem(KPRes.CarTel, false), - new EntryTemplateItem(KPRes.WorkFax, false), - new EntryTemplateItem(KPRes.HomeFax, false), - new EntryTemplateItem(KPRes.WebPage, false), - new EntryTemplateItem(KPRes.Assistant, false), - new EntryTemplateItem(KPRes.AssistantTel, false), - new EntryTemplateItem(KPRes.HomeAddress, false) - }); - } -} diff --git a/Ext/DeprecatedSources/EntryTemplates_DefaultText.xml b/Ext/DeprecatedSources/EntryTemplates_DefaultText.xml deleted file mode 100644 index 611a0c6..0000000 --- a/Ext/DeprecatedSources/EntryTemplates_DefaultText.xml +++ /dev/null @@ -1,1499 +0,0 @@ - - - - - Action - - - Add custom toolbar button - - - Add Entry - - - Add Entry... - - - Create a new password entry. - - - Add Entry String Field - - - Create a new string field for the current entry. - - - Advanced - - - After Opening a Database - - - All Entries - - - All Files - - - All Supported Files - - - Application - - - Application exit - - - Application startup - - - Arguments - - - Do you want to continue? - - - Assistant - - - AssistantTel - - - The following file has already been attached to the current entry: - - - Failed to attach file: - - - Attach Files To Entry - - - Attachments - - - Save Attached File As - - - Save attached files to: - - - Do you wish to rename the new file or overwrite the existing attached file? - - - Click [Yes] to rename the new file. - - - Click [No] to overwrite the existing attached file. - - - Click [Cancel] to skip this file. - - - Author - - - Automatically create new - - - Automatically generated passwords for new entries - - - Remember and automatically open last used database on startup - - - Automatically save when closing/locking the database - - - Show expired entries (if any) - - - Show entries that will expire soon (if any) - - - Auto-Type - - - Auto-Type Entry Selection - - - Multiple entries have been found for the currently active window. Please select the entry, which you want to auto-type into the active window. - - - Multiple entries exist for the current window. - - - Auto-type obfuscation may not work with all windows. - - - Prepend special initialization sequence for Internet Explorer windows - - - The specified auto-type sequence is invalid. - - - The following auto-type placeholder or special key code is unknown/unsupported: - - - Available Languages - - - Bank Account - - - Bits - - - Branch Code - - - Branch Hours - - - Branch Tel. - - - Browser - - - < &Back - - - &Finish - - - &Next > - - - Cancel - - - Cannot move entries because they aren't stored in the same group. - - - Car Tel. - - - You are changing the composite master key for the currently-open database. - - - Check for update at KeePass startup - - - You have the latest version. - - - New KeePass version available! - - - &Clear List - - - Clipboard - - - Clipboard will be cleared in [PARAM] seconds - - - Clear clipboard when closing KeePass - - - Data copied to clipboard. - - - Protect clipboard using 'Clipboard Viewer Ignore' format - - - &Close - - - Close button [X] minimizes main window instead of terminating the application - - - Company - - - Comparison - - - Components - - - Condition - - - Changes to the configuration/policy will affect you and all users of this KeePass installation. - - - Changes to the configuration/policy will only affect you. Policy flags that are enforced by the administrator are reset after restarting KeePass. - - - Failed to save the configuration. - - - Configure Auto-Type - - - Configure auto-type behaviour for this entry. - - - Configure Auto-Type Item - - - Associate a window title with a keystroke sequence. - - - Configure Keystroke Sequence - - - Define a default keystroke sequence. - - - Create New Password Database - Step 2 - - - Contact - - - Contains - - - Copied entry data to clipboard - - - Copy - - - Copy All - - - Copy - - - Copy Password to Clipboard - - - Copy &Password - - - Copy &TAN - - - Copy User Name to Clipboard - - - Create Composite Master Key - - - Create New Password Database - - - Creation Time - - - Remember user name and password - - - Do not remember user name and password - - - Remember user name only - - - CSV / Text File - - - Current Style - - - Custom - - - Custom Fields - - - Customizable HTML File - - - Custom toolbar button clicked - - - Cut - - - Data - - - Database - - - Enter a short description of the database or leave it empty. - - - Database Maintenance - - - Here you can maintain the currently opened database. - - - The current database file has been modified - - - Enter a name for the database or leave it empty. - - - Database Settings - - - Here you can configure various database settings. - - - Default - - - Delete - - - Delete Entries - - - Delete Entry - - - Are you sure you want to permanently delete the selected entries? - - - Are you sure you want to permanently delete the selected entry? - - - Delete Group - - - Deleting a group will also delete all entries and subgroups in that group. - - - Are you sure you want to permanently delete the selected group? - - - Department - - - Description - - - Details - - - Discard changes - - - Please see the documentation for more details. - - - Drag&Drop - - - The string field name you specified already exists. String field names must be unique for each entry. - - - Edit Entry - - - You're editing an existing password entry. - - - Edit Group - - - Edit properties of the currently selected group. - - - Edit Entry String Field - - - Edit one of the entry's string fields. - - - eMail - - - Empty - - - Encoding - - - Default ANSI (System) - - - Selected encoding is invalid. The file cannot be interpreted using the selected encoding. - - - Ends with - - - Enter Master Key - - - Generate additional random bits. - - - Entropy Collection - - - Entry - - - Entry List - - - Environment variable - - - Equals - - - Error Code - - - Errors - - - Event - - - Execute command line / URL - - - Exit instead of locking the workspace after the specified time - - - Expired Entries - - - Expiry Time - - - Export - - - Export data to an external file. - - - Export File/Data - - - Export To HTML - - - Export entries to a HTML file. - - - Exporting... - - - Export to: - - - Fatal Error - - - Feature - - - Field Name - - - The entered name exists already and cannot be used. - - - The entered name is invalid and cannot be used. - - - Please enter a field name. - - - The selected field, which identifies the source entry, contains illegal characters (like '{', '}', newline characters, ...). - - - Multiple entries match the specified identifying field. - - - To avoid ambiguity, entries can be identified by their UUIDs, which are unique. - - - Field Value - - - File - - - The file on disk/server has changed since it was loaded. Probably someone else has edited and saved the database. - - - Save the current database to the file. Changes made by the other user will be lost. - - - Load the file on disk/server and merge it with the current database in memory. - - - File exists - - - The following file exists already: - - - Failed to create the file association. Make sure you have write access to the file associations list. - - - Successfully associated KDBX files with KeePass! KDBX files will now be opened by KeePass when you double-click on them. - - - KeePass Password Database - - - The specified file is currently locked by the following user: - - - KeePass will open the file, but note that you might overwrite changes each other when saving. - - - This file path contains a semicolon (;) and therefore cannot be processed. Replace the semicolon and repeat the procedure. - - - The specified file could not be found. - - - File/URL - - - Files - - - Save database changes before closing the file? - - - Save database changes before exiting KeePass? - - - Save database changes before locking the workspace? - - - Abort the current operation. - - - The file will not be closed. - - - KeePass will not be closed. - - - The KeePass workspace will not be locked. - - - Discard all changes made to the database and close the file. - - - Discard all changes made to the database and exit KeePass. - - - Discard all changes made to the database and lock the KeePass workspace. - - - Save all changes made to the database and close the file. - - - Save all changes made to the database and exit KeePass. - - - Save all changes made to the database and lock the KeePass workspace. - - - The new file's content does not match the data that KeePass has written, i.e. writing to the file has failed and it might be corrupted now. - - - Please try saving again, and if that fails, save the database to a different location. - - - Filter - - - Focus entry list after a successful quick search (toolbar) - - - This file format doesn't support database descriptions. - - - This file format doesn't support database names. - - - This file format doesn't support root groups. All entries in the root group are moved to the first subgroup. - - - To export to this file format, the root group must have at least one subgroup. - - - This file format only supports one attachment per entry. Only the first attachment is saved, the others are ignored. - - - Frequency - - - General - - - Generated Passwords Count - - - Enter number of passwords to generate. - - - Please enter the number of passwords to generate: - - - Generated Passwords Samples - - - Generate a password - - - Generic CSV Importer - - - Remove selected profile - - - Remove the currently selected profile. - - - Save as Profile - - - Save current settings as a profile. - - - Please enter a name for the new password generator profile, or select an existing profile name to overwrite it: - - - Derive from previous password - - - Group - - - The selected group cannot store any entries. - - - This option is disabled, because local help is not installed. - - - Help Source Selection - - - Choose between local help and online help center. - - - Hide field using asterisks - - - Home Address - - - Homebanking - - - Home Fax - - - Do you want to visit the KeePass homepage now? - - - Home Tel. - - - IBAN - - - ID - - - Ignore - - - This file uses a file format feature that is not supported. - - - Image Viewer - - - Import - - - Import Behavior - - - Select an import method. - - - Import failed. - - - Import an external file. - - - Files to be imported: - - - Import File/Data - - - The import process has finished! - - - Importing... - - - It is indispensable that you read the documentation about this import method before continuing. - - - Have you understood how the import process works and want to start it now? - - - Internet - - - Invalid file structure! - - - Invalid Key - - - The specified URL is invalid. - - - The specified user name / password combination is invalid. - - - Job Title - - - The KeePassLibC library is required to open and save KDB files created by KeePass 1.x. - - - KeePass KDBX Files - - - KeePassLibC (1.x File Support) - - - KeePassLibC could not be found. - - - Alt - - - Control - - - Key Modifiers - - - Shift - - - Create a new key file - - - The specified key file could not be found or its format is unknown. - - - Key Files - - - Select key file manually - - - Use an existing file as key file - - - Keystroke Sequence - - - The selected language has been activated. KeePass must be restarted in order to load the language. - - - Last Access Time - - - Last Modification Time - - - Limit to single instance - - - Locked - - - &Lock Workspace - - - Un&lock Workspace - - - Lock workspace when minimizing main window - - - Lock workspace when locking Windows, switching user or sleeping - - - Main Window - - - Composite master key has been changed! - - - Save the database now in order to get the new key applied. - - - The master password must be at least {PARAM} characters long! - - - The estimated quality of the master password must be at least {PARAM} bits! - - - Menus - - - Merging data... - - - Min. Balance - - - Minimize main window after copying data to the clipboard - - - Minimize main window after locking the workspace - - - Minimize main window after opening a database - - - Minimize to tray instead of taskbar - - - Mobile Tel. - - - Name - - - Use native library for faster key transformations - - - Navigation - - - Network - - - Never expires - - - NewDatabase.kdbx - - - New Group - - - New state - - - No - - - The operating system didn't KeePass grant read access to the specified file. - - - (None) - - - None - - - Not - - - Notes - - - Not installed - - - The selected file isn't a valid XSL stylesheet. - - - The object with the specified name could not be found. - - - Off - - - of - - - On - - - Open Database File - - - Open database file - - - Opened database file - - - Opening password database... - - - Optimize for screen reader (only enable if you're using a screen reader) - - - Options - - - Here you can configure the global KeePass program options. - - - Other Placeholders - - - Overwrite - - - Overwrite the existing file? - - - Pager - - - Detailed descriptions of all parameters can be found in the help manual. - - - Password - - - Password Managers - - - Password Generation Options - - - Here you can define properties of generated passwords. - - - Enter the password: - - - Password and repeated password aren't identical! - - - Paste - - - Perform global auto-type - - - Pick Characters - - - Select the requested character positions. - - - Pick an icon. - - - Plugin - - - The following plugin cannot be loaded: - - - Plugins - - - Here you can configure all loaded KeePass plugins. - - - Allow auto-typing entries to other windows. - - - Allow copying entry information to clipboard (main window only). - - - This operation is disallowed by the application policy. Ask your administrator to allow this operation. - - - Allow sending information to other windows using drag&drop. - - - Allow exporting entries to (non-encrypted) file formats. - - - Allow importing entries from external files. - - - Allow loading plugins to extend KeePass functionality. - - - Allow printing password entry lists. - - - The following policy flag is required - - - Allow saving databases to disk/URL. - - - Print - - - Print password entries. - - - Quick Search - - - Exclude expired entries in quick searches (toolbar) - - - Ready. - - - Recycle Bin - - - Remember password hiding setting in 'Edit Entry' window - - - Do you wish to restart KeePass now? - - - Routing Code - - - Sample Entry - - - Save - - - Do you want to save the changes before closing? - - - KeePass - Save Before Close/Lock? - - - Save Database - - - Saved database file - - - Saving database... - - - Saving database file - - - Search... - - - Search the password database for entries. - - - Search Results - - - entries found. - - - Automatically search key files on removable media - - - Type to search the database - - - in - - - Find - - - Select All - - - Select Color - - - Please select a different group. - - - selected - - - Select a file. - - - Select an icon - - - Select Language - - - Here you can select a different user interface language. - - - One or more of the KeePass self-tests failed. - - - Show All Entries - - - Show Expired Entries - - - Show full path in title bar (instead of file name only) - - - Show grid lines in password entry list - - - Show in - - - Show tray icon only if main window has been sent to tray - - - Expired Entries and Entries That Will Expire Soon - - - Sort Code - - - Special Keys - - - Select one of the standard expire times - - - Standard Fields - - - Start and Exit - - - Start minimized and locked - - - Starts with - - - Success. - - - SWIFT Code - - - Synchronization failed. - - - Synchronize - - - Synchronizing... - - - Make sure that the two databases use the same composite master key. This is required for synchronization. - - - Synchronization completed successfully. - - - System - - - System Code Page - - - Account Info Tel. - - - Account names - - - Account Number - - - Account Type - - - TAN Wizard - - - With this TAN wizard you can easily add TAN entries. - - - Target Window - - - Text Viewer - - - Time span - - - Title - - - Toggle - - - Show/hide password using asterisks - - - New... - - - Open... - - - Save All - - - Too many files have been selected. Select smaller groups and repeat the current procedure a few times. - - - Transfers Of - - - Compute the number of rounds that lead to a delay of 1 second on this computer. - - - The trigger action type is unknown. - - - Add Trigger - - - Create a new workflow automation. - - - The trigger condition type is unknown. - - - Edit Trigger - - - Modify an existing workflow automation. - - - The trigger event type is unknown. - - - Trigger execution failed - - - Trigger name - - - Triggers - - - Automate workflows using the trigger system. - - - Change trigger on/off state - - - A newer KeePass version or a plugin might be required for this type. - - - Undo - - - Unknown - - - An unknown error occurred. - - - Unknown file version! - - - Update checking failed. - - - URL - - - Open a database stored on a server. - - - Open From URL - - - URL Override - - - Save current database on a server. - - - Save To URL - - - User Name - - - Enter the user name: - - - UUID - - - Value - - - Version - - - View Entry - - - You're viewing a password entry. - - - Wait - - - Warnings - - - Web Browser - - - Web Page - - - Web Site Login - - - Web Sites - - - Windows - - - Work Fax - - - Workspace Locked - - - Work Tel. - - - Transform using XSL Stylesheet - - - XSL Stylesheets - - - Select XSL Transformation File - - - XSL Stylesheets for KDB4 XML - - - Yes - - - - - - Failed to initialize encryption/decryption stream! - - - AES/Rijndael (256-Bit Key) - - - An extended error report has been copied to the clipboard. Please send it to the KeePass developers. - - - Fatal Error - - - A fatal error has occurred! - - - The file is corrupted. - - - The file header is corrupted! Some header data was declared but is not present. - - - Failed to load the specified file! - - - A newer KeePass version is required to open this file. - - - The target file might be in a corrupted state. Please try saving again, and if that fails, save the database to a different location. - - - Failed to save the current database to the specified location! - - - The file signature is invalid. Either the file isn't a KeePass database file at all or it is corrupted. - - - The file is encrypted using an unknown encryption algorithm! - - - The file is compressed using an unknown compression algorithm! - - - The file version is unsupported. - - - Failed to create the final encryption/decryption key! - - - The .NET framework/runtime, under which KeePass is currently running, does not support this operation. - - - The composite key is invalid! - - - Make sure the composite key is correct and try again. - - - Found invalid data while decoding. - - - In order to import KeePass 1.x KDB files, create a new 2.x database file and click 'File' -> 'Import' in the main menu. In the import dialog, choose 'KeePass KDB (1.x)' as file format. - - - The length of the master key seed is invalid! - - - The selected file appears to be an old format - - - Unknown header ID! - - - The operating system did not grant KeePass read/write access to the user profile folder, where the protected user key is stored. - - - diff --git a/Ext/DeprecatedSources/ImportCsvForm_120218.Designer.cs b/Ext/DeprecatedSources/ImportCsvForm_120218.Designer.cs deleted file mode 100644 index a83ebbb..0000000 --- a/Ext/DeprecatedSources/ImportCsvForm_120218.Designer.cs +++ /dev/null @@ -1,262 +0,0 @@ -namespace KeePass.Forms -{ - partial class ImportCsvForm - { - /// - /// Erforderliche Designervariable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Verwendete Ressourcen bereinigen. - /// - /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. - protected override void Dispose(bool disposing) - { - if(disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Vom Windows Form-Designer generierter Code - - /// - /// Erforderliche Methode für die Designerunterstützung. - /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. - /// - private void InitializeComponent() - { - this.m_btnOK = new System.Windows.Forms.Button(); - this.m_btnCancel = new System.Windows.Forms.Button(); - this.m_lblFileEncoding = new System.Windows.Forms.Label(); - this.m_cmbEncoding = new System.Windows.Forms.ComboBox(); - this.m_lvPreview = new KeePass.UI.CustomListViewEx(); - this.m_tbSourcePreview = new System.Windows.Forms.TextBox(); - this.m_lblSourcePreview = new System.Windows.Forms.Label(); - this.m_lvHeaderOrder = new KeePass.UI.CustomListViewEx(); - this.m_lblOrder = new System.Windows.Forms.Label(); - this.m_lblOrderHint = new System.Windows.Forms.Label(); - this.m_lblPreview = new System.Windows.Forms.Label(); - this.m_lblDelimiter = new System.Windows.Forms.Label(); - this.m_tbSepChar = new System.Windows.Forms.TextBox(); - this.m_cbDoubleQuoteToSingle = new System.Windows.Forms.CheckBox(); - this.m_pbRender = new System.Windows.Forms.ProgressBar(); - this.m_btnPreviewRefresh = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // m_btnOK - // - this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.m_btnOK.Location = new System.Drawing.Point(702, 450); - this.m_btnOK.Name = "m_btnOK"; - this.m_btnOK.Size = new System.Drawing.Size(75, 23); - this.m_btnOK.TabIndex = 0; - this.m_btnOK.Text = "&Import"; - this.m_btnOK.UseVisualStyleBackColor = true; - this.m_btnOK.Click += new System.EventHandler(this.OnBtnOK); - // - // m_btnCancel - // - this.m_btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.m_btnCancel.Location = new System.Drawing.Point(702, 479); - this.m_btnCancel.Name = "m_btnCancel"; - this.m_btnCancel.Size = new System.Drawing.Size(75, 23); - this.m_btnCancel.TabIndex = 1; - this.m_btnCancel.Text = "&Cancel"; - this.m_btnCancel.UseVisualStyleBackColor = true; - this.m_btnCancel.Click += new System.EventHandler(this.OnBtnCancel); - // - // m_lblFileEncoding - // - this.m_lblFileEncoding.AutoSize = true; - this.m_lblFileEncoding.Location = new System.Drawing.Point(9, 15); - this.m_lblFileEncoding.Name = "m_lblFileEncoding"; - this.m_lblFileEncoding.Size = new System.Drawing.Size(73, 13); - this.m_lblFileEncoding.TabIndex = 2; - this.m_lblFileEncoding.Text = "File encoding:"; - // - // m_cmbEncoding - // - this.m_cmbEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.m_cmbEncoding.FormattingEnabled = true; - this.m_cmbEncoding.Location = new System.Drawing.Point(105, 12); - this.m_cmbEncoding.Name = "m_cmbEncoding"; - this.m_cmbEncoding.Size = new System.Drawing.Size(228, 21); - this.m_cmbEncoding.TabIndex = 3; - this.m_cmbEncoding.SelectedIndexChanged += new System.EventHandler(this.OnCmbEncodingSelectedIndexChanged); - // - // m_lvPreview - // - this.m_lvPreview.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.m_lvPreview.Location = new System.Drawing.Point(12, 262); - this.m_lvPreview.Name = "m_lvPreview"; - this.m_lvPreview.ShowItemToolTips = true; - this.m_lvPreview.Size = new System.Drawing.Size(684, 240); - this.m_lvPreview.TabIndex = 14; - this.m_lvPreview.UseCompatibleStateImageBehavior = false; - this.m_lvPreview.View = System.Windows.Forms.View.Details; - // - // m_tbSourcePreview - // - this.m_tbSourcePreview.AcceptsReturn = true; - this.m_tbSourcePreview.Location = new System.Drawing.Point(105, 39); - this.m_tbSourcePreview.Multiline = true; - this.m_tbSourcePreview.Name = "m_tbSourcePreview"; - this.m_tbSourcePreview.ReadOnly = true; - this.m_tbSourcePreview.Size = new System.Drawing.Size(672, 90); - this.m_tbSourcePreview.TabIndex = 5; - // - // m_lblSourcePreview - // - this.m_lblSourcePreview.AutoSize = true; - this.m_lblSourcePreview.Location = new System.Drawing.Point(9, 42); - this.m_lblSourcePreview.Name = "m_lblSourcePreview"; - this.m_lblSourcePreview.Size = new System.Drawing.Size(68, 13); - this.m_lblSourcePreview.TabIndex = 4; - this.m_lblSourcePreview.Text = "Source data:"; - // - // m_lvHeaderOrder - // - this.m_lvHeaderOrder.AllowColumnReorder = true; - this.m_lvHeaderOrder.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.m_lvHeaderOrder.Location = new System.Drawing.Point(105, 135); - this.m_lvHeaderOrder.Name = "m_lvHeaderOrder"; - this.m_lvHeaderOrder.Size = new System.Drawing.Size(672, 53); - this.m_lvHeaderOrder.TabIndex = 7; - this.m_lvHeaderOrder.UseCompatibleStateImageBehavior = false; - this.m_lvHeaderOrder.View = System.Windows.Forms.View.Details; - // - // m_lblOrder - // - this.m_lblOrder.AutoSize = true; - this.m_lblOrder.Location = new System.Drawing.Point(9, 141); - this.m_lblOrder.Name = "m_lblOrder"; - this.m_lblOrder.Size = new System.Drawing.Size(90, 13); - this.m_lblOrder.TabIndex = 6; - this.m_lblOrder.Text = "Define field order:"; - // - // m_lblOrderHint - // - this.m_lblOrderHint.AutoSize = true; - this.m_lblOrderHint.Location = new System.Drawing.Point(102, 191); - this.m_lblOrderHint.Name = "m_lblOrderHint"; - this.m_lblOrderHint.Size = new System.Drawing.Size(499, 13); - this.m_lblOrderHint.TabIndex = 8; - this.m_lblOrderHint.Text = "Drag&&drop the columns to define the order of the fields in the CSV file. \"(Ignor" + - "e)\" columns will be ignored."; - // - // m_lblPreview - // - this.m_lblPreview.AutoSize = true; - this.m_lblPreview.Location = new System.Drawing.Point(9, 246); - this.m_lblPreview.Name = "m_lblPreview"; - this.m_lblPreview.Size = new System.Drawing.Size(125, 13); - this.m_lblPreview.TabIndex = 12; - this.m_lblPreview.Text = "Imported entries preview:"; - // - // m_lblDelimiter - // - this.m_lblDelimiter.AutoSize = true; - this.m_lblDelimiter.Location = new System.Drawing.Point(9, 216); - this.m_lblDelimiter.Name = "m_lblDelimiter"; - this.m_lblDelimiter.Size = new System.Drawing.Size(73, 13); - this.m_lblDelimiter.TabIndex = 9; - this.m_lblDelimiter.Text = "Field delimiter:"; - // - // m_tbSepChar - // - this.m_tbSepChar.Location = new System.Drawing.Point(105, 213); - this.m_tbSepChar.Name = "m_tbSepChar"; - this.m_tbSepChar.Size = new System.Drawing.Size(35, 20); - this.m_tbSepChar.TabIndex = 10; - this.m_tbSepChar.TextChanged += new System.EventHandler(this.OnDelimiterTextChanged); - // - // m_cbDoubleQuoteToSingle - // - this.m_cbDoubleQuoteToSingle.AutoSize = true; - this.m_cbDoubleQuoteToSingle.Location = new System.Drawing.Point(165, 215); - this.m_cbDoubleQuoteToSingle.Name = "m_cbDoubleQuoteToSingle"; - this.m_cbDoubleQuoteToSingle.Size = new System.Drawing.Size(238, 17); - this.m_cbDoubleQuoteToSingle.TabIndex = 11; - this.m_cbDoubleQuoteToSingle.Text = "Replace double quote (\"\") by single quote (\")"; - this.m_cbDoubleQuoteToSingle.UseVisualStyleBackColor = true; - this.m_cbDoubleQuoteToSingle.CheckedChanged += new System.EventHandler(this.OnDoubleQuoteCheckedChanged); - // - // m_pbRender - // - this.m_pbRender.Location = new System.Drawing.Point(142, 246); - this.m_pbRender.Name = "m_pbRender"; - this.m_pbRender.Size = new System.Drawing.Size(554, 13); - this.m_pbRender.Style = System.Windows.Forms.ProgressBarStyle.Continuous; - this.m_pbRender.TabIndex = 13; - // - // m_btnPreviewRefresh - // - this.m_btnPreviewRefresh.Location = new System.Drawing.Point(702, 262); - this.m_btnPreviewRefresh.Name = "m_btnPreviewRefresh"; - this.m_btnPreviewRefresh.Size = new System.Drawing.Size(75, 23); - this.m_btnPreviewRefresh.TabIndex = 15; - this.m_btnPreviewRefresh.Text = "&Refresh"; - this.m_btnPreviewRefresh.UseVisualStyleBackColor = true; - this.m_btnPreviewRefresh.Click += new System.EventHandler(this.OnBtnPreviewRefresh); - // - // ImportCsvForm - // - this.AcceptButton = this.m_btnOK; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.m_btnCancel; - this.ClientSize = new System.Drawing.Size(789, 514); - this.Controls.Add(this.m_btnPreviewRefresh); - this.Controls.Add(this.m_pbRender); - this.Controls.Add(this.m_cbDoubleQuoteToSingle); - this.Controls.Add(this.m_tbSepChar); - this.Controls.Add(this.m_lblDelimiter); - this.Controls.Add(this.m_lblPreview); - this.Controls.Add(this.m_lblOrderHint); - this.Controls.Add(this.m_lblOrder); - this.Controls.Add(this.m_lvHeaderOrder); - this.Controls.Add(this.m_lblSourcePreview); - this.Controls.Add(this.m_tbSourcePreview); - this.Controls.Add(this.m_lvPreview); - this.Controls.Add(this.m_cmbEncoding); - this.Controls.Add(this.m_lblFileEncoding); - this.Controls.Add(this.m_btnCancel); - this.Controls.Add(this.m_btnOK); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ImportCsvForm"; - this.ShowInTaskbar = false; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Generic CSV Importer"; - this.Load += new System.EventHandler(this.OnFormLoad); - this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button m_btnOK; - private System.Windows.Forms.Button m_btnCancel; - private System.Windows.Forms.Label m_lblFileEncoding; - private System.Windows.Forms.ComboBox m_cmbEncoding; - private KeePass.UI.CustomListViewEx m_lvPreview; - private System.Windows.Forms.TextBox m_tbSourcePreview; - private System.Windows.Forms.Label m_lblSourcePreview; - private KeePass.UI.CustomListViewEx m_lvHeaderOrder; - private System.Windows.Forms.Label m_lblOrder; - private System.Windows.Forms.Label m_lblOrderHint; - private System.Windows.Forms.Label m_lblPreview; - private System.Windows.Forms.Label m_lblDelimiter; - private System.Windows.Forms.TextBox m_tbSepChar; - private System.Windows.Forms.CheckBox m_cbDoubleQuoteToSingle; - private System.Windows.Forms.ProgressBar m_pbRender; - private System.Windows.Forms.Button m_btnPreviewRefresh; - } -} \ No newline at end of file diff --git a/Ext/DeprecatedSources/ImportCsvForm_120218.cs b/Ext/DeprecatedSources/ImportCsvForm_120218.cs deleted file mode 100644 index 3b9916f..0000000 --- a/Ext/DeprecatedSources/ImportCsvForm_120218.cs +++ /dev/null @@ -1,277 +0,0 @@ -/* - KeePass Password Safe - The Open-Source Password Manager - Copyright (C) 2003-2012 Dominik Reichl - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using System.Diagnostics; -using System.IO; - -using KeePass.DataExchange; -using KeePass.UI; -using KeePass.Resources; - -using KeePassLib; -using KeePassLib.Security; - -namespace KeePass.Forms -{ - public partial class ImportCsvForm : Form - { - private PwDatabase m_pwDatabase = null; - private byte[] m_pbInData = null; - private bool m_bBlockChangedEvent = false; - - private string m_strSource = string.Empty; - - private const string StrEncAscii = "ASCII"; - private const string StrEncUtf7 = "UTF-7"; - private const string StrEncUtf8 = "UTF-8"; - private const string StrEncUtf32 = "UTF-32"; - private const string StrEncUnicode = "Unicode"; - private const string StrEncBigUnicode = "Big Endian Unicode"; - - public void InitEx(PwDatabase pwStorage, byte[] pbInData) - { - m_pwDatabase = pwStorage; - m_pbInData = pbInData; - } - - public ImportCsvForm() - { - InitializeComponent(); - Program.Translation.ApplyTo(this); - } - - private void OnFormLoad(object sender, EventArgs e) - { - Debug.Assert(m_pwDatabase != null); if(m_pwDatabase == null) throw new InvalidOperationException(); - Debug.Assert(m_pbInData != null); if(m_pbInData == null) throw new InvalidOperationException(); - - GlobalWindowManager.AddWindow(this); - - this.Icon = Properties.Resources.KeePass; - - m_bBlockChangedEvent = true; - - AddFieldColumn(m_lvHeaderOrder, KPRes.Title, -1); - AddFieldColumn(m_lvHeaderOrder, KPRes.UserName, -1); - AddFieldColumn(m_lvHeaderOrder, KPRes.Password, -1); - AddFieldColumn(m_lvHeaderOrder, KPRes.Url, -1); - AddFieldColumn(m_lvHeaderOrder, KPRes.Notes, -1); - AddFieldColumn(m_lvHeaderOrder, KPRes.Custom + " 1", -1); - AddFieldColumn(m_lvHeaderOrder, KPRes.Custom + " 2", -1); - AddFieldColumn(m_lvHeaderOrder, KPRes.Custom + " 3", -1); - AddFieldColumn(m_lvHeaderOrder, "(" + KPRes.Ignore + ")", -1); - AddFieldColumn(m_lvHeaderOrder, "(" + KPRes.Ignore + ")", -1); - AddFieldColumn(m_lvHeaderOrder, "(" + KPRes.Ignore + ")", -1); - - foreach(ColumnHeader chHdr in m_lvHeaderOrder.Columns) - chHdr.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); - - const int nPrevColSize = 120; - AddFieldColumn(m_lvPreview, KPRes.Title, nPrevColSize); - AddFieldColumn(m_lvPreview, KPRes.UserName, nPrevColSize); - AddFieldColumn(m_lvPreview, KPRes.Password, nPrevColSize); - AddFieldColumn(m_lvPreview, KPRes.Url, nPrevColSize); - AddFieldColumn(m_lvPreview, KPRes.Notes, nPrevColSize); - AddFieldColumn(m_lvPreview, KPRes.Custom + " 1", nPrevColSize); - AddFieldColumn(m_lvPreview, KPRes.Custom + " 2", nPrevColSize); - AddFieldColumn(m_lvPreview, KPRes.Custom + " 3", nPrevColSize); - - m_cmbEncoding.Items.Add(KPRes.EncodingAnsi); - m_cmbEncoding.Items.Add(StrEncAscii); - m_cmbEncoding.Items.Add(StrEncUtf7); - m_cmbEncoding.Items.Add(StrEncUtf8); - m_cmbEncoding.Items.Add(StrEncUtf32); - m_cmbEncoding.Items.Add(StrEncUnicode); - m_cmbEncoding.Items.Add(StrEncBigUnicode); - - m_cmbEncoding.SelectedIndex = 0; - m_tbSepChar.Text = ","; - m_cbDoubleQuoteToSingle.Checked = true; - - m_bBlockChangedEvent = false; - - UpdateStringSource(); - UpdatePreview(); - } - - private static void AddFieldColumn(ListView lv, string strText, int nSize) - { - ColumnHeader hdr = lv.Columns.Add(strText); - - if(nSize >= 0) hdr.Width = nSize; - } - - private void OnBtnOK(object sender, EventArgs e) - { - OnBtnPreviewRefresh(sender, e); - Application.DoEvents(); - - int nItem = 0; - foreach(ListViewItem lvi in m_lvPreview.Items) - { - m_pbRender.Value = (100 * nItem) / m_lvPreview.Items.Count; - ++nItem; - - PwEntry pe = new PwEntry(true, true); - m_pwDatabase.RootGroup.AddEntry(pe, true); - - pe.Strings.Set(PwDefs.TitleField, new ProtectedString( - m_pwDatabase.MemoryProtection.ProtectTitle, lvi.Text)); - pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( - m_pwDatabase.MemoryProtection.ProtectUserName, lvi.SubItems[1].Text)); - pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( - m_pwDatabase.MemoryProtection.ProtectPassword, lvi.SubItems[2].Text)); - pe.Strings.Set(PwDefs.UrlField, new ProtectedString( - m_pwDatabase.MemoryProtection.ProtectUrl, lvi.SubItems[3].Text)); - pe.Strings.Set(PwDefs.NotesField, new ProtectedString( - m_pwDatabase.MemoryProtection.ProtectNotes, lvi.SubItems[4].Text)); - - string strCustom = lvi.SubItems[5].Text; - if(strCustom.Length > 0) - pe.Strings.Set(KPRes.Custom + " 1", new ProtectedString(false, strCustom)); - - strCustom = lvi.SubItems[6].Text; - if(strCustom.Length > 0) - pe.Strings.Set(KPRes.Custom + " 2", new ProtectedString(false, strCustom)); - - strCustom = lvi.SubItems[7].Text; - if(strCustom.Length > 0) - pe.Strings.Set(KPRes.Custom + " 3", new ProtectedString(false, strCustom)); - } - - m_pbRender.Value = 100; - } - - private void OnBtnCancel(object sender, EventArgs e) - { - } - - private void UpdateStringSource() - { - string strEncoding = (m_cmbEncoding.Items[m_cmbEncoding.SelectedIndex] as string); - - Encoding enc = Encoding.Default; - if(strEncoding == StrEncAscii) enc = Encoding.ASCII; - else if(strEncoding == StrEncUtf7) enc = Encoding.UTF7; - else if(strEncoding == StrEncUtf8) enc = Encoding.UTF8; - else if(strEncoding == StrEncUtf32) enc = Encoding.UTF32; - else if(strEncoding == StrEncUnicode) enc = Encoding.Unicode; - else if(strEncoding == StrEncBigUnicode) enc = Encoding.BigEndianUnicode; - else { Debug.Assert(strEncoding == KPRes.EncodingAnsi); } - - try - { - MemoryStream ms = new MemoryStream(m_pbInData, false); - StreamReader sr = new StreamReader(ms, enc); - m_strSource = sr.ReadToEnd(); - sr.Close(); - ms.Close(); - } - catch(Exception) { m_strSource = KPRes.EncodingFail; } - - m_tbSourcePreview.Text = string.Empty; - m_tbSourcePreview.Text = m_strSource; - } - - private void UpdatePreview() - { - m_lvPreview.Items.Clear(); - // m_lvPreview.BeginUpdate(); - - string strDelimiter = m_tbSepChar.Text; - if(strDelimiter.Length == 0) return; - - char[] vPartTrimChars = new char[] { '\"' }; - int nLine = 0; - string[] vLines = m_strSource.Split(new char[] { '\r', '\n' }); - foreach(string strLine in vLines) - { - m_pbRender.Value = (100 * nLine) / vLines.Length; - ++nLine; - - if((strLine == null) || (strLine.Length == 0)) continue; - - List vParts = ImportUtil.SplitCsvLine(strLine, strDelimiter); - - for(int i = 0; i < vParts.Count; ++i) - vParts[i] = vParts[i].Trim(vPartTrimChars); - - ListViewItem lvi = new ListViewItem(string.Empty); - - lvi.Text = SafeListIndex(vParts, m_lvHeaderOrder.Columns[0].DisplayIndex); - lvi.SubItems.Add(SafeListIndex(vParts, m_lvHeaderOrder.Columns[1].DisplayIndex)); - lvi.SubItems.Add(SafeListIndex(vParts, m_lvHeaderOrder.Columns[2].DisplayIndex)); - lvi.SubItems.Add(SafeListIndex(vParts, m_lvHeaderOrder.Columns[3].DisplayIndex)); - lvi.SubItems.Add(SafeListIndex(vParts, m_lvHeaderOrder.Columns[4].DisplayIndex)); - lvi.SubItems.Add(SafeListIndex(vParts, m_lvHeaderOrder.Columns[5].DisplayIndex)); - lvi.SubItems.Add(SafeListIndex(vParts, m_lvHeaderOrder.Columns[6].DisplayIndex)); - lvi.SubItems.Add(SafeListIndex(vParts, m_lvHeaderOrder.Columns[7].DisplayIndex)); - - m_lvPreview.Items.Add(lvi); - } - - m_pbRender.Value = 100; - // m_lvPreview.EndUpdate(); - } - - private static string SafeListIndex(List vList, int nIndex) - { - if(nIndex >= vList.Count) return string.Empty; - return vList[nIndex]; - } - - private void OnCmbEncodingSelectedIndexChanged(object sender, EventArgs e) - { - if(m_bBlockChangedEvent) return; - - UpdateStringSource(); - UpdatePreview(); - } - - private void OnDelimiterTextChanged(object sender, EventArgs e) - { - if(m_bBlockChangedEvent) return; - - UpdatePreview(); - } - - private void OnDoubleQuoteCheckedChanged(object sender, EventArgs e) - { - if(m_bBlockChangedEvent) return; - - UpdatePreview(); - } - - private void OnBtnPreviewRefresh(object sender, EventArgs e) - { - UpdatePreview(); - } - - private void OnFormClosed(object sender, FormClosedEventArgs e) - { - GlobalWindowManager.RemoveWindow(this); - } - } -} \ No newline at end of file diff --git a/Ext/DeprecatedSources/ImportCsvForm_120218.resx b/Ext/DeprecatedSources/ImportCsvForm_120218.resx deleted file mode 100644 index ff31a6d..0000000 --- a/Ext/DeprecatedSources/ImportCsvForm_120218.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Ext/DeprecatedSources/Kdb4File.Read.Dom.cs b/Ext/DeprecatedSources/Kdb4File.Read.Dom.cs deleted file mode 100644 index 24b4cca..0000000 --- a/Ext/DeprecatedSources/Kdb4File.Read.Dom.cs +++ /dev/null @@ -1,680 +0,0 @@ -/* - KeePass Password Safe - The Open-Source Password Manager - Copyright (C) 2003-2010 Dominik Reichl - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -using System; -using System.Collections.Generic; -using System.Text; -using System.Security; -using System.Security.Cryptography; -using System.Drawing; -using System.Xml; -using System.IO; -using System.Diagnostics; - -using KeePassLib; -using KeePassLib.Collections; -using KeePassLib.Cryptography; -using KeePassLib.Cryptography.Cipher; -using KeePassLib.Interfaces; -using KeePassLib.Security; -using KeePassLib.Utility; - -namespace KeePassLib.Serialization -{ - public sealed partial class Kdb4File - { - /* - private void ReadXmlDom(Stream readerStream) - { - XmlDocument doc = new XmlDocument(); - doc.Load(readerStream); - - XmlElement el = doc.DocumentElement; - ReadDocument(el); - } - - private void ReadDocument(XmlNode xmlRootNode) - { - Debug.Assert(xmlRootNode != null); - if(xmlRootNode == null) throw new ArgumentNullException("xmlRootNode"); - if(xmlRootNode.Name != ElemDocNode) throw new XmlException("xmlRootNode"); - - foreach(XmlNode xmlChild in xmlRootNode.ChildNodes) - { - string strNodeName = xmlChild.Name; - - if(strNodeName == ElemMeta) ReadMeta(xmlChild); - else if(strNodeName == ElemRoot) ReadRoot(xmlChild); - else ReadUnknown(xmlChild); - } - } - */ - - private void ReadUnknown(XmlNode xmlNode) - { - ProcessNode(xmlNode); - - // if(m_slLogger != null) - // m_slLogger.SetText("Unknown field: " + xmlNode.Name, LogStatusType.Warning); - - foreach(XmlNode xmlChild in xmlNode.ChildNodes) - ReadUnknown(xmlChild); - } - - private XorredBuffer ProcessNode(XmlNode xmlNode) - { - Debug.Assert(xmlNode != null); - if(xmlNode == null) throw new ArgumentNullException("xmlNode"); - - XmlAttributeCollection xac = xmlNode.Attributes; - if(xac == null) return null; - - XmlNode xmlProtected = xac.GetNamedItem(AttrProtected); - if(xmlProtected != null) - { - if(xmlProtected.Value == ValTrue) - { - string strInner = xmlNode.InnerText; - - byte[] pbEncrypted; - if(strInner.Length > 0) - pbEncrypted = Convert.FromBase64String(strInner); - else pbEncrypted = new byte[0]; - - byte[] pbPad = m_randomStream.GetRandomBytes((uint)pbEncrypted.Length); - - return new XorredBuffer(pbEncrypted, pbPad); - } - } - - return null; - } - - /* - private void ReadMeta(XmlNode xmlNode) - { - ProcessNode(xmlNode); - - foreach(XmlNode xmlChild in xmlNode.ChildNodes) - { - string strName = xmlChild.Name; - - if(strName == ElemGenerator) { } // Ignore - else if(strName == ElemDbName) - m_pwDatabase.Name = ReadString(xmlChild); - else if(strName == ElemDbNameChanged) - m_pwDatabase.NameChanged = ReadTime(xmlChild); - else if(strName == ElemDbDesc) - m_pwDatabase.Description = ReadString(xmlChild); - else if(strName == ElemDbDescChanged) - m_pwDatabase.DescriptionChanged = ReadTime(xmlChild); - else if(strName == ElemDbDefaultUser) - m_pwDatabase.DefaultUserName = ReadString(xmlChild); - else if(strName == ElemDbDefaultUserChanged) - m_pwDatabase.DefaultUserNameChanged = ReadTime(xmlChild); - else if(strName == ElemDbMntncHistoryDays) - m_pwDatabase.MaintenanceHistoryDays = ReadUInt(xmlChild, 365); - else if(strName == ElemDbKeyChanged) - m_pwDatabase.MasterKeyChanged = ReadTime(xmlChild); - else if(strName == ElemDbKeyChangeRec) - m_pwDatabase.MasterKeyChangeRec = ReadLong(xmlChild, -1); - else if(strName == ElemDbKeyChangeForce) - m_pwDatabase.MasterKeyChangeForce = ReadLong(xmlChild, -1); - else if(strName == ElemMemoryProt) - ReadMemoryProtection(xmlChild); - else if(strName == ElemCustomIcons) - ReadCustomIcons(xmlChild); - else if(strName == ElemRecycleBinEnabled) - m_pwDatabase.RecycleBinEnabled = ReadBool(xmlChild, true); - else if(strName == ElemRecycleBinUuid) - m_pwDatabase.RecycleBinUuid = ReadUuid(xmlChild); - else if(strName == ElemRecycleBinChanged) - m_pwDatabase.RecycleBinChanged = ReadTime(xmlChild); - else if(strName == ElemEntryTemplatesGroup) - m_pwDatabase.EntryTemplatesGroup = ReadUuid(xmlChild); - else if(strName == ElemEntryTemplatesGroupChanged) - m_pwDatabase.EntryTemplatesGroupChanged = ReadTime(xmlChild); - else if(strName == ElemLastSelectedGroup) - m_pwDatabase.LastSelectedGroup = ReadUuid(xmlChild); - else if(strName == ElemLastTopVisibleGroup) - m_pwDatabase.LastTopVisibleGroup = ReadUuid(xmlChild); - else if(strName == ElemCustomData) - ReadStringDictEx(xmlChild, m_pwDatabase.CustomData); - else ReadUnknown(xmlChild); - } - } - - private void ReadMemoryProtection(XmlNode xmlNode) - { - ProcessNode(xmlNode); - - foreach(XmlNode xmlChild in xmlNode.ChildNodes) - { - string strName = xmlChild.Name; - - if(strName == ElemProtTitle) - m_pwDatabase.MemoryProtection.ProtectTitle = ReadBool(xmlChild, false); - else if(strName == ElemProtUserName) - m_pwDatabase.MemoryProtection.ProtectUserName = ReadBool(xmlChild, false); - else if(strName == ElemProtPassword) - m_pwDatabase.MemoryProtection.ProtectPassword = ReadBool(xmlChild, true); - else if(strName == ElemProtUrl) - m_pwDatabase.MemoryProtection.ProtectUrl = ReadBool(xmlChild, false); - else if(strName == ElemProtNotes) - m_pwDatabase.MemoryProtection.ProtectNotes = ReadBool(xmlChild, false); - // else if(strName == ElemProtAutoHide) - // m_pwDatabase.MemoryProtection.AutoEnableVisualHiding = ReadBool(xmlChild, true); - else ReadUnknown(xmlChild); - } - } - - private void ReadCustomIcons(XmlNode xmlNode) - { - ProcessNode(xmlNode); - - foreach(XmlNode xmlChild in xmlNode.ChildNodes) - { - string strName = xmlChild.Name; - - if(strName == ElemCustomIconItem) - ReadCustomIcon(xmlChild); - else ReadUnknown(xmlChild); - } - } - - private void ReadCustomIcon(XmlNode xmlNode) - { - ProcessNode(xmlNode); - - PwUuid uuid = PwUuid.Zero; - byte[] pbImageData = null; - - foreach(XmlNode xmlChild in xmlNode.ChildNodes) - { - string strName = xmlChild.Name; - - if(strName == ElemCustomIconItemID) - uuid = ReadUuid(xmlChild); - else if(strName == ElemCustomIconItemData) - { - string str = ReadString(xmlChild); - - if((str != null) && (str.Length > 0)) - pbImageData = Convert.FromBase64String(str); - else { Debug.Assert(false); } - } - else ReadUnknown(xmlChild); - } - - if((uuid != PwUuid.Zero) && (pbImageData != null)) - m_pwDatabase.CustomIcons.Add(new PwCustomIcon(uuid, pbImageData)); - else { Debug.Assert(false); } - } - - private void ReadRoot(XmlNode xmlNode) - { - ProcessNode(xmlNode); - - bool bFoundDataGroup = false; - foreach(XmlNode xmlChild in xmlNode.ChildNodes) - { - string strName = xmlChild.Name; - - if(strName == ElemGroup) - { - if(!bFoundDataGroup) - { - m_pwDatabase.RootGroup = ReadGroup(xmlChild); - bFoundDataGroup = true; - } - else { Debug.Assert(false); ReadUnknown(xmlChild); } - } - else if(strName == ElemDeletedObjects) - { - ReadDeletedObjects(xmlChild, m_pwDatabase.DeletedObjects); - } - else ReadUnknown(xmlChild); - } - - Debug.Assert(m_pwDatabase.RootGroup != null); - Debug.Assert(m_pwDatabase.RootGroup.ParentGroup == null); - } - - private PwGroup ReadGroup(XmlNode xmlNode) - { - ProcessNode(xmlNode); - - PwGroup pgStorage = new PwGroup(false, false); - - foreach(XmlNode xmlChild in xmlNode.ChildNodes) - { - string strName = xmlChild.Name; - - if(strName == ElemUuid) pgStorage.Uuid = ReadUuid(xmlChild); - else if(strName == ElemName) pgStorage.Name = ReadString(xmlChild); - else if(strName == ElemNotes) pgStorage.Notes = ReadString(xmlChild); - else if(strName == ElemIcon) pgStorage.IconID = (PwIcon)ReadUInt(xmlChild, (uint)PwIcon.Key); - else if(strName == ElemCustomIconID) pgStorage.CustomIconUuid = ReadUuid(xmlChild); - else if(strName == ElemTimes) ReadTimes(xmlChild, pgStorage); - else if(strName == ElemIsExpanded) - pgStorage.IsExpanded = ReadBool(xmlChild, true); - else if(strName == ElemGroupDefaultAutoTypeSeq) - pgStorage.DefaultAutoTypeSequence = ReadString(xmlChild); - else if(strName == ElemEnableAutoType) - pgStorage.EnableAutoType = StrUtil.StringToBoolEx(ReadString(xmlChild)); - else if(strName == ElemEnableSearching) - pgStorage.EnableSearching = StrUtil.StringToBoolEx(ReadString(xmlChild)); - else if(strName == ElemLastTopVisibleEntry) - pgStorage.LastTopVisibleEntry = ReadUuid(xmlChild); - else if(strName == ElemGroup) - { - PwGroup pgSub = ReadGroup(xmlChild); - pgSub.ParentGroup = pgStorage; - pgStorage.Groups.Add(pgSub); - } - else if(strName == ElemEntry) - { - PwEntry pe = ReadEntry(xmlChild); - pgStorage.AddEntry(pe, true); - } - else ReadUnknown(xmlChild); - } - - // Create new UUID if absent - if(PwUuid.Zero.EqualsValue(pgStorage.Uuid)) - pgStorage.Uuid = new PwUuid(true); // No assert (import) - - return pgStorage; - } - */ - - private PwEntry ReadEntry(XmlNode xmlNode) - { - ProcessNode(xmlNode); - - PwEntry pe = new PwEntry(false, false); - - Debug.Assert(Color.Empty.ToArgb() == 0); - - foreach(XmlNode xmlChild in xmlNode.ChildNodes) - { - string strName = xmlChild.Name; - - if(strName == ElemUuid) pe.Uuid = ReadUuid(xmlChild); - else if(strName == ElemIcon) - pe.IconId = (PwIcon)ReadUInt(xmlChild, (uint)PwIcon.Key); - else if(strName == ElemCustomIconID) - pe.CustomIconUuid = ReadUuid(xmlChild); - else if(strName == ElemFgColor) - { - string strColor = ReadString(xmlChild); - if((strColor != null) && (strColor.Length > 0)) - pe.ForegroundColor = ColorTranslator.FromHtml(strColor); - } - else if(strName == ElemBgColor) - { - string strColor = ReadString(xmlChild); - if((strColor != null) && (strColor.Length > 0)) - pe.BackgroundColor = ColorTranslator.FromHtml(strColor); - } - else if(strName == ElemOverrideUrl) - pe.OverrideUrl = ReadString(xmlChild); - else if(strName == ElemTags) - pe.Tags = StrUtil.StringToTags(ReadString(xmlChild)); - else if(strName == ElemTimes) ReadTimes(xmlChild, pe); - else if(strName == ElemString) ReadProtectedStringEx(xmlChild, pe.Strings); - else if(strName == ElemBinary) ReadProtectedBinaryEx(xmlChild, pe.Binaries); - else if(strName == ElemAutoType) ReadAutoType(xmlChild, pe.AutoType); - else if(strName == ElemHistory) ReadHistory(xmlChild, pe.History); - else ReadUnknown(xmlChild); - } - - // Create new UUID if absent - if(PwUuid.Zero.EqualsValue(pe.Uuid)) - pe.Uuid = new PwUuid(true); // No assert (import) - - return pe; - } - - private void ReadTimes(XmlNode xmlNode, ITimeLogger times) - { - ProcessNode(xmlNode); - - foreach(XmlNode xmlChild in xmlNode) - { - string strName = xmlChild.Name; - - if(strName == ElemLastModTime) - times.LastModificationTime = ReadTime(xmlChild); - else if(strName == ElemCreationTime) - times.CreationTime = ReadTime(xmlChild); - else if(strName == ElemLastAccessTime) - times.LastAccessTime = ReadTime(xmlChild); - else if(strName == ElemExpiryTime) - times.ExpiryTime = ReadTime(xmlChild); - else if(strName == ElemExpires) - times.Expires = ReadBool(xmlChild, false); - else if(strName == ElemUsageCount) - times.UsageCount = ReadULong(xmlChild, 0); - else if(strName == ElemLocationChanged) - times.LocationChanged = ReadTime(xmlChild); - else - ReadUnknown(xmlChild); - } - } - - private string ReadString(XmlNode xmlNode) - { - ProcessNode(xmlNode); - - return xmlNode.InnerText; - } - - private bool ReadBool(XmlNode xmlNode, bool bDefault) - { - ProcessNode(xmlNode); - - string str = xmlNode.InnerText; - if(str == ValTrue) return true; - else if(str == ValFalse) return false; - - Debug.Assert(false); - return bDefault; - } - - private PwUuid ReadUuid(XmlNode xmlNode) - { - ProcessNode(xmlNode); - - if(string.IsNullOrEmpty(xmlNode.InnerText)) return PwUuid.Zero; - return new PwUuid(Convert.FromBase64String(xmlNode.InnerText)); - } - - private uint ReadUInt(XmlNode xmlNode, uint uDefault) - { - ProcessNode(xmlNode); - - uint u; - if(StrUtil.TryParseUInt(xmlNode.InnerText, out u)) return u; - - Debug.Assert(false); - return uDefault; - } - - /* private long ReadLong(XmlNode xmlNode, long nDefault) - { - ProcessNode(xmlNode); - - long n; - if(StrUtil.TryParseLong(xmlNode.InnerText, out n)) return n; - - Debug.Assert(false); - return nDefault; - } */ - - private ulong ReadULong(XmlNode xmlNode, ulong uDefault) - { - ProcessNode(xmlNode); - - ulong u; - if(StrUtil.TryParseULong(xmlNode.InnerText, out u)) return u; - - Debug.Assert(false); - return uDefault; - } - - private DateTime ReadTime(XmlNode xmlNode) - { - ProcessNode(xmlNode); - - DateTime dt; - if(TimeUtil.TryDeserializeUtc(xmlNode.InnerText, out dt)) return dt; - - Debug.Assert(false); - return m_dtNow; - } - - private void ReadProtectedStringEx(XmlNode xmlNode, ProtectedStringDictionary dictStorage) - { - ProcessNode(xmlNode); - - string strKey = string.Empty; - XorredBuffer xbValue = null; - string strValue = null; - - foreach(XmlNode xmlChild in xmlNode.ChildNodes) - { - if(xmlChild.Name == ElemKey) - { - ProcessNode(xmlChild); - strKey = xmlChild.InnerText; - } - else if(xmlChild.Name == ElemValue) - { - xbValue = ProcessNode(xmlChild); - - // If contents aren't protected: read as plain-text string - if(xbValue == null) strValue = xmlChild.InnerText; - } - else ReadUnknown(xmlChild); - } - - if(xbValue != null) - { - Debug.Assert(strValue == null); - dictStorage.Set(strKey, new ProtectedString(true, xbValue)); - } - else - { - Debug.Assert(strValue != null); - dictStorage.Set(strKey, new ProtectedString(false, strValue)); - } - -#if DEBUG - if(m_format == Kdb4Format.Default) - { - if(strKey == PwDefs.TitleField) - { - Debug.Assert(m_pwDatabase.MemoryProtection.ProtectTitle == - dictStorage.Get(strKey).IsProtected); - } - else if(strKey == PwDefs.UserNameField) - { - Debug.Assert(m_pwDatabase.MemoryProtection.ProtectUserName == - dictStorage.Get(strKey).IsProtected); - } - else if(strKey == PwDefs.PasswordField) - { - Debug.Assert(m_pwDatabase.MemoryProtection.ProtectPassword == - dictStorage.Get(strKey).IsProtected); - } - else if(strKey == PwDefs.UrlField) - { - Debug.Assert(m_pwDatabase.MemoryProtection.ProtectUrl == - dictStorage.Get(strKey).IsProtected); - } - else if(strKey == PwDefs.NotesField) - { - Debug.Assert(m_pwDatabase.MemoryProtection.ProtectNotes == - dictStorage.Get(strKey).IsProtected); - } - } -#endif - } - - private void ReadProtectedBinaryEx(XmlNode xmlNode, ProtectedBinaryDictionary dictStorage) - { - ProcessNode(xmlNode); - - string strKey = string.Empty; - XorredBuffer xbValue = null; - byte[] pbValue = null; - - foreach(XmlNode xmlChild in xmlNode.ChildNodes) - { - if(xmlChild.Name == ElemKey) - { - ProcessNode(xmlChild); - strKey = xmlChild.InnerText; - } - else if(xmlChild.Name == ElemValue) - { - xbValue = ProcessNode(xmlChild); - - if(xbValue == null) - { - string strInner = xmlChild.InnerText; - - if(strInner.Length > 0) - pbValue = Convert.FromBase64String(strInner); - else pbValue = new byte[0]; - } - } - else ReadUnknown(xmlChild); - } - - if(xbValue != null) - { - Debug.Assert(pbValue == null); - dictStorage.Set(strKey, new ProtectedBinary(true, xbValue)); - } - else - { - Debug.Assert(pbValue != null); - dictStorage.Set(strKey, new ProtectedBinary(false, pbValue)); - } - } - - private void ReadAutoType(XmlNode xmlNode, AutoTypeConfig atConfig) - { - ProcessNode(xmlNode); - - foreach(XmlNode xmlChild in xmlNode.ChildNodes) - { - if(xmlChild.Name == ElemAutoTypeEnabled) - atConfig.Enabled = ReadBool(xmlChild, true); - else if(xmlChild.Name == ElemAutoTypeObfuscation) - atConfig.ObfuscationOptions = - (AutoTypeObfuscationOptions)ReadUInt(xmlChild, 0); - else if(xmlChild.Name == ElemAutoTypeDefaultSeq) - atConfig.DefaultSequence = ReadString(xmlChild); - else if(xmlChild.Name == ElemAutoTypeItem) - ReadAutoTypeItem(xmlChild, atConfig); - else ReadUnknown(xmlChild); - } - } - - private void ReadAutoTypeItem(XmlNode xmlNode, AutoTypeConfig atStorage) - { - ProcessNode(xmlNode); - - string strWindow = string.Empty, strKeySeq = string.Empty; - - foreach(XmlNode xmlChild in xmlNode.ChildNodes) - { - if(xmlChild.Name == ElemWindow) - strWindow = ReadString(xmlChild); - else if(xmlChild.Name == ElemKeystrokeSequence) - strKeySeq = ReadString(xmlChild); - else ReadUnknown(xmlChild); - } - - atStorage.Set(strWindow, strKeySeq); - } - - /* - private void ReadDeletedObjects(XmlNode xmlNode, PwObjectList list) - { - ProcessNode(xmlNode); - - foreach(XmlNode xmlChild in xmlNode.ChildNodes) - { - if(xmlChild.Name == ElemDeletedObject) - list.Add(ReadDeletedObject(xmlChild)); - else ReadUnknown(xmlChild); - } - } - - private PwDeletedObject ReadDeletedObject(XmlNode xmlNode) - { - ProcessNode(xmlNode); - - PwDeletedObject pdo = new PwDeletedObject(); - foreach(XmlNode xmlChild in xmlNode.ChildNodes) - { - if(xmlChild.Name == ElemUuid) - pdo.Uuid = ReadUuid(xmlChild); - else if(xmlChild.Name == ElemDeletionTime) - pdo.DeletionTime = ReadTime(xmlChild); - else ReadUnknown(xmlChild); - } - - return pdo; - } - */ - - private void ReadHistory(XmlNode xmlNode, PwObjectList plStorage) - { - ProcessNode(xmlNode); - - foreach(XmlNode xmlChild in xmlNode.ChildNodes) - { - if(xmlChild.Name == ElemEntry) - { - plStorage.Add(ReadEntry(xmlChild)); - } - else ReadUnknown(xmlChild); - } - } - - /* - private void ReadStringDictEx(XmlNode xmlNode, StringDictionaryEx sdStorage) - { - ProcessNode(xmlNode); - - foreach(XmlNode xmlChild in xmlNode.ChildNodes) - { - if(xmlChild.Name == ElemStringDictExItem) - ReadStringDictExItem(xmlChild, sdStorage); - else ReadUnknown(xmlChild); - } - } - - private void ReadStringDictExItem(XmlNode xmlNode, StringDictionaryEx sdStorage) - { - ProcessNode(xmlNode); - - string strName = null, strValue = null; - - foreach(XmlNode xmlChild in xmlNode.ChildNodes) - { - if(xmlChild.Name == ElemKey) - strName = ReadString(xmlChild); - else if(xmlChild.Name == ElemValue) - strValue = ReadString(xmlChild); - else ReadUnknown(xmlChild); - } - - if((strName != null) && (strValue != null)) - m_pwDatabase.CustomData.Set(strName, strValue); - else { Debug.Assert(false); } - } - */ - } -} diff --git a/Ext/DeprecatedSources/KeePassCsv1x_120221.cs b/Ext/DeprecatedSources/KeePassCsv1x_120221.cs deleted file mode 100644 index 1cbde91..0000000 --- a/Ext/DeprecatedSources/KeePassCsv1x_120221.cs +++ /dev/null @@ -1,187 +0,0 @@ -/* - KeePass Password Safe - The Open-Source Password Manager - Copyright (C) 2003-2012 Dominik Reichl - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -using System; -using System.Collections.Generic; -using System.Text; -using System.Diagnostics; -using System.Drawing; -using System.IO; - -using KeePassLib; -using KeePassLib.Delegates; -using KeePassLib.Interfaces; -using KeePassLib.Security; -using KeePassLib.Utility; - -namespace KeePass.DataExchange.Formats -{ - internal sealed class KeePassCsv1x : FileFormatProvider - { - public override bool SupportsImport { get { return true; } } - public override bool SupportsExport { get { return true; } } - - public override string FormatName { get { return "KeePass CSV (1.x)"; } } - public override string DefaultExtension { get { return "csv"; } } - public override string ApplicationGroup { get { return PwDefs.ShortProductName; } } - - public override bool ImportAppendsToRootGroupOnly { get { return true; } } - - public override Image SmallIcon - { - get { return KeePass.Properties.Resources.B16x16_KeePass; } - } - - public override void Import(PwDatabase pwStorage, Stream sInput, - IStatusLogger slLogger) - { - StreamReader sr = new StreamReader(sInput, Encoding.UTF8); - string strFileContents = sr.ReadToEnd(); - sr.Close(); - - CharStream csSource = new CharStream(strFileContents); - - while(true) - { - if(ReadEntry(pwStorage, csSource) == false) - break; - } - } - - private static bool ReadEntry(PwDatabase pwStorage, CharStream csSource) - { - PwEntry pe = new PwEntry(true, true); - - string strTitle = ReadCsvField(csSource); - if(strTitle == null) return false; // No entry available - - string strUser = ReadCsvField(csSource); - if(strUser == null) throw new InvalidDataException(); - - string strPassword = ReadCsvField(csSource); - if(strPassword == null) throw new InvalidDataException(); - - string strUrl = ReadCsvField(csSource); - if(strUrl == null) throw new InvalidDataException(); - - string strNotes = ReadCsvField(csSource); - if(strNotes == null) throw new InvalidDataException(); - - if((strTitle == "Account") && (strUser == "Login Name") && - (strPassword == "Password") && (strUrl == "Web Site") && - (strNotes == "Comments")) - { - return true; // Ignore header entry - } - - pe.Strings.Set(PwDefs.TitleField, new ProtectedString( - pwStorage.MemoryProtection.ProtectTitle, strTitle)); - pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( - pwStorage.MemoryProtection.ProtectUserName, strUser)); - pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( - pwStorage.MemoryProtection.ProtectPassword, strPassword)); - pe.Strings.Set(PwDefs.UrlField, new ProtectedString( - pwStorage.MemoryProtection.ProtectUrl, strUrl)); - pe.Strings.Set(PwDefs.NotesField, new ProtectedString( - pwStorage.MemoryProtection.ProtectNotes, strNotes)); - - pwStorage.RootGroup.AddEntry(pe, true); - return true; - } - - private static string ReadCsvField(CharStream csSource) - { - StringBuilder sb = new StringBuilder(); - bool bInField = false; - - while(true) - { - char ch = csSource.ReadChar(); - if(ch == char.MinValue) - return null; - - if((ch == '\"') && !bInField) - bInField = true; - else if((ch == '\"') && bInField) - break; - else if(ch == '\\') - { - char chSub = csSource.ReadChar(); - if(chSub == char.MinValue) - throw new InvalidDataException(); - - sb.Append(chSub); - } - else if(bInField) - sb.Append(ch); - } - - return sb.ToString(); - } - - public override bool Export(PwExportInfo pwExportInfo, Stream sOutput, - IStatusLogger slLogger) - { - PwGroup pg = (pwExportInfo.DataGroup ?? ((pwExportInfo.ContextDatabase != - null) ? pwExportInfo.ContextDatabase.RootGroup : null)); - - StreamWriter sw = new StreamWriter(sOutput, new UTF8Encoding(false)); - sw.Write("\"Account\",\"Login Name\",\"Password\",\"Web Site\",\"Comments\"\r\n"); - - EntryHandler eh = delegate(PwEntry pe) - { - WriteCsvEntry(sw, pe); - return true; - }; - - if(pg != null) pg.TraverseTree(TraversalMethod.PreOrder, null, eh); - - sw.Close(); - return true; - } - - private static void WriteCsvEntry(StreamWriter sw, PwEntry pe) - { - if(sw == null) { Debug.Assert(false); return; } - if(pe == null) { Debug.Assert(false); return; } - - const string strSep = "\",\""; - - sw.Write("\""); - WriteCsvString(sw, pe.Strings.ReadSafe(PwDefs.TitleField), strSep); - WriteCsvString(sw, pe.Strings.ReadSafe(PwDefs.UserNameField), strSep); - WriteCsvString(sw, pe.Strings.ReadSafe(PwDefs.PasswordField), strSep); - WriteCsvString(sw, pe.Strings.ReadSafe(PwDefs.UrlField), strSep); - WriteCsvString(sw, pe.Strings.ReadSafe(PwDefs.NotesField), "\"\r\n"); - } - - private static void WriteCsvString(StreamWriter sw, string strText, - string strAppend) - { - string str = strText; - - str = str.Replace("\\", "\\\\"); - str = str.Replace("\"", "\\\""); - - sw.Write(str); - - if((strAppend != null) && (strAppend.Length > 0)) sw.Write(strAppend); - } - } -} diff --git a/Ext/DeprecatedSources/MainForm_110830.txt b/Ext/DeprecatedSources/MainForm_110830.txt deleted file mode 100644 index 7221fdf..0000000 --- a/Ext/DeprecatedSources/MainForm_110830.txt +++ /dev/null @@ -1,66 +0,0 @@ - /* public void RefreshEntriesList() - { - int nItemCount = m_lvEntries.Items.Count; - if(nItemCount <= 0) return; - - PwEntry peTop = GetTopEntry(); - PwEntry peFocused = GetSelectedEntry(false); - int iScrollY = NativeMethods.GetScrollPosY(m_lvEntries.Handle); - - UpdateImageLists(); // Important - - PwEntry[] vSelected = GetSelectedEntries(); - if(vSelected == null) vSelected = new PwEntry[0]; - - PwEntry[] vList = new PwEntry[nItemCount]; - for(int iEnum = 0; iEnum < nItemCount; ++iEnum) - vList[iEnum] = (PwEntry)m_lvEntries.Items[iEnum].Tag; - - m_lvEntries.BeginUpdate(); - m_lvEntries.Items.Clear(); - m_lvEntries.Groups.Clear(); - m_lvgLastEntryGroup = null; - - int nTopIndex = -1; - ListViewItem lviFocused = null; - - m_dtCachedNow = DateTime.Now; - ListViewStateEx lvseCachedState = new ListViewStateEx(m_lvEntries); - - for(int iAdd = 0; iAdd < nItemCount; ++iAdd) - { - PwEntry pe = vList[iAdd]; - - ListViewItem lvi = SetListEntry(pe, null); - - if(pe == peTop) nTopIndex = iAdd; - if(pe == peFocused) lviFocused = lvi; - - if(Array.IndexOf(vSelected, pe) >= 0) lvi.Selected = true; - } - - Debug.Assert(lvseCachedState.CompareTo(m_lvEntries)); - - UIUtil.SetAlternatingBgColors(m_lvEntries, m_clrAlternateItemBgColor, - Program.Config.MainWindow.EntryListAlternatingBgColors); - - Debug.Assert(m_bEntryGrouping == m_lvEntries.ShowGroups); - if(m_lvEntries.ShowGroups) - { - // Test nTopIndex to ensure we're not scrolling an unrelated list - if((nTopIndex >= 0) && (iScrollY > 0)) - NativeMethods.Scroll(m_lvEntries, 0, iScrollY); - } - else - { - if(nTopIndex >= 0) - { - m_lvEntries.EnsureVisible(m_lvEntries.Items.Count - 1); - m_lvEntries.EnsureVisible(nTopIndex); - } - } - - if(lviFocused != null) m_lvEntries.FocusedItem = lviFocused; - - m_lvEntries.EndUpdate(); - } */ diff --git a/Ext/DeprecatedSources/PasswordListPrintDocument_110101.cs b/Ext/DeprecatedSources/PasswordListPrintDocument_110101.cs deleted file mode 100644 index fe1b7c4..0000000 --- a/Ext/DeprecatedSources/PasswordListPrintDocument_110101.cs +++ /dev/null @@ -1,165 +0,0 @@ -/* - KeePass Password Safe - The Open-Source Password Manager - Copyright (C) 2003-2011 Dominik Reichl - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -/* -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; -using System.Drawing.Printing; -using System.Windows.Forms; -using System.Diagnostics; - -using KeePassLib; -using KeePassLib.Delegates; -using KeePassLib.Security; - -namespace KeePass.UI -{ - internal sealed class PasswordListLine - { - public PwIcon IconID = PwIcon.None; - public PwUuid CustomIcon = null; - public List TextFields = new List(); - } - - public sealed class PasswordListPrintDocument : PrintDocument - { - private PwGroup m_pgDataSource = null; - - private Font m_fontNormal = null; - private Font m_fontPassword = null; - - private List m_vLines = new List(); - private int m_nCurrentLine = 0; - - public PasswordListPrintDocument(PwGroup pgDataSource) - { - Debug.Assert(pgDataSource != null); - if(pgDataSource == null) throw new ArgumentNullException("pgDataSource"); - - m_pgDataSource = pgDataSource; - } - - private void DisposePrinterFont(ref Font f) - { - if(f != null) - { - f.Dispose(); - f = null; - } - } - - protected override void OnBeginPrint(PrintEventArgs e) - { - base.OnBeginPrint(e); - - RenderDocument(e); - - m_fontNormal = new Font(FontFamily.GenericSansSerif, 10.0f); - m_fontPassword = new Font(FontFamily.GenericMonospace, 10.0f); - } - - protected override void OnEndPrint(PrintEventArgs e) - { - base.OnEndPrint(e); - - DisposePrinterFont(ref m_fontNormal); - DisposePrinterFont(ref m_fontPassword); - } - - protected override void OnPrintPage(PrintPageEventArgs e) - { - base.OnPrintPage(e); - - Graphics g = e.Graphics; - - float fLeft = e.MarginBounds.Left; - float fRight = e.MarginBounds.Right; - float fTop = e.MarginBounds.Top; - float fBottom = e.MarginBounds.Bottom; - float fWidth = fRight - fLeft; - - string strTestText = @"WJygpqQIL|°"; - float fNormalHeight = TextRenderer.MeasureText(g, strTestText, - m_fontNormal).Height; - float fPasswordHeight = TextRenderer.MeasureText(g, strTestText, - m_fontPassword).Height; - - float fLineHeight = Math.Max(fNormalHeight, fPasswordHeight); - - float fCurrentY = fTop; - - while(true) - { - if((fCurrentY + fLineHeight) >= fBottom) - break; - - PasswordListLine pll = m_vLines[m_nCurrentLine]; - int nTextCount = pll.TextFields.Count; - - for(int iField = 0; iField < nTextCount; ++iField) - { - PointF ptText = new PointF((fWidth * iField) / nTextCount, - fCurrentY); - - g.DrawString(pll.TextFields[iField], m_fontNormal, - Brushes.Black, ptText); - } - - fCurrentY += fLineHeight; - - ++m_nCurrentLine; - if(m_nCurrentLine == m_vLines.Count) break; - } - - e.HasMorePages = (m_nCurrentLine != m_vLines.Count); - } - - private void RenderDocument(PrintEventArgs e) - { - m_vLines.Clear(); - m_nCurrentLine = 0; - - GroupHandler gh = delegate(PwGroup pg) - { - return true; - }; - - EntryHandler eh = delegate(PwEntry pe) - { - PasswordListLine pll = new PasswordListLine(); - - pll.IconID = pe.IconID; - pll.CustomIcon = pe.CustomIconUuid; - pll.TextFields.Add(pe.Strings.ReadSafe(PwDefs.TitleField)); - pll.TextFields.Add(pe.Strings.ReadSafe(PwDefs.UserNameField)); - pll.TextFields.Add(pe.Strings.ReadSafe(PwDefs.PasswordField)); - pll.TextFields.Add(pe.Strings.ReadSafe(PwDefs.UrlField)); - pll.TextFields.Add(pe.Strings.ReadSafe(PwDefs.NotesField)); - - m_vLines.Add(pll); - return true; - }; - - m_pgDataSource.TraverseTree(TraversalMethod.PreOrder, gh, eh); - } - } -} -*/ diff --git a/Ext/DeprecatedSources/PopularPasswords_100725.cs b/Ext/DeprecatedSources/PopularPasswords_100725.cs deleted file mode 100644 index ed8cf57..0000000 --- a/Ext/DeprecatedSources/PopularPasswords_100725.cs +++ /dev/null @@ -1,369 +0,0 @@ -/* - KeePass Password Safe - The Open-Source Password Manager - Copyright (C) 2003-2010 Dominik Reichl - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -using System; -using System.Collections.Generic; -using System.Text; -using System.IO; -using System.Security.Cryptography; -using System.Globalization; -using System.Diagnostics; - -using KeePassLib.Utility; - -namespace KeePassLib.Cryptography -{ - /// - /// Bloom filter-based popular password checking. - /// - public static class PopularPasswords - { - private const int PpcTableSize = 4096 * 8; // Bits, multiple of 64 - - // Bits set: 15719 of 32768 - // Hash functions: 16 - // Phi (bits unset ratio) estimation: 0.520486428116307 - // Exact Phi: 0.520294189453125 - // False positives ratio: 7.86320618801785E-06 - private static readonly ulong[] PpcTable = { - 0xE4489A3404344788UL, 0x86B25DB476F58AB7UL, 0xB581FAA53EA2342AUL, - 0x70B2C54E1E6762D0UL, 0x1AEEB1A9DF75C01BUL, 0xEE2B0C368A1FE6DAUL, - 0x02DC8D0E5CD9FC17UL, 0x6A449E23057C6560UL, 0x889E159F16E9681DUL, - 0x2686144C0927486FUL, 0x6C4AF58039D4E4D0UL, 0xC5AB193CD0077707UL, - 0x32399D528F7E1F07UL, 0xD6396059B4C04626UL, 0x0E0AF217323143B5UL, - 0x5BD81DA44A6EC64BUL, 0xC2B7AF8E93C4D482UL, 0x92E221F8F7D6F708UL, - 0x91E9933F20E90825UL, 0x5D0AD3B4F81061E3UL, 0x06101FFA010464E7UL, - 0xB10F259524E1BEAAUL, 0x81191B0D13812121UL, 0x2CBEF0BAE5896DA0UL, - 0x4187F900F4B164F8UL, 0x6362BB64B8507748UL, 0x3A622549FE71D89DUL, - 0x052819709952C6CFUL, 0x58EBFBDEACA4D82EUL, 0x2AA0001D0A33CCA0UL, - 0x19EF6C2C114DDC21UL, 0x937F5B504AE709F0UL, 0xD0CD4487EA84F479UL, - 0x169CA49DB21A1338UL, 0x307EF1001D232212UL, 0xB1A42ECB6F61051EUL, - 0x98E28AD44EA4D8F0UL, 0x65820520E5FC0830UL, 0xC231BE1D6054AAD5UL, - 0x3E61CEADDA6AD3A9UL, 0xCE1AA54066469E83UL, 0x3DE3666FB5653C57UL, - 0x39D894D5C6310CA5UL, 0x39CB8A2D5A49CB02UL, 0xDEC88143040007E7UL, - 0x371BFD3E22C20F6DUL, 0x93E1697B64CD8C89UL, 0x67CB5B14CC3ED9EDUL, - 0x6D10DA90332239D6UL, 0x6673DD254CD82162UL, 0x24089D15A893BB0FUL, - 0xEA4D11D96C16A203UL, 0xF70176A0E28539A8UL, 0x0DE6B18BA8966C86UL, - 0x856FC8659A6E9D7FUL, 0x7B726A5A2A6DE203UL, 0x0CFBC2911CB2CE63UL, - 0x6363D417490A0256UL, 0x541A26883DF51A45UL, 0xB37BE5AF83DA3AD1UL, - 0xE7B834E9000CA060UL, 0x841B2F8473222666UL, 0xE16CCFE7029B7E5EUL, - 0x3C08D6AABC226AC9UL, 0x0887968C7690498FUL, 0x3B12659FAC807598UL, - 0xD886F0364EC34407UL, 0x1B31A94B51E024F5UL, 0xC492A4F451800A11UL, - 0x6D89165B69494B89UL, 0x5B183AFD7A22D9B5UL, 0xCDFF381022100872UL, - 0xD29D38A72690562BUL, 0xEFBEE452E0B08682UL, 0x79D755AD7BC57506UL, - 0x38C5372ED560B720UL, 0xB42B16AA623D0378UL, 0x5166ECA60CC145F7UL, - 0x415C4A83F53FA99EUL, 0x3CA25AC6937A92F2UL, 0xDDEE63E44F2B5C9CUL, - 0x580EE47F5FC58ABAUL, 0x7AA9763C6E7BBBD5UL, 0x80420F1F81FBF086UL, - 0xC882A993C8A6AAA0UL, 0x2AE686154F8B3C1AUL, 0x30FE1DA4CA7C74EDUL, - 0x6062AD6F3A825452UL, 0xC53E126449486920UL, 0x9C02CADB149D340CUL, - 0x640F66F165EB961DUL, 0xAC20B871E28D20D6UL, 0x208E878696510DE9UL, - 0x0E9526E74040EE6CUL, 0x39AF5257605AF29EUL, 0x9E0B4A4F372E14ACUL, - 0x74143CD2D734F14DUL, 0x426496359E685811UL, 0x7B63BF2DB9B343C6UL, - 0xB3B40017B49BC96BUL, 0x4BE5B132E6AD8F35UL, 0x0CBDF68541C060F2UL, - 0x5D822A6CF8548376UL, 0xADC77581F25106E4UL, 0x4E91EC63FE2E5847UL, - 0x95167F55FC249D81UL, 0xD4D8F7E04A9F1845UL, 0xD4B55F3F350F10DEUL, - 0x310E105A026E91F8UL, 0xA1DF7398366C1398UL, 0x19D187ADC6C2C26DUL, - 0x1A20235761A2ED08UL, 0xA0B65B813345E3FCUL, 0x208EDBEA6828239FUL, - 0x6745B0810E0DC190UL, 0xDB09F52112896186UL, 0xAAFD7E27B0760AC0UL, - 0x7081DDCC1AEF30F3UL, 0x12744B39E6A8A1E8UL, 0x59A0166D773C5BE4UL, - 0x25426A44E348A784UL, 0x2F117FAF2464B3EFUL, 0x07DE883BA546C9F0UL, - 0x81260E8469A42391UL, 0x7528100996040644UL, 0xB20E1E42F1601FAEUL, - 0x68C9A1A96C5D7002UL, 0x3AE9934E86D51BADUL, 0xCF095403DAC63ED5UL, - 0xAB6F755ECB8064C8UL, 0x8480C7D61D55829FUL, 0x1E7A383A70CBFA6FUL, - 0x2ED63359316544BAUL, 0x4ACCC761760FC489UL, 0x9B668054F469AE2DUL, - 0xCA231AB3FE49327BUL, 0x9164054162F1567BUL, 0x0E276E3BC1FA10AEUL, - 0xB47E34300405D7EFUL, 0xA50FD0B6BF67C75FUL, 0x62BCA28A13A5C2B9UL, - 0x9884F6008C2AE25BUL, 0x80F0D9722D30215CUL, 0xF702F1093AA6AD69UL, - 0x11ECD08A62B902ACUL, 0x32EADD0519A8F117UL, 0x784E07D4E2026220UL, - 0x3803CAC2CDDC9FCDUL, 0x9F55A4559CF9FBCAUL, 0xB64A7C5991550497UL, - 0x632DEF7CE48765A1UL, 0xB7EEC58454987009UL, 0xB798651B5C588074UL, - 0xCF177657608C684FUL, 0x09B886763311529FUL, 0x13279B25F38E9078UL, - 0x4494804869BB8200UL, 0xF3316EF9A5693494UL, 0x6E0DA3E544E21ED9UL, - 0x087F84F0538BD741UL, 0xBC877CCA688983C5UL, 0xF733E7057A2661B4UL, - 0xB503AD77C9E83B23UL, 0x8FB6B2560FCAE443UL, 0xC10E770A2389C1F4UL, - 0x4BBEE81101789902UL, 0xCF28D640F2C4EE03UL, 0xB5FA56647A0D246EUL, - 0xE0E13635CC3A003CUL, 0xAF321B876375B0E0UL, 0x5CC1F60F2CEC1947UL, - 0x6D79F85C6C3E2178UL, 0x8C5105F188F59F48UL, 0xF026E4771132D495UL, - 0x68806C37457C8A11UL, 0xAC4FCFE08FF935E9UL, 0x02C9ED0DE36DEAD0UL, - 0x736E789114C176C0UL, 0x018484BB3F90C627UL, 0xADE11EBC06679C81UL, - 0xDC12310CF4646120UL, 0x565939720A871E91UL, 0x5129FA305D5F80D8UL, - 0x2F1978C44B222F66UL, 0xB2019E9C3C9223A3UL, 0xC26E8310561ABA8BUL, - 0x4C3268947F138A08UL, 0x1B10F12838C2F672UL, 0x3DD765F24A8EAD63UL, - 0xAC255685D091756CUL, 0x1EE8F33DAB66696EUL, 0xDCC69A9317A640E4UL, - 0xB3E10F8B1451577BUL, 0x9C989C1D83694926UL, 0x76C223945AE55AC5UL, - 0x3A5B5A5BA089C4F4UL, 0x5FF9863504F6D63AUL, 0x2BA33660EBC2D7B2UL, - 0xA90E90345E800C21UL, 0xE5C1C600199418DFUL, 0xB05541ED4A60E891UL, - 0xA79B38C035129539UL, 0x101AE63623F00D19UL, 0x86AEF221B04AE1E6UL, - 0x2D5FB8BDF5DD4537UL, 0xCF57F9D3F420CD52UL, 0x41FAB56E1CBEDE7DUL, - 0x4E31A70953DE2053UL, 0xB697E044F555FB02UL, 0x9E32B905F6B54765UL, - 0x0EE565A5E3C49262UL, 0x0E2BEB43000C0363UL, 0xBABF2096A749073FUL, - 0xDE0C27F78E1B89D9UL, 0x14878D174A34D220UL, 0x49189778D3782CF7UL, - 0xC4E37E8E0AFBE8FFUL, 0x0553DB16D17599F3UL, 0xE5324CCC7E3DFAF6UL, - 0x1002D714B914D3E3UL, 0x2C8C0DF862CF9D90UL, 0x552817B44DFF5733UL, - 0xD343B93EE79DA789UL, 0x5B70BB23756C998AUL, 0xB4E79BF903F1B28EUL, - 0xFEC69776A1728BC1UL, 0x3B3481B27815701CUL, 0x8028717CB8AB7835UL, - 0x15C681958C8DAE00UL, 0x44D5CEAEF0A1563CUL, 0x6BB90C05209F1A8EUL, - 0x1323A9FA431DC10DUL, 0x50C7BFFE3DB35371UL, 0x613D8488D33B6D4FUL, - 0x6C300351CF14A712UL, 0xD451A406E06F92D2UL, 0x9D48DC26ABA018B3UL, - 0x1F4573A97CA5FDBAUL, 0x6E65AE090F50F2FBUL, 0x1EBA1E084584BFB3UL, - 0x58BC501FBF7AC020UL, 0x0CF6120722B5D600UL, 0x4ABC91E6DC5000EEUL, - 0x9CBD9C3911614606UL, 0x0BDC8E1A1650977FUL, 0x90383FB6559BCB49UL, - 0x42B98DA163D4411DUL, 0x1C4582B0DBE9F911UL, 0x372C888720E79B05UL, - 0x906560A343786D02UL, 0x9E233DF7175BD4FEUL, 0x4EB66BA91A9C41BFUL, - 0x41FDB3460AC6F231UL, 0x79DB680FA3BA9330UL, 0x5A541224CD43333DUL, - 0x9F3E5B722C0AEEE1UL, 0xA91711FDED89836EUL, 0x80E21258E3E49714UL, - 0x7819026EF352AD7FUL, 0xC293097A18EBEB58UL, 0xCDD60C0948E07C98UL, - 0x444C2170AC4C972AUL, 0xB714CA937966E535UL, 0x6F11F3358AFA71BCUL, - 0xA84E8A3E6892C978UL, 0xE6308B5D0DB90822UL, 0x46E0A95E998B2B86UL, - 0x6A5C6F56AEA55DDBUL, 0x1DB0599111046F3EUL, 0x55D6DB893B553280UL, - 0x62C8F9D71B387563UL, 0x3389047820C4085CUL, 0xA744C6E6B040304BUL, - 0xFD5D213F3F48497DUL, 0xCC5B2117B6532683UL, 0xDC1C19721683F83DUL, - 0x1CB8405C21EB9AADUL, 0x8DB81937DF5C01B6UL, 0x99C6DF745BB3FAEBUL, - 0x450BEAA37F336CEDUL, 0xF0154CEB08FB4623UL, 0xA00293117E29034BUL, - 0xA66DD9AC091740E8UL, 0xB4E7455E47738348UL, 0x9BF6AB384A17588BUL, - 0x355EA7E660615307UL, 0x29973430E7BD32C1UL, 0xFCF99196BA1453FEUL, - 0x561E4A9749A31000UL, 0x996E40ACB907907CUL, 0x8C068A537891D817UL, - 0xDB42112F997B7851UL, 0xFA785497B0DBA777UL, 0x28AEF904C18EE0E3UL, - 0x8A70C563CE4B4567UL, 0x56A968C07D246D99UL, 0xFD327FAD0450EF8DUL, - 0x00C7DA2B6C9F79F5UL, 0xCF6280916EBF0129UL, 0xAC978A54BDD2071DUL, - 0x2D41D3E0C76E3F32UL, 0x63425615DB3281B4UL, 0x481BB08F50D69823UL, - 0x5F80EE74AC0BE2BDUL, 0x0D3AC9CC76A2D632UL, 0xEDB7C0E219D80DFAUL, - 0xCD2FA275D82EB2B6UL, 0x41898B02F28A159DUL, 0x1BD46018489C80B8UL, - 0x3AE0AECD4BB1127DUL, 0xA0FF48E7432058DFUL, 0xD1CC9C721482F42CUL, - 0x7B0FB481B5F19E03UL, 0xA221FDB32FC9174BUL, 0x1FE31F128748AD5CUL, - 0xA9C80E0BB849C784UL, 0x9725ED5C207DEAB2UL, 0x8EEC7C5310933D31UL, - 0xDE590C192A0B27B4UL, 0xE51CE519B6437021UL, 0x6E1057997FB1DEAEUL, - 0xC57DF8FEB45EE6A4UL, 0xDE24D5C87D4555E2UL, 0xF00FC5511FE008C1UL, - 0xC664EFBB36A481EDUL, 0x58688CC427EC4CC7UL, 0x254829013B0E76AEUL, - 0xECD1857ED61869A5UL, 0x64CE789BDE508F7DUL, 0xF295CAAA594ECC58UL, - 0x8F5B58B79C94EBE0UL, 0xA39BF312E6C61A6CUL, 0x0D00969829C5502BUL, - 0xB8C13C1FC5CB718DUL, 0x3224118DA915B5EFUL, 0x10EC24C2121DD4D7UL, - 0x1FB788E5D8E03357UL, 0x5E9F86D0099CE632UL, 0x673ED65F677821B0UL, - 0x312A41E1B51549F9UL, 0x00DF25E45DAD76E2UL, 0x5A1561911C876B19UL, - 0x1A58EF968CC11787UL, 0x029599EB8BD8719AUL, 0xEA27B36FFF5930F7UL, - 0x04060010169D7A62UL, 0x5630B4458FBA3A71UL, 0xB9CB8F84D66A93F8UL, - 0x3428A1C10490B5BAUL, 0x7E5857F34A1482F7UL, 0xCC62980D2ADAC41DUL, - 0x903EC89CC55BD0CEUL, 0xFE9EC99089004024UL, 0xECD3E226F9BE420CUL, - 0x17475B3D71CCA656UL, 0x5CCBD2176CA8DE01UL, 0xB13675D62856894CUL, - 0x744032E639C3F11FUL, 0x0E349612CEAF382AUL, 0x41E516CDA67BB4DCUL, - 0x343CB2990641694AUL, 0xEF1EE7E82B7E65CAUL, 0x32D3BD01D421A7CBUL, - 0xD7FC605717AF512CUL, 0x62D776335ACAA6A6UL, 0xFDA7C7EFBEFFB24DUL, - 0x1DA4421BE204563FUL, 0x7AC5071D7D6439ECUL, 0xB04907D74291F402UL, - 0x1622EAB93909C0BEUL, 0x0104D4A240D85592UL, 0x902DAC0ADEE44311UL, - 0xC1A9DFE403C0DA20UL, 0xF625780DB1B3F871UL, 0x75AB40C313DF9E55UL, - 0xDFAE2CD087187B45UL, 0x417D7807D2171F9FUL, 0xCD1D1A444D86DF78UL, - 0x87DE186A752CDB73UL, 0xEDEBA23523A0DC64UL, 0x10AA6B0C35F6B110UL, - 0x38C31C863D4F4ED5UL, 0x7A4665420070B621UL, 0x4F2B5963CE4F5F6CUL, - 0x1960F7AD866513A3UL, 0x3A7C924A978F8251UL, 0x56B8481940FDF39AUL, - 0x11643EEFEEE1ACA6UL, 0xED127C507EF6C54CUL, 0xB5EBD3BFA89E9F67UL, - 0x21879F26D4BE4A14UL, 0x8D6154A8A2027EA6UL, 0x1C69E882730B93C8UL, - 0x8D7B11D1DD98B5F2UL, 0x76A7FAA7A888B1FBUL, 0x90A971E4C8F7AE28UL, - 0x56A4D02DF123F5EAUL, 0x44A05664A7F03956UL, 0x309C6C63418B2616UL, - 0x108CA042607E272AUL, 0x4AB8F3508ADDA60CUL, 0xA7FBBAF0BB17714BUL, - 0x3CC8A384E2D96A84UL, 0x391E782A19AD5190UL, 0x23065DCE40659703UL, - 0xC530D54413A3791EUL, 0x803E3C294BE1C26EUL, 0x61ABAAC14D74EC54UL, - 0xA4F72A046456894DUL, 0x242893DB0DB83BB0UL, 0xD34E3160ADCB5CAFUL, - 0x70DC7C26C140E652UL, 0xC61E965117931ED2UL, 0x6E292C67D1F4C3A7UL, - 0xCBF4C4668630AD09UL, 0x89E71E5660F60C09UL, 0xB94E78B3D69CF448UL, - 0x34F7E505129E67E8UL, 0x2B5692EB2F9ADB1FUL, 0x18B33EB5C6218B92UL, - 0x69B0107420A2245FUL, 0x882D9A53746BB452UL, 0xD672B7869EA7CFD9UL, - 0x19A7272D0738C53FUL, 0x1322E47C89337EB2UL, 0x812E69C0245E50D7UL, - 0xF187AA4541ABDDD3UL, 0x8FEAA798A615B748UL, 0x667E3C139D8B56C8UL, - 0xAEC9BF9F45CA5D44UL, 0xFBB9142069E57883UL, 0x094C75FB9845661DUL, - 0x23A6C5F02F3A6C55UL, 0x9A16DA92770C6ECCUL, 0xF748C20B24D1DC6FUL, - 0x7ACB623BBD295332UL, 0xEAEF79479E38A94CUL, 0x704D58570E2E5332UL, - 0x036F52F5A9684E7CUL, 0xEC738490914BA27EUL, 0xF9278559E81D901EUL, - 0x49821AAC204B64C2UL, 0x990985242F9C9A31UL, 0x06A3649A1BA11E75UL, - 0xE4A1A9808B319814UL, 0x18A4498A7BBA0060UL, 0x75ED340849D3CCA3UL, - 0x82225D786972A9E0UL, 0x8EADE60B8E678CD5UL, 0xC99BB41C1726AABDUL, - 0x2AB9C9C8FAC6DC30UL, 0x0441780010493500UL, 0xDDDDE54767F517ADUL, - 0x56DB8BCC493B8490UL, 0xD1A6739A09D42053UL, 0x617912F0246C3648UL, - 0x6ADF565B9B17101DUL, 0x0CA0C0BEC98D33BBUL, 0xC920D715A451BC53UL, - 0xA10E436864547E8FUL, 0x8A2686E7564305BAUL, 0xF5454820A996BC1FUL, - 0xC9216226D09DDC39UL, 0x68A0E58CAE5C7DB9UL, 0x7F5252D3EA712008UL, - 0x5BC5B55C5F4A9803UL, 0xAFC544F4F2E4002EUL, 0x6C42C429889A7D5CUL, - 0x2F4F73AA425DEFA6UL, 0x2E6AFD00A266DEF0UL, 0x49CACCAAE1B2C278UL, - 0xB62663F96D79781DUL, 0x87E5E67912BAD6F9UL, 0x93BF4AB146F447CFUL, - 0xC942B3D03448F513UL, 0x50B6C04EC1C35605UL, 0x010B453F9ACBF9DDUL, - 0x84CB000D0AA3E002UL, 0xB0AFA8BD656B2A9AUL, 0x736BC06ADC0DBADFUL, - 0x18C9AE72A4F7F14DUL, 0x8B20226817FED9F7UL, 0x488201718D3F25AAUL, - 0xB436031BF234430AUL, 0x301B579C25A81F6CUL, 0x94AD1143EF48395BUL, - 0xD18DAC91770DE980UL, 0xB8B8E0C504956DE5UL, 0xDDC58A6B8AF36BD0UL, - 0x70288138236C8C2EUL, 0x12566E4A4C2B5769UL, 0x323D3516D4611368UL, - 0xC8A045E9E3E20B1FUL, 0x1B69C6DCD29AAE04UL, 0x24DA7006D030D431UL, - 0x468A8E0A5523AF97UL, 0x075CABD7CAC6346DUL, 0x6AA5CE224365EB50UL, - 0x888443448F8FC9F1UL, 0x4D04602CAD6D5208UL, 0x84FC44D5FE8D928EUL, - 0x703E412307FC7C32UL, 0xAFBAEAA0E3D8BBAAUL, 0x7C32F528AA001332UL, - 0x86BB81913BB879C7UL, 0x99853897C46219ABUL, 0xA213ED45FD500DD2UL, - 0xD591D1A722685833UL, 0x33305B089DCD5298UL, 0x52D2E2138D12701CUL, - 0x99B931133F6A60CDUL, 0x2633C5A928D65828UL - }; - - public static bool IsPopularPassword(char[] vPassword) - { - Debug.Assert(PpcTable.Length == (PpcTableSize / 64)); - - if(vPassword == null) throw new ArgumentNullException("vPassword"); - if(vPassword.Length == 0) return false; - - foreach(char ch in vPassword) - { - if(!IsPopularChar(ch)) return false; - } - - UTF8Encoding utf8 = new UTF8Encoding(false); - byte[] pbUtf8 = utf8.GetBytes(vPassword); - - int[] vIndices = GetTableIndices(pbUtf8, PpcTableSize); - Array.Clear(pbUtf8, 0, pbUtf8.Length); - - foreach(int iIndex in vIndices) - { - if(!GetTableBit(PpcTable, iIndex)) return false; - } - - return true; - } - - private static bool IsPopularChar(char ch) - { - return (((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z')) || - ((ch >= '0') && (ch <= '9')) || (ch == '_') || (ch == '!')); - } - - private static int[] GetTableIndices(byte[] pbPasswordUtf8, int nTableSize) - { - Debug.Assert((nTableSize >= 2) && (nTableSize <= 0x10000)); - Debug.Assert((nTableSize % 64) == 0); - - SHA512Managed sha = new SHA512Managed(); - byte[] pbHash = sha.ComputeHash(pbPasswordUtf8); - - int[] vIndices = new int[pbHash.Length / 4]; // 4 by experiment - for(int i = 0; i < vIndices.Length; ++i) - vIndices[i] = ((((int)pbHash[i * 2] << 8) | - (int)pbHash[i * 2 + 1]) % nTableSize); - - return vIndices; - } - - private static bool GetTableBit(ulong[] vTable, int iBit) - { - return ((vTable[iBit >> 6] & (1UL << (iBit & 0x3F))) != 0UL); - } - -#if (DEBUG && !KeePassLibSD) - private static bool SetTableBit(ulong[] vTable, int iBit) - { - if(GetTableBit(vTable, iBit)) return false; - - vTable[iBit >> 6] = (vTable[iBit >> 6] | (1UL << (iBit & 0x3F))); - return true; - } - - public static void MakeList() - { - string strData = File.ReadAllText("MostPopularPasswords.txt", Encoding.UTF8); - strData += " "; - CharStream cs = new CharStream(strData); - - List vPasswords = new List(); - StringBuilder sbPassword = new StringBuilder(); - while(true) - { - char ch = cs.ReadChar(); - if(ch == char.MinValue) break; - - if(char.IsWhiteSpace(ch)) - { - string strPassword = sbPassword.ToString(); - strPassword = strPassword.ToLower(); - - if(strPassword.Length > 3) - { - if(vPasswords.IndexOf(strPassword) < 0) - vPasswords.Add(strPassword); - } - - sbPassword = new StringBuilder(); - } - else - { - Debug.Assert(!char.IsControl(ch) && !char.IsHighSurrogate(ch) && - !char.IsLowSurrogate(ch) && !char.IsSurrogate(ch)); - Debug.Assert(IsPopularChar(ch)); - sbPassword.Append(ch); - } - } - - ulong[] vTable = new ulong[PpcTableSize / 64]; - Array.Clear(vTable, 0, vTable.Length); - - long lBitsInTable = 0; - UTF8Encoding utf8 = new UTF8Encoding(false); - foreach(string strPassword in vPasswords) - { - byte[] pbUtf8 = utf8.GetBytes(strPassword); - int[] vIndices = GetTableIndices(pbUtf8, PpcTableSize); - - foreach(int i in vIndices) - { - if(SetTableBit(vTable, i)) ++lBitsInTable; - } - } - - StringBuilder sb = new StringBuilder(); - sb.Append("\t\t\t"); - for(int i = 0; i < vTable.Length; ++i) - { - if(i > 0) - { - if((i % 3) == 0) - { - sb.AppendLine(","); - sb.Append("\t\t\t"); - } - else sb.Append(", "); - } - - sb.Append("0x"); - sb.Append(vTable[i].ToString("X16")); - sb.Append("UL"); - } - - sb.AppendLine(); - sb.AppendLine(); - sb.AppendLine("Bits set: " + lBitsInTable.ToString() + " of " + - PpcTableSize.ToString()); - int cHashFn = GetTableIndices(utf8.GetBytes("Dummy"), PpcTableSize).Length; - sb.AppendLine("Hash functions: " + cHashFn.ToString()); - double dblPhi = Math.Pow(1.0 - ((double)cHashFn / PpcTableSize), - (double)vPasswords.Count); - sb.AppendLine("Phi (bits unset ratio) estimation: " + - dblPhi.ToString(CultureInfo.InvariantCulture)); - dblPhi = ((double)(PpcTableSize - lBitsInTable) / (double)PpcTableSize); - sb.AppendLine("Exact Phi: " + dblPhi.ToString(CultureInfo.InvariantCulture)); - sb.AppendLine("False positives ratio: " + Math.Pow(1.0 - dblPhi, - (double)cHashFn).ToString(CultureInfo.InvariantCulture)); - - File.WriteAllText("Table.txt", sb.ToString()); - } -#endif - } -} diff --git a/Ext/DeprecatedSources/ProtectedString_111029.cs b/Ext/DeprecatedSources/ProtectedString_111029.cs deleted file mode 100644 index e37fd06..0000000 --- a/Ext/DeprecatedSources/ProtectedString_111029.cs +++ /dev/null @@ -1,436 +0,0 @@ -/* - KeePass Password Safe - The Open-Source Password Manager - Copyright (C) 2003-2011 Dominik Reichl - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -using System; -using System.Security; -using System.Text; -using System.Diagnostics; -using System.Runtime.InteropServices; - -using KeePassLib.Cryptography; -using KeePassLib.Utility; - -#if KeePassLibSD -using KeePassLibSD; -#endif - -namespace KeePassLib.Security -{ - /// - /// Represents an in-memory encrypted string. - /// -#if (DEBUG && !KeePassLibSD) - [DebuggerDisplay(@"{ReadString()}")] -#endif - public sealed class ProtectedString - { - // SecureString objects are supported only on Windows 2000 SP3 and - // higher. On all other systems (98 / ME) we use a standard string - // object instead of the secure one. This of course decreases the - // security of the class, but at least allows the application - // to run on older systems, too. - private SecureString m_secString = null; // Created in constructor - private string m_strAlternativeSecString = string.Empty; - - private string m_strPlainText = string.Empty; // Never null - private bool m_bIsProtected = false; // See default constructor - - private XorredBuffer m_xbEncrypted = null; // UTF-8 representation - - /// - /// A flag specifying whether the ProtectedString object has turned on - /// in-memory protection or not. - /// - public bool IsProtected - { - get { return m_bIsProtected; } - } - - /// - /// A value specifying whether the ProtectedString object is currently - /// in-memory protected or not. This flag can be different than - /// IsProtected: if a XorredBuffer is used, the IsProtected - /// flag represents the memory protection flag, but not the actual protection. - /// In this case use IsViewable, which returns true if a - /// XorredBuffer is currently in use. - /// - public bool IsViewable - { - get { return (!m_bIsProtected && (m_xbEncrypted == null)); } - } - - public bool IsEmpty - { - get - { - if(m_xbEncrypted != null) return (m_xbEncrypted.Length == 0); - - if(m_bIsProtected) - { - if(m_secString != null) return (m_secString.Length == 0); - else return (m_strAlternativeSecString.Length == 0); - } - - return (m_strPlainText.Length == 0); - } - } - - public int Length - { - get - { - if(m_xbEncrypted != null) - { - byte[] pb = m_xbEncrypted.ReadPlainText(); - - string str = StrUtil.Utf8.GetString(pb, 0, pb.Length); - SetString(str); // Clear the XorredBuffer object - - // No need to erase the pb buffer, the plain text is - // now readable in memory anyway (in str). - - return ((str != null) ? str.Length : 0); - } - - if(m_bIsProtected) - { - if(m_secString != null) return m_secString.Length; - else return m_strAlternativeSecString.Length; - } - - return m_strPlainText.Length; // Unprotected string - } - } - - /// - /// Construct a new protected string object. Protection is - /// disabled by default! You need to call the - /// EnableProtection member function in order to - /// enable the protection, if you wish the string to be protected. - /// - public ProtectedString() - { - try { m_secString = new SecureString(); } - catch(NotSupportedException) { } // Windows 98 / ME - } - - /// - /// Construct a new in-memory encrypted string object. - /// - /// If this parameter is true, - /// the string will be protected in-memory (encrypted). If it - /// is false, the string will be stored as plain-text. - public ProtectedString(bool bEnableProtection) - { - try { m_secString = new SecureString(); } - catch(NotSupportedException) { } // Windows 98 / ME - - m_bIsProtected = bEnableProtection; - } - - /// - /// Construct a new protected string. The string is initialized - /// to the value supplied in the parameters. - /// - /// If this parameter is true, - /// the string will be protected in-memory (encrypted). If it - /// is false, the string will be stored as plain-text. - /// The initial string value. This - /// parameter won't be modified. - public ProtectedString(bool bEnableProtection, string strValue) - { - try { m_secString = new SecureString(); } - catch(NotSupportedException) { } // Windows 98 / ME - - m_bIsProtected = bEnableProtection; - SetString(strValue); - } - - /// - /// Construct a new protected string. The string is initialized - /// to the value supplied in the parameters (UTF-8 encoded string). - /// - /// If this parameter is true, - /// the string will be protected in-memory (encrypted). If it - /// is false, the string will be stored as plain-text. - /// The initial string value, encoded as - /// UTF-8 byte array. This parameter won't be modified. - public ProtectedString(bool bEnableProtection, byte[] vUtf8Value) - { - if(vUtf8Value == null) throw new ArgumentNullException("vUtf8Value"); - - try { m_secString = new SecureString(); } - catch(NotSupportedException) { } // Windows 98 / ME - - m_bIsProtected = bEnableProtection; - SetString(StrUtil.Utf8.GetString(vUtf8Value, 0, vUtf8Value.Length)); - } - - /// - /// Construct a new protected string. The string is initialized - /// to the value passed in the pbTemplate protected string. - /// - /// The initial string value. This - /// parameter won't be modified. Must not be null. - /// Thrown if the input - /// parameter is null. - public ProtectedString(ProtectedString psTemplate) - { - Debug.Assert(psTemplate != null); - if(psTemplate == null) throw new ArgumentNullException("psTemplate"); - - try { m_secString = new SecureString(); } - catch(NotSupportedException) { } // Windows 98 / ME - - m_bIsProtected = psTemplate.m_bIsProtected; - SetString(psTemplate.ReadString()); - } - - /// - /// Construct a new protected string. The string is initialized - /// to the value passed in the XorredBuffer object. - /// - /// Enable protection or not. - /// XorredBuffer object containing the - /// string in UTF-8 representation. The UTF-8 string must not - /// be null-terminated. - /// Thrown if the input - /// parameter is null. - public ProtectedString(bool bEnableProtection, XorredBuffer xbProtected) - { - Debug.Assert(xbProtected != null); - if(xbProtected == null) throw new ArgumentNullException("xbProtected"); - - try { m_secString = new SecureString(); } - catch(NotSupportedException) { } // Windows 98 / ME - - m_bIsProtected = bEnableProtection; - m_xbEncrypted = xbProtected; - } - - /// - /// Clear the string. Doesn't change the protection level. - /// - public void Clear() - { - if(m_secString != null) m_secString.Clear(); - else m_strAlternativeSecString = string.Empty; - - m_strPlainText = string.Empty; - - m_xbEncrypted = null; - } - - /// - /// Change the protection level (protect or don't protect). Note: you - /// only need to call this function if you really want to change the - /// protection. If you specified the protection flag in the constructor, - /// and don't want to change it, you don't need to call this function. - /// - /// If true, the string will be protected - /// (encrypted in-memory). Otherwise the string will be stored in - /// plain-text in the process memory. - public void EnableProtection(bool bProtect) - { - if(m_xbEncrypted != null) - { - m_bIsProtected = bProtect; - return; - } - - if(m_bIsProtected && !bProtect) // Unprotect - { - string strPlainText = ReadString(); - - Clear(); - - m_strPlainText = strPlainText; - m_bIsProtected = false; - } - else if(!m_bIsProtected && bProtect) // Protect - { - m_bIsProtected = true; - - SetString(m_strPlainText); - } - } - - /// - /// Assign a new string value to the object. - /// - /// New string. The string must not contain - /// a null terminator. - /// Thrown if the input - /// parameter is null. - /// Thrown if the new string - /// contains a null terminator. - public void SetString(string strNewValue) - { - Clear(); - - Debug.Assert(strNewValue != null); if(strNewValue == null) throw new ArgumentNullException("strNewValue"); - - // String must not contain any null character - Debug.Assert(strNewValue.IndexOf((char)0) < 0); - - if(m_bIsProtected) - { - if(m_secString != null) - { - char ch; - for(int i = 0; i < strNewValue.Length; ++i) - { - ch = strNewValue[i]; - if(ch == 0) throw new ArgumentException(); - - m_secString.AppendChar(ch); - } - } - else m_strAlternativeSecString = strNewValue; - } - else // Currently not protected - { - m_strPlainText = strNewValue; - } - } - - /// - /// Convert the protected string to a normal string object. - /// Be careful with this function, the returned string object - /// isn't protected any more and stored in plain-text in the - /// process memory. - /// - /// Plain-text string. Is never null. - public string ReadString() - { - if(m_xbEncrypted != null) - { - byte[] pb = m_xbEncrypted.ReadPlainText(); - - string str = StrUtil.Utf8.GetString(pb, 0, pb.Length); - SetString(str); // Clear the XorredBuffer object - - // No need to erase the pb buffer, the plain text is - // now readable in memory anyway (in str). - - return (str ?? string.Empty); - } - - if(m_bIsProtected) - { - if(m_secString != null) - { -#if !KeePassLibSD - IntPtr p = Marshal.SecureStringToGlobalAllocUnicode(m_secString); - string str = Marshal.PtrToStringUni(p); - Marshal.ZeroFreeGlobalAllocUnicode(p); -#else - string str = m_secString.ReadAsString(); -#endif - return (str ?? string.Empty); - } - else return m_strAlternativeSecString; - } - - return m_strPlainText; // Unprotected string - } - - /// - /// Read out the string and return a byte array that contains the - /// string encoded using UTF-8. The returned string is not protected - /// anymore! - /// - /// Plain-text UTF-8 byte array. - public byte[] ReadUtf8() - { - if(m_xbEncrypted != null) - { - byte[] pb = m_xbEncrypted.ReadPlainText(); - - // Clear XorredBuffer - SetString(StrUtil.Utf8.GetString(pb, 0, pb.Length)); - - return pb; - } - - if(m_bIsProtected) - { - if(m_secString != null) - { -#if !KeePassLibSD - Debug.Assert(sizeof(char) == 2); - char[] vChars = new char[m_secString.Length]; - - IntPtr p = Marshal.SecureStringToGlobalAllocUnicode(m_secString); - for(int i = 0; i < vChars.Length; ++i) - vChars[i] = (char)Marshal.ReadInt16(p, i * 2); - Marshal.ZeroFreeGlobalAllocUnicode(p); - - byte[] pb = StrUtil.Utf8.GetBytes(vChars, 0, vChars.Length); - Array.Clear(vChars, 0, vChars.Length); -#else - byte[] pb = StrUtil.Utf8.GetBytes(m_secString.ReadAsString()); -#endif - return pb; - } - else return StrUtil.Utf8.GetBytes(m_strAlternativeSecString); - } - - return StrUtil.Utf8.GetBytes(m_strPlainText); // Unprotected string - } - - /// - /// Read the protected string and return it protected with a sequence - /// of bytes generated by a random stream. The object's data will be - /// invisible in process memory only if the object has been initialized - /// using a XorredBuffer. If no XorredBuffer has been used - /// or the string has been read once already (in plain-text), the - /// operation won't be secure and the protected string will be visible - /// in process memory. - /// - /// Random number source. - /// Protected string. - /// Thrown if the input - /// parameter is null. - public byte[] ReadXorredString(CryptoRandomStream crsRandomSource) - { - Debug.Assert(crsRandomSource != null); if(crsRandomSource == null) throw new ArgumentNullException("crsRandomSource"); - - if(m_xbEncrypted != null) - { - uint uLen = m_xbEncrypted.Length; - byte[] randomPad = crsRandomSource.GetRandomBytes(uLen); - return m_xbEncrypted.ChangeKey(randomPad); - } - else // Not using XorredBuffer - { - byte[] pbData = ReadUtf8(); - uint uLen = (uint)pbData.Length; - - byte[] randomPad = crsRandomSource.GetRandomBytes(uLen); - Debug.Assert(randomPad.Length == uLen); - - for(uint i = 0; i < uLen; ++i) - pbData[i] ^= randomPad[i]; - - return pbData; - } - } - } -} diff --git a/Ext/DeprecatedSources/ShInstUtil/Program.cs b/Ext/DeprecatedSources/ShInstUtil/Program.cs deleted file mode 100644 index ba84f37..0000000 --- a/Ext/DeprecatedSources/ShInstUtil/Program.cs +++ /dev/null @@ -1,114 +0,0 @@ -/* - KeePass Password Safe - The Open-Source Password Manager - Copyright (C) 2003-2009 Dominik Reichl - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using System.IO; -using System.Reflection; -using System.Diagnostics; - -using Microsoft.Win32; - -namespace ShInstUtil -{ - public static class Program - { - [STAThread] - public static void Main(string[] args) - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - - if((args == null) || (args.Length == 0)) return; - - string strCmd = args[0]; - if(string.IsNullOrEmpty(strCmd)) return; - strCmd = strCmd.ToLower(); - strCmd = strCmd.Trim(new char[]{ '\r', '\n', ' ', '\t', '-', '/', - '\"', '\'' }); - - if(strCmd == "ngen_install") - { - UpdateNativeImage(false); - UpdateNativeImage(true); - } - else if(strCmd == "ngen_uninstall") - UpdateNativeImage(false); - } - - private static string FindNGenPath() - { - RegistryKey kSoftware = Registry.LocalMachine.OpenSubKey("SOFTWARE"); - RegistryKey kMicrosoft = kSoftware.OpenSubKey("Microsoft"); - RegistryKey kNet = kMicrosoft.OpenSubKey(".NETFramework"); - - string strPath = (kNet.GetValue("InstallRoot") as string); - - kNet.Close(); - kMicrosoft.Close(); - kSoftware.Close(); - - if(string.IsNullOrEmpty(strPath)) return null; - - DirectoryInfo di = new DirectoryInfo(strPath); - FileInfo[] vNGens = di.GetFiles("ngen.exe", SearchOption.AllDirectories); - if((vNGens == null) || (vNGens.Length == 0)) return null; - - strPath = null; - DateTime dt = DateTime.MinValue.AddYears(1); - foreach(FileInfo fi in vNGens) - { - if(fi.CreationTime >= dt) - { - strPath = fi.FullName; - dt = fi.CreationTime; - } - } - - return strPath; - } - - private static void UpdateNativeImage(bool bInstall) - { - try - { - string strNGen = FindNGenPath(); - if(string.IsNullOrEmpty(strNGen)) return; - - string strMe = Assembly.GetExecutingAssembly().Location; - string strBasePath = Path.GetDirectoryName(strMe).Trim(new char[]{ - '\r', '\n', ' ', '\t', '\"', '\'' }); - string strToReg = strBasePath + Path.DirectorySeparatorChar + "KeePass.exe"; - - string strPreCmd = (bInstall ? string.Empty : "un"); - - ProcessStartInfo psi = new ProcessStartInfo(); - psi.Arguments = strPreCmd + "install \"" + strToReg + "\""; - psi.CreateNoWindow = true; - psi.FileName = strNGen; - psi.WindowStyle = ProcessWindowStyle.Hidden; - - Process p = Process.Start(psi); - p.WaitForExit(16000); - } - catch(Exception) { } - } - } -} diff --git a/Ext/DeprecatedSources/ShInstUtil/Properties/AssemblyInfo.cs b/Ext/DeprecatedSources/ShInstUtil/Properties/AssemblyInfo.cs deleted file mode 100644 index 0a72271..0000000 --- a/Ext/DeprecatedSources/ShInstUtil/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,42 +0,0 @@ -/* - KeePass Password Safe - The Open-Source Password Manager - Copyright (C) 2003-2009 Dominik Reichl - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General assembly properties -[assembly: AssemblyTitle("ShInstUtil - KeePass Installation Utility")] -[assembly: AssemblyDescription("Installation Utility")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Dominik Reichl")] -[assembly: AssemblyProduct("ShInstUtil - KeePass Installation Utility")] -[assembly: AssemblyCopyright("Copyright © 2007-2009 Dominik Reichl")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// COM settings -[assembly: ComVisible(false)] - -// Assembly GUID -[assembly: Guid("7e0eb6e8-4f13-4b04-aad9-2acf8417a776")] - -// Assembly version information -[assembly: AssemblyVersion("2.0.8.*")] -[assembly: AssemblyFileVersion("2.0.8.0")] diff --git a/Ext/DeprecatedSources/ShInstUtil/Properties/Resources.Designer.cs b/Ext/DeprecatedSources/ShInstUtil/Properties/Resources.Designer.cs deleted file mode 100644 index 128a6da..0000000 --- a/Ext/DeprecatedSources/ShInstUtil/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1433 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace ShInstUtil.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ShInstUtil.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/Ext/DeprecatedSources/ShInstUtil/Properties/Resources.resx b/Ext/DeprecatedSources/ShInstUtil/Properties/Resources.resx deleted file mode 100644 index ffecec8..0000000 --- a/Ext/DeprecatedSources/ShInstUtil/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Ext/DeprecatedSources/ShInstUtil/Properties/Settings.Designer.cs b/Ext/DeprecatedSources/ShInstUtil/Properties/Settings.Designer.cs deleted file mode 100644 index 82e5aad..0000000 --- a/Ext/DeprecatedSources/ShInstUtil/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1433 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace ShInstUtil.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/Ext/DeprecatedSources/ShInstUtil/Properties/Settings.settings b/Ext/DeprecatedSources/ShInstUtil/Properties/Settings.settings deleted file mode 100644 index abf36c5..0000000 --- a/Ext/DeprecatedSources/ShInstUtil/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Ext/DeprecatedSources/ShInstUtil/ShInstUtil.csproj b/Ext/DeprecatedSources/ShInstUtil/ShInstUtil.csproj deleted file mode 100644 index c2a3539..0000000 --- a/Ext/DeprecatedSources/ShInstUtil/ShInstUtil.csproj +++ /dev/null @@ -1,75 +0,0 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {D6240ED0-5AE4-4F6D-B1F1-C691630B4D3F} - WinExe - Properties - ShInstUtil - ShInstUtil - true - ShInstUtil.pfx - - - 2.0 - - - - - true - full - false - ..\Build\ShInstUtil\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - ..\Build\ShInstUtil\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - True - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - True - Settings.settings - True - - - - - \ No newline at end of file diff --git a/Ext/DeprecatedSources/ShInstUtil/ShInstUtil.pfx b/Ext/DeprecatedSources/ShInstUtil/ShInstUtil.pfx deleted file mode 100644 index 19b0155..0000000 Binary files a/Ext/DeprecatedSources/ShInstUtil/ShInstUtil.pfx and /dev/null differ diff --git a/Ext/DeprecatedSources/UpdateCheck_111216.cs b/Ext/DeprecatedSources/UpdateCheck_111216.cs deleted file mode 100644 index aaae237..0000000 --- a/Ext/DeprecatedSources/UpdateCheck_111216.cs +++ /dev/null @@ -1,205 +0,0 @@ -/* - KeePass Password Safe - The Open-Source Password Manager - Copyright (C) 2003-2011 Dominik Reichl - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -using System; -using System.Collections.Generic; -using System.Text; -using System.Net; -using System.Net.Cache; -using System.Windows.Forms; -using System.Xml; -using System.Diagnostics; -using System.Threading; - -// using KeePass.Native; -using KeePass.Resources; - -using KeePassLib; -using KeePassLib.Resources; -using KeePassLib.Serialization; -using KeePassLib.Utility; - -namespace KeePass.Util -{ - /* public static class UpdateCheck - { - private const string ElemRoot = "KeePass"; - - private const string ElemVersionU = "Version32"; - private const string ElemVersionStr = "VersionDisplayString"; - - private static volatile string m_strVersionURL = string.Empty; - private static volatile ToolStripStatusLabel m_tsResultsViewer = null; - - public static void StartAsync(string strVersionUrl, ToolStripStatusLabel tsResultsViewer) - { - m_strVersionURL = strVersionUrl; - m_tsResultsViewer = tsResultsViewer; - - // Local, but thread will continue to run anyway - Thread th = new Thread(new ThreadStart(UpdateCheck.OnStartCheck)); - th.Start(); - } - - private static void OnStartCheck() - { - // NativeProgressDialog dlg = null; - // if(m_tsResultsViewer == null) - // { - // dlg = new NativeProgressDialog(); - // dlg.StartLogging(KPRes.Wait + "...", false); - // } - - try - { - IOWebClient webClient = new IOWebClient(); - IOConnection.ConfigureWebClient(webClient); - - Uri uri = new Uri(m_strVersionURL); - - webClient.DownloadDataCompleted += - new DownloadDataCompletedEventHandler(OnDownloadCompleted); - - webClient.DownloadDataAsync(uri); - } - // catch(NotImplementedException) - // { - // ReportStatusEx(KLRes.FrameworkNotImplExcp, true); - // } - catch(Exception) { } - - // if(dlg != null) dlg.EndLogging(); - } - - private static void OnDownloadCompleted(object sender, DownloadDataCompletedEventArgs e) - { - string strXmlFile = NetUtil.GZipUtf8ResultToString(e); - - if(strXmlFile == null) - { - if(e.Error != null) - { - if(m_tsResultsViewer == null) - MessageService.ShowWarning(KPRes.UpdateCheckingFailed, e.Error); - else if(e.Error.Message != null) - UpdateCheck.SetTsStatus(KPRes.UpdateCheckingFailed + " " + - e.Error.Message); - } - else ReportStatusEx(KPRes.UpdateCheckingFailed, true); - - return; - } - - XmlDocument xmlDoc = new XmlDocument(); - - try { xmlDoc.LoadXml(strXmlFile); } - catch(Exception) - { - StructureFail(); - return; - } - - XmlElement xmlRoot = xmlDoc.DocumentElement; - if(xmlRoot == null) { StructureFail(); return; } - if(xmlRoot.Name != ElemRoot) { StructureFail(); return; } - - uint uVersion = 0; - - foreach(XmlNode xmlChild in xmlRoot.ChildNodes) - { - if(xmlChild.Name == ElemVersionU) - uint.TryParse(xmlChild.InnerText, out uVersion); - else if(xmlChild.Name == ElemVersionStr) - { - // strVersion = xmlChild.InnerText; - } - } - - if(uVersion > PwDefs.Version32) - { - if(m_tsResultsViewer == null) - { - if(MessageService.AskYesNo(KPRes.ChkForUpdNewVersion + - MessageService.NewParagraph + KPRes.WebsiteVisitQuestion)) - { - WinUtil.OpenUrl(PwDefs.HomepageUrl, null); - } - } - else UpdateCheck.SetTsStatus(KPRes.ChkForUpdNewVersion); - } - else if(uVersion == PwDefs.Version32) - ReportStatusEx(KPRes.ChkForUpdGotLatest, false); - else - ReportStatusEx(KPRes.UnknownFileVersion, true); - } - - private static void ReportStatusEx(string strText, bool bIsWarning) - { - ReportStatusEx(strText, strText, bIsWarning); - } - - private static void ReportStatusEx(string strLongText, string strShortText, - bool bIsWarning) - { - if(m_tsResultsViewer == null) - { - if(bIsWarning) MessageService.ShowWarning(strLongText); - else MessageService.ShowInfo(strLongText); - } - else UpdateCheck.SetTsStatus(strShortText); - } - - private static void StructureFail() - { - Debug.Assert(false); - - if(m_tsResultsViewer == null) - MessageService.ShowWarning(KPRes.InvalidFileStructure); - else - UpdateCheck.SetTsStatus(KPRes.ChkForUpdGotLatest + " " + - KPRes.InvalidFileStructure); - } - - private static void SetTsStatus(string strText) - { - if(strText == null) { Debug.Assert(false); return; } - if(m_tsResultsViewer == null) { Debug.Assert(false); return; } - - try - { - ToolStrip pParent = m_tsResultsViewer.Owner; - if((pParent != null) && pParent.InvokeRequired) - { - pParent.Invoke(new Priv_CfuSsd(UpdateCheck.SetTsStatusDirect), - new object[] { strText }); - } - else UpdateCheck.SetTsStatusDirect(strText); - } - catch(Exception) { Debug.Assert(false); } - } - - public delegate void Priv_CfuSsd(string strText); - - private static void SetTsStatusDirect(string strText) - { - try { m_tsResultsViewer.Text = strText; } - catch(Exception) { Debug.Assert(false); } - } - } */ -} diff --git a/Ext/DeprecatedSources/XorredBuffer_111029.cs b/Ext/DeprecatedSources/XorredBuffer_111029.cs deleted file mode 100644 index 3b16d96..0000000 --- a/Ext/DeprecatedSources/XorredBuffer_111029.cs +++ /dev/null @@ -1,196 +0,0 @@ -/* - KeePass Password Safe - The Open-Source Password Manager - Copyright (C) 2003-2011 Dominik Reichl - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -using System; -using System.Diagnostics; - -namespace KeePassLib.Security -{ - /// - /// Represents an object that is encrypted using a XOR pad until - /// it is read. The key XOR pad can be changed without revealing the - /// protected data in process memory. - /// - public sealed class XorredBuffer - { - private byte[] m_pbData = new byte[0]; // Never null - private byte[] m_pbXorPad = new byte[0]; // Never null - - /// - /// Length of the protected data in bytes. - /// - public uint Length - { - get { return (uint)m_pbData.Length; } - } - - /// - /// Construct a new XOR-protected object using a protected byte array - /// and a XOR pad that decrypts the protected data. The - /// byte array must have the same size - /// as the byte array. - /// - /// Protected data (XOR pad applied). - /// XOR pad that is used to decrypt the - /// parameter. - /// Thrown if one of the input - /// parameters is null. - /// Thrown if the byte arrays are - /// of different size. - public XorredBuffer(byte[] pbProtectedData, byte[] pbXorPad) - { - Debug.Assert(pbProtectedData != null); if(pbProtectedData == null) throw new ArgumentNullException("pbProtectedData"); - Debug.Assert(pbXorPad != null); if(pbXorPad == null) throw new ArgumentNullException("pbXorPad"); - - Debug.Assert(pbProtectedData.Length == pbXorPad.Length); - if(pbProtectedData.Length != pbXorPad.Length) throw new ArgumentException(); - - m_pbData = pbProtectedData; - m_pbXorPad = pbXorPad; - } - - private void Decrypt() - { - Debug.Assert((m_pbData.Length == m_pbXorPad.Length) || (m_pbXorPad.Length == 0)); - - if(m_pbData.Length == m_pbXorPad.Length) - { - for(int i = 0; i < m_pbData.Length; ++i) - m_pbData[i] ^= m_pbXorPad[i]; - - m_pbXorPad = new byte[0]; - } - } - - /// - /// Decrypt the buffer. The XorredBuffer protection is useless - /// after you used this method. The object cannot be re-encrypted. - /// - /// Unprotected plain-text byte array. - public byte[] ReadPlainText() - { - Decrypt(); - return m_pbData; - } - - /// - /// Change the protection key for this XorredBuffer object. - /// The data will first be decrypted using the old key and then - /// re-encrypted using the new key. This operation doesn't reveal - /// the plain-text in the process memory. - /// - /// New protection pad. Must contain exactly - /// the same number of bytes as the length of the currently protected data. - /// Use the Length property of the XorredBuffer to query - /// the data length and pass a correct number of bytes to ChangeKey. - /// New protected data (encrypted using the new XOR pad). - /// Thrown if the input - /// parameter is null. - /// Thrown if the input - /// byte array doesn't have the correct size. - public byte[] ChangeKey(byte[] pbNewXorPad) - { - Debug.Assert(pbNewXorPad != null); if(pbNewXorPad == null) throw new ArgumentNullException("pbNewXorPad"); - - Debug.Assert(pbNewXorPad.Length == m_pbData.Length); - if(pbNewXorPad.Length != m_pbData.Length) throw new ArgumentException(); - - if(m_pbXorPad.Length == m_pbData.Length) // Data is protected - { - for(int i = 0; i < m_pbData.Length; ++i) - m_pbData[i] ^= (byte)(m_pbXorPad[i] ^ pbNewXorPad[i]); - } - else // Data is unprotected - { - for(int i = 0; i < m_pbData.Length; ++i) - m_pbData[i] ^= pbNewXorPad[i]; - } - - m_pbXorPad = pbNewXorPad; - return m_pbData; - } - - public bool EqualsValue(XorredBuffer xb) - { - if(xb == null) { Debug.Assert(false); throw new ArgumentNullException("xb"); } - - if(xb.m_pbData.Length != m_pbData.Length) return false; - - bool bDecThis = (m_pbData.Length == m_pbXorPad.Length); - bool bDecOther = (xb.m_pbData.Length == xb.m_pbXorPad.Length); - for(int i = 0; i < m_pbData.Length; ++i) - { - byte bt1 = m_pbData[i]; - if(bDecThis) bt1 ^= m_pbXorPad[i]; - - byte bt2 = xb.m_pbData[i]; - if(bDecOther) bt2 ^= xb.m_pbXorPad[i]; - - if(bt1 != bt2) return false; - } - - return true; - } - - public bool EqualsValue(byte[] pb) - { - if(pb == null) { Debug.Assert(false); throw new ArgumentNullException("pb"); } - - if(pb.Length != m_pbData.Length) return false; - - if(m_pbData.Length == m_pbXorPad.Length) - { - for(int i = 0; i < m_pbData.Length; ++i) - { - if((byte)(m_pbData[i] ^ m_pbXorPad[i]) != pb[i]) return false; - } - return true; - } - - for(int i = 0; i < m_pbData.Length; ++i) - { - if(m_pbData[i] != pb[i]) return false; - } - return true; - } - - /// - /// XOR all bytes in a data buffer with a pad. Both byte arrays must - /// be of the same size. - /// - /// Data to be protected. - /// XOR pad. - /// Thrown if one of the - /// parameters is null. - /// Thrown if the length of - /// the data array and the pad aren't equal. - [Obsolete("Use MemUtil.XorArray instead.")] - public static void XorArrays(byte[] pbData, byte[] pbPad) - { - Debug.Assert(pbData != null); if(pbData == null) throw new ArgumentNullException("pbData"); - Debug.Assert(pbPad != null); if(pbPad == null) throw new ArgumentNullException("pbPad"); - - Debug.Assert(pbData.Length == pbPad.Length); - if(pbData.Length != pbPad.Length) throw new ArgumentException(); - - for(int i = 0; i < pbData.Length; ++i) - pbData[i] ^= pbPad[i]; - } - } -} diff --git a/Ext/KeePass.exe.config b/Ext/KeePass.exe.config index 5f6aca9..f9efb5a 100644 --- a/Ext/KeePass.exe.config +++ b/Ext/KeePass.exe.config @@ -10,8 +10,8 @@ - + diff --git a/Ext/KeePass.iss b/Ext/KeePass.iss index 63fc529..ea6fc95 100644 --- a/Ext/KeePass.iss +++ b/Ext/KeePass.iss @@ -8,10 +8,10 @@ #define MyAppNameEx "KeePass Password Safe 2" #define MyAppPublisher "Dominik Reichl" -#define KeeVersionStr "2.20" -#define KeeVersionStrWithMinor "2.20" -#define KeeVersionStrWithMinorPath "2.20" -#define KeeVersionWin "2.20.0.0" +#define KeeVersionStr "2.20.1" +#define KeeVersionStrWithMinor "2.20.1" +#define KeeVersionStrWithMinorPath "2.20.1" +#define KeeVersionWin "2.20.1.0" #define MyAppURL "http://keepass.info/" #define MyAppExeName "KeePass.exe" diff --git a/Ext/KeePassMsi/KeePassMsi.vdproj b/Ext/KeePassMsi/KeePassMsi.vdproj index 54e1cdb..7df4aa7 100644 --- a/Ext/KeePassMsi/KeePassMsi.vdproj +++ b/Ext/KeePassMsi/KeePassMsi.vdproj @@ -382,7 +382,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:KeePass, Version=2.20.0.18622, Culture=neutral, PublicKeyToken=fed2ed7716aecf5c, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:KeePass, Version=2.20.1.16631, Culture=neutral, PublicKeyToken=fed2ed7716aecf5c, processorArchitecture=MSIL" "ScatterAssemblies" { "_838987B3C51D42C3C7B9BDA1339A5500" @@ -413,7 +413,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:KeePass.XmlSerializers, Version=2.20.0.18622, Culture=neutral, PublicKeyToken=fed2ed7716aecf5c, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:KeePass.XmlSerializers, Version=2.20.1.16631, Culture=neutral, PublicKeyToken=fed2ed7716aecf5c, processorArchitecture=MSIL" "ScatterAssemblies" { "_8C05ADB649434D7892E36709EBDED4CC" @@ -564,7 +564,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:KeePass, Version=2.20.0.18622, Culture=neutral, PublicKeyToken=fed2ed7716aecf5c, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:KeePass, Version=2.20.1.16631, Culture=neutral, PublicKeyToken=fed2ed7716aecf5c, processorArchitecture=MSIL" "ScatterAssemblies" { "_C4F8814F844C43EE8C9F5B662182B11A" @@ -712,14 +712,14 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:KeePass" - "ProductCode" = "8:{F6B49374-09A3-4B84-BA45-1CA2CD1C793F}" - "PackageCode" = "8:{72EA3387-C9B6-433D-B670-E84AEC1CF35C}" + "ProductCode" = "8:{798C312A-7893-46A2-A269-D3176F13D060}" + "PackageCode" = "8:{F4690AAC-FA26-488E-A4EE-5FAFE81E56DA}" "UpgradeCode" = "8:{F2F19898-4F86-4940-9BFA-426574CE03E1}" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE" "InstallAllUsers" = "11:TRUE" - "ProductVersion" = "8:2.20.0" + "ProductVersion" = "8:2.20.1" "Manufacturer" = "8:Dominik Reichl" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:http://keepass.info/" diff --git a/KeePass/Native/NativeMethods.Unix.cs b/KeePass/Native/NativeMethods.Unix.cs index 8544892..11a0c6e 100644 --- a/KeePass/Native/NativeMethods.Unix.cs +++ b/KeePass/Native/NativeMethods.Unix.cs @@ -175,6 +175,12 @@ internal static void SetWmClass(Form f, string strName, string strClass) { if(f == null) { Debug.Assert(false); return; } + // The following crashes under Mac OS X (SIGSEGV in native code, + // not just an exception), thus skip it when we're on Mac OS X + // https://sourceforge.net/projects/keepass/forums/forum/329221/topic/5860588 + if(KeeNativeLib.NativeLib.GetPlatformID() == PlatformID.MacOSX) + return; + try { Type tXplatUIX11 = GetXplatUIX11Type(true); diff --git a/KeePass/Plugins/PlgxCache.cs b/KeePass/Plugins/PlgxCache.cs index fa6acf2..c554ef9 100644 --- a/KeePass/Plugins/PlgxCache.cs +++ b/KeePass/Plugins/PlgxCache.cs @@ -114,7 +114,7 @@ public static string GetCacheRoot() // if(di.DriveType == DriveType.Network) // { // strDataDir = UrlUtil.EnsureTerminatingSeparator( - // Path.GetTempPath(), false); + // UrlUtil.GetTempPath(), false); // strDataDir = strDataDir.Substring(0, strDataDir.Length - 1); // } // } diff --git a/KeePass/Plugins/PlgxPlugin.cs b/KeePass/Plugins/PlgxPlugin.cs index 6345912..578bfc5 100644 --- a/KeePass/Plugins/PlgxPlugin.cs +++ b/KeePass/Plugins/PlgxPlugin.cs @@ -266,7 +266,7 @@ public static void CreateInfoFile(string strPlgxPath) private static string CreateTempDirectory() { - string strTmpRoot = Path.GetTempPath(); + string strTmpRoot = UrlUtil.GetTempPath(); strTmpRoot = UrlUtil.EnsureTerminatingSeparator(strTmpRoot, false); strTmpRoot += (new PwUuid(true)).ToHexString(); diff --git a/KeePass/Program.cs b/KeePass/Program.cs index a41b7a9..4c573c1 100644 --- a/KeePass/Program.cs +++ b/KeePass/Program.cs @@ -284,7 +284,7 @@ public static void Main(string[] args) try { string strFileOut = UrlUtil.EnsureTerminatingSeparator( - Path.GetTempPath(), false) + "KeePass_UrlOverride.tmp"; + UrlUtil.GetTempPath(), false) + "KeePass_UrlOverride.tmp"; string strContent = ("[KeePass]\r\nKeeURLOverride=" + Program.Config.Integration.UrlOverride + "\r\n"); File.WriteAllText(strFileOut, strContent); diff --git a/KeePass/Properties/AssemblyInfo.cs b/KeePass/Properties/AssemblyInfo.cs index 03f753b..9712ee7 100644 --- a/KeePass/Properties/AssemblyInfo.cs +++ b/KeePass/Properties/AssemblyInfo.cs @@ -38,5 +38,5 @@ [assembly: Guid("02020c52-c0da-47c0-9f3f-a6fe76cee400")] // Assembly version information -[assembly: AssemblyVersion("2.20.0.*")] -[assembly: AssemblyFileVersion("2.20.0.0")] +[assembly: AssemblyVersion("2.20.1.*")] +[assembly: AssemblyFileVersion("2.20.1.0")] diff --git a/KeePass/Resources/Nuvola_Derived/B16x16_DeleteEntry.png b/KeePass/Resources/Nuvola_Derived/B16x16_DeleteEntry.png index cf9dea0..8cff343 100644 Binary files a/KeePass/Resources/Nuvola_Derived/B16x16_DeleteEntry.png and b/KeePass/Resources/Nuvola_Derived/B16x16_DeleteEntry.png differ diff --git a/KeePass/Resources/Nuvola_Derived/B16x16_EditCopyLink.png b/KeePass/Resources/Nuvola_Derived/B16x16_EditCopyLink.png index 731f611..fff5000 100644 Binary files a/KeePass/Resources/Nuvola_Derived/B16x16_EditCopyLink.png and b/KeePass/Resources/Nuvola_Derived/B16x16_EditCopyLink.png differ diff --git a/KeePass/Resources/Nuvola_Derived/B16x16_FileSave_Disabled.png b/KeePass/Resources/Nuvola_Derived/B16x16_FileSave_Disabled.png index 52c99f6..9727a0b 100644 Binary files a/KeePass/Resources/Nuvola_Derived/B16x16_FileSave_Disabled.png and b/KeePass/Resources/Nuvola_Derived/B16x16_FileSave_Disabled.png differ diff --git a/KeePass/Resources/Nuvola_Derived/B16x16_File_Close.png b/KeePass/Resources/Nuvola_Derived/B16x16_File_Close.png index 20394a6..4818ef4 100644 Binary files a/KeePass/Resources/Nuvola_Derived/B16x16_File_Close.png and b/KeePass/Resources/Nuvola_Derived/B16x16_File_Close.png differ diff --git a/KeePass/Resources/Nuvola_Derived/B16x16_File_SaveAll.png b/KeePass/Resources/Nuvola_Derived/B16x16_File_SaveAll.png index e9baa39..b34b1dd 100644 Binary files a/KeePass/Resources/Nuvola_Derived/B16x16_File_SaveAll.png and b/KeePass/Resources/Nuvola_Derived/B16x16_File_SaveAll.png differ diff --git a/KeePass/Resources/Nuvola_Derived/B16x16_File_SaveAll_Disabled.png b/KeePass/Resources/Nuvola_Derived/B16x16_File_SaveAll_Disabled.png index 3c8bc37..9fe7e0a 100644 Binary files a/KeePass/Resources/Nuvola_Derived/B16x16_File_SaveAll_Disabled.png and b/KeePass/Resources/Nuvola_Derived/B16x16_File_SaveAll_Disabled.png differ diff --git a/KeePass/Resources/Nuvola_Derived/B16x16_Key_New.png b/KeePass/Resources/Nuvola_Derived/B16x16_Key_New.png index de21b88..fb4f54e 100644 Binary files a/KeePass/Resources/Nuvola_Derived/B16x16_Key_New.png and b/KeePass/Resources/Nuvola_Derived/B16x16_Key_New.png differ diff --git a/KeePass/Resources/Nuvola_Derived/B16x16_Window_2Horz1Vert.png b/KeePass/Resources/Nuvola_Derived/B16x16_Window_2Horz1Vert.png index 8ffb889..26f7b73 100644 Binary files a/KeePass/Resources/Nuvola_Derived/B16x16_Window_2Horz1Vert.png and b/KeePass/Resources/Nuvola_Derived/B16x16_Window_2Horz1Vert.png differ diff --git a/KeePass/Resources/Nuvola_Derived/B16x16_Window_3Horz.png b/KeePass/Resources/Nuvola_Derived/B16x16_Window_3Horz.png index d46201a..cd9e3bc 100644 Binary files a/KeePass/Resources/Nuvola_Derived/B16x16_Window_3Horz.png and b/KeePass/Resources/Nuvola_Derived/B16x16_Window_3Horz.png differ diff --git a/KeePass/UI/OpenWithMenu.cs b/KeePass/UI/OpenWithMenu.cs index b14d6bd..36b5ecb 100644 --- a/KeePass/UI/OpenWithMenu.cs +++ b/KeePass/UI/OpenWithMenu.cs @@ -238,9 +238,12 @@ private void FindAppsByKnown() if(NativeLib.IsUnix()) { AddAppByFile(AppLocator.FindAppUnix("epiphany-browser"), @"&Epiphany"); - AddAppByFile(AppLocator.FindAppUnix("arora"), @"&Arora"); AddAppByFile(AppLocator.FindAppUnix("galeon"), @"Ga&leon"); AddAppByFile(AppLocator.FindAppUnix("konqueror"), @"&Konqueror"); + AddAppByFile(AppLocator.FindAppUnix("rekonq"), @"&Rekonq"); + AddAppByFile(AppLocator.FindAppUnix("arora"), @"&Arora"); + AddAppByFile(AppLocator.FindAppUnix("midori"), @"&Midori"); + AddAppByFile(AppLocator.FindAppUnix("Dooble"), @"&Dooble"); // Upper-case } } @@ -254,22 +257,22 @@ private void FindAppsByRegistry() private void FindAppsByRegistryPriv(string strRootSubKey) { - RegistryKey kRoot = Registry.LocalMachine.OpenSubKey(strRootSubKey); + RegistryKey kRoot = Registry.LocalMachine.OpenSubKey(strRootSubKey, false); if(kRoot == null) return; // No assert, key might not exist string[] vAppSubKeys = kRoot.GetSubKeyNames(); foreach(string strAppSubKey in vAppSubKeys) { - RegistryKey kApp = kRoot.OpenSubKey(strAppSubKey); + RegistryKey kApp = kRoot.OpenSubKey(strAppSubKey, false); string strName = (kApp.GetValue(string.Empty) as string); string strAltName = null; - RegistryKey kCmd = kApp.OpenSubKey("shell\\open\\command"); + RegistryKey kCmd = kApp.OpenSubKey("shell\\open\\command", false); if(kCmd == null) { Debug.Assert(false); kApp.Close(); continue; } string strCmdLine = (kCmd.GetValue(string.Empty) as string); kCmd.Close(); - RegistryKey kCaps = kApp.OpenSubKey("Capabilities"); + RegistryKey kCaps = kApp.OpenSubKey("Capabilities", false); if(kCaps != null) { strAltName = (kCaps.GetValue("ApplicationName") as string); diff --git a/KeePass/Util/AppLocator.cs b/KeePass/Util/AppLocator.cs index 0b7c26b..7abc71b 100644 --- a/KeePass/Util/AppLocator.cs +++ b/KeePass/Util/AppLocator.cs @@ -76,7 +76,11 @@ private static string GetPath(int iBrwID, FindAppDelegate f) string strPath; if(m_dictPaths.TryGetValue(iBrwID, out strPath)) return strPath; - try { strPath = f(); } + try + { + strPath = f(); + if((strPath != null) && (strPath.Length == 0)) strPath = null; + } catch(Exception) { strPath = null; } m_dictPaths[iBrwID] = strPath; @@ -120,14 +124,12 @@ public static string FillPlaceholders(string strText, SprContext ctx) private static string FindInternetExplorer() { - RegistryKey kApps = Registry.ClassesRoot.OpenSubKey("Applications", false); - RegistryKey kIE = kApps.OpenSubKey("iexplore.exe", false); - RegistryKey kShell = kIE.OpenSubKey("shell", false); - RegistryKey kOpen = kShell.OpenSubKey("open", false); - RegistryKey kCommand = kOpen.OpenSubKey("command", false); - string strPath = (kCommand.GetValue(string.Empty) as string); + RegistryKey kCommand = Registry.ClassesRoot.OpenSubKey( + "Applications\\iexplore.exe\\shell\\open\\command", false); + if(kCommand == null) return null; - if(strPath != null) + string strPath = (kCommand.GetValue(string.Empty) as string); + if(!string.IsNullOrEmpty(strPath)) { strPath = strPath.Trim(); strPath = UrlUtil.GetQuotedAppPath(strPath).Trim(); @@ -135,10 +137,6 @@ private static string FindInternetExplorer() else { Debug.Assert(false); } kCommand.Close(); - kOpen.Close(); - kShell.Close(); - kIE.Close(); - kApps.Close(); return strPath; } @@ -158,28 +156,28 @@ private static string FindFirefox() private static string FindFirefoxPr(bool bWowNode) { - RegistryKey kSoftware = Registry.LocalMachine.OpenSubKey("SOFTWARE", false); - - RegistryKey kWow = (bWowNode ? kSoftware.OpenSubKey("Wow6432Node", false) : null); - - RegistryKey kMozilla = (kWow ?? kSoftware).OpenSubKey("Mozilla", false); - RegistryKey kFirefox = kMozilla.OpenSubKey("Mozilla Firefox", false); + RegistryKey kFirefox = Registry.LocalMachine.OpenSubKey(bWowNode ? + "SOFTWARE\\Wow6432Node\\Mozilla\\Mozilla Firefox" : + "SOFTWARE\\Mozilla\\Mozilla Firefox", false); + if(kFirefox == null) return null; string strCurVer = (kFirefox.GetValue("CurrentVersion") as string); - if((strCurVer == null) || (strCurVer.Length == 0)) + if(string.IsNullOrEmpty(strCurVer)) { kFirefox.Close(); - kMozilla.Close(); - if(kWow != null) kWow.Close(); - kSoftware.Close(); return null; } - RegistryKey kCurVer = kFirefox.OpenSubKey(strCurVer); - RegistryKey kMain = kCurVer.OpenSubKey("Main"); + RegistryKey kMain = kFirefox.OpenSubKey(strCurVer + "\\Main", false); + if(kMain == null) + { + Debug.Assert(false); + kFirefox.Close(); + return null; + } string strPath = (kMain.GetValue("PathToExe") as string); - if(strPath != null) + if(!string.IsNullOrEmpty(strPath)) { strPath = strPath.Trim(); strPath = UrlUtil.GetQuotedAppPath(strPath).Trim(); @@ -187,11 +185,7 @@ private static string FindFirefoxPr(bool bWowNode) else { Debug.Assert(false); } kMain.Close(); - kCurVer.Close(); kFirefox.Close(); - kMozilla.Close(); - if(kWow != null) kWow.Close(); - kSoftware.Close(); return strPath; } @@ -199,27 +193,22 @@ private static string FindOpera() { if(NativeLib.IsUnix()) return FindAppUnix("opera"); - RegistryKey kHtml = Registry.ClassesRoot.OpenSubKey("Opera.HTML", false); - RegistryKey kShell = kHtml.OpenSubKey("shell", false); - RegistryKey kOpen = kShell.OpenSubKey("open", false); - RegistryKey kCommand = kOpen.OpenSubKey("command", false); - string strPath = (kCommand.GetValue(string.Empty) as string); + RegistryKey kCommand = Registry.ClassesRoot.OpenSubKey( + "Opera.HTML\\shell\\open\\command", false); + if(kCommand == null) return null; - if((strPath != null) && (strPath.Length > 0)) + string strPath = (kCommand.GetValue(string.Empty) as string); + if(!string.IsNullOrEmpty(strPath)) { strPath = strPath.Trim(); strPath = UrlUtil.GetQuotedAppPath(strPath).Trim(); } - else strPath = null; + else { Debug.Assert(false); } kCommand.Close(); - kOpen.Close(); - kShell.Close(); - kHtml.Close(); return strPath; } - // HKEY_CLASSES_ROOT\\ChromeHTML\\shell\\open\\command private static string FindChrome() { if(NativeLib.IsUnix()) @@ -229,60 +218,80 @@ private static string FindChrome() return FindAppUnix("chromium-browser"); } + string strPath = FindChromeNew(); + if(string.IsNullOrEmpty(strPath)) + strPath = FindChromeOld(); + return strPath; + } + + // HKEY_CLASSES_ROOT\\ChromeHTML[.ID]\\shell\\open\\command + private static string FindChromeNew() + { RegistryKey kHtml = Registry.ClassesRoot.OpenSubKey("ChromeHTML", false); - RegistryKey kShell = kHtml.OpenSubKey("shell", false); - RegistryKey kOpen = kShell.OpenSubKey("open", false); - RegistryKey kCommand = kOpen.OpenSubKey("command", false); - string strPath = (kCommand.GetValue(string.Empty) as string); + if(kHtml == null) // New versions append an ID + { + string[] vKeys = Registry.ClassesRoot.GetSubKeyNames(); + foreach(string strEnum in vKeys) + { + if(strEnum.StartsWith("ChromeHTML.", StrUtil.CaseIgnoreCmp)) + { + kHtml = Registry.ClassesRoot.OpenSubKey(strEnum, false); + break; + } + } + + if(kHtml == null) return null; + } + + RegistryKey kCommand = kHtml.OpenSubKey("shell\\open\\command", false); + if(kCommand == null) + { + Debug.Assert(false); + kHtml.Close(); + return null; + } + string strPath = (kCommand.GetValue(string.Empty) as string); if(!string.IsNullOrEmpty(strPath)) { strPath = strPath.Trim(); strPath = UrlUtil.GetQuotedAppPath(strPath).Trim(); } - else strPath = null; + else { Debug.Assert(false); } kCommand.Close(); - kOpen.Close(); - kShell.Close(); kHtml.Close(); - return (strPath ?? FindChromeOld()); + return strPath; } // HKEY_CLASSES_ROOT\\Applications\\chrome.exe\\shell\\open\\command private static string FindChromeOld() { - RegistryKey kApps = Registry.ClassesRoot.OpenSubKey("Applications", false); - RegistryKey kExe = kApps.OpenSubKey("chrome.exe", false); - RegistryKey kShell = kExe.OpenSubKey("shell", false); - RegistryKey kOpen = kShell.OpenSubKey("open", false); - RegistryKey kCommand = kOpen.OpenSubKey("command", false); - string strPath = (kCommand.GetValue(string.Empty) as string); + RegistryKey kCommand = Registry.ClassesRoot.OpenSubKey( + "Applications\\chrome.exe\\shell\\open\\command", false); + if(kCommand == null) return null; + string strPath = (kCommand.GetValue(string.Empty) as string); if(!string.IsNullOrEmpty(strPath)) { strPath = strPath.Trim(); strPath = UrlUtil.GetQuotedAppPath(strPath).Trim(); } - else strPath = null; + else { Debug.Assert(false); } kCommand.Close(); - kOpen.Close(); - kShell.Close(); - kExe.Close(); - kApps.Close(); return strPath; } // HKEY_LOCAL_MACHINE\\SOFTWARE\\Apple Computer, Inc.\\Safari\\BrowserExe private static string FindSafari() { - RegistryKey kSoftware = Registry.LocalMachine.OpenSubKey("SOFTWARE", false); - RegistryKey kApple = kSoftware.OpenSubKey("Apple Computer, Inc.", false); - RegistryKey kSafari = kApple.OpenSubKey("Safari", false); - string strPath = (kSafari.GetValue("BrowserExe") as string); + RegistryKey kSafari = Registry.LocalMachine.OpenSubKey( + "SOFTWARE\\Apple Computer, Inc.\\Safari", false); + if(kSafari == null) return null; - if(strPath != null) + string strPath = (kSafari.GetValue("BrowserExe") as string); + if(!string.IsNullOrEmpty(strPath)) { strPath = strPath.Trim(); strPath = UrlUtil.GetQuotedAppPath(strPath).Trim(); @@ -290,8 +299,6 @@ private static string FindSafari() else { Debug.Assert(false); } kSafari.Close(); - kApple.Close(); - kSoftware.Close(); return strPath; } diff --git a/KeePass/Util/GlobalMutexPool.cs b/KeePass/Util/GlobalMutexPool.cs index 43964a8..8bf1813 100644 --- a/KeePass/Util/GlobalMutexPool.cs +++ b/KeePass/Util/GlobalMutexPool.cs @@ -201,7 +201,8 @@ public static void Refresh() private static string GetMutexPath(string strName) { - string strDir = UrlUtil.EnsureTerminatingSeparator(Path.GetTempPath(), false); + string strDir = UrlUtil.EnsureTerminatingSeparator( + UrlUtil.GetTempPath(), false); return (strDir + IpcUtilEx.IpcMsgFilePreID + IpcBroadcast.GetUserID() + "-Mutex-" + strName + ".tmp"); } diff --git a/KeePass/Util/IpcBroadcast.Fsw.cs b/KeePass/Util/IpcBroadcast.Fsw.cs index 6aed17b..f7ba4e4 100644 --- a/KeePass/Util/IpcBroadcast.Fsw.cs +++ b/KeePass/Util/IpcBroadcast.Fsw.cs @@ -49,7 +49,8 @@ private static void FswEnsurePaths() { if(m_strMsgFilePath != null) return; - string strDir = UrlUtil.EnsureTerminatingSeparator(Path.GetTempPath(), false); + string strDir = UrlUtil.EnsureTerminatingSeparator( + UrlUtil.GetTempPath(), false); m_strMsgFileName = IpcUtilEx.IpcMsgFilePreID + GetUserID() + IpcUtilEx.IpcMsgFilePostID; m_strMsgFilePath = strDir + m_strMsgFileName; @@ -109,7 +110,7 @@ private static void FswStartServer() { FswEnsurePaths(); - m_fsw = new FileSystemWatcher(Path.GetTempPath(), m_strMsgFileName); + m_fsw = new FileSystemWatcher(UrlUtil.GetTempPath(), m_strMsgFileName); m_fsw.IncludeSubdirectories = false; m_fsw.NotifyFilter = (NotifyFilters.CreationTime | NotifyFilters.LastWrite); diff --git a/KeePass/Util/IpcUtilEx.cs b/KeePass/Util/IpcUtilEx.cs index 247a111..3953c5a 100644 --- a/KeePass/Util/IpcUtilEx.cs +++ b/KeePass/Util/IpcUtilEx.cs @@ -115,7 +115,7 @@ private static string GetIpcFilePath(int nId) { try { - string str = Path.GetTempPath(); + string str = UrlUtil.GetTempPath(); str = UrlUtil.EnsureTerminatingSeparator(str, false); return (str + IpcMsgFilePreID + nId.ToString() + ".tmp"); diff --git a/KeePass/Util/SessionLockNotifier.cs b/KeePass/Util/SessionLockNotifier.cs index 276b3ef..b66f7ac 100644 --- a/KeePass/Util/SessionLockNotifier.cs +++ b/KeePass/Util/SessionLockNotifier.cs @@ -114,7 +114,9 @@ private void OnSessionSwitch(object sender, SessionSwitchEventArgs e) r = SessionLockReason.Lock; else if(e.Reason == SessionSwitchReason.SessionLogoff) r = SessionLockReason.Ending; - else if(e.Reason == SessionSwitchReason.SessionRemoteControl) + else if((e.Reason == SessionSwitchReason.SessionRemoteControl) || + (e.Reason == SessionSwitchReason.RemoteConnect) || + (e.Reason == SessionSwitchReason.RemoteDisconnect)) r = SessionLockReason.RemoteControlChange; if(r != SessionLockReason.Unknown) diff --git a/KeePass/Util/ShellUtil.cs b/KeePass/Util/ShellUtil.cs index 6f6674a..17dac7c 100644 --- a/KeePass/Util/ShellUtil.cs +++ b/KeePass/Util/ShellUtil.cs @@ -46,8 +46,8 @@ public static class ShellUtil try { kClassesRoot.CreateSubKey("." + strFileExt); } catch(Exception) { } RegistryKey kFileExt = kClassesRoot.OpenSubKey("." + strFileExt, true); - kFileExt.SetValue(string.Empty, strExtId, RegistryValueKind.String); + kFileExt.Close(); try { kClassesRoot.CreateSubKey(strExtId); } catch(Exception) { } @@ -58,11 +58,11 @@ public static class ShellUtil try { kExtInfo.CreateSubKey("DefaultIcon"); } catch(Exception) { } RegistryKey kIcon = kExtInfo.OpenSubKey("DefaultIcon", true); - if(strAppPath.IndexOfAny(new char[]{ ' ', '\t' }) < 0) kIcon.SetValue(string.Empty, strAppPath + ",0", RegistryValueKind.String); else kIcon.SetValue(string.Empty, "\"" + strAppPath + "\",0", RegistryValueKind.String); + kIcon.Close(); try { kExtInfo.CreateSubKey("shell"); } catch(Exception) { } @@ -77,8 +77,12 @@ public static class ShellUtil try { kShellOpen.CreateSubKey("command"); } catch(Exception) { } RegistryKey kShellCommand = kShellOpen.OpenSubKey("command", true); - kShellCommand.SetValue(string.Empty, "\"" + strAppPath + "\" \"%1\"", RegistryValueKind.String); + kShellCommand.Close(); + + kShellOpen.Close(); + kShell.Close(); + kExtInfo.Close(); ShChangeNotify(); @@ -128,6 +132,7 @@ private static void ShChangeNotify() { RegistryKey kRun = Registry.CurrentUser.OpenSubKey(AutoRunKey, true); kRun.DeleteValue(strAppName); + kRun.Close(); } } catch(Exception) { Debug.Assert(false); } @@ -138,8 +143,8 @@ public static bool GetStartWithWindows(string strAppName) try { string strNotFound = Guid.NewGuid().ToString(); - string strResult = Registry.GetValue("HKEY_CURRENT_USER\\" + AutoRunKey, - strAppName, strNotFound) as string; + string strResult = (Registry.GetValue("HKEY_CURRENT_USER\\" + AutoRunKey, + strAppName, strNotFound) as string); if((strResult != null) && (strResult != strNotFound) && (strResult.Length > 0)) @@ -171,6 +176,7 @@ public static bool GetStartWithWindows(string strAppName) { RegistryKey kRun = Registry.LocalMachine.OpenSubKey(PreLoadKey, true); kRun.DeleteValue(strAppName); + kRun.Close(); } } catch(Exception) { Debug.Assert(false); } diff --git a/KeePass/Util/TempFilesPool.cs b/KeePass/Util/TempFilesPool.cs index 9cc9e5b..97784bc 100644 --- a/KeePass/Util/TempFilesPool.cs +++ b/KeePass/Util/TempFilesPool.cs @@ -76,7 +76,7 @@ public void AddDirectory(string strTempDir, bool bDeleteRecursive) public string GetTempFileName() { - return this.GetTempFileName(true); + return GetTempFileName(true); } public string GetTempFileName(bool bCreateEmptyFile) diff --git a/KeePass/Util/WinUtil.cs b/KeePass/Util/WinUtil.cs index d068296..8e944e8 100644 --- a/KeePass/Util/WinUtil.cs +++ b/KeePass/Util/WinUtil.cs @@ -379,7 +379,7 @@ private static string FreeDriveIfCurrent(char chDriveLetter) char chCur = char.ToUpper(strCur[0]); if(chPar != chCur) return string.Empty; - string strTemp = Path.GetTempPath(); + string strTemp = UrlUtil.GetTempPath(); WinUtil.SetWorkingDirectory(strTemp); return strCur; diff --git a/KeePassLib/Native/NativeMethods.cs b/KeePassLib/Native/NativeMethods.cs index 87170bd..41bbd2e 100644 --- a/KeePassLib/Native/NativeMethods.cs +++ b/KeePassLib/Native/NativeMethods.cs @@ -21,6 +21,10 @@ using System.Text; using System.Security; using System.Runtime.InteropServices; +using System.IO; +using System.Diagnostics; + +using KeePassLib.Utility; namespace KeePassLib.Native { @@ -148,6 +152,27 @@ internal static int StrCmpNaturally(string x, string y) return x.CompareTo(y); #else return StrCmpLogicalW(x, y); +#endif + } + + internal static string GetUserRuntimeDir() + { +#if !KeePassLibSD + string strRtDir = Environment.GetEnvironmentVariable("XDG_RUNTIME_DIR"); + if(string.IsNullOrEmpty(strRtDir)) + strRtDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); + if(string.IsNullOrEmpty(strRtDir)) + { + Debug.Assert(false); + return Path.GetTempPath(); // Not UrlUtil (otherwise cyclic) + } + + strRtDir = UrlUtil.EnsureTerminatingSeparator(strRtDir, false); + strRtDir += PwDefs.ShortProductName; + + return strRtDir; +#else + return Path.GetTempPath(); #endif } } diff --git a/KeePassLib/Properties/AssemblyInfo.cs b/KeePassLib/Properties/AssemblyInfo.cs index 2fe2c41..a506eb0 100644 --- a/KeePassLib/Properties/AssemblyInfo.cs +++ b/KeePassLib/Properties/AssemblyInfo.cs @@ -38,5 +38,5 @@ [assembly: Guid("395f6eec-a1e0-4438-aa82-b75099348134")] // Assembly version information -[assembly: AssemblyVersion("2.20.0.*")] -[assembly: AssemblyFileVersion("2.20.0.0")] +[assembly: AssemblyVersion("2.20.1.*")] +[assembly: AssemblyFileVersion("2.20.1.0")] diff --git a/KeePassLib/PwDefs.cs b/KeePassLib/PwDefs.cs index d165d4b..3766103 100644 --- a/KeePassLib/PwDefs.cs +++ b/KeePassLib/PwDefs.cs @@ -54,18 +54,18 @@ public static class PwDefs /// e.g. 2.19 = 0x02130000. /// It is highly recommended to use FileVersion64 instead. /// - public const uint Version32 = 0x02140000; + public const uint Version32 = 0x02140100; /// /// Version, encoded as 64-bit unsigned integer /// (component-wise, 16 bits per component). /// - public const ulong FileVersion64 = 0x0002001400000000UL; + public const ulong FileVersion64 = 0x0002001400010000UL; /// /// Version, encoded as string. /// - public const string VersionString = "2.20"; + public const string VersionString = "2.20.1"; public const string Copyright = @"Copyright © 2003-2012 Dominik Reichl"; diff --git a/KeePassLib/Utility/AppLogEx.cs b/KeePassLib/Utility/AppLogEx.cs index c4d3afa..b1353e5 100644 --- a/KeePassLib/Utility/AppLogEx.cs +++ b/KeePassLib/Utility/AppLogEx.cs @@ -51,7 +51,7 @@ public static void Open(string strPrefix) string strDirSep = string.Empty; strDirSep += Path.DirectorySeparatorChar; - string strTemp = Path.GetTempPath(); + string strTemp = UrlUtil.GetTempPath(); if(!strTemp.EndsWith(strDirSep)) strTemp += strDirSep; diff --git a/KeePassLib/Utility/GfxUtil.cs b/KeePassLib/Utility/GfxUtil.cs index 5edf5c1..2b48740 100644 --- a/KeePassLib/Utility/GfxUtil.cs +++ b/KeePassLib/Utility/GfxUtil.cs @@ -54,20 +54,28 @@ private static Image LoadImagePriv(Stream s) { #if !KeePassLibSD imgSrc = Image.FromStream(s); - Image img = new Bitmap(imgSrc.Width, imgSrc.Height, + Bitmap bmp = new Bitmap(imgSrc.Width, imgSrc.Height, PixelFormat.Format32bppArgb); + + try + { + bmp.SetResolution(imgSrc.HorizontalResolution, + imgSrc.VerticalResolution); + Debug.Assert(bmp.Size == imgSrc.Size); + } + catch(Exception) { Debug.Assert(false); } #else imgSrc = new Bitmap(s); - Image img = new Bitmap(imgSrc.Width, imgSrc.Height); + Bitmap bmp = new Bitmap(imgSrc.Width, imgSrc.Height); #endif - using(Graphics g = Graphics.FromImage(img)) + using(Graphics g = Graphics.FromImage(bmp)) { g.Clear(Color.Transparent); g.DrawImage(imgSrc, 0, 0); } - return img; + return bmp; } finally { if(imgSrc != null) imgSrc.Dispose(); } } diff --git a/KeePassLib/Utility/UrlUtil.cs b/KeePassLib/Utility/UrlUtil.cs index 5d01cfd..178c081 100644 --- a/KeePassLib/Utility/UrlUtil.cs +++ b/KeePassLib/Utility/UrlUtil.cs @@ -20,9 +20,9 @@ using System; using System.Collections.Generic; using System.IO; -using System.Diagnostics; using System.Runtime.InteropServices; using System.Text; +using System.Diagnostics; using KeePassLib.Native; @@ -588,5 +588,22 @@ public static bool AssemblyEquals(string strExt, string strShort) return false; } + + public static string GetTempPath() + { + string strDir; + if(NativeLib.IsUnix()) + strDir = NativeMethods.GetUserRuntimeDir(); + else strDir = Path.GetTempPath(); + + try + { + if(Directory.Exists(strDir) == false) + Directory.CreateDirectory(strDir); + } + catch(Exception) { Debug.Assert(false); } + + return strDir; + } } } diff --git a/KeePassLibSD/Properties/AssemblyInfo.cs b/KeePassLibSD/Properties/AssemblyInfo.cs index 5cd83ff..47ffb10 100644 --- a/KeePassLibSD/Properties/AssemblyInfo.cs +++ b/KeePassLibSD/Properties/AssemblyInfo.cs @@ -38,4 +38,4 @@ [assembly: Guid("1d3c6f10-e10b-47be-a2f1-af2562d7d470")] // Assembly version information -[assembly: AssemblyVersion("2.20.0.*")] +[assembly: AssemblyVersion("2.20.1.*")] diff --git a/ShInstUtil/ShInstUtil.rc b/ShInstUtil/ShInstUtil.rc index 31cfe29..97955d5 100644 --- a/ShInstUtil/ShInstUtil.rc +++ b/ShInstUtil/ShInstUtil.rc @@ -65,8 +65,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,20,0,0 - PRODUCTVERSION 2,20,0,0 + FILEVERSION 2,20,1,0 + PRODUCTVERSION 2,20,1,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -83,12 +83,12 @@ BEGIN BEGIN VALUE "CompanyName", "Dominik Reichl" VALUE "FileDescription", "ShInstUtil - KeePass Helper Utility" - VALUE "FileVersion", "2, 20, 0, 0" + VALUE "FileVersion", "2, 20, 1, 0" VALUE "InternalName", "ShInstUtil" VALUE "LegalCopyright", "Copyright (c) 2007-2012 Dominik Reichl" VALUE "OriginalFilename", "ShInstUtil.exe" VALUE "ProductName", "ShInstUtil - KeePass Helper Utility" - VALUE "ProductVersion", "2, 20, 0, 0" + VALUE "ProductVersion", "2, 20, 1, 0" END END BLOCK "VarFileInfo" diff --git a/Translation/TrlUtil/Properties/AssemblyInfo.cs b/Translation/TrlUtil/Properties/AssemblyInfo.cs index e45e4fa..51a3108 100644 --- a/Translation/TrlUtil/Properties/AssemblyInfo.cs +++ b/Translation/TrlUtil/Properties/AssemblyInfo.cs @@ -38,5 +38,5 @@ [assembly: Guid("39aa6f93-a1c9-497f-bad2-cc42a61d5710")] // Assembly version information -[assembly: AssemblyVersion("2.20.0.*")] -[assembly: AssemblyFileVersion("2.20.0.0")] +[assembly: AssemblyVersion("2.20.1.*")] +[assembly: AssemblyFileVersion("2.20.1.0")]