keepass2-2.25/0000775000175000017500000000000012300124171013102 5ustar jtaylorjtaylorkeepass2-2.25/Translation/0000775000175000017500000000000012273663444015424 5ustar jtaylorjtaylorkeepass2-2.25/Translation/DefaultTextSD.xml0000664000175000017500000000034011105612640020604 0ustar jtaylorjtaylor Test keepass2-2.25/Translation/DefaultUpdateCs.bat0000664000175000017500000000046611176572202021127 0ustar jtaylorjtaylorTrlUtil.exe src_from_xml DefaultText.xml MOVE /Y KPRes.Generated.cs ..\KeePass\Resources\KPRes.Generated.cs MOVE /Y KLRes.Generated.cs ..\KeePassLib\Resources\KLRes.Generated.cs TrlUtil.exe src_from_xml DefaultTextSD.xml MOVE /Y KSRes.Generated.cs ..\KeePassLib\Resources\KSRes.Generated.cs PAUSE CLSkeepass2-2.25/Translation/TrlUtil/0000775000175000017500000000000012273663444017023 5ustar jtaylorjtaylorkeepass2-2.25/Translation/TrlUtil/MainForm.Designer.cs0000664000175000017500000011421712172725654022627 0ustar jtaylorjtaylornamespace TrlUtil { partial class MainForm { /// /// 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() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.m_tabMain = new System.Windows.Forms.TabControl(); this.m_tabProps = new System.Windows.Forms.TabPage(); this.m_cbRtl = new System.Windows.Forms.CheckBox(); this.m_lblAuthorContact = new System.Windows.Forms.Label(); this.m_tbAuthorContact = new System.Windows.Forms.TextBox(); this.m_linkLangCode = new System.Windows.Forms.LinkLabel(); this.m_lblLangIDSample = new System.Windows.Forms.Label(); this.m_tbLangID = new System.Windows.Forms.TextBox(); this.m_lblLangID = new System.Windows.Forms.Label(); this.m_lblAuthorName = new System.Windows.Forms.Label(); this.m_tbAuthorName = new System.Windows.Forms.TextBox(); this.m_lblNameLclSample = new System.Windows.Forms.Label(); this.m_tbNameLcl = new System.Windows.Forms.TextBox(); this.m_lblNameLcl = new System.Windows.Forms.Label(); this.m_lblNameEngSample = new System.Windows.Forms.Label(); this.m_lblNameEng = new System.Windows.Forms.Label(); this.m_tbNameEng = new System.Windows.Forms.TextBox(); this.m_tabStrings = new System.Windows.Forms.TabPage(); this.m_lblStrSaveHint = new System.Windows.Forms.Label(); this.m_tbStrTrl = new System.Windows.Forms.TextBox(); this.m_tbStrEng = new System.Windows.Forms.TextBox(); this.m_lblStrTrl = new System.Windows.Forms.Label(); this.m_lblStrEng = new System.Windows.Forms.Label(); this.m_lvStrings = new KeePass.UI.CustomListViewEx(); this.m_tabDialogs = new System.Windows.Forms.TabPage(); this.m_lblIconColorHint = new System.Windows.Forms.Label(); this.m_grpControl = new System.Windows.Forms.GroupBox(); this.m_grpControlLayout = new System.Windows.Forms.GroupBox(); this.m_lblLayoutHint2 = new System.Windows.Forms.Label(); this.m_lblLayoutHint = new System.Windows.Forms.Label(); this.m_tbLayoutH = new System.Windows.Forms.TextBox(); this.m_tbLayoutW = new System.Windows.Forms.TextBox(); this.m_tbLayoutY = new System.Windows.Forms.TextBox(); this.m_tbLayoutX = new System.Windows.Forms.TextBox(); this.m_lblLayoutH = new System.Windows.Forms.Label(); this.m_lblLayoutW = new System.Windows.Forms.Label(); this.m_lblLayoutY = new System.Windows.Forms.Label(); this.m_lblLayoutX = new System.Windows.Forms.Label(); this.m_tbCtrlTrlText = new System.Windows.Forms.TextBox(); this.m_tbCtrlEngText = new System.Windows.Forms.TextBox(); this.m_lblCtrlTrlText = new System.Windows.Forms.Label(); this.m_lblCtrlEngText = new System.Windows.Forms.Label(); this.m_tvControls = new System.Windows.Forms.TreeView(); this.m_tabUnusedText = new System.Windows.Forms.TabPage(); this.m_btnClearUnusedText = new System.Windows.Forms.Button(); this.m_rtbUnusedText = new KeePass.UI.CustomRichTextBoxEx(); this.m_menuMain = new KeePass.UI.CustomMenuStripEx(); this.m_menuFile = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileOpen = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSave = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSaveAs = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuFileImport = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileImportLng = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileImportPo = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileImportSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuFileImport2xNoChecks = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSep1 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuFileExit = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuEdit = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuEditNextUntrl = new System.Windows.Forms.ToolStripMenuItem(); this.m_tsMain = new KeePass.UI.CustomToolStripEx(); this.m_tbOpen = new System.Windows.Forms.ToolStripButton(); this.m_tbSave = new System.Windows.Forms.ToolStripButton(); this.m_tbSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_tbNextUntrl = new System.Windows.Forms.ToolStripButton(); this.m_tbSep1 = new System.Windows.Forms.ToolStripSeparator(); this.m_tbFind = new System.Windows.Forms.ToolStripTextBox(); this.m_tabMain.SuspendLayout(); this.m_tabProps.SuspendLayout(); this.m_tabStrings.SuspendLayout(); this.m_tabDialogs.SuspendLayout(); this.m_grpControl.SuspendLayout(); this.m_grpControlLayout.SuspendLayout(); this.m_tabUnusedText.SuspendLayout(); this.m_menuMain.SuspendLayout(); this.m_tsMain.SuspendLayout(); this.SuspendLayout(); // // m_tabMain // this.m_tabMain.Controls.Add(this.m_tabProps); this.m_tabMain.Controls.Add(this.m_tabStrings); this.m_tabMain.Controls.Add(this.m_tabDialogs); this.m_tabMain.Controls.Add(this.m_tabUnusedText); this.m_tabMain.Location = new System.Drawing.Point(12, 53); this.m_tabMain.Name = "m_tabMain"; this.m_tabMain.SelectedIndex = 0; this.m_tabMain.Size = new System.Drawing.Size(605, 461); this.m_tabMain.TabIndex = 0; this.m_tabMain.SelectedIndexChanged += new System.EventHandler(this.OnTabMainSelectedIndexChanged); // // m_tabProps // this.m_tabProps.Controls.Add(this.m_cbRtl); this.m_tabProps.Controls.Add(this.m_lblAuthorContact); this.m_tabProps.Controls.Add(this.m_tbAuthorContact); this.m_tabProps.Controls.Add(this.m_linkLangCode); this.m_tabProps.Controls.Add(this.m_lblLangIDSample); this.m_tabProps.Controls.Add(this.m_tbLangID); this.m_tabProps.Controls.Add(this.m_lblLangID); this.m_tabProps.Controls.Add(this.m_lblAuthorName); this.m_tabProps.Controls.Add(this.m_tbAuthorName); this.m_tabProps.Controls.Add(this.m_lblNameLclSample); this.m_tabProps.Controls.Add(this.m_tbNameLcl); this.m_tabProps.Controls.Add(this.m_lblNameLcl); this.m_tabProps.Controls.Add(this.m_lblNameEngSample); this.m_tabProps.Controls.Add(this.m_lblNameEng); this.m_tabProps.Controls.Add(this.m_tbNameEng); this.m_tabProps.Location = new System.Drawing.Point(4, 22); this.m_tabProps.Name = "m_tabProps"; this.m_tabProps.Padding = new System.Windows.Forms.Padding(3); this.m_tabProps.Size = new System.Drawing.Size(597, 435); this.m_tabProps.TabIndex = 0; this.m_tabProps.Text = "Properties"; this.m_tabProps.UseVisualStyleBackColor = true; // // m_cbRtl // this.m_cbRtl.AutoSize = true; this.m_cbRtl.Location = new System.Drawing.Point(9, 238); this.m_cbRtl.Name = "m_cbRtl"; this.m_cbRtl.Size = new System.Drawing.Size(149, 17); this.m_cbRtl.TabIndex = 14; this.m_cbRtl.Text = "Script is written right-to-left"; this.m_cbRtl.UseVisualStyleBackColor = true; // // m_lblAuthorContact // this.m_lblAuthorContact.AutoSize = true; this.m_lblAuthorContact.Location = new System.Drawing.Point(6, 206); this.m_lblAuthorContact.Name = "m_lblAuthorContact"; this.m_lblAuthorContact.Size = new System.Drawing.Size(80, 13); this.m_lblAuthorContact.TabIndex = 12; this.m_lblAuthorContact.Text = "Author contact:"; // // m_tbAuthorContact // this.m_tbAuthorContact.Location = new System.Drawing.Point(147, 203); this.m_tbAuthorContact.Name = "m_tbAuthorContact"; this.m_tbAuthorContact.Size = new System.Drawing.Size(435, 20); this.m_tbAuthorContact.TabIndex = 13; // // m_linkLangCode // this.m_linkLangCode.AutoSize = true; this.m_linkLangCode.Location = new System.Drawing.Point(144, 151); this.m_linkLangCode.Name = "m_linkLangCode"; this.m_linkLangCode.Size = new System.Drawing.Size(156, 13); this.m_linkLangCode.TabIndex = 9; this.m_linkLangCode.TabStop = true; this.m_linkLangCode.Text = "See ISO 639-1 language codes"; this.m_linkLangCode.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.OnLinkLangCodeClicked); // // m_lblLangIDSample // this.m_lblLangIDSample.AutoSize = true; this.m_lblLangIDSample.Location = new System.Drawing.Point(144, 135); this.m_lblLangIDSample.Name = "m_lblLangIDSample"; this.m_lblLangIDSample.Size = new System.Drawing.Size(65, 13); this.m_lblLangIDSample.TabIndex = 8; this.m_lblLangIDSample.Text = "Example: de"; // // m_tbLangID // this.m_tbLangID.Location = new System.Drawing.Point(147, 112); this.m_tbLangID.Name = "m_tbLangID"; this.m_tbLangID.Size = new System.Drawing.Size(435, 20); this.m_tbLangID.TabIndex = 7; // // m_lblLangID // this.m_lblLangID.AutoSize = true; this.m_lblLangID.Location = new System.Drawing.Point(6, 115); this.m_lblLangID.Name = "m_lblLangID"; this.m_lblLangID.Size = new System.Drawing.Size(132, 13); this.m_lblLangID.TabIndex = 6; this.m_lblLangID.Text = "ISO 639-1 language code:"; // // m_lblAuthorName // this.m_lblAuthorName.AutoSize = true; this.m_lblAuthorName.Location = new System.Drawing.Point(6, 180); this.m_lblAuthorName.Name = "m_lblAuthorName"; this.m_lblAuthorName.Size = new System.Drawing.Size(70, 13); this.m_lblAuthorName.TabIndex = 10; this.m_lblAuthorName.Text = "Author name:"; // // m_tbAuthorName // this.m_tbAuthorName.Location = new System.Drawing.Point(147, 177); this.m_tbAuthorName.Name = "m_tbAuthorName"; this.m_tbAuthorName.Size = new System.Drawing.Size(435, 20); this.m_tbAuthorName.TabIndex = 11; // // m_lblNameLclSample // this.m_lblNameLclSample.AutoSize = true; this.m_lblNameLclSample.Location = new System.Drawing.Point(144, 86); this.m_lblNameLclSample.Name = "m_lblNameLclSample"; this.m_lblNameLclSample.Size = new System.Drawing.Size(93, 13); this.m_lblNameLclSample.TabIndex = 5; this.m_lblNameLclSample.Text = "Example: Deutsch"; // // m_tbNameLcl // this.m_tbNameLcl.Location = new System.Drawing.Point(147, 63); this.m_tbNameLcl.Name = "m_tbNameLcl"; this.m_tbNameLcl.Size = new System.Drawing.Size(435, 20); this.m_tbNameLcl.TabIndex = 4; // // m_lblNameLcl // this.m_lblNameLcl.AutoSize = true; this.m_lblNameLcl.Location = new System.Drawing.Point(6, 66); this.m_lblNameLcl.Name = "m_lblNameLcl"; this.m_lblNameLcl.Size = new System.Drawing.Size(117, 13); this.m_lblNameLcl.TabIndex = 3; this.m_lblNameLcl.Text = "Native language name:"; // // m_lblNameEngSample // this.m_lblNameEngSample.AutoSize = true; this.m_lblNameEngSample.Location = new System.Drawing.Point(144, 38); this.m_lblNameEngSample.Name = "m_lblNameEngSample"; this.m_lblNameEngSample.Size = new System.Drawing.Size(90, 13); this.m_lblNameEngSample.TabIndex = 2; this.m_lblNameEngSample.Text = "Example: German"; // // m_lblNameEng // this.m_lblNameEng.AutoSize = true; this.m_lblNameEng.Location = new System.Drawing.Point(6, 18); this.m_lblNameEng.Name = "m_lblNameEng"; this.m_lblNameEng.Size = new System.Drawing.Size(120, 13); this.m_lblNameEng.TabIndex = 0; this.m_lblNameEng.Text = "English language name:"; // // m_tbNameEng // this.m_tbNameEng.Location = new System.Drawing.Point(147, 15); this.m_tbNameEng.Name = "m_tbNameEng"; this.m_tbNameEng.Size = new System.Drawing.Size(435, 20); this.m_tbNameEng.TabIndex = 1; // // m_tabStrings // this.m_tabStrings.Controls.Add(this.m_lblStrSaveHint); this.m_tabStrings.Controls.Add(this.m_tbStrTrl); this.m_tabStrings.Controls.Add(this.m_tbStrEng); this.m_tabStrings.Controls.Add(this.m_lblStrTrl); this.m_tabStrings.Controls.Add(this.m_lblStrEng); this.m_tabStrings.Controls.Add(this.m_lvStrings); this.m_tabStrings.Location = new System.Drawing.Point(4, 22); this.m_tabStrings.Name = "m_tabStrings"; this.m_tabStrings.Padding = new System.Windows.Forms.Padding(3); this.m_tabStrings.Size = new System.Drawing.Size(597, 435); this.m_tabStrings.TabIndex = 1; this.m_tabStrings.Text = "String Tables"; this.m_tabStrings.UseVisualStyleBackColor = true; // // m_lblStrSaveHint // this.m_lblStrSaveHint.AutoSize = true; this.m_lblStrSaveHint.Location = new System.Drawing.Point(66, 410); this.m_lblStrSaveHint.Name = "m_lblStrSaveHint"; this.m_lblStrSaveHint.Size = new System.Drawing.Size(248, 13); this.m_lblStrSaveHint.TabIndex = 5; this.m_lblStrSaveHint.Text = "Press [Return] to save/accept the translated string."; // // m_tbStrTrl // this.m_tbStrTrl.Location = new System.Drawing.Point(69, 387); this.m_tbStrTrl.Name = "m_tbStrTrl"; this.m_tbStrTrl.Size = new System.Drawing.Size(522, 20); this.m_tbStrTrl.TabIndex = 4; this.m_tbStrTrl.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnStrKeyDown); this.m_tbStrTrl.KeyUp += new System.Windows.Forms.KeyEventHandler(this.OnStrKeyUp); // // m_tbStrEng // this.m_tbStrEng.Location = new System.Drawing.Point(69, 328); this.m_tbStrEng.Multiline = true; this.m_tbStrEng.Name = "m_tbStrEng"; this.m_tbStrEng.ReadOnly = true; this.m_tbStrEng.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.m_tbStrEng.Size = new System.Drawing.Size(522, 53); this.m_tbStrEng.TabIndex = 2; // // m_lblStrTrl // this.m_lblStrTrl.AutoSize = true; this.m_lblStrTrl.Location = new System.Drawing.Point(3, 390); this.m_lblStrTrl.Name = "m_lblStrTrl"; this.m_lblStrTrl.Size = new System.Drawing.Size(60, 13); this.m_lblStrTrl.TabIndex = 3; this.m_lblStrTrl.Text = "Translated:"; // // m_lblStrEng // this.m_lblStrEng.AutoSize = true; this.m_lblStrEng.Location = new System.Drawing.Point(3, 331); this.m_lblStrEng.Name = "m_lblStrEng"; this.m_lblStrEng.Size = new System.Drawing.Size(44, 13); this.m_lblStrEng.TabIndex = 1; this.m_lblStrEng.Text = "English:"; // // m_lvStrings // this.m_lvStrings.FullRowSelect = true; this.m_lvStrings.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; this.m_lvStrings.HideSelection = false; this.m_lvStrings.Location = new System.Drawing.Point(6, 6); this.m_lvStrings.MultiSelect = false; this.m_lvStrings.Name = "m_lvStrings"; this.m_lvStrings.ShowItemToolTips = true; this.m_lvStrings.Size = new System.Drawing.Size(585, 316); this.m_lvStrings.TabIndex = 0; this.m_lvStrings.UseCompatibleStateImageBehavior = false; this.m_lvStrings.View = System.Windows.Forms.View.Details; this.m_lvStrings.SelectedIndexChanged += new System.EventHandler(this.OnStringsSelectedIndexChanged); this.m_lvStrings.DoubleClick += new System.EventHandler(this.OnStrDoubleClick); // // m_tabDialogs // this.m_tabDialogs.Controls.Add(this.m_lblIconColorHint); this.m_tabDialogs.Controls.Add(this.m_grpControl); this.m_tabDialogs.Controls.Add(this.m_tvControls); this.m_tabDialogs.Location = new System.Drawing.Point(4, 22); this.m_tabDialogs.Name = "m_tabDialogs"; this.m_tabDialogs.Size = new System.Drawing.Size(597, 435); this.m_tabDialogs.TabIndex = 2; this.m_tabDialogs.Text = "Dialogs"; this.m_tabDialogs.UseVisualStyleBackColor = true; // // m_lblIconColorHint // this.m_lblIconColorHint.AutoSize = true; this.m_lblIconColorHint.Location = new System.Drawing.Point(221, 407); this.m_lblIconColorHint.Name = "m_lblIconColorHint"; this.m_lblIconColorHint.Size = new System.Drawing.Size(307, 13); this.m_lblIconColorHint.TabIndex = 5; this.m_lblIconColorHint.Text = "In a correct translation, all icons in the tree on the left are green."; // // m_grpControl // this.m_grpControl.Controls.Add(this.m_grpControlLayout); this.m_grpControl.Controls.Add(this.m_tbCtrlTrlText); this.m_grpControl.Controls.Add(this.m_tbCtrlEngText); this.m_grpControl.Controls.Add(this.m_lblCtrlTrlText); this.m_grpControl.Controls.Add(this.m_lblCtrlEngText); this.m_grpControl.Location = new System.Drawing.Point(224, 6); this.m_grpControl.Name = "m_grpControl"; this.m_grpControl.Size = new System.Drawing.Size(367, 357); this.m_grpControl.TabIndex = 1; this.m_grpControl.TabStop = false; this.m_grpControl.Text = "Selected Control"; // // m_grpControlLayout // this.m_grpControlLayout.Controls.Add(this.m_lblLayoutHint2); this.m_grpControlLayout.Controls.Add(this.m_lblLayoutHint); this.m_grpControlLayout.Controls.Add(this.m_tbLayoutH); this.m_grpControlLayout.Controls.Add(this.m_tbLayoutW); this.m_grpControlLayout.Controls.Add(this.m_tbLayoutY); this.m_grpControlLayout.Controls.Add(this.m_tbLayoutX); this.m_grpControlLayout.Controls.Add(this.m_lblLayoutH); this.m_grpControlLayout.Controls.Add(this.m_lblLayoutW); this.m_grpControlLayout.Controls.Add(this.m_lblLayoutY); this.m_grpControlLayout.Controls.Add(this.m_lblLayoutX); this.m_grpControlLayout.Location = new System.Drawing.Point(9, 174); this.m_grpControlLayout.Name = "m_grpControlLayout"; this.m_grpControlLayout.Size = new System.Drawing.Size(352, 174); this.m_grpControlLayout.TabIndex = 4; this.m_grpControlLayout.TabStop = false; this.m_grpControlLayout.Text = "Layout"; // // m_lblLayoutHint2 // this.m_lblLayoutHint2.Location = new System.Drawing.Point(6, 127); this.m_lblLayoutHint2.Name = "m_lblLayoutHint2"; this.m_lblLayoutHint2.Size = new System.Drawing.Size(340, 40); this.m_lblLayoutHint2.TabIndex = 9; this.m_lblLayoutHint2.Text = "The values must be entered according to the \"en-US\" culture, i.e. the decimal poi" + "nt is represented by a dot (.), the negative sign is leading the number."; // // m_lblLayoutHint // this.m_lblLayoutHint.Location = new System.Drawing.Point(6, 77); this.m_lblLayoutHint.Name = "m_lblLayoutHint"; this.m_lblLayoutHint.Size = new System.Drawing.Size(340, 41); this.m_lblLayoutHint.TabIndex = 8; this.m_lblLayoutHint.Text = "All values need be entered in % relative to the current position/size. For exampl" + "e, entering -50 in the width field will shrink the control\'s width to half of it" + "s previous value."; // // m_tbLayoutH // this.m_tbLayoutH.Location = new System.Drawing.Point(246, 45); this.m_tbLayoutH.Name = "m_tbLayoutH"; this.m_tbLayoutH.Size = new System.Drawing.Size(100, 20); this.m_tbLayoutH.TabIndex = 7; this.m_tbLayoutH.TextChanged += new System.EventHandler(this.OnLayoutHeightTextChanged); // // m_tbLayoutW // this.m_tbLayoutW.Location = new System.Drawing.Point(53, 45); this.m_tbLayoutW.Name = "m_tbLayoutW"; this.m_tbLayoutW.Size = new System.Drawing.Size(100, 20); this.m_tbLayoutW.TabIndex = 5; this.m_tbLayoutW.TextChanged += new System.EventHandler(this.OnLayoutWidthTextChanged); // // m_tbLayoutY // this.m_tbLayoutY.Location = new System.Drawing.Point(246, 19); this.m_tbLayoutY.Name = "m_tbLayoutY"; this.m_tbLayoutY.Size = new System.Drawing.Size(100, 20); this.m_tbLayoutY.TabIndex = 3; this.m_tbLayoutY.TextChanged += new System.EventHandler(this.OnLayoutYTextChanged); // // m_tbLayoutX // this.m_tbLayoutX.Location = new System.Drawing.Point(53, 19); this.m_tbLayoutX.Name = "m_tbLayoutX"; this.m_tbLayoutX.Size = new System.Drawing.Size(100, 20); this.m_tbLayoutX.TabIndex = 1; this.m_tbLayoutX.TextChanged += new System.EventHandler(this.OnLayoutXTextChanged); // // m_lblLayoutH // this.m_lblLayoutH.AutoSize = true; this.m_lblLayoutH.Location = new System.Drawing.Point(199, 48); this.m_lblLayoutH.Name = "m_lblLayoutH"; this.m_lblLayoutH.Size = new System.Drawing.Size(41, 13); this.m_lblLayoutH.TabIndex = 6; this.m_lblLayoutH.Text = "Height:"; // // m_lblLayoutW // this.m_lblLayoutW.AutoSize = true; this.m_lblLayoutW.Location = new System.Drawing.Point(6, 48); this.m_lblLayoutW.Name = "m_lblLayoutW"; this.m_lblLayoutW.Size = new System.Drawing.Size(38, 13); this.m_lblLayoutW.TabIndex = 4; this.m_lblLayoutW.Text = "Width:"; // // m_lblLayoutY // this.m_lblLayoutY.AutoSize = true; this.m_lblLayoutY.Location = new System.Drawing.Point(199, 22); this.m_lblLayoutY.Name = "m_lblLayoutY"; this.m_lblLayoutY.Size = new System.Drawing.Size(17, 13); this.m_lblLayoutY.TabIndex = 2; this.m_lblLayoutY.Text = "Y:"; // // m_lblLayoutX // this.m_lblLayoutX.AutoSize = true; this.m_lblLayoutX.Location = new System.Drawing.Point(6, 22); this.m_lblLayoutX.Name = "m_lblLayoutX"; this.m_lblLayoutX.Size = new System.Drawing.Size(17, 13); this.m_lblLayoutX.TabIndex = 0; this.m_lblLayoutX.Text = "X:"; // // m_tbCtrlTrlText // this.m_tbCtrlTrlText.Location = new System.Drawing.Point(9, 113); this.m_tbCtrlTrlText.Name = "m_tbCtrlTrlText"; this.m_tbCtrlTrlText.Size = new System.Drawing.Size(352, 20); this.m_tbCtrlTrlText.TabIndex = 3; this.m_tbCtrlTrlText.TextChanged += new System.EventHandler(this.OnCtrlTrlTextChanged); this.m_tbCtrlTrlText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnCtrlTrlTextKeyDown); this.m_tbCtrlTrlText.KeyUp += new System.Windows.Forms.KeyEventHandler(this.OnCtrlTrlTextKeyUp); // // m_tbCtrlEngText // this.m_tbCtrlEngText.Location = new System.Drawing.Point(9, 41); this.m_tbCtrlEngText.Multiline = true; this.m_tbCtrlEngText.Name = "m_tbCtrlEngText"; this.m_tbCtrlEngText.ReadOnly = true; this.m_tbCtrlEngText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.m_tbCtrlEngText.Size = new System.Drawing.Size(352, 53); this.m_tbCtrlEngText.TabIndex = 1; // // m_lblCtrlTrlText // this.m_lblCtrlTrlText.AutoSize = true; this.m_lblCtrlTrlText.Location = new System.Drawing.Point(6, 97); this.m_lblCtrlTrlText.Name = "m_lblCtrlTrlText"; this.m_lblCtrlTrlText.Size = new System.Drawing.Size(60, 13); this.m_lblCtrlTrlText.TabIndex = 2; this.m_lblCtrlTrlText.Text = "Translated:"; // // m_lblCtrlEngText // this.m_lblCtrlEngText.AutoSize = true; this.m_lblCtrlEngText.Location = new System.Drawing.Point(6, 25); this.m_lblCtrlEngText.Name = "m_lblCtrlEngText"; this.m_lblCtrlEngText.Size = new System.Drawing.Size(44, 13); this.m_lblCtrlEngText.TabIndex = 0; this.m_lblCtrlEngText.Text = "English:"; // // m_tvControls // this.m_tvControls.HideSelection = false; this.m_tvControls.Location = new System.Drawing.Point(6, 6); this.m_tvControls.Name = "m_tvControls"; this.m_tvControls.ShowNodeToolTips = true; this.m_tvControls.ShowRootLines = false; this.m_tvControls.Size = new System.Drawing.Size(200, 423); this.m_tvControls.TabIndex = 0; this.m_tvControls.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.OnCustomControlsAfterSelect); // // m_tabUnusedText // this.m_tabUnusedText.Controls.Add(this.m_btnClearUnusedText); this.m_tabUnusedText.Controls.Add(this.m_rtbUnusedText); this.m_tabUnusedText.Location = new System.Drawing.Point(4, 22); this.m_tabUnusedText.Name = "m_tabUnusedText"; this.m_tabUnusedText.Padding = new System.Windows.Forms.Padding(3); this.m_tabUnusedText.Size = new System.Drawing.Size(597, 435); this.m_tabUnusedText.TabIndex = 3; this.m_tabUnusedText.Text = "Unused Text"; this.m_tabUnusedText.UseVisualStyleBackColor = true; // // m_btnClearUnusedText // this.m_btnClearUnusedText.Location = new System.Drawing.Point(516, 406); this.m_btnClearUnusedText.Name = "m_btnClearUnusedText"; this.m_btnClearUnusedText.Size = new System.Drawing.Size(75, 23); this.m_btnClearUnusedText.TabIndex = 1; this.m_btnClearUnusedText.Text = "&Clear"; this.m_btnClearUnusedText.UseVisualStyleBackColor = true; this.m_btnClearUnusedText.Click += new System.EventHandler(this.OnBtnClearUnusedText); // // m_rtbUnusedText // this.m_rtbUnusedText.Location = new System.Drawing.Point(6, 6); this.m_rtbUnusedText.Name = "m_rtbUnusedText"; this.m_rtbUnusedText.Size = new System.Drawing.Size(585, 394); this.m_rtbUnusedText.TabIndex = 0; this.m_rtbUnusedText.Text = ""; // // m_menuMain // this.m_menuMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuFile, this.m_menuEdit}); this.m_menuMain.Location = new System.Drawing.Point(0, 0); this.m_menuMain.Name = "m_menuMain"; this.m_menuMain.Size = new System.Drawing.Size(629, 24); this.m_menuMain.TabIndex = 1; this.m_menuMain.TabStop = true; // // m_menuFile // this.m_menuFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuFileOpen, this.m_menuFileSave, this.m_menuFileSaveAs, this.m_menuFileSep0, this.m_menuFileImport, this.m_menuFileSep1, this.m_menuFileExit}); this.m_menuFile.Name = "m_menuFile"; this.m_menuFile.Size = new System.Drawing.Size(39, 20); this.m_menuFile.Text = "&File"; // // m_menuFileOpen // this.m_menuFileOpen.Image = global::TrlUtil.Properties.Resources.B16x16_Folder_Yellow_Open; this.m_menuFileOpen.Name = "m_menuFileOpen"; this.m_menuFileOpen.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); this.m_menuFileOpen.Size = new System.Drawing.Size(154, 22); this.m_menuFileOpen.Text = "&Open..."; this.m_menuFileOpen.Click += new System.EventHandler(this.OnFileOpen); // // m_menuFileSave // this.m_menuFileSave.Image = global::TrlUtil.Properties.Resources.B16x16_FileSave; this.m_menuFileSave.Name = "m_menuFileSave"; this.m_menuFileSave.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); this.m_menuFileSave.Size = new System.Drawing.Size(154, 22); this.m_menuFileSave.Text = "&Save"; this.m_menuFileSave.Click += new System.EventHandler(this.OnFileSave); // // m_menuFileSaveAs // this.m_menuFileSaveAs.Image = global::TrlUtil.Properties.Resources.B16x16_FileSaveAs; this.m_menuFileSaveAs.Name = "m_menuFileSaveAs"; this.m_menuFileSaveAs.Size = new System.Drawing.Size(154, 22); this.m_menuFileSaveAs.Text = "Save &As..."; this.m_menuFileSaveAs.Click += new System.EventHandler(this.OnFileSaveAs); // // m_menuFileSep0 // this.m_menuFileSep0.Name = "m_menuFileSep0"; this.m_menuFileSep0.Size = new System.Drawing.Size(151, 6); // // m_menuFileImport // this.m_menuFileImport.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuFileImportLng, this.m_menuFileImportPo, this.m_menuFileImportSep0, this.m_menuFileImport2xNoChecks}); this.m_menuFileImport.Name = "m_menuFileImport"; this.m_menuFileImport.Size = new System.Drawing.Size(154, 22); this.m_menuFileImport.Text = "&Import"; // // m_menuFileImportLng // this.m_menuFileImportLng.Name = "m_menuFileImportLng"; this.m_menuFileImportLng.Size = new System.Drawing.Size(311, 22); this.m_menuFileImportLng.Text = "KeePass &1.x LNG File..."; this.m_menuFileImportLng.Click += new System.EventHandler(this.OnImport1xLng); // // m_menuFileImportPo // this.m_menuFileImportPo.Name = "m_menuFileImportPo"; this.m_menuFileImportPo.Size = new System.Drawing.Size(311, 22); this.m_menuFileImportPo.Text = "&PO File..."; this.m_menuFileImportPo.Click += new System.EventHandler(this.OnImportPo); // // m_menuFileImportSep0 // this.m_menuFileImportSep0.Name = "m_menuFileImportSep0"; this.m_menuFileImportSep0.Size = new System.Drawing.Size(308, 6); // // m_menuFileImport2xNoChecks // this.m_menuFileImport2xNoChecks.Name = "m_menuFileImport2xNoChecks"; this.m_menuFileImport2xNoChecks.Size = new System.Drawing.Size(311, 22); this.m_menuFileImport2xNoChecks.Text = "KeePass &2.x LNGX File (No Base Checks)..."; this.m_menuFileImport2xNoChecks.Click += new System.EventHandler(this.OnImport2xNoChecks); // // m_menuFileSep1 // this.m_menuFileSep1.Name = "m_menuFileSep1"; this.m_menuFileSep1.Size = new System.Drawing.Size(151, 6); // // m_menuFileExit // this.m_menuFileExit.Name = "m_menuFileExit"; this.m_menuFileExit.Size = new System.Drawing.Size(154, 22); this.m_menuFileExit.Text = "&Exit"; this.m_menuFileExit.Click += new System.EventHandler(this.OnFileExit); // // m_menuEdit // this.m_menuEdit.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuEditNextUntrl}); this.m_menuEdit.Name = "m_menuEdit"; this.m_menuEdit.Size = new System.Drawing.Size(40, 20); this.m_menuEdit.Text = "&Edit"; // // m_menuEditNextUntrl // this.m_menuEditNextUntrl.Image = global::TrlUtil.Properties.Resources.B16x16_Down; this.m_menuEditNextUntrl.Name = "m_menuEditNextUntrl"; this.m_menuEditNextUntrl.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U))); this.m_menuEditNextUntrl.Size = new System.Drawing.Size(245, 22); this.m_menuEditNextUntrl.Text = "Go to Next &Untranslated"; this.m_menuEditNextUntrl.Click += new System.EventHandler(this.OnEditNextUntrl); // // m_tsMain // this.m_tsMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_tbOpen, this.m_tbSave, this.m_tbSep0, this.m_tbNextUntrl, this.m_tbSep1, this.m_tbFind}); this.m_tsMain.Location = new System.Drawing.Point(0, 24); this.m_tsMain.Name = "m_tsMain"; this.m_tsMain.Size = new System.Drawing.Size(629, 25); this.m_tsMain.TabIndex = 2; this.m_tsMain.TabStop = true; // // m_tbOpen // this.m_tbOpen.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbOpen.Image = global::TrlUtil.Properties.Resources.B16x16_Folder_Yellow_Open; this.m_tbOpen.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbOpen.Name = "m_tbOpen"; this.m_tbOpen.Size = new System.Drawing.Size(23, 22); this.m_tbOpen.Text = "Open... (Ctrl+O)"; this.m_tbOpen.Click += new System.EventHandler(this.OnFileOpen); // // m_tbSave // this.m_tbSave.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbSave.Image = global::TrlUtil.Properties.Resources.B16x16_FileSave; this.m_tbSave.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbSave.Name = "m_tbSave"; this.m_tbSave.Size = new System.Drawing.Size(23, 22); this.m_tbSave.Text = "Save (Ctrl+S)"; this.m_tbSave.Click += new System.EventHandler(this.OnFileSave); // // m_tbSep0 // this.m_tbSep0.Name = "m_tbSep0"; this.m_tbSep0.Size = new System.Drawing.Size(6, 25); // // m_tbNextUntrl // this.m_tbNextUntrl.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbNextUntrl.Image = global::TrlUtil.Properties.Resources.B16x16_Down; this.m_tbNextUntrl.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbNextUntrl.Name = "m_tbNextUntrl"; this.m_tbNextUntrl.Size = new System.Drawing.Size(23, 22); this.m_tbNextUntrl.Text = "Go to Next Untranslated (Ctrl+U)"; this.m_tbNextUntrl.Click += new System.EventHandler(this.OnEditNextUntrl); // // m_tbSep1 // this.m_tbSep1.Name = "m_tbSep1"; this.m_tbSep1.Size = new System.Drawing.Size(6, 25); // // m_tbFind // this.m_tbFind.AcceptsReturn = true; this.m_tbFind.Name = "m_tbFind"; this.m_tbFind.Size = new System.Drawing.Size(180, 25); this.m_tbFind.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnFindKeyDown); this.m_tbFind.KeyUp += new System.Windows.Forms.KeyEventHandler(this.OnFindKeyUp); this.m_tbFind.TextChanged += new System.EventHandler(this.OnFindTextChanged); // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(629, 526); this.Controls.Add(this.m_tsMain); this.Controls.Add(this.m_tabMain); this.Controls.Add(this.m_menuMain); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MainMenuStrip = this.m_menuMain; this.MaximizeBox = false; this.Name = "MainForm"; this.Text = "KeePass Translation Utility"; this.Load += new System.EventHandler(this.OnFormLoad); this.m_tabMain.ResumeLayout(false); this.m_tabProps.ResumeLayout(false); this.m_tabProps.PerformLayout(); this.m_tabStrings.ResumeLayout(false); this.m_tabStrings.PerformLayout(); this.m_tabDialogs.ResumeLayout(false); this.m_tabDialogs.PerformLayout(); this.m_grpControl.ResumeLayout(false); this.m_grpControl.PerformLayout(); this.m_grpControlLayout.ResumeLayout(false); this.m_grpControlLayout.PerformLayout(); this.m_tabUnusedText.ResumeLayout(false); this.m_menuMain.ResumeLayout(false); this.m_menuMain.PerformLayout(); this.m_tsMain.ResumeLayout(false); this.m_tsMain.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.TabControl m_tabMain; private System.Windows.Forms.TabPage m_tabProps; private System.Windows.Forms.TabPage m_tabStrings; private System.Windows.Forms.TabPage m_tabDialogs; private System.Windows.Forms.Label m_lblNameLclSample; private System.Windows.Forms.TextBox m_tbNameLcl; private System.Windows.Forms.Label m_lblNameLcl; private System.Windows.Forms.Label m_lblNameEngSample; private System.Windows.Forms.Label m_lblNameEng; private System.Windows.Forms.TextBox m_tbNameEng; private System.Windows.Forms.Label m_lblLangIDSample; private System.Windows.Forms.TextBox m_tbLangID; private System.Windows.Forms.Label m_lblLangID; private System.Windows.Forms.Label m_lblAuthorName; private System.Windows.Forms.TextBox m_tbAuthorName; private System.Windows.Forms.LinkLabel m_linkLangCode; private System.Windows.Forms.Label m_lblAuthorContact; private System.Windows.Forms.TextBox m_tbAuthorContact; private KeePass.UI.CustomMenuStripEx m_menuMain; private System.Windows.Forms.ToolStripMenuItem m_menuFile; private System.Windows.Forms.ToolStripMenuItem m_menuFileOpen; private System.Windows.Forms.ToolStripMenuItem m_menuFileSave; private System.Windows.Forms.ToolStripSeparator m_menuFileSep0; private System.Windows.Forms.ToolStripMenuItem m_menuFileExit; private KeePass.UI.CustomListViewEx m_lvStrings; private System.Windows.Forms.TextBox m_tbStrTrl; private System.Windows.Forms.TextBox m_tbStrEng; private System.Windows.Forms.Label m_lblStrTrl; private System.Windows.Forms.Label m_lblStrEng; private System.Windows.Forms.Label m_lblStrSaveHint; private System.Windows.Forms.ToolStripMenuItem m_menuFileSaveAs; private System.Windows.Forms.TreeView m_tvControls; private System.Windows.Forms.GroupBox m_grpControl; private System.Windows.Forms.Label m_lblCtrlEngText; private System.Windows.Forms.TextBox m_tbCtrlTrlText; private System.Windows.Forms.TextBox m_tbCtrlEngText; private System.Windows.Forms.Label m_lblCtrlTrlText; private System.Windows.Forms.GroupBox m_grpControlLayout; private System.Windows.Forms.TextBox m_tbLayoutH; private System.Windows.Forms.TextBox m_tbLayoutW; private System.Windows.Forms.TextBox m_tbLayoutY; private System.Windows.Forms.TextBox m_tbLayoutX; private System.Windows.Forms.Label m_lblLayoutH; private System.Windows.Forms.Label m_lblLayoutW; private System.Windows.Forms.Label m_lblLayoutY; private System.Windows.Forms.Label m_lblLayoutX; private System.Windows.Forms.Label m_lblLayoutHint2; private System.Windows.Forms.Label m_lblLayoutHint; private System.Windows.Forms.Label m_lblIconColorHint; private System.Windows.Forms.TabPage m_tabUnusedText; private System.Windows.Forms.Button m_btnClearUnusedText; private KeePass.UI.CustomRichTextBoxEx m_rtbUnusedText; private System.Windows.Forms.ToolStripMenuItem m_menuFileImport; private System.Windows.Forms.ToolStripMenuItem m_menuFileImportLng; private System.Windows.Forms.ToolStripSeparator m_menuFileSep1; private KeePass.UI.CustomToolStripEx m_tsMain; private System.Windows.Forms.ToolStripButton m_tbOpen; private System.Windows.Forms.ToolStripButton m_tbSave; private System.Windows.Forms.ToolStripSeparator m_tbSep0; private System.Windows.Forms.ToolStripTextBox m_tbFind; private System.Windows.Forms.ToolStripSeparator m_menuFileImportSep0; private System.Windows.Forms.ToolStripMenuItem m_menuFileImport2xNoChecks; private System.Windows.Forms.CheckBox m_cbRtl; private System.Windows.Forms.ToolStripMenuItem m_menuFileImportPo; private System.Windows.Forms.ToolStripSeparator m_tbSep1; private System.Windows.Forms.ToolStripButton m_tbNextUntrl; private System.Windows.Forms.ToolStripMenuItem m_menuEdit; private System.Windows.Forms.ToolStripMenuItem m_menuEditNextUntrl; } } keepass2-2.25/Translation/TrlUtil/Program.cs0000664000175000017500000001446112261553106020755 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Text; using System.IO; using System.IO.Compression; using System.Xml; using KeePassLib.Utility; namespace TrlUtil { public static class Program { [STAThread] public static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if((args != null) && (args.Length == 2)) { try { ExecuteCmd(args[0], args[1]); } catch(Exception exCmd) { MessageBox.Show(exCmd.Message, "TrlUtil", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return; } Application.Run(new MainForm()); } private static void ExecuteCmd(string strCmd, string strFile) { if(strCmd == "convert_resx") { StreamWriter swOut = new StreamWriter(strFile + ".lng.xml", false, new UTF8Encoding(false)); XmlDocument xmlIn = new XmlDocument(); xmlIn.Load(strFile); foreach(XmlNode xmlChild in xmlIn.DocumentElement.ChildNodes) { if(xmlChild.Name != "data") continue; swOut.Write("\r\n\t" + xmlChild.SelectSingleNode("value").InnerXml + "\r\n\r\n"); } swOut.Close(); } /* else if(strCmd == "compress") { byte[] pbData = File.ReadAllBytes(strFile); FileStream fs = new FileStream(strFile + ".lngx", FileMode.Create, FileAccess.Write, FileShare.None); GZipStream gz = new GZipStream(fs, CompressionMode.Compress); gz.Write(pbData, 0, pbData.Length); gz.Close(); fs.Close(); } */ else if(strCmd == "src_from_xml") { XmlDocument xmlIn = new XmlDocument(); xmlIn.Load(strFile); foreach(XmlNode xmlTable in xmlIn.DocumentElement.SelectNodes("StringTable")) { StreamWriter swOut = new StreamWriter(xmlTable.Attributes["Name"].Value + ".Generated.cs", false, new UTF8Encoding(false)); swOut.WriteLine("// This is a generated file!"); swOut.WriteLine("// Do not edit manually, changes will be overwritten."); swOut.WriteLine(); swOut.WriteLine("using System;"); swOut.WriteLine("using System.Collections.Generic;"); swOut.WriteLine(); swOut.WriteLine("namespace " + xmlTable.Attributes["Namespace"].Value); swOut.WriteLine("{"); swOut.WriteLine("\t/// "); swOut.WriteLine("\t/// A strongly-typed resource class, for looking up localized strings, etc."); swOut.WriteLine("\t/// "); swOut.WriteLine("\tpublic static class " + xmlTable.Attributes["Name"].Value); swOut.WriteLine("\t{"); swOut.WriteLine("\t\tprivate static string TryGetEx(Dictionary dictNew,"); swOut.WriteLine("\t\t\tstring strName, string strDefault)"); swOut.WriteLine("\t\t{"); swOut.WriteLine("\t\t\tstring strTemp;"); swOut.WriteLine(); swOut.WriteLine("\t\t\tif(dictNew.TryGetValue(strName, out strTemp))"); swOut.WriteLine("\t\t\t\treturn strTemp;"); swOut.WriteLine(); swOut.WriteLine("\t\t\treturn strDefault;"); swOut.WriteLine("\t\t}"); swOut.WriteLine(); swOut.WriteLine("\t\tpublic static void SetTranslatedStrings(Dictionary dictNew)"); swOut.WriteLine("\t\t{"); swOut.WriteLine("\t\t\tif(dictNew == null) throw new ArgumentNullException(\"dictNew\");"); swOut.WriteLine(); foreach(XmlNode xmlData in xmlTable.SelectNodes("Data")) { string strName = xmlData.Attributes["Name"].Value; swOut.WriteLine("\t\t\tm_str" + strName + " = TryGetEx(dictNew, \"" + strName + "\", m_str" + strName + ");"); } swOut.WriteLine("\t\t}"); swOut.WriteLine(); swOut.WriteLine("\t\tprivate static readonly string[] m_vKeyNames = {"); XmlNodeList xNodes = xmlTable.SelectNodes("Data"); for(int i = 0; i < xNodes.Count; ++i) { XmlNode xmlData = xNodes.Item(i); swOut.WriteLine("\t\t\t\"" + xmlData.Attributes["Name"].Value + "\"" + ((i != xNodes.Count - 1) ? "," : string.Empty)); } swOut.WriteLine("\t\t};"); swOut.WriteLine(); swOut.WriteLine("\t\tpublic static string[] GetKeyNames()"); swOut.WriteLine("\t\t{"); swOut.WriteLine("\t\t\treturn m_vKeyNames;"); swOut.WriteLine("\t\t}"); foreach(XmlNode xmlData in xmlTable.SelectNodes("Data")) { string strName = xmlData.Attributes["Name"].Value; string strValue = xmlData.SelectSingleNode("Value").InnerText; if(strValue.Contains("\"")) { // Console.WriteLine(strValue); strValue = strValue.Replace("\"", "\"\""); } swOut.WriteLine(); swOut.WriteLine("\t\tprivate static string m_str" + strName + " ="); swOut.WriteLine("\t\t\t@\"" + strValue + "\";"); swOut.WriteLine("\t\t/// "); swOut.WriteLine("\t\t/// Look up a localized string similar to"); swOut.WriteLine("\t\t/// '" + StrUtil.StringToHtml(strValue) + "'."); swOut.WriteLine("\t\t/// "); swOut.WriteLine("\t\tpublic static string " + strName); swOut.WriteLine("\t\t{"); swOut.WriteLine("\t\t\tget { return m_str" + strName + "; }"); swOut.WriteLine("\t\t}"); } swOut.WriteLine("\t}"); // Close class swOut.WriteLine("}"); swOut.Close(); } } } } } keepass2-2.25/Translation/TrlUtil/Properties/0000775000175000017500000000000012271475522021153 5ustar jtaylorjtaylorkeepass2-2.25/Translation/TrlUtil/Properties/Settings.Designer.cs0000664000175000017500000000210010765174556025043 0ustar jtaylorjtaylor//------------------------------------------------------------------------------ // // 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 TrlUtil.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; } } } } keepass2-2.25/Translation/TrlUtil/Properties/AssemblyInfo.cs0000664000175000017500000000316612271475522024103 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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("KeePass Translation Utility")] [assembly: AssemblyDescription("KeePass Translation Utility")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Dominik Reichl")] [assembly: AssemblyProduct("KeePass Translation Utility")] [assembly: AssemblyCopyright("Copyright © 2008-2014 Dominik Reichl")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // COM settings [assembly: ComVisible(false)] // Assembly GUID [assembly: Guid("39aa6f93-a1c9-497f-bad2-cc42a61d5710")] // Assembly version information [assembly: AssemblyVersion("2.25.0.*")] [assembly: AssemblyFileVersion("2.25.0.0")] keepass2-2.25/Translation/TrlUtil/Properties/Resources.resx0000664000175000017500000002224112172704174024027 0ustar jtaylorjtaylor 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 ..\Resources\B16x16_Binary.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\B16x16_FileSave.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\B16x16_FileSaveAs.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\B16x16_Folder_Yellow_Open.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\B16x16_Keyboard_Layout.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\B16x16_KRec_Record.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\B16x16_LedGreen.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\B16x16_LedLightBlue.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\B16x16_LedLightGreen.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\B16x16_LedOrange.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\KeePass.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\B16x16_View_Remove.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\B16x16_Down.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a keepass2-2.25/Translation/TrlUtil/Properties/Resources.Designer.cs0000664000175000017500000001435012172704174025214 0ustar jtaylorjtaylor//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:2.0.50727.5466 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ namespace TrlUtil.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("TrlUtil.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; } } internal static System.Drawing.Bitmap B16x16_Binary { get { object obj = ResourceManager.GetObject("B16x16_Binary", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } internal static System.Drawing.Bitmap B16x16_Down { get { object obj = ResourceManager.GetObject("B16x16_Down", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } internal static System.Drawing.Bitmap B16x16_FileSave { get { object obj = ResourceManager.GetObject("B16x16_FileSave", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } internal static System.Drawing.Bitmap B16x16_FileSaveAs { get { object obj = ResourceManager.GetObject("B16x16_FileSaveAs", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } internal static System.Drawing.Bitmap B16x16_Folder_Yellow_Open { get { object obj = ResourceManager.GetObject("B16x16_Folder_Yellow_Open", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } internal static System.Drawing.Bitmap B16x16_Keyboard_Layout { get { object obj = ResourceManager.GetObject("B16x16_Keyboard_Layout", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } internal static System.Drawing.Bitmap B16x16_KRec_Record { get { object obj = ResourceManager.GetObject("B16x16_KRec_Record", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } internal static System.Drawing.Bitmap B16x16_LedGreen { get { object obj = ResourceManager.GetObject("B16x16_LedGreen", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } internal static System.Drawing.Bitmap B16x16_LedLightBlue { get { object obj = ResourceManager.GetObject("B16x16_LedLightBlue", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } internal static System.Drawing.Bitmap B16x16_LedLightGreen { get { object obj = ResourceManager.GetObject("B16x16_LedLightGreen", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } internal static System.Drawing.Bitmap B16x16_LedOrange { get { object obj = ResourceManager.GetObject("B16x16_LedOrange", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } internal static System.Drawing.Bitmap B16x16_View_Remove { get { object obj = ResourceManager.GetObject("B16x16_View_Remove", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } internal static System.Drawing.Icon KeePass { get { object obj = ResourceManager.GetObject("KeePass", resourceCulture); return ((System.Drawing.Icon)(obj)); } } } } keepass2-2.25/Translation/TrlUtil/Properties/Settings.settings0000664000175000017500000000037110755775352024547 0ustar jtaylorjtaylor keepass2-2.25/Translation/TrlUtil/FormTrlMgr.cs0000664000175000017500000002006112261553106021372 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Reflection; using System.Diagnostics; using System.Windows.Forms; using KeePass.Forms; using KeePass.UI; using KeePassLib.Translation; namespace TrlUtil { public static class FormTrlMgr { private static bool m_bIgnoreBaseHash = false; public static bool IgnoreBaseHash { get { return m_bIgnoreBaseHash; } set { m_bIgnoreBaseHash = value; } } public static List CreateListOfCurrentVersion() { List l = new List(); AddForm(l, new AboutForm()); AddForm(l, new AutoTypeCtxForm()); AddForm(l, new CharPickerForm()); AddForm(l, new ColumnsForm()); AddForm(l, new CsvImportForm()); AddForm(l, new DatabaseOperationsForm()); AddForm(l, new DatabaseSettingsForm()); AddForm(l, new DataEditorForm()); AddForm(l, new DataViewerForm()); AddForm(l, new DuplicationForm()); AddForm(l, new EcasActionForm()); AddForm(l, new EcasConditionForm()); AddForm(l, new EcasEventForm()); AddForm(l, new EcasTriggerForm()); AddForm(l, new EcasTriggersForm()); AddForm(l, new EditAutoTypeItemForm()); AddForm(l, new EditStringForm()); AddForm(l, new EntropyForm()); AddForm(l, new EntryListForm()); AddForm(l, new EntryReportForm()); AddForm(l, new ExchangeDataForm()); AddForm(l, new FieldRefForm()); AddForm(l, new FileBrowserForm()); AddForm(l, new GroupForm()); AddForm(l, new HelpSourceForm()); AddForm(l, new IconPickerForm()); AddForm(l, new ImportMethodForm()); AddForm(l, new InternalBrowserForm()); AddForm(l, new IOConnectionForm()); AddForm(l, new KeyCreationForm()); AddForm(l, new KeyPromptForm()); AddForm(l, new LanguageForm()); AddForm(l, new KeePass.Forms.MainForm()); AddForm(l, new OptionsForm()); AddForm(l, new PluginsForm()); AddForm(l, new PrintForm()); AddForm(l, new ProxyForm()); AddForm(l, new PwEntryForm()); AddForm(l, new PwGeneratorForm()); AddForm(l, new SearchForm()); AddForm(l, new SingleLineEditForm()); AddForm(l, new StatusLoggerForm()); AddForm(l, new StatusProgressForm()); AddForm(l, new TanWizardForm()); AddForm(l, new TextEncodingForm()); AddForm(l, new UpdateCheckForm()); AddForm(l, new UrlSchemeForm()); AddForm(l, new UrlSchemesForm()); AddForm(l, new XmlReplaceForm()); return l; } private static void AddForm(List listForms, Form f) { KPFormCustomization kpfc = new KPFormCustomization(); kpfc.FullName = f.GetType().FullName; kpfc.FormEnglish = f; kpfc.Window.TextEnglish = f.Text; kpfc.Window.BaseHash = KPControlCustomization.HashControl(f); foreach(Control c in f.Controls) AddControl(kpfc, c); kpfc.Controls.Sort(); listForms.Add(kpfc); } private static void AddControl(KPFormCustomization kpfc, Control c) { if((kpfc == null) || (c == null)) { Debug.Assert(false); return; } bool bAdd = true; Type t = c.GetType(); if(c.Text.Length == 0) bAdd = false; else if(c.Name.Length == 0) bAdd = false; else if(t == typeof(MenuStrip)) bAdd = false; else if(t == typeof(PictureBox)) bAdd = false; else if(t == typeof(TreeView)) bAdd = false; else if(t == typeof(ToolStrip)) bAdd = false; else if(t == typeof(WebBrowser)) bAdd = false; else if(t == typeof(Panel)) bAdd = false; else if(t == typeof(StatusStrip)) bAdd = false; else if(c.Text.StartsWith(@"<") && c.Text.EndsWith(@">")) bAdd = false; if(t == typeof(TabControl)) bAdd = true; else if(t == typeof(ProgressBar)) bAdd = true; else if(t == typeof(TextBox)) bAdd = true; else if(t == typeof(PromptedTextBox)) bAdd = true; else if(t == typeof(RichTextBox)) bAdd = true; else if(t == typeof(KeePass.UI.CustomRichTextBoxEx)) bAdd = true; else if(t == typeof(ComboBox)) bAdd = true; else if(t == typeof(KeePass.UI.ImageComboBoxEx)) bAdd = true; else if(t == typeof(Label)) bAdd = true; else if(t == typeof(ListView)) bAdd = true; else if(t == typeof(CustomListViewEx)) bAdd = true; else if(t == typeof(Button)) bAdd = true; else if(t == typeof(KeePass.UI.QualityProgressBar)) bAdd = true; else if(t == typeof(DateTimePicker)) bAdd = true; else if(t == typeof(CheckedListBox)) bAdd = true; if(bAdd && (c.Name.Length > 0)) { KPControlCustomization kpcc = new KPControlCustomization(); kpcc.Name = c.Name; kpcc.BaseHash = KPControlCustomization.HashControl(c); if((t != typeof(TabControl)) && (t != typeof(NumericUpDown))) kpcc.TextEnglish = c.Text; else kpcc.TextEnglish = string.Empty; kpfc.Controls.Add(kpcc); } foreach(Control cSub in c.Controls) AddControl(kpfc, cSub); } public static void RenderToTreeControl(List listCustoms, TreeView tv) { tv.BeginUpdate(); tv.Nodes.Clear(); foreach(KPFormCustomization kpfc in listCustoms) { string strName = kpfc.FullName; int nLastDot = strName.LastIndexOf('.'); if(nLastDot >= 0) strName = strName.Substring(nLastDot + 1); TreeNode tnForm = tv.Nodes.Add(strName); tnForm.Tag = kpfc; TreeNode tnWindow = tnForm.Nodes.Add("Window"); tnWindow.Tag = kpfc.Window; foreach(KPControlCustomization kpcc in kpfc.Controls) { TreeNode tnControl = tnForm.Nodes.Add(kpcc.Name); tnControl.Tag = kpcc; } tnForm.ExpandAll(); } tv.EndUpdate(); } public static void MergeForms(List lInto, List lFrom, StringBuilder sbUnusedText) { foreach(KPFormCustomization kpInto in lInto) { foreach(KPFormCustomization kpFrom in lFrom) { if(kpInto.FullName == kpFrom.FullName) MergeFormCustomizations(kpInto, kpFrom, sbUnusedText); } } } private static void MergeFormCustomizations(KPFormCustomization kpInto, KPFormCustomization kpFrom, StringBuilder sbUnusedText) { MergeControlCustomizations(kpInto.Window, kpFrom.Window, sbUnusedText); foreach(KPControlCustomization ccInto in kpInto.Controls) { foreach(KPControlCustomization ccFrom in kpFrom.Controls) { if(ccInto.Name == ccFrom.Name) MergeControlCustomizations(ccInto, ccFrom, sbUnusedText); } } } private static void MergeControlCustomizations(KPControlCustomization ccInto, KPControlCustomization ccFrom, StringBuilder sbUnusedText) { if(ccFrom.Text.Length > 0) { bool bTextValid = true; if(!m_bIgnoreBaseHash && (ccFrom.BaseHash.Length > 0) && !ccInto.MatchHash(ccFrom.BaseHash)) bTextValid = false; if(bTextValid) ccInto.Text = ccFrom.Text; else // Create a backup { string strTrimmed = ccFrom.Text.Trim(); if(strTrimmed.Length > 0) sbUnusedText.AppendLine(strTrimmed); } } if(ccFrom.Layout.X.Length > 0) ccInto.Layout.X = ccFrom.Layout.X; if(ccFrom.Layout.Y.Length > 0) ccInto.Layout.Y = ccFrom.Layout.Y; if(ccFrom.Layout.Width.Length > 0) ccInto.Layout.Width = ccFrom.Layout.Width; if(ccFrom.Layout.Height.Length > 0) ccInto.Layout.Height = ccFrom.Layout.Height; } } } keepass2-2.25/Translation/TrlUtil/TrlImport.cs0000664000175000017500000001047512261553106021303 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using KeePassLib.Translation; using KeePassLib.Utility; namespace TrlUtil { public static class TrlImport { public static void Import1xLng(KPTranslation kpInto, string strFile) { if((strFile == null) || (strFile.Length == 0)) { Debug.Assert(false); return; } string strData = File.ReadAllText(strFile, StrUtil.Utf8); Dictionary dict = new Dictionary(); const int nStatePreEn = 0; const int nStateInEn = 1; const int nStateBetween = 2; const int nStateInTrl = 3; StringBuilder sbEn = new StringBuilder(); StringBuilder sbTrl = new StringBuilder(); int nState = nStatePreEn; for(int i = 0; i < strData.Length; ++i) { char ch = strData[i]; if(ch == '|') { if(nState == nStatePreEn) nState = nStateInEn; else if(nState == nStateInEn) nState = nStateBetween; else if(nState == nStateBetween) nState = nStateInTrl; else if(nState == nStateInTrl) { dict[sbEn.ToString()] = sbTrl.ToString(); sbEn = new StringBuilder(); sbTrl = new StringBuilder(); nState = nStatePreEn; } } else if(nState == nStateInEn) sbEn.Append(ch); else if(nState == nStateInTrl) sbTrl.Append(ch); } Debug.Assert(nState == nStatePreEn); dict[string.Empty] = string.Empty; MergeDict(kpInto, dict); } private static void MergeDict(KPTranslation kpInto, Dictionary dict) { if(kpInto == null) { Debug.Assert(false); return; } if(dict == null) { Debug.Assert(false); return; } foreach(KPStringTable kpst in kpInto.StringTables) { foreach(KPStringTableItem kpsti in kpst.Strings) { string strTrl; if(dict.TryGetValue(kpsti.ValueEnglish, out strTrl)) kpsti.Value = strTrl; } } foreach(KPFormCustomization kpfc in kpInto.Forms) { string strTrlWnd; if(dict.TryGetValue(kpfc.Window.TextEnglish, out strTrlWnd)) kpfc.Window.Text = strTrlWnd; foreach(KPControlCustomization kpcc in kpfc.Controls) { string strTrlCtrl; if(dict.TryGetValue(kpcc.TextEnglish, out strTrlCtrl)) kpcc.Text = strTrlCtrl; } } } public static void ImportPo(KPTranslation kpInto, string strFile) { if((strFile == null) || (strFile.Length == 0)) { Debug.Assert(false); return; } string strData = File.ReadAllText(strFile, StrUtil.Utf8); strData = StrUtil.NormalizeNewLines(strData, false); string[] vData = strData.Split('\n'); Dictionary dict = new Dictionary(); string strID = string.Empty; foreach(string strLine in vData) { string str = strLine.Trim(); if(str.StartsWith("msgid ", StrUtil.CaseIgnoreCmp)) strID = FilterPoValue(str.Substring(6)); else if(str.StartsWith("msgstr ", StrUtil.CaseIgnoreCmp)) { if(strID.Length > 0) { dict[strID] = FilterPoValue(str.Substring(7)); strID = string.Empty; } } } MergeDict(kpInto, dict); } private static string FilterPoValue(string str) { if(str == null) { Debug.Assert(false); return string.Empty; } if(str.StartsWith("\"") && str.EndsWith("\"") && (str.Length >= 2)) str = str.Substring(1, str.Length - 2); else { Debug.Assert(false); } str = str.Replace("\\\"", "\""); return str; } } } keepass2-2.25/Translation/TrlUtil/MainForm.resx0000664000175000017500000012156712172725654021452 0ustar jtaylorjtaylor 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 17, 17 137, 17 AAABAAgAICAQAAEABADoAgAAhgAAABAQEAABAAQAKAEAAG4DAAAwMAAAAQAIAKgOAACWBAAAICAAAAEA CACoCAAAPhMAABAQAAABAAgAaAUAAOYbAAAwMAAAAQAgAKglAABOIQAAICAAAAEAIACoEAAA9kYAABAQ AAABACAAaAQAAJ5XAAAoAAAAIAAAAEAAAAABAAQAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA gAAAgAAAAICAAIAAAACAAIAAgIAAAICAgADAwMAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA////AAAA AAAAB3AAAAdwAAAAAAAAAAAABwAHd3dwAHcAAAAAAAAABwB3f///93cAcAAAAAAAAAB3j//////4dwAA AAAAAAAH//////////9wAAAAAAAAf///////////9wAAAAAHB//0RERERERET/9wcAAAcH//9ERERERE RE//9wcAAAeP//////////////hwAAcH///0RERP9ERET///cHAAeP//9ERET/RERE///4cAcH////// ///////////3B3B////0RERP9ERET///9wcHj///9ERET/RERE////hwB///////////////////cAf/ ///0RERERERET////3AH////9ERERERERE////9wB///////////////////cAeP////9E////RP//// +HBwf/////RP///0T/////cHcH/////0T///9E/////3AAB4////9E////RP////hwAHB/////RP///0 T////3BwAAf////0T///9E////hwAABwf///9ET//0RP///3dwAABwf///9ERERE////cHAAAAAAf/// 9ERET///9wAAAAAAAAf//////////3AAAAAAAABwd4//////+HcHAAAAAAAABwB3eP//h3cAcAAAAAAA AAAHAAd3d3AAcAAAAAAAAAAAAAdwAAAHcAAAAAAA/+AH//+AAP/+AAB//AAAP/gAAB/wAAAP4AAAB8AA AAPAAAADgAAAAYAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAYAA AAHAAAADwAAAA+AAAAfwAAAP+AAAH/wAAD/+AAB//4AB///gB/8oAAAAEAAAACAAAAABAAQAAAAAAIAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAICAgADAwMAAAAD/AAD/ AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAAcG//9gcAAAAP////8AAAcPd3d3d/BwAP9ERERE /wAG/3d/93f/YA//RE/0RP/wD/93d3d3//AP/0RERET/8A//9P//T//wBv/0//9P/2AA//R/90//AAcP /0d0//BwAAD/9E//AAAABwb//2BwAAAAAAAAAAAA+B8AAOAHAADAAwAAgAEAAIABAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAACAAQAAgAEAAMADAADgBwAA+B8AACgAAAAwAAAAYAAAAAEACAAAAAAAAAkAAAAA AAAAA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000664000175000017500000001057312261553106022147 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Windows.Forms; using System.Diagnostics; using KeePassLib.Translation; using KeePassLib.Utility; namespace TrlUtil { public static class AccelKeysCheck { private static char GetAccelKey(string strText) { if(strText == null) { Debug.Assert(false); return char.MinValue; } if(strText.Length == 0) return char.MinValue; strText = strText.Replace(@"&&", string.Empty); Debug.Assert(strText.IndexOf('&') == strText.LastIndexOf('&')); int nIndex = strText.IndexOf('&'); Debug.Assert(nIndex != (strText.Length - 1)); if((nIndex >= 0) && (nIndex < (strText.Length - 1))) return char.ToUpper(strText[nIndex + 1]); return char.MinValue; } public static string Validate(KPTranslation trl) { if(trl == null) { Debug.Assert(false); return null; } foreach(KPFormCustomization kpfc in trl.Forms) { string str = Validate(kpfc); if(str != null) return str; } return null; } private static string Validate(KPFormCustomization kpfc) { if(kpfc == null) { Debug.Assert(false); return null; } if(kpfc.FormEnglish == null) { Debug.Assert(false); return null; } string str = Validate(kpfc, kpfc.FormEnglish, null); if(str != null) return str; return null; } private static string Validate(KPFormCustomization kpfc, Control c, Dictionary dictParent) { if(kpfc == null) { Debug.Assert(false); return null; } if(kpfc.FormEnglish == null) { Debug.Assert(false); return null; } if(c == null) { Debug.Assert(false); return null; } Dictionary dictAccel = new Dictionary(); foreach(Control cSub in c.Controls) { string strText = Translate(kpfc, cSub); char chKey = GetAccelKey(strText); if(chKey == char.MinValue) continue; string strId = kpfc.FullName + "." + cSub.Name + " - \"" + strText + "\""; bool bCollides = dictAccel.ContainsKey(chKey); bool bCollidesParent = ((dictParent != null) ? dictParent.ContainsKey(chKey) : false); if(bCollides || bCollidesParent) { string strMsg = "Key " + chKey.ToString() + ":"; strMsg += MessageService.NewLine; strMsg += (bCollides ? dictAccel[chKey] : dictParent[chKey]); strMsg += MessageService.NewLine + strId; return strMsg; } dictAccel.Add(chKey, strId); } Dictionary dictSub = MergeDictionaries(dictParent, dictAccel); foreach(Control cSub in c.Controls) { string str = Validate(kpfc, cSub, dictSub); if(str != null) return str; } return null; } private static string Translate(KPFormCustomization kpfc, Control c) { string strName = c.Name; if(string.IsNullOrEmpty(strName)) return string.Empty; foreach(KPControlCustomization cc in kpfc.Controls) { if(cc.Name == strName) { if(!string.IsNullOrEmpty(cc.TextEnglish)) { Debug.Assert(c.Text == cc.TextEnglish); } return cc.Text; } } return c.Text; } private static Dictionary MergeDictionaries( Dictionary x, Dictionary y) { Dictionary d = new Dictionary(); if(x != null) { foreach(KeyValuePair kvp in x) d[kvp.Key] = kvp.Value; } if(y != null) { foreach(KeyValuePair kvp in y) d[kvp.Key] = kvp.Value; } return d; } } } keepass2-2.25/Translation/TrlUtil/TrlUtil.csproj0000664000175000017500000001160512172704176021643 0ustar jtaylorjtaylor Debug AnyCPU 9.0.30729 2.0 {B7E890E7-BF50-4450-9A52-C105BD98651C} WinExe Properties TrlUtil TrlUtil Resources\KeePass.ico 2.0 true full false ..\ TRACE;DEBUG;KeeTranslationUtility prompt 4 pdbonly true ..\ TRACE;KeeTranslationUtility prompt 4 Form MainForm.cs Form Designer MainForm.cs ResXFileCodeGenerator Resources.Designer.cs Designer True Resources.resx True SettingsSingleFileGenerator Settings.Designer.cs True Settings.settings True {10938016-DEE2-4A25-9A5A-8FD3444379CA} KeePass keepass2-2.25/Translation/TrlUtil/Resources/0000775000175000017500000000000012172704146020766 5ustar jtaylorjtaylorkeepass2-2.25/Translation/TrlUtil/Resources/B16x16_LedOrange.png0000664000175000017500000000201110133447024024267 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxA$>e+> /󟁡KB=R=-A΋GD(+{ܶڅ8K3ÿo\e4A*KPumuxi޽~o Q5,3~9 V#W ,1(i1/z+%&f-/cPw ̏8~C ` #А@C30x=gb?}. fF =]6gwe`Pzhff.h?r 7ÍY"h TTtbP1PP.y3(  X8@'@Ca`Sb`30zP-P;@V >>jbX$a 1 & X?6N6nk@PPabFϿX~N.IDATxڕ_HSQǿsALAd$!|9/C`UЫIJ zN$",-+4n+*ZP$\Z?pϟs]$IH);i%)`Y,!0+Fs$>6FffJb%^ V_25EQf Q z?\?vlm2ѲIK@Pn蠥ޒxMZ- 1 Z)V76 5BR@ ,=B!55BUU/+#5w#D8Y|8Y%<L],F,8l^Ŀ1W\B)wFt%JA,}+y2Lu7vNn Mp\j܍pnBv4lOtEXtSoftwareAdobe ImageReadyqe<IENDB`keepass2-2.25/Translation/TrlUtil/Resources/B16x16_Keyboard_Layout.png0000664000175000017500000000206610131465222025534 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxAi33<(/C H#*ݏe Yq_ϔR`gW60a`PQb`xP |~ X~qqn_x")% % P!χ), 8V(z<0 7\q"QR?jl/yf,  bŃ8 u7Fe @,30? P3?P1\@[/8N= ++>AC& RaWc EAJ&16ع ݪܰRU  %,f 7dff`gROh@ad` 5xY^{-Š (͠pbQFU%9)1!6V,f'babbbPRfeLc``e``! hAI 00prC_p<4D+/'0<Ӈ[ 2e`@,cf`cc +mG~0ں{8u.c'eFfF!by+Ñ#7޽t.bb" 8}&Nvbx{>0}  of^p]_7ؘei ,,~7!~ay} } -@nHXIENDB`keepass2-2.25/Translation/TrlUtil/Resources/B16x16_Folder_Yellow_Open.png0000664000175000017500000000115110133525306026162 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxbd```.ˀJ>h@ ? qs1 31#~I0r ܊@2x/!W؀C@>ӿ>  q2N1H; h(#+Xُ[{`W]h3j?5ge`bv;5\ۇ p/wyW8D H~aՎ )@C?$a/ o~%H3_ 4~<?°7b? ? `Qǁ@ x3î? V z+~lalH!PHw :t @۫ D@L cĠ&D@?y(8^ `DC @L3(0IENDB`keepass2-2.25/Translation/TrlUtil/Resources/B16x16_LedGreen.png0000664000175000017500000000221010133447034024116 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxAK >e"> n]Z  /?fsâ Νÿ 6WH1xB'Pc&dg1лʠc`dA%7:-JbKd) "Ɔ%7/_2`߯ O?3w $_2 Y51=ffao1|ݏw fx-(@p1۰02`Ű&?tD؄Y8.o~̰N?83p]g4 &~?Xd8aã?79xY|G e%>  nG]fʆq N ₢ @^}xp 60=rq3{)=l'c8 _}xyY2h(333 /ÿ"=+Yy~2|g1egP3k(101o _l5c0|f 17Pb_w |Xdws<>@]vZ_xYX1袯@+ϛ e`afes(@٨j0= ~1H23003l/c?T xD$ 03+? ~exxAE û?z;/&!v AKyHaXM-Pa֋-mDƈ8PHn)@ 4JSG$Q}MfxKC>lEu+ZY wxrP#; 0؁AX(&a6+y`bxebe/4s^b @ t*ֿ< 'ֿg bb`cq뵇W*+`b7@2 (6V g<n fy 8ŕ[PTKS?@޵w`= f>56qc7>s0|܉ &`X=?2pFbd05d~<98س$dDD/??~sӁڟ8Y ̡Q*_iIENDB`keepass2-2.25/Translation/TrlUtil/Resources/B16x16_LedLightBlue.png0000664000175000017500000000200110133447032024731 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxbdP] ϯї 0̜s?X3P ^z^% \L ~U: h_ f-=IE}x @0kâ.X& /10az'!bt؎>u@1vie0A4~o@e`􊑁{-c#!Tp%(8xـ.`7Рo@b`8h>Cbeg`: 6PWm"@3B @1fip0q  #Q  /fj Y| X~g𛓏A@9 A0bHoo'x L@ہ001 H@@.&@ 랿bxeb'n32ab `C! L ݵ^e>;D! c10\9v҉&o fـ u+7(7D3й ٜ c8Â9G' t'~8w҃oԹ؀)XY9 W/2fgg ڸ?ofP 6F2H)|@gq>IENDB`keepass2-2.25/Translation/TrlUtil/Resources/KeePass.ico0000664000175000017500000017460411436702542023031 0ustar jtaylorjtaylor (~00 Nh n^!00 %̾  t h( @ppwwpwwwpwwpDDDDDDOpppDDDDDDOpDDODDOppxDDODDOppDDODDODDODDOppDDDDDDOpDDDDDDOppOOppOOpOOxOOOOppOOppDDOwDDDDppDDOppwwwxwpwwpppp??( `pwwwwpDDDDww`DODwwwwDDDDOO`OGtpO`p(0`     !% 3$!!!&#"%$#%%%+%#.(&/+*<,'1-,70.81/333720666831;42976?75999R/#R1%R5+S8.@:9@=<T;3T?8UB;YC;BBBLFDTF@THD[JDVLHWOLZOLWPMZPM^PLWUT\ZYsPCm_Zq\UmmmygayictttJ3M;O8P>P:TCYJUA]J^R^EbUfZi_i^n^cFeJiNhQmXmSmQp[qYsYjbmbpgrjtfwswqxszu~yvcxf{e~iqOsLvPxRzU|V}Y{|}mrw|[]ډm̉rӌtΒ}ږ~`bdfikmps{x}˝՗Ӛᝆ읂٨㦑ﮘȰİȰͳʹԷʶʹɺϿ׾ػ൥½½¹ǿõŻŸɿ±óijĴŵǸȹ˼̾<,,<!?6aa3 ?qc,61,&ٳ~vnlll ƥ~~vvnllljj~q֥~~~nvllljjjl簈~~vnnlljjji}٬~~vnllljjiij,ְ~~vvllkkjiii,尰~~~vnlljjiiiq&򳳱   @iii?Ƴ  @iii~?7Ƴ  @kkji3uuttssrggfxXUURRQPPPhkkkil zT @mmkkj zW Bvmmkko****))))%)|f%$$#####"J}vmmlk<[[NNLLLLIIyFEEEECCCAV}}}mml <,8 |d  G~}mvm6, e G~~}vvva]][][[NNLL{IIIFFFCECY~}vv/..*.****)))))%%%%%#%%#S~vv   Hv H娧uuutttrrrffza,8 ZƳ %6,< .ij 9 </ ^ Oa + q!! 6Ʃ !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¾ó   !               J3wPuNsLdɱVRP   !  !           L5yRwPuNsLﮘTJFqƶ}zwurpmj}h{e{{xډmqYoVmTlQjOhMfKeIcFqO{UySwQuN}YȰq865ŵ±   !  !   ӌt{mX      O8}X{VySwQuNﯘ70.ȹŵò   !  !  !ӏw잂p[     P:[}X{VySxQd~x\˼ȹƶòUC=UB;UA:U@9U?8T>6T=5T<4T;3T;2ږ~힃|fS6,R5+R4)R3)R3'R1&R1%R0$R/#^E^[~Y|VzTxRƶú\$#"˽ɺƶijmclaj_i]g[fYdWcVaT_Rᝆ̉rXHWFUETCRAQ?P=NUC=UBN;L9J7I4[@~Z{VxReYʻƶ±!!!!!!T8/잂}9%      j;*^Z|VySȹ321ʼǷlbj_h\eYcVaTq_잃`OVETCR@P=N;aHc_[|Wﬕ2,*`^]˼!!!!!!T<3:'     k>/hd`\|^SP}zyskqhnelbj_h\fYcWaT_Q]NZKXHVETCiRmid`lzmh}zz"!!!!!!!!!!!   lD6sniepzmi`_^yrwpumrjpgndlai^g\eYcV`S^P\MZJp[xsoj^TQ332ZNJ"ZKFɺƵ°뫔)!^N잂~yto2-,sm",%#ɼʻƶ±~!!{i쟃~yuY""˼ǷòaV!#ࠊퟄYGFF+'%"cVQ˽Ǹó캩4($!U?7䀹ɺE?=ujf"#̱̽ȸyo!!~pﬕʺCCC%CBB&#""I@=Ӱ,$!!?2.ﭖB=;CCC%WWW""B:8{t/(%"%WWW  wnk"""""$ʻƶ±˿  % :53"$ JA>ʻͿ %1 껻1%CCBB?>% WWWGFFFDCWWW CCC%333`__}{{}{z`^^322CCC%YY??(  0 60.60- 0 WWWC=;ǸB:7WWW ::9kb~ZxRf:99 WWW˼ulc[yStMWWW0C@?!        uNB:70ͿT?7T<4T90valVR1&R/#m<+{Vi ƶ    }jS8/    _|WȺ 765VFAUC=UA:l^S8/S8/S6+nD5h`60.766         sj60.nD5ɺ±㩔nD5ņp~t $ ¥˼òs."멑朗0DDCf]ZVLHŷA40}aWﭕC><0WWW721JA>@74D95滫WWW :::ɾ::9 WWWDDDDA@WWW 0766766 0AAAAAAAAAAAAAAAAkeepass2-2.25/Translation/TrlUtil/Resources/B16x16_FileSaveAs.png0000664000175000017500000000176110133443100024413 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb?#c200@BL@VzIn؅\?w' X@Beڒ~Blj4?H^ < _=Z+&yS=>?  h; W/^`ng $ @`x33H ]/W?3X0>g`a W{0؀?h @?@1 fɻwƠ)DSe(tX}6^L LL c20|ə _TN0q)Eb7P;3$YAt̓s_2H)10< ù'u ĭx?U}e & Ŀ?_W1]ge`0W /41țx22F?F Ͼ0197ßO3Ch/݋of|,=^`0CR@]p?o~0~}Š '0\eaɑð~Ù,T^v_20( a(piGw9fjG[;X] oH0 ~0u)321(g2&10 Q s@A\o 30ea`ffx9gbc`bxt)LLg 3q20|_BIo |f_?dY~dc?X/@]pu̓\|wg>^Vg?!NYɗo ?aŻ߯9@g:|k㭏IENDB`keepass2-2.25/Translation/TrlUtil/Resources/B16x16_Down.png0000664000175000017500000000162010133443504023342 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<"IDATxb?% X@t `bb5k_,Pǟ'߿,B/d0_~άלea-1q031zVC, lKg̠l`s#[@o>30\yo ^g:d!z .$?" @u20w b߾dG U6N@l/6]1Y?1 ? <\ 6F_y@6?P[ ïĸO ?IA1l2o?a)-[a K>1l|??^~ps]a^٫n2r /_/ ğ?/ (AU'7[*xvkwѰA !ŪDZ?e>,q6cd``b;?# 7P7L@^>A.~baFF@El@H8L@ 8@`db2Clg`27P32102C ؘA 85yh.'T@Af?mF#P߿ /! _??3|_w3WY|v@À/$Z33;?0FX fc7 ˯ L _12 F~3L`3e`gf@Aߟ@ge0w_S&s}6@qr220Xjb_P4 Vq2pbPt67;#ODy^- 4j@A4   X Y3|AT/F &l| ٘0ewt30ДU>ad VHL؀ /6}3p]Fh"bFWp|afxo參 KC4>Sg%IENDB`keepass2-2.25/Translation/TrlUtil/Resources/B16x16_Binary.png0000664000175000017500000000150710130001210023640 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb:a߿ LLL  Ab lllR1aX?X{@%XQ3@U陹dDpww63'sl0 @1bll\#Vb&zfZ 3L"UÝfO1 rǏ60 {$r.'߿@jA@ -[| R6A -7@~<<< W KQ(l!!؂XHRݱ仫 \  c,l>d  pJx "03S.nfF}(3 V"@ MLL PL  9PX X@ ++ ,kkk@ @lk Vp @A 1H   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.Reflection; using KeePass.App; using KeePass.Resources; using KeePass.UI; using KeePass.Util; using KeePass.Util.XmlSerialization; using KeePassLib; using KeePassLib.Resources; using KeePassLib.Serialization; using KeePassLib.Translation; using KeePassLib.Utility; namespace TrlUtil { public partial class MainForm : Form { private const string TrlUtilName = "TrlUtil"; private KPTranslation m_trl = new KPTranslation(); private string m_strFile = string.Empty; private ImageList m_ilStr = new ImageList(); private const string m_strFileFilter = "KeePass Translation (*.lngx)|*.lngx|All Files (*.*)|*.*"; private static readonly string[] m_vEmpty = new string[2] { @"", @"<>" }; private KPControlCustomization m_kpccLast = null; private const int m_inxWindow = 6; private const int m_inxMissing = 1; private const int m_inxOk = 4; private const int m_inxWarning = 5; private bool m_bModified = false; private PreviewForm m_prev = new PreviewForm(); private delegate void ImportFn(KPTranslation trlInto, IOConnectionInfo ioc); public MainForm() { InitializeComponent(); } private void OnFormLoad(object sender, EventArgs e) { this.Text += " " + PwDefs.VersionString; m_trl.Forms = FormTrlMgr.CreateListOfCurrentVersion(); m_rtbUnusedText.SimpleTextOnly = true; string strSearchTr = ((WinUtil.IsAtLeastWindowsVista ? string.Empty : " ") + "Search in active tab..."); UIUtil.SetCueBanner(m_tbFind, strSearchTr); this.CreateStringTableUI(); this.UpdateControlTree(); if(m_tvControls.SelectedNode == null) m_tvControls.SelectedNode = m_tvControls.Nodes[0]; UpdatePreviewForm(); m_prev.Show(); try { this.DoubleBuffered = true; } catch(Exception) { Debug.Assert(false); } UpdateUIState(); } private void CreateStringTableUI() { int nWidth = m_lvStrings.ClientSize.Width - 20; m_ilStr.ColorDepth = ColorDepth.Depth32Bit; m_ilStr.ImageSize = new Size(16, 16); m_ilStr.Images.Add(Properties.Resources.B16x16_Binary); m_ilStr.Images.Add(Properties.Resources.B16x16_KRec_Record); m_ilStr.Images.Add(Properties.Resources.B16x16_LedGreen); m_ilStr.Images.Add(Properties.Resources.B16x16_LedLightBlue); m_ilStr.Images.Add(Properties.Resources.B16x16_LedLightGreen); m_ilStr.Images.Add(Properties.Resources.B16x16_LedOrange); m_ilStr.Images.Add(Properties.Resources.B16x16_View_Remove); m_lvStrings.SmallImageList = m_ilStr; m_tvControls.ImageList = m_ilStr; m_lvStrings.Columns.Add("ID", nWidth / 5); m_lvStrings.Columns.Add("English", (nWidth * 2) / 5); m_lvStrings.Columns.Add("Translated", (nWidth * 2) / 5); m_trl.StringTables.Clear(); KPStringTable kpstP = new KPStringTable(); kpstP.Name = "KeePass.Resources.KPRes"; m_trl.StringTables.Add(kpstP); KPStringTable kpstL = new KPStringTable(); kpstL.Name = "KeePassLib.Resources.KLRes"; m_trl.StringTables.Add(kpstL); KPStringTable kpstM = new KPStringTable(); kpstM.Name = "KeePass.Forms.MainForm.m_menuMain"; m_trl.StringTables.Add(kpstM); KPStringTable kpstE = new KPStringTable(); kpstE.Name = "KeePass.Forms.MainForm.m_ctxPwList"; m_trl.StringTables.Add(kpstE); KPStringTable kpstG = new KPStringTable(); kpstG.Name = "KeePass.Forms.MainForm.m_ctxGroupList"; m_trl.StringTables.Add(kpstG); KPStringTable kpstT = new KPStringTable(); kpstT.Name = "KeePass.Forms.MainForm.m_ctxTray"; m_trl.StringTables.Add(kpstT); KPStringTable kpstET = new KPStringTable(); kpstET.Name = "KeePass.Forms.PwEntryForm.m_ctxTools"; m_trl.StringTables.Add(kpstET); KPStringTable kpstDT = new KPStringTable(); kpstDT.Name = "KeePass.Forms.PwEntryForm.m_ctxDefaultTimes"; m_trl.StringTables.Add(kpstDT); KPStringTable kpstLO = new KPStringTable(); kpstLO.Name = "KeePass.Forms.PwEntryForm.m_ctxListOperations"; m_trl.StringTables.Add(kpstLO); KPStringTable kpstPG = new KPStringTable(); kpstPG.Name = "KeePass.Forms.PwEntryForm.m_ctxPwGen"; m_trl.StringTables.Add(kpstPG); KPStringTable kpstSM = new KPStringTable(); kpstSM.Name = "KeePass.Forms.PwEntryForm.m_ctxStrMoveToStandard"; m_trl.StringTables.Add(kpstSM); KPStringTable kpstBA = new KPStringTable(); kpstBA.Name = "KeePass.Forms.PwEntryForm.m_ctxBinAttach"; m_trl.StringTables.Add(kpstBA); KPStringTable kpstTT = new KPStringTable(); kpstTT.Name = "KeePass.Forms.EcasTriggersForm.m_ctxTools"; m_trl.StringTables.Add(kpstTT); KPStringTable kpstDE = new KPStringTable(); kpstDE.Name = "KeePass.Forms.DataEditorForm.m_menuMain"; m_trl.StringTables.Add(kpstDE); KPStringTable kpstSD = new KPStringTable(); kpstSD.Name = "KeePassLib.Resources.KSRes"; m_trl.StringTables.Add(kpstSD); Type tKP = typeof(KPRes); ListViewGroup lvg = new ListViewGroup("KeePass Strings"); m_lvStrings.Groups.Add(lvg); foreach(string strKey in KPRes.GetKeyNames()) { PropertyInfo pi = tKP.GetProperty(strKey); MethodInfo mi = pi.GetGetMethod(); if(mi.ReturnType != typeof(string)) { MessageBox.Show(this, "Return type is not string:\r\n" + strKey, TrlUtilName + ": Fatal Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string strEng = (mi.Invoke(null, null) as string); if(strEng == null) { MessageBox.Show(this, "English string is null:\r\n" + strKey, TrlUtilName + ": Fatal Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } KPStringTableItem kpstItem = new KPStringTableItem(); kpstItem.Name = strKey; kpstItem.ValueEnglish = strEng; kpstP.Strings.Add(kpstItem); ListViewItem lvi = new ListViewItem(); lvi.Group = lvg; lvi.Text = strKey; lvi.SubItems.Add(strEng); lvi.SubItems.Add(string.Empty); lvi.Tag = kpstItem; lvi.ImageIndex = 0; m_lvStrings.Items.Add(lvi); } Type tKL = typeof(KLRes); lvg = new ListViewGroup("KeePass Library Strings"); m_lvStrings.Groups.Add(lvg); foreach(string strLibKey in KLRes.GetKeyNames()) { PropertyInfo pi = tKL.GetProperty(strLibKey); MethodInfo mi = pi.GetGetMethod(); if(mi.ReturnType != typeof(string)) { MessageBox.Show(this, "Return type is not string:\r\n" + strLibKey, TrlUtilName + ": Fatal Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string strEng = (mi.Invoke(null, null) as string); if(strEng == null) { MessageBox.Show(this, "English string is null:\r\n" + strLibKey, TrlUtilName + ": Fatal Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } KPStringTableItem kpstItem = new KPStringTableItem(); kpstItem.Name = strLibKey; kpstItem.ValueEnglish = strEng; kpstL.Strings.Add(kpstItem); ListViewItem lvi = new ListViewItem(); lvi.Group = lvg; lvi.Text = strLibKey; lvi.SubItems.Add(strEng); lvi.SubItems.Add(string.Empty); lvi.Tag = kpstItem; lvi.ImageIndex = 0; m_lvStrings.Items.Add(lvi); } lvg = new ListViewGroup("Main Menu Commands"); m_lvStrings.Groups.Add(lvg); KeePass.Forms.MainForm mf = new KeePass.Forms.MainForm(); TrlAddMenuCommands(kpstM, lvg, mf.MainMenu.Items); lvg = new ListViewGroup("Entry Context Menu Commands"); m_lvStrings.Groups.Add(lvg); TrlAddMenuCommands(kpstE, lvg, mf.EntryContextMenu.Items); lvg = new ListViewGroup("Group Context Menu Commands"); m_lvStrings.Groups.Add(lvg); TrlAddMenuCommands(kpstG, lvg, mf.GroupContextMenu.Items); lvg = new ListViewGroup("System Tray Context Menu Commands"); m_lvStrings.Groups.Add(lvg); TrlAddMenuCommands(kpstT, lvg, mf.TrayContextMenu.Items); KeePass.Forms.PwEntryForm ef = new KeePass.Forms.PwEntryForm(); lvg = new ListViewGroup("Entry Tools Context Menu Commands"); m_lvStrings.Groups.Add(lvg); TrlAddMenuCommands(kpstET, lvg, ef.ToolsContextMenu.Items); lvg = new ListViewGroup("Default Times Context Menu Commands"); m_lvStrings.Groups.Add(lvg); TrlAddMenuCommands(kpstDT, lvg, ef.DefaultTimesContextMenu.Items); lvg = new ListViewGroup("List Operations Context Menu Commands"); m_lvStrings.Groups.Add(lvg); TrlAddMenuCommands(kpstLO, lvg, ef.ListOperationsContextMenu.Items); lvg = new ListViewGroup("Password Generator Context Menu Commands"); m_lvStrings.Groups.Add(lvg); TrlAddMenuCommands(kpstPG, lvg, ef.PasswordGeneratorContextMenu.Items); KeePass.Forms.EcasTriggersForm tf = new KeePass.Forms.EcasTriggersForm(); lvg = new ListViewGroup("Ecas Trigger Tools Context Menu Commands"); m_lvStrings.Groups.Add(lvg); TrlAddMenuCommands(kpstTT, lvg, tf.ToolsContextMenu.Items); KeePass.Forms.DataEditorForm df = new KeePass.Forms.DataEditorForm(); lvg = new ListViewGroup("Data Editor Menu Commands"); m_lvStrings.Groups.Add(lvg); TrlAddMenuCommands(kpstDE, lvg, df.MainMenuEx.Items); lvg = new ListViewGroup("Standard String Movement Context Menu Commands"); m_lvStrings.Groups.Add(lvg); TrlAddMenuCommands(kpstSM, lvg, ef.StandardStringMovementContextMenu.Items); lvg = new ListViewGroup("Entry Attachments Context Menu Commands"); m_lvStrings.Groups.Add(lvg); TrlAddMenuCommands(kpstBA, lvg, ef.AttachmentsContextMenu.Items); Type tSD = typeof(KSRes); lvg = new ListViewGroup("KeePassLibSD Strings"); m_lvStrings.Groups.Add(lvg); foreach(string strLibSDKey in KSRes.GetKeyNames()) { PropertyInfo pi = tSD.GetProperty(strLibSDKey); MethodInfo mi = pi.GetGetMethod(); if(mi.ReturnType != typeof(string)) { MessageBox.Show(this, "Return type is not string:\r\n" + strLibSDKey, TrlUtilName + ": Fatal Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string strEng = (mi.Invoke(null, null) as string); if(strEng == null) { MessageBox.Show(this, "English string is null:\r\n" + strLibSDKey, TrlUtilName + ": Fatal Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } KPStringTableItem kpstItem = new KPStringTableItem(); kpstItem.Name = strLibSDKey; kpstItem.ValueEnglish = strEng; kpstL.Strings.Add(kpstItem); ListViewItem lvi = new ListViewItem(); lvi.Group = lvg; lvi.Text = strLibSDKey; lvi.SubItems.Add(strEng); lvi.SubItems.Add(string.Empty); lvi.Tag = kpstItem; lvi.ImageIndex = 0; m_lvStrings.Items.Add(lvi); } } private void TrlAddMenuCommands(KPStringTable kpst, ListViewGroup grp, ToolStripItemCollection tsic) { foreach(ToolStripItem tsi in tsic) { if(tsi.Text.Length == 0) continue; if(tsi.Text.StartsWith(@"<") && tsi.Text.EndsWith(@">")) continue; KPStringTableItem kpstItem = new KPStringTableItem(); kpstItem.Name = tsi.Name; kpstItem.ValueEnglish = tsi.Text; kpst.Strings.Add(kpstItem); ListViewItem lvi = new ListViewItem(); lvi.Group = grp; lvi.Text = tsi.Name; lvi.SubItems.Add(tsi.Text); lvi.SubItems.Add(string.Empty); lvi.Tag = kpstItem; lvi.ImageIndex = 0; m_lvStrings.Items.Add(lvi); ToolStripMenuItem tsmi = (tsi as ToolStripMenuItem); if(tsmi != null) TrlAddMenuCommands(kpst, grp, tsmi.DropDownItems); } } private void UpdateStringTableUI() { foreach(ListViewItem lvi in m_lvStrings.Items) { KPStringTableItem kpstItem = (lvi.Tag as KPStringTableItem); Debug.Assert(kpstItem != null); if(kpstItem == null) continue; lvi.SubItems[2].Text = kpstItem.Value; } } private void UpdateControlTree() { FormTrlMgr.RenderToTreeControl(m_trl.Forms, m_tvControls); UpdateStatusImages(null); } private void UpdateUIState() { bool bTrlTab = ((m_tabMain.SelectedTab == m_tabStrings) || (m_tabMain.SelectedTab == m_tabDialogs)); m_menuEditNextUntrl.Enabled = bTrlTab; m_tbNextUntrl.Enabled = bTrlTab; m_tbFind.Enabled = bTrlTab; } private void OnLinkLangCodeClicked(object sender, LinkLabelLinkClickedEventArgs e) { try { Process.Start(@"http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes"); } catch(Exception ex) { MessageBox.Show(this, ex.Message, TrlUtilName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } private void OnFileOpen(object sender, EventArgs e) { OpenFileDialogEx ofd = UIUtil.CreateOpenFileDialog("Open KeePass Translation", m_strFileFilter, 1, null, false, AppDefs.FileDialogContext.Attachments); if(ofd.ShowDialog() != DialogResult.OK) return; KPTranslation kpTrl = null; try { XmlSerializerEx xs = new XmlSerializerEx(typeof(KPTranslation)); kpTrl = KPTranslation.LoadFromFile(ofd.FileName, xs); } catch(Exception ex) { MessageBox.Show(this, ex.Message, TrlUtilName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } m_strFile = ofd.FileName; StringBuilder sbUnusedText = new StringBuilder(); if(kpTrl.UnusedText.Length > 0) { if(kpTrl.UnusedText.EndsWith("\r") || kpTrl.UnusedText.EndsWith("\n")) sbUnusedText.Append(kpTrl.UnusedText); else sbUnusedText.AppendLine(kpTrl.UnusedText); } m_trl.Properties = kpTrl.Properties; foreach(KPStringTable kpstNew in kpTrl.StringTables) { foreach(KPStringTable kpstInto in m_trl.StringTables) { if(kpstInto.Name == kpstNew.Name) MergeInStringTable(kpstInto, kpstNew, sbUnusedText); } } FormTrlMgr.MergeForms(m_trl.Forms, kpTrl.Forms, sbUnusedText); m_tbNameEng.Text = m_trl.Properties.NameEnglish; m_tbNameLcl.Text = m_trl.Properties.NameNative; m_tbLangID.Text = m_trl.Properties.Iso6391Code; m_tbAuthorName.Text = m_trl.Properties.AuthorName; m_tbAuthorContact.Text = m_trl.Properties.AuthorContact; m_cbRtl.Checked = m_trl.Properties.RightToLeft; m_rtbUnusedText.Text = sbUnusedText.ToString(); this.UpdateStringTableUI(); this.UpdateStatusImages(null); this.UpdatePreviewForm(); } private void MergeInStringTable(KPStringTable tbInto, KPStringTable tbSource, StringBuilder sbUnusedText) { foreach(KPStringTableItem kpSrc in tbSource.Strings) { bool bHasAssigned = false; foreach(KPStringTableItem kpDst in tbInto.Strings) { if(kpSrc.Name == kpDst.Name) { if(kpSrc.Value.Length > 0) { kpDst.Value = kpSrc.Value; bHasAssigned = true; } } } if(!bHasAssigned) { string strTrimmed = kpSrc.Value.Trim(); if(strTrimmed.Length > 0) sbUnusedText.AppendLine(strTrimmed); } } } private void UpdateInternalTranslation() { m_trl.Properties.NameEnglish = StrUtil.SafeXmlString(m_tbNameEng.Text); m_trl.Properties.NameNative = StrUtil.SafeXmlString(m_tbNameLcl.Text); m_trl.Properties.Iso6391Code = StrUtil.SafeXmlString(m_tbLangID.Text); m_trl.Properties.AuthorName = StrUtil.SafeXmlString(m_tbAuthorName.Text); m_trl.Properties.AuthorContact = StrUtil.SafeXmlString(m_tbAuthorContact.Text); m_trl.Properties.RightToLeft = m_cbRtl.Checked; } private void UpdateStatusImages(TreeNodeCollection vtn) { if(vtn == null) vtn = m_tvControls.Nodes; foreach(TreeNode tn in vtn) { KPFormCustomization kpfc = (tn.Tag as KPFormCustomization); KPControlCustomization kpcc = (tn.Tag as KPControlCustomization); if(kpfc != null) { tn.ImageIndex = m_inxWindow; tn.SelectedImageIndex = m_inxWindow; } else if(kpcc != null) { int iCurrentImage = tn.ImageIndex, iNewImage; if(Array.IndexOf(m_vEmpty, kpcc.TextEnglish) >= 0) iNewImage = ((kpcc.Text.Length == 0) ? m_inxOk : m_inxWarning); else if((kpcc.TextEnglish.Length > 0) && (kpcc.Text.Length > 0)) iNewImage = m_inxOk; else if((kpcc.TextEnglish.Length > 0) && (kpcc.Text.Length == 0)) iNewImage = m_inxMissing; else if((kpcc.TextEnglish.Length == 0) && (kpcc.Text.Length == 0)) iNewImage = m_inxOk; else if((kpcc.TextEnglish.Length == 0) && (kpcc.Text.Length > 0)) iNewImage = m_inxWarning; else iNewImage = m_inxWarning; if(iNewImage != iCurrentImage) { tn.ImageIndex = iNewImage; tn.SelectedImageIndex = iNewImage; } } else { Debug.Assert(false); } if(tn.Nodes != null) UpdateStatusImages(tn.Nodes); } } private void OnFileSave(object sender, EventArgs e) { UpdateInternalTranslation(); if(m_strFile.Length == 0) { OnFileSaveAs(sender, e); return; } PrepareSave(); try { XmlSerializerEx xs = new XmlSerializerEx(typeof(KPTranslation)); KPTranslation.SaveToFile(m_trl, m_strFile, xs); m_bModified = false; } catch(Exception ex) { MessageBox.Show(this, ex.Message, TrlUtilName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } private void PrepareSave() { m_trl.Properties.Application = PwDefs.ProductName; m_trl.Properties.ApplicationVersion = PwDefs.VersionString; m_trl.Properties.Generator = TrlUtilName; PwUuid pwUuid = new PwUuid(true); m_trl.Properties.FileUuid = pwUuid.ToHexString(); m_trl.Properties.LastModified = DateTime.Now.ToString("u"); m_trl.UnusedText = m_rtbUnusedText.Text; try { Validate3Dots(); } catch(Exception) { Debug.Assert(false); } try { string strAccel = AccelKeysCheck.Validate(m_trl); if(strAccel != null) { MessageBox.Show(this, "Warning! The following accelerator keys collide:" + MessageService.NewParagraph + strAccel + MessageService.NewParagraph + "Click [OK] to continue saving.", TrlUtilName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch(Exception) { Debug.Assert(false); } } private void Validate3Dots() { if(m_trl.Properties.RightToLeft) return; // Check doesn't support RTL foreach(KPStringTable kpst in m_trl.StringTables) { foreach(KPStringTableItem kpi in kpst.Strings) { string strEn = kpi.ValueEnglish; string strTrl = kpi.Value; if(string.IsNullOrEmpty(strEn) || string.IsNullOrEmpty(strTrl)) continue; bool bEllEn = (strEn.EndsWith(@"...") || strEn.EndsWith(@"…")); bool bEllTrl = (strTrl.EndsWith(@"...") || strTrl.EndsWith(@"…")); if(bEllEn && !bEllTrl) MessageBox.Show(this, "Warning! The English string" + MessageService.NewParagraph + strEn + MessageService.NewParagraph + "ends with 3 dots, but the translated string does not:" + MessageService.NewParagraph + strTrl, TrlUtilName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } private void OnFileExit(object sender, EventArgs e) { if(m_bModified) OnFileSaveAs(sender, e); this.Close(); } private void OnStringsSelectedIndexChanged(object sender, EventArgs e) { ListView.SelectedListViewItemCollection lvsic = m_lvStrings.SelectedItems; if(lvsic.Count != 1) { m_tbStrEng.Text = string.Empty; m_tbStrTrl.Text = string.Empty; return; } KPStringTableItem kpstItem = (lvsic[0].Tag as KPStringTableItem); Debug.Assert(kpstItem != null); if(kpstItem == null) return; UIUtil.SetMultilineText(m_tbStrEng, lvsic[0].SubItems[1].Text); m_tbStrTrl.Text = lvsic[0].SubItems[2].Text; } private void OnStrKeyDown(object sender, KeyEventArgs e) { if((e.KeyCode == Keys.Return) || (e.KeyCode == Keys.Enter)) { UIUtil.SetHandled(e, true); ListView.SelectedListViewItemCollection lvsic = m_lvStrings.SelectedItems; if(lvsic.Count != 1) return; KPStringTableItem kpstItem = (lvsic[0].Tag as KPStringTableItem); if(kpstItem == null) { Debug.Assert(false); return; } kpstItem.Value = StrUtil.SafeXmlString(m_tbStrTrl.Text); this.UpdateStringTableUI(); int iIndex = lvsic[0].Index; if(iIndex < m_lvStrings.Items.Count - 1) { lvsic[0].Selected = false; UIUtil.SetFocusedItem(m_lvStrings, m_lvStrings.Items[ iIndex + 1], true); } m_bModified = true; } } private void OnStrKeyUp(object sender, KeyEventArgs e) { if((e.KeyCode == Keys.Return) || (e.KeyCode == Keys.Enter)) UIUtil.SetHandled(e, true); } private void OnFileSaveAs(object sender, EventArgs e) { SaveFileDialogEx sfd = UIUtil.CreateSaveFileDialog("Save KeePass Translation", m_tbNameEng.Text + ".lngx", m_strFileFilter, 1, "lngx", AppDefs.FileDialogContext.Attachments); if(sfd.ShowDialog() != DialogResult.OK) return; m_strFile = sfd.FileName; OnFileSave(sender, e); } private void OnStrDoubleClick(object sender, EventArgs e) { UIUtil.SetFocus(m_tbStrTrl, this); } private void OnCustomControlsAfterSelect(object sender, TreeViewEventArgs e) { ShowCustomControlProps(e.Node.Tag as KPControlCustomization); UpdatePreviewForm(); } private void ShowCustomControlProps(KPControlCustomization kpcc) { if(kpcc == null) return; // No assert m_kpccLast = kpcc; UIUtil.SetMultilineText(m_tbCtrlEngText, m_kpccLast.TextEnglish); m_tbCtrlTrlText.Text = m_kpccLast.Text; m_tbLayoutX.Text = KpccLayout.ToControlRelativeString(m_kpccLast.Layout.X); m_tbLayoutY.Text = KpccLayout.ToControlRelativeString(m_kpccLast.Layout.Y); m_tbLayoutW.Text = KpccLayout.ToControlRelativeString(m_kpccLast.Layout.Width); m_tbLayoutH.Text = KpccLayout.ToControlRelativeString(m_kpccLast.Layout.Height); } private void OnCtrlTrlTextChanged(object sender, EventArgs e) { string strText = m_tbCtrlTrlText.Text; if((m_kpccLast != null) && (m_kpccLast.Text != strText)) { m_kpccLast.Text = StrUtil.SafeXmlString(m_tbCtrlTrlText.Text); m_bModified = true; } UpdateStatusImages(null); UpdatePreviewForm(); } private void OnLayoutXTextChanged(object sender, EventArgs e) { if(m_kpccLast != null) { m_kpccLast.Layout.SetControlRelativeValue( KpccLayout.LayoutParameterEx.X, m_tbLayoutX.Text); m_bModified = true; UpdatePreviewForm(); } } private void OnLayoutYTextChanged(object sender, EventArgs e) { if(m_kpccLast != null) { m_kpccLast.Layout.SetControlRelativeValue( KpccLayout.LayoutParameterEx.Y, m_tbLayoutY.Text); m_bModified = true; UpdatePreviewForm(); } } private void OnLayoutWidthTextChanged(object sender, EventArgs e) { if(m_kpccLast != null) { m_kpccLast.Layout.SetControlRelativeValue( KpccLayout.LayoutParameterEx.Width, m_tbLayoutW.Text); m_bModified = true; UpdatePreviewForm(); } } private void OnLayoutHeightTextChanged(object sender, EventArgs e) { if(m_kpccLast != null) { m_kpccLast.Layout.SetControlRelativeValue( KpccLayout.LayoutParameterEx.Height, m_tbLayoutH.Text); m_bModified = true; UpdatePreviewForm(); } } private void OnCtrlTrlTextKeyDown(object sender, KeyEventArgs e) { if((e.KeyCode == Keys.Return) || (e.KeyCode == Keys.Enter)) { UIUtil.SetHandled(e, true); TreeNode tn = m_tvControls.SelectedNode; if(tn == null) return; try { TreeNode tnNew = tn.NextNode; if(tnNew != null) m_tvControls.SelectedNode = tnNew; } catch(Exception) { Debug.Assert(false); } } } private void OnCtrlTrlTextKeyUp(object sender, KeyEventArgs e) { if((e.KeyCode == Keys.Return) || (e.KeyCode == Keys.Enter)) UIUtil.SetHandled(e, true); } private void UpdatePreviewForm() { TreeNode tn = m_tvControls.SelectedNode; if(tn == null) return; if(tn.Parent != null) tn = tn.Parent; string strFormName = tn.Text; foreach(KPFormCustomization kpfc in m_trl.Forms) { if(kpfc.FullName.EndsWith(strFormName)) { UpdatePreviewForm(kpfc); break; } } } private void UpdatePreviewForm(KPFormCustomization kpfc) { // bool bResizeEng = (string.IsNullOrEmpty(kpfc.Window.Layout.Width) && // string.IsNullOrEmpty(kpfc.Window.Layout.Height)); m_prev.CopyForm(kpfc.FormEnglish); kpfc.ApplyTo(m_prev); } private void OnBtnClearUnusedText(object sender, EventArgs e) { m_rtbUnusedText.Text = string.Empty; } private void OnImport1xLng(object sender, EventArgs e) { PerformImport("lng", "KeePass 1.x LNG File", Import1xLng); } private static void Import1xLng(KPTranslation trlInto, IOConnectionInfo ioc) { TrlImport.Import1xLng(trlInto, ioc.Path); } private void PerformImport(string strFileExt, string strFileDesc, ImportFn f) { OpenFileDialogEx ofd = UIUtil.CreateOpenFileDialog("Import " + strFileDesc, strFileDesc + " (*." + strFileExt + ")|*." + strFileExt + "|All Files (*.*)|*.*", 1, strFileExt, false, AppDefs.FileDialogContext.Import); if(ofd.ShowDialog() != DialogResult.OK) return; try { f(m_trl, IOConnectionInfo.FromPath(ofd.FileName)); } catch(Exception ex) { MessageBox.Show(this, ex.Message, TrlUtilName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } UpdateStringTableUI(); UpdateControlTree(); m_tvControls.SelectedNode = m_tvControls.Nodes[0]; UpdatePreviewForm(); } private void PerformQuickFind() { string str = m_tbFind.Text; if(string.IsNullOrEmpty(str)) return; bool bResult = true; if(m_tabMain.SelectedTab == m_tabStrings) bResult = PerformQuickFindStrings(str); else if(m_tabMain.SelectedTab == m_tabDialogs) bResult = PerformQuickFindDialogs(str); if(!bResult) m_tbFind.BackColor = AppDefs.ColorEditError; } private bool PerformQuickFindStrings(string strFind) { int nItems = m_lvStrings.Items.Count; if(nItems == 0) return false; ListViewItem lviStart = m_lvStrings.FocusedItem; int iOffset = ((lviStart != null) ? (lviStart.Index + 1) : 0); for(int i = 0; i < nItems; ++i) { int j = ((iOffset + i) % nItems); ListViewItem lvi = m_lvStrings.Items[j]; foreach(ListViewItem.ListViewSubItem lvsi in lvi.SubItems) { if(lvsi.Text.IndexOf(strFind, StrUtil.CaseIgnoreCmp) >= 0) { UIUtil.SetFocusedItem(m_lvStrings, lvi, false); m_lvStrings.SelectedItems.Clear(); lvi.Selected = true; m_lvStrings.EnsureVisible(j); return true; } } } return false; } private bool PerformQuickFindDialogs(string strFind) { List vNodes = new List(); List vValues = new List(); GetControlTreeItems(m_tvControls.Nodes, vNodes, vValues); int iOffset = vNodes.IndexOf(m_tvControls.SelectedNode) + 1; for(int i = 0; i < vNodes.Count; ++i) { int j = ((iOffset + i) % vNodes.Count); if(vValues[j].IndexOf(strFind, StrUtil.CaseIgnoreCmp) >= 0) { m_tvControls.SelectedNode = vNodes[j]; return true; } } return false; } private void GetControlTreeItems(TreeNodeCollection tnBase, List vNodes, List vValues) { foreach(TreeNode tn in tnBase) { KPFormCustomization kpfc = (tn.Tag as KPFormCustomization); KPControlCustomization kpcc = (tn.Tag as KPControlCustomization); vNodes.Add(tn); if(kpfc != null) vValues.Add(kpfc.Window.Name + "©" + kpfc.Window.TextEnglish + "©" + kpfc.Window.Text); else if(kpcc != null) vValues.Add(kpcc.Name + "©" + kpcc.TextEnglish + "©" + kpcc.Text); else vValues.Add(tn.Text); GetControlTreeItems(tn.Nodes, vNodes, vValues); } } private void OnFindKeyDown(object sender, KeyEventArgs e) { if((e.KeyCode == Keys.Return) || (e.KeyCode == Keys.Enter)) { UIUtil.SetHandled(e, true); PerformQuickFind(); return; } } private void OnFindKeyUp(object sender, KeyEventArgs e) { if((e.KeyCode == Keys.Return) || (e.KeyCode == Keys.Enter)) { UIUtil.SetHandled(e, true); return; } } private void OnFindTextChanged(object sender, EventArgs e) { m_tbFind.ResetBackColor(); } private void OnTabMainSelectedIndexChanged(object sender, EventArgs e) { UpdateUIState(); } private void OnImport2xNoChecks(object sender, EventArgs e) { FormTrlMgr.IgnoreBaseHash = true; OnFileOpen(sender, EventArgs.Empty); FormTrlMgr.IgnoreBaseHash = false; } private void OnImportPo(object sender, EventArgs e) { PerformImport("po", "PO File", ImportPo); } private static void ImportPo(KPTranslation trlInto, IOConnectionInfo ioc) { TrlImport.ImportPo(trlInto, ioc.Path); } private void OnEditNextUntrl(object sender, EventArgs e) { if(m_tabMain.SelectedTab == m_tabStrings) { int nItems = m_lvStrings.Items.Count; if(nItems == 0) { Debug.Assert(false); return; } ListViewItem lviStart = m_lvStrings.FocusedItem; int iOffset = ((lviStart != null) ? (lviStart.Index + 1) : 0); for(int i = 0; i < nItems; ++i) { int j = ((iOffset + i) % nItems); ListViewItem lvi = m_lvStrings.Items[j]; KPStringTableItem kpstItem = (lvi.Tag as KPStringTableItem); if(kpstItem == null) { Debug.Assert(false); continue; } if(string.IsNullOrEmpty(kpstItem.Value) && !string.IsNullOrEmpty(kpstItem.ValueEnglish)) { m_lvStrings.EnsureVisible(j); lvi.Selected = true; lvi.Focused = true; UIUtil.SetFocus(m_tbStrTrl, this); return; } } } else if(m_tabMain.SelectedTab == m_tabDialogs) { List vNodes = new List(); List vValues = new List(); GetControlTreeItems(m_tvControls.Nodes, vNodes, vValues); int iOffset = vNodes.IndexOf(m_tvControls.SelectedNode) + 1; for(int i = 0; i < vNodes.Count; ++i) { int j = ((iOffset + i) % vNodes.Count); TreeNode tn = vNodes[j]; string strEng = null, strText = null; KPControlCustomization kpcc = (tn.Tag as KPControlCustomization); if(kpcc != null) { strEng = kpcc.TextEnglish; strText = kpcc.Text; } if(string.IsNullOrEmpty(strEng) || (Array.IndexOf( m_vEmpty, strEng) >= 0)) strText = "Dummy"; if(string.IsNullOrEmpty(strText)) { m_tvControls.SelectedNode = tn; UIUtil.SetFocus(m_tbCtrlTrlText, this); return; } } } else { Debug.Assert(false); return; } // Unsupported tab // MessageService.ShowInfo("No untranslated strings found on the current tab page."); MessageBox.Show(this, "No untranslated strings found on the current tab page.", TrlUtilName, MessageBoxButtons.OK, MessageBoxIcon.Information); } } } keepass2-2.25/Translation/TrlUtil/PreviewForm.cs0000664000175000017500000001112312261553106021603 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Windows.Forms; using System.Drawing; using System.Diagnostics; using System.Reflection; using KeePass.UI; namespace TrlUtil { public sealed class PreviewForm : Form { private static Random m_rand = new Random(); public PreviewForm() { try { this.DoubleBuffered = true; } catch(Exception) { Debug.Assert(false); } } protected override void OnKeyDown(KeyEventArgs e) { if(e.KeyCode == Keys.Escape) UIUtil.SetHandled(e, true); else base.OnKeyDown(e); } protected override void OnKeyUp(KeyEventArgs e) { if(e.KeyCode == Keys.Escape) UIUtil.SetHandled(e, true); else base.OnKeyUp(e); } public void CopyForm(Form f) { this.SuspendLayout(); this.MinimizeBox = false; this.MaximizeBox = false; this.ControlBox = false; this.FormBorderStyle = FormBorderStyle.FixedDialog; this.Controls.Clear(); this.ClientSize = f.ClientSize; this.Text = f.Text; CopyChildControls(this, f); this.ResumeLayout(true); } private void CopyChildControls(Control cDest, Control cSource) { if((cDest == null) || (cSource == null)) return; foreach(Control c in cSource.Controls) { Type t = c.GetType(); Control cCopy; bool bCopyChilds = true; if(t == typeof(Button)) cCopy = new Button(); else if(t == typeof(Label)) { cCopy = new Label(); (cCopy as Label).AutoSize = (c as Label).AutoSize; } else if(t == typeof(CheckBox)) cCopy = new CheckBox(); else if(t == typeof(RadioButton)) cCopy = new RadioButton(); else if(t == typeof(GroupBox)) cCopy = new GroupBox(); // NumericUpDown leads to GDI objects leak // else if(t == typeof(NumericUpDown)) cCopy = new NumericUpDown(); else if(t == typeof(Panel)) cCopy = new Panel(); else if(t == typeof(TabControl)) cCopy = new TabControl(); else if(t == typeof(TabPage)) cCopy = new TabPage(); else if(t == typeof(ComboBox)) { cCopy = new ComboBox(); (cCopy as ComboBox).DropDownStyle = (c as ComboBox).DropDownStyle; } else if(t == typeof(PromptedTextBox)) { cCopy = new PromptedTextBox(); (cCopy as PromptedTextBox).Multiline = (c as PromptedTextBox).Multiline; } else if(t == typeof(TextBox)) { cCopy = new TextBox(); (cCopy as TextBox).Multiline = (c as TextBox).Multiline; } else if((t == typeof(RichTextBox)) || // RTB leads to GDI objects leak (t == typeof(CustomRichTextBoxEx))) { cCopy = new TextBox(); (cCopy as TextBox).Multiline = true; } else { cCopy = new Label(); bCopyChilds = false; } Color clr = Color.FromArgb(128 + m_rand.Next(0, 128), 128 + m_rand.Next(0, 128), 128 + m_rand.Next(0, 128)); cCopy.Name = c.Name; cCopy.Font = c.Font; cCopy.BackColor = clr; cCopy.Text = c.Text; Type tCopy = cCopy.GetType(); PropertyInfo piAutoSizeSrc = t.GetProperty("AutoSize", typeof(bool)); PropertyInfo piAutoSizeDst = tCopy.GetProperty("AutoSize", typeof(bool)); if((piAutoSizeSrc != null) && (piAutoSizeDst != null)) { MethodInfo miSrc = piAutoSizeSrc.GetGetMethod(); MethodInfo miDst = piAutoSizeDst.GetSetMethod(); miDst.Invoke(cCopy, new object[] { miSrc.Invoke(c, null) }); } try { cDest.Controls.Add(cCopy); if(bCopyChilds) CopyChildControls(cCopy, c); } catch(Exception) { Debug.Assert(false); } cCopy.Left = c.Left; cCopy.Top = c.Top; cCopy.Width = c.Width; cCopy.Height = c.Height; cCopy.ClientSize = c.ClientSize; if(c.Dock != DockStyle.None) cCopy.Dock = c.Dock; } } } } keepass2-2.25/Translation/DefaultText.xml0000664000175000017500000020564712270756216020412 0ustar jtaylorjtaylor Action Activate database (select tab) Add Entry Create a new entry. Add Group Create a new entry group. Add Entry String Field Create a new string field for the current entry. Advanced After Opening a Database Align Center Align Left Align Right All Entries All Files All Supported Files Use alternating item background colors Application Application exit Application initialized Application started and ready Arguments &Ascending Do you want to continue? Asterisks The following file has already been attached to the current entry: Discard any changes made to the temporary file and do not modify the current attachment. Replace the attachment by the (modified) temporary file. KeePass has extracted the attachment to a (EFS-encrypted) temporary file and opened it using an external application. After viewing/editing and closing the file in the external application, please choose how to continue In any case, KeePass will securely delete the temporary file afterwards. 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 Auto 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 Cancel auto-type when the target window title changes Cancel auto-type when the target window changes 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. If you want KeePass to search the active database for a matching entry and auto-type it, use the 'Global auto-type' hot key. An entry matches if one of its tags is contained in the target window title An entry matches if its title is contained in the target window title An entry matches if the host component of its URL is contained in the target window title An entry matches if its URL is contained in the target window title Auto-type obfuscation may not work with all windows. Prepend special initialization sequence for Internet Explorer windows Send Alt keypress when only the Alt modifier is active To use the 'Auto-type selected entry' hot key, you first need to select an entry in KeePass. The specified auto-type sequence is invalid. The following auto-type placeholder or special key code is unknown/unsupported: The 'xdotool' utility/package is required for auto-type. For global auto-type, the 'xdotool' utility/package is required (version 2.20100818.3004 or higher!). Available Available Languages Background Color Binary (no conversion) Bits Bold Browser built-in < &Back &Finish &Next > Cancel &Cancel Cannot move entries because they aren't stored in the same group. Change Master Key You are changing the composite master key for the currently-open database. Check for update at KeePass startup Checking for updates Clear master key command line parameters after using them once &Clear List Clipboard Clipboard will be cleared in [PARAM] seconds Clear clipboard when closing KeePass Data copied to clipboard. Use 'Clipboard Viewer Ignore' clipboard format Close active database &Close Close button [X] minimizes main window instead of terminating the application Closing database file Column Columns Company Comparison Component 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 Columns Configure entry list columns. 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 Link Copy Copy Password to Clipboard Copy &Password Copy &TAN Copy URLs to clipboard instead of opening them &Copy URL(s) to Clipboard Copy User Name to Clipboard Copy Whole Entries Count Create Composite Master Key Create New Password Database Create new &IDs Creation Time Remember user name and password Do not remember user name and password Remember user name only There must be exactly one .csproj or .vbproj file. CSV / Text File Current Style Custom Custom Fields Customizable HTML File Add custom toolbar button Custom toolbar button clicked Remove custom toolbar button 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. Active database has unsaved changes Data Editor Data Viewer Show results of database maintenance in a dialog {PARAM} has not modified the database. Default Delete &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? &Descending Description Details Do not show this dialog again. Disable Disabled Disable 'Save' command (instead of graying it out) if the database hasn't been modified &Discard changes Please see the documentation for more details. Drag&Drop Drop to background after copying data to the clipboard The string field name you specified already exists. String field names must be unique for each entry. &Edit Edit Entry You're editing an existing entry. Edit Group Edit properties of the currently selected group. Edit Entry String Field Edit one of the entry's string fields. eMail Empty You have selected to use an empty master password. An empty master password is not the same as using no master password at all. Are you sure you want to use an empty master password? Are you sure you want to permanently delete the items? Enable Enabled Encoding Selected encoding is invalid. The file cannot be interpreted using the selected encoding. Ends with Enter Master Key Enter Current Master Key Generate additional random bits. Entropy Collection Entry Entry List Automatically resize entry list columns when resizing the main window Environment variable Equals Error Code Errors Event Execute command line / URL Exit instead of locking the workspace after the specified time Always exit instead of locking the workspace Expired Entries Expiry Time Expiry Time (Date Only) Export Export data to an external file. Export File/Data Export To HTML Export entries to a HTML file. Exporting... Export active database Export to: External Application Fatal Error Feature Field 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 File format 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 Find Focus quick search box when restoring from taskbar Focus quick search box when restoring from tray Focus entry list after a successful quick search Folder Font Force using system font (Unix only) Format 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. General Generate 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. {PARAM}-Bit Hex Key Hex Viewer Hide field using asterisks History Homebanking Host It is highly recommended not to use global hot keys with only Alt or Alt-Shift as modifier. Recommended modifiers are Ctrl-Alt, Ctrl-Shift and Ctrl-Alt-Shift. Are you sure you want to use the specified hot keys? 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? Import into active database incompatible with sorting Inherit setting from parent Installed Allow interleaved sending of keys Internal Editor Internal Viewer Internet Invalid Key The specified URL is invalid. The specified user name / password combination is invalid. IO Connection File Input/Output Connections Italic 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. Importing/exporting data from/to KDB files is only supported on Windows (because a library is used that contains the core code of KeePass 1.x, which is Windows-only). Please use a different file format for migrating your data. &Keep existing Alt Ctrl LCtrl Esc Key Modifiers Return Shift LShift Key Changed Key file 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 The selected key provider cannot be used, because it is incompatible with the secure desktop. If you want to use the selected key provider, you have to disable the secure desktop option in 'Tools' -> 'Options' -> tab 'Security'. 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 the remote control mode changes Lock workspace when locking the computer or switching the user Lock workspace when the computer is about to be suspended Main Window Composite master key has been changed! Save the database now in order to get the new key applied. The master key for this database has been used for quite a while and must be changed now. Click [OK] to open the master key changing dialog. Do you want to change the master key now? The master key for this database has been used for quite a while and it is recommended to change it now. Enter master key on secure desktop The master password must be at least {PARAM} characters long! The estimated quality of the master password must be at least {PARAM} bits! Menus Method 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 More {PARAM} more entries Name Use native library for faster key transformations Navigation Network Never expires New New Database NewDatabase.kdbx A newer .NET Framework is required. New Group New line New state New version available No The operating system didn't grant KeePass read access to the specified file. (None) No Key Repeat None &No Sort Not (not recommended) Notes Not installed The selected file isn't a valid XSL stylesheet. The object with the specified name could not be found. {PARAM} object(s) deleted Off of On Operation aborted. &Open Open Database Open Database File Open database file Opened Opened database file Opening password database... &Open URL(s) Open with {PARAM} 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 Built-In Overrides Custom Overrides Overwrite Overwrite &existing Overwrite the existing file? Overwrite if &newer Overwrite if newer and apply &deletions Install this package and try again. 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! Repeat the password to prevent typing errors. Paste Perform Auto-&Type Perform global auto-type Perform auto-type with selected entry Pick Characters Select the requested character positions. Pick an icon. Plugin This plugin appears to be a plugin for KeePass 1.x. KeePass 1.x plugins cannot be used together with KeePass 2.x and vice versa. The plugin cache will be cleared and rebuilt if necessary when KeePass is restarted. The following plugin is incompatible with the current KeePass version: The plugin cannot be loaded. The current operating system is unsupported by the plugin. Provided by Plugins Plugins Compiling and loading plugins... Here you can configure all loaded KeePass plugins. Have a look at the plugin's website for an appropriate version. Allow auto-typing entries to other windows. Allow auto-typing using the 'Perform Auto-Type' command (Ctrl+V). Allow changing the master key of a database. Do not require entering current master key before changing it. Allow copying entry information to clipboard (main window only). Allow copying whole entries to clipboard. 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. Do not require entering current master key before exporting. Allow importing entries from external files. Allow creating new database files. Allow loading plugins to extend KeePass functionality. Allow printing entry lists. Do not require entering current master key before printing. The following policy flag is required Allow saving databases to disk/URL. Allow editing triggers. Pre-release version Print Print password entries. Exclude expired entries in quick searches Search for passwords in quick searches Resolve field references in quick searches Quick Search (Toolbar) Random MAC Address Ready. recommended &Recommended Recycle Bin Collapse newly-created recycle bin tree node Redo Remember password hiding setting in 'Edit Entry' window Remember key sources (key file paths, provider names, ...) Remember working directories Remote host is reachable (ping) Repair Mode In repair mode, the integrity of the data is not checked (in order to rescue as much data as possible). When no integrity checks are performed, corrupted/malicious data might be incorporated into the database. Are you sure you want to attempt to repair the selected file? Thus the repair functionality should only be used when there really is no other solution. If you use it, afterwards you should thoroughly check your whole database for corrupted/malicious data. Require password repetition only when hiding using asterisks is enabled Do you wish to restart KeePass now? &Retry Root Directory Ensure same keyboard layouts during auto-type Sample Entry Save Do you want to save the changes before closing? KeePass - Save Before Close/Lock? &Save Save Database Save active database Saved database file Saving database... Saving database file after saving before saving Scheme Search... Search the password database for entries. Search Results Searching entries found. Automatically search key files Automatically search key files also on removable media Type to search the database in Find Note: KeePass shows this simple file browser dialog, because standard Windows file dialogs cannot be shown on the secure desktop for security reasons. An application has switched from the secure desktop to a different desktop. Play UAC sound when switching to secure desktop Click [OK] to switch back to the secure desktop. Select All Select Color Please select a different group. Selected column 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. Separator Sequence Show dereferenced data When showing dereferenced data, additionally show references Show dereferenced data asynchronously Show Entries Show full path in title bar (instead of file name only) Show in Show tray icon only if main window has been sent to tray Size slow Expired Entries and Entries That Will Expire Soon Special Keys Accept invalid SSL certificates (self-signed, expired, ...) Select one of the standard expire times Standard Fields Start and Exit Start minimized and locked Starts with Status Strikeout String Success. Synchronization failed. Synchronize Synchronize active database with a file/URL 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 Tag Add a new tag. New Tag Tags No tags found Mark TAN entries as expired when using them TAN Wizard With this TAN wizard you can easily add TAN entries. Target Window No templates found Text Color 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. 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. Edit Triggers Change trigger on/off state A newer KeePass version or a plugin might be required for this type. Underline Undo Unhide Passwords Allow displaying passwords as plain-text. Unhide button also unhides source characters Unknown An unknown error occurred. Update Check Enable automatic update check? Update check failed. Version information file cannot be downloaded. KeePass can automatically check for updates on each program start. No personal information is sent to the KeePass web server. KeePass just downloads a small version information file and compares the available version with the installed version. Automatic update checks are performed unintrusively in the background. A notification is only displayed when an update is available. Updates are not downloaded or installed automatically. The results of the update check. User interface state updated Up to date URL Open a database stored on a server. Open From URL URL Override Save current database on a server. Save To URL Scheme-Specific URL Override Scheme-Specific URL Overrides Use custom ToolStrip renderer Use database lock files Use file transactions for writing databases User account User Name Enter the user name: UUID Validation failed Value Verify written file after saving a database Version View &View View Entry You're viewing an entry. Wait Wait for exit Warning Warnings Web Browser Web Site Login Web Sites Windows Favorites Windows Without Context Workspace Locked The modified XML data is invalid. XML Replace Replace data in the XML representation of the database. Transform using XSL Stylesheet XSL Stylesheets Select XSL Transformation File XSL Stylesheets for KDBX XML Yes Zoom Failed to initialize encryption/decryption stream! AES/Rijndael (256-Bit Key) An extended error report has been copied to the clipboard. 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! The file is locked, because the following user is currently writing to it: A newer KeePass version is required to open this file. The target file might be corrupted. Please try saving again. 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. Database files cannot be used as key files. The length of the master key seed is invalid! The selected file appears to be an old format Please try it again in a few seconds. 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. keepass2-2.25/KeePassLib/0000775000175000017500000000000012273663444015110 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLib/Native/0000775000175000017500000000000012261553104016322 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLib/Native/NativeLib.cs0000664000175000017500000002117012261553104020527 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Runtime.InteropServices; using System.Windows.Forms; using System.Threading; using System.Diagnostics; using KeePassLib.Utility; namespace KeePassLib.Native { /// /// Interface to native library (library containing fast versions of /// several cryptographic functions). /// public static class NativeLib { private static bool m_bAllowNative = true; /// /// If this property is set to true, the native library is used. /// If it is false, all calls to functions in this class will fail. /// public static bool AllowNative { get { return m_bAllowNative; } set { m_bAllowNative = value; } } /// /// Determine if the native library is installed. /// /// Returns true, if the native library is installed. public static bool IsLibraryInstalled() { byte[] pDummy0 = new byte[32]; byte[] pDummy1 = new byte[32]; // Save the native state bool bCachedNativeState = m_bAllowNative; // Temporarily allow native functions and try to load the library m_bAllowNative = true; bool bResult = TransformKey256(pDummy0, pDummy1, 16); // Pop native state and return result m_bAllowNative = bCachedNativeState; return bResult; } private static bool? m_bIsUnix = null; public static bool IsUnix() { if(m_bIsUnix.HasValue) return m_bIsUnix.Value; PlatformID p = GetPlatformID(); // Mono defines Unix as 128 in early .NET versions #if !KeePassLibSD m_bIsUnix = ((p == PlatformID.Unix) || (p == PlatformID.MacOSX) || ((int)p == 128)); #else m_bIsUnix = (((int)p == 4) || ((int)p == 6) || ((int)p == 128)); #endif return m_bIsUnix.Value; } private static PlatformID? m_platID = null; public static PlatformID GetPlatformID() { if(m_platID.HasValue) return m_platID.Value; #if KeePassRT m_platID = PlatformID.Win32NT; #else m_platID = Environment.OSVersion.Platform; #endif #if (!KeePassLibSD && !KeePassRT) // Mono returns PlatformID.Unix on Mac OS X, workaround this if(m_platID.Value == PlatformID.Unix) { if((RunConsoleApp("uname", null) ?? string.Empty).Trim().Equals( "Darwin", StrUtil.CaseIgnoreCmp)) m_platID = PlatformID.MacOSX; } #endif return m_platID.Value; } #if (!KeePassLibSD && !KeePassRT) public static string RunConsoleApp(string strAppPath, string strParams) { return RunConsoleApp(strAppPath, strParams, null); } public static string RunConsoleApp(string strAppPath, string strParams, string strStdInput) { return RunConsoleApp(strAppPath, strParams, strStdInput, (AppRunFlags.GetStdOutput | AppRunFlags.WaitForExit)); } private delegate string RunProcessDelegate(); public static string RunConsoleApp(string strAppPath, string strParams, string strStdInput, AppRunFlags f) { if(strAppPath == null) throw new ArgumentNullException("strAppPath"); if(strAppPath.Length == 0) throw new ArgumentException("strAppPath"); bool bStdOut = ((f & AppRunFlags.GetStdOutput) != AppRunFlags.None); RunProcessDelegate fnRun = delegate() { try { ProcessStartInfo psi = new ProcessStartInfo(); psi.CreateNoWindow = true; psi.FileName = strAppPath; psi.WindowStyle = ProcessWindowStyle.Hidden; psi.UseShellExecute = false; psi.RedirectStandardOutput = bStdOut; if(strStdInput != null) psi.RedirectStandardInput = true; if(!string.IsNullOrEmpty(strParams)) psi.Arguments = strParams; Process p = Process.Start(psi); if(strStdInput != null) { p.StandardInput.Write(strStdInput); p.StandardInput.Close(); } string strOutput = string.Empty; if(bStdOut) strOutput = p.StandardOutput.ReadToEnd(); if((f & AppRunFlags.WaitForExit) != AppRunFlags.None) p.WaitForExit(); else if((f & AppRunFlags.GCKeepAlive) != AppRunFlags.None) { Thread th = new Thread(delegate() { try { p.WaitForExit(); } catch(Exception) { Debug.Assert(false); } }); th.Start(); } return strOutput; } catch(Exception) { Debug.Assert(false); } return null; }; if((f & AppRunFlags.DoEvents) != AppRunFlags.None) { List
lDisabledForms = new List(); if((f & AppRunFlags.DisableForms) != AppRunFlags.None) { foreach(Form form in Application.OpenForms) { if(!form.Enabled) continue; lDisabledForms.Add(form); form.Enabled = false; } } IAsyncResult ar = fnRun.BeginInvoke(null, null); while(!ar.AsyncWaitHandle.WaitOne(0)) { Application.DoEvents(); Thread.Sleep(2); } string strRet = fnRun.EndInvoke(ar); for(int i = lDisabledForms.Count - 1; i >= 0; --i) lDisabledForms[i].Enabled = true; return strRet; } return fnRun(); } #endif /// /// Transform a key. /// /// Source and destination buffer. /// Key to use in the transformation. /// Number of transformation rounds. /// Returns true, if the key was transformed successfully. public static bool TransformKey256(byte[] pBuf256, byte[] pKey256, ulong uRounds) { if(m_bAllowNative == false) return false; KeyValuePair kvp = PrepareArrays256(pBuf256, pKey256); bool bResult = false; try { bResult = NativeMethods.TransformKey(kvp.Key, kvp.Value, uRounds); } catch(Exception) { bResult = false; } if(bResult) GetBuffers256(kvp, pBuf256, pKey256); NativeLib.FreeArrays(kvp); return bResult; } /// /// Benchmark key transformation. /// /// Number of seconds to perform the benchmark. /// Number of transformations done. /// Returns true, if the benchmark was successful. public static bool TransformKeyBenchmark256(uint uTimeMs, out ulong puRounds) { puRounds = 0; if(m_bAllowNative == false) return false; try { puRounds = NativeMethods.TransformKeyBenchmark(uTimeMs); } catch(Exception) { return false; } return true; } private static KeyValuePair PrepareArrays256(byte[] pBuf256, byte[] pKey256) { Debug.Assert((pBuf256 != null) && (pBuf256.Length == 32)); if(pBuf256 == null) throw new ArgumentNullException("pBuf256"); if(pBuf256.Length != 32) throw new ArgumentException(); Debug.Assert((pKey256 != null) && (pKey256.Length == 32)); if(pKey256 == null) throw new ArgumentNullException("pKey256"); if(pKey256.Length != 32) throw new ArgumentException(); IntPtr hBuf = Marshal.AllocHGlobal(pBuf256.Length); Marshal.Copy(pBuf256, 0, hBuf, pBuf256.Length); IntPtr hKey = Marshal.AllocHGlobal(pKey256.Length); Marshal.Copy(pKey256, 0, hKey, pKey256.Length); return new KeyValuePair(hBuf, hKey); } private static void GetBuffers256(KeyValuePair kvpSource, byte[] pbDestBuf, byte[] pbDestKey) { if(kvpSource.Key != IntPtr.Zero) Marshal.Copy(kvpSource.Key, pbDestBuf, 0, pbDestBuf.Length); if(kvpSource.Value != IntPtr.Zero) Marshal.Copy(kvpSource.Value, pbDestKey, 0, pbDestKey.Length); } private static void FreeArrays(KeyValuePair kvpPointers) { if(kvpPointers.Key != IntPtr.Zero) Marshal.FreeHGlobal(kvpPointers.Key); if(kvpPointers.Value != IntPtr.Zero) Marshal.FreeHGlobal(kvpPointers.Value); } } } keepass2-2.25/KeePassLib/Native/NativeMethods.cs0000664000175000017500000001363112261553104021427 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Text; using System.Security; using System.Runtime.InteropServices; using System.IO; using System.Diagnostics; using KeePassLib.Utility; namespace KeePassLib.Native { internal static class NativeMethods { internal const int MAX_PATH = 260; /* [DllImport("KeePassNtv32.dll", EntryPoint = "TransformKey")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool TransformKey32(IntPtr pBuf256, IntPtr pKey256, UInt64 uRounds); [DllImport("KeePassNtv64.dll", EntryPoint = "TransformKey")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool TransformKey64(IntPtr pBuf256, IntPtr pKey256, UInt64 uRounds); internal static bool TransformKey(IntPtr pBuf256, IntPtr pKey256, UInt64 uRounds) { if(Marshal.SizeOf(typeof(IntPtr)) == 8) return TransformKey64(pBuf256, pKey256, uRounds); else return TransformKey32(pBuf256, pKey256, uRounds); } [DllImport("KeePassNtv32.dll", EntryPoint = "TransformKeyTimed")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool TransformKeyTimed32(IntPtr pBuf256, IntPtr pKey256, ref UInt64 puRounds, UInt32 uSeconds); [DllImport("KeePassNtv64.dll", EntryPoint = "TransformKeyTimed")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool TransformKeyTimed64(IntPtr pBuf256, IntPtr pKey256, ref UInt64 puRounds, UInt32 uSeconds); internal static bool TransformKeyTimed(IntPtr pBuf256, IntPtr pKey256, ref UInt64 puRounds, UInt32 uSeconds) { if(Marshal.SizeOf(typeof(IntPtr)) == 8) return TransformKeyTimed64(pBuf256, pKey256, ref puRounds, uSeconds); else return TransformKeyTimed32(pBuf256, pKey256, ref puRounds, uSeconds); } */ [DllImport("KeePassLibC32.dll", EntryPoint = "TransformKey256")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool TransformKey32(IntPtr pBuf256, IntPtr pKey256, UInt64 uRounds); [DllImport("KeePassLibC64.dll", EntryPoint = "TransformKey256")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool TransformKey64(IntPtr pBuf256, IntPtr pKey256, UInt64 uRounds); internal static bool TransformKey(IntPtr pBuf256, IntPtr pKey256, UInt64 uRounds) { if(Marshal.SizeOf(typeof(IntPtr)) == 8) return TransformKey64(pBuf256, pKey256, uRounds); else return TransformKey32(pBuf256, pKey256, uRounds); } [DllImport("KeePassLibC32.dll", EntryPoint = "TransformKeyBenchmark256")] private static extern UInt64 TransformKeyBenchmark32(UInt32 uTimeMs); [DllImport("KeePassLibC64.dll", EntryPoint = "TransformKeyBenchmark256")] private static extern UInt64 TransformKeyBenchmark64(UInt32 uTimeMs); internal static UInt64 TransformKeyBenchmark(UInt32 uTimeMs) { if(Marshal.SizeOf(typeof(IntPtr)) == 8) return TransformKeyBenchmark64(uTimeMs); else return TransformKeyBenchmark32(uTimeMs); } #if (!KeePassLibSD && !KeePassRT) [DllImport("ShlWApi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)] internal static extern int StrCmpLogicalW(string x, string y); [DllImport("ShlWApi.dll", CharSet = CharSet.Auto)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool PathRelativePathTo([Out] StringBuilder pszPath, [In] string pszFrom, [In] uint dwAttrFrom, [In] string pszTo, [In] uint dwAttrTo); #endif private static bool? m_bSupportsLogicalCmp = null; private static void TestNaturalComparisonsSupport() { #if (KeePassLibSD || KeePassRT) #warning No native natural comparisons supported. m_bSupportsLogicalCmp = false; #else try { StrCmpLogicalW("0", "0"); // Throws exception if unsupported m_bSupportsLogicalCmp = true; } catch(Exception) { m_bSupportsLogicalCmp = false; } #endif } internal static bool SupportsStrCmpNaturally { get { if(m_bSupportsLogicalCmp.HasValue == false) TestNaturalComparisonsSupport(); return m_bSupportsLogicalCmp.Value; } } internal static int StrCmpNaturally(string x, string y) { if(m_bSupportsLogicalCmp.HasValue == false) TestNaturalComparisonsSupport(); if(m_bSupportsLogicalCmp.Value == false) return 0; #if (KeePassLibSD || KeePassRT) #warning No native natural comparisons supported. return x.CompareTo(y); #else return StrCmpLogicalW(x, y); #endif } internal static string GetUserRuntimeDir() { #if !KeePassLibSD #if KeePassRT string strRtDir = Windows.Storage.ApplicationData.Current.LocalFolder.Path; #else 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) } #endif strRtDir = UrlUtil.EnsureTerminatingSeparator(strRtDir, false); strRtDir += PwDefs.ShortProductName; return strRtDir; #else return Path.GetTempPath(); #endif } } } keepass2-2.25/KeePassLib/PwUuid.cs0000664000175000017500000001272612261553104016650 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml; using System.Diagnostics; using KeePassLib.Utility; namespace KeePassLib { // [ImmutableObject(true)] /// /// Represents an UUID of a password entry or group. Once created, /// PwUuid objects aren't modifyable anymore (immutable). /// public sealed class PwUuid : IComparable, IEquatable { /// /// Standard size in bytes of a UUID. /// public const uint UuidSize = 16; /// /// Zero UUID (all bytes are zero). /// public static readonly PwUuid Zero = new PwUuid(false); private byte[] m_pbUuid = null; // Never null after constructor /// /// Get the 16 UUID bytes. /// public byte[] UuidBytes { get { return m_pbUuid; } } /// /// Construct a new UUID object. /// /// If this parameter is true, a new /// UUID is generated. If it is false, the UUID is initialized /// to zero. public PwUuid(bool bCreateNew) { if(bCreateNew) CreateNew(); else SetZero(); } /// /// Construct a new UUID object. /// /// Initial value of the PwUuid object. public PwUuid(byte[] uuidBytes) { SetValue(uuidBytes); } /// /// Create a new, random UUID. /// /// Returns true if a random UUID has been generated, /// otherwise it returns false. private void CreateNew() { Debug.Assert(m_pbUuid == null); // Only call from constructor while(true) { m_pbUuid = Guid.NewGuid().ToByteArray(); if((m_pbUuid == null) || (m_pbUuid.Length != (int)UuidSize)) { Debug.Assert(false); throw new InvalidOperationException(); } // Zero is a reserved value -- do not generate Zero if(!Equals(PwUuid.Zero)) break; Debug.Assert(false); } } private void SetValue(byte[] uuidBytes) { Debug.Assert((uuidBytes != null) && (uuidBytes.Length == (int)UuidSize)); if(uuidBytes == null) throw new ArgumentNullException("uuidBytes"); if(uuidBytes.Length != (int)UuidSize) throw new ArgumentException(); Debug.Assert(m_pbUuid == null); // Only call from constructor m_pbUuid = new byte[UuidSize]; Array.Copy(uuidBytes, m_pbUuid, (int)UuidSize); } private void SetZero() { Debug.Assert(m_pbUuid == null); // Only call from constructor m_pbUuid = new byte[UuidSize]; // Array.Clear(m_pbUuid, 0, (int)UuidSize); #if DEBUG List l = new List(m_pbUuid); Debug.Assert(l.TrueForAll(bt => (bt == 0))); #endif } [Obsolete] public bool EqualsValue(PwUuid uuid) { return Equals(uuid); } public override bool Equals(object obj) { return Equals(obj as PwUuid); } public bool Equals(PwUuid other) { if(other == null) { Debug.Assert(false); return false; } for(int i = 0; i < (int)UuidSize; ++i) { if(m_pbUuid[i] != other.m_pbUuid[i]) return false; } return true; } private int m_h = 0; public override int GetHashCode() { if(m_h == 0) m_h = (int)MemUtil.Hash32(m_pbUuid, 0, m_pbUuid.Length); return m_h; } public int CompareTo(PwUuid other) { if(other == null) { Debug.Assert(false); throw new ArgumentNullException("other"); } for(int i = 0; i < (int)UuidSize; ++i) { if(m_pbUuid[i] < other.m_pbUuid[i]) return -1; if(m_pbUuid[i] > other.m_pbUuid[i]) return 1; } return 0; } /// /// Convert the UUID to its string representation. /// /// String containing the UUID value. public string ToHexString() { return MemUtil.ByteArrayToHexString(m_pbUuid); } #if DEBUG public override string ToString() { return ToHexString(); } #endif } [Obsolete] public sealed class PwUuidComparable : IComparable { private byte[] m_pbUuid = new byte[PwUuid.UuidSize]; public PwUuidComparable(PwUuid pwUuid) { if(pwUuid == null) throw new ArgumentNullException("pwUuid"); Array.Copy(pwUuid.UuidBytes, m_pbUuid, (int)PwUuid.UuidSize); } public int CompareTo(PwUuidComparable other) { if(other == null) throw new ArgumentNullException("other"); for(int i = 0; i < (int)PwUuid.UuidSize; ++i) { if(m_pbUuid[i] < other.m_pbUuid[i]) return -1; if(m_pbUuid[i] > other.m_pbUuid[i]) return 1; } return 0; } } } keepass2-2.25/KeePassLib/Translation/0000775000175000017500000000000012261553106017374 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLib/Translation/KPStringTable.cs0000664000175000017500000000520612261553106022377 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml.Serialization; using System.Windows.Forms; using System.Diagnostics; namespace KeePassLib.Translation { public sealed class KPStringTable { private string m_strName = string.Empty; [XmlAttribute] public string Name { get { return m_strName; } set { if(value == null) throw new ArgumentNullException("value"); m_strName = value; } } private List m_vItems = new List(); [XmlArrayItem("Data")] public List Strings { get { return m_vItems; } set { if(value == null) throw new ArgumentNullException("value"); m_vItems = value; } } public Dictionary ToDictionary() { Dictionary dict = new Dictionary(); foreach(KPStringTableItem kpstItem in m_vItems) { if(kpstItem.Value.Length > 0) dict[kpstItem.Name] = kpstItem.Value; } return dict; } #if (!KeePassLibSD && !KeePassRT) public void ApplyTo(ToolStripItemCollection tsic) { if(tsic == null) throw new ArgumentNullException("tsic"); Dictionary dict = this.ToDictionary(); if(dict.Count == 0) return; this.ApplyTo(tsic, dict); } private void ApplyTo(ToolStripItemCollection tsic, Dictionary dict) { if(tsic == null) return; foreach(ToolStripItem tsi in tsic) { if(tsi.Text.Length == 0) continue; string strTrl; if(dict.TryGetValue(tsi.Name, out strTrl)) tsi.Text = strTrl; ToolStripMenuItem tsmi = tsi as ToolStripMenuItem; if((tsmi != null) && (tsmi.DropDownItems != null)) this.ApplyTo(tsmi.DropDownItems); } } #endif } } keepass2-2.25/KeePassLib/Translation/KPControlCustomization.cs0000664000175000017500000002547512261553106024404 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.ComponentModel; using System.Windows.Forms; using System.Diagnostics; using System.Xml.Serialization; using System.Globalization; using System.IO; using System.Security.Cryptography; using System.Drawing; using KeePassLib.Utility; namespace KeePassLib.Translation { public sealed class KpccLayout { public enum LayoutParameterEx { X, Y, Width, Height } private const string m_strControlRelative = @"%c"; internal const NumberStyles m_nsParser = (NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint); internal static readonly CultureInfo m_lclInv = CultureInfo.InvariantCulture; private string m_strPosX = string.Empty; [XmlAttribute] [DefaultValue("")] public string X { get { return m_strPosX; } set { if(value == null) throw new ArgumentNullException("value"); m_strPosX = value; } } private string m_strPosY = string.Empty; [XmlAttribute] [DefaultValue("")] public string Y { get { return m_strPosY; } set { if(value == null) throw new ArgumentNullException("value"); m_strPosY = value; } } private string m_strSizeW = string.Empty; [XmlAttribute] [DefaultValue("")] public string Width { get { return m_strSizeW; } set { if(value == null) throw new ArgumentNullException("value"); m_strSizeW = value; } } private string m_strSizeH = string.Empty; [XmlAttribute] [DefaultValue("")] public string Height { get { return m_strSizeH; } set { if(value == null) throw new ArgumentNullException("value"); m_strSizeH = value; } } public void SetControlRelativeValue(LayoutParameterEx lp, string strValue) { Debug.Assert(strValue != null); if(strValue == null) throw new ArgumentNullException("strValue"); if(strValue.Length > 0) strValue += m_strControlRelative; if(lp == LayoutParameterEx.X) m_strPosX = strValue; else if(lp == LayoutParameterEx.Y) m_strPosY = strValue; else if(lp == LayoutParameterEx.Width) m_strSizeW = strValue; else if(lp == LayoutParameterEx.Height) m_strSizeH = strValue; else { Debug.Assert(false); } } #if (!KeePassLibSD && !KeePassRT) internal void ApplyTo(Control c) { Debug.Assert(c != null); if(c == null) return; int? v; v = GetModControlParameter(c, LayoutParameterEx.X, m_strPosX); if(v.HasValue) c.Left = v.Value; v = GetModControlParameter(c, LayoutParameterEx.Y, m_strPosY); if(v.HasValue) c.Top = v.Value; v = GetModControlParameter(c, LayoutParameterEx.Width, m_strSizeW); if(v.HasValue) c.Width = v.Value; v = GetModControlParameter(c, LayoutParameterEx.Height, m_strSizeH); if(v.HasValue) c.Height = v.Value; } private static int? GetModControlParameter(Control c, LayoutParameterEx p, string strModParam) { if(strModParam.Length == 0) return null; Debug.Assert(c.Left == c.Location.X); Debug.Assert(c.Top == c.Location.Y); Debug.Assert(c.Width == c.Size.Width); Debug.Assert(c.Height == c.Size.Height); int iPrev; if(p == LayoutParameterEx.X) iPrev = c.Left; else if(p == LayoutParameterEx.Y) iPrev = c.Top; else if(p == LayoutParameterEx.Width) iPrev = c.Width; else if(p == LayoutParameterEx.Height) iPrev = c.Height; else { Debug.Assert(false); return null; } double? dRel = ToControlRelativePercent(strModParam); if(dRel.HasValue) return (iPrev + (int)((dRel.Value * (double)iPrev) / 100.0)); Debug.Assert(false); return null; } public static double? ToControlRelativePercent(string strEncoded) { Debug.Assert(strEncoded != null); if(strEncoded == null) throw new ArgumentNullException("strEncoded"); if(strEncoded.Length == 0) return null; if(strEncoded.EndsWith(m_strControlRelative)) { string strValue = strEncoded.Substring(0, strEncoded.Length - m_strControlRelative.Length); if((strValue.Length == 1) && (strValue == "-")) strValue = "0"; double dRel; if(double.TryParse(strValue, m_nsParser, m_lclInv, out dRel)) { return dRel; } else { Debug.Assert(false); return null; } } Debug.Assert(false); return null; } #endif public static string ToControlRelativeString(string strEncoded) { Debug.Assert(strEncoded != null); if(strEncoded == null) throw new ArgumentNullException("strEncoded"); if(strEncoded.Length == 0) return string.Empty; if(strEncoded.EndsWith(m_strControlRelative)) return strEncoded.Substring(0, strEncoded.Length - m_strControlRelative.Length); Debug.Assert(false); return string.Empty; } } public sealed class KPControlCustomization : IComparable { private string m_strMemberName = string.Empty; /// /// Member variable name of the control to be translated. /// [XmlAttribute] public string Name { get { return m_strMemberName; } set { if(value == null) throw new ArgumentNullException("value"); m_strMemberName = value; } } private string m_strHash = string.Empty; [XmlAttribute] public string BaseHash { get { return m_strHash; } set { if(value == null) throw new ArgumentNullException("value"); m_strHash = value; } } private string m_strText = string.Empty; [DefaultValue("")] public string Text { get { return m_strText; } set { if(value == null) throw new ArgumentNullException("value"); m_strText = value; } } private string m_strEngText = string.Empty; [XmlIgnore] public string TextEnglish { get { return m_strEngText; } set { m_strEngText = value; } } private KpccLayout m_layout = new KpccLayout(); public KpccLayout Layout { get { return m_layout; } set { if(value == null) throw new ArgumentNullException("value"); m_layout = value; } } public int CompareTo(KPControlCustomization kpOther) { if(kpOther == null) { Debug.Assert(false); return 1; } return m_strMemberName.CompareTo(kpOther.Name); } #if (!KeePassLibSD && !KeePassRT) private static readonly Type[] m_vTextControls = new Type[] { typeof(MenuStrip), typeof(PictureBox), typeof(ListView), typeof(TreeView), typeof(ToolStrip), typeof(WebBrowser), typeof(Panel), typeof(StatusStrip), typeof(ProgressBar), typeof(NumericUpDown), typeof(TabControl) }; public static bool ControlSupportsText(object oControl) { if(oControl == null) return false; Type t = oControl.GetType(); for(int i = 0; i < m_vTextControls.Length; ++i) { if(t == m_vTextControls[i]) return false; } return true; } // Name-unchecked (!) property application method internal void ApplyTo(Control c) { if((m_strText.Length > 0) && ControlSupportsText(c) && (c.Text.Length > 0)) { c.Text = m_strText; } m_layout.ApplyTo(c); } public static string HashControl(Control c) { if(c == null) { Debug.Assert(false); return string.Empty; } StringBuilder sb = new StringBuilder(); WriteCpiParam(sb, c.Text); if(c is Form) { WriteCpiParam(sb, c.ClientSize.Width.ToString(KpccLayout.m_lclInv)); WriteCpiParam(sb, c.ClientSize.Height.ToString(KpccLayout.m_lclInv)); } else // Normal control { WriteCpiParam(sb, c.Left.ToString(KpccLayout.m_lclInv)); WriteCpiParam(sb, c.Top.ToString(KpccLayout.m_lclInv)); WriteCpiParam(sb, c.Width.ToString(KpccLayout.m_lclInv)); WriteCpiParam(sb, c.Height.ToString(KpccLayout.m_lclInv)); WriteCpiParam(sb, c.Dock.ToString()); } WriteCpiParam(sb, c.Font.Name); WriteCpiParam(sb, c.Font.SizeInPoints.ToString(KpccLayout.m_lclInv)); WriteCpiParam(sb, c.Font.Bold ? "B" : "N"); WriteCpiParam(sb, c.Font.Italic ? "I" : "N"); WriteCpiParam(sb, c.Font.Underline ? "U" : "N"); WriteCpiParam(sb, c.Font.Strikeout ? "S" : "N"); WriteControlDependentParams(sb, c); byte[] pb = StrUtil.Utf8.GetBytes(sb.ToString()); SHA256Managed sha256 = new SHA256Managed(); byte[] pbSha = sha256.ComputeHash(pb); // Also see MatchHash return "v1:" + Convert.ToBase64String(pbSha, 0, 3, Base64FormattingOptions.None); } private static void WriteControlDependentParams(StringBuilder sb, Control c) { CheckBox cb = (c as CheckBox); RadioButton rb = (c as RadioButton); Button btn = (c as Button); Label l = (c as Label); LinkLabel ll = (c as LinkLabel); if(cb != null) { WriteCpiParam(sb, cb.AutoSize ? "A" : "F"); WriteCpiParam(sb, cb.TextAlign.ToString()); WriteCpiParam(sb, cb.TextImageRelation.ToString()); WriteCpiParam(sb, cb.Appearance.ToString()); WriteCpiParam(sb, cb.CheckAlign.ToString()); } else if(rb != null) { WriteCpiParam(sb, rb.AutoSize ? "A" : "F"); WriteCpiParam(sb, rb.TextAlign.ToString()); WriteCpiParam(sb, rb.TextImageRelation.ToString()); WriteCpiParam(sb, rb.Appearance.ToString()); WriteCpiParam(sb, rb.CheckAlign.ToString()); } else if(btn != null) { WriteCpiParam(sb, btn.AutoSize ? "A" : "F"); WriteCpiParam(sb, btn.TextAlign.ToString()); WriteCpiParam(sb, btn.TextImageRelation.ToString()); } else if(l != null) { WriteCpiParam(sb, l.AutoSize ? "A" : "F"); WriteCpiParam(sb, l.TextAlign.ToString()); } else if(ll != null) { WriteCpiParam(sb, ll.AutoSize ? "A" : "F"); WriteCpiParam(sb, ll.TextAlign.ToString()); } } private static void WriteCpiParam(StringBuilder sb, string strProp) { sb.Append('/'); sb.Append(strProp); } public bool MatchHash(string strHash) { if(strHash == null) throw new ArgumentNullException("strHash"); // Currently only v1: is supported, see HashControl return (m_strHash == strHash); } #endif } } keepass2-2.25/KeePassLib/Translation/KPStringTableItem.cs0000664000175000017500000000273312261553106023220 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml.Serialization; namespace KeePassLib.Translation { public sealed class KPStringTableItem { private string m_strName = string.Empty; public string Name { get { return m_strName; } set { m_strName = value; } } private string m_strValue = string.Empty; public string Value { get { return m_strValue; } set { m_strValue = value; } } private string m_strEnglish = string.Empty; [XmlIgnore] public string ValueEnglish { get { return m_strEnglish; } set { m_strEnglish = value; } } } } keepass2-2.25/KeePassLib/Translation/KPFormCustomization.cs0000664000175000017500000000544312261553106023660 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Windows.Forms; using System.Xml.Serialization; using System.Diagnostics; using System.Reflection; namespace KeePassLib.Translation { public sealed class KPFormCustomization { private string m_strFQName = string.Empty; /// /// The fully qualified name of the form. /// [XmlAttribute] public string FullName { get { return m_strFQName; } set { if(value == null) throw new ArgumentNullException("value"); m_strFQName = value; } } private KPControlCustomization m_ccWindow = new KPControlCustomization(); public KPControlCustomization Window { get { return m_ccWindow; } set { m_ccWindow = value; } } private List m_vControls = new List(); [XmlArray("ChildControls")] [XmlArrayItem("Control")] public List Controls { get { return m_vControls; } set { if(value == null) throw new ArgumentNullException("value"); m_vControls = value; } } #if (!KeePassLibSD && !KeePassRT) private Form m_formEnglish = null; [XmlIgnore] public Form FormEnglish { get { return m_formEnglish; } set { m_formEnglish = value; } } public void ApplyTo(Form form) { Debug.Assert(form != null); if(form == null) throw new ArgumentNullException("form"); // Not supported by TrlUtil (preview form): // Debug.Assert(form.GetType().FullName == m_strFQName); m_ccWindow.ApplyTo(form); if(m_vControls.Count == 0) return; foreach(Control c in form.Controls) ApplyToControl(c); } private void ApplyToControl(Control c) { foreach(KPControlCustomization cc in m_vControls) { if(c.Name == cc.Name) { cc.ApplyTo(c); break; } } foreach(Control cSub in c.Controls) ApplyToControl(cSub); } #endif } } keepass2-2.25/KeePassLib/Translation/KPTranslation.cs0000664000175000017500000001446412261553106022465 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml; using System.Xml.Serialization; using System.Windows.Forms; using System.ComponentModel; using System.Drawing; using System.Diagnostics; using KeePassLib.Interfaces; using KeePassLib.Utility; #if !KeePassLibSD using System.IO.Compression; #else using ICSharpCode.SharpZipLib.GZip; #endif namespace KeePassLib.Translation { [XmlRoot("Translation")] public sealed class KPTranslation { public const string FileExtension = "lngx"; private KPTranslationProperties m_props = new KPTranslationProperties(); public KPTranslationProperties Properties { get { return m_props; } set { m_props = value; } } private List m_vStringTables = new List(); [XmlArrayItem("StringTable")] public List StringTables { get { return m_vStringTables; } set { if(value == null) throw new ArgumentNullException("value"); m_vStringTables = value; } } private List m_vForms = new List(); [XmlArrayItem("Form")] public List Forms { get { return m_vForms; } set { if(value == null) throw new ArgumentNullException("value"); m_vForms = value; } } private string m_strUnusedText = string.Empty; [DefaultValue("")] public string UnusedText { get { return m_strUnusedText; } set { if(value == null) throw new ArgumentNullException("value"); m_strUnusedText = value; } } public static void SaveToFile(KPTranslation kpTrl, string strFileName, IXmlSerializerEx xs) { if(xs == null) throw new ArgumentNullException("xs"); FileStream fs = new FileStream(strFileName, FileMode.Create, FileAccess.Write, FileShare.None); #if !KeePassLibSD GZipStream gz = new GZipStream(fs, CompressionMode.Compress); #else GZipOutputStream gz = new GZipOutputStream(fs); #endif XmlWriterSettings xws = new XmlWriterSettings(); xws.CheckCharacters = true; xws.Encoding = StrUtil.Utf8; xws.Indent = true; xws.IndentChars = "\t"; XmlWriter xw = XmlWriter.Create(gz, xws); xs.Serialize(xw, kpTrl); xw.Close(); gz.Close(); fs.Close(); } public static KPTranslation LoadFromFile(string strFile, IXmlSerializerEx xs) { if(xs == null) throw new ArgumentNullException("xs"); FileStream fs = new FileStream(strFile, FileMode.Open, FileAccess.Read, FileShare.Read); #if !KeePassLibSD GZipStream gz = new GZipStream(fs, CompressionMode.Decompress); #else GZipInputStream gz = new GZipInputStream(fs); #endif KPTranslation kpTrl = (xs.Deserialize(gz) as KPTranslation); gz.Close(); fs.Close(); return kpTrl; } public Dictionary SafeGetStringTableDictionary( string strTableName) { foreach(KPStringTable kpst in m_vStringTables) { if(kpst.Name == strTableName) return kpst.ToDictionary(); } return new Dictionary(); } #if (!KeePassLibSD && !KeePassRT) public void ApplyTo(Form form) { if(form == null) throw new ArgumentNullException("form"); if(m_props.RightToLeft) { try { form.RightToLeft = RightToLeft.Yes; form.RightToLeftLayout = true; } catch(Exception) { Debug.Assert(false); } } string strTypeName = form.GetType().FullName; foreach(KPFormCustomization kpfc in m_vForms) { if(kpfc.FullName == strTypeName) { kpfc.ApplyTo(form); break; } } if(m_props.RightToLeft) { try { RtlApplyToControls(form.Controls); } catch(Exception) { Debug.Assert(false); } } } private static void RtlApplyToControls(Control.ControlCollection cc) { foreach(Control c in cc) { if(c.Controls.Count > 0) RtlApplyToControls(c.Controls); if(c is DateTimePicker) ((DateTimePicker)c).RightToLeftLayout = true; else if(c is ListView) ((ListView)c).RightToLeftLayout = true; else if(c is MonthCalendar) ((MonthCalendar)c).RightToLeftLayout = true; else if(c is ProgressBar) ((ProgressBar)c).RightToLeftLayout = true; else if(c is TabControl) ((TabControl)c).RightToLeftLayout = true; else if(c is TrackBar) ((TrackBar)c).RightToLeftLayout = true; else if(c is TreeView) ((TreeView)c).RightToLeftLayout = true; else if(c is ToolStrip) RtlApplyToToolStripItems(((ToolStrip)c).Items); if((c is GroupBox) || (c is Panel)) RtlMoveChildControls(c); } } private static void RtlMoveChildControls(Control cParent) { int nParentWidth = cParent.Size.Width; foreach(Control c in cParent.Controls) { Point ptCur = c.Location; c.Location = new Point(nParentWidth - c.Size.Width - ptCur.X, ptCur.Y); } } private static void RtlApplyToToolStripItems(ToolStripItemCollection tsic) { foreach(ToolStripItem tsi in tsic) { tsi.RightToLeftAutoMirrorImage = true; } } public void ApplyTo(string strTableName, ToolStripItemCollection tsic) { if(tsic == null) throw new ArgumentNullException("tsic"); KPStringTable kpst = null; foreach(KPStringTable kpstEnum in m_vStringTables) { if(kpstEnum.Name == strTableName) { kpst = kpstEnum; break; } } if(kpst != null) kpst.ApplyTo(tsic); } #endif } } keepass2-2.25/KeePassLib/Translation/KPTranslationProperties.cs0000664000175000017500000000530512261553106024534 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; namespace KeePassLib.Translation { public sealed class KPTranslationProperties { private string m_strApp = string.Empty; public string Application { get { return m_strApp; } set { m_strApp = value; } } private string m_strForVersion = PwDefs.VersionString; public string ApplicationVersion { get { return m_strForVersion; } set { m_strForVersion = value; } } private string m_strNameEnglish = string.Empty; public string NameEnglish { get { return m_strNameEnglish; } set { m_strNameEnglish = value; } } private string m_strNameNative = string.Empty; public string NameNative { get { return m_strNameNative; } set { m_strNameNative = value; } } private string m_strIso6391Code = string.Empty; public string Iso6391Code { get { return m_strIso6391Code; } set { m_strIso6391Code = value; } } private bool m_bRtl = false; public bool RightToLeft { get { return m_bRtl; } set { m_bRtl = value; } } private string m_strAuthorName = string.Empty; public string AuthorName { get { return m_strAuthorName; } set { m_strAuthorName = value; } } private string m_strAuthorContact = string.Empty; public string AuthorContact { get { return m_strAuthorContact; } set { m_strAuthorContact = value; } } private string m_strGen = string.Empty; public string Generator { get { return m_strGen; } set { m_strGen = value; } } private string m_strUuid = string.Empty; public string FileUuid { get { return m_strUuid; } set { m_strUuid = value; } } private string m_strLastModified = string.Empty; public string LastModified { get { return m_strLastModified; } set { m_strLastModified = value; } } } } keepass2-2.25/KeePassLib/Keys/0000775000175000017500000000000012261553104016007 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLib/Keys/UserKeyType.cs0000664000175000017500000000200412261553104020563 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; namespace KeePassLib.Keys { [Flags] public enum UserKeyType { None = 0, Other = 1, Password = 2, KeyFile = 4, UserAccount = 8 } } keepass2-2.25/KeePassLib/Keys/KeyProviderPool.cs0000664000175000017500000000541212261553104021435 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; using System.Collections.Generic; using System.Text; using System.Diagnostics; namespace KeePassLib.Keys { public sealed class KeyProviderPool : IEnumerable { private List m_vProviders = new List(); public int Count { get { return m_vProviders.Count; } } IEnumerator IEnumerable.GetEnumerator() { return m_vProviders.GetEnumerator(); } public IEnumerator GetEnumerator() { return m_vProviders.GetEnumerator(); } public void Add(KeyProvider prov) { Debug.Assert(prov != null); if(prov == null) throw new ArgumentNullException("prov"); m_vProviders.Add(prov); } public bool Remove(KeyProvider prov) { Debug.Assert(prov != null); if(prov == null) throw new ArgumentNullException("prov"); return m_vProviders.Remove(prov); } public KeyProvider Get(string strProviderName) { if(strProviderName == null) throw new ArgumentNullException("strProviderName"); foreach(KeyProvider prov in m_vProviders) { if(prov.Name == strProviderName) return prov; } return null; } public bool IsKeyProvider(string strName) { Debug.Assert(strName != null); if(strName == null) throw new ArgumentNullException("strName"); foreach(KeyProvider prov in m_vProviders) { if(prov.Name == strName) return true; } return false; } internal byte[] GetKey(string strProviderName, KeyProviderQueryContext ctx, out bool bPerformHash) { Debug.Assert(strProviderName != null); if(strProviderName == null) throw new ArgumentNullException("strProviderName"); bPerformHash = true; foreach(KeyProvider prov in m_vProviders) { if(prov.Name == strProviderName) { bPerformHash = !prov.DirectKey; return prov.GetKey(ctx); } } Debug.Assert(false); return null; } } } keepass2-2.25/KeePassLib/Keys/CompositeKey.cs0000664000175000017500000003142312261553104020754 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Text; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Security.Cryptography; #if KeePassRT using Org.BouncyCastle.Crypto.Engines; using Org.BouncyCastle.Crypto.Parameters; #endif using KeePassLib.Native; using KeePassLib.Resources; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePassLib.Keys { /// /// Represents a key. A key can be build up using several user key data sources /// like a password, a key file, the currently logged on user credentials, /// the current computer ID, etc. /// public sealed class CompositeKey { private List m_vUserKeys = new List(); /// /// List of all user keys contained in the current composite key. /// public IEnumerable UserKeys { get { return m_vUserKeys; } } public uint UserKeyCount { get { return (uint)m_vUserKeys.Count; } } /// /// Construct a new, empty key object. /// public CompositeKey() { } // /// // /// Deconstructor, clears up the key. // /// // ~CompositeKey() // { // Clear(); // } // /// // /// Clears the key. This function also erases all previously stored // /// user key data objects. // /// // public void Clear() // { // foreach(IUserKey pKey in m_vUserKeys) // pKey.Clear(); // m_vUserKeys.Clear(); // } /// /// Add a user key. /// /// User key to add. public void AddUserKey(IUserKey pKey) { Debug.Assert(pKey != null); if(pKey == null) throw new ArgumentNullException("pKey"); m_vUserKeys.Add(pKey); } /// /// Remove a user key. /// /// User key to remove. /// Returns true if the key was removed successfully. public bool RemoveUserKey(IUserKey pKey) { Debug.Assert(pKey != null); if(pKey == null) throw new ArgumentNullException("pKey"); Debug.Assert(m_vUserKeys.IndexOf(pKey) >= 0); return m_vUserKeys.Remove(pKey); } #if !KeePassRT /// /// Test whether the composite key contains a specific type of /// user keys (password, key file, ...). If at least one user /// key of that type is present, the function returns true. /// /// User key type. /// Returns true, if the composite key contains /// a user key of the specified type. public bool ContainsType(Type tUserKeyType) { Debug.Assert(tUserKeyType != null); if(tUserKeyType == null) throw new ArgumentNullException("tUserKeyType"); foreach(IUserKey pKey in m_vUserKeys) { if(tUserKeyType.IsInstanceOfType(pKey)) return true; } return false; } /// /// Get the first user key of a specified type. /// /// Type of the user key to get. /// Returns the first user key of the specified type /// or null if no key of that type is found. public IUserKey GetUserKey(Type tUserKeyType) { Debug.Assert(tUserKeyType != null); if(tUserKeyType == null) throw new ArgumentNullException("tUserKeyType"); foreach(IUserKey pKey in m_vUserKeys) { if(tUserKeyType.IsInstanceOfType(pKey)) return pKey; } return null; } #endif /// /// Creates the composite key from the supplied user key sources (password, /// key file, user account, computer ID, etc.). /// private byte[] CreateRawCompositeKey32() { ValidateUserKeys(); // Concatenate user key data MemoryStream ms = new MemoryStream(); foreach(IUserKey pKey in m_vUserKeys) { ProtectedBinary b = pKey.KeyData; if(b != null) { byte[] pbKeyData = b.ReadData(); ms.Write(pbKeyData, 0, pbKeyData.Length); MemUtil.ZeroByteArray(pbKeyData); } } SHA256Managed sha256 = new SHA256Managed(); byte[] pbHash = sha256.ComputeHash(ms.ToArray()); ms.Close(); return pbHash; } public bool EqualsValue(CompositeKey ckOther) { if(ckOther == null) throw new ArgumentNullException("ckOther"); byte[] pbThis = CreateRawCompositeKey32(); byte[] pbOther = ckOther.CreateRawCompositeKey32(); bool bResult = MemUtil.ArraysEqual(pbThis, pbOther); Array.Clear(pbOther, 0, pbOther.Length); Array.Clear(pbThis, 0, pbThis.Length); return bResult; } /// /// Generate a 32-bit wide key out of the composite key. /// /// Seed used in the key transformation /// rounds. Must be a byte array containing exactly 32 bytes; must /// not be null. /// Number of key transformation rounds. /// Returns a protected binary object that contains the /// resulting 32-bit wide key. public ProtectedBinary GenerateKey32(byte[] pbKeySeed32, ulong uNumRounds) { Debug.Assert(pbKeySeed32 != null); if(pbKeySeed32 == null) throw new ArgumentNullException("pbKeySeed32"); Debug.Assert(pbKeySeed32.Length == 32); if(pbKeySeed32.Length != 32) throw new ArgumentException("pbKeySeed32"); byte[] pbRaw32 = CreateRawCompositeKey32(); if((pbRaw32 == null) || (pbRaw32.Length != 32)) { Debug.Assert(false); return null; } byte[] pbTrf32 = TransformKey(pbRaw32, pbKeySeed32, uNumRounds); if((pbTrf32 == null) || (pbTrf32.Length != 32)) { Debug.Assert(false); return null; } ProtectedBinary pbRet = new ProtectedBinary(true, pbTrf32); MemUtil.ZeroByteArray(pbTrf32); MemUtil.ZeroByteArray(pbRaw32); return pbRet; } private void ValidateUserKeys() { int nAccounts = 0; foreach(IUserKey uKey in m_vUserKeys) { if(uKey is KcpUserAccount) ++nAccounts; } if(nAccounts >= 2) { Debug.Assert(false); throw new InvalidOperationException(); } } /// /// Transform the current key uNumRounds times. /// /// The original key which will be transformed. /// This parameter won't be modified. /// Seed used for key transformations. Must not /// be null. This parameter won't be modified. /// Transformation count. /// 256-bit transformed key. private static byte[] TransformKey(byte[] pbOriginalKey32, byte[] pbKeySeed32, ulong uNumRounds) { Debug.Assert((pbOriginalKey32 != null) && (pbOriginalKey32.Length == 32)); if(pbOriginalKey32 == null) throw new ArgumentNullException("pbOriginalKey32"); if(pbOriginalKey32.Length != 32) throw new ArgumentException(); Debug.Assert((pbKeySeed32 != null) && (pbKeySeed32.Length == 32)); if(pbKeySeed32 == null) throw new ArgumentNullException("pbKeySeed32"); if(pbKeySeed32.Length != 32) throw new ArgumentException(); byte[] pbNewKey = new byte[32]; Array.Copy(pbOriginalKey32, pbNewKey, pbNewKey.Length); // Try to use the native library first if(NativeLib.TransformKey256(pbNewKey, pbKeySeed32, uNumRounds)) return (new SHA256Managed()).ComputeHash(pbNewKey); if(TransformKeyManaged(pbNewKey, pbKeySeed32, uNumRounds) == false) return null; SHA256Managed sha256 = new SHA256Managed(); return sha256.ComputeHash(pbNewKey); } public static bool TransformKeyManaged(byte[] pbNewKey32, byte[] pbKeySeed32, ulong uNumRounds) { #if KeePassRT KeyParameter kp = new KeyParameter(pbKeySeed32); AesEngine aes = new AesEngine(); aes.Init(true, kp); for(ulong i = 0; i < uNumRounds; ++i) { aes.ProcessBlock(pbNewKey32, 0, pbNewKey32, 0); aes.ProcessBlock(pbNewKey32, 16, pbNewKey32, 16); } #else byte[] pbIV = new byte[16]; Array.Clear(pbIV, 0, pbIV.Length); RijndaelManaged r = new RijndaelManaged(); if(r.BlockSize != 128) // AES block size { Debug.Assert(false); r.BlockSize = 128; } r.IV = pbIV; r.Mode = CipherMode.ECB; r.KeySize = 256; r.Key = pbKeySeed32; ICryptoTransform iCrypt = r.CreateEncryptor(); // !iCrypt.CanReuseTransform -- doesn't work with Mono if((iCrypt == null) || (iCrypt.InputBlockSize != 16) || (iCrypt.OutputBlockSize != 16)) { Debug.Assert(false, "Invalid ICryptoTransform."); Debug.Assert((iCrypt.InputBlockSize == 16), "Invalid input block size!"); Debug.Assert((iCrypt.OutputBlockSize == 16), "Invalid output block size!"); return false; } for(ulong i = 0; i < uNumRounds; ++i) { iCrypt.TransformBlock(pbNewKey32, 0, 16, pbNewKey32, 0); iCrypt.TransformBlock(pbNewKey32, 16, 16, pbNewKey32, 16); } #endif return true; } /// /// Benchmark the TransformKey method. Within /// ms, random keys will be transformed /// and the number of performed transformations are returned. /// /// Test duration in ms. /// Stepping. /// should be a prime number. For fast processors /// (PCs) a value of 3001 is recommended, for slower processors (PocketPC) /// a value of 401 is recommended. /// Number of transformations performed in the specified /// amount of time. Maximum value is uint.MaxValue. public static ulong TransformKeyBenchmark(uint uMilliseconds, ulong uStep) { ulong uRounds; // Try native method if(NativeLib.TransformKeyBenchmark256(uMilliseconds, out uRounds)) return uRounds; byte[] pbKey = new byte[32]; byte[] pbNewKey = new byte[32]; for(int i = 0; i < pbKey.Length; ++i) { pbKey[i] = (byte)i; pbNewKey[i] = (byte)i; } #if KeePassRT KeyParameter kp = new KeyParameter(pbKey); AesEngine aes = new AesEngine(); aes.Init(true, kp); #else byte[] pbIV = new byte[16]; Array.Clear(pbIV, 0, pbIV.Length); RijndaelManaged r = new RijndaelManaged(); if(r.BlockSize != 128) // AES block size { Debug.Assert(false); r.BlockSize = 128; } r.IV = pbIV; r.Mode = CipherMode.ECB; r.KeySize = 256; r.Key = pbKey; ICryptoTransform iCrypt = r.CreateEncryptor(); // !iCrypt.CanReuseTransform -- doesn't work with Mono if((iCrypt == null) || (iCrypt.InputBlockSize != 16) || (iCrypt.OutputBlockSize != 16)) { Debug.Assert(false, "Invalid ICryptoTransform."); Debug.Assert(iCrypt.InputBlockSize == 16, "Invalid input block size!"); Debug.Assert(iCrypt.OutputBlockSize == 16, "Invalid output block size!"); return PwDefs.DefaultKeyEncryptionRounds; } #endif uRounds = 0; int tStart = Environment.TickCount; while(true) { for(ulong j = 0; j < uStep; ++j) { #if KeePassRT aes.ProcessBlock(pbNewKey, 0, pbNewKey, 0); aes.ProcessBlock(pbNewKey, 16, pbNewKey, 16); #else iCrypt.TransformBlock(pbNewKey, 0, 16, pbNewKey, 0); iCrypt.TransformBlock(pbNewKey, 16, 16, pbNewKey, 16); #endif } uRounds += uStep; if(uRounds < uStep) // Overflow check { uRounds = ulong.MaxValue; break; } uint tElapsed = (uint)(Environment.TickCount - tStart); if(tElapsed > uMilliseconds) break; } return uRounds; } } public sealed class InvalidCompositeKeyException : Exception { public override string Message { get { return KLRes.InvalidCompositeKey + MessageService.NewParagraph + KLRes.InvalidCompositeKeyHint; } } /// /// Construct a new invalid composite key exception. /// public InvalidCompositeKeyException() { } } } keepass2-2.25/KeePassLib/Keys/KeyValidator.cs0000664000175000017500000000314212261553104020734 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; namespace KeePassLib.Keys { public enum KeyValidationType { MasterPassword = 0 } public abstract class KeyValidator { /// /// Name of your key validator (should be unique). /// public abstract string Name { get; } /// /// Validate a key. /// /// Key to validate. /// Type of the validation to perform. /// Returns null, if the validation is successful. /// If there's a problem with the key, the returned string describes /// the problem. public abstract string Validate(string strKey, KeyValidationType t); } } keepass2-2.25/KeePassLib/Keys/KcpCustomKey.cs0000664000175000017500000000402312261553104020716 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Security.Cryptography; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePassLib.Keys { public sealed class KcpCustomKey : IUserKey { private readonly string m_strName; private ProtectedBinary m_pbKey; /// /// Name of the provider that generated the custom key. /// public string Name { get { return m_strName; } } public ProtectedBinary KeyData { get { return m_pbKey; } } public KcpCustomKey(string strName, byte[] pbKeyData, bool bPerformHash) { Debug.Assert(strName != null); if(strName == null) throw new ArgumentNullException("strName"); Debug.Assert(pbKeyData != null); if(pbKeyData == null) throw new ArgumentNullException("pbKeyData"); m_strName = strName; if(bPerformHash) { SHA256Managed sha256 = new SHA256Managed(); byte[] pbRaw = sha256.ComputeHash(pbKeyData); m_pbKey = new ProtectedBinary(true, pbRaw); } else m_pbKey = new ProtectedBinary(true, pbKeyData); } // public void Clear() // { // m_pbKey = null; // } } } keepass2-2.25/KeePassLib/Keys/KcpKeyFile.cs0000664000175000017500000002170312261553104020327 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Text; using System.IO; using System.Xml; using System.Security; using System.Security.Cryptography; using System.Diagnostics; using KeePassLib.Cryptography; using KeePassLib.Resources; using KeePassLib.Security; using KeePassLib.Serialization; using KeePassLib.Utility; namespace KeePassLib.Keys { /// /// Key files as provided by the user. /// public sealed class KcpKeyFile : IUserKey { private string m_strPath; private ProtectedBinary m_pbKeyData; /// /// Path to the key file. /// public string Path { get { return m_strPath; } } /// /// Get key data. Querying this property is fast (it returns a /// reference to a cached ProtectedBinary object). /// If no key data is available, null is returned. /// public ProtectedBinary KeyData { get { return m_pbKeyData; } } public KcpKeyFile(string strKeyFile) { Construct(IOConnectionInfo.FromPath(strKeyFile), false); } public KcpKeyFile(string strKeyFile, bool bThrowIfDbFile) { Construct(IOConnectionInfo.FromPath(strKeyFile), bThrowIfDbFile); } public KcpKeyFile(IOConnectionInfo iocKeyFile) { Construct(iocKeyFile, false); } public KcpKeyFile(IOConnectionInfo iocKeyFile, bool bThrowIfDbFile) { Construct(iocKeyFile, bThrowIfDbFile); } private void Construct(IOConnectionInfo iocFile, bool bThrowIfDbFile) { byte[] pbFileData = IOConnection.ReadFile(iocFile); if(pbFileData == null) throw new FileNotFoundException(); if(bThrowIfDbFile && (pbFileData.Length >= 8)) { uint uSig1 = MemUtil.BytesToUInt32(MemUtil.Mid(pbFileData, 0, 4)); uint uSig2 = MemUtil.BytesToUInt32(MemUtil.Mid(pbFileData, 4, 4)); if(((uSig1 == KdbxFile.FileSignature1) && (uSig2 == KdbxFile.FileSignature2)) || ((uSig1 == KdbxFile.FileSignaturePreRelease1) && (uSig2 == KdbxFile.FileSignaturePreRelease2)) || ((uSig1 == KdbxFile.FileSignatureOld1) && (uSig2 == KdbxFile.FileSignatureOld2))) #if KeePassLibSD throw new Exception(KLRes.KeyFileDbSel); #else throw new InvalidDataException(KLRes.KeyFileDbSel); #endif } byte[] pbKey = LoadXmlKeyFile(pbFileData); if(pbKey == null) pbKey = LoadKeyFile(pbFileData); if(pbKey == null) throw new InvalidOperationException(); m_strPath = iocFile.Path; m_pbKeyData = new ProtectedBinary(true, pbKey); MemUtil.ZeroByteArray(pbKey); } // public void Clear() // { // m_strPath = string.Empty; // m_pbKeyData = null; // } private static byte[] LoadKeyFile(byte[] pbFileData) { if(pbFileData == null) { Debug.Assert(false); return null; } int iLength = pbFileData.Length; byte[] pbKey = null; if(iLength == 32) pbKey = LoadBinaryKey32(pbFileData); else if(iLength == 64) pbKey = LoadHexKey32(pbFileData); if(pbKey == null) { SHA256Managed sha256 = new SHA256Managed(); pbKey = sha256.ComputeHash(pbFileData); } return pbKey; } private static byte[] LoadBinaryKey32(byte[] pbFileData) { if(pbFileData == null) { Debug.Assert(false); return null; } if(pbFileData.Length != 32) { Debug.Assert(false); return null; } return pbFileData; } private static byte[] LoadHexKey32(byte[] pbFileData) { if(pbFileData == null) { Debug.Assert(false); return null; } if(pbFileData.Length != 64) { Debug.Assert(false); return null; } try { string strHex = StrUtil.Utf8.GetString(pbFileData, 0, 64); if(!StrUtil.IsHexString(strHex, true)) return null; byte[] pbKey = MemUtil.HexStringToByteArray(strHex); if((pbKey == null) || (pbKey.Length != 32)) return null; return pbKey; } catch(Exception) { Debug.Assert(false); } return null; } /// /// Create a new, random key-file. /// /// Path where the key-file should be saved to. /// If the file exists already, it will be overwritten. /// Additional entropy used to generate /// the random key. May be null (in this case only the KeePass-internal /// random number generator is used). /// Returns a FileSaveResult error code. public static void Create(string strFilePath, byte[] pbAdditionalEntropy) { byte[] pbKey32 = CryptoRandom.Instance.GetRandomBytes(32); if(pbKey32 == null) throw new SecurityException(); byte[] pbFinalKey32; if((pbAdditionalEntropy == null) || (pbAdditionalEntropy.Length == 0)) pbFinalKey32 = pbKey32; else { MemoryStream ms = new MemoryStream(); ms.Write(pbAdditionalEntropy, 0, pbAdditionalEntropy.Length); ms.Write(pbKey32, 0, 32); SHA256Managed sha256 = new SHA256Managed(); pbFinalKey32 = sha256.ComputeHash(ms.ToArray()); ms.Close(); } CreateXmlKeyFile(strFilePath, pbFinalKey32); } // ================================================================ // XML Key Files // ================================================================ // Sample XML file: // // // // 1.00 // // // ySFoKuCcJblw8ie6RkMBdVCnAf4EedSch7ItujK6bmI= // // private const string RootElementName = "KeyFile"; private const string MetaElementName = "Meta"; private const string VersionElementName = "Version"; private const string KeyElementName = "Key"; private const string KeyDataElementName = "Data"; private static byte[] LoadXmlKeyFile(byte[] pbFileData) { if(pbFileData == null) { Debug.Assert(false); return null; } MemoryStream ms = new MemoryStream(pbFileData, false); byte[] pbKeyData = null; try { XmlDocument doc = new XmlDocument(); doc.Load(ms); XmlElement el = doc.DocumentElement; if((el == null) || !el.Name.Equals(RootElementName)) return null; if(el.ChildNodes.Count < 2) return null; foreach(XmlNode xmlChild in el.ChildNodes) { if(xmlChild.Name.Equals(MetaElementName)) { } // Ignore Meta else if(xmlChild.Name == KeyElementName) { foreach(XmlNode xmlKeyChild in xmlChild.ChildNodes) { if(xmlKeyChild.Name == KeyDataElementName) { if(pbKeyData == null) pbKeyData = Convert.FromBase64String(xmlKeyChild.InnerText); } } } } } catch(Exception) { pbKeyData = null; } finally { ms.Close(); } return pbKeyData; } private static void CreateXmlKeyFile(string strFile, byte[] pbKeyData) { Debug.Assert(strFile != null); if(strFile == null) throw new ArgumentNullException("strFile"); Debug.Assert(pbKeyData != null); if(pbKeyData == null) throw new ArgumentNullException("pbKeyData"); IOConnectionInfo ioc = IOConnectionInfo.FromPath(strFile); Stream sOut = IOConnection.OpenWrite(ioc); XmlTextWriter xtw = new XmlTextWriter(sOut, StrUtil.Utf8); xtw.WriteStartDocument(); xtw.WriteWhitespace("\r\n"); xtw.WriteStartElement(RootElementName); // KeyFile xtw.WriteWhitespace("\r\n\t"); xtw.WriteStartElement(MetaElementName); // Meta xtw.WriteWhitespace("\r\n\t\t"); xtw.WriteStartElement(VersionElementName); // Version xtw.WriteString("1.00"); xtw.WriteEndElement(); // End Version xtw.WriteWhitespace("\r\n\t"); xtw.WriteEndElement(); // End Meta xtw.WriteWhitespace("\r\n\t"); xtw.WriteStartElement(KeyElementName); // Key xtw.WriteWhitespace("\r\n\t\t"); xtw.WriteStartElement(KeyDataElementName); // Data xtw.WriteString(Convert.ToBase64String(pbKeyData)); xtw.WriteEndElement(); // End Data xtw.WriteWhitespace("\r\n\t"); xtw.WriteEndElement(); // End Key xtw.WriteWhitespace("\r\n"); xtw.WriteEndElement(); // RootElementName xtw.WriteWhitespace("\r\n"); xtw.WriteEndDocument(); // End KeyFile xtw.Close(); sOut.Close(); } } } keepass2-2.25/KeePassLib/Keys/KeyProvider.cs0000664000175000017500000001024512261553104020603 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePassLib.Serialization; namespace KeePassLib.Keys { public sealed class KeyProviderQueryContext { private IOConnectionInfo m_ioInfo; public IOConnectionInfo DatabaseIOInfo { get { return m_ioInfo; } } public string DatabasePath { get { return m_ioInfo.Path; } } private bool m_bCreatingNewKey; public bool CreatingNewKey { get { return m_bCreatingNewKey; } } private bool m_bSecDesktop; public bool IsOnSecureDesktop { get { return m_bSecDesktop; } } public KeyProviderQueryContext(IOConnectionInfo ioInfo, bool bCreatingNewKey, bool bOnSecDesktop) { if(ioInfo == null) throw new ArgumentNullException("ioInfo"); m_ioInfo = ioInfo.CloneDeep(); m_bCreatingNewKey = bCreatingNewKey; m_bSecDesktop = bOnSecDesktop; } } public abstract class KeyProvider { /// /// Name of your key provider (should be unique). /// public abstract string Name { get; } /// /// Property indicating whether the provider is exclusive. /// If the provider is exclusive, KeePass doesn't allow other /// key sources (master password, Windows user account, ...) /// to be combined with the provider. /// Key providers typically should return false /// (to allow non-exclusive use), i.e. don't override this /// property. /// public virtual bool Exclusive { get { return false; } } /// /// Property that specifies whether the returned key data /// gets hashed by KeePass first or is written directly to /// the user key data stream. /// Standard key provider plugins should return false /// (i.e. don't overwrite this property). Returning true /// may cause severe security problems and is highly /// discouraged. /// public virtual bool DirectKey { get { return false; } } // public virtual PwIcon ImageIndex // { // get { return PwIcon.UserKey; } // } /// /// This property specifies whether the GetKey method might /// show a form or dialog. If there is any chance that the method shows /// one, this property must return true. Only if it's guaranteed /// that the GetKey method doesn't show any form or dialog, this /// property should return false. /// public virtual bool GetKeyMightShowGui { get { return true; } } /// /// This property specifies whether the key provider is compatible /// with the secure desktop mode. This almost never is the case, /// so you usually won't override this property. /// public virtual bool SecureDesktopCompatible { get { return false; } } public abstract byte[] GetKey(KeyProviderQueryContext ctx); } #if DEBUG public sealed class SampleKeyProvider : KeyProvider { public override string Name { get { return "Built-In Sample Key Provider"; } } // Do not just copy this to your own key provider class! See above. public override bool GetKeyMightShowGui { get { return false; } } public override byte[] GetKey(KeyProviderQueryContext ctx) { return new byte[]{ 2, 3, 5, 7, 11, 13 }; } } #endif } keepass2-2.25/KeePassLib/Keys/KeyValidatorPool.cs0000664000175000017500000000465112261553104021574 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; using System.Collections.Generic; using System.Text; using System.Diagnostics; using KeePassLib.Utility; namespace KeePassLib.Keys { public sealed class KeyValidatorPool : IEnumerable { private List m_vValidators = new List(); public int Count { get { return m_vValidators.Count; } } IEnumerator IEnumerable.GetEnumerator() { return m_vValidators.GetEnumerator(); } public IEnumerator GetEnumerator() { return m_vValidators.GetEnumerator(); } public void Add(KeyValidator v) { Debug.Assert(v != null); if(v == null) throw new ArgumentNullException("v"); m_vValidators.Add(v); } public bool Remove(KeyValidator v) { Debug.Assert(v != null); if(v == null) throw new ArgumentNullException("v"); return m_vValidators.Remove(v); } public string Validate(string strKey, KeyValidationType t) { Debug.Assert(strKey != null); if(strKey == null) throw new ArgumentNullException("strKey"); foreach(KeyValidator v in m_vValidators) { string strResult = v.Validate(strKey, t); if(strResult != null) return strResult; } return null; } public string Validate(byte[] pbKeyUtf8, KeyValidationType t) { Debug.Assert(pbKeyUtf8 != null); if(pbKeyUtf8 == null) throw new ArgumentNullException("pbKeyUtf8"); if(m_vValidators.Count == 0) return null; string strKey = StrUtil.Utf8.GetString(pbKeyUtf8, 0, pbKeyUtf8.Length); return Validate(strKey, t); } } } keepass2-2.25/KeePassLib/Keys/IUserKey.cs0000664000175000017500000000271212261553104020040 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePassLib.Security; namespace KeePassLib.Keys { /// /// Interface to a user key, like a password, key file data, etc. /// public interface IUserKey { /// /// Get key data. Querying this property is fast (it returns a /// reference to a cached ProtectedBinary object). /// If no key data is available, null is returned. /// ProtectedBinary KeyData { get; } // /// // /// Clear the key and securely erase all security-critical information. // /// // void Clear(); } } keepass2-2.25/KeePassLib/Keys/KcpPassword.cs0000664000175000017500000000456512261553104020610 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Text; using System.Diagnostics; using System.Security.Cryptography; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePassLib.Keys { /// /// Master password / passphrase as provided by the user. /// public sealed class KcpPassword : IUserKey { private ProtectedString m_psPassword; private ProtectedBinary m_pbKeyData; /// /// Get the password as protected string. /// public ProtectedString Password { get { return m_psPassword; } } /// /// Get key data. Querying this property is fast (it returns a /// reference to a cached ProtectedBinary object). /// If no key data is available, null is returned. /// public ProtectedBinary KeyData { get { return m_pbKeyData; } } public KcpPassword(byte[] pbPasswordUtf8) { SetKey(pbPasswordUtf8); } public KcpPassword(string strPassword) { SetKey(StrUtil.Utf8.GetBytes(strPassword)); } private void SetKey(byte[] pbPasswordUtf8) { Debug.Assert(pbPasswordUtf8 != null); if(pbPasswordUtf8 == null) throw new ArgumentNullException("pbPasswordUtf8"); SHA256Managed sha256 = new SHA256Managed(); byte[] pbRaw = sha256.ComputeHash(pbPasswordUtf8); m_psPassword = new ProtectedString(true, pbPasswordUtf8); m_pbKeyData = new ProtectedBinary(true, pbRaw); } // public void Clear() // { // m_psPassword = null; // m_pbKeyData = null; // } } } keepass2-2.25/KeePassLib/Keys/KcpUserAccount.cs0000664000175000017500000001047512261553104021236 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Security.Cryptography; using System.IO; using KeePassLib.Cryptography; using KeePassLib.Resources; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePassLib.Keys { /// /// A user key depending on the currently logged on Windows user account. /// public sealed class KcpUserAccount : IUserKey { private ProtectedBinary m_pbKeyData = null; // Constant initialization vector (unique for KeePass) private static readonly byte[] m_pbEntropy = new byte[]{ 0xDE, 0x13, 0x5B, 0x5F, 0x18, 0xA3, 0x46, 0x70, 0xB2, 0x57, 0x24, 0x29, 0x69, 0x88, 0x98, 0xE6 }; private const string UserKeyFileName = "ProtectedUserKey.bin"; /// /// Get key data. Querying this property is fast (it returns a /// reference to a cached ProtectedBinary object). /// If no key data is available, null is returned. /// public ProtectedBinary KeyData { get { return m_pbKeyData; } } /// /// Construct a user account key. /// public KcpUserAccount() { // Test if ProtectedData is supported -- throws an exception // when running on an old system (Windows 98 / ME). byte[] pbDummyData = new byte[128]; ProtectedData.Protect(pbDummyData, m_pbEntropy, DataProtectionScope.CurrentUser); byte[] pbKey = LoadUserKey(false); if(pbKey == null) pbKey = CreateUserKey(); if(pbKey == null) throw new SecurityException(KLRes.UserAccountKeyError); m_pbKeyData = new ProtectedBinary(true, pbKey); Array.Clear(pbKey, 0, pbKey.Length); } // public void Clear() // { // m_pbKeyData = null; // } private static string GetUserKeyFilePath(bool bCreate) { #if KeePassRT string strUserDir = Windows.Storage.ApplicationData.Current.RoamingFolder.Path; #else string strUserDir = Environment.GetFolderPath( Environment.SpecialFolder.ApplicationData); #endif strUserDir = UrlUtil.EnsureTerminatingSeparator(strUserDir, false); strUserDir += PwDefs.ShortProductName; if(bCreate && !Directory.Exists(strUserDir)) Directory.CreateDirectory(strUserDir); strUserDir = UrlUtil.EnsureTerminatingSeparator(strUserDir, false); return strUserDir + UserKeyFileName; } private static byte[] LoadUserKey(bool bShowWarning) { byte[] pbKey = null; #if !KeePassLibSD try { string strFilePath = GetUserKeyFilePath(false); byte[] pbProtectedKey = File.ReadAllBytes(strFilePath); pbKey = ProtectedData.Unprotect(pbProtectedKey, m_pbEntropy, DataProtectionScope.CurrentUser); Array.Clear(pbProtectedKey, 0, pbProtectedKey.Length); } catch(Exception exLoad) { if(bShowWarning) MessageService.ShowWarning(exLoad); pbKey = null; } #endif return pbKey; } private static byte[] CreateUserKey() { byte[] pbKey = null; #if !KeePassLibSD try { string strFilePath = GetUserKeyFilePath(true); byte[] pbRandomKey = CryptoRandom.Instance.GetRandomBytes(64); byte[] pbProtectedKey = ProtectedData.Protect(pbRandomKey, m_pbEntropy, DataProtectionScope.CurrentUser); File.WriteAllBytes(strFilePath, pbProtectedKey); Array.Clear(pbProtectedKey, 0, pbProtectedKey.Length); Array.Clear(pbRandomKey, 0, pbRandomKey.Length); pbKey = LoadUserKey(true); } catch(Exception) { pbKey = null; } #endif return pbKey; } } } keepass2-2.25/KeePassLib/Utility/0000775000175000017500000000000012261553106016541 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLib/Utility/GfxUtil.cs0000664000175000017500000000542712261553106020462 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Drawing; using System.Drawing.Imaging; using System.Diagnostics; namespace KeePassLib.Utility { public static class GfxUtil { #if KeePassRT public static Image LoadImage(byte[] pb) { MemoryStream ms = new MemoryStream(pb, false); try { return Image.FromStream(ms); } finally { ms.Close(); } } #else public static Image LoadImage(byte[] pb) { if(pb == null) throw new ArgumentNullException("pb"); MemoryStream ms = new MemoryStream(pb, false); try { return LoadImagePriv(ms); } catch(Exception) { Image imgIco = TryLoadIco(pb); if(imgIco != null) return imgIco; throw; } finally { ms.Close(); } } private static Image LoadImagePriv(Stream s) { // Image.FromStream wants the stream to be open during // the whole lifetime of the image; as we can't guarantee // this, we make a copy of the image Image imgSrc = null; try { #if !KeePassLibSD imgSrc = Image.FromStream(s); 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); Bitmap bmp = new Bitmap(imgSrc.Width, imgSrc.Height); #endif using(Graphics g = Graphics.FromImage(bmp)) { g.Clear(Color.Transparent); g.DrawImage(imgSrc, 0, 0); } return bmp; } finally { if(imgSrc != null) imgSrc.Dispose(); } } private static Image TryLoadIco(byte[] pb) { #if !KeePassLibSD MemoryStream ms = new MemoryStream(pb, false); try { return (new Icon(ms)).ToBitmap(); } catch(Exception) { } finally { ms.Close(); } #endif return null; } #endif } } keepass2-2.25/KeePassLib/Utility/UrlUtil.cs0000664000175000017500000005340212261553106020474 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using System.Runtime.InteropServices; using System.Text; using System.Diagnostics; using KeePassLib.Native; namespace KeePassLib.Utility { /// /// A class containing various static path utility helper methods (like /// stripping extension from a file, etc.). /// public static class UrlUtil { private static readonly char[] m_vDirSeps = new char[] { '\\', '/', UrlUtil.LocalDirSepChar }; private static readonly char[] m_vPathTrimCharsWs = new char[] { '\"', ' ', '\t', '\r', '\n' }; public static char LocalDirSepChar { #if KeePassRT get { return '\\'; } #else get { return Path.DirectorySeparatorChar; } #endif } /// /// Get the directory (path) of a file name. The returned string is /// terminated by a directory separator character. Example: /// passing C:\\My Documents\\My File.kdb in /// would produce this string: C:\\My Documents\\. /// /// Full path of a file. /// Append a terminating directory separator /// character to the returned path. /// If true, the returned path /// is guaranteed to be a valid directory path (for example X:\\ instead /// of X:, overriding ). /// This should only be set to true, if the returned path is directly /// passed to some directory API. /// Directory of the file. The return value is an empty string /// ("") if the input parameter is null. public static string GetFileDirectory(string strFile, bool bAppendTerminatingChar, bool bEnsureValidDirSpec) { Debug.Assert(strFile != null); if(strFile == null) throw new ArgumentNullException("strFile"); int nLastSep = strFile.LastIndexOfAny(m_vDirSeps); if(nLastSep < 0) return strFile; // None if(bEnsureValidDirSpec && (nLastSep == 2) && (strFile[1] == ':') && (strFile[2] == '\\')) // Length >= 3 and Windows root directory bAppendTerminatingChar = true; if(!bAppendTerminatingChar) return strFile.Substring(0, nLastSep); return EnsureTerminatingSeparator(strFile.Substring(0, nLastSep), false); } /// /// Gets the file name of the specified file (full path). Example: /// if is C:\\My Documents\\My File.kdb /// the returned string is My File.kdb. /// /// Full path of a file. /// File name of the specified file. The return value is /// an empty string ("") if the input parameter is null. public static string GetFileName(string strPath) { Debug.Assert(strPath != null); if(strPath == null) throw new ArgumentNullException("strPath"); int nLastSep = strPath.LastIndexOfAny(m_vDirSeps); if(nLastSep < 0) return strPath; if(nLastSep >= (strPath.Length - 1)) return string.Empty; return strPath.Substring(nLastSep + 1); } /// /// Strip the extension of a file. /// /// Full path of a file with extension. /// File name without extension. public static string StripExtension(string strPath) { Debug.Assert(strPath != null); if(strPath == null) throw new ArgumentNullException("strPath"); int nLastDirSep = strPath.LastIndexOfAny(m_vDirSeps); int nLastExtDot = strPath.LastIndexOf('.'); if(nLastExtDot <= nLastDirSep) return strPath; return strPath.Substring(0, nLastExtDot); } /// /// Get the extension of a file. /// /// Full path of a file with extension. /// Extension without prepending dot. public static string GetExtension(string strPath) { Debug.Assert(strPath != null); if(strPath == null) throw new ArgumentNullException("strPath"); int nLastDirSep = strPath.LastIndexOfAny(m_vDirSeps); int nLastExtDot = strPath.LastIndexOf('.'); if(nLastExtDot <= nLastDirSep) return string.Empty; if(nLastExtDot == (strPath.Length - 1)) return string.Empty; return strPath.Substring(nLastExtDot + 1); } /// /// Ensure that a path is terminated with a directory separator character. /// /// Input path. /// If true, a slash (/) is appended to /// the string if it's not terminated already. If false, the /// default system directory separator character is used. /// Path having a directory separator as last character. public static string EnsureTerminatingSeparator(string strPath, bool bUrl) { Debug.Assert(strPath != null); if(strPath == null) throw new ArgumentNullException("strPath"); int nLength = strPath.Length; if(nLength <= 0) return string.Empty; char chLast = strPath[nLength - 1]; for(int i = 0; i < m_vDirSeps.Length; ++i) { if(chLast == m_vDirSeps[i]) return strPath; } if(bUrl) return (strPath + '/'); return (strPath + UrlUtil.LocalDirSepChar); } /* /// /// File access mode enumeration. Used by the FileAccessible /// method. /// public enum FileAccessMode { /// /// Opening a file in read mode. The specified file must exist. /// Read = 0, /// /// Opening a file in create mode. If the file exists already, it /// will be overwritten. If it doesn't exist, it will be created. /// The return value is true, if data can be written to the /// file. /// Create } */ /* /// /// Test if a specified path is accessible, either in read or write mode. /// /// Path to test. /// Requested file access mode. /// Returns true if the specified path is accessible in /// the requested mode, otherwise the return value is false. public static bool FileAccessible(string strFilePath, FileAccessMode fMode) { Debug.Assert(strFilePath != null); if(strFilePath == null) throw new ArgumentNullException("strFilePath"); if(fMode == FileAccessMode.Read) { FileStream fs; try { fs = File.OpenRead(strFilePath); } catch(Exception) { return false; } if(fs == null) return false; fs.Close(); return true; } else if(fMode == FileAccessMode.Create) { FileStream fs; try { fs = File.Create(strFilePath); } catch(Exception) { return false; } if(fs == null) return false; fs.Close(); return true; } return false; } */ public static string GetQuotedAppPath(string strPath) { if(strPath == null) { Debug.Assert(false); return string.Empty; } // int nFirst = strPath.IndexOf('\"'); // int nSecond = strPath.IndexOf('\"', nFirst + 1); // if((nFirst >= 0) && (nSecond >= 0)) // return strPath.Substring(nFirst + 1, nSecond - nFirst - 1); // return strPath; string str = strPath.Trim(); if(str.Length <= 1) return str; if(str[0] != '\"') return str; int iSecond = str.IndexOf('\"', 1); if(iSecond <= 0) return str; return str.Substring(1, iSecond - 1); } public static string FileUrlToPath(string strUrl) { Debug.Assert(strUrl != null); if(strUrl == null) throw new ArgumentNullException("strUrl"); string str = strUrl; if(str.StartsWith(@"file:///", StrUtil.CaseIgnoreCmp)) str = str.Substring(8, str.Length - 8); str = str.Replace('/', UrlUtil.LocalDirSepChar); return str; } public static bool UnhideFile(string strFile) { #if (KeePassLibSD || KeePassRT) return false; #else if(strFile == null) throw new ArgumentNullException("strFile"); try { FileAttributes fa = File.GetAttributes(strFile); if((long)(fa & FileAttributes.Hidden) == 0) return false; return HideFile(strFile, false); } catch(Exception) { } return false; #endif } public static bool HideFile(string strFile, bool bHide) { #if (KeePassLibSD || KeePassRT) return false; #else if(strFile == null) throw new ArgumentNullException("strFile"); try { FileAttributes fa = File.GetAttributes(strFile); if(bHide) fa = ((fa & ~FileAttributes.Normal) | FileAttributes.Hidden); else // Unhide { fa &= ~FileAttributes.Hidden; if((long)fa == 0) fa |= FileAttributes.Normal; } File.SetAttributes(strFile, fa); return true; } catch(Exception) { } return false; #endif } public static string MakeRelativePath(string strBaseFile, string strTargetFile) { if(strBaseFile == null) throw new ArgumentNullException("strBasePath"); if(strTargetFile == null) throw new ArgumentNullException("strTargetPath"); if(strBaseFile.Length == 0) return strTargetFile; if(strTargetFile.Length == 0) return string.Empty; // Test whether on different Windows drives if((strBaseFile.Length >= 3) && (strTargetFile.Length >= 3)) { if((strBaseFile[1] == ':') && (strTargetFile[1] == ':') && (strBaseFile[2] == '\\') && (strTargetFile[2] == '\\') && (strBaseFile[0] != strTargetFile[0])) return strTargetFile; } #if (!KeePassLibSD && !KeePassRT) if(NativeLib.IsUnix()) #endif { bool bBaseUnc = IsUncPath(strBaseFile); bool bTargetUnc = IsUncPath(strTargetFile); if((!bBaseUnc && bTargetUnc) || (bBaseUnc && !bTargetUnc)) return strTargetFile; string strBase = GetShortestAbsolutePath(strBaseFile); string strTarget = GetShortestAbsolutePath(strTargetFile); string[] vBase = strBase.Split(m_vDirSeps); string[] vTarget = strTarget.Split(m_vDirSeps); int i = 0; while((i < (vBase.Length - 1)) && (i < (vTarget.Length - 1)) && (vBase[i] == vTarget[i])) { ++i; } StringBuilder sbRel = new StringBuilder(); for(int j = i; j < (vBase.Length - 1); ++j) { if(sbRel.Length > 0) sbRel.Append(UrlUtil.LocalDirSepChar); sbRel.Append(".."); } for(int k = i; k < vTarget.Length; ++k) { if(sbRel.Length > 0) sbRel.Append(UrlUtil.LocalDirSepChar); sbRel.Append(vTarget[k]); } return sbRel.ToString(); } #if (!KeePassLibSD && !KeePassRT) try // Windows { const int nMaxPath = NativeMethods.MAX_PATH * 2; StringBuilder sb = new StringBuilder(nMaxPath + 2); if(NativeMethods.PathRelativePathTo(sb, strBaseFile, 0, strTargetFile, 0) == false) return strTargetFile; string str = sb.ToString(); while(str.StartsWith(".\\")) str = str.Substring(2, str.Length - 2); return str; } catch(Exception) { Debug.Assert(false); } return strTargetFile; #endif } public static string MakeAbsolutePath(string strBaseFile, string strTargetFile) { if(strBaseFile == null) throw new ArgumentNullException("strBasePath"); if(strTargetFile == null) throw new ArgumentNullException("strTargetPath"); if(strBaseFile.Length == 0) return strTargetFile; if(strTargetFile.Length == 0) return string.Empty; if(IsAbsolutePath(strTargetFile)) return strTargetFile; string strBaseDir = GetFileDirectory(strBaseFile, true, false); return GetShortestAbsolutePath(strBaseDir + strTargetFile); } public static bool IsAbsolutePath(string strPath) { if(strPath == null) throw new ArgumentNullException("strPath"); if(strPath.Length == 0) return false; if(IsUncPath(strPath)) return true; try { return Path.IsPathRooted(strPath); } catch(Exception) { Debug.Assert(false); } return true; } public static string GetShortestAbsolutePath(string strPath) { if(strPath == null) throw new ArgumentNullException("strPath"); if(strPath.Length == 0) return string.Empty; // Path.GetFullPath is incompatible with UNC paths traversing over // different server shares (which are created by PathRelativePathTo); // we need to build the absolute path on our own... if(IsUncPath(strPath)) { char chSep = strPath[0]; Debug.Assert(Array.IndexOf(m_vDirSeps, chSep) >= 0); List l = new List(); #if !KeePassLibSD string[] v = strPath.Split(m_vDirSeps, StringSplitOptions.None); #else string[] v = strPath.Split(m_vDirSeps); #endif Debug.Assert((v.Length >= 3) && (v[0].Length == 0) && (v[1].Length == 0)); foreach(string strPart in v) { if(strPart.Equals(".")) continue; else if(strPart.Equals("..")) { if(l.Count > 0) l.RemoveAt(l.Count - 1); else { Debug.Assert(false); } } else l.Add(strPart); // Do not ignore zero length parts } StringBuilder sb = new StringBuilder(); for(int i = 0; i < l.Count; ++i) { // Don't test length of sb, might be 0 due to initial UNC seps if(i > 0) sb.Append(chSep); sb.Append(l[i]); } return sb.ToString(); } string str; try { #if KeePassRT var dirT = Windows.Storage.StorageFolder.GetFolderFromPathAsync( strPath).AwaitEx(); str = dirT.Path; #else str = Path.GetFullPath(strPath); #endif } catch(Exception) { Debug.Assert(false); return strPath; } Debug.Assert(str.IndexOf("\\..\\") < 0); foreach(char ch in m_vDirSeps) { string strSep = new string(ch, 1); str = str.Replace(strSep + "." + strSep, strSep); } return str; } public static int GetUrlLength(string strText, int nOffset) { if(strText == null) throw new ArgumentNullException("strText"); if(nOffset > strText.Length) throw new ArgumentException(); // Not >= (0 len) int iPosition = nOffset, nLength = 0, nStrLen = strText.Length; while(iPosition < nStrLen) { char ch = strText[iPosition]; ++iPosition; if((ch == ' ') || (ch == '\t') || (ch == '\r') || (ch == '\n')) break; ++nLength; } return nLength; } public static string RemoveScheme(string strUrl) { if(string.IsNullOrEmpty(strUrl)) return string.Empty; int nNetScheme = strUrl.IndexOf(@"://", StrUtil.CaseIgnoreCmp); int nShScheme = strUrl.IndexOf(@":/", StrUtil.CaseIgnoreCmp); int nSmpScheme = strUrl.IndexOf(@":", StrUtil.CaseIgnoreCmp); if((nNetScheme < 0) && (nShScheme < 0) && (nSmpScheme < 0)) return strUrl; // No scheme int nMin = Math.Min(Math.Min((nNetScheme >= 0) ? nNetScheme : int.MaxValue, (nShScheme >= 0) ? nShScheme : int.MaxValue), (nSmpScheme >= 0) ? nSmpScheme : int.MaxValue); if(nMin == nNetScheme) return strUrl.Substring(nMin + 3); if(nMin == nShScheme) return strUrl.Substring(nMin + 2); return strUrl.Substring(nMin + 1); } public static string ConvertSeparators(string strPath) { return ConvertSeparators(strPath, UrlUtil.LocalDirSepChar); } public static string ConvertSeparators(string strPath, char chSeparator) { if(string.IsNullOrEmpty(strPath)) return string.Empty; strPath = strPath.Replace('/', chSeparator); strPath = strPath.Replace('\\', chSeparator); return strPath; } public static bool IsUncPath(string strPath) { if(strPath == null) throw new ArgumentNullException("strPath"); return (strPath.StartsWith("\\\\") || strPath.StartsWith("//")); } public static string FilterFileName(string strName) { if(strName == null) { Debug.Assert(false); return string.Empty; } string str = strName; str = str.Replace('/', '-'); str = str.Replace('\\', '-'); str = str.Replace(":", string.Empty); str = str.Replace("*", string.Empty); str = str.Replace("?", string.Empty); str = str.Replace("\"", string.Empty); str = str.Replace(@"'", string.Empty); str = str.Replace('<', '('); str = str.Replace('>', ')'); str = str.Replace('|', '-'); return str; } /// /// Get the host component of an URL. /// This method is faster and more fault-tolerant than creating /// an Uri object and querying its Host /// property. /// /// /// For the input s://u:p@d.tld:p/p?q#f the return /// value is d.tld. /// public static string GetHost(string strUrl) { if(strUrl == null) { Debug.Assert(false); return string.Empty; } StringBuilder sb = new StringBuilder(); bool bInExtHost = false; for(int i = 0; i < strUrl.Length; ++i) { char ch = strUrl[i]; if(bInExtHost) { if(ch == '/') { if(sb.Length == 0) { } // Ignore leading '/'s else break; } else sb.Append(ch); } else // !bInExtHost { if(ch == ':') bInExtHost = true; } } string str = sb.ToString(); if(str.Length == 0) str = strUrl; // Remove the login part int nLoginLen = str.IndexOf('@'); if(nLoginLen >= 0) str = str.Substring(nLoginLen + 1); // Remove the port int iPort = str.LastIndexOf(':'); if(iPort >= 0) str = str.Substring(0, iPort); return str; } public static bool AssemblyEquals(string strExt, string strShort) { if((strExt == null) || (strShort == null)) { Debug.Assert(false); return false; } if(strExt.Equals(strShort, StrUtil.CaseIgnoreCmp) || strExt.StartsWith(strShort + ",", StrUtil.CaseIgnoreCmp)) return true; if(!strShort.EndsWith(".dll", StrUtil.CaseIgnoreCmp)) { if(strExt.Equals(strShort + ".dll", StrUtil.CaseIgnoreCmp) || strExt.StartsWith(strShort + ".dll,", StrUtil.CaseIgnoreCmp)) return true; } if(!strShort.EndsWith(".exe", StrUtil.CaseIgnoreCmp)) { if(strExt.Equals(strShort + ".exe", StrUtil.CaseIgnoreCmp) || strExt.StartsWith(strShort + ".exe,", StrUtil.CaseIgnoreCmp)) return true; } return false; } public static string GetTempPath() { string strDir; if(NativeLib.IsUnix()) strDir = NativeMethods.GetUserRuntimeDir(); #if KeePassRT else strDir = Windows.Storage.ApplicationData.Current.TemporaryFolder.Path; #else else strDir = Path.GetTempPath(); #endif try { if(Directory.Exists(strDir) == false) Directory.CreateDirectory(strDir); } catch(Exception) { Debug.Assert(false); } return strDir; } #if !KeePassLibSD // Structurally mostly equivalent to UrlUtil.GetFileInfos public static List GetFilePaths(string strDir, string strPattern, SearchOption opt) { List l = new List(); if(strDir == null) { Debug.Assert(false); return l; } if(strPattern == null) { Debug.Assert(false); return l; } string[] v = Directory.GetFiles(strDir, strPattern, opt); if(v == null) { Debug.Assert(false); return l; } // Only accept files with the correct extension; GetFiles may // return additional files, see GetFiles documentation string strExt = GetExtension(strPattern); if(!string.IsNullOrEmpty(strExt) && (strExt.IndexOf('*') < 0) && (strExt.IndexOf('?') < 0)) { strExt = "." + strExt; foreach(string strPathRaw in v) { if(strPathRaw == null) { Debug.Assert(false); continue; } string strPath = strPathRaw.Trim(m_vPathTrimCharsWs); if(strPath.Length == 0) { Debug.Assert(false); continue; } Debug.Assert(strPath == strPathRaw); if(!strPath.EndsWith(strExt, StrUtil.CaseIgnoreCmp)) continue; l.Add(strPathRaw); } } else l.AddRange(v); return l; } // Structurally mostly equivalent to UrlUtil.GetFilePaths public static List GetFileInfos(DirectoryInfo di, string strPattern, SearchOption opt) { List l = new List(); if(di == null) { Debug.Assert(false); return l; } if(strPattern == null) { Debug.Assert(false); return l; } FileInfo[] v = di.GetFiles(strPattern, opt); if(v == null) { Debug.Assert(false); return l; } // Only accept files with the correct extension; GetFiles may // return additional files, see GetFiles documentation string strExt = GetExtension(strPattern); if(!string.IsNullOrEmpty(strExt) && (strExt.IndexOf('*') < 0) && (strExt.IndexOf('?') < 0)) { strExt = "." + strExt; foreach(FileInfo fi in v) { if(fi == null) { Debug.Assert(false); continue; } string strPathRaw = fi.FullName; if(strPathRaw == null) { Debug.Assert(false); continue; } string strPath = strPathRaw.Trim(m_vPathTrimCharsWs); if(strPath.Length == 0) { Debug.Assert(false); continue; } Debug.Assert(strPath == strPathRaw); if(!strPath.EndsWith(strExt, StrUtil.CaseIgnoreCmp)) continue; l.Add(fi); } } else l.AddRange(v); return l; } #endif } } keepass2-2.25/KeePassLib/Utility/MessageService.cs0000664000175000017500000003123412261553106022000 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Collections.Specialized; using System.Text; using System.Windows.Forms; using System.Diagnostics; using KeePassLib.Resources; using KeePassLib.Serialization; namespace KeePassLib.Utility { public sealed class MessageServiceEventArgs : EventArgs { private string m_strTitle = string.Empty; private string m_strText = string.Empty; private MessageBoxButtons m_msgButtons = MessageBoxButtons.OK; private MessageBoxIcon m_msgIcon = MessageBoxIcon.None; public string Title { get { return m_strTitle; } } public string Text { get { return m_strText; } } public MessageBoxButtons Buttons { get { return m_msgButtons; } } public MessageBoxIcon Icon { get { return m_msgIcon; } } public MessageServiceEventArgs() { } public MessageServiceEventArgs(string strTitle, string strText, MessageBoxButtons msgButtons, MessageBoxIcon msgIcon) { m_strTitle = (strTitle ?? string.Empty); m_strText = (strText ?? string.Empty); m_msgButtons = msgButtons; m_msgIcon = msgIcon; } } public static class MessageService { private static volatile uint m_uCurrentMessageCount = 0; #if !KeePassLibSD private const MessageBoxIcon m_mbiInfo = MessageBoxIcon.Information; private const MessageBoxIcon m_mbiWarning = MessageBoxIcon.Warning; private const MessageBoxIcon m_mbiFatal = MessageBoxIcon.Error; private const MessageBoxOptions m_mboRtl = (MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign); #else private const MessageBoxIcon m_mbiInfo = MessageBoxIcon.Asterisk; private const MessageBoxIcon m_mbiWarning = MessageBoxIcon.Exclamation; private const MessageBoxIcon m_mbiFatal = MessageBoxIcon.Hand; #endif private const MessageBoxIcon m_mbiQuestion = MessageBoxIcon.Question; public static string NewLine { #if !KeePassLibSD get { return Environment.NewLine; } #else get { return "\r\n"; } #endif } public static string NewParagraph { #if !KeePassLibSD get { return Environment.NewLine + Environment.NewLine; } #else get { return "\r\n\r\n"; } #endif } public static uint CurrentMessageCount { get { return m_uCurrentMessageCount; } } public static event EventHandler MessageShowing; private static string ObjectsToMessage(object[] vLines) { return ObjectsToMessage(vLines, false); } private static string ObjectsToMessage(object[] vLines, bool bFullExceptions) { if(vLines == null) return string.Empty; string strNewPara = MessageService.NewParagraph; StringBuilder sbText = new StringBuilder(); bool bSeparator = false; foreach(object obj in vLines) { if(obj == null) continue; string strAppend = null; Exception exObj = (obj as Exception); string strObj = (obj as string); #if (!KeePassLibSD && !KeePassRT) StringCollection scObj = (obj as StringCollection); #endif if(exObj != null) { if(bFullExceptions) strAppend = StrUtil.FormatException(exObj); else if((exObj.Message != null) && (exObj.Message.Length > 0)) strAppend = exObj.Message; } #if (!KeePassLibSD && !KeePassRT) else if(scObj != null) { StringBuilder sb = new StringBuilder(); foreach(string strCollLine in scObj) { if(sb.Length > 0) sb.AppendLine(); sb.Append(strCollLine.TrimEnd()); } strAppend = sb.ToString(); } #endif else if(strObj != null) strAppend = strObj; else strAppend = obj.ToString(); if(!string.IsNullOrEmpty(strAppend)) { if(bSeparator) sbText.Append(strNewPara); else bSeparator = true; sbText.Append(strAppend); } } return sbText.ToString(); } #if (!KeePassLibSD && !KeePassRT) internal static Form GetTopForm() { FormCollection fc = Application.OpenForms; if((fc == null) || (fc.Count == 0)) return null; return fc[fc.Count - 1]; } #endif private static DialogResult SafeShowMessageBox(string strText, string strTitle, MessageBoxButtons mb, MessageBoxIcon mi, MessageBoxDefaultButton mdb) { #if (KeePassLibSD || KeePassRT) return MessageBox.Show(strText, strTitle, mb, mi, mdb); #else IWin32Window wnd = null; try { Form f = GetTopForm(); if((f != null) && f.InvokeRequired) return (DialogResult)f.Invoke(new SafeShowMessageBoxInternalDelegate( SafeShowMessageBoxInternal), f, strText, strTitle, mb, mi, mdb); else wnd = f; } catch(Exception) { Debug.Assert(false); } if(wnd == null) { if(StrUtil.RightToLeft) return MessageBox.Show(strText, strTitle, mb, mi, mdb, m_mboRtl); return MessageBox.Show(strText, strTitle, mb, mi, mdb); } try { if(StrUtil.RightToLeft) return MessageBox.Show(wnd, strText, strTitle, mb, mi, mdb, m_mboRtl); return MessageBox.Show(wnd, strText, strTitle, mb, mi, mdb); } catch(Exception) { Debug.Assert(false); } if(StrUtil.RightToLeft) return MessageBox.Show(strText, strTitle, mb, mi, mdb, m_mboRtl); return MessageBox.Show(strText, strTitle, mb, mi, mdb); #endif } #if (!KeePassLibSD && !KeePassRT) internal delegate DialogResult SafeShowMessageBoxInternalDelegate(IWin32Window iParent, string strText, string strTitle, MessageBoxButtons mb, MessageBoxIcon mi, MessageBoxDefaultButton mdb); internal static DialogResult SafeShowMessageBoxInternal(IWin32Window iParent, string strText, string strTitle, MessageBoxButtons mb, MessageBoxIcon mi, MessageBoxDefaultButton mdb) { if(StrUtil.RightToLeft) return MessageBox.Show(iParent, strText, strTitle, mb, mi, mdb, m_mboRtl); return MessageBox.Show(iParent, strText, strTitle, mb, mi, mdb); } #endif public static void ShowInfo(params object[] vLines) { ShowInfoEx(null, vLines); } public static void ShowInfoEx(string strTitle, params object[] vLines) { ++m_uCurrentMessageCount; strTitle = (strTitle ?? PwDefs.ShortProductName); string strText = ObjectsToMessage(vLines); if(MessageService.MessageShowing != null) MessageService.MessageShowing(null, new MessageServiceEventArgs( strTitle, strText, MessageBoxButtons.OK, m_mbiInfo)); SafeShowMessageBox(strText, strTitle, MessageBoxButtons.OK, m_mbiInfo, MessageBoxDefaultButton.Button1); --m_uCurrentMessageCount; } public static void ShowWarning(params object[] vLines) { ShowWarningPriv(vLines, false); } internal static void ShowWarningExcp(params object[] vLines) { ShowWarningPriv(vLines, true); } private static void ShowWarningPriv(object[] vLines, bool bFullExceptions) { ++m_uCurrentMessageCount; string strTitle = PwDefs.ShortProductName; string strText = ObjectsToMessage(vLines, bFullExceptions); if(MessageService.MessageShowing != null) MessageService.MessageShowing(null, new MessageServiceEventArgs( strTitle, strText, MessageBoxButtons.OK, m_mbiWarning)); SafeShowMessageBox(strText, strTitle, MessageBoxButtons.OK, m_mbiWarning, MessageBoxDefaultButton.Button1); --m_uCurrentMessageCount; } public static void ShowFatal(params object[] vLines) { ++m_uCurrentMessageCount; string strTitle = PwDefs.ShortProductName + @" - " + KLRes.FatalError; string strText = KLRes.FatalErrorText + MessageService.NewParagraph + KLRes.ErrorInClipboard + MessageService.NewParagraph + // Please send it to the KeePass developers. // KLRes.ErrorFeedbackRequest + MessageService.NewParagraph + ObjectsToMessage(vLines); try { #if !KeePassLibSD Clipboard.Clear(); Clipboard.SetText(ObjectsToMessage(vLines, true)); #else Clipboard.SetDataObject(ObjectsToMessage(vLines, true)); #endif } catch(Exception) { Debug.Assert(false); } if(MessageService.MessageShowing != null) MessageService.MessageShowing(null, new MessageServiceEventArgs( strTitle, strText, MessageBoxButtons.OK, m_mbiFatal)); SafeShowMessageBox(strText, strTitle, MessageBoxButtons.OK, m_mbiFatal, MessageBoxDefaultButton.Button1); --m_uCurrentMessageCount; } public static DialogResult Ask(string strText, string strTitle, MessageBoxButtons mbb) { ++m_uCurrentMessageCount; string strTextEx = (strText ?? string.Empty); string strTitleEx = (strTitle ?? PwDefs.ShortProductName); if(MessageService.MessageShowing != null) MessageService.MessageShowing(null, new MessageServiceEventArgs( strTitleEx, strTextEx, mbb, m_mbiQuestion)); DialogResult dr = SafeShowMessageBox(strTextEx, strTitleEx, mbb, m_mbiQuestion, MessageBoxDefaultButton.Button1); --m_uCurrentMessageCount; return dr; } public static bool AskYesNo(string strText, string strTitle, bool bDefaultToYes, MessageBoxIcon mbi) { ++m_uCurrentMessageCount; string strTextEx = (strText ?? string.Empty); string strTitleEx = (strTitle ?? PwDefs.ShortProductName); if(MessageService.MessageShowing != null) MessageService.MessageShowing(null, new MessageServiceEventArgs( strTitleEx, strTextEx, MessageBoxButtons.YesNo, mbi)); DialogResult dr = SafeShowMessageBox(strTextEx, strTitleEx, MessageBoxButtons.YesNo, mbi, bDefaultToYes ? MessageBoxDefaultButton.Button1 : MessageBoxDefaultButton.Button2); --m_uCurrentMessageCount; return (dr == DialogResult.Yes); } public static bool AskYesNo(string strText, string strTitle, bool bDefaultToYes) { return AskYesNo(strText, strTitle, bDefaultToYes, m_mbiQuestion); } public static bool AskYesNo(string strText, string strTitle) { return AskYesNo(strText, strTitle, true, m_mbiQuestion); } public static bool AskYesNo(string strText) { return AskYesNo(strText, null, true, m_mbiQuestion); } public static void ShowLoadWarning(string strFilePath, Exception ex) { ShowLoadWarning(strFilePath, ex, false); } public static void ShowLoadWarning(string strFilePath, Exception ex, bool bFullException) { string str = string.Empty; if((strFilePath != null) && (strFilePath.Length > 0)) str += strFilePath + MessageService.NewParagraph; str += KLRes.FileLoadFailed; if((ex != null) && (ex.Message != null) && (ex.Message.Length > 0)) { str += MessageService.NewParagraph; if(!bFullException) str += ex.Message; else str += ObjectsToMessage(new object[] { ex }, true); } ShowWarning(str); } public static void ShowLoadWarning(IOConnectionInfo ioConnection, Exception ex) { if(ioConnection != null) ShowLoadWarning(ioConnection.GetDisplayName(), ex, false); else ShowWarning(ex); } public static void ShowSaveWarning(string strFilePath, Exception ex, bool bCorruptionWarning) { FileLockException fl = (ex as FileLockException); if(fl != null) { ShowWarning(fl.Message); return; } string str = string.Empty; if((strFilePath != null) && (strFilePath.Length > 0)) str += strFilePath + MessageService.NewParagraph; str += KLRes.FileSaveFailed; if((ex != null) && (ex.Message != null) && (ex.Message.Length > 0)) str += MessageService.NewParagraph + ex.Message; if(bCorruptionWarning) str += MessageService.NewParagraph + KLRes.FileSaveCorruptionWarning; ShowWarning(str); } public static void ShowSaveWarning(IOConnectionInfo ioConnection, Exception ex, bool bCorruptionWarning) { if(ioConnection != null) ShowSaveWarning(ioConnection.GetDisplayName(), ex, bCorruptionWarning); else ShowWarning(ex); } public static void ExternalIncrementMessageCount() { ++m_uCurrentMessageCount; } public static void ExternalDecrementMessageCount() { --m_uCurrentMessageCount; } } } keepass2-2.25/KeePassLib/Utility/MemUtil.cs0000664000175000017500000004272412261553106020455 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Cryptography; using System.Diagnostics; using System.IO; #if !KeePassLibSD using System.IO.Compression; #else using KeePassLibSD; #endif namespace KeePassLib.Utility { /// /// Contains static buffer manipulation and string conversion routines. /// public static class MemUtil { private static readonly uint[] m_vSBox = new uint[256] { 0xCD2FACB3, 0xE78A7F5C, 0x6F0803FC, 0xBCF6E230, 0x3A321712, 0x06403DB1, 0xD2F84B95, 0xDF22A6E4, 0x07CE9E5B, 0x31788A0C, 0xF683F6F4, 0xEA061F49, 0xFA5C2ACA, 0x4B9E494E, 0xB0AB25BA, 0x767731FC, 0x261893A7, 0x2B09F2CE, 0x046261E4, 0x41367B4B, 0x18A7F225, 0x8F923C0E, 0x5EF3A325, 0x28D0435E, 0x84C22919, 0xED66873C, 0x8CEDE444, 0x7FC47C24, 0xFCFC6BA3, 0x676F928D, 0xB4147187, 0xD8FB126E, 0x7D798D17, 0xFF82E424, 0x1712FA5B, 0xABB09DD5, 0x8156BA63, 0x84E4D969, 0xC937FB9A, 0x2F1E5BFC, 0x178ECA11, 0x0E71CD5F, 0x52AAC6F4, 0x71EEFC8F, 0x7090D749, 0x21CACA31, 0x92996378, 0x0939A8A8, 0xE9EE1934, 0xD2718616, 0xF2500543, 0xB911873C, 0xD3CB3EEC, 0x2BA0DBEB, 0xB42D0A27, 0xECE67C0F, 0x302925F0, 0x6114F839, 0xD39E6307, 0xE28970D6, 0xEB982F99, 0x941B4CDF, 0xC540E550, 0x8124FC45, 0x98B025C7, 0xE2BF90EA, 0x4F57C976, 0xCF546FE4, 0x59566DC8, 0xE3F4360D, 0xF5F9D231, 0xD6180B22, 0xB54E088A, 0xB5DFE6A6, 0x3637A36F, 0x056E9284, 0xAFF8FBC5, 0x19E01648, 0x8611F043, 0xDAE44337, 0xF61B6A1C, 0x257ACD9E, 0xDD35F507, 0xEF05CAFA, 0x05EB4A83, 0xFC25CA92, 0x0A4728E6, 0x9CF150EF, 0xAEEF67DE, 0xA9472337, 0x57C81EFE, 0x3E5E009F, 0x02CB03BB, 0x2BA85674, 0xF21DC251, 0x78C34A34, 0xABB1F5BF, 0xB95A2FBD, 0x1FB47777, 0x9A96E8AC, 0x5D2D2838, 0x55AAC92A, 0x99EE324E, 0x10F6214B, 0x58ABDFB1, 0x2008794D, 0xBEC880F0, 0xE75E5341, 0x88015C34, 0x352D8FBF, 0x622B7F6C, 0xF5C59EA2, 0x1F759D8E, 0xADE56159, 0xCC7B4C25, 0x5B8BC48C, 0xB6BD15AF, 0x3C5B5110, 0xE74A7C3D, 0xEE613161, 0x156A1C67, 0x72C06817, 0xEA0A6F69, 0x4CECF993, 0xCA9D554C, 0x8E20361F, 0x42D396B9, 0x595DE578, 0x749D7955, 0xFD1BA5FD, 0x81FC160E, 0xDB97E28C, 0x7CF148F7, 0x0B0B3CF5, 0x534DE605, 0x46421066, 0xD4B68DD1, 0x9E479CE6, 0xAE667A9D, 0xBC082082, 0xB06DD6EF, 0x20F0F23F, 0xB99E1551, 0xF47A2E3A, 0x71DA50C6, 0x67B65779, 0x2A8CB376, 0x1EA71EEE, 0x29ABCD50, 0xB6EB0C6B, 0x23C10511, 0x6F3F2144, 0x6AF23012, 0xF696BD9E, 0xB94099D8, 0xAD5A9C81, 0x7A0794FA, 0x7EDF59D6, 0x1E72E574, 0x8561913C, 0x4E4D568F, 0xEECB9928, 0x9C124D2E, 0x0848B82C, 0xF1CA395F, 0x9DAF43DC, 0xF77EC323, 0x394E9B59, 0x7E200946, 0x8B811D68, 0x16DA3305, 0xAB8DE2C3, 0xE6C53B64, 0x98C2D321, 0x88A97D81, 0xA7106419, 0x8E52F7BF, 0x8ED262AF, 0x7CCA974E, 0xF0933241, 0x040DD437, 0xE143B3D4, 0x3019F56F, 0xB741521D, 0xF1745362, 0x4C435F9F, 0xB4214D0D, 0x0B0C348B, 0x5051D189, 0x4C30447E, 0x7393D722, 0x95CEDD0B, 0xDD994E80, 0xC3D22ED9, 0x739CD900, 0x131EB9C4, 0xEF1062B2, 0x4F0DE436, 0x52920073, 0x9A7F3D80, 0x896E7B1B, 0x2C8BBE5A, 0xBD304F8A, 0xA993E22C, 0x134C41A0, 0xFA989E00, 0x39CE9726, 0xFB89FCCF, 0xE8FBAC97, 0xD4063FFC, 0x935A2B5A, 0x44C8EE83, 0xCB2BC7B6, 0x02989E92, 0x75478BEA, 0x144378D0, 0xD853C087, 0x8897A34E, 0xDD23629D, 0xBDE2A2A2, 0x581D8ECC, 0x5DA8AEE8, 0xFF8AAFD0, 0xBA2BCF6E, 0x4BD98DAC, 0xF2EDB9E4, 0xFA2DC868, 0x47E84661, 0xECEB1C7D, 0x41705CA4, 0x5982E4D4, 0xEB5204A1, 0xD196CAFB, 0x6414804D, 0x3ABD4B46, 0x8B494C26, 0xB432D52B, 0x39C5356B, 0x6EC80BF7, 0x71BE5483, 0xCEC4A509, 0xE9411D61, 0x52F341E5, 0xD2E6197B, 0x4F02826C, 0xA9E48838, 0xD1F8F247, 0xE4957FB3, 0x586CCA99, 0x9A8B6A5B, 0x4998FBEA, 0xF762BE4C, 0x90DFE33C, 0x9731511E, 0x88C6A82F, 0xDD65A4D4 }; /// /// Convert a hexadecimal string to a byte array. The input string must be /// even (i.e. its length is a multiple of 2). /// /// String containing hexadecimal characters. /// Returns a byte array. Returns null if the string parameter /// was null or is an uneven string (i.e. if its length isn't a /// multiple of 2). /// Thrown if /// is null. public static byte[] HexStringToByteArray(string strHex) { if(strHex == null) { Debug.Assert(false); throw new ArgumentNullException("strHex"); } int nStrLen = strHex.Length; if((nStrLen & 1) != 0) { Debug.Assert(false); return null; } byte[] pb = new byte[nStrLen / 2]; byte bt; char ch; for(int i = 0; i < nStrLen; i += 2) { ch = strHex[i]; if((ch >= '0') && (ch <= '9')) bt = (byte)(ch - '0'); else if((ch >= 'a') && (ch <= 'f')) bt = (byte)(ch - 'a' + 10); else if((ch >= 'A') && (ch <= 'F')) bt = (byte)(ch - 'A' + 10); else { Debug.Assert(false); bt = 0; } bt <<= 4; ch = strHex[i + 1]; if((ch >= '0') && (ch <= '9')) bt += (byte)(ch - '0'); else if((ch >= 'a') && (ch <= 'f')) bt += (byte)(ch - 'a' + 10); else if((ch >= 'A') && (ch <= 'F')) bt += (byte)(ch - 'A' + 10); else { Debug.Assert(false); } pb[i >> 1] = bt; } return pb; } /// /// Convert a byte array to a hexadecimal string. /// /// Input byte array. /// Returns the hexadecimal string representing the byte /// array. Returns null, if the input byte array was null. Returns /// an empty string, if the input byte array has length 0. public static string ByteArrayToHexString(byte[] pbArray) { if(pbArray == null) return null; int nLen = pbArray.Length; if(nLen == 0) return string.Empty; StringBuilder sb = new StringBuilder(); byte bt, btHigh, btLow; for(int i = 0; i < nLen; ++i) { bt = pbArray[i]; btHigh = bt; btHigh >>= 4; btLow = (byte)(bt & 0x0F); if(btHigh >= 10) sb.Append((char)('A' + btHigh - 10)); else sb.Append((char)('0' + btHigh)); if(btLow >= 10) sb.Append((char)('A' + btLow - 10)); else sb.Append((char)('0' + btLow)); } return sb.ToString(); } /// /// Set all bytes in a byte array to zero. /// /// Input array. All bytes of this array will be set /// to zero. public static void ZeroByteArray(byte[] pbArray) { Debug.Assert(pbArray != null); if(pbArray == null) throw new ArgumentNullException("pbArray"); // for(int i = 0; i < pbArray.Length; ++i) // pbArray[i] = 0; Array.Clear(pbArray, 0, pbArray.Length); } /// /// Convert 2 bytes to a 16-bit unsigned integer using Little-Endian /// encoding. /// /// Input bytes. Array must contain at least 2 bytes. /// 16-bit unsigned integer. public static ushort BytesToUInt16(byte[] pb) { Debug.Assert((pb != null) && (pb.Length == 2)); if(pb == null) throw new ArgumentNullException("pb"); if(pb.Length != 2) throw new ArgumentException(); return (ushort)((ushort)pb[0] | ((ushort)pb[1] << 8)); } /// /// Convert 4 bytes to a 32-bit unsigned integer using Little-Endian /// encoding. /// /// Input bytes. /// 32-bit unsigned integer. public static uint BytesToUInt32(byte[] pb) { Debug.Assert((pb != null) && (pb.Length == 4)); if(pb == null) throw new ArgumentNullException("pb"); if(pb.Length != 4) throw new ArgumentException("Input array must contain 4 bytes!"); return (uint)pb[0] | ((uint)pb[1] << 8) | ((uint)pb[2] << 16) | ((uint)pb[3] << 24); } /// /// Convert 8 bytes to a 64-bit unsigned integer using Little-Endian /// encoding. /// /// Input bytes. /// 64-bit unsigned integer. public static ulong BytesToUInt64(byte[] pb) { Debug.Assert((pb != null) && (pb.Length == 8)); if(pb == null) throw new ArgumentNullException("pb"); if(pb.Length != 8) throw new ArgumentException(); return (ulong)pb[0] | ((ulong)pb[1] << 8) | ((ulong)pb[2] << 16) | ((ulong)pb[3] << 24) | ((ulong)pb[4] << 32) | ((ulong)pb[5] << 40) | ((ulong)pb[6] << 48) | ((ulong)pb[7] << 56); } /// /// Convert a 16-bit unsigned integer to 2 bytes using Little-Endian /// encoding. /// /// 16-bit input word. /// Two bytes representing the 16-bit value. public static byte[] UInt16ToBytes(ushort uValue) { byte[] pb = new byte[2]; unchecked { pb[0] = (byte)uValue; pb[1] = (byte)(uValue >> 8); } return pb; } /// /// Convert a 32-bit unsigned integer to 4 bytes using Little-Endian /// encoding. /// /// 32-bit input word. /// Four bytes representing the 32-bit value. public static byte[] UInt32ToBytes(uint uValue) { byte[] pb = new byte[4]; unchecked { pb[0] = (byte)uValue; pb[1] = (byte)(uValue >> 8); pb[2] = (byte)(uValue >> 16); pb[3] = (byte)(uValue >> 24); } return pb; } /// /// Convert a 64-bit unsigned integer to 8 bytes using Little-Endian /// encoding. /// /// 64-bit input word. /// Eight bytes representing the 64-bit value. public static byte[] UInt64ToBytes(ulong uValue) { byte[] pb = new byte[8]; unchecked { pb[0] = (byte)uValue; pb[1] = (byte)(uValue >> 8); pb[2] = (byte)(uValue >> 16); pb[3] = (byte)(uValue >> 24); pb[4] = (byte)(uValue >> 32); pb[5] = (byte)(uValue >> 40); pb[6] = (byte)(uValue >> 48); pb[7] = (byte)(uValue >> 56); } return pb; } public static bool ArraysEqual(byte[] x, byte[] y) { // Return false if one of them is null (not comparable)! if((x == null) || (y == null)) { Debug.Assert(false); return false; } if(x.Length != y.Length) return false; for(int i = 0; i < x.Length; ++i) { if(x[i] != y[i]) return false; } return true; } public static void XorArray(byte[] pbSource, int nSourceOffset, byte[] pbBuffer, int nBufferOffset, int nLength) { if(pbSource == null) throw new ArgumentNullException("pbSource"); if(nSourceOffset < 0) throw new ArgumentException(); if(pbBuffer == null) throw new ArgumentNullException("pbBuffer"); if(nBufferOffset < 0) throw new ArgumentException(); if(nLength < 0) throw new ArgumentException(); if((nSourceOffset + nLength) > pbSource.Length) throw new ArgumentException(); if((nBufferOffset + nLength) > pbBuffer.Length) throw new ArgumentException(); for(int i = 0; i < nLength; ++i) pbBuffer[nBufferOffset + i] ^= pbSource[nSourceOffset + i]; } /// /// Fast hash that can be used e.g. for hash tables. /// The algorithm might change in the future; do not store /// the hashes for later use. /// public static uint Hash32(byte[] v, int iStart, int iLength) { uint u = 0x326F637B; if(v == null) { Debug.Assert(false); return u; } if(iStart < 0) { Debug.Assert(false); return u; } if(iLength < 0) { Debug.Assert(false); return u; } int m = iStart + iLength; if(m > v.Length) { Debug.Assert(false); return u; } for(int i = iStart; i < m; ++i) { u ^= m_vSBox[v[i]]; u *= 3; } return u; } public static void CopyStream(Stream sSource, Stream sTarget) { Debug.Assert((sSource != null) && (sTarget != null)); if(sSource == null) throw new ArgumentNullException("sSource"); if(sTarget == null) throw new ArgumentNullException("sTarget"); const int nBufSize = 4096; byte[] pbBuf = new byte[nBufSize]; while(true) { int nRead = sSource.Read(pbBuf, 0, nBufSize); if(nRead == 0) break; sTarget.Write(pbBuf, 0, nRead); } // Do not close any of the streams } public static byte[] Read(Stream s, int nCount) { if(s == null) throw new ArgumentNullException("s"); if(nCount < 0) throw new ArgumentOutOfRangeException("nCount"); byte[] pb = new byte[nCount]; int iOffset = 0; while(nCount > 0) { int iRead = s.Read(pb, iOffset, nCount); if(iRead == 0) break; iOffset += iRead; nCount -= iRead; } if(iOffset != pb.Length) { byte[] pbPart = new byte[iOffset]; Array.Copy(pb, pbPart, iOffset); return pbPart; } return pb; } public static void Write(Stream s, byte[] pbData) { if(s == null) { Debug.Assert(false); return; } if(pbData == null) { Debug.Assert(false); return; } s.Write(pbData, 0, pbData.Length); } public static byte[] Compress(byte[] pbData) { if(pbData == null) throw new ArgumentNullException("pbData"); if(pbData.Length == 0) return pbData; MemoryStream msCompressed = new MemoryStream(); GZipStream gz = new GZipStream(msCompressed, CompressionMode.Compress); MemoryStream msSource = new MemoryStream(pbData, false); MemUtil.CopyStream(msSource, gz); gz.Close(); msSource.Close(); byte[] pbCompressed = msCompressed.ToArray(); msCompressed.Close(); return pbCompressed; } public static byte[] Decompress(byte[] pbCompressed) { if(pbCompressed == null) throw new ArgumentNullException("pbCompressed"); if(pbCompressed.Length == 0) return pbCompressed; MemoryStream msCompressed = new MemoryStream(pbCompressed, false); GZipStream gz = new GZipStream(msCompressed, CompressionMode.Decompress); MemoryStream msData = new MemoryStream(); MemUtil.CopyStream(gz, msData); gz.Close(); msCompressed.Close(); byte[] pbData = msData.ToArray(); msData.Close(); return pbData; } public static int IndexOf(T[] vHaystack, T[] vNeedle) where T : IEquatable { if(vHaystack == null) throw new ArgumentNullException("vHaystack"); if(vNeedle == null) throw new ArgumentNullException("vNeedle"); if(vNeedle.Length == 0) return 0; for(int i = 0; i <= (vHaystack.Length - vNeedle.Length); ++i) { bool bFound = true; for(int m = 0; m < vNeedle.Length; ++m) { if(!vHaystack[i + m].Equals(vNeedle[m])) { bFound = false; break; } } if(bFound) return i; } return -1; } public static T[] Mid(T[] v, int iOffset, int iLength) { if(v == null) throw new ArgumentNullException("v"); if(iOffset < 0) throw new ArgumentOutOfRangeException("iOffset"); if(iLength < 0) throw new ArgumentOutOfRangeException("iLength"); if((iOffset + iLength) > v.Length) throw new ArgumentException(); T[] r = new T[iLength]; Array.Copy(v, iOffset, r, 0, iLength); return r; } public static IEnumerable Union(IEnumerable a, IEnumerable b, IEqualityComparer cmp) { if(a == null) throw new ArgumentNullException("a"); if(b == null) throw new ArgumentNullException("b"); Dictionary d = ((cmp != null) ? (new Dictionary(cmp)) : (new Dictionary())); foreach(T ta in a) { if(d.ContainsKey(ta)) continue; // Prevent duplicates d[ta] = true; yield return ta; } foreach(T tb in b) { if(d.ContainsKey(tb)) continue; // Prevent duplicates d[tb] = true; yield return tb; } yield break; } public static IEnumerable Intersect(IEnumerable a, IEnumerable b, IEqualityComparer cmp) { if(a == null) throw new ArgumentNullException("a"); if(b == null) throw new ArgumentNullException("b"); Dictionary d = ((cmp != null) ? (new Dictionary(cmp)) : (new Dictionary())); foreach(T tb in b) { d[tb] = true; } foreach(T ta in a) { if(d.Remove(ta)) // Prevent duplicates yield return ta; } yield break; } public static IEnumerable Except(IEnumerable a, IEnumerable b, IEqualityComparer cmp) { if(a == null) throw new ArgumentNullException("a"); if(b == null) throw new ArgumentNullException("b"); Dictionary d = ((cmp != null) ? (new Dictionary(cmp)) : (new Dictionary())); foreach(T tb in b) { d[tb] = true; } foreach(T ta in a) { if(d.ContainsKey(ta)) continue; d[ta] = true; // Prevent duplicates yield return ta; } yield break; } } } keepass2-2.25/KeePassLib/Utility/TimeUtil.cs0000664000175000017500000002056412261553106020633 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; using KeePassLib.Interfaces; namespace KeePassLib.Utility { /// /// Contains various static time structure manipulation and conversion /// routines. /// public static class TimeUtil { /// /// Length of a compressed PW_TIME structure in bytes. /// public const int PwTimeLength = 7; /// /// Pack a DateTime object into 5 bytes. Layout: 2 zero bits, /// year 12 bits, month 4 bits, day 5 bits, hour 5 bits, minute 6 /// bits, second 6 bits. /// /// /// public static byte[] PackTime(DateTime dt) { byte[] pb = new byte[5]; // Pack time to 5 byte structure: // Byte bits: 11111111 22222222 33333333 44444444 55555555 // Contents : 00YYYYYY YYYYYYMM MMDDDDDH HHHHMMMM MMSSSSSS pb[0] = (byte)((dt.Year >> 6) & 0x3F); pb[1] = (byte)(((dt.Year & 0x3F) << 2) | ((dt.Month >> 2) & 0x03)); pb[2] = (byte)(((dt.Month & 0x03) << 6) | ((dt.Day & 0x1F) << 1) | ((dt.Hour >> 4) & 0x01)); pb[3] = (byte)(((dt.Hour & 0x0F) << 4) | ((dt.Minute >> 2) & 0x0F)); pb[4] = (byte)(((dt.Minute & 0x03) << 6) | (dt.Second & 0x3F)); return pb; } /// /// Unpack a packed time (5 bytes, packed by the PackTime /// member function) to a DateTime object. /// /// Packed time, 5 bytes. /// Unpacked DateTime object. public static DateTime UnpackTime(byte[] pb) { Debug.Assert((pb != null) && (pb.Length == 5)); if(pb == null) throw new ArgumentNullException("pb"); if(pb.Length != 5) throw new ArgumentException(); int n1 = pb[0], n2 = pb[1], n3 = pb[2], n4 = pb[3], n5 = pb[4]; // Unpack 5 byte structure to date and time int nYear = (n1 << 6) | (n2 >> 2); int nMonth = ((n2 & 0x00000003) << 2) | (n3 >> 6); int nDay = (n3 >> 1) & 0x0000001F; int nHour = ((n3 & 0x00000001) << 4) | (n4 >> 4); int nMinute = ((n4 & 0x0000000F) << 2) | (n5 >> 6); int nSecond = n5 & 0x0000003F; return new DateTime(nYear, nMonth, nDay, nHour, nMinute, nSecond); } /// /// Pack a DateTime object into 7 bytes (PW_TIME). /// /// Object to be encoded. /// Packed time, 7 bytes (PW_TIME). public static byte[] PackPwTime(DateTime dt) { Debug.Assert(PwTimeLength == 7); byte[] pb = new byte[7]; pb[0] = (byte)(dt.Year & 0xFF); pb[1] = (byte)(dt.Year >> 8); pb[2] = (byte)dt.Month; pb[3] = (byte)dt.Day; pb[4] = (byte)dt.Hour; pb[5] = (byte)dt.Minute; pb[6] = (byte)dt.Second; return pb; } /// /// Unpack a packed time (7 bytes, PW_TIME) to a DateTime object. /// /// Packed time, 7 bytes. /// Unpacked DateTime object. public static DateTime UnpackPwTime(byte[] pb) { Debug.Assert(PwTimeLength == 7); Debug.Assert(pb != null); if(pb == null) throw new ArgumentNullException("pb"); Debug.Assert(pb.Length == 7); if(pb.Length != 7) throw new ArgumentException(); return new DateTime(((int)pb[1] << 8) | (int)pb[0], (int)pb[2], (int)pb[3], (int)pb[4], (int)pb[5], (int)pb[6]); } /// /// Convert a DateTime object to a displayable string. /// /// DateTime object to convert to a string. /// String representing the specified DateTime object. public static string ToDisplayString(DateTime dt) { return dt.ToString(); } public static string ToDisplayStringDateOnly(DateTime dt) { return dt.ToString("d"); } public static DateTime FromDisplayString(string strDisplay) { DateTime dt; #if !KeePassLibSD if(DateTime.TryParse(strDisplay, out dt)) return dt; #else try { dt = DateTime.Parse(strDisplay); return dt; } catch(Exception) { } #endif Debug.Assert(false); return DateTime.Now; } public static string SerializeUtc(DateTime dt) { string str = dt.ToUniversalTime().ToString("s"); if(str.EndsWith("Z") == false) str += "Z"; return str; } public static bool TryDeserializeUtc(string str, out DateTime dt) { if(str == null) throw new ArgumentNullException("str"); if(str.EndsWith("Z")) str = str.Substring(0, str.Length - 1); bool bResult = StrUtil.TryParseDateTime(str, out dt); if(bResult) dt = dt.ToLocalTime(); return bResult; } private static DateTime? m_dtUnixRoot = null; public static DateTime ConvertUnixTime(double dtUnix) { try { if(!m_dtUnixRoot.HasValue) m_dtUnixRoot = (new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)).ToLocalTime(); return m_dtUnixRoot.Value.AddSeconds(dtUnix); } catch(Exception) { Debug.Assert(false); } return DateTime.Now; } #if !KeePassLibSD private static string[] m_vUSMonths = null; /// /// Parse a US textual date string, like e.g. "January 02, 2012". /// public static DateTime? ParseUSTextDate(string strDate) { if(strDate == null) { Debug.Assert(false); return null; } if(m_vUSMonths == null) m_vUSMonths = new string[]{ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; string str = strDate.Trim(); for(int i = 0; i < m_vUSMonths.Length; ++i) { if(str.StartsWith(m_vUSMonths[i], StrUtil.CaseIgnoreCmp)) { str = str.Substring(m_vUSMonths[i].Length); string[] v = str.Split(new char[]{ ',', ';' }); if((v == null) || (v.Length != 2)) return null; string strDay = v[0].Trim().TrimStart('0'); int iDay, iYear; if(int.TryParse(strDay, out iDay) && int.TryParse(v[1].Trim(), out iYear)) return new DateTime(iYear, i + 1, iDay); else { Debug.Assert(false); return null; } } } return null; } #endif private static readonly DateTime m_dtInvMin = new DateTime(2999, 12, 27, 23, 59, 59); private static readonly DateTime m_dtInvMax = new DateTime(2999, 12, 29, 23, 59, 59); public static int Compare(DateTime dtA, DateTime dtB, bool bUnkIsPast) { if(bUnkIsPast) { // 2999-12-28 23:59:59 in KeePass 1.x means 'unknown'; // expect time zone corruption (twice) // bool bInvA = ((dtA.Year == 2999) && (dtA.Month == 12) && // (dtA.Day >= 27) && (dtA.Day <= 29) && (dtA.Minute == 59) && // (dtA.Second == 59)); // bool bInvB = ((dtB.Year == 2999) && (dtB.Month == 12) && // (dtB.Day >= 27) && (dtB.Day <= 29) && (dtB.Minute == 59) && // (dtB.Second == 59)); // Faster due to internal implementation of DateTime: bool bInvA = ((dtA >= m_dtInvMin) && (dtA <= m_dtInvMax) && (dtA.Minute == 59) && (dtA.Second == 59)); bool bInvB = ((dtB >= m_dtInvMin) && (dtB <= m_dtInvMax) && (dtB.Minute == 59) && (dtB.Second == 59)); if(bInvA) return (bInvB ? 0 : -1); if(bInvB) return 1; } return dtA.CompareTo(dtB); } internal static int CompareLastMod(ITimeLogger tlA, ITimeLogger tlB, bool bUnkIsPast) { if(tlA == null) { Debug.Assert(false); return ((tlB == null) ? 0 : -1); } if(tlB == null) { Debug.Assert(false); return 1; } return Compare(tlA.LastModificationTime, tlB.LastModificationTime, bUnkIsPast); } } } keepass2-2.25/KeePassLib/Utility/AppLogEx.cs0000664000175000017500000000545012261553106020553 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; #if !KeePassLibSD using System.IO.Compression; #endif namespace KeePassLib.Utility { /// /// Application-wide logging services. /// public static class AppLogEx { private static StreamWriter m_swOut = null; public static void Open(string strPrefix) { return; // Logging is not enabled in normal builds of KeePass! /* AppLogEx.Close(); Debug.Assert(strPrefix != null); if(strPrefix == null) strPrefix = "Log"; try { string strDirSep = string.Empty; strDirSep += UrlUtil.LocalDirSepChar; string strTemp = UrlUtil.GetTempPath(); if(!strTemp.EndsWith(strDirSep)) strTemp += strDirSep; string strPath = strTemp + strPrefix + "-"; Debug.Assert(strPath.IndexOf('/') < 0); DateTime dtNow = DateTime.Now; string strTime = dtNow.ToString("s"); strTime = strTime.Replace('T', '-'); strTime = strTime.Replace(':', '-'); strPath += strTime + "-" + Environment.TickCount.ToString( NumberFormatInfo.InvariantInfo) + ".log.gz"; FileStream fsOut = new FileStream(strPath, FileMode.Create, FileAccess.Write, FileShare.None); GZipStream gz = new GZipStream(fsOut, CompressionMode.Compress); m_swOut = new StreamWriter(gz); AppLogEx.Log("Started logging on " + dtNow.ToString("s") + "."); } catch(Exception) { Debug.Assert(false); } */ } public static void Close() { if(m_swOut == null) return; m_swOut.Close(); m_swOut = null; } public static void Log(string strText) { if(m_swOut == null) return; if(strText == null) m_swOut.WriteLine(); else m_swOut.WriteLine(strText); } public static void Log(Exception ex) { if(m_swOut == null) return; if(ex == null) m_swOut.WriteLine(); else m_swOut.WriteLine(ex.ToString()); } } } keepass2-2.25/KeePassLib/Utility/StrUtil.cs0000664000175000017500000012432112261553106020501 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; using System.Collections.Generic; using System.Text; using System.Drawing; using System.IO; using System.Text.RegularExpressions; using System.Security.Cryptography; using System.Globalization; using System.Diagnostics; using KeePassLib.Collections; using KeePassLib.Cryptography.PasswordGenerator; using KeePassLib.Native; using KeePassLib.Security; using KeePassLib.Resources; namespace KeePassLib.Utility { /// /// Character stream class. /// public sealed class CharStream { private string m_strString = string.Empty; private int m_nPos = 0; public CharStream(string str) { Debug.Assert(str != null); if(str == null) throw new ArgumentNullException("str"); m_strString = str; } public void Seek(SeekOrigin org, int nSeek) { if(org == SeekOrigin.Begin) m_nPos = nSeek; else if(org == SeekOrigin.Current) m_nPos += nSeek; else if(org == SeekOrigin.End) m_nPos = m_strString.Length + nSeek; } public char ReadChar() { if(m_nPos < 0) return char.MinValue; if(m_nPos >= m_strString.Length) return char.MinValue; char chRet = m_strString[m_nPos]; ++m_nPos; return chRet; } public char ReadChar(bool bSkipWhiteSpace) { if(bSkipWhiteSpace == false) return ReadChar(); while(true) { char ch = ReadChar(); if((ch != ' ') && (ch != '\t') && (ch != '\r') && (ch != '\n')) return ch; } } public char PeekChar() { if(m_nPos < 0) return char.MinValue; if(m_nPos >= m_strString.Length) return char.MinValue; return m_strString[m_nPos]; } public char PeekChar(bool bSkipWhiteSpace) { if(bSkipWhiteSpace == false) return PeekChar(); int iIndex = m_nPos; while(true) { if(iIndex < 0) return char.MinValue; if(iIndex >= m_strString.Length) return char.MinValue; char ch = m_strString[iIndex]; if((ch != ' ') && (ch != '\t') && (ch != '\r') && (ch != '\n')) return ch; ++iIndex; } } } public enum StrEncodingType { Unknown = 0, Default, Ascii, Utf7, Utf8, Utf16LE, Utf16BE, Utf32LE, Utf32BE } public sealed class StrEncodingInfo { private readonly StrEncodingType m_type; public StrEncodingType Type { get { return m_type; } } private readonly string m_strName; public string Name { get { return m_strName; } } private readonly Encoding m_enc; public Encoding Encoding { get { return m_enc; } } private readonly uint m_cbCodePoint; /// /// Size of a character in bytes. /// public uint CodePointSize { get { return m_cbCodePoint; } } private readonly byte[] m_vSig; /// /// Start signature of the text (byte order mark). /// May be null or empty, if no signature is known. /// public byte[] StartSignature { get { return m_vSig; } } public StrEncodingInfo(StrEncodingType t, string strName, Encoding enc, uint cbCodePoint, byte[] vStartSig) { if(strName == null) throw new ArgumentNullException("strName"); if(enc == null) throw new ArgumentNullException("enc"); if(cbCodePoint <= 0) throw new ArgumentOutOfRangeException("cbCodePoint"); m_type = t; m_strName = strName; m_enc = enc; m_cbCodePoint = cbCodePoint; m_vSig = vStartSig; } } /// /// A class containing various string helper methods. /// public static class StrUtil { public const StringComparison CaseIgnoreCmp = StringComparison.OrdinalIgnoreCase; public static StringComparer CaseIgnoreComparer { get { return StringComparer.OrdinalIgnoreCase; } } private static bool m_bRtl = false; public static bool RightToLeft { get { return m_bRtl; } set { m_bRtl = value; } } private static UTF8Encoding m_encUtf8 = null; public static UTF8Encoding Utf8 { get { if(m_encUtf8 == null) m_encUtf8 = new UTF8Encoding(false, false); return m_encUtf8; } } private static List m_lEncs = null; public static IEnumerable Encodings { get { if(m_lEncs != null) return m_lEncs; List l = new List(); l.Add(new StrEncodingInfo(StrEncodingType.Default, #if KeePassRT StrUtil.Utf8.WebName, StrUtil.Utf8, 1, null)); #else #if !KeePassLibSD Encoding.Default.EncodingName, #else Encoding.Default.WebName, #endif Encoding.Default, (uint)Encoding.Default.GetBytes("a").Length, null)); #endif #if !KeePassRT l.Add(new StrEncodingInfo(StrEncodingType.Ascii, "ASCII", Encoding.ASCII, 1, null)); l.Add(new StrEncodingInfo(StrEncodingType.Utf7, "Unicode (UTF-7)", Encoding.UTF7, 1, null)); #endif l.Add(new StrEncodingInfo(StrEncodingType.Utf8, "Unicode (UTF-8)", StrUtil.Utf8, 1, new byte[] { 0xEF, 0xBB, 0xBF })); l.Add(new StrEncodingInfo(StrEncodingType.Utf16LE, "Unicode (UTF-16 LE)", new UnicodeEncoding(false, false), 2, new byte[] { 0xFF, 0xFE })); l.Add(new StrEncodingInfo(StrEncodingType.Utf16BE, "Unicode (UTF-16 BE)", new UnicodeEncoding(true, false), 2, new byte[] { 0xFE, 0xFF })); #if (!KeePassLibSD && !KeePassRT) l.Add(new StrEncodingInfo(StrEncodingType.Utf32LE, "Unicode (UTF-32 LE)", new UTF32Encoding(false, false), 4, new byte[] { 0xFF, 0xFE, 0x0, 0x0 })); l.Add(new StrEncodingInfo(StrEncodingType.Utf32BE, "Unicode (UTF-32 BE)", new UTF32Encoding(true, false), 4, new byte[] { 0x0, 0x0, 0xFE, 0xFF })); #endif m_lEncs = l; return l; } } // public static string RtfPar // { // // get { return (m_bRtl ? "\\rtlpar " : "\\par "); } // get { return "\\par "; } // } // /// // /// Convert a string into a valid RTF string. // /// // /// Any string. // /// RTF-encoded string. // public static string MakeRtfString(string str) // { // Debug.Assert(str != null); if(str == null) throw new ArgumentNullException("str"); // str = str.Replace("\\", "\\\\"); // str = str.Replace("\r", string.Empty); // str = str.Replace("{", "\\{"); // str = str.Replace("}", "\\}"); // str = str.Replace("\n", StrUtil.RtfPar); // StringBuilder sbEncoded = new StringBuilder(); // for(int i = 0; i < str.Length; ++i) // { // char ch = str[i]; // if((int)ch >= 256) // sbEncoded.Append(StrUtil.RtfEncodeChar(ch)); // else sbEncoded.Append(ch); // } // return sbEncoded.ToString(); // } public static string RtfEncodeChar(char ch) { // Unicode character values must be encoded using // 16-bit numbers (decimal); Unicode values greater // than 32767 must be expressed as negative numbers short sh = (short)ch; return ("\\u" + sh.ToString(NumberFormatInfo.InvariantInfo) + "?"); } /// /// Convert a string into a valid HTML sequence representing that string. /// /// String to convert. /// String, HTML-encoded. public static string StringToHtml(string str) { Debug.Assert(str != null); if(str == null) throw new ArgumentNullException("str"); str = str.Replace(@"&", @"&"); str = str.Replace(@"<", @"<"); str = str.Replace(@">", @">"); str = str.Replace("\"", @"""); str = str.Replace("\'", @"'"); str = NormalizeNewLines(str, false); str = str.Replace("\n", @"
"); return str; } public static string XmlToString(string str) { Debug.Assert(str != null); if(str == null) throw new ArgumentNullException("str"); str = str.Replace(@"&", @"&"); str = str.Replace(@"<", @"<"); str = str.Replace(@">", @">"); str = str.Replace(@""", "\""); str = str.Replace(@"'", "\'"); return str; } public static string ReplaceCaseInsensitive(string strString, string strFind, string strNew) { Debug.Assert(strString != null); if(strString == null) return strString; Debug.Assert(strFind != null); if(strFind == null) return strString; Debug.Assert(strNew != null); if(strNew == null) return strString; string str = strString; int nPos = 0; while(nPos < str.Length) { nPos = str.IndexOf(strFind, nPos, StringComparison.OrdinalIgnoreCase); if(nPos < 0) break; str = str.Remove(nPos, strFind.Length); str = str.Insert(nPos, strNew); nPos += strNew.Length; } return str; } /// /// Split up a command-line into application and argument. /// /// Command-line to split. /// Application path. /// Arguments. public static void SplitCommandLine(string strCmdLine, out string strApp, out string strArgs) { Debug.Assert(strCmdLine != null); if(strCmdLine == null) throw new ArgumentNullException("strCmdLine"); string str = strCmdLine.Trim(); strApp = null; strArgs = null; if(str.StartsWith("\"")) { int nSecond = str.IndexOf('\"', 1); if(nSecond >= 1) { strApp = str.Substring(1, nSecond - 1).Trim(); strArgs = str.Remove(0, nSecond + 1).Trim(); } } if(strApp == null) { int nSpace = str.IndexOf(' '); if(nSpace >= 0) { strApp = str.Substring(0, nSpace); strArgs = str.Remove(0, nSpace).Trim(); } else strApp = strCmdLine; } if(strApp == null) strApp = string.Empty; if(strArgs == null) strArgs = string.Empty; } // /// // /// Initialize an RTF document based on given font face and size. // /// // /// StringBuilder to put the generated RTF into. // /// Face name of the font to use. // /// Size of the font to use. // public static void InitRtf(StringBuilder sb, string strFontFace, float fFontSize) // { // Debug.Assert(sb != null); if(sb == null) throw new ArgumentNullException("sb"); // Debug.Assert(strFontFace != null); if(strFontFace == null) throw new ArgumentNullException("strFontFace"); // sb.Append("{\\rtf1"); // if(m_bRtl) sb.Append("\\fbidis"); // sb.Append("\\ansi\\ansicpg"); // sb.Append(Encoding.Default.CodePage); // sb.Append("\\deff0{\\fonttbl{\\f0\\fswiss MS Sans Serif;}{\\f1\\froman\\fcharset2 Symbol;}{\\f2\\fswiss "); // sb.Append(strFontFace); // sb.Append(";}{\\f3\\fswiss Arial;}}"); // sb.Append("{\\colortbl\\red0\\green0\\blue0;}"); // if(m_bRtl) sb.Append("\\rtldoc"); // sb.Append("\\deflang1031\\pard\\plain\\f2\\cf0 "); // sb.Append("\\fs"); // sb.Append((int)(fFontSize * 2)); // if(m_bRtl) sb.Append("\\rtlpar\\qr\\rtlch "); // } // /// // /// Convert a simple HTML string to an RTF string. // /// // /// Input HTML string. // /// RTF string representing the HTML input string. // public static string SimpleHtmlToRtf(string strHtmlString) // { // StringBuilder sb = new StringBuilder(); // StrUtil.InitRtf(sb, "Microsoft Sans Serif", 8.25f); // sb.Append(" "); // string str = MakeRtfString(strHtmlString); // str = str.Replace("", "\\b "); // str = str.Replace("", "\\b0 "); // str = str.Replace("", "\\i "); // str = str.Replace("", "\\i0 "); // str = str.Replace("", "\\ul "); // str = str.Replace("", "\\ul0 "); // str = str.Replace("
", StrUtil.RtfPar); // sb.Append(str); // return sb.ToString(); // } /// /// Convert a Color to a HTML color identifier string. /// /// Color to convert. /// If this is true, an empty string /// is returned if the color is transparent. /// HTML color identifier string. public static string ColorToUnnamedHtml(Color color, bool bEmptyIfTransparent) { if(bEmptyIfTransparent && (color.A != 255)) return string.Empty; StringBuilder sb = new StringBuilder(); byte bt; sb.Append('#'); bt = (byte)(color.R >> 4); if(bt < 10) sb.Append((char)('0' + bt)); else sb.Append((char)('A' - 10 + bt)); bt = (byte)(color.R & 0x0F); if(bt < 10) sb.Append((char)('0' + bt)); else sb.Append((char)('A' - 10 + bt)); bt = (byte)(color.G >> 4); if(bt < 10) sb.Append((char)('0' + bt)); else sb.Append((char)('A' - 10 + bt)); bt = (byte)(color.G & 0x0F); if(bt < 10) sb.Append((char)('0' + bt)); else sb.Append((char)('A' - 10 + bt)); bt = (byte)(color.B >> 4); if(bt < 10) sb.Append((char)('0' + bt)); else sb.Append((char)('A' - 10 + bt)); bt = (byte)(color.B & 0x0F); if(bt < 10) sb.Append((char)('0' + bt)); else sb.Append((char)('A' - 10 + bt)); return sb.ToString(); } /// /// Format an exception and convert it to a string. /// /// Exception to convert/format. /// String representing the exception. public static string FormatException(Exception excp) { string strText = string.Empty; if(excp.Message != null) strText += excp.Message + MessageService.NewLine; #if !KeePassLibSD if(excp.Source != null) strText += excp.Source + MessageService.NewLine; #endif if(excp.StackTrace != null) strText += excp.StackTrace + MessageService.NewLine; #if !KeePassLibSD #if !KeePassRT if(excp.TargetSite != null) strText += excp.TargetSite.ToString() + MessageService.NewLine; #endif if(excp.Data != null) { strText += MessageService.NewLine; foreach(DictionaryEntry de in excp.Data) strText += @"'" + de.Key + @"' -> '" + de.Value + @"'" + MessageService.NewLine; } #endif if(excp.InnerException != null) { strText += MessageService.NewLine + "Inner:" + MessageService.NewLine; if(excp.InnerException.Message != null) strText += excp.InnerException.Message + MessageService.NewLine; #if !KeePassLibSD if(excp.InnerException.Source != null) strText += excp.InnerException.Source + MessageService.NewLine; #endif if(excp.InnerException.StackTrace != null) strText += excp.InnerException.StackTrace + MessageService.NewLine; #if !KeePassLibSD #if !KeePassRT if(excp.InnerException.TargetSite != null) strText += excp.InnerException.TargetSite.ToString(); #endif if(excp.InnerException.Data != null) { strText += MessageService.NewLine; foreach(DictionaryEntry de in excp.InnerException.Data) strText += @"'" + de.Key + @"' -> '" + de.Value + @"'" + MessageService.NewLine; } #endif } return strText; } public static bool TryParseUShort(string str, out ushort u) { #if !KeePassLibSD return ushort.TryParse(str, out u); #else try { u = ushort.Parse(str); return true; } catch(Exception) { u = 0; return false; } #endif } public static bool TryParseInt(string str, out int n) { #if !KeePassLibSD return int.TryParse(str, out n); #else try { n = int.Parse(str); return true; } catch(Exception) { n = 0; } return false; #endif } public static bool TryParseIntInvariant(string str, out int n) { #if !KeePassLibSD return int.TryParse(str, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out n); #else try { n = int.Parse(str, NumberStyles.Integer, NumberFormatInfo.InvariantInfo); return true; } catch(Exception) { n = 0; } return false; #endif } public static bool TryParseUInt(string str, out uint u) { #if !KeePassLibSD return uint.TryParse(str, out u); #else try { u = uint.Parse(str); return true; } catch(Exception) { u = 0; } return false; #endif } public static bool TryParseUIntInvariant(string str, out uint u) { #if !KeePassLibSD return uint.TryParse(str, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out u); #else try { u = uint.Parse(str, NumberStyles.Integer, NumberFormatInfo.InvariantInfo); return true; } catch(Exception) { u = 0; } return false; #endif } public static bool TryParseLong(string str, out long n) { #if !KeePassLibSD return long.TryParse(str, out n); #else try { n = long.Parse(str); return true; } catch(Exception) { n = 0; } return false; #endif } public static bool TryParseLongInvariant(string str, out long n) { #if !KeePassLibSD return long.TryParse(str, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out n); #else try { n = long.Parse(str, NumberStyles.Integer, NumberFormatInfo.InvariantInfo); return true; } catch(Exception) { n = 0; } return false; #endif } public static bool TryParseULong(string str, out ulong u) { #if !KeePassLibSD return ulong.TryParse(str, out u); #else try { u = ulong.Parse(str); return true; } catch(Exception) { u = 0; } return false; #endif } public static bool TryParseULongInvariant(string str, out ulong u) { #if !KeePassLibSD return ulong.TryParse(str, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out u); #else try { u = ulong.Parse(str, NumberStyles.Integer, NumberFormatInfo.InvariantInfo); return true; } catch(Exception) { u = 0; } return false; #endif } public static bool TryParseDateTime(string str, out DateTime dt) { #if !KeePassLibSD return DateTime.TryParse(str, out dt); #else try { dt = DateTime.Parse(str); return true; } catch(Exception) { dt = DateTime.MinValue; return false; } #endif } public static string CompactString3Dots(string strText, int nMaxChars) { Debug.Assert(strText != null); if(strText == null) throw new ArgumentNullException("strText"); Debug.Assert(nMaxChars >= 0); if(nMaxChars < 0) throw new ArgumentOutOfRangeException("nMaxChars"); if(nMaxChars == 0) return string.Empty; if(strText.Length <= nMaxChars) return strText; if(nMaxChars <= 3) return strText.Substring(0, nMaxChars); return strText.Substring(0, nMaxChars - 3) + "..."; } public static string GetStringBetween(string strText, int nStartIndex, string strStart, string strEnd) { int nTemp; return GetStringBetween(strText, nStartIndex, strStart, strEnd, out nTemp); } public static string GetStringBetween(string strText, int nStartIndex, string strStart, string strEnd, out int nInnerStartIndex) { if(strText == null) throw new ArgumentNullException("strText"); if(strStart == null) throw new ArgumentNullException("strStart"); if(strEnd == null) throw new ArgumentNullException("strEnd"); nInnerStartIndex = -1; int nIndex = strText.IndexOf(strStart, nStartIndex); if(nIndex < 0) return string.Empty; nIndex += strStart.Length; int nEndIndex = strText.IndexOf(strEnd, nIndex); if(nEndIndex < 0) return string.Empty; nInnerStartIndex = nIndex; return strText.Substring(nIndex, nEndIndex - nIndex); } /// /// Removes all characters that are not valid XML characters, /// according to http://www.w3.org/TR/xml/#charsets . /// /// Source text. /// Text containing only valid XML characters. public static string SafeXmlString(string strText) { Debug.Assert(strText != null); // No throw if(string.IsNullOrEmpty(strText)) return strText; int nLength = strText.Length; StringBuilder sb = new StringBuilder(nLength); for(int i = 0; i < nLength; ++i) { char ch = strText[i]; if(((ch >= '\u0020') && (ch <= '\uD7FF')) || (ch == '\u0009') || (ch == '\u000A') || (ch == '\u000D') || ((ch >= '\uE000') && (ch <= '\uFFFD'))) sb.Append(ch); else if((ch >= '\uD800') && (ch <= '\uDBFF')) // High surrogate { if((i + 1) < nLength) { char chLow = strText[i + 1]; if((chLow >= '\uDC00') && (chLow <= '\uDFFF')) // Low sur. { sb.Append(ch); sb.Append(chLow); ++i; } else { Debug.Assert(false); } // Low sur. invalid } else { Debug.Assert(false); } // Low sur. missing } Debug.Assert((ch < '\uDC00') || (ch > '\uDFFF')); // Lonely low sur. } return sb.ToString(); } private static Regex m_rxNaturalSplit = null; public static int CompareNaturally(string strX, string strY) { Debug.Assert(strX != null); if(strX == null) throw new ArgumentNullException("strX"); Debug.Assert(strY != null); if(strY == null) throw new ArgumentNullException("strY"); if(NativeMethods.SupportsStrCmpNaturally) return NativeMethods.StrCmpNaturally(strX, strY); strX = strX.ToLower(); // Case-insensitive comparison strY = strY.ToLower(); if(m_rxNaturalSplit == null) m_rxNaturalSplit = new Regex(@"([0-9]+)", #if KeePassRT RegexOptions.None); #else RegexOptions.Compiled); #endif string[] vPartsX = m_rxNaturalSplit.Split(strX); string[] vPartsY = m_rxNaturalSplit.Split(strY); for(int i = 0; i < Math.Min(vPartsX.Length, vPartsY.Length); ++i) { string strPartX = vPartsX[i], strPartY = vPartsY[i]; int iPartCompare; #if KeePassLibSD ulong uX = 0, uY = 0; try { uX = ulong.Parse(strPartX); uY = ulong.Parse(strPartY); iPartCompare = uX.CompareTo(uY); } catch(Exception) { iPartCompare = strPartX.CompareTo(strPartY); } #else ulong uX, uY; if(ulong.TryParse(strPartX, out uX) && ulong.TryParse(strPartY, out uY)) iPartCompare = uX.CompareTo(uY); else iPartCompare = strPartX.CompareTo(strPartY); #endif if(iPartCompare != 0) return iPartCompare; } if(vPartsX.Length == vPartsY.Length) return 0; if(vPartsX.Length < vPartsY.Length) return -1; return 1; } public static string RemoveAccelerator(string strMenuText) { if(strMenuText == null) throw new ArgumentNullException("strMenuText"); string str = strMenuText; for(char ch = 'A'; ch <= 'Z'; ++ch) { string strEnhAcc = @"(&" + ch.ToString() + @")"; if(str.IndexOf(strEnhAcc) >= 0) { str = str.Replace(@" " + strEnhAcc, string.Empty); str = str.Replace(strEnhAcc, string.Empty); } } str = str.Replace(@"&", string.Empty); return str; } public static string EncodeMenuText(string strText) { if(strText == null) throw new ArgumentNullException("strText"); return strText.Replace(@"&", @"&&"); } public static string EncodeToolTipText(string strText) { if(strText == null) throw new ArgumentNullException("strText"); return strText.Replace(@"&", @"&&&"); } public static bool IsHexString(string str, bool bStrict) { if(str == null) throw new ArgumentNullException("str"); if(str.Length == 0) return true; foreach(char ch in str) { if((ch >= '0') && (ch <= '9')) continue; if((ch >= 'a') && (ch <= 'z')) continue; if((ch >= 'A') && (ch <= 'Z')) continue; if(bStrict) return false; if((ch == ' ') || (ch == '\t') || (ch == '\r') || (ch == '\n')) continue; return false; } return true; } #if !KeePassLibSD private static readonly char[] m_vPatternPartsSep = new char[]{ '*' }; public static bool SimplePatternMatch(string strPattern, string strText, StringComparison sc) { if(strPattern == null) throw new ArgumentNullException("strPattern"); if(strText == null) throw new ArgumentNullException("strText"); if(strPattern.IndexOf('*') < 0) return strText.Equals(strPattern, sc); string[] vPatternParts = strPattern.Split(m_vPatternPartsSep, StringSplitOptions.RemoveEmptyEntries); if(vPatternParts == null) { Debug.Assert(false); return true; } if(vPatternParts.Length == 0) return true; if(strText.Length == 0) return false; if(!strPattern.StartsWith(@"*") && !strText.StartsWith(vPatternParts[0], sc)) { return false; } if(!strPattern.EndsWith(@"*") && !strText.EndsWith(vPatternParts[ vPatternParts.Length - 1], sc)) { return false; } int iOffset = 0; for(int i = 0; i < vPatternParts.Length; ++i) { string strPart = vPatternParts[i]; int iFound = strText.IndexOf(strPart, iOffset, sc); if(iFound < iOffset) return false; iOffset = iFound + strPart.Length; if(iOffset == strText.Length) return (i == (vPatternParts.Length - 1)); } return true; } #endif // !KeePassLibSD public static bool StringToBool(string str) { if(string.IsNullOrEmpty(str)) return false; // No assert string s = str.Trim().ToLower(); if(s == "true") return true; if(s == "yes") return true; if(s == "1") return true; if(s == "enabled") return true; if(s == "checked") return true; return false; } public static bool? StringToBoolEx(string str) { if(string.IsNullOrEmpty(str)) return null; string s = str.Trim().ToLower(); if(s == "true") return true; if(s == "false") return false; return null; } public static string BoolToString(bool bValue) { return (bValue ? "true" : "false"); } public static string BoolToStringEx(bool? bValue) { if(bValue.HasValue) return BoolToString(bValue.Value); return "null"; } /// /// Normalize new line characters in a string. Input strings may /// contain mixed new line character sequences from all commonly /// used operating systems (i.e. \r\n from Windows, \n from Unix /// and \r from Mac OS. /// /// String with mixed new line characters. /// If true, new line characters /// are normalized for Windows (\r\n); if false, new line /// characters are normalized for Unix (\n). /// String with normalized new line characters. public static string NormalizeNewLines(string str, bool bWindows) { if(string.IsNullOrEmpty(str)) return str; str = str.Replace("\r\n", "\n"); str = str.Replace("\r", "\n"); if(bWindows) str = str.Replace("\n", "\r\n"); return str; } private static char[] m_vNewLineChars = null; public static void NormalizeNewLines(ProtectedStringDictionary dict, bool bWindows) { if(dict == null) { Debug.Assert(false); return; } if(m_vNewLineChars == null) m_vNewLineChars = new char[]{ '\r', '\n' }; List vKeys = dict.GetKeys(); foreach(string strKey in vKeys) { ProtectedString ps = dict.Get(strKey); if(ps == null) { Debug.Assert(false); continue; } string strValue = ps.ReadString(); if(strValue.IndexOfAny(m_vNewLineChars) < 0) continue; dict.Set(strKey, new ProtectedString(ps.IsProtected, NormalizeNewLines(strValue, bWindows))); } } public static string AlphaNumericOnly(string str) { if(string.IsNullOrEmpty(str)) return str; StringBuilder sb = new StringBuilder(); for(int i = 0; i < str.Length; ++i) { char ch = str[i]; if(((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')) || ((ch >= '0') && (ch <= '9'))) sb.Append(ch); } return sb.ToString(); } public static string FormatDataSize(ulong uBytes) { const ulong uKB = 1024; const ulong uMB = uKB * uKB; const ulong uGB = uMB * uKB; const ulong uTB = uGB * uKB; if(uBytes == 0) return "0 KB"; if(uBytes <= uKB) return "1 KB"; if(uBytes <= uMB) return (((uBytes - 1UL) / uKB) + 1UL).ToString() + " KB"; if(uBytes <= uGB) return (((uBytes - 1UL) / uMB) + 1UL).ToString() + " MB"; if(uBytes <= uTB) return (((uBytes - 1UL) / uGB) + 1UL).ToString() + " GB"; return (((uBytes - 1UL)/ uTB) + 1UL).ToString() + " TB"; } public static string FormatDataSizeKB(ulong uBytes) { const ulong uKB = 1024; if(uBytes == 0) return "0 KB"; if(uBytes <= uKB) return "1 KB"; return (((uBytes - 1UL) / uKB) + 1UL).ToString() + " KB"; } private static readonly char[] m_vVersionSep = new char[]{ '.', ',' }; public static ulong ParseVersion(string strVersion) { if(strVersion == null) { Debug.Assert(false); return 0; } string[] vVer = strVersion.Split(m_vVersionSep); if((vVer == null) || (vVer.Length == 0)) { Debug.Assert(false); return 0; } ushort uPart; StrUtil.TryParseUShort(vVer[0].Trim(), out uPart); ulong uVer = ((ulong)uPart << 48); if(vVer.Length >= 2) { StrUtil.TryParseUShort(vVer[1].Trim(), out uPart); uVer |= ((ulong)uPart << 32); } if(vVer.Length >= 3) { StrUtil.TryParseUShort(vVer[2].Trim(), out uPart); uVer |= ((ulong)uPart << 16); } if(vVer.Length >= 4) { StrUtil.TryParseUShort(vVer[3].Trim(), out uPart); uVer |= (ulong)uPart; } return uVer; } public static string VersionToString(ulong uVersion) { return VersionToString(uVersion, false); } public static string VersionToString(ulong uVersion, bool bEnsureAtLeastTwoComp) { string str = string.Empty; bool bMultiComp = false; for(int i = 0; i < 4; ++i) { ushort us = (ushort)(uVersion & 0xFFFFUL); if((us != 0) || (str.Length > 0)) { if(str.Length > 0) { str = "." + str; bMultiComp = true; } str = us.ToString(NumberFormatInfo.InvariantInfo) + str; } uVersion >>= 16; } if(bEnsureAtLeastTwoComp && !bMultiComp && (str.Length > 0)) str += ".0"; return str; } private static readonly byte[] m_pbOptEnt = { 0xA5, 0x74, 0x2E, 0xEC }; public static string EncryptString(string strPlainText) { if(string.IsNullOrEmpty(strPlainText)) return string.Empty; try { byte[] pbPlain = StrUtil.Utf8.GetBytes(strPlainText); byte[] pbEnc = ProtectedData.Protect(pbPlain, m_pbOptEnt, DataProtectionScope.CurrentUser); #if (!KeePassLibSD && !KeePassRT) return Convert.ToBase64String(pbEnc, Base64FormattingOptions.None); #else return Convert.ToBase64String(pbEnc); #endif } catch(Exception) { Debug.Assert(false); } return strPlainText; } public static string DecryptString(string strCipherText) { if(string.IsNullOrEmpty(strCipherText)) return string.Empty; try { byte[] pbEnc = Convert.FromBase64String(strCipherText); byte[] pbPlain = ProtectedData.Unprotect(pbEnc, m_pbOptEnt, DataProtectionScope.CurrentUser); return StrUtil.Utf8.GetString(pbPlain, 0, pbPlain.Length); } catch(Exception) { Debug.Assert(false); } return strCipherText; } public static string SerializeIntArray(int[] vNumbers) { if(vNumbers == null) throw new ArgumentNullException("vNumbers"); StringBuilder sb = new StringBuilder(); for(int i = 0; i < vNumbers.Length; ++i) { if(i > 0) sb.Append(' '); sb.Append(vNumbers[i].ToString(NumberFormatInfo.InvariantInfo)); } return sb.ToString(); } public static int[] DeserializeIntArray(string strSerialized) { if(strSerialized == null) throw new ArgumentNullException("strSerialized"); if(strSerialized.Length == 0) return new int[0]; string[] vParts = strSerialized.Split(' '); int[] v = new int[vParts.Length]; for(int i = 0; i < vParts.Length; ++i) { int n; if(!TryParseIntInvariant(vParts[i], out n)) { Debug.Assert(false); } v[i] = n; } return v; } private static readonly char[] m_vTagSep = new char[]{ ',', ';', ':' }; public static string TagsToString(List vTags, bool bForDisplay) { if(vTags == null) throw new ArgumentNullException("vTags"); StringBuilder sb = new StringBuilder(); bool bFirst = true; foreach(string strTag in vTags) { if(string.IsNullOrEmpty(strTag)) { Debug.Assert(false); continue; } Debug.Assert(strTag.IndexOfAny(m_vTagSep) < 0); if(!bFirst) { if(bForDisplay) sb.Append(", "); else sb.Append(';'); } sb.Append(strTag); bFirst = false; } return sb.ToString(); } public static List StringToTags(string strTags) { if(strTags == null) throw new ArgumentNullException("strTags"); List lTags = new List(); if(strTags.Length == 0) return lTags; string[] vTags = strTags.Split(m_vTagSep); foreach(string strTag in vTags) { string strFlt = strTag.Trim(); if(strFlt.Length > 0) lTags.Add(strFlt); } return lTags; } public static string Obfuscate(string strPlain) { if(strPlain == null) { Debug.Assert(false); return string.Empty; } if(strPlain.Length == 0) return string.Empty; byte[] pb = StrUtil.Utf8.GetBytes(strPlain); Array.Reverse(pb); for(int i = 0; i < pb.Length; ++i) pb[i] = (byte)(pb[i] ^ 0x65); #if (!KeePassLibSD && !KeePassRT) return Convert.ToBase64String(pb, Base64FormattingOptions.None); #else return Convert.ToBase64String(pb); #endif } public static string Deobfuscate(string strObf) { if(strObf == null) { Debug.Assert(false); return string.Empty; } if(strObf.Length == 0) return string.Empty; try { byte[] pb = Convert.FromBase64String(strObf); for(int i = 0; i < pb.Length; ++i) pb[i] = (byte)(pb[i] ^ 0x65); Array.Reverse(pb); return StrUtil.Utf8.GetString(pb, 0, pb.Length); } catch(Exception) { Debug.Assert(false); } return string.Empty; } /// /// Split a string and include the separators in the splitted array. /// /// String to split. /// Separators. /// Specifies whether separators are /// matched case-sensitively or not. /// Splitted string including separators. public static List SplitWithSep(string str, string[] vSeps, bool bCaseSensitive) { if(str == null) throw new ArgumentNullException("str"); if(vSeps == null) throw new ArgumentNullException("vSeps"); List v = new List(); while(true) { int minIndex = int.MaxValue, minSep = -1; for(int i = 0; i < vSeps.Length; ++i) { string strSep = vSeps[i]; if(string.IsNullOrEmpty(strSep)) { Debug.Assert(false); continue; } int iIndex = (bCaseSensitive ? str.IndexOf(strSep) : str.IndexOf(strSep, StrUtil.CaseIgnoreCmp)); if((iIndex >= 0) && (iIndex < minIndex)) { minIndex = iIndex; minSep = i; } } if(minIndex == int.MaxValue) break; v.Add(str.Substring(0, minIndex)); v.Add(vSeps[minSep]); str = str.Substring(minIndex + vSeps[minSep].Length); } v.Add(str); return v; } public static string MultiToSingleLine(string strMulti) { if(strMulti == null) { Debug.Assert(false); return string.Empty; } if(strMulti.Length == 0) return string.Empty; string str = strMulti; str = str.Replace("\r\n", " "); str = str.Replace("\r", " "); str = str.Replace("\n", " "); return str; } public static List SplitSearchTerms(string strSearch) { List l = new List(); if(strSearch == null) { Debug.Assert(false); return l; } StringBuilder sbTerm = new StringBuilder(); bool bQuoted = false; for(int i = 0; i < strSearch.Length; ++i) { char ch = strSearch[i]; if(((ch == ' ') || (ch == '\t') || (ch == '\r') || (ch == '\n')) && !bQuoted) { if(sbTerm.Length > 0) l.Add(sbTerm.ToString()); sbTerm.Remove(0, sbTerm.Length); } else if(ch == '\"') bQuoted = !bQuoted; else sbTerm.Append(ch); } if(sbTerm.Length > 0) l.Add(sbTerm.ToString()); return l; } public static int CompareLengthGt(string x, string y) { if(x.Length == y.Length) return 0; return ((x.Length > y.Length) ? -1 : 1); } public static bool IsDataUri(string strUri) { return IsDataUri(strUri, null); } public static bool IsDataUri(string strUri, string strReqMimeType) { if(strUri == null) { Debug.Assert(false); return false; } // strReqMimeType may be null const string strPrefix = "data:"; if(!strUri.StartsWith(strPrefix, StrUtil.CaseIgnoreCmp)) return false; int iC = strUri.IndexOf(','); if(iC < 0) return false; if(!string.IsNullOrEmpty(strReqMimeType)) { int iS = strUri.IndexOf(';', 0, iC); int iTerm = ((iS >= 0) ? iS : iC); string strMime = strUri.Substring(strPrefix.Length, iTerm - strPrefix.Length); if(!strMime.Equals(strReqMimeType, StrUtil.CaseIgnoreCmp)) return false; } return true; } /// /// Create a data URI (according to RFC 2397). /// /// Data to encode. /// Optional MIME type. If null, /// an appropriate type is used. /// Data URI. public static string DataToDataUri(byte[] pbData, string strMimeType) { if(pbData == null) throw new ArgumentNullException("pbData"); if(strMimeType == null) strMimeType = "application/octet-stream"; #if (!KeePassLibSD && !KeePassRT) return ("data:" + strMimeType + ";base64," + Convert.ToBase64String( pbData, Base64FormattingOptions.None)); #else return ("data:" + strMimeType + ";base64," + Convert.ToBase64String( pbData)); #endif } /// /// Convert a data URI (according to RFC 2397) to binary data. /// /// Data URI to decode. /// Decoded binary data. public static byte[] DataUriToData(string strDataUri) { if(strDataUri == null) throw new ArgumentNullException("strDataUri"); if(!strDataUri.StartsWith("data:", StrUtil.CaseIgnoreCmp)) return null; int iSep = strDataUri.IndexOf(','); if(iSep < 0) return null; string strDesc = strDataUri.Substring(5, iSep - 5); bool bBase64 = strDesc.EndsWith(";base64", StrUtil.CaseIgnoreCmp); string strData = strDataUri.Substring(iSep + 1); if(bBase64) return Convert.FromBase64String(strData); MemoryStream ms = new MemoryStream(); #if KeePassRT Encoding enc = StrUtil.Utf8; #else Encoding enc = Encoding.ASCII; #endif string[] v = strData.Split('%'); byte[] pb = enc.GetBytes(v[0]); ms.Write(pb, 0, pb.Length); for(int i = 1; i < v.Length; ++i) { ms.WriteByte(Convert.ToByte(v[i].Substring(0, 2), 16)); pb = enc.GetBytes(v[i].Substring(2)); ms.Write(pb, 0, pb.Length); } pb = ms.ToArray(); ms.Close(); return pb; } /// /// Remove placeholders from a string (wrapped in '{' and '}'). /// This doesn't remove environment variables (wrapped in '%'). /// public static string RemovePlaceholders(string str) { if(str == null) { Debug.Assert(false); return string.Empty; } while(true) { int iPlhStart = str.IndexOf('{'); if(iPlhStart < 0) break; int iPlhEnd = str.IndexOf('}', iPlhStart); // '{' might be at end if(iPlhEnd < 0) break; str = (str.Substring(0, iPlhStart) + str.Substring(iPlhEnd + 1)); } return str; } public static StrEncodingInfo GetEncoding(StrEncodingType t) { foreach(StrEncodingInfo sei in StrUtil.Encodings) { if(sei.Type == t) return sei; } return null; } public static StrEncodingInfo GetEncoding(string strName) { foreach(StrEncodingInfo sei in StrUtil.Encodings) { if(sei.Name == strName) return sei; } return null; } private static string[] m_vPrefSepChars = null; /// /// Find a character that does not occur within a given text. /// public static char GetUnusedChar(string strText) { if(strText == null) { Debug.Assert(false); return '@'; } if(m_vPrefSepChars == null) m_vPrefSepChars = new string[5] { "@!$%#/\\:;,.*-_?", PwCharSet.UpperCase, PwCharSet.LowerCase, PwCharSet.Digits, PwCharSet.PrintableAsciiSpecial }; for(int i = 0; i < m_vPrefSepChars.Length; ++i) { foreach(char ch in m_vPrefSepChars[i]) { if(strText.IndexOf(ch) < 0) return ch; } } for(char ch = '\u00C0'; ch < char.MaxValue; ++ch) { if(strText.IndexOf(ch) < 0) return ch; } return char.MinValue; } public static char ByteToSafeChar(byte bt) { const char chDefault = '.'; // 00-1F are C0 control chars if(bt < 0x20) return chDefault; // 20-7F are basic Latin; 7F is DEL if(bt < 0x7F) return (char)bt; // 80-9F are C1 control chars if(bt < 0xA0) return chDefault; // A0-FF are Latin-1 supplement; AD is soft hyphen if(bt == 0xAD) return '-'; return (char)bt; } public static int Count(string str, string strNeedle) { if(str == null) { Debug.Assert(false); return 0; } if(string.IsNullOrEmpty(strNeedle)) { Debug.Assert(false); return 0; } int iOffset = 0, iCount = 0; while(iOffset < str.Length) { int p = str.IndexOf(strNeedle, iOffset); if(p < 0) break; ++iCount; iOffset = p + 1; } return iCount; } } } keepass2-2.25/KeePassLib/PwCustomIcon.cs0000664000175000017500000000421212261553104020014 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; using System.Drawing; using System.IO; using KeePassLib.Utility; namespace KeePassLib { /// /// Custom icon. PwCustomIcon objects are immutable. /// public sealed class PwCustomIcon { private PwUuid m_pwUuid; private byte[] m_pbImageDataPng; private Image m_pCachedImage; public PwUuid Uuid { get { return m_pwUuid; } } public byte[] ImageDataPng { get { return m_pbImageDataPng; } } public Image Image { get { return m_pCachedImage; } } public PwCustomIcon(PwUuid pwUuid, byte[] pbImageDataPng) { Debug.Assert(pwUuid != null); if(pwUuid == null) throw new ArgumentNullException("pwUuid"); Debug.Assert(!pwUuid.Equals(PwUuid.Zero)); if(pwUuid.Equals(PwUuid.Zero)) throw new ArgumentException("pwUuid == 0"); Debug.Assert(pbImageDataPng != null); if(pbImageDataPng == null) throw new ArgumentNullException("pbImageDataPng"); m_pwUuid = pwUuid; m_pbImageDataPng = pbImageDataPng; #if !KeePassLibSD // MemoryStream ms = new MemoryStream(m_pbImageDataPng, false); // m_pCachedImage = Image.FromStream(ms); // ms.Close(); m_pCachedImage = GfxUtil.LoadImage(m_pbImageDataPng); #else m_pCachedImage = null; #endif } } } keepass2-2.25/KeePassLib/PwGroup.cs0000664000175000017500000013002512273412536017035 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using System.Text.RegularExpressions; using KeePassLib.Collections; using KeePassLib.Delegates; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePassLib { /// /// A group containing several password entries. /// public sealed class PwGroup : ITimeLogger, IStructureItem, IDeepCloneable { public const bool DefaultAutoTypeEnabled = true; public const bool DefaultSearchingEnabled = true; private PwObjectList m_listGroups = new PwObjectList(); private PwObjectList m_listEntries = new PwObjectList(); private PwGroup m_pParentGroup = null; private DateTime m_tParentGroupLastMod = PwDefs.DtDefaultNow; private PwUuid m_uuid = PwUuid.Zero; private string m_strName = string.Empty; private string m_strNotes = string.Empty; private PwIcon m_pwIcon = PwIcon.Folder; private PwUuid m_pwCustomIconID = PwUuid.Zero; private DateTime m_tCreation = PwDefs.DtDefaultNow; private DateTime m_tLastMod = PwDefs.DtDefaultNow; private DateTime m_tLastAccess = PwDefs.DtDefaultNow; private DateTime m_tExpire = PwDefs.DtDefaultNow; private bool m_bExpires = false; private ulong m_uUsageCount = 0; private bool m_bIsExpanded = true; private bool m_bVirtual = false; private string m_strDefaultAutoTypeSequence = string.Empty; private bool? m_bEnableAutoType = null; private bool? m_bEnableSearching = null; private PwUuid m_pwLastTopVisibleEntry = PwUuid.Zero; /// /// UUID of this group. /// public PwUuid Uuid { get { return m_uuid; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_uuid = value; } } /// /// The name of this group. Cannot be null. /// public string Name { get { return m_strName; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_strName = value; } } /// /// Comments about this group. Cannot be null. /// public string Notes { get { return m_strNotes; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_strNotes = value; } } /// /// Icon of the group. /// public PwIcon IconId { get { return m_pwIcon; } set { m_pwIcon = value; } } /// /// Get the custom icon ID. This value is 0, if no custom icon is /// being used (i.e. the icon specified by the IconID property /// should be displayed). /// public PwUuid CustomIconUuid { get { return m_pwCustomIconID; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_pwCustomIconID = value; } } /// /// Reference to the group to which this group belongs. May be null. /// public PwGroup ParentGroup { get { return m_pParentGroup; } // Plugins: use PwGroup.AddGroup instead. internal set { Debug.Assert(value != this); m_pParentGroup = value; } } /// /// The date/time when the location of the object was last changed. /// public DateTime LocationChanged { get { return m_tParentGroupLastMod; } set { m_tParentGroupLastMod = value; } } /// /// A flag that specifies if the group is shown as expanded or /// collapsed in the user interface. /// public bool IsExpanded { get { return m_bIsExpanded; } set { m_bIsExpanded = value; } } /// /// The date/time when this group was created. /// public DateTime CreationTime { get { return m_tCreation; } set { m_tCreation = value; } } /// /// The date/time when this group was last modified. /// public DateTime LastModificationTime { get { return m_tLastMod; } set { m_tLastMod = value; } } /// /// The date/time when this group was last accessed (read). /// public DateTime LastAccessTime { get { return m_tLastAccess; } set { m_tLastAccess = value; } } /// /// The date/time when this group expires. /// public DateTime ExpiryTime { get { return m_tExpire; } set { m_tExpire = value; } } /// /// Flag that determines if the group expires. /// public bool Expires { get { return m_bExpires; } set { m_bExpires = value; } } /// /// Get or set the usage count of the group. To increase the usage /// count by one, use the Touch function. /// public ulong UsageCount { get { return m_uUsageCount; } set { m_uUsageCount = value; } } /// /// Get a list of subgroups in this group. /// public PwObjectList Groups { get { return m_listGroups; } } /// /// Get a list of entries in this group. /// public PwObjectList Entries { get { return m_listEntries; } } /// /// A flag specifying whether this group is virtual or not. Virtual /// groups can contain links to entries stored in other groups. /// Note that this flag has to be interpreted and set by the calling /// code; it won't prevent you from accessing and modifying the list /// of entries in this group in any way. /// public bool IsVirtual { get { return m_bVirtual; } set { m_bVirtual = value; } } /// /// Default auto-type keystroke sequence for all entries in /// this group. This property can be an empty string, which /// means that the value should be inherited from the parent. /// public string DefaultAutoTypeSequence { get { return m_strDefaultAutoTypeSequence; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_strDefaultAutoTypeSequence = value; } } public bool? EnableAutoType { get { return m_bEnableAutoType; } set { m_bEnableAutoType = value; } } public bool? EnableSearching { get { return m_bEnableSearching; } set { m_bEnableSearching = value; } } public PwUuid LastTopVisibleEntry { get { return m_pwLastTopVisibleEntry; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_pwLastTopVisibleEntry = value; } } public static EventHandler GroupTouched; public EventHandler Touched; /// /// Construct a new, empty group. /// public PwGroup() { } /// /// Construct a new, empty group. /// /// Create a new UUID for this group. /// Set creation, last access and last modification times to the current time. public PwGroup(bool bCreateNewUuid, bool bSetTimes) { if(bCreateNewUuid) m_uuid = new PwUuid(true); if(bSetTimes) { m_tCreation = m_tLastMod = m_tLastAccess = m_tParentGroupLastMod = DateTime.Now; } } /// /// Construct a new group. /// /// Create a new UUID for this group. /// Set creation, last access and last modification times to the current time. /// Name of the new group. /// Icon of the new group. public PwGroup(bool bCreateNewUuid, bool bSetTimes, string strName, PwIcon pwIcon) { if(bCreateNewUuid) m_uuid = new PwUuid(true); if(bSetTimes) { m_tCreation = m_tLastMod = m_tLastAccess = m_tParentGroupLastMod = DateTime.Now; } if(strName != null) m_strName = strName; m_pwIcon = pwIcon; } /// /// Deeply clone the current group. The returned group will be an exact /// value copy of the current object (including UUID, etc.). /// /// Exact value copy of the current PwGroup object. public PwGroup CloneDeep() { PwGroup pg = new PwGroup(false, false); pg.m_uuid = m_uuid; // PwUuid is immutable pg.m_listGroups = m_listGroups.CloneDeep(); pg.m_listEntries = m_listEntries.CloneDeep(); pg.m_pParentGroup = m_pParentGroup; pg.m_tParentGroupLastMod = m_tParentGroupLastMod; pg.m_strName = m_strName; pg.m_strNotes = m_strNotes; pg.m_pwIcon = m_pwIcon; pg.m_pwCustomIconID = m_pwCustomIconID; pg.m_tCreation = m_tCreation; pg.m_tLastMod = m_tLastMod; pg.m_tLastAccess = m_tLastAccess; pg.m_tExpire = m_tExpire; pg.m_bExpires = m_bExpires; pg.m_uUsageCount = m_uUsageCount; pg.m_bIsExpanded = m_bIsExpanded; pg.m_bVirtual = m_bVirtual; pg.m_strDefaultAutoTypeSequence = m_strDefaultAutoTypeSequence; pg.m_pwLastTopVisibleEntry = m_pwLastTopVisibleEntry; return pg; } public PwGroup CloneStructure() { PwGroup pg = new PwGroup(false, false); pg.m_uuid = m_uuid; // PwUuid is immutable pg.m_tParentGroupLastMod = m_tParentGroupLastMod; // Do not assign m_pParentGroup foreach(PwGroup pgSub in m_listGroups) pg.AddGroup(pgSub.CloneStructure(), true); foreach(PwEntry peSub in m_listEntries) pg.AddEntry(peSub.CloneStructure(), true); return pg; } public bool EqualsGroup(PwGroup pg, PwCompareOptions pwOpt, MemProtCmpMode mpCmpStr) { if(pg == null) { Debug.Assert(false); return false; } bool bIgnoreLastAccess = ((pwOpt & PwCompareOptions.IgnoreLastAccess) != PwCompareOptions.None); bool bIgnoreLastMod = ((pwOpt & PwCompareOptions.IgnoreLastMod) != PwCompareOptions.None); if(!m_uuid.Equals(pg.m_uuid)) return false; if((pwOpt & PwCompareOptions.IgnoreParentGroup) == PwCompareOptions.None) { if(m_pParentGroup != pg.m_pParentGroup) return false; if(!bIgnoreLastMod && (m_tParentGroupLastMod != pg.m_tParentGroupLastMod)) return false; } if(m_strName != pg.m_strName) return false; if(m_strNotes != pg.m_strNotes) return false; if(m_pwIcon != pg.m_pwIcon) return false; if(!m_pwCustomIconID.Equals(pg.m_pwCustomIconID)) return false; if(m_tCreation != pg.m_tCreation) return false; if(!bIgnoreLastMod && (m_tLastMod != pg.m_tLastMod)) return false; if(!bIgnoreLastAccess && (m_tLastAccess != pg.m_tLastAccess)) return false; if(m_tExpire != pg.m_tExpire) return false; if(m_bExpires != pg.m_bExpires) return false; if(!bIgnoreLastAccess && (m_uUsageCount != pg.m_uUsageCount)) return false; // if(m_bIsExpanded != pg.m_bIsExpanded) return false; if(m_strDefaultAutoTypeSequence != pg.m_strDefaultAutoTypeSequence) return false; if(!m_pwLastTopVisibleEntry.Equals(pg.m_pwLastTopVisibleEntry)) return false; if((pwOpt & PwCompareOptions.PropertiesOnly) == PwCompareOptions.None) { if(m_listEntries.UCount != pg.m_listEntries.UCount) return false; for(uint u = 0; u < m_listEntries.UCount; ++u) { PwEntry peA = m_listEntries.GetAt(u); PwEntry peB = pg.m_listEntries.GetAt(u); if(!peA.EqualsEntry(peB, pwOpt, mpCmpStr)) return false; } if(m_listGroups.UCount != pg.m_listGroups.UCount) return false; for(uint u = 0; u < m_listGroups.UCount; ++u) { PwGroup pgA = m_listGroups.GetAt(u); PwGroup pgB = pg.m_listGroups.GetAt(u); if(!pgA.EqualsGroup(pgB, pwOpt, mpCmpStr)) return false; } } return true; } /// /// Assign properties to the current group based on a template group. /// /// Template group. Must not be null. /// Only set the properties of the template group /// if it is newer than the current one. /// If true, the /// LocationChanged property is copied, otherwise not. public void AssignProperties(PwGroup pgTemplate, bool bOnlyIfNewer, bool bAssignLocationChanged) { Debug.Assert(pgTemplate != null); if(pgTemplate == null) throw new ArgumentNullException("pgTemplate"); if(bOnlyIfNewer && (TimeUtil.Compare(pgTemplate.m_tLastMod, m_tLastMod, true) < 0)) return; // Template UUID should be the same as the current one Debug.Assert(m_uuid.Equals(pgTemplate.m_uuid)); m_uuid = pgTemplate.m_uuid; if(bAssignLocationChanged) m_tParentGroupLastMod = pgTemplate.m_tParentGroupLastMod; m_strName = pgTemplate.m_strName; m_strNotes = pgTemplate.m_strNotes; m_pwIcon = pgTemplate.m_pwIcon; m_pwCustomIconID = pgTemplate.m_pwCustomIconID; m_tCreation = pgTemplate.m_tCreation; m_tLastMod = pgTemplate.m_tLastMod; m_tLastAccess = pgTemplate.m_tLastAccess; m_tExpire = pgTemplate.m_tExpire; m_bExpires = pgTemplate.m_bExpires; m_uUsageCount = pgTemplate.m_uUsageCount; m_strDefaultAutoTypeSequence = pgTemplate.m_strDefaultAutoTypeSequence; m_pwLastTopVisibleEntry = pgTemplate.m_pwLastTopVisibleEntry; } /// /// Touch the group. This function updates the internal last access /// time. If the parameter is true, /// the last modification time gets updated, too. /// /// Modify last modification time. public void Touch(bool bModified) { Touch(bModified, true); } /// /// Touch the group. This function updates the internal last access /// time. If the parameter is true, /// the last modification time gets updated, too. /// /// Modify last modification time. /// If true, all parent objects /// get touched, too. public void Touch(bool bModified, bool bTouchParents) { m_tLastAccess = DateTime.Now; ++m_uUsageCount; if(bModified) m_tLastMod = m_tLastAccess; if(this.Touched != null) this.Touched(this, new ObjectTouchedEventArgs(this, bModified, bTouchParents)); if(PwGroup.GroupTouched != null) PwGroup.GroupTouched(this, new ObjectTouchedEventArgs(this, bModified, bTouchParents)); if(bTouchParents && (m_pParentGroup != null)) m_pParentGroup.Touch(bModified, true); } /// /// Get number of groups and entries in the current group. This function /// can also traverse through all subgroups and accumulate their counts /// (recursive mode). /// /// If this parameter is true, all /// subgroups and entries in subgroups will be counted and added to /// the returned value. If it is false, only the number of /// subgroups and entries of the current group is returned. /// Number of subgroups. /// Number of entries. public void GetCounts(bool bRecursive, out uint uNumGroups, out uint uNumEntries) { if(bRecursive) { uint uTotalGroups = m_listGroups.UCount; uint uTotalEntries = m_listEntries.UCount; uint uSubGroupCount, uSubEntryCount; foreach(PwGroup pg in m_listGroups) { pg.GetCounts(true, out uSubGroupCount, out uSubEntryCount); uTotalGroups += uSubGroupCount; uTotalEntries += uSubEntryCount; } uNumGroups = uTotalGroups; uNumEntries = uTotalEntries; } else // !bRecursive { uNumGroups = m_listGroups.UCount; uNumEntries = m_listEntries.UCount; } } public uint GetEntriesCount(bool bRecursive) { uint uGroups, uEntries; GetCounts(bRecursive, out uGroups, out uEntries); return uEntries; } /// /// Traverse the group/entry tree in the current group. Various traversal /// methods are available. /// /// Specifies the traversal method. /// Function that performs an action on /// the currently visited group (see GroupHandler for more). /// This parameter may be null, in this case the tree is traversed but /// you don't get notifications for each visited group. /// Function that performs an action on /// the currently visited entry (see EntryHandler for more). /// This parameter may be null. /// Returns true if all entries and groups have been /// traversed. If the traversal has been canceled by one of the two /// handlers, the return value is false. public bool TraverseTree(TraversalMethod tm, GroupHandler groupHandler, EntryHandler entryHandler) { bool bRet = false; switch(tm) { case TraversalMethod.None: bRet = true; break; case TraversalMethod.PreOrder: bRet = PreOrderTraverseTree(groupHandler, entryHandler); break; default: Debug.Assert(false); break; } return bRet; } private bool PreOrderTraverseTree(GroupHandler groupHandler, EntryHandler entryHandler) { if(entryHandler != null) { foreach(PwEntry pe in m_listEntries) { if(!entryHandler(pe)) return false; } } if(groupHandler != null) { foreach(PwGroup pg in m_listGroups) { if(!groupHandler(pg)) return false; pg.PreOrderTraverseTree(groupHandler, entryHandler); } } else // groupHandler == null { foreach(PwGroup pg in m_listGroups) { pg.PreOrderTraverseTree(null, entryHandler); } } return true; } /// /// Pack all groups into one flat linked list of references (recursively). /// Temporary IDs (TemporaryID field) and levels (TemporaryLevel) /// are assigned automatically. /// /// Flat list of all groups. public LinkedList GetFlatGroupList() { LinkedList list = new LinkedList(); foreach(PwGroup pg in m_listGroups) { list.AddLast(pg); if(pg.Groups.UCount != 0) LinearizeGroupRecursive(list, pg, 1); } return list; } private void LinearizeGroupRecursive(LinkedList list, PwGroup pg, ushort uLevel) { Debug.Assert(pg != null); if(pg == null) return; foreach(PwGroup pwg in pg.Groups) { list.AddLast(pwg); if(pwg.Groups.UCount != 0) LinearizeGroupRecursive(list, pwg, (ushort)(uLevel + 1)); } } /// /// Pack all entries into one flat linked list of references. Temporary /// group IDs are assigned automatically. /// /// A flat group list created by /// GetFlatGroupList. /// Flat list of all entries. public static LinkedList GetFlatEntryList(LinkedList flatGroupList) { Debug.Assert(flatGroupList != null); if(flatGroupList == null) return null; LinkedList list = new LinkedList(); foreach(PwGroup pg in flatGroupList) { foreach(PwEntry pe in pg.Entries) list.AddLast(pe); } return list; } /// /// Enable protection of a specific string field type. /// /// Name of the string field to protect or unprotect. /// Enable protection or not. /// Returns true, if the operation completed successfully, /// otherwise false. public bool EnableStringFieldProtection(string strFieldName, bool bEnable) { Debug.Assert(strFieldName != null); EntryHandler eh = delegate(PwEntry pe) { // Enable protection of current string pe.Strings.EnableProtection(strFieldName, bEnable); // Do the same for all history items foreach(PwEntry peHistory in pe.History) { peHistory.Strings.EnableProtection(strFieldName, bEnable); } return true; }; return PreOrderTraverseTree(null, eh); } /// /// Search this group and all subgroups for entries. /// /// Specifies the search method. /// Entry list in which the search results will /// be stored. public void SearchEntries(SearchParameters sp, PwObjectList listStorage) { SearchEntries(sp, listStorage, null); } /// /// Search this group and all subgroups for entries. /// /// Specifies the search method. /// Entry list in which the search results will /// be stored. public void SearchEntries(SearchParameters sp, PwObjectList listStorage, IStatusLogger slStatus) { if(sp == null) { Debug.Assert(false); return; } if(listStorage == null) { Debug.Assert(false); return; } ulong uCurEntries = 0, uTotalEntries = 0; List lTerms = StrUtil.SplitSearchTerms(sp.SearchString); if((lTerms.Count <= 1) || sp.RegularExpression) { if(slStatus != null) uTotalEntries = GetEntriesCount(true); SearchEntriesSingle(sp, listStorage, slStatus, ref uCurEntries, uTotalEntries); return; } // Search longer strings first (for improved performance) lTerms.Sort(StrUtil.CompareLengthGt); string strFullSearch = sp.SearchString; // Backup PwGroup pg = this; for(int iTerm = 0; iTerm < lTerms.Count; ++iTerm) { // Update counters for a better state guess if(slStatus != null) { ulong uRemRounds = (ulong)(lTerms.Count - iTerm); uTotalEntries = uCurEntries + (uRemRounds * pg.GetEntriesCount(true)); } PwGroup pgNew = new PwGroup(); sp.SearchString = lTerms[iTerm]; bool bNegate = false; if(sp.SearchString.StartsWith("-")) { sp.SearchString = sp.SearchString.Substring(1); bNegate = (sp.SearchString.Length > 0); } if(!pg.SearchEntriesSingle(sp, pgNew.Entries, slStatus, ref uCurEntries, uTotalEntries)) { pg = null; break; } if(bNegate) { PwObjectList lCand = pg.GetEntries(true); pg = new PwGroup(); foreach(PwEntry peCand in lCand) { if(pgNew.Entries.IndexOf(peCand) < 0) pg.Entries.Add(peCand); } } else pg = pgNew; } if(pg != null) listStorage.Add(pg.Entries); sp.SearchString = strFullSearch; // Restore } private bool SearchEntriesSingle(SearchParameters spIn, PwObjectList listStorage, IStatusLogger slStatus, ref ulong uCurEntries, ulong uTotalEntries) { SearchParameters sp = spIn.Clone(); if(sp.SearchString == null) { Debug.Assert(false); return true; } sp.SearchString = sp.SearchString.Trim(); bool bTitle = sp.SearchInTitles; bool bUserName = sp.SearchInUserNames; bool bPassword = sp.SearchInPasswords; bool bUrl = sp.SearchInUrls; bool bNotes = sp.SearchInNotes; bool bOther = sp.SearchInOther; bool bUuids = sp.SearchInUuids; bool bGroupName = sp.SearchInGroupNames; bool bTags = sp.SearchInTags; bool bExcludeExpired = sp.ExcludeExpired; bool bRespectEntrySearchingDisabled = sp.RespectEntrySearchingDisabled; DateTime dtNow = DateTime.Now; Regex rx = null; if(sp.RegularExpression) { #if KeePassRT RegexOptions ro = RegexOptions.None; #else RegexOptions ro = RegexOptions.Compiled; #endif if((sp.ComparisonMode == StringComparison.CurrentCultureIgnoreCase) || #if !KeePassRT (sp.ComparisonMode == StringComparison.InvariantCultureIgnoreCase) || #endif (sp.ComparisonMode == StringComparison.OrdinalIgnoreCase)) { ro |= RegexOptions.IgnoreCase; } rx = new Regex(sp.SearchString, ro); } ulong uLocalCurEntries = uCurEntries; EntryHandler eh = null; if(sp.SearchString.Length <= 0) // Report all { eh = delegate(PwEntry pe) { if(slStatus != null) { if(!slStatus.SetProgress((uint)((uLocalCurEntries * 100UL) / uTotalEntries))) return false; ++uLocalCurEntries; } if(bRespectEntrySearchingDisabled && !pe.GetSearchingEnabled()) return true; // Skip if(bExcludeExpired && pe.Expires && (dtNow > pe.ExpiryTime)) return true; // Skip listStorage.Add(pe); return true; }; } else { eh = delegate(PwEntry pe) { if(slStatus != null) { if(!slStatus.SetProgress((uint)((uLocalCurEntries * 100UL) / uTotalEntries))) return false; ++uLocalCurEntries; } if(bRespectEntrySearchingDisabled && !pe.GetSearchingEnabled()) return true; // Skip if(bExcludeExpired && pe.Expires && (dtNow > pe.ExpiryTime)) return true; // Skip uint uInitialResults = listStorage.UCount; foreach(KeyValuePair kvp in pe.Strings) { string strKey = kvp.Key; if(strKey == PwDefs.TitleField) { if(bTitle) SearchEvalAdd(sp, kvp.Value.ReadString(), rx, pe, listStorage); } else if(strKey == PwDefs.UserNameField) { if(bUserName) SearchEvalAdd(sp, kvp.Value.ReadString(), rx, pe, listStorage); } else if(strKey == PwDefs.PasswordField) { if(bPassword) SearchEvalAdd(sp, kvp.Value.ReadString(), rx, pe, listStorage); } else if(strKey == PwDefs.UrlField) { if(bUrl) SearchEvalAdd(sp, kvp.Value.ReadString(), rx, pe, listStorage); } else if(strKey == PwDefs.NotesField) { if(bNotes) SearchEvalAdd(sp, kvp.Value.ReadString(), rx, pe, listStorage); } else if(bOther) SearchEvalAdd(sp, kvp.Value.ReadString(), rx, pe, listStorage); // An entry can match only once => break if we have added it if(listStorage.UCount > uInitialResults) break; } if(bUuids && (listStorage.UCount == uInitialResults)) SearchEvalAdd(sp, pe.Uuid.ToHexString(), rx, pe, listStorage); if(bGroupName && (listStorage.UCount == uInitialResults) && (pe.ParentGroup != null)) SearchEvalAdd(sp, pe.ParentGroup.Name, rx, pe, listStorage); if(bTags) { foreach(string strTag in pe.Tags) { if(listStorage.UCount != uInitialResults) break; // Match SearchEvalAdd(sp, strTag, rx, pe, listStorage); } } return true; }; } if(!PreOrderTraverseTree(null, eh)) return false; uCurEntries = uLocalCurEntries; return true; } private static void SearchEvalAdd(SearchParameters sp, string strDataField, Regex rx, PwEntry pe, PwObjectList lResults) { bool bMatch = false; if(rx == null) bMatch = (strDataField.IndexOf(sp.SearchString, sp.ComparisonMode) >= 0); else bMatch = rx.IsMatch(strDataField); if(!bMatch && (sp.DataTransformationFn != null)) { string strCmp = sp.DataTransformationFn(strDataField, pe); if(!object.ReferenceEquals(strCmp, strDataField)) { if(rx == null) bMatch = (strCmp.IndexOf(sp.SearchString, sp.ComparisonMode) >= 0); else bMatch = rx.IsMatch(strCmp); } } if(bMatch) lResults.Add(pe); } public List BuildEntryTagsList() { return BuildEntryTagsList(false); } public List BuildEntryTagsList(bool bSort) { List vTags = new List(); EntryHandler eh = delegate(PwEntry pe) { foreach(string strTag in pe.Tags) { bool bFound = false; for(int i = 0; i < vTags.Count; ++i) { if(vTags[i].Equals(strTag, StrUtil.CaseIgnoreCmp)) { bFound = true; break; } } if(!bFound) vTags.Add(strTag); } return true; }; TraverseTree(TraversalMethod.PreOrder, null, eh); if(bSort) vTags.Sort(StrUtil.CaseIgnoreComparer); return vTags; } #if !KeePassLibSD public IDictionary BuildEntryTagsDict(bool bSort) { IDictionary d; if(!bSort) d = new Dictionary(StrUtil.CaseIgnoreComparer); else d = new SortedDictionary(StrUtil.CaseIgnoreComparer); EntryHandler eh = delegate(PwEntry pe) { foreach(string strTag in pe.Tags) { uint u; if(d.TryGetValue(strTag, out u)) d[strTag] = u + 1; else d[strTag] = 1; } return true; }; TraverseTree(TraversalMethod.PreOrder, null, eh); return d; } #endif public void FindEntriesByTag(string strTag, PwObjectList listStorage, bool bSearchRecursive) { if(strTag == null) throw new ArgumentNullException("strTag"); if(strTag.Length == 0) return; foreach(PwEntry pe in m_listEntries) { foreach(string strEntryTag in pe.Tags) { if(strEntryTag.Equals(strTag, StrUtil.CaseIgnoreCmp)) { listStorage.Add(pe); break; } } } if(bSearchRecursive) { foreach(PwGroup pg in m_listGroups) pg.FindEntriesByTag(strTag, listStorage, true); } } /// /// Find a group. /// /// UUID identifying the group the caller is looking for. /// If true, the search is recursive. /// Returns reference to found group, otherwise null. public PwGroup FindGroup(PwUuid uuid, bool bSearchRecursive) { // Do not assert on PwUuid.Zero if(m_uuid.Equals(uuid)) return this; if(bSearchRecursive) { PwGroup pgRec; foreach(PwGroup pg in m_listGroups) { pgRec = pg.FindGroup(uuid, true); if(pgRec != null) return pgRec; } } else // Not recursive { foreach(PwGroup pg in m_listGroups) { if(pg.m_uuid.Equals(uuid)) return pg; } } return null; } /// /// Find an object. /// /// UUID of the object to find. /// Specifies whether to search recursively. /// If null, groups and entries are /// searched. If true, only entries are searched. If false, /// only groups are searched. /// Reference to the object, if found. Otherwise null. public IStructureItem FindObject(PwUuid uuid, bool bRecursive, bool? bEntries) { if(bEntries.HasValue) { if(bEntries.Value) return FindEntry(uuid, bRecursive); else return FindGroup(uuid, bRecursive); } PwGroup pg = FindGroup(uuid, bRecursive); if(pg != null) return pg; return FindEntry(uuid, bRecursive); } /// /// Try to find a subgroup and create it, if it doesn't exist yet. /// /// Name of the subgroup. /// If the group isn't found: create it. /// Returns a reference to the requested group or null if /// it doesn't exist and shouldn't be created. public PwGroup FindCreateGroup(string strName, bool bCreateIfNotFound) { Debug.Assert(strName != null); if(strName == null) throw new ArgumentNullException("strName"); foreach(PwGroup pg in m_listGroups) { if(pg.Name == strName) return pg; } if(!bCreateIfNotFound) return null; PwGroup pgNew = new PwGroup(true, true, strName, PwIcon.Folder); AddGroup(pgNew, true); return pgNew; } /// /// Find an entry. /// /// UUID identifying the entry the caller is looking for. /// If true, the search is recursive. /// Returns reference to found entry, otherwise null. public PwEntry FindEntry(PwUuid uuid, bool bSearchRecursive) { foreach(PwEntry pe in m_listEntries) { if(pe.Uuid.Equals(uuid)) return pe; } if(bSearchRecursive) { PwEntry peSub; foreach(PwGroup pg in m_listGroups) { peSub = pg.FindEntry(uuid, true); if(peSub != null) return peSub; } } return null; } /// /// Get the full path of a group. /// /// Full path of the group. public string GetFullPath() { return GetFullPath(".", false); } /// /// Get the full path of a group. /// /// String that separates the group /// names. /// Full path of the group. public string GetFullPath(string strSeparator, bool bIncludeTopMostGroup) { Debug.Assert(strSeparator != null); if(strSeparator == null) throw new ArgumentNullException("strSeparator"); string strPath = m_strName; PwGroup pg = m_pParentGroup; while(pg != null) { if((!bIncludeTopMostGroup) && (pg.m_pParentGroup == null)) break; strPath = pg.Name + strSeparator + strPath; pg = pg.m_pParentGroup; } return strPath; } /// /// Assign new UUIDs to groups and entries. /// /// Create new UUIDs for subgroups. /// Create new UUIDs for entries. /// Recursive tree traversal. public void CreateNewItemUuids(bool bNewGroups, bool bNewEntries, bool bRecursive) { if(bNewGroups) { foreach(PwGroup pg in m_listGroups) pg.Uuid = new PwUuid(true); } if(bNewEntries) { foreach(PwEntry pe in m_listEntries) pe.SetUuid(new PwUuid(true), true); } if(bRecursive) { foreach(PwGroup pg in m_listGroups) pg.CreateNewItemUuids(bNewGroups, bNewEntries, true); } } public void TakeOwnership(bool bTakeSubGroups, bool bTakeEntries, bool bRecursive) { if(bTakeSubGroups) { foreach(PwGroup pg in m_listGroups) pg.ParentGroup = this; } if(bTakeEntries) { foreach(PwEntry pe in m_listEntries) pe.ParentGroup = this; } if(bRecursive) { foreach(PwGroup pg in m_listGroups) pg.TakeOwnership(bTakeSubGroups, bTakeEntries, true); } } #if !KeePassLibSD /// /// Find/create a subtree of groups. /// /// Tree string. /// Separators that delimit groups in the /// strTree parameter. public PwGroup FindCreateSubTree(string strTree, char[] vSeparators) { return FindCreateSubTree(strTree, vSeparators, true); } public PwGroup FindCreateSubTree(string strTree, char[] vSeparators, bool bAllowCreate) { if(vSeparators == null) { Debug.Assert(false); vSeparators = new char[0]; } string[] v = new string[vSeparators.Length]; for(int i = 0; i < vSeparators.Length; ++i) v[i] = new string(vSeparators[i], 1); return FindCreateSubTree(strTree, v, bAllowCreate); } public PwGroup FindCreateSubTree(string strTree, string[] vSeparators, bool bAllowCreate) { Debug.Assert(strTree != null); if(strTree == null) return this; if(strTree.Length == 0) return this; string[] vGroups = strTree.Split(vSeparators, StringSplitOptions.None); if((vGroups == null) || (vGroups.Length == 0)) return this; PwGroup pgContainer = this; for(int nGroup = 0; nGroup < vGroups.Length; ++nGroup) { if(string.IsNullOrEmpty(vGroups[nGroup])) continue; bool bFound = false; foreach(PwGroup pg in pgContainer.Groups) { if(pg.Name == vGroups[nGroup]) { pgContainer = pg; bFound = true; break; } } if(!bFound) { if(!bAllowCreate) return null; PwGroup pg = new PwGroup(true, true, vGroups[nGroup], PwIcon.Folder); pgContainer.AddGroup(pg, true); pgContainer = pg; } } return pgContainer; } #endif /// /// Get the level of the group (i.e. the number of parent groups). /// /// Number of parent groups. public uint GetLevel() { PwGroup pg = m_pParentGroup; uint uLevel = 0; while(pg != null) { pg = pg.ParentGroup; ++uLevel; } return uLevel; } public string GetAutoTypeSequenceInherited() { if(m_strDefaultAutoTypeSequence.Length > 0) return m_strDefaultAutoTypeSequence; if(m_pParentGroup != null) return m_pParentGroup.GetAutoTypeSequenceInherited(); return string.Empty; } public bool GetAutoTypeEnabledInherited() { if(m_bEnableAutoType.HasValue) return m_bEnableAutoType.Value; if(m_pParentGroup != null) return m_pParentGroup.GetAutoTypeEnabledInherited(); return DefaultAutoTypeEnabled; } public bool GetSearchingEnabledInherited() { if(m_bEnableSearching.HasValue) return m_bEnableSearching.Value; if(m_pParentGroup != null) return m_pParentGroup.GetSearchingEnabledInherited(); return DefaultSearchingEnabled; } /// /// Get a list of subgroups (not including this one). /// /// If true, subgroups are added /// recursively, i.e. all child groups are returned, too. /// List of subgroups. If is /// true, it is guaranteed that subsubgroups appear after /// subgroups. public PwObjectList GetGroups(bool bRecursive) { if(bRecursive == false) return m_listGroups; PwObjectList list = m_listGroups.CloneShallow(); foreach(PwGroup pgSub in m_listGroups) { list.Add(pgSub.GetGroups(true)); } return list; } public PwObjectList GetEntries(bool bIncludeSubGroupEntries) { if(bIncludeSubGroupEntries == false) return m_listEntries; PwObjectList list = m_listEntries.CloneShallow(); foreach(PwGroup pgSub in m_listGroups) { list.Add(pgSub.GetEntries(true)); } return list; } /// /// Get objects contained in this group. /// /// Specifies whether to search recursively. /// If null, the returned list contains /// groups and entries. If true, the returned list contains only /// entries. If false, the returned list contains only groups. /// List of objects. public List GetObjects(bool bRecursive, bool? bEntries) { List list = new List(); if(!bEntries.HasValue || !bEntries.Value) { PwObjectList lGroups = GetGroups(bRecursive); foreach(PwGroup pg in lGroups) list.Add(pg); } if(!bEntries.HasValue || bEntries.Value) { PwObjectList lEntries = GetEntries(bRecursive); foreach(PwEntry pe in lEntries) list.Add(pe); } return list; } public bool IsContainedIn(PwGroup pgContainer) { PwGroup pgCur = m_pParentGroup; while(pgCur != null) { if(pgCur == pgContainer) return true; pgCur = pgCur.m_pParentGroup; } return false; } /// /// Add a subgroup to this group. /// /// Group to be added. Must not be null. /// If this parameter is true, the /// parent group reference of the subgroup will be set to the current /// group (i.e. the current group takes ownership of the subgroup). public void AddGroup(PwGroup subGroup, bool bTakeOwnership) { AddGroup(subGroup, bTakeOwnership, false); } /// /// Add a subgroup to this group. /// /// Group to be added. Must not be null. /// If this parameter is true, the /// parent group reference of the subgroup will be set to the current /// group (i.e. the current group takes ownership of the subgroup). /// If true, the /// LocationChanged property of the subgroup is updated. public void AddGroup(PwGroup subGroup, bool bTakeOwnership, bool bUpdateLocationChangedOfSub) { if(subGroup == null) throw new ArgumentNullException("subGroup"); m_listGroups.Add(subGroup); if(bTakeOwnership) subGroup.m_pParentGroup = this; if(bUpdateLocationChangedOfSub) subGroup.LocationChanged = DateTime.Now; } /// /// Add an entry to this group. /// /// Entry to be added. Must not be null. /// If this parameter is true, the /// parent group reference of the entry will be set to the current /// group (i.e. the current group takes ownership of the entry). public void AddEntry(PwEntry pe, bool bTakeOwnership) { AddEntry(pe, bTakeOwnership, false); } /// /// Add an entry to this group. /// /// Entry to be added. Must not be null. /// If this parameter is true, the /// parent group reference of the entry will be set to the current /// group (i.e. the current group takes ownership of the entry). /// If true, the /// LocationChanged property of the entry is updated. public void AddEntry(PwEntry pe, bool bTakeOwnership, bool bUpdateLocationChangedOfEntry) { if(pe == null) throw new ArgumentNullException("pe"); m_listEntries.Add(pe); // Do not remove the entry from its previous parent group, // only assign it to the new one if(bTakeOwnership) pe.ParentGroup = this; if(bUpdateLocationChangedOfEntry) pe.LocationChanged = DateTime.Now; } public void SortSubGroups(bool bRecursive) { m_listGroups.Sort(new PwGroupComparer()); if(bRecursive) { foreach(PwGroup pgSub in m_listGroups) pgSub.SortSubGroups(true); } } public void DeleteAllObjects(PwDatabase pdContext) { DateTime dtNow = DateTime.Now; foreach(PwEntry pe in m_listEntries) { PwDeletedObject pdo = new PwDeletedObject(pe.Uuid, dtNow); pdContext.DeletedObjects.Add(pdo); } m_listEntries.Clear(); foreach(PwGroup pg in m_listGroups) { pg.DeleteAllObjects(pdContext); PwDeletedObject pdo = new PwDeletedObject(pg.Uuid, dtNow); pdContext.DeletedObjects.Add(pdo); } m_listGroups.Clear(); } } public sealed class PwGroupComparer : IComparer { public PwGroupComparer() { } public int Compare(PwGroup a, PwGroup b) { return StrUtil.CompareNaturally(a.Name, b.Name); } } } keepass2-2.25/KeePassLib/KeePassLib.csproj0000664000175000017500000001574612003550436020314 0ustar jtaylorjtaylor Debug AnyCPU 9.0.30729 2.0 {53573E4E-33CB-4FDB-8698-C95F5E40E7F3} Library Properties KeePassLib KeePassLib true KeePassLib.pfx 2.0 true full false ..\Build\KeePassLib\Debug\ DEBUG;TRACE prompt 4 ..\Build\KeePassLib\Debug\KeePassLib.xml pdbonly true ..\Build\KeePassLib\Release\ TRACE prompt 4 ..\Build\KeePassLib\Release\KeePassLib.xml Component keepass2-2.25/KeePassLib/Properties/0000775000175000017500000000000012271475522017240 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLib/Properties/AssemblyInfo.cs0000664000175000017500000000313412271475522022163 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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("KeePassLib")] [assembly: AssemblyDescription("KeePass Password Management Library")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Dominik Reichl")] [assembly: AssemblyProduct("KeePassLib")] [assembly: AssemblyCopyright("Copyright © 2003-2014 Dominik Reichl")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // COM settings [assembly: ComVisible(false)] // Assembly GUID [assembly: Guid("395f6eec-a1e0-4438-aa82-b75099348134")] // Assembly version information [assembly: AssemblyVersion("2.25.0.*")] [assembly: AssemblyFileVersion("2.25.0.0")] keepass2-2.25/KeePassLib/Cryptography/0000775000175000017500000000000012265454114017574 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLib/Cryptography/Cipher/0000775000175000017500000000000012261553104021001 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLib/Cryptography/Cipher/CipherPool.cs0000664000175000017500000001132712261553104023400 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using System.Security; namespace KeePassLib.Cryptography.Cipher { /// /// Pool of encryption/decryption algorithms (ciphers). /// public sealed class CipherPool { private List m_vCiphers = new List(); private static CipherPool m_poolGlobal = null; /// /// Reference to the global cipher pool. /// public static CipherPool GlobalPool { get { if(m_poolGlobal != null) return m_poolGlobal; m_poolGlobal = new CipherPool(); m_poolGlobal.AddCipher(new StandardAesEngine()); return m_poolGlobal; } } /// /// Remove all cipher engines from the current pool. /// public void Clear() { m_vCiphers.Clear(); } /// /// Add a cipher engine to the pool. /// /// Cipher engine to add. Must not be null. public void AddCipher(ICipherEngine csEngine) { Debug.Assert(csEngine != null); if(csEngine == null) throw new ArgumentNullException("csEngine"); // Return if a cipher with that ID is registered already. for(int i = 0; i < m_vCiphers.Count; ++i) if(m_vCiphers[i].CipherUuid.Equals(csEngine.CipherUuid)) return; m_vCiphers.Add(csEngine); } /// /// Get a cipher identified by its UUID. /// /// UUID of the cipher to return. /// Reference to the requested cipher. If the cipher is /// not found, null is returned. public ICipherEngine GetCipher(PwUuid uuidCipher) { foreach(ICipherEngine iEngine in m_vCiphers) { if(iEngine.CipherUuid.Equals(uuidCipher)) return iEngine; } return null; } /// /// Get the index of a cipher. This index is temporary and should /// not be stored or used to identify a cipher. /// /// UUID of the cipher. /// Index of the requested cipher. Returns -1 if /// the specified cipher is not found. public int GetCipherIndex(PwUuid uuidCipher) { for(int i = 0; i < m_vCiphers.Count; ++i) { if(m_vCiphers[i].CipherUuid.Equals(uuidCipher)) return i; } Debug.Assert(false); return -1; } /// /// Get the index of a cipher. This index is temporary and should /// not be stored or used to identify a cipher. /// /// Name of the cipher. Note that /// multiple ciphers can have the same name. In this case, the /// first matching cipher is returned. /// Cipher with the specified name or -1 if /// no cipher with that name is found. public int GetCipherIndex(string strDisplayName) { for(int i = 0; i < m_vCiphers.Count; ++i) if(m_vCiphers[i].DisplayName == strDisplayName) return i; Debug.Assert(false); return -1; } /// /// Get the number of cipher engines in this pool. /// public int EngineCount { get { return m_vCiphers.Count; } } /// /// Get the cipher engine at the specified position. Throws /// an exception if the index is invalid. You can use this /// to iterate over all ciphers, but do not use it to /// identify ciphers. /// /// Index of the requested cipher engine. /// Reference to the cipher engine at the specified /// position. public ICipherEngine this[int nIndex] { get { if((nIndex < 0) || (nIndex >= m_vCiphers.Count)) throw new ArgumentOutOfRangeException("nIndex"); return m_vCiphers[nIndex]; } } } } keepass2-2.25/KeePassLib/Cryptography/Cipher/ICipherEngine.cs0000664000175000017500000000426112261553104024004 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; namespace KeePassLib.Cryptography.Cipher { /// /// Interface of an encryption/decryption class. /// public interface ICipherEngine { /// /// UUID of the engine. If you want to write an engine/plugin, /// please contact the KeePass team to obtain a new UUID. /// PwUuid CipherUuid { get; } /// /// String displayed in the list of available encryption/decryption /// engines in the GUI. /// string DisplayName { get; } /// /// Encrypt a stream. /// /// Stream to read the plain-text from. /// Key to use. /// Initialization vector. /// Stream, from which the encrypted data can be read. Stream EncryptStream(Stream sPlainText, byte[] pbKey, byte[] pbIV); /// /// Decrypt a stream. /// /// Stream to read the encrypted data from. /// Key to use. /// Initialization vector. /// Stream, from which the decrypted data can be read. Stream DecryptStream(Stream sEncrypted, byte[] pbKey, byte[] pbIV); } } keepass2-2.25/KeePassLib/Cryptography/Cipher/StandardAesEngine.cs0000664000175000017500000001224112261553104024647 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; using System.Diagnostics; #if !KeePassRT using System.Security.Cryptography; #else using Org.BouncyCastle.Crypto; using Org.BouncyCastle.Crypto.Engines; using Org.BouncyCastle.Crypto.IO; using Org.BouncyCastle.Crypto.Modes; using Org.BouncyCastle.Crypto.Paddings; using Org.BouncyCastle.Crypto.Parameters; #endif using KeePassLib.Resources; namespace KeePassLib.Cryptography.Cipher { /// /// Standard AES cipher implementation. /// public sealed class StandardAesEngine : ICipherEngine { #if !KeePassRT private const CipherMode m_rCipherMode = CipherMode.CBC; private const PaddingMode m_rCipherPadding = PaddingMode.PKCS7; #endif private static PwUuid m_uuidAes = null; /// /// UUID of the cipher engine. This ID uniquely identifies the /// AES engine. Must not be used by other ciphers. /// public static PwUuid AesUuid { get { if(m_uuidAes == null) { m_uuidAes = new PwUuid(new byte[]{ 0x31, 0xC1, 0xF2, 0xE6, 0xBF, 0x71, 0x43, 0x50, 0xBE, 0x58, 0x05, 0x21, 0x6A, 0xFC, 0x5A, 0xFF }); } return m_uuidAes; } } /// /// Get the UUID of this cipher engine as PwUuid object. /// public PwUuid CipherUuid { get { return StandardAesEngine.AesUuid; } } /// /// Get a displayable name describing this cipher engine. /// public string DisplayName { get { return KLRes.EncAlgorithmAes; } } private static void ValidateArguments(Stream stream, bool bEncrypt, byte[] pbKey, byte[] pbIV) { Debug.Assert(stream != null); if(stream == null) throw new ArgumentNullException("stream"); Debug.Assert(pbKey != null); if(pbKey == null) throw new ArgumentNullException("pbKey"); Debug.Assert(pbKey.Length == 32); if(pbKey.Length != 32) throw new ArgumentException("Key must be 256 bits wide!"); Debug.Assert(pbIV != null); if(pbIV == null) throw new ArgumentNullException("pbIV"); Debug.Assert(pbIV.Length == 16); if(pbIV.Length != 16) throw new ArgumentException("Initialization vector must be 128 bits wide!"); if(bEncrypt) { Debug.Assert(stream.CanWrite); if(stream.CanWrite == false) throw new ArgumentException("Stream must be writable!"); } else // Decrypt { Debug.Assert(stream.CanRead); if(stream.CanRead == false) throw new ArgumentException("Encrypted stream must be readable!"); } } private static Stream CreateStream(Stream s, bool bEncrypt, byte[] pbKey, byte[] pbIV) { StandardAesEngine.ValidateArguments(s, bEncrypt, pbKey, pbIV); byte[] pbLocalIV = new byte[16]; Array.Copy(pbIV, pbLocalIV, 16); byte[] pbLocalKey = new byte[32]; Array.Copy(pbKey, pbLocalKey, 32); #if !KeePassRT RijndaelManaged r = new RijndaelManaged(); if(r.BlockSize != 128) // AES block size { Debug.Assert(false); r.BlockSize = 128; } r.IV = pbLocalIV; r.KeySize = 256; r.Key = pbLocalKey; r.Mode = m_rCipherMode; r.Padding = m_rCipherPadding; ICryptoTransform iTransform = (bEncrypt ? r.CreateEncryptor() : r.CreateDecryptor()); Debug.Assert(iTransform != null); if(iTransform == null) throw new SecurityException("Unable to create Rijndael transform!"); return new CryptoStream(s, iTransform, bEncrypt ? CryptoStreamMode.Write : CryptoStreamMode.Read); #else AesEngine aes = new AesEngine(); CbcBlockCipher cbc = new CbcBlockCipher(aes); PaddedBufferedBlockCipher bc = new PaddedBufferedBlockCipher(cbc, new Pkcs7Padding()); KeyParameter kp = new KeyParameter(pbLocalKey); ParametersWithIV prmIV = new ParametersWithIV(kp, pbLocalIV); bc.Init(bEncrypt, prmIV); IBufferedCipher cpRead = (bEncrypt ? null : bc); IBufferedCipher cpWrite = (bEncrypt ? bc : null); return new CipherStream(s, cpRead, cpWrite); #endif } public Stream EncryptStream(Stream sPlainText, byte[] pbKey, byte[] pbIV) { return StandardAesEngine.CreateStream(sPlainText, true, pbKey, pbIV); } public Stream DecryptStream(Stream sEncrypted, byte[] pbKey, byte[] pbIV) { return StandardAesEngine.CreateStream(sEncrypted, false, pbKey, pbIV); } } } keepass2-2.25/KeePassLib/Cryptography/Cipher/Salsa20Cipher.cs0000664000175000017500000001302112261553104023665 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 */ // Implementation of the Salsa20 cipher, based on the eSTREAM submission. using System; using System.Diagnostics; using KeePassLib.Utility; namespace KeePassLib.Cryptography.Cipher { public sealed class Salsa20Cipher { private uint[] m_state = new uint[16]; private uint[] m_x = new uint[16]; // Working buffer private byte[] m_output = new byte[64]; private int m_outputPos = 64; private static readonly uint[] m_sigma = new uint[4]{ 0x61707865, 0x3320646E, 0x79622D32, 0x6B206574 }; public Salsa20Cipher(byte[] pbKey32, byte[] pbIV8) { KeySetup(pbKey32); IvSetup(pbIV8); } ~Salsa20Cipher() { // Clear sensitive data Array.Clear(m_state, 0, m_state.Length); Array.Clear(m_x, 0, m_x.Length); } private void NextOutput() { uint[] x = m_x; // Local alias for working buffer // Compiler/runtime might remove array bound checks after this if(x.Length < 16) throw new InvalidOperationException(); Array.Copy(m_state, x, 16); unchecked { for(int i = 0; i < 10; ++i) // (int i = 20; i > 0; i -= 2) { x[ 4] ^= Rotl32(x[ 0] + x[12], 7); x[ 8] ^= Rotl32(x[ 4] + x[ 0], 9); x[12] ^= Rotl32(x[ 8] + x[ 4], 13); x[ 0] ^= Rotl32(x[12] + x[ 8], 18); x[ 9] ^= Rotl32(x[ 5] + x[ 1], 7); x[13] ^= Rotl32(x[ 9] + x[ 5], 9); x[ 1] ^= Rotl32(x[13] + x[ 9], 13); x[ 5] ^= Rotl32(x[ 1] + x[13], 18); x[14] ^= Rotl32(x[10] + x[ 6], 7); x[ 2] ^= Rotl32(x[14] + x[10], 9); x[ 6] ^= Rotl32(x[ 2] + x[14], 13); x[10] ^= Rotl32(x[ 6] + x[ 2], 18); x[ 3] ^= Rotl32(x[15] + x[11], 7); x[ 7] ^= Rotl32(x[ 3] + x[15], 9); x[11] ^= Rotl32(x[ 7] + x[ 3], 13); x[15] ^= Rotl32(x[11] + x[ 7], 18); x[ 1] ^= Rotl32(x[ 0] + x[ 3], 7); x[ 2] ^= Rotl32(x[ 1] + x[ 0], 9); x[ 3] ^= Rotl32(x[ 2] + x[ 1], 13); x[ 0] ^= Rotl32(x[ 3] + x[ 2], 18); x[ 6] ^= Rotl32(x[ 5] + x[ 4], 7); x[ 7] ^= Rotl32(x[ 6] + x[ 5], 9); x[ 4] ^= Rotl32(x[ 7] + x[ 6], 13); x[ 5] ^= Rotl32(x[ 4] + x[ 7], 18); x[11] ^= Rotl32(x[10] + x[ 9], 7); x[ 8] ^= Rotl32(x[11] + x[10], 9); x[ 9] ^= Rotl32(x[ 8] + x[11], 13); x[10] ^= Rotl32(x[ 9] + x[ 8], 18); x[12] ^= Rotl32(x[15] + x[14], 7); x[13] ^= Rotl32(x[12] + x[15], 9); x[14] ^= Rotl32(x[13] + x[12], 13); x[15] ^= Rotl32(x[14] + x[13], 18); } for(int i = 0; i < 16; ++i) x[i] += m_state[i]; for(int i = 0; i < 16; ++i) { m_output[i << 2] = (byte)x[i]; m_output[(i << 2) + 1] = (byte)(x[i] >> 8); m_output[(i << 2) + 2] = (byte)(x[i] >> 16); m_output[(i << 2) + 3] = (byte)(x[i] >> 24); } m_outputPos = 0; ++m_state[8]; if(m_state[8] == 0) ++m_state[9]; } } private static uint Rotl32(uint x, int b) { unchecked { return ((x << b) | (x >> (32 - b))); } } private static uint U8To32Little(byte[] pb, int iOffset) { unchecked { return ((uint)pb[iOffset] | ((uint)pb[iOffset + 1] << 8) | ((uint)pb[iOffset + 2] << 16) | ((uint)pb[iOffset + 3] << 24)); } } private void KeySetup(byte[] k) { if(k == null) throw new ArgumentNullException("k"); if(k.Length != 32) throw new ArgumentException(); m_state[1] = U8To32Little(k, 0); m_state[2] = U8To32Little(k, 4); m_state[3] = U8To32Little(k, 8); m_state[4] = U8To32Little(k, 12); m_state[11] = U8To32Little(k, 16); m_state[12] = U8To32Little(k, 20); m_state[13] = U8To32Little(k, 24); m_state[14] = U8To32Little(k, 28); m_state[0] = m_sigma[0]; m_state[5] = m_sigma[1]; m_state[10] = m_sigma[2]; m_state[15] = m_sigma[3]; } private void IvSetup(byte[] pbIV) { if(pbIV == null) throw new ArgumentNullException("pbIV"); if(pbIV.Length != 8) throw new ArgumentException(); m_state[6] = U8To32Little(pbIV, 0); m_state[7] = U8To32Little(pbIV, 4); m_state[8] = 0; m_state[9] = 0; } public void Encrypt(byte[] m, int nByteCount, bool bXor) { if(m == null) throw new ArgumentNullException("m"); if(nByteCount > m.Length) throw new ArgumentException(); int nBytesRem = nByteCount, nOffset = 0; while(nBytesRem > 0) { Debug.Assert((m_outputPos >= 0) && (m_outputPos <= 64)); if(m_outputPos == 64) NextOutput(); Debug.Assert(m_outputPos < 64); int nCopy = Math.Min(64 - m_outputPos, nBytesRem); if(bXor) MemUtil.XorArray(m_output, m_outputPos, m, nOffset, nCopy); else Array.Copy(m_output, m_outputPos, m, nOffset, nCopy); m_outputPos += nCopy; nBytesRem -= nCopy; nOffset += nCopy; } } } } keepass2-2.25/KeePassLib/Cryptography/PopularPasswords.cs0000664000175000017500000000675012261553104023456 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePassLib.Utility; namespace KeePassLib.Cryptography { public static class PopularPasswords { private static Dictionary> m_dicts = new Dictionary>(); internal static int MaxLength { get { Debug.Assert(m_dicts.Count > 0); // Should be initialized int iMaxLen = 0; foreach(int iLen in m_dicts.Keys) { if(iLen > iMaxLen) iMaxLen = iLen; } return iMaxLen; } } internal static bool ContainsLength(int nLength) { Dictionary dDummy; return m_dicts.TryGetValue(nLength, out dDummy); } public static bool IsPopularPassword(char[] vPassword) { ulong uDummy; return IsPopularPassword(vPassword, out uDummy); } public static bool IsPopularPassword(char[] vPassword, out ulong uDictSize) { if(vPassword == null) throw new ArgumentNullException("vPassword"); if(vPassword.Length == 0) { uDictSize = 0; return false; } string str = new string(vPassword); try { return IsPopularPasswordPriv(str, out uDictSize); } catch(Exception) { Debug.Assert(false); } uDictSize = 0; return false; } private static bool IsPopularPasswordPriv(string str, out ulong uDictSize) { Debug.Assert(m_dicts.Count > 0); // Should be initialized with data Dictionary d; if(!m_dicts.TryGetValue(str.Length, out d)) { uDictSize = 0; return false; } uDictSize = (ulong)d.Count; return d.ContainsKey(str); } public static void Add(byte[] pbData, bool bGZipped) { try { if(bGZipped) pbData = MemUtil.Decompress(pbData); string strData = StrUtil.Utf8.GetString(pbData, 0, pbData.Length); if(string.IsNullOrEmpty(strData)) { Debug.Assert(false); return; } if(!char.IsWhiteSpace(strData[strData.Length - 1])) strData += "\n"; StringBuilder sb = new StringBuilder(); for(int i = 0; i < strData.Length; ++i) { char ch = strData[i]; if(char.IsWhiteSpace(ch)) { int cc = sb.Length; if(cc > 0) { string strWord = sb.ToString(); Debug.Assert(strWord.Length == cc); Dictionary d; if(!m_dicts.TryGetValue(cc, out d)) { d = new Dictionary(); m_dicts[cc] = d; } d[strWord] = true; sb.Remove(0, cc); } } else sb.Append(char.ToLower(ch)); } } catch(Exception) { Debug.Assert(false); } } } } keepass2-2.25/KeePassLib/Cryptography/QualityEstimation.cs0000664000175000017500000005225412261553104023613 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePassLib.Cryptography.PasswordGenerator; using KeePassLib.Utility; namespace KeePassLib.Cryptography { /// /// A class that offers static functions to estimate the quality of /// passwords. /// public static class QualityEstimation { private static class PatternID { public const char LowerAlpha = 'L'; public const char UpperAlpha = 'U'; public const char Digit = 'D'; public const char Special = 'S'; public const char High = 'H'; public const char Other = 'X'; public const char Dictionary = 'W'; public const char Repetition = 'R'; public const char Number = 'N'; public const char DiffSeq = 'C'; public const string All = "LUDSHXWRNC"; } // private static class CharDistrib // { // public static readonly ulong[] LowerAlpha = new ulong[26] { // 884, 211, 262, 249, 722, 98, 172, 234, 556, 124, 201, 447, 321, // 483, 518, 167, 18, 458, 416, 344, 231, 105, 80, 48, 238, 76 // }; // public static readonly ulong[] UpperAlpha = new ulong[26] { // 605, 188, 209, 200, 460, 81, 130, 163, 357, 122, 144, 332, 260, // 317, 330, 132, 18, 320, 315, 250, 137, 76, 60, 36, 161, 54 // }; // public static readonly ulong[] Digit = new ulong[10] { // 574, 673, 524, 377, 339, 336, 312, 310, 357, 386 // }; // } private sealed class QeCharType { private readonly char m_chTypeID; public char TypeID { get { return m_chTypeID; } } private readonly string m_strAlph; public string Alphabet { get { return m_strAlph; } } private readonly int m_nChars; public int CharCount { get { return m_nChars; } } private readonly char m_chFirst; private readonly char m_chLast; private readonly double m_dblCharSize; public double CharSize { get { return m_dblCharSize; } } public QeCharType(char chTypeID, string strAlphabet, bool bIsConsecutive) { if(strAlphabet == null) throw new ArgumentNullException(); if(strAlphabet.Length == 0) throw new ArgumentException(); m_chTypeID = chTypeID; m_strAlph = strAlphabet; m_nChars = m_strAlph.Length; m_chFirst = (bIsConsecutive ? m_strAlph[0] : char.MinValue); m_chLast = (bIsConsecutive ? m_strAlph[m_nChars - 1] : char.MinValue); m_dblCharSize = Log2(m_nChars); Debug.Assert(((int)(m_chLast - m_chFirst) == (m_nChars - 1)) || !bIsConsecutive); } public QeCharType(char chTypeID, int nChars) // Catch-none set { if(nChars <= 0) throw new ArgumentOutOfRangeException(); m_chTypeID = chTypeID; m_strAlph = string.Empty; m_nChars = nChars; m_chFirst = char.MinValue; m_chLast = char.MinValue; m_dblCharSize = Log2(m_nChars); } public bool Contains(char ch) { if(m_chLast != char.MinValue) return ((ch >= m_chFirst) && (ch <= m_chLast)); Debug.Assert(m_strAlph.Length > 0); // Don't call for catch-none set return (m_strAlph.IndexOf(ch) >= 0); } } private sealed class EntropyEncoder { private readonly string m_strAlph; private Dictionary m_dHisto = new Dictionary(); private readonly ulong m_uBaseWeight; private readonly ulong m_uCharWeight; private readonly ulong m_uOccExclThreshold; public EntropyEncoder(string strAlphabet, ulong uBaseWeight, ulong uCharWeight, ulong uOccExclThreshold) { if(strAlphabet == null) throw new ArgumentNullException(); if(strAlphabet.Length == 0) throw new ArgumentException(); m_strAlph = strAlphabet; m_uBaseWeight = uBaseWeight; m_uCharWeight = uCharWeight; m_uOccExclThreshold = uOccExclThreshold; #if DEBUG Dictionary d = new Dictionary(); foreach(char ch in m_strAlph) { d[ch] = true; } Debug.Assert(d.Count == m_strAlph.Length); // No duplicates #endif } public void Reset() { m_dHisto.Clear(); } public void Write(char ch) { Debug.Assert(m_strAlph.IndexOf(ch) >= 0); ulong uOcc; m_dHisto.TryGetValue(ch, out uOcc); Debug.Assert(m_dHisto.ContainsKey(ch) || (uOcc == 0)); m_dHisto[ch] = uOcc + 1; } public double GetOutputSize() { ulong uTotalWeight = m_uBaseWeight * (ulong)m_strAlph.Length; foreach(ulong u in m_dHisto.Values) { Debug.Assert(u >= 1); if(u > m_uOccExclThreshold) uTotalWeight += (u - m_uOccExclThreshold) * m_uCharWeight; } double dSize = 0.0, dTotalWeight = (double)uTotalWeight; foreach(ulong u in m_dHisto.Values) { ulong uWeight = m_uBaseWeight; if(u > m_uOccExclThreshold) uWeight += (u - m_uOccExclThreshold) * m_uCharWeight; dSize -= (double)u * Log2((double)uWeight / dTotalWeight); } return dSize; } } private sealed class MultiEntropyEncoder { private Dictionary m_dEncs = new Dictionary(); public MultiEntropyEncoder() { } public void AddEncoder(char chTypeID, EntropyEncoder ec) { if(ec == null) { Debug.Assert(false); return; } Debug.Assert(!m_dEncs.ContainsKey(chTypeID)); m_dEncs[chTypeID] = ec; } public void Reset() { foreach(EntropyEncoder ec in m_dEncs.Values) { ec.Reset(); } } public bool Write(char chTypeID, char chData) { EntropyEncoder ec; if(!m_dEncs.TryGetValue(chTypeID, out ec)) return false; ec.Write(chData); return true; } public double GetOutputSize() { double d = 0.0; foreach(EntropyEncoder ec in m_dEncs.Values) { d += ec.GetOutputSize(); } return d; } } private sealed class QePatternInstance { private readonly int m_iPos; public int Position { get { return m_iPos; } } private readonly int m_nLen; public int Length { get { return m_nLen; } } private readonly char m_chPatternID; public char PatternID { get { return m_chPatternID; } } private readonly double m_dblCost; public double Cost { get { return m_dblCost; } } private readonly QeCharType m_ctSingle; public QeCharType SingleCharType { get { return m_ctSingle; } } public QePatternInstance(int iPosition, int nLength, char chPatternID, double dblCost) { m_iPos = iPosition; m_nLen = nLength; m_chPatternID = chPatternID; m_dblCost = dblCost; m_ctSingle = null; } public QePatternInstance(int iPosition, int nLength, QeCharType ctSingle) { m_iPos = iPosition; m_nLen = nLength; m_chPatternID = ctSingle.TypeID; m_dblCost = ctSingle.CharSize; m_ctSingle = ctSingle; } } private sealed class QePathState { public readonly int Position; public readonly List Path; public QePathState(int iPosition, List lPath) { this.Position = iPosition; this.Path = lPath; } } private static object m_objSyncInit = new object(); private static List m_lCharTypes = null; private static void EnsureInitialized() { lock(m_objSyncInit) { if(m_lCharTypes == null) { string strSpecial = PwCharSet.PrintableAsciiSpecial; if(strSpecial.IndexOf(' ') >= 0) { Debug.Assert(false); } else strSpecial = strSpecial + " "; int nSp = strSpecial.Length; int nHi = PwCharSet.HighAnsiChars.Length; m_lCharTypes = new List(); m_lCharTypes.Add(new QeCharType(PatternID.LowerAlpha, PwCharSet.LowerCase, true)); m_lCharTypes.Add(new QeCharType(PatternID.UpperAlpha, PwCharSet.UpperCase, true)); m_lCharTypes.Add(new QeCharType(PatternID.Digit, PwCharSet.Digits, true)); m_lCharTypes.Add(new QeCharType(PatternID.Special, strSpecial, false)); m_lCharTypes.Add(new QeCharType(PatternID.High, PwCharSet.HighAnsiChars, false)); m_lCharTypes.Add(new QeCharType(PatternID.Other, 0x10000 - (2 * 26) - 10 - nSp - nHi)); } } } /// /// Estimate the quality of a password. /// /// Password to check. /// Estimated bit-strength of the password. public static uint EstimatePasswordBits(char[] vPasswordChars) { if(vPasswordChars == null) { Debug.Assert(false); return 0; } if(vPasswordChars.Length == 0) return 0; EnsureInitialized(); int n = vPasswordChars.Length; List[] vPatterns = new List[n]; for(int i = 0; i < n; ++i) { vPatterns[i] = new List(); QePatternInstance piChar = new QePatternInstance(i, 1, GetCharType(vPasswordChars[i])); vPatterns[i].Add(piChar); } FindRepetitions(vPasswordChars, vPatterns); FindNumbers(vPasswordChars, vPatterns); FindDiffSeqs(vPasswordChars, vPatterns); FindPopularPasswords(vPasswordChars, vPatterns); // Encoders must not be static, because the entropy estimation // may run concurrently in multiple threads and the encoders are // not read-only EntropyEncoder ecPattern = new EntropyEncoder(PatternID.All, 0, 1, 0); MultiEntropyEncoder mcData = new MultiEntropyEncoder(); for(int i = 0; i < (m_lCharTypes.Count - 1); ++i) { // Let m be the alphabet size. In order to ensure that two same // characters cost at least as much as a single character, for // the probability p and weight w of the character it must hold: // -log(1/m) >= -2*log(p) // <=> log(1/m) <= log(p^2) <=> 1/m <= p^2 <=> p >= sqrt(1/m); // sqrt(1/m) = (1+w)/(m+w) // <=> m+w = (1+w)*sqrt(m) <=> m+w = sqrt(m) + w*sqrt(m) // <=> w*(1-sqrt(m)) = sqrt(m) - m <=> w = (sqrt(m)-m)/(1-sqrt(m)) // <=> w = (sqrt(m)-m)*(1+sqrt(m))/(1-m) // <=> w = (sqrt(m)-m+m-m*sqrt(m))/(1-m) <=> w = sqrt(m) ulong uw = (ulong)Math.Sqrt((double)m_lCharTypes[i].CharCount); mcData.AddEncoder(m_lCharTypes[i].TypeID, new EntropyEncoder( m_lCharTypes[i].Alphabet, 1, uw, 1)); } double dblMinCost = (double)int.MaxValue; int tStart = Environment.TickCount; Stack sRec = new Stack(); sRec.Push(new QePathState(0, new List())); while(sRec.Count > 0) { int tDiff = Environment.TickCount - tStart; if(tDiff > 500) break; QePathState s = sRec.Pop(); if(s.Position >= n) { Debug.Assert(s.Position == n); double dblCost = ComputePathCost(s.Path, vPasswordChars, ecPattern, mcData); if(dblCost < dblMinCost) dblMinCost = dblCost; } else { List lSubs = vPatterns[s.Position]; for(int i = lSubs.Count - 1; i >= 0; --i) { QePatternInstance pi = lSubs[i]; Debug.Assert(pi.Position == s.Position); Debug.Assert(pi.Length >= 1); List lNewPath = new List(s.Path.Count + 1); lNewPath.AddRange(s.Path); lNewPath.Add(pi); Debug.Assert(lNewPath.Capacity == (s.Path.Count + 1)); QePathState sNew = new QePathState(s.Position + pi.Length, lNewPath); sRec.Push(sNew); } } } return (uint)Math.Ceiling(dblMinCost); } /// /// Estimate the quality of a password. /// /// Password to check, UTF-8 encoded. /// Estimated bit-strength of the password. public static uint EstimatePasswordBits(byte[] pbUnprotectedUtf8) { if(pbUnprotectedUtf8 == null) { Debug.Assert(false); return 0; } char[] vChars = StrUtil.Utf8.GetChars(pbUnprotectedUtf8); uint uResult = EstimatePasswordBits(vChars); Array.Clear(vChars, 0, vChars.Length); return uResult; } private static QeCharType GetCharType(char ch) { int nTypes = m_lCharTypes.Count; Debug.Assert((nTypes > 0) && (m_lCharTypes[nTypes - 1].CharCount > 256)); for(int i = 0; i < (nTypes - 1); ++i) { if(m_lCharTypes[i].Contains(ch)) return m_lCharTypes[i]; } return m_lCharTypes[nTypes - 1]; } private static double ComputePathCost(List l, char[] vPassword, EntropyEncoder ecPattern, MultiEntropyEncoder mcData) { ecPattern.Reset(); for(int i = 0; i < l.Count; ++i) ecPattern.Write(l[i].PatternID); double dblPatternCost = ecPattern.GetOutputSize(); mcData.Reset(); double dblDataCost = 0.0; foreach(QePatternInstance pi in l) { QeCharType tChar = pi.SingleCharType; if(tChar != null) { char ch = vPassword[pi.Position]; if(!mcData.Write(tChar.TypeID, ch)) dblDataCost += pi.Cost; } else dblDataCost += pi.Cost; } dblDataCost += mcData.GetOutputSize(); return (dblPatternCost + dblDataCost); } private static void FindPopularPasswords(char[] vPassword, List[] vPatterns) { int n = vPassword.Length; char[] vLower = new char[n]; char[] vLeet = new char[n]; for(int i = 0; i < n; ++i) { char ch = vPassword[i]; vLower[i] = char.ToLower(ch); vLeet[i] = char.ToLower(DecodeLeetChar(ch)); } char chErased = default(char); Debug.Assert(chErased == char.MinValue); int nMaxLen = Math.Min(n, PopularPasswords.MaxLength); for(int nSubLen = nMaxLen; nSubLen >= 3; --nSubLen) { if(!PopularPasswords.ContainsLength(nSubLen)) continue; char[] vSub = new char[nSubLen]; for(int i = 0; i <= (n - nSubLen); ++i) { if(Array.IndexOf(vLower, chErased, i, nSubLen) >= 0) continue; Array.Copy(vLower, i, vSub, 0, nSubLen); if(!EvalAddPopularPasswordPattern(vPatterns, vPassword, i, vSub, 0.0)) { Array.Copy(vLeet, i, vSub, 0, nSubLen); if(EvalAddPopularPasswordPattern(vPatterns, vPassword, i, vSub, 1.5)) { Array.Clear(vLower, i, nSubLen); // Not vLeet Debug.Assert(vLower[i] == chErased); } } else { Array.Clear(vLower, i, nSubLen); Debug.Assert(vLower[i] == chErased); } } } } private static bool EvalAddPopularPasswordPattern(List[] vPatterns, char[] vPassword, int i, char[] vSub, double dblCostPerMod) { ulong uDictSize; if(!PopularPasswords.IsPopularPassword(vSub, out uDictSize)) return false; int n = vSub.Length; int d = HammingDist(vSub, 0, vPassword, i, n); double dblCost = Log2((double)uDictSize); // dblCost += log2(n binom d) int k = Math.Min(d, n - d); for(int j = n; j > (n - k); --j) dblCost += Log2(j); for(int j = k; j >= 2; --j) dblCost -= Log2(j); dblCost += dblCostPerMod * (double)d; vPatterns[i].Add(new QePatternInstance(i, n, PatternID.Dictionary, dblCost)); return true; } private static char DecodeLeetChar(char chLeet) { if((chLeet >= '\u00C0') && (chLeet <= '\u00C6')) return 'a'; if((chLeet >= '\u00C8') && (chLeet <= '\u00CB')) return 'e'; if((chLeet >= '\u00CC') && (chLeet <= '\u00CF')) return 'i'; if((chLeet >= '\u00D2') && (chLeet <= '\u00D6')) return 'o'; if((chLeet >= '\u00D9') && (chLeet <= '\u00DC')) return 'u'; if((chLeet >= '\u00E0') && (chLeet <= '\u00E6')) return 'a'; if((chLeet >= '\u00E8') && (chLeet <= '\u00EB')) return 'e'; if((chLeet >= '\u00EC') && (chLeet <= '\u00EF')) return 'i'; if((chLeet >= '\u00F2') && (chLeet <= '\u00F6')) return 'o'; if((chLeet >= '\u00F9') && (chLeet <= '\u00FC')) return 'u'; char ch; switch(chLeet) { case '4': case '@': case '?': case '^': case '\u00AA': ch = 'a'; break; case '8': case '\u00DF': ch = 'b'; break; case '(': case '{': case '[': case '<': case '\u00A2': case '\u00A9': case '\u00C7': case '\u00E7': ch = 'c'; break; case '\u00D0': case '\u00F0': ch = 'd'; break; case '3': case '\u20AC': case '&': case '\u00A3': ch = 'e'; break; case '6': case '9': ch = 'g'; break; case '#': ch = 'h'; break; case '1': case '!': case '|': case '\u00A1': case '\u00A6': ch = 'i'; break; case '\u00D1': case '\u00F1': ch = 'n'; break; case '0': case '*': case '\u00A4': // Currency case '\u00B0': // Degree case '\u00D8': case '\u00F8': ch = 'o'; break; case '\u00AE': ch = 'r'; break; case '$': case '5': case '\u00A7': ch = 's'; break; case '+': case '7': ch = 't'; break; case '\u00B5': ch = 'u'; break; case '%': case '\u00D7': ch = 'x'; break; case '\u00A5': case '\u00DD': case '\u00FD': case '\u00FF': ch = 'y'; break; case '2': ch = 'z'; break; default: ch = chLeet; break; } return ch; } private static int HammingDist(char[] v1, int iOffset1, char[] v2, int iOffset2, int nLength) { int nDist = 0; for(int i = 0; i < nLength; ++i) { if(v1[iOffset1 + i] != v2[iOffset2 + i]) ++nDist; } return nDist; } private static void FindRepetitions(char[] vPassword, List[] vPatterns) { int n = vPassword.Length; char[] v = new char[n]; Array.Copy(vPassword, v, n); char chErased = char.MaxValue; for(int m = (n / 2); m >= 3; --m) { for(int x1 = 0; x1 <= (n - (2 * m)); ++x1) { bool bFoundRep = false; for(int x2 = (x1 + m); x2 <= (n - m); ++x2) { if(PartsEqual(v, x1, x2, m)) { double dblCost = Log2(x1 + 1) + Log2(m); vPatterns[x2].Add(new QePatternInstance(x2, m, PatternID.Repetition, dblCost)); ErasePart(v, x2, m, ref chErased); bFoundRep = true; } } if(bFoundRep) ErasePart(v, x1, m, ref chErased); } } } private static bool PartsEqual(char[] v, int x1, int x2, int nLength) { for(int i = 0; i < nLength; ++i) { if(v[x1 + i] != v[x2 + i]) return false; } return true; } private static void ErasePart(char[] v, int i, int n, ref char chErased) { for(int j = 0; j < n; ++j) { v[i + j] = chErased; --chErased; } } private static void FindNumbers(char[] vPassword, List[] vPatterns) { int n = vPassword.Length; StringBuilder sb = new StringBuilder(); for(int i = 0; i < n; ++i) { char ch = vPassword[i]; if((ch >= '0') && (ch <= '9')) sb.Append(ch); else { AddNumberPattern(vPatterns, sb.ToString(), i - sb.Length); sb.Remove(0, sb.Length); } } AddNumberPattern(vPatterns, sb.ToString(), n - sb.Length); } private static void AddNumberPattern(List[] vPatterns, string strNumber, int i) { if(strNumber.Length <= 2) return; int nZeros = 0; for(int j = 0; j < strNumber.Length; ++j) { if(strNumber[j] != '0') break; ++nZeros; } double dblCost = Log2(nZeros + 1); if(nZeros < strNumber.Length) { string strNonZero = strNumber.Substring(nZeros); #if KeePassLibSD try { dblCost += Log2(double.Parse(strNonZero)); } catch(Exception) { Debug.Assert(false); return; } #else double d; if(double.TryParse(strNonZero, out d)) dblCost += Log2(d); else { Debug.Assert(false); return; } #endif } vPatterns[i].Add(new QePatternInstance(i, strNumber.Length, PatternID.Number, dblCost)); } private static void FindDiffSeqs(char[] vPassword, List[] vPatterns) { int d = int.MinValue, p = 0; string str = new string(vPassword) + new string(char.MaxValue, 1); for(int i = 1; i < str.Length; ++i) { int dCur = (int)str[i] - (int)str[i - 1]; if(dCur != d) { if((i - p) >= 3) // At least 3 chars involved { QeCharType ct = GetCharType(str[p]); double dblCost = ct.CharSize + Log2(i - p - 1); vPatterns[p].Add(new QePatternInstance(p, i - p, PatternID.DiffSeq, dblCost)); } d = dCur; p = i - 1; } } } private static double Log2(double dblValue) { #if KeePassLibSD return (Math.Log(dblValue) / Math.Log(2.0)); #else return Math.Log(dblValue, 2.0); #endif } } } keepass2-2.25/KeePassLib/Cryptography/SelfTest.cs0000664000175000017500000004110512261553104021650 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Security; using System.Security.Cryptography; using System.Text; using System.Globalization; using System.Diagnostics; using KeePassLib.Cryptography.Cipher; using KeePassLib.Keys; using KeePassLib.Native; using KeePassLib.Utility; using KeePassLib.Resources; using KeePassLib.Security; namespace KeePassLib.Cryptography { /* #pragma warning disable 1591 /// /// Return values of the SelfTest.Perform method. /// public enum SelfTestResult { Success = 0, RijndaelEcbError = 1, Salsa20Error = 2, NativeKeyTransformationError = 3 } #pragma warning restore 1591 */ /// /// Class containing self-test methods. /// public static class SelfTest { /// /// Perform a self-test. /// public static void Perform() { TestFipsComplianceProblems(); // Must be the first test TestRijndael(); TestSalsa20(); TestNativeKeyTransform(); TestHmacOtp(); TestProtectedObjects(); TestMemUtil(); TestStrUtil(); TestUrlUtil(); Debug.Assert((int)PwIcon.World == 1); Debug.Assert((int)PwIcon.Warning == 2); Debug.Assert((int)PwIcon.BlackBerry == 68); } internal static void TestFipsComplianceProblems() { #if !KeePassRT try { new RijndaelManaged(); } catch(Exception exAes) { throw new SecurityException("AES/Rijndael: " + exAes.Message); } try { new SHA256Managed(); } catch(Exception exSha256) { throw new SecurityException("SHA-256: " + exSha256.Message); } #endif } private static void TestRijndael() { #if !KeePassRT // Test vector (official ECB test vector #356) byte[] pbIV = new byte[16]; byte[] pbTestKey = new byte[32]; byte[] pbTestData = new byte[16]; byte[] pbReferenceCT = new byte[16] { 0x75, 0xD1, 0x1B, 0x0E, 0x3A, 0x68, 0xC4, 0x22, 0x3D, 0x88, 0xDB, 0xF0, 0x17, 0x97, 0x7D, 0xD7 }; int i; for(i = 0; i < 16; ++i) pbIV[i] = 0; for(i = 0; i < 32; ++i) pbTestKey[i] = 0; for(i = 0; i < 16; ++i) pbTestData[i] = 0; pbTestData[0] = 0x04; RijndaelManaged r = new RijndaelManaged(); if(r.BlockSize != 128) // AES block size { Debug.Assert(false); r.BlockSize = 128; } r.IV = pbIV; r.KeySize = 256; r.Key = pbTestKey; r.Mode = CipherMode.ECB; ICryptoTransform iCrypt = r.CreateEncryptor(); iCrypt.TransformBlock(pbTestData, 0, 16, pbTestData, 0); if(!MemUtil.ArraysEqual(pbTestData, pbReferenceCT)) throw new SecurityException(KLRes.EncAlgorithmAes + "."); #endif } private static void TestSalsa20() { // Test values from official set 6, vector 3 byte[] pbKey= new byte[32] { 0x0F, 0x62, 0xB5, 0x08, 0x5B, 0xAE, 0x01, 0x54, 0xA7, 0xFA, 0x4D, 0xA0, 0xF3, 0x46, 0x99, 0xEC, 0x3F, 0x92, 0xE5, 0x38, 0x8B, 0xDE, 0x31, 0x84, 0xD7, 0x2A, 0x7D, 0xD0, 0x23, 0x76, 0xC9, 0x1C }; byte[] pbIV = new byte[8] { 0x28, 0x8F, 0xF6, 0x5D, 0xC4, 0x2B, 0x92, 0xF9 }; byte[] pbExpected = new byte[16] { 0x5E, 0x5E, 0x71, 0xF9, 0x01, 0x99, 0x34, 0x03, 0x04, 0xAB, 0xB2, 0x2A, 0x37, 0xB6, 0x62, 0x5B }; byte[] pb = new byte[16]; Salsa20Cipher c = new Salsa20Cipher(pbKey, pbIV); c.Encrypt(pb, pb.Length, false); if(!MemUtil.ArraysEqual(pb, pbExpected)) throw new SecurityException("Salsa20."); #if DEBUG // Extended test in debug mode byte[] pbExpected2 = new byte[16] { 0xAB, 0xF3, 0x9A, 0x21, 0x0E, 0xEE, 0x89, 0x59, 0x8B, 0x71, 0x33, 0x37, 0x70, 0x56, 0xC2, 0xFE }; byte[] pbExpected3 = new byte[16] { 0x1B, 0xA8, 0x9D, 0xBD, 0x3F, 0x98, 0x83, 0x97, 0x28, 0xF5, 0x67, 0x91, 0xD5, 0xB7, 0xCE, 0x23 }; Random r = new Random(); int nPos = Salsa20ToPos(c, r, pb.Length, 65536); c.Encrypt(pb, pb.Length, false); if(!MemUtil.ArraysEqual(pb, pbExpected2)) throw new SecurityException("Salsa20-2."); nPos = Salsa20ToPos(c, r, nPos + pb.Length, 131008); Array.Clear(pb, 0, pb.Length); c.Encrypt(pb, pb.Length, true); if(!MemUtil.ArraysEqual(pb, pbExpected3)) throw new SecurityException("Salsa20-3."); #endif } #if DEBUG private static int Salsa20ToPos(Salsa20Cipher c, Random r, int nPos, int nTargetPos) { byte[] pb = new byte[512]; while(nPos < nTargetPos) { int x = r.Next(1, 513); int nGen = Math.Min(nTargetPos - nPos, x); c.Encrypt(pb, nGen, r.Next(0, 2) == 0); nPos += nGen; } return nTargetPos; } #endif private static void TestNativeKeyTransform() { #if DEBUG byte[] pbOrgKey = CryptoRandom.Instance.GetRandomBytes(32); byte[] pbSeed = CryptoRandom.Instance.GetRandomBytes(32); ulong uRounds = (ulong)((new Random()).Next(1, 0x3FFF)); byte[] pbManaged = new byte[32]; Array.Copy(pbOrgKey, pbManaged, 32); if(CompositeKey.TransformKeyManaged(pbManaged, pbSeed, uRounds) == false) throw new SecurityException("Managed transform."); byte[] pbNative = new byte[32]; Array.Copy(pbOrgKey, pbNative, 32); if(NativeLib.TransformKey256(pbNative, pbSeed, uRounds) == false) return; // Native library not available ("success") if(!MemUtil.ArraysEqual(pbManaged, pbNative)) throw new SecurityException("Native transform."); #endif } private static void TestMemUtil() { #if DEBUG Random r = new Random(); byte[] pb = CryptoRandom.Instance.GetRandomBytes((uint)r.Next( 0, 0x2FFFF)); byte[] pbCompressed = MemUtil.Compress(pb); if(!MemUtil.ArraysEqual(MemUtil.Decompress(pbCompressed), pb)) throw new InvalidOperationException("GZip"); Encoding enc = StrUtil.Utf8; pb = enc.GetBytes("012345678901234567890a"); byte[] pbN = enc.GetBytes("9012"); if(MemUtil.IndexOf(pb, pbN) != 9) throw new InvalidOperationException("MemUtil-1"); pbN = enc.GetBytes("01234567890123"); if(MemUtil.IndexOf(pb, pbN) != 0) throw new InvalidOperationException("MemUtil-2"); pbN = enc.GetBytes("a"); if(MemUtil.IndexOf(pb, pbN) != 21) throw new InvalidOperationException("MemUtil-3"); pbN = enc.GetBytes("0a"); if(MemUtil.IndexOf(pb, pbN) != 20) throw new InvalidOperationException("MemUtil-4"); pbN = enc.GetBytes("1"); if(MemUtil.IndexOf(pb, pbN) != 1) throw new InvalidOperationException("MemUtil-5"); pbN = enc.GetBytes("b"); if(MemUtil.IndexOf(pb, pbN) >= 0) throw new InvalidOperationException("MemUtil-6"); pbN = enc.GetBytes("012b"); if(MemUtil.IndexOf(pb, pbN) >= 0) throw new InvalidOperationException("MemUtil-7"); #endif } private static void TestHmacOtp() { #if (DEBUG && !KeePassLibSD && !KeePassRT) byte[] pbSecret = StrUtil.Utf8.GetBytes("12345678901234567890"); string[] vExp = new string[]{ "755224", "287082", "359152", "969429", "338314", "254676", "287922", "162583", "399871", "520489" }; for(int i = 0; i < vExp.Length; ++i) { if(HmacOtp.Generate(pbSecret, (ulong)i, 6, false, -1) != vExp[i]) throw new InvalidOperationException("HmacOtp"); } #endif } private static void TestProtectedObjects() { #if DEBUG Encoding enc = StrUtil.Utf8; byte[] pbData = enc.GetBytes("Test Test Test Test"); ProtectedBinary pb = new ProtectedBinary(true, pbData); if(!pb.IsProtected) throw new SecurityException("ProtectedBinary-1"); byte[] pbDec = pb.ReadData(); if(!MemUtil.ArraysEqual(pbData, pbDec)) throw new SecurityException("ProtectedBinary-2"); if(!pb.IsProtected) throw new SecurityException("ProtectedBinary-3"); byte[] pbData2 = enc.GetBytes("Test Test Test Test"); byte[] pbData3 = enc.GetBytes("Test Test Test Test Test"); ProtectedBinary pb2 = new ProtectedBinary(true, pbData2); ProtectedBinary pb3 = new ProtectedBinary(true, pbData3); if(!pb.Equals(pb2)) throw new SecurityException("ProtectedBinary-4"); if(pb.Equals(pb3)) throw new SecurityException("ProtectedBinary-5"); if(pb2.Equals(pb3)) throw new SecurityException("ProtectedBinary-6"); if(pb.GetHashCode() != pb2.GetHashCode()) throw new SecurityException("ProtectedBinary-7"); if(!((object)pb).Equals((object)pb2)) throw new SecurityException("ProtectedBinary-8"); if(((object)pb).Equals((object)pb3)) throw new SecurityException("ProtectedBinary-9"); if(((object)pb2).Equals((object)pb3)) throw new SecurityException("ProtectedBinary-10"); ProtectedString ps = new ProtectedString(); if(ps.Length != 0) throw new SecurityException("ProtectedString-1"); if(!ps.IsEmpty) throw new SecurityException("ProtectedString-2"); if(ps.ReadString().Length != 0) throw new SecurityException("ProtectedString-3"); ps = new ProtectedString(true, "Test"); ProtectedString ps2 = new ProtectedString(true, enc.GetBytes("Test")); if(ps.IsEmpty) throw new SecurityException("ProtectedString-4"); pbData = ps.ReadUtf8(); pbData2 = ps2.ReadUtf8(); if(!MemUtil.ArraysEqual(pbData, pbData2)) throw new SecurityException("ProtectedString-5"); if(pbData.Length != 4) throw new SecurityException("ProtectedString-6"); if(ps.ReadString() != ps2.ReadString()) throw new SecurityException("ProtectedString-7"); pbData = ps.ReadUtf8(); pbData2 = ps2.ReadUtf8(); if(!MemUtil.ArraysEqual(pbData, pbData2)) throw new SecurityException("ProtectedString-8"); if(!ps.IsProtected) throw new SecurityException("ProtectedString-9"); if(!ps2.IsProtected) throw new SecurityException("ProtectedString-10"); #endif } private static void TestStrUtil() { #if DEBUG string[] vSeps = new string[]{ "ax", "b", "c" }; const string str1 = "axbqrstcdeax"; List v1 = StrUtil.SplitWithSep(str1, vSeps, true); if(v1.Count != 9) throw new InvalidOperationException("StrUtil-1"); if(v1[0].Length > 0) throw new InvalidOperationException("StrUtil-2"); if(!v1[1].Equals("ax")) throw new InvalidOperationException("StrUtil-3"); if(v1[2].Length > 0) throw new InvalidOperationException("StrUtil-4"); if(!v1[3].Equals("b")) throw new InvalidOperationException("StrUtil-5"); if(!v1[4].Equals("qrst")) throw new InvalidOperationException("StrUtil-6"); if(!v1[5].Equals("c")) throw new InvalidOperationException("StrUtil-7"); if(!v1[6].Equals("de")) throw new InvalidOperationException("StrUtil-8"); if(!v1[7].Equals("ax")) throw new InvalidOperationException("StrUtil-9"); if(v1[8].Length > 0) throw new InvalidOperationException("StrUtil-10"); const string str2 = "12ab56"; List v2 = StrUtil.SplitWithSep(str2, new string[]{ "AB" }, false); if(v2.Count != 3) throw new InvalidOperationException("StrUtil-11"); if(!v2[0].Equals("12")) throw new InvalidOperationException("StrUtil-12"); if(!v2[1].Equals("AB")) throw new InvalidOperationException("StrUtil-13"); if(!v2[2].Equals("56")) throw new InvalidOperationException("StrUtil-14"); List v3 = StrUtil.SplitWithSep("pqrs", vSeps, false); if(v3.Count != 1) throw new InvalidOperationException("StrUtil-15"); if(!v3[0].Equals("pqrs")) throw new InvalidOperationException("StrUtil-16"); if(StrUtil.VersionToString(0x000F000E000D000CUL) != "15.14.13.12") throw new InvalidOperationException("StrUtil-V1"); if(StrUtil.VersionToString(0x00FF000E00010000UL) != "255.14.1") throw new InvalidOperationException("StrUtil-V2"); if(StrUtil.VersionToString(0x000F00FF00000000UL) != "15.255") throw new InvalidOperationException("StrUtil-V3"); if(StrUtil.VersionToString(0x00FF000000000000UL) != "255") throw new InvalidOperationException("StrUtil-V4"); if(StrUtil.VersionToString(0x00FF000000000000UL, true) != "255.0") throw new InvalidOperationException("StrUtil-V5"); if(StrUtil.VersionToString(0x0000000000070000UL, true) != "0.0.7") throw new InvalidOperationException("StrUtil-V6"); if(StrUtil.RtfEncodeChar('\u0000') != "\\u0?") throw new InvalidOperationException("StrUtil-Rtf1"); if(StrUtil.RtfEncodeChar('\u7FFF') != "\\u32767?") throw new InvalidOperationException("StrUtil-Rtf2"); if(StrUtil.RtfEncodeChar('\u8000') != "\\u-32768?") throw new InvalidOperationException("StrUtil-Rtf3"); if(StrUtil.RtfEncodeChar('\uFFFF') != "\\u-1?") throw new InvalidOperationException("StrUtil-Rtf4"); if(!StrUtil.StringToBool(Boolean.TrueString)) throw new InvalidOperationException("StrUtil-Bool1"); if(StrUtil.StringToBool(Boolean.FalseString)) throw new InvalidOperationException("StrUtil-Bool2"); if(StrUtil.Count("Abracadabra", "a") != 4) throw new InvalidOperationException("StrUtil-Count1"); if(StrUtil.Count("Bla", "U") != 0) throw new InvalidOperationException("StrUtil-Count2"); if(StrUtil.Count("AAAAA", "AA") != 4) throw new InvalidOperationException("StrUtil-Count3"); const string sU = "data:mytype;base64,"; if(!StrUtil.IsDataUri(sU)) throw new InvalidOperationException("StrUtil-DataUri1"); if(!StrUtil.IsDataUri(sU, "mytype")) throw new InvalidOperationException("StrUtil-DataUri2"); if(StrUtil.IsDataUri(sU, "notmytype")) throw new InvalidOperationException("StrUtil-DataUri3"); uint u = 0x7FFFFFFFU; if(u.ToString(NumberFormatInfo.InvariantInfo) != "2147483647") throw new InvalidOperationException("StrUtil-Inv1"); if(uint.MaxValue.ToString(NumberFormatInfo.InvariantInfo) != "4294967295") throw new InvalidOperationException("StrUtil-Inv2"); if(long.MinValue.ToString(NumberFormatInfo.InvariantInfo) != "-9223372036854775808") throw new InvalidOperationException("StrUtil-Inv3"); if(short.MinValue.ToString(NumberFormatInfo.InvariantInfo) != "-32768") throw new InvalidOperationException("StrUtil-Inv4"); #endif } private static void TestUrlUtil() { #if DEBUG if(UrlUtil.GetHost(@"scheme://domain:port/path?query_string#fragment_id") != "domain") throw new InvalidOperationException("UrlUtil-H1"); if(UrlUtil.GetHost(@"http://example.org:80") != "example.org") throw new InvalidOperationException("UrlUtil-H2"); if(UrlUtil.GetHost(@"mailto:bob@example.com") != "example.com") throw new InvalidOperationException("UrlUtil-H3"); if(UrlUtil.GetHost(@"ftp://asmith@ftp.example.org") != "ftp.example.org") throw new InvalidOperationException("UrlUtil-H4"); if(UrlUtil.GetHost(@"scheme://username:password@domain:port/path?query_string#fragment_id") != "domain") throw new InvalidOperationException("UrlUtil-H5"); if(UrlUtil.GetHost(@"bob@example.com") != "example.com") throw new InvalidOperationException("UrlUtil-H6"); if(UrlUtil.GetHost(@"s://u:p@d.tld:p/p?q#f") != "d.tld") throw new InvalidOperationException("UrlUtil-H7"); if(NativeLib.IsUnix()) return; string strBase = "\\\\HOMESERVER\\Apps\\KeePass\\KeePass.exe"; string strDoc = "\\\\HOMESERVER\\Documents\\KeePass\\NewDatabase.kdbx"; string strRel = "..\\..\\Documents\\KeePass\\NewDatabase.kdbx"; string str = UrlUtil.MakeRelativePath(strBase, strDoc); if(!str.Equals(strRel)) throw new InvalidOperationException("UrlUtil-R1"); str = UrlUtil.MakeAbsolutePath(strBase, strRel); if(!str.Equals(strDoc)) throw new InvalidOperationException("UrlUtil-R2"); str = UrlUtil.GetQuotedAppPath(" \"Test\" \"%1\" "); if(str != "Test") throw new InvalidOperationException("UrlUtil-Q1"); str = UrlUtil.GetQuotedAppPath("C:\\Program Files\\Test.exe"); if(str != "C:\\Program Files\\Test.exe") throw new InvalidOperationException("UrlUtil-Q2"); str = UrlUtil.GetQuotedAppPath("Reg.exe \"Test\" \"Test 2\""); if(str != "Reg.exe \"Test\" \"Test 2\"") throw new InvalidOperationException("UrlUtil-Q3"); #endif } } } keepass2-2.25/KeePassLib/Cryptography/CryptoRandomStream.cs0000664000175000017500000001406512261553104023721 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; using System.Security.Cryptography; using KeePassLib.Cryptography.Cipher; namespace KeePassLib.Cryptography { /// /// Algorithms supported by CryptoRandomStream. /// public enum CrsAlgorithm { /// /// Not supported. /// Null = 0, /// /// A variant of the ARCFour algorithm (RC4 incompatible). /// ArcFourVariant = 1, /// /// Salsa20 stream cipher algorithm. /// Salsa20 = 2, Count = 3 } /// /// A random stream class. The class is initialized using random /// bytes provided by the caller. The produced stream has random /// properties, but for the same seed always the same stream /// is produced, i.e. this class can be used as stream cipher. /// public sealed class CryptoRandomStream { private CrsAlgorithm m_crsAlgorithm; private byte[] m_pbState = null; private byte m_i = 0; private byte m_j = 0; private Salsa20Cipher m_salsa20 = null; /// /// Construct a new cryptographically secure random stream object. /// /// Algorithm to use. /// Initialization key. Must not be null and /// must contain at least 1 byte. /// Thrown if the /// parameter is null. /// Thrown if the /// parameter contains no bytes or the /// algorithm is unknown. public CryptoRandomStream(CrsAlgorithm genAlgorithm, byte[] pbKey) { m_crsAlgorithm = genAlgorithm; Debug.Assert(pbKey != null); if(pbKey == null) throw new ArgumentNullException("pbKey"); uint uKeyLen = (uint)pbKey.Length; Debug.Assert(uKeyLen != 0); if(uKeyLen == 0) throw new ArgumentException(); if(genAlgorithm == CrsAlgorithm.ArcFourVariant) { // Fill the state linearly m_pbState = new byte[256]; for(uint w = 0; w < 256; ++w) m_pbState[w] = (byte)w; unchecked { byte j = 0, t; uint inxKey = 0; for(uint w = 0; w < 256; ++w) // Key setup { j += (byte)(m_pbState[w] + pbKey[inxKey]); t = m_pbState[0]; // Swap entries m_pbState[0] = m_pbState[j]; m_pbState[j] = t; ++inxKey; if(inxKey >= uKeyLen) inxKey = 0; } } GetRandomBytes(512); // Increases security, see cryptanalysis } else if(genAlgorithm == CrsAlgorithm.Salsa20) { SHA256Managed sha256 = new SHA256Managed(); byte[] pbKey32 = sha256.ComputeHash(pbKey); byte[] pbIV = new byte[]{ 0xE8, 0x30, 0x09, 0x4B, 0x97, 0x20, 0x5D, 0x2A }; // Unique constant m_salsa20 = new Salsa20Cipher(pbKey32, pbIV); } else // Unknown algorithm { Debug.Assert(false); throw new ArgumentException(); } } /// /// Get random bytes. /// /// Number of random bytes to retrieve. /// Returns random bytes. public byte[] GetRandomBytes(uint uRequestedCount) { if(uRequestedCount == 0) return new byte[0]; byte[] pbRet = new byte[uRequestedCount]; if(m_crsAlgorithm == CrsAlgorithm.ArcFourVariant) { unchecked { for(uint w = 0; w < uRequestedCount; ++w) { ++m_i; m_j += m_pbState[m_i]; byte t = m_pbState[m_i]; // Swap entries m_pbState[m_i] = m_pbState[m_j]; m_pbState[m_j] = t; t = (byte)(m_pbState[m_i] + m_pbState[m_j]); pbRet[w] = m_pbState[t]; } } } else if(m_crsAlgorithm == CrsAlgorithm.Salsa20) m_salsa20.Encrypt(pbRet, pbRet.Length, false); else { Debug.Assert(false); } return pbRet; } public ulong GetRandomUInt64() { byte[] pb = GetRandomBytes(8); unchecked { return ((ulong)pb[0]) | ((ulong)pb[1] << 8) | ((ulong)pb[2] << 16) | ((ulong)pb[3] << 24) | ((ulong)pb[4] << 32) | ((ulong)pb[5] << 40) | ((ulong)pb[6] << 48) | ((ulong)pb[7] << 56); } } #if CRSBENCHMARK public static string Benchmark() { int nRounds = 2000000; string str = "ArcFour small: " + BenchTime(CrsAlgorithm.ArcFourVariant, nRounds, 16).ToString() + "\r\n"; str += "ArcFour big: " + BenchTime(CrsAlgorithm.ArcFourVariant, 32, 2 * 1024 * 1024).ToString() + "\r\n"; str += "Salsa20 small: " + BenchTime(CrsAlgorithm.Salsa20, nRounds, 16).ToString() + "\r\n"; str += "Salsa20 big: " + BenchTime(CrsAlgorithm.Salsa20, 32, 2 * 1024 * 1024).ToString(); return str; } private static int BenchTime(CrsAlgorithm cra, int nRounds, int nDataSize) { byte[] pbKey = new byte[4] { 0x00, 0x01, 0x02, 0x03 }; int nStart = Environment.TickCount; for(int i = 0; i < nRounds; ++i) { CryptoRandomStream c = new CryptoRandomStream(cra, pbKey); c.GetRandomBytes((uint)nDataSize); } int nEnd = Environment.TickCount; return (nEnd - nStart); } #endif } } keepass2-2.25/KeePassLib/Cryptography/HmacOtp.cs0000664000175000017500000000554512261553104021462 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Cryptography; using System.Globalization; using KeePassLib.Utility; #if (!KeePassLibSD && !KeePassRT) namespace KeePassLib.Cryptography { /// /// Generate HMAC-based one-time passwords as specified in RFC 4226. /// public static class HmacOtp { private static readonly uint[] vDigitsPower = new uint[]{ 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 }; public static string Generate(byte[] pbSecret, ulong uFactor, uint uCodeDigits, bool bAddChecksum, int iTruncationOffset) { byte[] pbText = MemUtil.UInt64ToBytes(uFactor); Array.Reverse(pbText); // Big-Endian HMACSHA1 hsha1 = new HMACSHA1(pbSecret); byte[] pbHash = hsha1.ComputeHash(pbText); uint uOffset = (uint)(pbHash[pbHash.Length - 1] & 0xF); if((iTruncationOffset >= 0) && (iTruncationOffset < (pbHash.Length - 4))) uOffset = (uint)iTruncationOffset; uint uBinary = (uint)(((pbHash[uOffset] & 0x7F) << 24) | ((pbHash[uOffset + 1] & 0xFF) << 16) | ((pbHash[uOffset + 2] & 0xFF) << 8) | (pbHash[uOffset + 3] & 0xFF)); uint uOtp = (uBinary % vDigitsPower[uCodeDigits]); if(bAddChecksum) uOtp = ((uOtp * 10) + CalculateChecksum(uOtp, uCodeDigits)); uint uDigits = (bAddChecksum ? (uCodeDigits + 1) : uCodeDigits); return uOtp.ToString(NumberFormatInfo.InvariantInfo).PadLeft( (int)uDigits, '0'); } private static readonly uint[] vDoubleDigits = new uint[]{ 0, 2, 4, 6, 8, 1, 3, 5, 7, 9 }; private static uint CalculateChecksum(uint uNum, uint uDigits) { bool bDoubleDigit = true; uint uTotal = 0; while(0 < uDigits--) { uint uDigit = (uNum % 10); uNum /= 10; if(bDoubleDigit) uDigit = vDoubleDigits[uDigit]; uTotal += uDigit; bDoubleDigit = !bDoubleDigit; } uint uResult = (uTotal % 10); if(uResult != 0) uResult = 10 - uResult; return uResult; } } } #endif keepass2-2.25/KeePassLib/Cryptography/PasswordGenerator/0000775000175000017500000000000012261553104023240 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLib/Cryptography/PasswordGenerator/CustomPwGeneratorPool.cs0000664000175000017500000000530012261553104030047 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; using System.Collections.Generic; using System.Text; namespace KeePassLib.Cryptography.PasswordGenerator { public sealed class CustomPwGeneratorPool : IEnumerable { private List m_vGens = new List(); public int Count { get { return m_vGens.Count; } } public CustomPwGeneratorPool() { } IEnumerator IEnumerable.GetEnumerator() { return m_vGens.GetEnumerator(); } public IEnumerator GetEnumerator() { return m_vGens.GetEnumerator(); } public void Add(CustomPwGenerator pwg) { if(pwg == null) throw new ArgumentNullException("pwg"); PwUuid uuid = pwg.Uuid; if(uuid == null) throw new ArgumentException(); int nIndex = FindIndex(uuid); if(nIndex >= 0) m_vGens[nIndex] = pwg; // Replace else m_vGens.Add(pwg); } public CustomPwGenerator Find(PwUuid uuid) { if(uuid == null) throw new ArgumentNullException("uuid"); foreach(CustomPwGenerator pwg in m_vGens) { if(uuid.Equals(pwg.Uuid)) return pwg; } return null; } public CustomPwGenerator Find(string strName) { if(strName == null) throw new ArgumentNullException("strName"); foreach(CustomPwGenerator pwg in m_vGens) { if(pwg.Name == strName) return pwg; } return null; } private int FindIndex(PwUuid uuid) { if(uuid == null) throw new ArgumentNullException("uuid"); for(int i = 0; i < m_vGens.Count; ++i) { if(uuid.Equals(m_vGens[i].Uuid)) return i; } return -1; } public bool Remove(PwUuid uuid) { if(uuid == null) throw new ArgumentNullException("uuid"); int nIndex = FindIndex(uuid); if(nIndex < 0) return false; m_vGens.RemoveAt(nIndex); return true; } } } keepass2-2.25/KeePassLib/Cryptography/PasswordGenerator/CustomPwGenerator.cs0000664000175000017500000000424112261553104027220 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePassLib; using KeePassLib.Security; namespace KeePassLib.Cryptography.PasswordGenerator { public abstract class CustomPwGenerator { /// /// Each custom password generation algorithm must have /// its own unique UUID. /// public abstract PwUuid Uuid { get; } /// /// Displayable name of the password generation algorithm. /// public abstract string Name { get; } public virtual bool SupportsOptions { get { return false; } } /// /// Password generation function. /// /// Password generation options chosen /// by the user. This may be null, if the default /// options should be used. /// Source that the algorithm /// can use to generate random numbers. /// Generated password or null in case /// of failure. If returning null, the caller assumes /// that an error message has already been shown to the user. public abstract ProtectedString Generate(PwProfile prf, CryptoRandomStream crsRandomSource); public virtual string GetOptions(string strCurrentOptions) { return string.Empty; } } } keepass2-2.25/KeePassLib/Cryptography/PasswordGenerator/CharSetBasedGenerator.cs0000664000175000017500000000403212261553104027725 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePassLib.Security; using KeePassLib.Utility; namespace KeePassLib.Cryptography.PasswordGenerator { internal static class CharSetBasedGenerator { internal static PwgError Generate(out ProtectedString psOut, PwProfile pwProfile, CryptoRandomStream crsRandomSource) { psOut = ProtectedString.Empty; if(pwProfile.Length == 0) return PwgError.Success; PwCharSet pcs = new PwCharSet(pwProfile.CharSet.ToString()); char[] vGenerated = new char[pwProfile.Length]; PwGenerator.PrepareCharSet(pcs, pwProfile); for(int nIndex = 0; nIndex < (int)pwProfile.Length; ++nIndex) { char ch = PwGenerator.GenerateCharacter(pwProfile, pcs, crsRandomSource); if(ch == char.MinValue) { Array.Clear(vGenerated, 0, vGenerated.Length); return PwgError.TooFewCharacters; } vGenerated[nIndex] = ch; } byte[] pbUtf8 = StrUtil.Utf8.GetBytes(vGenerated); psOut = new ProtectedString(true, pbUtf8); MemUtil.ZeroByteArray(pbUtf8); Array.Clear(vGenerated, 0, vGenerated.Length); return PwgError.Success; } } } keepass2-2.25/KeePassLib/Cryptography/PasswordGenerator/PwGenerator.cs0000664000175000017500000001147412261553104026033 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePassLib.Security; namespace KeePassLib.Cryptography.PasswordGenerator { public enum PwgError { Success = 0, Unknown = 1, TooFewCharacters = 2, UnknownAlgorithm = 3 } /// /// Utility functions for generating random passwords. /// public static class PwGenerator { public static PwgError Generate(out ProtectedString psOut, PwProfile pwProfile, byte[] pbUserEntropy, CustomPwGeneratorPool pwAlgorithmPool) { Debug.Assert(pwProfile != null); if(pwProfile == null) throw new ArgumentNullException("pwProfile"); CryptoRandomStream crs = CreateCryptoStream(pbUserEntropy); PwgError e = PwgError.Unknown; if(pwProfile.GeneratorType == PasswordGeneratorType.CharSet) e = CharSetBasedGenerator.Generate(out psOut, pwProfile, crs); else if(pwProfile.GeneratorType == PasswordGeneratorType.Pattern) e = PatternBasedGenerator.Generate(out psOut, pwProfile, crs); else if(pwProfile.GeneratorType == PasswordGeneratorType.Custom) e = GenerateCustom(out psOut, pwProfile, crs, pwAlgorithmPool); else { Debug.Assert(false); psOut = ProtectedString.Empty; } return e; } private static CryptoRandomStream CreateCryptoStream(byte[] pbAdditionalEntropy) { byte[] pbKey = CryptoRandom.Instance.GetRandomBytes(256); // Mix in additional entropy if((pbAdditionalEntropy != null) && (pbAdditionalEntropy.Length > 0)) { for(int nKeyPos = 0; nKeyPos < pbKey.Length; ++nKeyPos) pbKey[nKeyPos] ^= pbAdditionalEntropy[nKeyPos % pbAdditionalEntropy.Length]; } return new CryptoRandomStream(CrsAlgorithm.Salsa20, pbKey); } internal static char GenerateCharacter(PwProfile pwProfile, PwCharSet pwCharSet, CryptoRandomStream crsRandomSource) { if(pwCharSet.Size == 0) return char.MinValue; ulong uIndex = crsRandomSource.GetRandomUInt64(); uIndex %= (ulong)pwCharSet.Size; char ch = pwCharSet[(uint)uIndex]; if(pwProfile.NoRepeatingCharacters) pwCharSet.Remove(ch); return ch; } internal static void PrepareCharSet(PwCharSet pwCharSet, PwProfile pwProfile) { pwCharSet.Remove(PwCharSet.Invalid); if(pwProfile.ExcludeLookAlike) pwCharSet.Remove(PwCharSet.LookAlike); if(pwProfile.ExcludeCharacters.Length > 0) pwCharSet.Remove(pwProfile.ExcludeCharacters); } internal static void ShufflePassword(char[] pPassword, CryptoRandomStream crsRandomSource) { Debug.Assert(pPassword != null); if(pPassword == null) return; Debug.Assert(crsRandomSource != null); if(crsRandomSource == null) return; if(pPassword.Length <= 1) return; // Nothing to shuffle for(int nSelect = 0; nSelect < pPassword.Length; ++nSelect) { ulong uRandomIndex = crsRandomSource.GetRandomUInt64(); uRandomIndex %= (ulong)(pPassword.Length - nSelect); char chTemp = pPassword[nSelect]; pPassword[nSelect] = pPassword[nSelect + (int)uRandomIndex]; pPassword[nSelect + (int)uRandomIndex] = chTemp; } } private static PwgError GenerateCustom(out ProtectedString psOut, PwProfile pwProfile, CryptoRandomStream crs, CustomPwGeneratorPool pwAlgorithmPool) { psOut = ProtectedString.Empty; Debug.Assert(pwProfile.GeneratorType == PasswordGeneratorType.Custom); if(pwAlgorithmPool == null) return PwgError.UnknownAlgorithm; string strID = pwProfile.CustomAlgorithmUuid; if(string.IsNullOrEmpty(strID)) { Debug.Assert(false); return PwgError.UnknownAlgorithm; } byte[] pbUuid = Convert.FromBase64String(strID); PwUuid uuid = new PwUuid(pbUuid); CustomPwGenerator pwg = pwAlgorithmPool.Find(uuid); if(pwg == null) { Debug.Assert(false); return PwgError.UnknownAlgorithm; } ProtectedString pwd = pwg.Generate(pwProfile.CloneDeep(), crs); if(pwd == null) return PwgError.Unknown; psOut = pwd; return PwgError.Success; } } } keepass2-2.25/KeePassLib/Cryptography/PasswordGenerator/PatternBasedGenerator.cs0000664000175000017500000001100212261553104030004 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePassLib.Security; using KeePassLib.Utility; namespace KeePassLib.Cryptography.PasswordGenerator { internal static class PatternBasedGenerator { internal static PwgError Generate(out ProtectedString psOut, PwProfile pwProfile, CryptoRandomStream crsRandomSource) { psOut = ProtectedString.Empty; LinkedList vGenerated = new LinkedList(); PwCharSet pcsCurrent = new PwCharSet(); PwCharSet pcsCustom = new PwCharSet(); PwCharSet pcsUsed = new PwCharSet(); bool bInCharSetDef = false; string strPattern = ExpandPattern(pwProfile.Pattern); if(strPattern.Length == 0) return PwgError.Success; CharStream csStream = new CharStream(strPattern); char ch = csStream.ReadChar(); while(ch != char.MinValue) { pcsCurrent.Clear(); bool bGenerateChar = false; if(ch == '\\') { ch = csStream.ReadChar(); if(ch == char.MinValue) // Backslash at the end { vGenerated.AddLast('\\'); break; } if(bInCharSetDef) pcsCustom.Add(ch); else { vGenerated.AddLast(ch); pcsUsed.Add(ch); } } else if(ch == '[') { pcsCustom.Clear(); bInCharSetDef = true; } else if(ch == ']') { pcsCurrent.Add(pcsCustom.ToString()); bInCharSetDef = false; bGenerateChar = true; } else if(bInCharSetDef) { if(pcsCustom.AddCharSet(ch) == false) pcsCustom.Add(ch); } else if(pcsCurrent.AddCharSet(ch) == false) { vGenerated.AddLast(ch); pcsUsed.Add(ch); } else bGenerateChar = true; if(bGenerateChar) { PwGenerator.PrepareCharSet(pcsCurrent, pwProfile); if(pwProfile.NoRepeatingCharacters) pcsCurrent.Remove(pcsUsed.ToString()); char chGen = PwGenerator.GenerateCharacter(pwProfile, pcsCurrent, crsRandomSource); if(chGen == char.MinValue) return PwgError.TooFewCharacters; vGenerated.AddLast(chGen); pcsUsed.Add(chGen); } ch = csStream.ReadChar(); } if(vGenerated.Count == 0) return PwgError.Success; char[] vArray = new char[vGenerated.Count]; vGenerated.CopyTo(vArray, 0); if(pwProfile.PatternPermutePassword) PwGenerator.ShufflePassword(vArray, crsRandomSource); byte[] pbUtf8 = StrUtil.Utf8.GetBytes(vArray); psOut = new ProtectedString(true, pbUtf8); MemUtil.ZeroByteArray(pbUtf8); Array.Clear(vArray, 0, vArray.Length); vGenerated.Clear(); return PwgError.Success; } private static string ExpandPattern(string strPattern) { Debug.Assert(strPattern != null); if(strPattern == null) return string.Empty; string str = strPattern; while(true) { int nOpen = FindFirstUnescapedChar(str, '{'); int nClose = FindFirstUnescapedChar(str, '}'); if((nOpen >= 0) && (nOpen < nClose)) { string strCount = str.Substring(nOpen + 1, nClose - nOpen - 1); str = str.Remove(nOpen, nClose - nOpen + 1); uint uRepeat; if(StrUtil.TryParseUInt(strCount, out uRepeat) && (nOpen >= 1)) { if(uRepeat == 0) str = str.Remove(nOpen - 1, 1); else str = str.Insert(nOpen, new string(str[nOpen - 1], (int)uRepeat - 1)); } } else break; } return str; } private static int FindFirstUnescapedChar(string str, char ch) { for(int i = 0; i < str.Length; ++i) { char chCur = str[i]; if(chCur == '\\') ++i; // Next is escaped, skip it else if(chCur == ch) return i; } return -1; } } } keepass2-2.25/KeePassLib/Cryptography/PasswordGenerator/PwCharSet.cs0000664000175000017500000002345612261553104025441 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; namespace KeePassLib.Cryptography.PasswordGenerator { public sealed class PwCharSet { public const string UpperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; public const string LowerCase = "abcdefghijklmnopqrstuvwxyz"; public const string Digits = "0123456789"; public const string UpperConsonants = "BCDFGHJKLMNPQRSTVWXYZ"; public const string LowerConsonants = "bcdfghjklmnpqrstvwxyz"; public const string UpperVowels = "AEIOU"; public const string LowerVowels = "aeiou"; public const string Punctuation = @",.;:"; public const string Brackets = @"[]{}()<>"; public const string PrintableAsciiSpecial = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; public const string UpperHex = "0123456789ABCDEF"; public const string LowerHex = "0123456789abcdef"; public const string Invalid = "\t\r\n"; public const string LookAlike = @"O0l1I|"; private const int CharTabSize = (0x10000 / 8); private List m_vChars = new List(); private byte[] m_vTab = new byte[CharTabSize]; private static string m_strHighAnsi = null; public static string HighAnsiChars { get { if(m_strHighAnsi == null) { new PwCharSet(); } // Create string Debug.Assert(m_strHighAnsi != null); return m_strHighAnsi; } } private static string m_strSpecial = null; public static string SpecialChars { get { if(m_strSpecial == null) { new PwCharSet(); } // Create string Debug.Assert(m_strSpecial != null); return m_strSpecial; } } /// /// Create a new, empty character set collection object. /// public PwCharSet() { Initialize(true); } public PwCharSet(string strCharSet) { Initialize(true); Add(strCharSet); } private PwCharSet(bool bFullInitialize) { Initialize(bFullInitialize); } private void Initialize(bool bFullInitialize) { Clear(); if(!bFullInitialize) return; if(m_strHighAnsi == null) { StringBuilder sbHighAnsi = new StringBuilder(); // [U+0080, U+009F] are C1 control characters, // U+00A0 is non-breaking space for(char ch = '\u00A1'; ch <= '\u00AC'; ++ch) sbHighAnsi.Append(ch); // U+00AD is soft hyphen (format character) for(char ch = '\u00AE'; ch < '\u00FF'; ++ch) sbHighAnsi.Append(ch); sbHighAnsi.Append('\u00FF'); m_strHighAnsi = sbHighAnsi.ToString(); } if(m_strSpecial == null) { PwCharSet pcs = new PwCharSet(false); pcs.AddRange('!', '/'); pcs.AddRange(':', '@'); pcs.AddRange('[', '`'); pcs.Add(@"|~"); pcs.Remove(@"-_ "); pcs.Remove(PwCharSet.Brackets); m_strSpecial = pcs.ToString(); } } /// /// Number of characters in this set. /// public uint Size { get { return (uint)m_vChars.Count; } } /// /// Get a character of the set using an index. /// /// Index of the character to get. /// Character at the specified position. If the index is invalid, /// an ArgumentOutOfRangeException is thrown. public char this[uint uPos] { get { if(uPos >= (uint)m_vChars.Count) throw new ArgumentOutOfRangeException("uPos"); return m_vChars[(int)uPos]; } } /// /// Remove all characters from this set. /// public void Clear() { m_vChars.Clear(); Array.Clear(m_vTab, 0, m_vTab.Length); } public bool Contains(char ch) { return (((m_vTab[ch / 8] >> (ch % 8)) & 1) != char.MinValue); } public bool Contains(string strCharacters) { Debug.Assert(strCharacters != null); if(strCharacters == null) throw new ArgumentNullException("strCharacters"); foreach(char ch in strCharacters) { if(!Contains(ch)) return false; } return true; } /// /// Add characters to the set. /// /// Character to add. public void Add(char ch) { if(ch == char.MinValue) { Debug.Assert(false); return; } if(!Contains(ch)) { m_vChars.Add(ch); m_vTab[ch / 8] |= (byte)(1 << (ch % 8)); } } /// /// Add characters to the set. /// /// String containing characters to add. public void Add(string strCharSet) { Debug.Assert(strCharSet != null); if(strCharSet == null) throw new ArgumentNullException("strCharSet"); m_vChars.Capacity = m_vChars.Count + strCharSet.Length; foreach(char ch in strCharSet) Add(ch); } public void Add(string strCharSet1, string strCharSet2) { Add(strCharSet1); Add(strCharSet2); } public void Add(string strCharSet1, string strCharSet2, string strCharSet3) { Add(strCharSet1); Add(strCharSet2); Add(strCharSet3); } public void AddRange(char chMin, char chMax) { m_vChars.Capacity = m_vChars.Count + (chMax - chMin) + 1; for(char ch = chMin; ch < chMax; ++ch) Add(ch); Add(chMax); } public bool AddCharSet(char chCharSetIdentifier) { bool bResult = true; switch(chCharSetIdentifier) { case 'a': Add(PwCharSet.LowerCase, PwCharSet.Digits); break; case 'A': Add(PwCharSet.LowerCase, PwCharSet.UpperCase, PwCharSet.Digits); break; case 'U': Add(PwCharSet.UpperCase, PwCharSet.Digits); break; case 'c': Add(PwCharSet.LowerConsonants); break; case 'C': Add(PwCharSet.LowerConsonants, PwCharSet.UpperConsonants); break; case 'z': Add(PwCharSet.UpperConsonants); break; case 'd': Add(PwCharSet.Digits); break; // Digit case 'h': Add(PwCharSet.LowerHex); break; case 'H': Add(PwCharSet.UpperHex); break; case 'l': Add(PwCharSet.LowerCase); break; case 'L': Add(PwCharSet.LowerCase, PwCharSet.UpperCase); break; case 'u': Add(PwCharSet.UpperCase); break; case 'p': Add(PwCharSet.Punctuation); break; case 'b': Add(PwCharSet.Brackets); break; case 's': Add(PwCharSet.PrintableAsciiSpecial); break; case 'S': Add(PwCharSet.UpperCase, PwCharSet.LowerCase); Add(PwCharSet.Digits, PwCharSet.PrintableAsciiSpecial); break; case 'v': Add(PwCharSet.LowerVowels); break; case 'V': Add(PwCharSet.LowerVowels, PwCharSet.UpperVowels); break; case 'Z': Add(PwCharSet.UpperVowels); break; case 'x': Add(m_strHighAnsi); break; default: bResult = false; break; } return bResult; } public bool Remove(char ch) { m_vTab[ch / 8] &= (byte)(~(1 << (ch % 8))); return m_vChars.Remove(ch); } public bool Remove(string strCharacters) { Debug.Assert(strCharacters != null); if(strCharacters == null) throw new ArgumentNullException("strCharacters"); bool bResult = true; foreach(char ch in strCharacters) { if(!Remove(ch)) bResult = false; } return bResult; } public bool RemoveIfAllExist(string strCharacters) { Debug.Assert(strCharacters != null); if(strCharacters == null) throw new ArgumentNullException("strCharacters"); if(!Contains(strCharacters)) return false; return Remove(strCharacters); } /// /// Convert the character set to a string containing all its characters. /// /// String containing all character set characters. public override string ToString() { StringBuilder sb = new StringBuilder(); foreach(char ch in m_vChars) sb.Append(ch); return sb.ToString(); } public string PackAndRemoveCharRanges() { StringBuilder sb = new StringBuilder(); sb.Append(RemoveIfAllExist(PwCharSet.UpperCase) ? 'U' : '_'); sb.Append(RemoveIfAllExist(PwCharSet.LowerCase) ? 'L' : '_'); sb.Append(RemoveIfAllExist(PwCharSet.Digits) ? 'D' : '_'); sb.Append(RemoveIfAllExist(m_strSpecial) ? 'S' : '_'); sb.Append(RemoveIfAllExist(PwCharSet.Punctuation) ? 'P' : '_'); sb.Append(RemoveIfAllExist(@"-") ? 'm' : '_'); sb.Append(RemoveIfAllExist(@"_") ? 'u' : '_'); sb.Append(RemoveIfAllExist(@" ") ? 's' : '_'); sb.Append(RemoveIfAllExist(PwCharSet.Brackets) ? 'B' : '_'); sb.Append(RemoveIfAllExist(m_strHighAnsi) ? 'H' : '_'); return sb.ToString(); } public void UnpackCharRanges(string strRanges) { if(strRanges == null) { Debug.Assert(false); return; } if(strRanges.Length < 10) { Debug.Assert(false); return; } if(strRanges[0] != '_') Add(PwCharSet.UpperCase); if(strRanges[1] != '_') Add(PwCharSet.LowerCase); if(strRanges[2] != '_') Add(PwCharSet.Digits); if(strRanges[3] != '_') Add(m_strSpecial); if(strRanges[4] != '_') Add(PwCharSet.Punctuation); if(strRanges[5] != '_') Add('-'); if(strRanges[6] != '_') Add('_'); if(strRanges[7] != '_') Add(' '); if(strRanges[8] != '_') Add(PwCharSet.Brackets); if(strRanges[9] != '_') Add(m_strHighAnsi); } } } keepass2-2.25/KeePassLib/Cryptography/PasswordGenerator/PwProfile.cs0000664000175000017500000001641212261553104025502 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml.Serialization; using System.ComponentModel; using System.Diagnostics; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePassLib.Cryptography.PasswordGenerator { /// /// Type of the password generator. Different types like generators /// based on given patterns, based on character sets, etc. are /// available. /// public enum PasswordGeneratorType { /// /// Generator based on character spaces/sets, i.e. groups /// of characters like lower-case, upper-case or numeric characters. /// CharSet = 0, /// /// Password generation based on a pattern. The user has provided /// a pattern, which describes how the generated password has to /// look like. /// Pattern = 1, Custom = 2 } public sealed class PwProfile : IDeepCloneable { private string m_strName = string.Empty; [DefaultValue("")] public string Name { get { return m_strName; } set { m_strName = value; } } private PasswordGeneratorType m_type = PasswordGeneratorType.CharSet; public PasswordGeneratorType GeneratorType { get { return m_type; } set { m_type = value; } } private bool m_bUserEntropy = false; [DefaultValue(false)] public bool CollectUserEntropy { get { return m_bUserEntropy; } set { m_bUserEntropy = value; } } private uint m_uLength = 20; public uint Length { get { return m_uLength; } set { m_uLength = value; } } private PwCharSet m_pwCharSet = new PwCharSet(PwCharSet.UpperCase + PwCharSet.LowerCase + PwCharSet.Digits); [XmlIgnore] public PwCharSet CharSet { get { return m_pwCharSet; } set { if(value == null) throw new ArgumentNullException("value"); m_pwCharSet = value; } } private string m_strCharSetRanges = string.Empty; [DefaultValue("")] public string CharSetRanges { get { this.UpdateCharSet(true); return m_strCharSetRanges; } set { if(value == null) throw new ArgumentNullException("value"); m_strCharSetRanges = value; this.UpdateCharSet(false); } } private string m_strCharSetAdditional = string.Empty; [DefaultValue("")] public string CharSetAdditional { get { this.UpdateCharSet(true); return m_strCharSetAdditional; } set { if(value == null) throw new ArgumentNullException("value"); m_strCharSetAdditional = value; this.UpdateCharSet(false); } } private string m_strPattern = string.Empty; [DefaultValue("")] public string Pattern { get { return m_strPattern; } set { m_strPattern = value; } } private bool m_bPatternPermute = false; [DefaultValue(false)] public bool PatternPermutePassword { get { return m_bPatternPermute; } set { m_bPatternPermute = value; } } private bool m_bNoLookAlike = false; [DefaultValue(false)] public bool ExcludeLookAlike { get { return m_bNoLookAlike; } set { m_bNoLookAlike = value; } } private bool m_bNoRepeat = false; [DefaultValue(false)] public bool NoRepeatingCharacters { get { return m_bNoRepeat; } set { m_bNoRepeat = value; } } private string m_strExclude = string.Empty; [DefaultValue("")] public string ExcludeCharacters { get { return m_strExclude; } set { if(value == null) throw new ArgumentNullException("value"); m_strExclude = value; } } private string m_strCustomID = string.Empty; [DefaultValue("")] public string CustomAlgorithmUuid { get { return m_strCustomID; } set { if(value == null) throw new ArgumentNullException("value"); m_strCustomID = value; } } private string m_strCustomOpt = string.Empty; [DefaultValue("")] public string CustomAlgorithmOptions { get { return m_strCustomOpt; } set { if(value == null) throw new ArgumentNullException("value"); m_strCustomOpt = value; } } public PwProfile() { } public PwProfile CloneDeep() { PwProfile p = new PwProfile(); p.m_strName = m_strName; p.m_type = m_type; p.m_bUserEntropy = m_bUserEntropy; p.m_uLength = m_uLength; p.m_pwCharSet = new PwCharSet(m_pwCharSet.ToString()); p.m_strCharSetRanges = m_strCharSetRanges; p.m_strCharSetAdditional = m_strCharSetAdditional; p.m_strPattern = m_strPattern; p.m_bPatternPermute = m_bPatternPermute; p.m_bNoLookAlike = m_bNoLookAlike; p.m_bNoRepeat = m_bNoRepeat; p.m_strExclude = m_strExclude; p.m_strCustomID = m_strCustomID; p.m_strCustomOpt = m_strCustomOpt; return p; } private void UpdateCharSet(bool bSetXml) { if(bSetXml) { PwCharSet pcs = new PwCharSet(m_pwCharSet.ToString()); m_strCharSetRanges = pcs.PackAndRemoveCharRanges(); m_strCharSetAdditional = pcs.ToString(); } else { PwCharSet pcs = new PwCharSet(m_strCharSetAdditional); pcs.UnpackCharRanges(m_strCharSetRanges); m_pwCharSet = pcs; } } public static PwProfile DeriveFromPassword(ProtectedString psPassword) { PwProfile pp = new PwProfile(); Debug.Assert(psPassword != null); if(psPassword == null) return pp; byte[] pbUtf8 = psPassword.ReadUtf8(); char[] vChars = StrUtil.Utf8.GetChars(pbUtf8); pp.GeneratorType = PasswordGeneratorType.CharSet; pp.Length = (uint)vChars.Length; PwCharSet pcs = pp.CharSet; pcs.Clear(); foreach(char ch in vChars) { if((ch >= 'A') && (ch <= 'Z')) pcs.Add(PwCharSet.UpperCase); else if((ch >= 'a') && (ch <= 'z')) pcs.Add(PwCharSet.LowerCase); else if((ch >= '0') && (ch <= '9')) pcs.Add(PwCharSet.Digits); else if(PwCharSet.SpecialChars.IndexOf(ch) >= 0) pcs.Add(PwCharSet.SpecialChars); else if(ch == ' ') pcs.Add(' '); else if(ch == '-') pcs.Add('-'); else if(ch == '_') pcs.Add('_'); else if(PwCharSet.Brackets.IndexOf(ch) >= 0) pcs.Add(PwCharSet.Brackets); else if(PwCharSet.HighAnsiChars.IndexOf(ch) >= 0) pcs.Add(PwCharSet.HighAnsiChars); else pcs.Add(ch); } Array.Clear(vChars, 0, vChars.Length); MemUtil.ZeroByteArray(pbUtf8); return pp; } public bool HasSecurityReducingOption() { return (m_bNoLookAlike || m_bNoRepeat || (m_strExclude.Length > 0)); } } } keepass2-2.25/KeePassLib/Cryptography/CryptoRandom.cs0000664000175000017500000002131712265454114022550 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Security.Cryptography; using System.IO; using System.Diagnostics; using System.Windows.Forms; using System.Drawing; using KeePassLib.Native; using KeePassLib.Utility; namespace KeePassLib.Cryptography { /// /// Cryptographically strong random number generator. The returned values /// are unpredictable and cannot be reproduced. /// CryptoRandom is a singleton class. /// public sealed class CryptoRandom { private byte[] m_pbEntropyPool = new byte[64]; private uint m_uCounter; private RNGCryptoServiceProvider m_rng = new RNGCryptoServiceProvider(); private ulong m_uGeneratedBytesCount = 0; private object m_oSyncRoot = new object(); private static CryptoRandom m_pInstance = null; public static CryptoRandom Instance { get { if(m_pInstance != null) return m_pInstance; m_pInstance = new CryptoRandom(); return m_pInstance; } } /// /// Get the number of random bytes that this instance generated so far. /// Note that this number can be higher than the number of random bytes /// actually requested using the GetRandomBytes method. /// public ulong GeneratedBytesCount { get { ulong u; lock(m_oSyncRoot) { u = m_uGeneratedBytesCount; } return u; } } /// /// Event that is triggered whenever the internal GenerateRandom256 /// method is called to generate random bytes. /// public event EventHandler GenerateRandom256Pre; private CryptoRandom() { Random r = new Random(); m_uCounter = (uint)r.Next(); AddEntropy(GetSystemData(r)); AddEntropy(GetCspData()); } /// /// Update the internal seed of the random number generator based /// on entropy data. /// This method is thread-safe. /// /// Entropy bytes. public void AddEntropy(byte[] pbEntropy) { if(pbEntropy == null) { Debug.Assert(false); return; } if(pbEntropy.Length == 0) { Debug.Assert(false); return; } byte[] pbNewData = pbEntropy; if(pbEntropy.Length >= 64) { #if !KeePassLibSD SHA512Managed shaNew = new SHA512Managed(); #else SHA256Managed shaNew = new SHA256Managed(); #endif pbNewData = shaNew.ComputeHash(pbEntropy); } MemoryStream ms = new MemoryStream(); lock(m_oSyncRoot) { ms.Write(m_pbEntropyPool, 0, m_pbEntropyPool.Length); ms.Write(pbNewData, 0, pbNewData.Length); byte[] pbFinal = ms.ToArray(); #if !KeePassLibSD Debug.Assert(pbFinal.Length == (64 + pbNewData.Length)); SHA512Managed shaPool = new SHA512Managed(); #else SHA256Managed shaPool = new SHA256Managed(); #endif m_pbEntropyPool = shaPool.ComputeHash(pbFinal); } ms.Close(); } private static byte[] GetSystemData(Random rWeak) { MemoryStream ms = new MemoryStream(); byte[] pb; pb = MemUtil.UInt32ToBytes((uint)Environment.TickCount); ms.Write(pb, 0, pb.Length); pb = TimeUtil.PackTime(DateTime.Now); ms.Write(pb, 0, pb.Length); #if (!KeePassLibSD && !KeePassRT) // In try-catch for systems without GUI; // https://sourceforge.net/p/keepass/discussion/329221/thread/20335b73/ try { Point pt = Cursor.Position; pb = MemUtil.UInt32ToBytes((uint)pt.X); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt32ToBytes((uint)pt.Y); ms.Write(pb, 0, pb.Length); } catch(Exception) { } #endif pb = MemUtil.UInt32ToBytes((uint)rWeak.Next()); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt32ToBytes((uint)NativeLib.GetPlatformID()); ms.Write(pb, 0, pb.Length); #if (!KeePassLibSD && !KeePassRT) Process p = null; try { pb = MemUtil.UInt32ToBytes((uint)Environment.ProcessorCount); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)Environment.WorkingSet); ms.Write(pb, 0, pb.Length); Version v = Environment.OSVersion.Version; int nv = (v.Major << 28) + (v.MajorRevision << 24) + (v.Minor << 20) + (v.MinorRevision << 16) + (v.Revision << 12) + v.Build; pb = MemUtil.UInt32ToBytes((uint)nv); ms.Write(pb, 0, pb.Length); p = Process.GetCurrentProcess(); pb = MemUtil.UInt64ToBytes((ulong)p.Handle.ToInt64()); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt32ToBytes((uint)p.HandleCount); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt32ToBytes((uint)p.Id); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.NonpagedSystemMemorySize64); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.PagedMemorySize64); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.PagedSystemMemorySize64); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.PeakPagedMemorySize64); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.PeakVirtualMemorySize64); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.PeakWorkingSet64); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.PrivateMemorySize64); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.StartTime.ToBinary()); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.VirtualMemorySize64); ms.Write(pb, 0, pb.Length); pb = MemUtil.UInt64ToBytes((ulong)p.WorkingSet64); ms.Write(pb, 0, pb.Length); // Not supported in Mono 1.2.6: // pb = MemUtil.UInt32ToBytes((uint)p.SessionId); // ms.Write(pb, 0, pb.Length); } catch(Exception) { } finally { try { if(p != null) p.Dispose(); } catch(Exception) { Debug.Assert(false); } } #endif pb = Guid.NewGuid().ToByteArray(); ms.Write(pb, 0, pb.Length); byte[] pbAll = ms.ToArray(); ms.Close(); return pbAll; } private byte[] GetCspData() { byte[] pbCspRandom = new byte[32]; m_rng.GetBytes(pbCspRandom); return pbCspRandom; } private byte[] GenerateRandom256() { if(this.GenerateRandom256Pre != null) this.GenerateRandom256Pre(this, EventArgs.Empty); byte[] pbFinal; lock(m_oSyncRoot) { unchecked { m_uCounter += 386047; } // Prime number byte[] pbCounter = MemUtil.UInt32ToBytes(m_uCounter); byte[] pbCspRandom = GetCspData(); MemoryStream ms = new MemoryStream(); ms.Write(m_pbEntropyPool, 0, m_pbEntropyPool.Length); ms.Write(pbCounter, 0, pbCounter.Length); ms.Write(pbCspRandom, 0, pbCspRandom.Length); pbFinal = ms.ToArray(); Debug.Assert(pbFinal.Length == (m_pbEntropyPool.Length + pbCounter.Length + pbCspRandom.Length)); ms.Close(); m_uGeneratedBytesCount += 32; } SHA256Managed sha256 = new SHA256Managed(); return sha256.ComputeHash(pbFinal); } /// /// Get a number of cryptographically strong random bytes. /// This method is thread-safe. /// /// Number of requested random bytes. /// A byte array consisting of /// random bytes. public byte[] GetRandomBytes(uint uRequestedBytes) { if(uRequestedBytes == 0) return new byte[0]; // Allow zero-length array byte[] pbRes = new byte[uRequestedBytes]; long lPos = 0; while(uRequestedBytes != 0) { byte[] pbRandom256 = GenerateRandom256(); Debug.Assert(pbRandom256.Length == 32); long lCopy = (long)((uRequestedBytes < 32) ? uRequestedBytes : 32); #if (!KeePassLibSD && !KeePassRT) Array.Copy(pbRandom256, 0, pbRes, lPos, lCopy); #else Array.Copy(pbRandom256, 0, pbRes, (int)lPos, (int)lCopy); #endif lPos += lCopy; uRequestedBytes -= (uint)lCopy; } Debug.Assert((int)lPos == pbRes.Length); return pbRes; } } } keepass2-2.25/KeePassLib/Cryptography/HashingStreamEx.cs0000664000175000017500000001102012261553104023142 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using KeePassLib.Utility; namespace KeePassLib.Cryptography { public sealed class HashingStreamEx : Stream { private Stream m_sBaseStream; private bool m_bWriting; private HashAlgorithm m_hash; private byte[] m_pbFinalHash = null; public byte[] Hash { get { return m_pbFinalHash; } } public override bool CanRead { get { return !m_bWriting; } } public override bool CanSeek { get { return false; } } public override bool CanWrite { get { return m_bWriting; } } public override long Length { get { return m_sBaseStream.Length; } } public override long Position { get { return m_sBaseStream.Position; } set { throw new NotSupportedException(); } } public HashingStreamEx(Stream sBaseStream, bool bWriting, HashAlgorithm hashAlgorithm) { if(sBaseStream == null) throw new ArgumentNullException("sBaseStream"); m_sBaseStream = sBaseStream; m_bWriting = bWriting; #if !KeePassLibSD m_hash = (hashAlgorithm ?? new SHA256Managed()); #else // KeePassLibSD m_hash = null; try { m_hash = HashAlgorithm.Create("SHA256"); } catch(Exception) { } try { if(m_hash == null) m_hash = HashAlgorithm.Create(); } catch(Exception) { } #endif if(m_hash == null) { Debug.Assert(false); return; } // Validate hash algorithm if((!m_hash.CanReuseTransform) || (!m_hash.CanTransformMultipleBlocks) || (m_hash.InputBlockSize != 1) || (m_hash.OutputBlockSize != 1)) { #if DEBUG MessageService.ShowWarning("Broken HashAlgorithm object in HashingStreamEx."); #endif m_hash = null; } } public override void Flush() { m_sBaseStream.Flush(); } #if KeePassRT protected override void Dispose(bool disposing) { if(!disposing) return; #else public override void Close() { #endif if(m_hash != null) { try { m_hash.TransformFinalBlock(new byte[0], 0, 0); m_pbFinalHash = m_hash.Hash; } catch(Exception) { Debug.Assert(false); } m_hash = null; } m_sBaseStream.Close(); } public override long Seek(long lOffset, SeekOrigin soOrigin) { throw new NotSupportedException(); } public override void SetLength(long lValue) { throw new NotSupportedException(); } public override int Read(byte[] pbBuffer, int nOffset, int nCount) { if(m_bWriting) throw new InvalidOperationException(); int nRead = m_sBaseStream.Read(pbBuffer, nOffset, nCount); int nPartialRead = nRead; while((nRead < nCount) && (nPartialRead != 0)) { nPartialRead = m_sBaseStream.Read(pbBuffer, nOffset + nRead, nCount - nRead); nRead += nPartialRead; } #if DEBUG byte[] pbOrg = new byte[pbBuffer.Length]; Array.Copy(pbBuffer, pbOrg, pbBuffer.Length); #endif if((m_hash != null) && (nRead > 0)) m_hash.TransformBlock(pbBuffer, nOffset, nRead, pbBuffer, nOffset); #if DEBUG Debug.Assert(MemUtil.ArraysEqual(pbBuffer, pbOrg)); #endif return nRead; } public override void Write(byte[] pbBuffer, int nOffset, int nCount) { if(!m_bWriting) throw new InvalidOperationException(); #if DEBUG byte[] pbOrg = new byte[pbBuffer.Length]; Array.Copy(pbBuffer, pbOrg, pbBuffer.Length); #endif if((m_hash != null) && (nCount > 0)) m_hash.TransformBlock(pbBuffer, nOffset, nCount, pbBuffer, nOffset); #if DEBUG Debug.Assert(MemUtil.ArraysEqual(pbBuffer, pbOrg)); #endif m_sBaseStream.Write(pbBuffer, nOffset, nCount); } } } keepass2-2.25/KeePassLib/PwDeletedObject.cs0000664000175000017500000000451512261553104020434 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using KeePassLib.Interfaces; namespace KeePassLib { /// /// Represents an object that has been deleted. /// public sealed class PwDeletedObject : IDeepCloneable { private PwUuid m_uuid = PwUuid.Zero; /// /// UUID of the entry that has been deleted. /// public PwUuid Uuid { get { return m_uuid; } set { if(value == null) throw new ArgumentNullException("value"); m_uuid = value; } } private DateTime m_dtDeletionTime = PwDefs.DtDefaultNow; /// /// The date/time when the entry has been deleted. /// public DateTime DeletionTime { get { return m_dtDeletionTime; } set { m_dtDeletionTime = value; } } /// /// Construct a new PwDeletedObject object. /// public PwDeletedObject() { } public PwDeletedObject(PwUuid uuid, DateTime dtDeletionTime) { if(uuid == null) throw new ArgumentNullException("uuid"); m_uuid = uuid; m_dtDeletionTime = dtDeletionTime; } /// /// Clone the object. /// /// Value copy of the current object. public PwDeletedObject CloneDeep() { PwDeletedObject pdo = new PwDeletedObject(); pdo.m_uuid = m_uuid; // PwUuid objects are immutable pdo.m_dtDeletionTime = m_dtDeletionTime; return pdo; } } } keepass2-2.25/KeePassLib/PwDatabase.cs0000664000175000017500000014515012261553104017444 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using System.IO; using System.Drawing; using KeePassLib.Collections; using KeePassLib.Cryptography; using KeePassLib.Cryptography.Cipher; using KeePassLib.Delegates; using KeePassLib.Interfaces; using KeePassLib.Keys; using KeePassLib.Resources; using KeePassLib.Security; using KeePassLib.Serialization; using KeePassLib.Utility; namespace KeePassLib { /// /// The core password manager class. It contains a number of groups, which /// contain the actual entries. /// public sealed class PwDatabase { internal const int DefaultHistoryMaxItems = 10; // -1 = unlimited internal const long DefaultHistoryMaxSize = 6 * 1024 * 1024; // -1 = unlimited private static bool m_bPrimaryCreated = false; // Initializations see Clear() private PwGroup m_pgRootGroup = null; private PwObjectList m_vDeletedObjects = new PwObjectList(); private PwUuid m_uuidDataCipher = StandardAesEngine.AesUuid; private PwCompressionAlgorithm m_caCompression = PwCompressionAlgorithm.GZip; private ulong m_uKeyEncryptionRounds = PwDefs.DefaultKeyEncryptionRounds; private CompositeKey m_pwUserKey = null; private MemoryProtectionConfig m_memProtConfig = new MemoryProtectionConfig(); private List m_vCustomIcons = new List(); private bool m_bUINeedsIconUpdate = true; private string m_strName = string.Empty; private DateTime m_dtNameChanged = PwDefs.DtDefaultNow; private string m_strDesc = string.Empty; private DateTime m_dtDescChanged = PwDefs.DtDefaultNow; private string m_strDefaultUserName = string.Empty; private DateTime m_dtDefaultUserChanged = PwDefs.DtDefaultNow; private uint m_uMntncHistoryDays = 365; private Color m_clr = Color.Empty; private DateTime m_dtKeyLastChanged = PwDefs.DtDefaultNow; private long m_lKeyChangeRecDays = -1; private long m_lKeyChangeForceDays = -1; private IOConnectionInfo m_ioSource = new IOConnectionInfo(); private bool m_bDatabaseOpened = false; private bool m_bModified = false; private PwUuid m_pwLastSelectedGroup = PwUuid.Zero; private PwUuid m_pwLastTopVisibleGroup = PwUuid.Zero; private bool m_bUseRecycleBin = true; private PwUuid m_pwRecycleBin = PwUuid.Zero; private DateTime m_dtRecycleBinChanged = PwDefs.DtDefaultNow; private PwUuid m_pwEntryTemplatesGroup = PwUuid.Zero; private DateTime m_dtEntryTemplatesChanged = PwDefs.DtDefaultNow; private int m_nHistoryMaxItems = DefaultHistoryMaxItems; private long m_lHistoryMaxSize = DefaultHistoryMaxSize; // In bytes private StringDictionaryEx m_vCustomData = new StringDictionaryEx(); private byte[] m_pbHashOfFileOnDisk = null; private byte[] m_pbHashOfLastIO = null; private bool m_bUseFileTransactions = false; private bool m_bUseFileLocks = false; private IStatusLogger m_slStatus = null; private static string m_strLocalizedAppName = string.Empty; // private const string StrBackupExtension = ".bak"; /// /// Get the root group that contains all groups and entries stored in the /// database. /// /// Root group. The return value is null, if no database /// has been opened. public PwGroup RootGroup { get { return m_pgRootGroup; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_pgRootGroup = value; } } /// /// IOConnection of the currently opened database file. /// Is never null. /// public IOConnectionInfo IOConnectionInfo { get { return m_ioSource; } } /// /// If this is true, a database is currently open. /// public bool IsOpen { get { return m_bDatabaseOpened; } } /// /// Modification flag. If true, the class has been modified and the /// user interface should prompt the user to save the changes before /// closing the database for example. /// public bool Modified { get { return m_bModified; } set { m_bModified = value; } } /// /// The user key used for database encryption. This key must be created /// and set before using any of the database load/save functions. /// public CompositeKey MasterKey { get { return m_pwUserKey; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_pwUserKey = value; } } /// /// Name of the database. /// public string Name { get { return m_strName; } set { Debug.Assert(value != null); if(value != null) m_strName = value; } } public DateTime NameChanged { get { return m_dtNameChanged; } set { m_dtNameChanged = value; } } /// /// Database description. /// public string Description { get { return m_strDesc; } set { Debug.Assert(value != null); if(value != null) m_strDesc = value; } } public DateTime DescriptionChanged { get { return m_dtDescChanged; } set { m_dtDescChanged = value; } } /// /// Default user name used for new entries. /// public string DefaultUserName { get { return m_strDefaultUserName; } set { Debug.Assert(value != null); if(value != null) m_strDefaultUserName = value; } } public DateTime DefaultUserNameChanged { get { return m_dtDefaultUserChanged; } set { m_dtDefaultUserChanged = value; } } /// /// Number of days until history entries are being deleted /// in a database maintenance operation. /// public uint MaintenanceHistoryDays { get { return m_uMntncHistoryDays; } set { m_uMntncHistoryDays = value; } } public Color Color { get { return m_clr; } set { m_clr = value; } } public DateTime MasterKeyChanged { get { return m_dtKeyLastChanged; } set { m_dtKeyLastChanged = value; } } public long MasterKeyChangeRec { get { return m_lKeyChangeRecDays; } set { m_lKeyChangeRecDays = value; } } public long MasterKeyChangeForce { get { return m_lKeyChangeForceDays; } set { m_lKeyChangeForceDays = value; } } /// /// The encryption algorithm used to encrypt the data part of the database. /// public PwUuid DataCipherUuid { get { return m_uuidDataCipher; } set { Debug.Assert(value != null); if(value != null) m_uuidDataCipher = value; } } /// /// Compression algorithm used to encrypt the data part of the database. /// public PwCompressionAlgorithm Compression { get { return m_caCompression; } set { m_caCompression = value; } } /// /// Number of key transformation rounds (in order to make dictionary /// attacks harder). /// public ulong KeyEncryptionRounds { get { return m_uKeyEncryptionRounds; } set { m_uKeyEncryptionRounds = value; } } /// /// Memory protection configuration (for default fields). /// public MemoryProtectionConfig MemoryProtection { get { return m_memProtConfig; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_memProtConfig = value; } } /// /// Get a list of all deleted objects. /// public PwObjectList DeletedObjects { get { return m_vDeletedObjects; } } /// /// Get all custom icons stored in this database. /// public List CustomIcons { get { return m_vCustomIcons; } } /// /// This is a dirty-flag for the UI. It is used to indicate when an /// icon list update is required. /// public bool UINeedsIconUpdate { get { return m_bUINeedsIconUpdate; } set { m_bUINeedsIconUpdate = value; } } public PwUuid LastSelectedGroup { get { return m_pwLastSelectedGroup; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_pwLastSelectedGroup = value; } } public PwUuid LastTopVisibleGroup { get { return m_pwLastTopVisibleGroup; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_pwLastTopVisibleGroup = value; } } public bool RecycleBinEnabled { get { return m_bUseRecycleBin; } set { m_bUseRecycleBin = value; } } public PwUuid RecycleBinUuid { get { return m_pwRecycleBin; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_pwRecycleBin = value; } } public DateTime RecycleBinChanged { get { return m_dtRecycleBinChanged; } set { m_dtRecycleBinChanged = value; } } /// /// UUID of the group containing template entries. May be /// PwUuid.Zero, if no entry templates group has been specified. /// public PwUuid EntryTemplatesGroup { get { return m_pwEntryTemplatesGroup; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_pwEntryTemplatesGroup = value; } } public DateTime EntryTemplatesGroupChanged { get { return m_dtEntryTemplatesChanged; } set { m_dtEntryTemplatesChanged = value; } } public int HistoryMaxItems { get { return m_nHistoryMaxItems; } set { m_nHistoryMaxItems = value; } } public long HistoryMaxSize { get { return m_lHistoryMaxSize; } set { m_lHistoryMaxSize = value; } } /// /// Custom data container that can be used by plugins to store /// own data in KeePass databases. /// public StringDictionaryEx CustomData { get { return m_vCustomData; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_vCustomData = value; } } /// /// Hash value of the primary file on disk (last read or last write). /// A call to SaveAs without making the saved file primary will /// not change this hash. May be null. /// public byte[] HashOfFileOnDisk { get { return m_pbHashOfFileOnDisk; } } public byte[] HashOfLastIO { get { return m_pbHashOfLastIO; } } public bool UseFileTransactions { get { return m_bUseFileTransactions; } set { m_bUseFileTransactions = value; } } public bool UseFileLocks { get { return m_bUseFileLocks; } set { m_bUseFileLocks = value; } } private string m_strDetachBins = null; /// /// Detach binaries when opening a file. If this isn't null, /// all binaries are saved to the specified path and are removed /// from the database. /// public string DetachBinaries { get { return m_strDetachBins; } set { m_strDetachBins = value; } } /// /// Localized application name. /// public static string LocalizedAppName { get { return m_strLocalizedAppName; } set { Debug.Assert(value != null); m_strLocalizedAppName = value; } } /// /// Constructs an empty password manager object. /// public PwDatabase() { if(m_bPrimaryCreated == false) m_bPrimaryCreated = true; Clear(); } private void Clear() { m_pgRootGroup = null; m_vDeletedObjects = new PwObjectList(); m_uuidDataCipher = StandardAesEngine.AesUuid; m_caCompression = PwCompressionAlgorithm.GZip; m_uKeyEncryptionRounds = PwDefs.DefaultKeyEncryptionRounds; m_pwUserKey = null; m_memProtConfig = new MemoryProtectionConfig(); m_vCustomIcons = new List(); m_bUINeedsIconUpdate = true; DateTime dtNow = DateTime.Now; m_strName = string.Empty; m_dtNameChanged = dtNow; m_strDesc = string.Empty; m_dtDescChanged = dtNow; m_strDefaultUserName = string.Empty; m_dtDefaultUserChanged = dtNow; m_uMntncHistoryDays = 365; m_clr = Color.Empty; m_dtKeyLastChanged = dtNow; m_lKeyChangeRecDays = -1; m_lKeyChangeForceDays = -1; m_ioSource = new IOConnectionInfo(); m_bDatabaseOpened = false; m_bModified = false; m_pwLastSelectedGroup = PwUuid.Zero; m_pwLastTopVisibleGroup = PwUuid.Zero; m_bUseRecycleBin = true; m_pwRecycleBin = PwUuid.Zero; m_dtRecycleBinChanged = dtNow; m_pwEntryTemplatesGroup = PwUuid.Zero; m_dtEntryTemplatesChanged = dtNow; m_nHistoryMaxItems = DefaultHistoryMaxItems; m_lHistoryMaxSize = DefaultHistoryMaxSize; m_vCustomData = new StringDictionaryEx(); m_pbHashOfFileOnDisk = null; m_pbHashOfLastIO = null; m_bUseFileTransactions = false; m_bUseFileLocks = false; } /// /// Initialize the class for managing a new database. Previously loaded /// data is deleted. /// /// IO connection of the new database. /// Key to open the database. public void New(IOConnectionInfo ioConnection, CompositeKey pwKey) { Debug.Assert(ioConnection != null); if(ioConnection == null) throw new ArgumentNullException("ioConnection"); Debug.Assert(pwKey != null); if(pwKey == null) throw new ArgumentNullException("pwKey"); Close(); m_ioSource = ioConnection; m_pwUserKey = pwKey; m_bDatabaseOpened = true; m_bModified = true; m_pgRootGroup = new PwGroup(true, true, UrlUtil.StripExtension(UrlUtil.GetFileName(ioConnection.Path)), PwIcon.FolderOpen); m_pgRootGroup.IsExpanded = true; } /// /// Open a database. The URL may point to any supported data source. /// /// IO connection to load the database from. /// Key used to open the specified database. /// Logger, which gets all status messages. public void Open(IOConnectionInfo ioSource, CompositeKey pwKey, IStatusLogger slLogger) { Debug.Assert(ioSource != null); if(ioSource == null) throw new ArgumentNullException("ioSource"); Debug.Assert(pwKey != null); if(pwKey == null) throw new ArgumentNullException("pwKey"); Close(); try { m_pgRootGroup = new PwGroup(true, true, UrlUtil.StripExtension( UrlUtil.GetFileName(ioSource.Path)), PwIcon.FolderOpen); m_pgRootGroup.IsExpanded = true; m_pwUserKey = pwKey; m_bModified = false; KdbxFile kdbx = new KdbxFile(this); kdbx.DetachBinaries = m_strDetachBins; Stream s = IOConnection.OpenRead(ioSource); kdbx.Load(s, KdbxFormat.Default, slLogger); s.Close(); m_pbHashOfLastIO = kdbx.HashOfFileOnDisk; m_pbHashOfFileOnDisk = kdbx.HashOfFileOnDisk; Debug.Assert(m_pbHashOfFileOnDisk != null); m_bDatabaseOpened = true; m_ioSource = ioSource; } catch(Exception) { Clear(); throw; } } /// /// Save the currently opened database. The file is written to the location /// it has been opened from. /// /// Logger that recieves status information. public void Save(IStatusLogger slLogger) { Debug.Assert(ValidateUuidUniqueness()); FileLock fl = null; if(m_bUseFileLocks) fl = new FileLock(m_ioSource); try { FileTransactionEx ft = new FileTransactionEx(m_ioSource, m_bUseFileTransactions); Stream s = ft.OpenWrite(); KdbxFile kdb = new KdbxFile(this); kdb.Save(s, null, KdbxFormat.Default, slLogger); ft.CommitWrite(); m_pbHashOfLastIO = kdb.HashOfFileOnDisk; m_pbHashOfFileOnDisk = kdb.HashOfFileOnDisk; Debug.Assert(m_pbHashOfFileOnDisk != null); } finally { if(fl != null) fl.Dispose(); } m_bModified = false; } /// /// Save the currently opened database to a different location. If /// is true, the specified /// location is made the default location for future saves /// using SaveDatabase. /// /// New location to serialize the database to. /// If true, the new location is made the /// standard location for the database. If false, a copy of the currently /// opened database is saved to the specified location, but it isn't /// made the default location (i.e. no lock files will be moved for /// example). /// Logger that recieves status information. public void SaveAs(IOConnectionInfo ioConnection, bool bIsPrimaryNow, IStatusLogger slLogger) { Debug.Assert(ioConnection != null); if(ioConnection == null) throw new ArgumentNullException("ioConnection"); IOConnectionInfo ioCurrent = m_ioSource; // Remember current m_ioSource = ioConnection; byte[] pbHashCopy = m_pbHashOfFileOnDisk; try { this.Save(slLogger); } catch(Exception) { m_ioSource = ioCurrent; // Restore m_pbHashOfFileOnDisk = pbHashCopy; m_pbHashOfLastIO = null; throw; } if(!bIsPrimaryNow) { m_ioSource = ioCurrent; // Restore m_pbHashOfFileOnDisk = pbHashCopy; } } /// /// Closes the currently opened database. No confirmation message is shown /// before closing. Unsaved changes will be lost. /// public void Close() { Clear(); } public void MergeIn(PwDatabase pwSource, PwMergeMethod mm) { MergeIn(pwSource, mm, null); } /// /// Synchronize the current database with another one. /// /// Input database to synchronize with. This input /// database is used to update the current one, but is not modified! You /// must copy the current object if you want a second instance of the /// synchronized database. The input database must not be seen as valid /// database any more after calling Synchronize. /// Merge method. /// Logger to report status messages to. /// May be null. public void MergeIn(PwDatabase pwSource, PwMergeMethod mm, IStatusLogger slStatus) { if(pwSource == null) throw new ArgumentNullException("pwSource"); PwGroup pgOrgStructure = m_pgRootGroup.CloneStructure(); PwGroup pgSrcStructure = pwSource.m_pgRootGroup.CloneStructure(); if(mm == PwMergeMethod.CreateNewUuids) pwSource.RootGroup.CreateNewItemUuids(true, true, true); GroupHandler gh = delegate(PwGroup pg) { if(pg == pwSource.m_pgRootGroup) return true; PwGroup pgLocal = m_pgRootGroup.FindGroup(pg.Uuid, true); if(pgLocal == null) { PwGroup pgSourceParent = pg.ParentGroup; PwGroup pgLocalContainer; if(pgSourceParent == pwSource.m_pgRootGroup) pgLocalContainer = m_pgRootGroup; else pgLocalContainer = m_pgRootGroup.FindGroup(pgSourceParent.Uuid, true); Debug.Assert(pgLocalContainer != null); if(pgLocalContainer == null) pgLocalContainer = m_pgRootGroup; PwGroup pgNew = new PwGroup(false, false); pgNew.Uuid = pg.Uuid; pgNew.AssignProperties(pg, false, true); pgLocalContainer.AddGroup(pgNew, true); } else // pgLocal != null { Debug.Assert(mm != PwMergeMethod.CreateNewUuids); if(mm == PwMergeMethod.OverwriteExisting) pgLocal.AssignProperties(pg, false, false); else if((mm == PwMergeMethod.OverwriteIfNewer) || (mm == PwMergeMethod.Synchronize)) { pgLocal.AssignProperties(pg, true, false); } // else if(mm == PwMergeMethod.KeepExisting) ... } return ((slStatus != null) ? slStatus.ContinueWork() : true); }; EntryHandler eh = delegate(PwEntry pe) { PwEntry peLocal = m_pgRootGroup.FindEntry(pe.Uuid, true); if(peLocal == null) { PwGroup pgSourceParent = pe.ParentGroup; PwGroup pgLocalContainer; if(pgSourceParent == pwSource.m_pgRootGroup) pgLocalContainer = m_pgRootGroup; else pgLocalContainer = m_pgRootGroup.FindGroup(pgSourceParent.Uuid, true); Debug.Assert(pgLocalContainer != null); if(pgLocalContainer == null) pgLocalContainer = m_pgRootGroup; PwEntry peNew = new PwEntry(false, false); peNew.Uuid = pe.Uuid; peNew.AssignProperties(pe, false, true, true); pgLocalContainer.AddEntry(peNew, true); } else // peLocal != null { Debug.Assert(mm != PwMergeMethod.CreateNewUuids); const PwCompareOptions cmpOpt = (PwCompareOptions.IgnoreParentGroup | PwCompareOptions.IgnoreLastAccess | PwCompareOptions.IgnoreHistory | PwCompareOptions.NullEmptyEquivStd); bool bEquals = peLocal.EqualsEntry(pe, cmpOpt, MemProtCmpMode.None); bool bOrgBackup = !bEquals; if(mm != PwMergeMethod.OverwriteExisting) bOrgBackup &= (TimeUtil.CompareLastMod(pe, peLocal, true) > 0); bOrgBackup &= !pe.HasBackupOfData(peLocal, false, true); if(bOrgBackup) peLocal.CreateBackup(null); // Maintain at end bool bSrcBackup = !bEquals && (mm != PwMergeMethod.OverwriteExisting); bSrcBackup &= (TimeUtil.CompareLastMod(peLocal, pe, true) > 0); bSrcBackup &= !peLocal.HasBackupOfData(pe, false, true); if(bSrcBackup) pe.CreateBackup(null); // Maintain at end if(mm == PwMergeMethod.OverwriteExisting) peLocal.AssignProperties(pe, false, false, false); else if((mm == PwMergeMethod.OverwriteIfNewer) || (mm == PwMergeMethod.Synchronize)) { peLocal.AssignProperties(pe, true, false, false); } // else if(mm == PwMergeMethod.KeepExisting) ... MergeEntryHistory(peLocal, pe, mm); } return ((slStatus != null) ? slStatus.ContinueWork() : true); }; if(!pwSource.RootGroup.TraverseTree(TraversalMethod.PreOrder, gh, eh)) throw new InvalidOperationException(); IStatusLogger slPrevStatus = m_slStatus; m_slStatus = slStatus; if(mm == PwMergeMethod.Synchronize) { ApplyDeletions(pwSource.m_vDeletedObjects, true); ApplyDeletions(m_vDeletedObjects, false); PwObjectPool ppOrgGroups = PwObjectPool.FromGroupRecursive( pgOrgStructure, false); PwObjectPool ppSrcGroups = PwObjectPool.FromGroupRecursive( pgSrcStructure, false); PwObjectPool ppOrgEntries = PwObjectPool.FromGroupRecursive( pgOrgStructure, true); PwObjectPool ppSrcEntries = PwObjectPool.FromGroupRecursive( pgSrcStructure, true); RelocateGroups(ppOrgGroups, ppSrcGroups); ReorderGroups(ppOrgGroups, ppSrcGroups); RelocateEntries(ppOrgEntries, ppSrcEntries); ReorderEntries(ppOrgEntries, ppSrcEntries); Debug.Assert(ValidateUuidUniqueness()); } // Must be called *after* merging groups, because group UUIDs // are required for recycle bin and entry template UUIDs MergeInDbProperties(pwSource, mm); MergeInCustomIcons(pwSource); MaintainBackups(); m_slStatus = slPrevStatus; } private void MergeInCustomIcons(PwDatabase pwSource) { foreach(PwCustomIcon pwci in pwSource.CustomIcons) { if(GetCustomIconIndex(pwci.Uuid) >= 0) continue; m_vCustomIcons.Add(pwci); // PwCustomIcon is immutable m_bUINeedsIconUpdate = true; } } /// /// Apply a list of deleted objects. /// /// List of deleted objects. private void ApplyDeletions(PwObjectList listDelObjects, bool bCopyDeletionInfoToLocal) { Debug.Assert(listDelObjects != null); if(listDelObjects == null) throw new ArgumentNullException("listDelObjects"); LinkedList listGroupsToDelete = new LinkedList(); LinkedList listEntriesToDelete = new LinkedList(); GroupHandler gh = delegate(PwGroup pg) { if(pg == m_pgRootGroup) return true; foreach(PwDeletedObject pdo in listDelObjects) { if(pg.Uuid.Equals(pdo.Uuid)) { if(TimeUtil.Compare(pg.LastModificationTime, pdo.DeletionTime, true) < 0) listGroupsToDelete.AddLast(pg); } } return ((m_slStatus != null) ? m_slStatus.ContinueWork() : true); }; EntryHandler eh = delegate(PwEntry pe) { foreach(PwDeletedObject pdo in listDelObjects) { if(pe.Uuid.Equals(pdo.Uuid)) { if(TimeUtil.Compare(pe.LastModificationTime, pdo.DeletionTime, true) < 0) listEntriesToDelete.AddLast(pe); } } return ((m_slStatus != null) ? m_slStatus.ContinueWork() : true); }; m_pgRootGroup.TraverseTree(TraversalMethod.PreOrder, gh, eh); foreach(PwGroup pg in listGroupsToDelete) pg.ParentGroup.Groups.Remove(pg); foreach(PwEntry pe in listEntriesToDelete) pe.ParentGroup.Entries.Remove(pe); if(bCopyDeletionInfoToLocal) { foreach(PwDeletedObject pdoNew in listDelObjects) { bool bCopy = true; foreach(PwDeletedObject pdoLocal in m_vDeletedObjects) { if(pdoNew.Uuid.Equals(pdoLocal.Uuid)) { bCopy = false; if(pdoNew.DeletionTime > pdoLocal.DeletionTime) pdoLocal.DeletionTime = pdoNew.DeletionTime; break; } } if(bCopy) m_vDeletedObjects.Add(pdoNew); } } } private void RelocateGroups(PwObjectPool ppOrgStructure, PwObjectPool ppSrcStructure) { PwObjectList vGroups = m_pgRootGroup.GetGroups(true); foreach(PwGroup pg in vGroups) { if((m_slStatus != null) && !m_slStatus.ContinueWork()) break; // PwGroup pgOrg = pgOrgStructure.FindGroup(pg.Uuid, true); IStructureItem ptOrg = ppOrgStructure.Get(pg.Uuid); if(ptOrg == null) continue; // PwGroup pgSrc = pgSrcStructure.FindGroup(pg.Uuid, true); IStructureItem ptSrc = ppSrcStructure.Get(pg.Uuid); if(ptSrc == null) continue; PwGroup pgOrgParent = ptOrg.ParentGroup; PwGroup pgSrcParent = ptSrc.ParentGroup; if(pgOrgParent.Uuid.Equals(pgSrcParent.Uuid)) { pg.LocationChanged = ((ptSrc.LocationChanged > ptOrg.LocationChanged) ? ptSrc.LocationChanged : ptOrg.LocationChanged); continue; } if(ptSrc.LocationChanged > ptOrg.LocationChanged) { PwGroup pgLocal = m_pgRootGroup.FindGroup(pgSrcParent.Uuid, true); if(pgLocal == null) { Debug.Assert(false); continue; } if(pgLocal.IsContainedIn(pg)) continue; pg.ParentGroup.Groups.Remove(pg); pgLocal.AddGroup(pg, true); pg.LocationChanged = ptSrc.LocationChanged; } else { Debug.Assert(pg.ParentGroup.Uuid.Equals(pgOrgParent.Uuid)); Debug.Assert(pg.LocationChanged == ptOrg.LocationChanged); } } Debug.Assert(m_pgRootGroup.GetGroups(true).UCount == vGroups.UCount); } private void RelocateEntries(PwObjectPool ppOrgStructure, PwObjectPool ppSrcStructure) { PwObjectList vEntries = m_pgRootGroup.GetEntries(true); foreach(PwEntry pe in vEntries) { if((m_slStatus != null) && !m_slStatus.ContinueWork()) break; // PwEntry peOrg = pgOrgStructure.FindEntry(pe.Uuid, true); IStructureItem ptOrg = ppOrgStructure.Get(pe.Uuid); if(ptOrg == null) continue; // PwEntry peSrc = pgSrcStructure.FindEntry(pe.Uuid, true); IStructureItem ptSrc = ppSrcStructure.Get(pe.Uuid); if(ptSrc == null) continue; PwGroup pgOrg = ptOrg.ParentGroup; PwGroup pgSrc = ptSrc.ParentGroup; if(pgOrg.Uuid.Equals(pgSrc.Uuid)) { pe.LocationChanged = ((ptSrc.LocationChanged > ptOrg.LocationChanged) ? ptSrc.LocationChanged : ptOrg.LocationChanged); continue; } if(ptSrc.LocationChanged > ptOrg.LocationChanged) { PwGroup pgLocal = m_pgRootGroup.FindGroup(pgSrc.Uuid, true); if(pgLocal == null) { Debug.Assert(false); continue; } pe.ParentGroup.Entries.Remove(pe); pgLocal.AddEntry(pe, true); pe.LocationChanged = ptSrc.LocationChanged; } else { Debug.Assert(pe.ParentGroup.Uuid.Equals(pgOrg.Uuid)); Debug.Assert(pe.LocationChanged == ptOrg.LocationChanged); } } Debug.Assert(m_pgRootGroup.GetEntries(true).UCount == vEntries.UCount); } private void ReorderGroups(PwObjectPool ppOrgStructure, PwObjectPool ppSrcStructure) { GroupHandler gh = delegate(PwGroup pg) { ReorderObjectList(pg.Groups, ppOrgStructure, ppSrcStructure, false); return true; }; ReorderObjectList(m_pgRootGroup.Groups, ppOrgStructure, ppSrcStructure, false); m_pgRootGroup.TraverseTree(TraversalMethod.PreOrder, gh, null); } private void ReorderEntries(PwObjectPool ppOrgStructure, PwObjectPool ppSrcStructure) { GroupHandler gh = delegate(PwGroup pg) { ReorderObjectList(pg.Entries, ppOrgStructure, ppSrcStructure, true); return true; }; ReorderObjectList(m_pgRootGroup.Entries, ppOrgStructure, ppSrcStructure, true); m_pgRootGroup.TraverseTree(TraversalMethod.PreOrder, gh, null); } private void ReorderObjectList(PwObjectList vItems, PwObjectPool ppOrgStructure, PwObjectPool ppSrcStructure, bool bEntries) where T : class, IStructureItem, IDeepCloneable { if(!ObjectListRequiresReorder(vItems, ppOrgStructure, ppSrcStructure, bEntries)) return; #if DEBUG PwObjectList vOrgListItems = vItems.CloneShallow(); #endif Queue> qToDo = new Queue>(); qToDo.Enqueue(new KeyValuePair(0, vItems.UCount - 1)); while(qToDo.Count > 0) { if((m_slStatus != null) && !m_slStatus.ContinueWork()) break; KeyValuePair kvp = qToDo.Dequeue(); if(kvp.Value <= kvp.Key) { Debug.Assert(false); continue; } Queue qRelBefore = new Queue(); Queue qRelAfter = new Queue(); uint uPivot = FindLocationChangedPivot(vItems, kvp, ppOrgStructure, ppSrcStructure, qRelBefore, qRelAfter, bEntries); T ptPivot = vItems.GetAt(uPivot); List vToSort = vItems.GetRange(kvp.Key, kvp.Value); Queue qBefore = new Queue(); Queue qAfter = new Queue(); bool bBefore = true; foreach(T pt in vToSort) { if(pt == ptPivot) { bBefore = false; continue; } bool bAdded = false; foreach(PwUuid puBefore in qRelBefore) { if(puBefore.Equals(pt.Uuid)) { qBefore.Enqueue(pt); bAdded = true; break; } } if(bAdded) continue; foreach(PwUuid puAfter in qRelAfter) { if(puAfter.Equals(pt.Uuid)) { qAfter.Enqueue(pt); bAdded = true; break; } } if(bAdded) continue; if(bBefore) qBefore.Enqueue(pt); else qAfter.Enqueue(pt); } Debug.Assert(bBefore == false); uint uPos = kvp.Key; while(qBefore.Count > 0) vItems.SetAt(uPos++, qBefore.Dequeue()); vItems.SetAt(uPos++, ptPivot); while(qAfter.Count > 0) vItems.SetAt(uPos++, qAfter.Dequeue()); Debug.Assert(uPos == (kvp.Value + 1)); int iNewPivot = vItems.IndexOf(ptPivot); if((iNewPivot < (int)kvp.Key) || (iNewPivot > (int)kvp.Value)) { Debug.Assert(false); continue; } if((iNewPivot - 1) > (int)kvp.Key) qToDo.Enqueue(new KeyValuePair(kvp.Key, (uint)(iNewPivot - 1))); if((iNewPivot + 1) < (int)kvp.Value) qToDo.Enqueue(new KeyValuePair((uint)(iNewPivot + 1), kvp.Value)); } #if DEBUG foreach(T ptItem in vOrgListItems) { Debug.Assert(vItems.IndexOf(ptItem) >= 0); } #endif } private static uint FindLocationChangedPivot(PwObjectList vItems, KeyValuePair kvpRange, PwObjectPool ppOrgStructure, PwObjectPool ppSrcStructure, Queue qBefore, Queue qAfter, bool bEntries) where T : class, IStructureItem, IDeepCloneable { uint uPosMax = kvpRange.Key; DateTime dtMax = DateTime.MinValue; List vNeighborSrc = null; for(uint u = kvpRange.Key; u <= kvpRange.Value; ++u) { T pt = vItems.GetAt(u); // IStructureItem ptOrg = pgOrgStructure.FindObject(pt.Uuid, true, bEntries); IStructureItem ptOrg = ppOrgStructure.Get(pt.Uuid); if((ptOrg != null) && (ptOrg.LocationChanged > dtMax)) { uPosMax = u; dtMax = ptOrg.LocationChanged; // No 'continue' vNeighborSrc = ptOrg.ParentGroup.GetObjects(false, bEntries); } // IStructureItem ptSrc = pgSrcStructure.FindObject(pt.Uuid, true, bEntries); IStructureItem ptSrc = ppSrcStructure.Get(pt.Uuid); if((ptSrc != null) && (ptSrc.LocationChanged > dtMax)) { uPosMax = u; dtMax = ptSrc.LocationChanged; // No 'continue' vNeighborSrc = ptSrc.ParentGroup.GetObjects(false, bEntries); } } GetNeighborItems(vNeighborSrc, vItems.GetAt(uPosMax).Uuid, qBefore, qAfter); return uPosMax; } private static void GetNeighborItems(List vItems, PwUuid pwPivot, Queue qBefore, Queue qAfter) { qBefore.Clear(); qAfter.Clear(); // Checks after clearing the queues if(vItems == null) { Debug.Assert(false); return; } // No throw bool bBefore = true; for(int i = 0; i < vItems.Count; ++i) { PwUuid pw = vItems[i].Uuid; if(pw.Equals(pwPivot)) bBefore = false; else if(bBefore) qBefore.Enqueue(pw); else qAfter.Enqueue(pw); } Debug.Assert(bBefore == false); } /// /// Method to check whether a reordering is required. This fast test /// allows to skip the reordering routine, resulting in a large /// performance increase. /// private bool ObjectListRequiresReorder(PwObjectList vItems, PwObjectPool ppOrgStructure, PwObjectPool ppSrcStructure, bool bEntries) where T : class, IStructureItem, IDeepCloneable { Debug.Assert(ppOrgStructure.ContainsOnlyType(bEntries ? typeof(PwEntry) : typeof(PwGroup))); Debug.Assert(ppSrcStructure.ContainsOnlyType(bEntries ? typeof(PwEntry) : typeof(PwGroup))); if(vItems.UCount <= 1) return false; if((m_slStatus != null) && !m_slStatus.ContinueWork()) return false; T ptFirst = vItems.GetAt(0); // IStructureItem ptOrg = pgOrgStructure.FindObject(ptFirst.Uuid, true, bEntries); IStructureItem ptOrg = ppOrgStructure.Get(ptFirst.Uuid); if(ptOrg == null) return true; // IStructureItem ptSrc = pgSrcStructure.FindObject(ptFirst.Uuid, true, bEntries); IStructureItem ptSrc = ppSrcStructure.Get(ptFirst.Uuid); if(ptSrc == null) return true; if(ptFirst.ParentGroup == null) { Debug.Assert(false); return true; } PwGroup pgOrgParent = ptOrg.ParentGroup; if(pgOrgParent == null) return true; // Root might be in tree PwGroup pgSrcParent = ptSrc.ParentGroup; if(pgSrcParent == null) return true; // Root might be in tree if(!ptFirst.ParentGroup.Uuid.Equals(pgOrgParent.Uuid)) return true; if(!pgOrgParent.Uuid.Equals(pgSrcParent.Uuid)) return true; List lOrg = pgOrgParent.GetObjects(false, bEntries); List lSrc = pgSrcParent.GetObjects(false, bEntries); if(vItems.UCount != (uint)lOrg.Count) return true; if(lOrg.Count != lSrc.Count) return true; for(uint u = 0; u < vItems.UCount; ++u) { IStructureItem pt = vItems.GetAt(u); Debug.Assert(pt.ParentGroup == ptFirst.ParentGroup); if(!pt.Uuid.Equals(lOrg[(int)u].Uuid)) return true; if(!pt.Uuid.Equals(lSrc[(int)u].Uuid)) return true; if(pt.LocationChanged != lOrg[(int)u].LocationChanged) return true; if(pt.LocationChanged != lSrc[(int)u].LocationChanged) return true; } return false; } private void MergeInDbProperties(PwDatabase pwSource, PwMergeMethod mm) { if(pwSource == null) { Debug.Assert(false); return; } if((mm == PwMergeMethod.KeepExisting) || (mm == PwMergeMethod.None)) return; bool bForce = (mm == PwMergeMethod.OverwriteExisting); if(bForce || (pwSource.m_dtNameChanged > m_dtNameChanged)) { m_strName = pwSource.m_strName; m_dtNameChanged = pwSource.m_dtNameChanged; } if(bForce || (pwSource.m_dtDescChanged > m_dtDescChanged)) { m_strDesc = pwSource.m_strDesc; m_dtDescChanged = pwSource.m_dtDescChanged; } if(bForce || (pwSource.m_dtDefaultUserChanged > m_dtDefaultUserChanged)) { m_strDefaultUserName = pwSource.m_strDefaultUserName; m_dtDefaultUserChanged = pwSource.m_dtDefaultUserChanged; } if(bForce) m_clr = pwSource.m_clr; PwUuid pwPrefBin = m_pwRecycleBin, pwAltBin = pwSource.m_pwRecycleBin; if(bForce || (pwSource.m_dtRecycleBinChanged > m_dtRecycleBinChanged)) { pwPrefBin = pwSource.m_pwRecycleBin; pwAltBin = m_pwRecycleBin; m_bUseRecycleBin = pwSource.m_bUseRecycleBin; m_dtRecycleBinChanged = pwSource.m_dtRecycleBinChanged; } if(m_pgRootGroup.FindGroup(pwPrefBin, true) != null) m_pwRecycleBin = pwPrefBin; else if(m_pgRootGroup.FindGroup(pwAltBin, true) != null) m_pwRecycleBin = pwAltBin; else m_pwRecycleBin = PwUuid.Zero; // Debug.Assert(false); PwUuid pwPrefTmp = m_pwEntryTemplatesGroup, pwAltTmp = pwSource.m_pwEntryTemplatesGroup; if(bForce || (pwSource.m_dtEntryTemplatesChanged > m_dtEntryTemplatesChanged)) { pwPrefTmp = pwSource.m_pwEntryTemplatesGroup; pwAltTmp = m_pwEntryTemplatesGroup; m_dtEntryTemplatesChanged = pwSource.m_dtEntryTemplatesChanged; } if(m_pgRootGroup.FindGroup(pwPrefTmp, true) != null) m_pwEntryTemplatesGroup = pwPrefTmp; else if(m_pgRootGroup.FindGroup(pwAltTmp, true) != null) m_pwEntryTemplatesGroup = pwAltTmp; else m_pwEntryTemplatesGroup = PwUuid.Zero; // Debug.Assert(false); } private void MergeEntryHistory(PwEntry pe, PwEntry peSource, PwMergeMethod mm) { if(!pe.Uuid.Equals(peSource.Uuid)) { Debug.Assert(false); return; } if(pe.History.UCount == peSource.History.UCount) { bool bEqual = true; for(uint uEnum = 0; uEnum < pe.History.UCount; ++uEnum) { if(pe.History.GetAt(uEnum).LastModificationTime != peSource.History.GetAt(uEnum).LastModificationTime) { bEqual = false; break; } } if(bEqual) return; } if((m_slStatus != null) && !m_slStatus.ContinueWork()) return; IDictionary dict = #if KeePassLibSD new SortedList(); #else new SortedDictionary(); #endif foreach(PwEntry peOrg in pe.History) { dict[peOrg.LastModificationTime] = peOrg; } foreach(PwEntry peSrc in peSource.History) { DateTime dt = peSrc.LastModificationTime; if(dict.ContainsKey(dt)) { if(mm == PwMergeMethod.OverwriteExisting) dict[dt] = peSrc.CloneDeep(); } else dict[dt] = peSrc.CloneDeep(); } pe.History.Clear(); foreach(KeyValuePair kvpCur in dict) { Debug.Assert(kvpCur.Value.Uuid.Equals(pe.Uuid)); Debug.Assert(kvpCur.Value.History.UCount == 0); pe.History.Add(kvpCur.Value); } } public bool MaintainBackups() { if(m_pgRootGroup == null) { Debug.Assert(false); return false; } bool bDeleted = false; EntryHandler eh = delegate(PwEntry pe) { if(pe.MaintainBackups(this)) bDeleted = true; return true; }; m_pgRootGroup.TraverseTree(TraversalMethod.PreOrder, null, eh); return bDeleted; } /* /// /// Synchronize current database with another one. /// /// Source file. public void Synchronize(string strFile) { PwDatabase pwSource = new PwDatabase(); IOConnectionInfo ioc = IOConnectionInfo.FromPath(strFile); pwSource.Open(ioc, m_pwUserKey, null); MergeIn(pwSource, PwMergeMethod.Synchronize); } */ /// /// Get the index of a custom icon. /// /// ID of the icon. /// Index of the icon. public int GetCustomIconIndex(PwUuid pwIconId) { for(int i = 0; i < m_vCustomIcons.Count; ++i) { PwCustomIcon pwci = m_vCustomIcons[i]; if(pwci.Uuid.Equals(pwIconId)) return i; } // Debug.Assert(false); // Do not assert return -1; } public int GetCustomIconIndex(byte[] pbPngData) { if(pbPngData == null) { Debug.Assert(false); return -1; } for(int i = 0; i < m_vCustomIcons.Count; ++i) { PwCustomIcon pwci = m_vCustomIcons[i]; byte[] pbEx = pwci.ImageDataPng; if(pbEx == null) { Debug.Assert(false); continue; } if(MemUtil.ArraysEqual(pbEx, pbPngData)) return i; } return -1; } /// /// Get a custom icon. This function can return null, if /// no cached image of the icon is available. /// /// ID of the icon. /// Image data. public Image GetCustomIcon(PwUuid pwIconId) { int nIndex = GetCustomIconIndex(pwIconId); if(nIndex >= 0) return m_vCustomIcons[nIndex].Image; else { Debug.Assert(false); return null; } } public bool DeleteCustomIcons(List vUuidsToDelete) { Debug.Assert(vUuidsToDelete != null); if(vUuidsToDelete == null) throw new ArgumentNullException("vUuidsToDelete"); if(vUuidsToDelete.Count <= 0) return true; GroupHandler gh = delegate(PwGroup pg) { PwUuid uuidThis = pg.CustomIconUuid; if(uuidThis.Equals(PwUuid.Zero)) return true; foreach(PwUuid uuidDelete in vUuidsToDelete) { if(uuidThis.Equals(uuidDelete)) { pg.CustomIconUuid = PwUuid.Zero; break; } } return true; }; EntryHandler eh = delegate(PwEntry pe) { RemoveCustomIconUuid(pe, vUuidsToDelete); return true; }; gh(m_pgRootGroup); if(!m_pgRootGroup.TraverseTree(TraversalMethod.PreOrder, gh, eh)) { Debug.Assert(false); return false; } foreach(PwUuid pwUuid in vUuidsToDelete) { int nIndex = GetCustomIconIndex(pwUuid); if(nIndex >= 0) m_vCustomIcons.RemoveAt(nIndex); } return true; } private static void RemoveCustomIconUuid(PwEntry pe, List vToDelete) { PwUuid uuidThis = pe.CustomIconUuid; if(uuidThis.Equals(PwUuid.Zero)) return; foreach(PwUuid uuidDelete in vToDelete) { if(uuidThis.Equals(uuidDelete)) { pe.CustomIconUuid = PwUuid.Zero; break; } } foreach(PwEntry peHistory in pe.History) RemoveCustomIconUuid(peHistory, vToDelete); } private bool ValidateUuidUniqueness() { #if DEBUG List l = new List(); bool bAllUnique = true; GroupHandler gh = delegate(PwGroup pg) { foreach(PwUuid u in l) bAllUnique &= !pg.Uuid.Equals(u); l.Add(pg.Uuid); return bAllUnique; }; EntryHandler eh = delegate(PwEntry pe) { foreach(PwUuid u in l) bAllUnique &= !pe.Uuid.Equals(u); l.Add(pe.Uuid); return bAllUnique; }; m_pgRootGroup.TraverseTree(TraversalMethod.PreOrder, gh, eh); return bAllUnique; #else return true; #endif } /* public void CreateBackupFile(IStatusLogger sl) { if(sl != null) sl.SetText(KLRes.CreatingBackupFile, LogStatusType.Info); IOConnectionInfo iocBk = m_ioSource.CloneDeep(); iocBk.Path += StrBackupExtension; bool bMadeUnhidden = UrlUtil.UnhideFile(iocBk.Path); bool bFastCopySuccess = false; if(m_ioSource.IsLocalFile() && (m_ioSource.UserName.Length == 0) && (m_ioSource.Password.Length == 0)) { try { string strFile = m_ioSource.Path + StrBackupExtension; File.Copy(m_ioSource.Path, strFile, true); bFastCopySuccess = true; } catch(Exception) { Debug.Assert(false); } } if(bFastCopySuccess == false) { using(Stream sIn = IOConnection.OpenRead(m_ioSource)) { using(Stream sOut = IOConnection.OpenWrite(iocBk)) { MemUtil.CopyStream(sIn, sOut); sOut.Close(); } sIn.Close(); } } if(bMadeUnhidden) UrlUtil.HideFile(iocBk.Path, true); // Hide again } */ /* private static void RemoveData(PwGroup pg) { EntryHandler eh = delegate(PwEntry pe) { pe.AutoType.Clear(); pe.Binaries.Clear(); pe.History.Clear(); pe.Strings.Clear(); return true; }; pg.TraverseTree(TraversalMethod.PreOrder, null, eh); } */ public uint DeleteDuplicateEntries(IStatusLogger sl) { uint uDeleted = 0; PwGroup pgRecycleBin = null; if(m_bUseRecycleBin) pgRecycleBin = m_pgRootGroup.FindGroup(m_pwRecycleBin, true); DateTime dtNow = DateTime.Now; PwObjectList l = m_pgRootGroup.GetEntries(true); int i = 0; while(true) { if(i >= ((int)l.UCount - 1)) break; if(sl != null) { long lCnt = (long)l.UCount, li = (long)i; long nArTotal = (lCnt * lCnt) / 2L; long nArCur = li * lCnt - ((li * li) / 2L); long nArPct = (nArCur * 100L) / nArTotal; if(nArPct < 0) nArPct = 0; if(nArPct > 100) nArPct = 100; if(!sl.SetProgress((uint)nArPct)) break; } PwEntry peA = l.GetAt((uint)i); for(uint j = (uint)i + 1; j < l.UCount; ++j) { PwEntry peB = l.GetAt(j); if(!DupEntriesEqual(peA, peB)) continue; bool bDeleteA = (TimeUtil.CompareLastMod(peA, peB, true) <= 0); if(pgRecycleBin != null) { bool bAInBin = peA.IsContainedIn(pgRecycleBin); bool bBInBin = peB.IsContainedIn(pgRecycleBin); if(bAInBin && !bBInBin) bDeleteA = true; else if(bBInBin && !bAInBin) bDeleteA = false; } if(bDeleteA) { peA.ParentGroup.Entries.Remove(peA); m_vDeletedObjects.Add(new PwDeletedObject(peA.Uuid, dtNow)); l.RemoveAt((uint)i); --i; } else { peB.ParentGroup.Entries.Remove(peB); m_vDeletedObjects.Add(new PwDeletedObject(peB.Uuid, dtNow)); l.RemoveAt(j); } ++uDeleted; break; } ++i; } return uDeleted; } private static List m_lStdFields = null; private static bool DupEntriesEqual(PwEntry a, PwEntry b) { if(m_lStdFields == null) m_lStdFields = PwDefs.GetStandardFields(); foreach(string strStdKey in m_lStdFields) { string strA = a.Strings.ReadSafe(strStdKey); string strB = b.Strings.ReadSafe(strStdKey); if(!strA.Equals(strB)) return false; } foreach(KeyValuePair kvpA in a.Strings) { if(PwDefs.IsStandardField(kvpA.Key)) continue; ProtectedString psB = b.Strings.Get(kvpA.Key); if(psB == null) return false; // Ignore protection setting, compare values only if(!kvpA.Value.ReadString().Equals(psB.ReadString())) return false; } foreach(KeyValuePair kvpB in b.Strings) { if(PwDefs.IsStandardField(kvpB.Key)) continue; ProtectedString psA = a.Strings.Get(kvpB.Key); if(psA == null) return false; // Must be equal by logic Debug.Assert(kvpB.Value.ReadString().Equals(psA.ReadString())); } if(a.Binaries.UCount != b.Binaries.UCount) return false; foreach(KeyValuePair kvpBin in a.Binaries) { ProtectedBinary pbB = b.Binaries.Get(kvpBin.Key); if(pbB == null) return false; // Ignore protection setting, compare values only byte[] pbDataA = kvpBin.Value.ReadData(); byte[] pbDataB = pbB.ReadData(); bool bBinEq = MemUtil.ArraysEqual(pbDataA, pbDataB); MemUtil.ZeroByteArray(pbDataA); MemUtil.ZeroByteArray(pbDataB); if(!bBinEq) return false; } return true; } public uint DeleteEmptyGroups() { uint uDeleted = 0; PwObjectList l = m_pgRootGroup.GetGroups(true); int iStart = (int)l.UCount - 1; for(int i = iStart; i >= 0; --i) { PwGroup pg = l.GetAt((uint)i); if((pg.Groups.UCount > 0) || (pg.Entries.UCount > 0)) continue; pg.ParentGroup.Groups.Remove(pg); m_vDeletedObjects.Add(new PwDeletedObject(pg.Uuid, DateTime.Now)); ++uDeleted; } return uDeleted; } public uint DeleteUnusedCustomIcons() { List lToDelete = new List(); foreach(PwCustomIcon pwci in m_vCustomIcons) lToDelete.Add(pwci.Uuid); GroupHandler gh = delegate(PwGroup pg) { PwUuid pwUuid = pg.CustomIconUuid; if((pwUuid == null) || pwUuid.Equals(PwUuid.Zero)) return true; for(int i = 0; i < lToDelete.Count; ++i) { if(lToDelete[i].Equals(pwUuid)) { lToDelete.RemoveAt(i); break; } } return true; }; EntryHandler eh = delegate(PwEntry pe) { PwUuid pwUuid = pe.CustomIconUuid; if((pwUuid == null) || pwUuid.Equals(PwUuid.Zero)) return true; for(int i = 0; i < lToDelete.Count; ++i) { if(lToDelete[i].Equals(pwUuid)) { lToDelete.RemoveAt(i); break; } } return true; }; gh(m_pgRootGroup); m_pgRootGroup.TraverseTree(TraversalMethod.PreOrder, gh, eh); uint uDeleted = 0; foreach(PwUuid pwDel in lToDelete) { int nIndex = GetCustomIconIndex(pwDel); if(nIndex < 0) { Debug.Assert(false); continue; } m_vCustomIcons.RemoveAt(nIndex); ++uDeleted; } if(uDeleted > 0) m_bUINeedsIconUpdate = true; return uDeleted; } } } keepass2-2.25/KeePassLib/PwDefs.cs0000664000175000017500000003347612271475522016640 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml.Serialization; using System.ComponentModel; using System.Diagnostics; using KeePassLib.Delegates; using KeePassLib.Interfaces; using KeePassLib.Serialization; namespace KeePassLib { /// /// Contains KeePassLib-global definitions and enums. /// public static class PwDefs { /// /// The product name. /// public const string ProductName = "KeePass Password Safe"; /// /// A short, simple string representing the product name. The string /// should contain no spaces, directory separator characters, etc. /// public const string ShortProductName = "KeePass"; internal const string UnixName = "keepass2"; internal const string ResClass = "KeePass2"; // With initial capital /// /// Version, encoded as 32-bit unsigned integer. /// 2.00 = 0x02000000, 2.01 = 0x02000100, ..., 2.18 = 0x02010800. /// As of 2.19, the version is encoded component-wise per byte, /// e.g. 2.19 = 0x02130000. /// It is highly recommended to use FileVersion64 instead. /// public const uint Version32 = 0x02190000; /// /// Version, encoded as 64-bit unsigned integer /// (component-wise, 16 bits per component). /// public const ulong FileVersion64 = 0x0002001900000000UL; /// /// Version, encoded as string. /// public const string VersionString = "2.25"; public const string Copyright = @"Copyright © 2003-2014 Dominik Reichl"; /// /// Product website URL. Terminated by a forward slash. /// public const string HomepageUrl = "http://keepass.info/"; /// /// Product donations URL. /// public const string DonationsUrl = "http://keepass.info/donate.html"; /// /// URL to the online plugins page. /// public const string PluginsUrl = "http://keepass.info/plugins.html"; /// /// URL to the online translations page. /// public const string TranslationsUrl = "http://keepass.info/translations.html"; /// /// URL to a TXT file (eventually compressed) that contains information /// about the latest KeePass version available on the website. /// public const string VersionUrl = "http://keepass.info/update/version2x.txt.gz"; /// /// URL to the root path of the online KeePass help. Terminated by /// a forward slash. /// public const string HelpUrl = "http://keepass.info/help/"; /// /// A DateTime object that represents the time when the assembly /// was loaded. /// public static readonly DateTime DtDefaultNow = DateTime.Now; /// /// Default number of master key encryption/transformation rounds (making dictionary attacks harder). /// public const ulong DefaultKeyEncryptionRounds = 6000; /// /// Default identifier string for the title field. Should not contain /// spaces, tabs or other whitespace. /// public const string TitleField = "Title"; /// /// Default identifier string for the user name field. Should not contain /// spaces, tabs or other whitespace. /// public const string UserNameField = "UserName"; /// /// Default identifier string for the password field. Should not contain /// spaces, tabs or other whitespace. /// public const string PasswordField = "Password"; /// /// Default identifier string for the URL field. Should not contain /// spaces, tabs or other whitespace. /// public const string UrlField = "URL"; /// /// Default identifier string for the notes field. Should not contain /// spaces, tabs or other whitespace. /// public const string NotesField = "Notes"; /// /// Default identifier string for the field which will contain TAN indices. /// public const string TanIndexField = UserNameField; /// /// Default title of an entry that is really a TAN entry. /// public const string TanTitle = @""; /// /// Prefix of a custom auto-type string field. /// public const string AutoTypeStringPrefix = "S:"; /// /// Default string representing a hidden password. /// public const string HiddenPassword = "********"; /// /// Default auto-type keystroke sequence. If no custom sequence is /// specified, this sequence is used. /// public const string DefaultAutoTypeSequence = @"{USERNAME}{TAB}{PASSWORD}{ENTER}"; /// /// Default auto-type keystroke sequence for TAN entries. If no custom /// sequence is specified, this sequence is used. /// public const string DefaultAutoTypeSequenceTan = @"{PASSWORD}"; /// /// Check if a name is a standard field name. /// /// Input field name. /// Returns true, if the field name is a standard /// field name (title, user name, password, ...), otherwise false. public static bool IsStandardField(string strFieldName) { Debug.Assert(strFieldName != null); if(strFieldName == null) return false; if(strFieldName.Equals(TitleField)) return true; if(strFieldName.Equals(UserNameField)) return true; if(strFieldName.Equals(PasswordField)) return true; if(strFieldName.Equals(UrlField)) return true; if(strFieldName.Equals(NotesField)) return true; return false; } public static List GetStandardFields() { List l = new List(); l.Add(TitleField); l.Add(UserNameField); l.Add(PasswordField); l.Add(UrlField); l.Add(NotesField); return l; } /// /// Check if an entry is a TAN. /// /// Password entry. /// Returns true if the entry is a TAN. public static bool IsTanEntry(PwEntry pe) { Debug.Assert(pe != null); if(pe == null) return false; return (pe.Strings.ReadSafe(PwDefs.TitleField) == TanTitle); } } #pragma warning disable 1591 // Missing XML comments warning /// /// Search parameters for group and entry searches. /// public sealed class SearchParameters { private string m_strText = string.Empty; [DefaultValue("")] public string SearchString { get { return m_strText; } set { if(value == null) throw new ArgumentNullException("value"); m_strText = value; } } private bool m_bRegex = false; [DefaultValue(false)] public bool RegularExpression { get { return m_bRegex; } set { m_bRegex = value; } } private bool m_bSearchInTitles = true; [DefaultValue(true)] public bool SearchInTitles { get { return m_bSearchInTitles; } set { m_bSearchInTitles = value; } } private bool m_bSearchInUserNames = true; [DefaultValue(true)] public bool SearchInUserNames { get { return m_bSearchInUserNames; } set { m_bSearchInUserNames = value; } } private bool m_bSearchInPasswords = false; [DefaultValue(false)] public bool SearchInPasswords { get { return m_bSearchInPasswords; } set { m_bSearchInPasswords = value; } } private bool m_bSearchInUrls = true; [DefaultValue(true)] public bool SearchInUrls { get { return m_bSearchInUrls; } set { m_bSearchInUrls = value; } } private bool m_bSearchInNotes = true; [DefaultValue(true)] public bool SearchInNotes { get { return m_bSearchInNotes; } set { m_bSearchInNotes = value; } } private bool m_bSearchInOther = true; [DefaultValue(true)] public bool SearchInOther { get { return m_bSearchInOther; } set { m_bSearchInOther = value; } } private bool m_bSearchInUuids = false; [DefaultValue(false)] public bool SearchInUuids { get { return m_bSearchInUuids; } set { m_bSearchInUuids = value; } } private bool m_bSearchInGroupNames = false; [DefaultValue(false)] public bool SearchInGroupNames { get { return m_bSearchInGroupNames; } set { m_bSearchInGroupNames = value; } } private bool m_bSearchInTags = true; [DefaultValue(true)] public bool SearchInTags { get { return m_bSearchInTags; } set { m_bSearchInTags = value; } } #if KeePassRT private StringComparison m_scType = StringComparison.OrdinalIgnoreCase; #else private StringComparison m_scType = StringComparison.InvariantCultureIgnoreCase; #endif /// /// String comparison type. Specifies the condition when the specified /// text matches a group/entry string. /// public StringComparison ComparisonMode { get { return m_scType; } set { m_scType = value; } } private bool m_bExcludeExpired = false; [DefaultValue(false)] public bool ExcludeExpired { get { return m_bExcludeExpired; } set { m_bExcludeExpired = value; } } private bool m_bRespectEntrySearchingDisabled = true; [DefaultValue(true)] public bool RespectEntrySearchingDisabled { get { return m_bRespectEntrySearchingDisabled; } set { m_bRespectEntrySearchingDisabled = value; } } private StrPwEntryDelegate m_fnDataTrf = null; [XmlIgnore] public StrPwEntryDelegate DataTransformationFn { get { return m_fnDataTrf; } set { m_fnDataTrf = value; } } private string m_strDataTrf = string.Empty; /// /// Only for serialization. /// [DefaultValue("")] public string DataTransformation { get { return m_strDataTrf; } set { if(value == null) throw new ArgumentNullException("value"); m_strDataTrf = value; } } [XmlIgnore] public static SearchParameters None { get { SearchParameters sp = new SearchParameters(); // sp.m_strText = string.Empty; // sp.m_bRegex = false; sp.m_bSearchInTitles = false; sp.m_bSearchInUserNames = false; // sp.m_bSearchInPasswords = false; sp.m_bSearchInUrls = false; sp.m_bSearchInNotes = false; sp.m_bSearchInOther = false; // sp.m_bSearchInUuids = false; // sp.SearchInGroupNames = false; sp.m_bSearchInTags = false; // sp.m_scType = StringComparison.InvariantCultureIgnoreCase; // sp.m_bExcludeExpired = false; // m_bRespectEntrySearchingDisabled = true; return sp; } } /// /// Construct a new search parameters object. /// public SearchParameters() { } public SearchParameters Clone() { return (SearchParameters)this.MemberwiseClone(); } } #pragma warning restore 1591 // Missing XML comments warning #pragma warning disable 1591 // Missing XML comments warning /// /// Memory protection configuration structure (for default fields). /// public sealed class MemoryProtectionConfig : IDeepCloneable { public bool ProtectTitle = false; public bool ProtectUserName = false; public bool ProtectPassword = true; public bool ProtectUrl = false; public bool ProtectNotes = false; // public bool AutoEnableVisualHiding = false; public MemoryProtectionConfig CloneDeep() { return (MemoryProtectionConfig)this.MemberwiseClone(); } public bool GetProtection(string strField) { if(strField == PwDefs.TitleField) return this.ProtectTitle; if(strField == PwDefs.UserNameField) return this.ProtectUserName; if(strField == PwDefs.PasswordField) return this.ProtectPassword; if(strField == PwDefs.UrlField) return this.ProtectUrl; if(strField == PwDefs.NotesField) return this.ProtectNotes; return false; } } #pragma warning restore 1591 // Missing XML comments warning public sealed class ObjectTouchedEventArgs : EventArgs { private object m_o; public object Object { get { return m_o; } } private bool m_bModified; public bool Modified { get { return m_bModified; } } private bool m_bParentsTouched; public bool ParentsTouched { get { return m_bParentsTouched; } } public ObjectTouchedEventArgs(object o, bool bModified, bool bParentsTouched) { m_o = o; m_bModified = bModified; m_bParentsTouched = bParentsTouched; } } public sealed class IOAccessEventArgs : EventArgs { private IOConnectionInfo m_ioc; public IOConnectionInfo IOConnectionInfo { get { return m_ioc; } } private IOConnectionInfo m_ioc2; public IOConnectionInfo IOConnectionInfo2 { get { return m_ioc2; } } private IOAccessType m_t; public IOAccessType Type { get { return m_t; } } public IOAccessEventArgs(IOConnectionInfo ioc, IOConnectionInfo ioc2, IOAccessType t) { m_ioc = ioc; m_ioc2 = ioc2; m_t = t; } } } keepass2-2.25/KeePassLib/PwEnums.cs0000664000175000017500000001257212261553104017030 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; namespace KeePassLib { /// /// Compression algorithm specifiers. /// public enum PwCompressionAlgorithm { /// /// No compression. /// None = 0, /// /// GZip compression. /// GZip = 1, /// /// Virtual field: currently known number of algorithms. Should not be used /// by plugins or libraries -- it's used internally only. /// Count = 2 } /// /// Tree traversal methods. /// public enum TraversalMethod { /// /// Don't traverse the tree. /// None = 0, /// /// Traverse the tree in pre-order mode, i.e. first visit all items /// in the current node, then visit all subnodes. /// PreOrder = 1 } /// /// Methods for merging password databases/entries. /// public enum PwMergeMethod { // Do not change the explicitly assigned values, otherwise // serialization (e.g. of Ecas triggers) breaks None = 0, OverwriteExisting = 1, KeepExisting = 2, OverwriteIfNewer = 3, CreateNewUuids = 4, Synchronize = 5 } /// /// Icon identifiers for groups and password entries. /// public enum PwIcon { Key = 0, World, Warning, NetworkServer, MarkedDirectory, UserCommunication, Parts, Notepad, WorldSocket, Identity, PaperReady, Digicam, IRCommunication, MultiKeys, Energy, Scanner, WorldStar, CDRom, Monitor, EMail, Configuration, ClipboardReady, PaperNew, Screen, EnergyCareful, EMailBox, Disk, Drive, PaperQ, TerminalEncrypted, Console, Printer, ProgramIcons, Run, Settings, WorldComputer, Archive, Homebanking, DriveWindows, Clock, EMailSearch, PaperFlag, Memory, TrashBin, Note, Expired, Info, Package, Folder, FolderOpen, FolderPackage, LockOpen, PaperLocked, Checked, Pen, Thumbnail, Book, List, UserKey, Tool, Home, Star, Tux, Feather, Apple, Wiki, Money, Certificate, BlackBerry, /// /// Virtual identifier -- represents the number of icons. /// Count } public enum ProxyServerType { None = 0, System = 1, Manual = 2 } /// /// Comparison modes for in-memory protected objects. /// public enum MemProtCmpMode { /// /// Ignore the in-memory protection states. /// None = 0, /// /// Ignore the in-memory protection states of standard /// objects; do compare in-memory protection states of /// custom objects. /// CustomOnly, /// /// Compare in-memory protection states. /// Full } [Flags] public enum PwCompareOptions { None = 0x0, /// /// Empty standard string fields are considered to be the /// same as non-existing standard string fields. /// This doesn't affect custom string comparisons. /// NullEmptyEquivStd = 0x1, IgnoreParentGroup = 0x2, IgnoreLastAccess = 0x4, IgnoreLastMod = 0x8, IgnoreHistory = 0x10, IgnoreLastBackup = 0x20, // For groups: PropertiesOnly = 0x40, IgnoreTimes = (IgnoreLastAccess | IgnoreLastMod) } public enum IOAccessType { None = 0, /// /// The IO connection is being opened for reading. /// Read = 1, /// /// The IO connection is being opened for writing. /// Write = 2, /// /// The IO connection is being opened for testing /// whether a file/object exists. /// Exists = 3, /// /// The IO connection is being opened for deleting a file/object. /// Delete = 4, /// /// The IO connection is being opened for renaming/moving a file/object. /// Move = 5 } // public enum PwLogicalOp // { // None = 0, // Or = 1, // And = 2, // NOr = 3, // NAnd = 4 // } [Flags] public enum AppRunFlags { None = 0, GetStdOutput = 1, WaitForExit = 2, // This flag prevents any handles being garbage-collected // before the started process has terminated, without // blocking the current thread; // https://sourceforge.net/p/keepass/patches/84/ GCKeepAlive = 4, // https://sourceforge.net/p/keepass/patches/85/ DoEvents = 8, DisableForms = 16 } } keepass2-2.25/KeePassLib/PwEntry.cs0000664000175000017500000006444612273412536017057 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using System.Xml; using System.Drawing; using KeePassLib.Collections; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePassLib { /// /// A class representing a password entry. A password entry consists of several /// fields like title, user name, password, etc. Each password entry has a /// unique ID (UUID). /// public sealed class PwEntry : ITimeLogger, IStructureItem, IDeepCloneable { private PwUuid m_uuid = PwUuid.Zero; private PwGroup m_pParentGroup = null; private DateTime m_tParentGroupLastMod = PwDefs.DtDefaultNow; private ProtectedStringDictionary m_listStrings = new ProtectedStringDictionary(); private ProtectedBinaryDictionary m_listBinaries = new ProtectedBinaryDictionary(); private AutoTypeConfig m_listAutoType = new AutoTypeConfig(); private PwObjectList m_listHistory = new PwObjectList(); private PwIcon m_pwIcon = PwIcon.Key; private PwUuid m_pwCustomIconID = PwUuid.Zero; private Color m_clrForeground = Color.Empty; private Color m_clrBackground = Color.Empty; private DateTime m_tCreation = PwDefs.DtDefaultNow; private DateTime m_tLastMod = PwDefs.DtDefaultNow; private DateTime m_tLastAccess = PwDefs.DtDefaultNow; private DateTime m_tExpire = PwDefs.DtDefaultNow; private bool m_bExpires = false; private ulong m_uUsageCount = 0; private string m_strOverrideUrl = string.Empty; private List m_vTags = new List(); /// /// UUID of this entry. /// public PwUuid Uuid { get { return m_uuid; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_uuid = value; } } /// /// Reference to a group which contains the current entry. /// public PwGroup ParentGroup { get { return m_pParentGroup; } // Plugins: use PwGroup.AddEntry instead. internal set { m_pParentGroup = value; } } /// /// The date/time when the location of the object was last changed. /// public DateTime LocationChanged { get { return m_tParentGroupLastMod; } set { m_tParentGroupLastMod = value; } } /// /// Get or set all entry strings. /// public ProtectedStringDictionary Strings { get { return m_listStrings; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_listStrings = value; } } /// /// Get or set all entry binaries. /// public ProtectedBinaryDictionary Binaries { get { return m_listBinaries; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_listBinaries = value; } } /// /// Get or set all auto-type window/keystroke sequence associations. /// public AutoTypeConfig AutoType { get { return m_listAutoType; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_listAutoType = value; } } /// /// Get all previous versions of this entry (backups). /// public PwObjectList History { get { return m_listHistory; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_listHistory = value; } } /// /// Image ID specifying the icon that will be used for this entry. /// public PwIcon IconId { get { return m_pwIcon; } set { m_pwIcon = value; } } /// /// Get the custom icon ID. This value is 0, if no custom icon is /// being used (i.e. the icon specified by the IconID property /// should be displayed). /// public PwUuid CustomIconUuid { get { return m_pwCustomIconID; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_pwCustomIconID = value; } } /// /// Get or set the foreground color of this entry. /// public Color ForegroundColor { get { return m_clrForeground; } set { m_clrForeground = value; } } /// /// Get or set the background color of this entry. /// public Color BackgroundColor { get { return m_clrBackground; } set { m_clrBackground = value; } } /// /// The date/time when this entry was created. /// public DateTime CreationTime { get { return m_tCreation; } set { m_tCreation = value; } } /// /// The date/time when this entry was last modified. /// public DateTime LastModificationTime { get { return m_tLastMod; } set { m_tLastMod = value; } } /// /// The date/time when this entry was last accessed (read). /// public DateTime LastAccessTime { get { return m_tLastAccess; } set { m_tLastAccess = value; } } /// /// The date/time when this entry expires. Use the Expires property /// to specify if the entry does actually expire or not. /// public DateTime ExpiryTime { get { return m_tExpire; } set { m_tExpire = value; } } /// /// Specifies whether the entry expires or not. /// public bool Expires { get { return m_bExpires; } set { m_bExpires = value; } } /// /// Get or set the usage count of the entry. To increase the usage /// count by one, use the Touch function. /// public ulong UsageCount { get { return m_uUsageCount; } set { m_uUsageCount = value; } } /// /// Entry-specific override URL. If this string is non-empty, /// public string OverrideUrl { get { return m_strOverrideUrl; } set { if(value == null) throw new ArgumentNullException("value"); m_strOverrideUrl = value; } } /// /// List of tags associated with this entry. /// public List Tags { get { return m_vTags; } set { if(value == null) throw new ArgumentNullException("value"); m_vTags = value; } } public static EventHandler EntryTouched; public EventHandler Touched; /// /// Construct a new, empty password entry. Member variables will be initialized /// to their default values. /// /// If true, a new UUID will be created /// for this entry. If false, the UUID is zero and you must set it /// manually later. /// If true, the creation, last modification /// and last access times will be set to the current system time. public PwEntry(bool bCreateNewUuid, bool bSetTimes) { if(bCreateNewUuid) m_uuid = new PwUuid(true); if(bSetTimes) { m_tCreation = m_tLastMod = m_tLastAccess = m_tParentGroupLastMod = DateTime.Now; } } /// /// Construct a new, empty password entry. Member variables will be initialized /// to their default values. /// /// Reference to the containing group, this /// parameter may be null and set later manually. /// If true, a new UUID will be created /// for this entry. If false, the UUID is zero and you must set it /// manually later. /// If true, the creation, last modification /// and last access times will be set to the current system time. [Obsolete("Use a different constructor. To add an entry to a group, use AddEntry of PwGroup.")] public PwEntry(PwGroup pwParentGroup, bool bCreateNewUuid, bool bSetTimes) { m_pParentGroup = pwParentGroup; if(bCreateNewUuid) m_uuid = new PwUuid(true); if(bSetTimes) { m_tCreation = m_tLastMod = m_tLastAccess = m_tParentGroupLastMod = DateTime.Now; } } /// /// Clone the current entry. The returned entry is an exact value copy /// of the current entry (including UUID and parent group reference). /// All mutable members are cloned. /// /// Exact value clone. All references to mutable values changed. public PwEntry CloneDeep() { PwEntry peNew = new PwEntry(false, false); peNew.m_uuid = m_uuid; // PwUuid is immutable peNew.m_pParentGroup = m_pParentGroup; peNew.m_tParentGroupLastMod = m_tParentGroupLastMod; peNew.m_listStrings = m_listStrings.CloneDeep(); peNew.m_listBinaries = m_listBinaries.CloneDeep(); peNew.m_listAutoType = m_listAutoType.CloneDeep(); peNew.m_listHistory = m_listHistory.CloneDeep(); peNew.m_pwIcon = m_pwIcon; peNew.m_pwCustomIconID = m_pwCustomIconID; peNew.m_clrForeground = m_clrForeground; peNew.m_clrBackground = m_clrBackground; peNew.m_tCreation = m_tCreation; peNew.m_tLastMod = m_tLastMod; peNew.m_tLastAccess = m_tLastAccess; peNew.m_tExpire = m_tExpire; peNew.m_bExpires = m_bExpires; peNew.m_uUsageCount = m_uUsageCount; peNew.m_strOverrideUrl = m_strOverrideUrl; peNew.m_vTags = new List(m_vTags); return peNew; } public PwEntry CloneStructure() { PwEntry peNew = new PwEntry(false, false); peNew.m_uuid = m_uuid; // PwUuid is immutable peNew.m_tParentGroupLastMod = m_tParentGroupLastMod; // Do not assign m_pParentGroup return peNew; } private static PwCompareOptions BuildCmpOpt(bool bIgnoreParentGroup, bool bIgnoreLastMod, bool bIgnoreLastAccess, bool bIgnoreHistory, bool bIgnoreThisLastBackup) { PwCompareOptions pwOpt = PwCompareOptions.None; if(bIgnoreParentGroup) pwOpt |= PwCompareOptions.IgnoreParentGroup; if(bIgnoreLastMod) pwOpt |= PwCompareOptions.IgnoreLastMod; if(bIgnoreLastAccess) pwOpt |= PwCompareOptions.IgnoreLastAccess; if(bIgnoreHistory) pwOpt |= PwCompareOptions.IgnoreHistory; if(bIgnoreThisLastBackup) pwOpt |= PwCompareOptions.IgnoreLastBackup; return pwOpt; } [Obsolete] public bool EqualsEntry(PwEntry pe, bool bIgnoreParentGroup, bool bIgnoreLastMod, bool bIgnoreLastAccess, bool bIgnoreHistory, bool bIgnoreThisLastBackup) { return EqualsEntry(pe, BuildCmpOpt(bIgnoreParentGroup, bIgnoreLastMod, bIgnoreLastAccess, bIgnoreHistory, bIgnoreThisLastBackup), MemProtCmpMode.None); } [Obsolete] public bool EqualsEntry(PwEntry pe, bool bIgnoreParentGroup, bool bIgnoreLastMod, bool bIgnoreLastAccess, bool bIgnoreHistory, bool bIgnoreThisLastBackup, MemProtCmpMode mpCmpStr) { return EqualsEntry(pe, BuildCmpOpt(bIgnoreParentGroup, bIgnoreLastMod, bIgnoreLastAccess, bIgnoreHistory, bIgnoreThisLastBackup), mpCmpStr); } public bool EqualsEntry(PwEntry pe, PwCompareOptions pwOpt, MemProtCmpMode mpCmpStr) { if(pe == null) { Debug.Assert(false); return false; } bool bNeEqStd = ((pwOpt & PwCompareOptions.NullEmptyEquivStd) != PwCompareOptions.None); bool bIgnoreLastAccess = ((pwOpt & PwCompareOptions.IgnoreLastAccess) != PwCompareOptions.None); bool bIgnoreLastMod = ((pwOpt & PwCompareOptions.IgnoreLastMod) != PwCompareOptions.None); if(!m_uuid.Equals(pe.m_uuid)) return false; if((pwOpt & PwCompareOptions.IgnoreParentGroup) == PwCompareOptions.None) { if(m_pParentGroup != pe.m_pParentGroup) return false; if(!bIgnoreLastMod && (m_tParentGroupLastMod != pe.m_tParentGroupLastMod)) return false; } if(!m_listStrings.EqualsDictionary(pe.m_listStrings, pwOpt, mpCmpStr)) return false; if(!m_listBinaries.EqualsDictionary(pe.m_listBinaries)) return false; if(!m_listAutoType.Equals(pe.m_listAutoType)) return false; if((pwOpt & PwCompareOptions.IgnoreHistory) == PwCompareOptions.None) { bool bIgnoreLastBackup = ((pwOpt & PwCompareOptions.IgnoreLastBackup) != PwCompareOptions.None); if(!bIgnoreLastBackup && (m_listHistory.UCount != pe.m_listHistory.UCount)) return false; if(bIgnoreLastBackup && (m_listHistory.UCount == 0)) { Debug.Assert(false); return false; } if(bIgnoreLastBackup && ((m_listHistory.UCount - 1) != pe.m_listHistory.UCount)) return false; PwCompareOptions cmpSub = PwCompareOptions.IgnoreParentGroup; if(bNeEqStd) cmpSub |= PwCompareOptions.NullEmptyEquivStd; if(bIgnoreLastMod) cmpSub |= PwCompareOptions.IgnoreLastMod; if(bIgnoreLastAccess) cmpSub |= PwCompareOptions.IgnoreLastAccess; for(uint uHist = 0; uHist < pe.m_listHistory.UCount; ++uHist) { if(!m_listHistory.GetAt(uHist).EqualsEntry(pe.m_listHistory.GetAt( uHist), cmpSub, MemProtCmpMode.None)) return false; } } if(m_pwIcon != pe.m_pwIcon) return false; if(!m_pwCustomIconID.Equals(pe.m_pwCustomIconID)) return false; if(m_clrForeground != pe.m_clrForeground) return false; if(m_clrBackground != pe.m_clrBackground) return false; if(m_tCreation != pe.m_tCreation) return false; if(!bIgnoreLastMod && (m_tLastMod != pe.m_tLastMod)) return false; if(!bIgnoreLastAccess && (m_tLastAccess != pe.m_tLastAccess)) return false; if(m_tExpire != pe.m_tExpire) return false; if(m_bExpires != pe.m_bExpires) return false; if(!bIgnoreLastAccess && (m_uUsageCount != pe.m_uUsageCount)) return false; if(m_strOverrideUrl != pe.m_strOverrideUrl) return false; if(m_vTags.Count != pe.m_vTags.Count) return false; for(int iTag = 0; iTag < m_vTags.Count; ++iTag) { if(m_vTags[iTag] != pe.m_vTags[iTag]) return false; } return true; } /// /// Assign properties to the current entry based on a template entry. /// /// Template entry. Must not be null. /// Only set the properties of the template entry /// if it is newer than the current one. /// If true, the history will be /// copied, too. /// If true, the /// LocationChanged property is copied, otherwise not. public void AssignProperties(PwEntry peTemplate, bool bOnlyIfNewer, bool bIncludeHistory, bool bAssignLocationChanged) { Debug.Assert(peTemplate != null); if(peTemplate == null) throw new ArgumentNullException("peTemplate"); if(bOnlyIfNewer && (TimeUtil.Compare(peTemplate.m_tLastMod, m_tLastMod, true) < 0)) return; // Template UUID should be the same as the current one Debug.Assert(m_uuid.Equals(peTemplate.m_uuid)); m_uuid = peTemplate.m_uuid; if(bAssignLocationChanged) m_tParentGroupLastMod = peTemplate.m_tParentGroupLastMod; m_listStrings = peTemplate.m_listStrings; m_listBinaries = peTemplate.m_listBinaries; m_listAutoType = peTemplate.m_listAutoType; if(bIncludeHistory) m_listHistory = peTemplate.m_listHistory; m_pwIcon = peTemplate.m_pwIcon; m_pwCustomIconID = peTemplate.m_pwCustomIconID; // Immutable m_clrForeground = peTemplate.m_clrForeground; m_clrBackground = peTemplate.m_clrBackground; m_tCreation = peTemplate.m_tCreation; m_tLastMod = peTemplate.m_tLastMod; m_tLastAccess = peTemplate.m_tLastAccess; m_tExpire = peTemplate.m_tExpire; m_bExpires = peTemplate.m_bExpires; m_uUsageCount = peTemplate.m_uUsageCount; m_strOverrideUrl = peTemplate.m_strOverrideUrl; m_vTags = new List(peTemplate.m_vTags); } /// /// Touch the entry. This function updates the internal last access /// time. If the parameter is true, /// the last modification time gets updated, too. /// /// Modify last modification time. public void Touch(bool bModified) { Touch(bModified, true); } /// /// Touch the entry. This function updates the internal last access /// time. If the parameter is true, /// the last modification time gets updated, too. /// /// Modify last modification time. /// If true, all parent objects /// get touched, too. public void Touch(bool bModified, bool bTouchParents) { m_tLastAccess = DateTime.Now; ++m_uUsageCount; if(bModified) m_tLastMod = m_tLastAccess; if(this.Touched != null) this.Touched(this, new ObjectTouchedEventArgs(this, bModified, bTouchParents)); if(PwEntry.EntryTouched != null) PwEntry.EntryTouched(this, new ObjectTouchedEventArgs(this, bModified, bTouchParents)); if(bTouchParents && (m_pParentGroup != null)) m_pParentGroup.Touch(bModified, true); } /// /// Create a backup of this entry. The backup item doesn't contain any /// history items. /// [Obsolete] public void CreateBackup() { CreateBackup(null); } /// /// Create a backup of this entry. The backup item doesn't contain any /// history items. /// If this parameter isn't null, /// the history list is maintained automatically (i.e. old backups are /// deleted if there are too many or the history size is too large). /// This parameter may be null (no maintenance then). /// public void CreateBackup(PwDatabase pwHistMntcSettings) { PwEntry peCopy = CloneDeep(); peCopy.History = new PwObjectList(); // Remove history m_listHistory.Add(peCopy); // Must be added at end, see EqualsEntry if(pwHistMntcSettings != null) MaintainBackups(pwHistMntcSettings); } /// /// Restore an entry snapshot from backups. /// /// Index of the backup item, to which /// should be reverted. [Obsolete] public void RestoreFromBackup(uint uBackupIndex) { RestoreFromBackup(uBackupIndex, null); } /// /// Restore an entry snapshot from backups. /// /// Index of the backup item, to which /// should be reverted. /// If this parameter isn't null, /// the history list is maintained automatically (i.e. old backups are /// deleted if there are too many or the history size is too large). /// This parameter may be null (no maintenance then). public void RestoreFromBackup(uint uBackupIndex, PwDatabase pwHistMntcSettings) { Debug.Assert(uBackupIndex < m_listHistory.UCount); if(uBackupIndex >= m_listHistory.UCount) throw new ArgumentOutOfRangeException("uBackupIndex"); PwEntry pe = m_listHistory.GetAt(uBackupIndex); Debug.Assert(pe != null); if(pe == null) throw new InvalidOperationException(); CreateBackup(pwHistMntcSettings); // Backup current data before restoring AssignProperties(pe, false, false, false); } public bool HasBackupOfData(PwEntry peData, bool bIgnoreLastMod, bool bIgnoreLastAccess) { if(peData == null) { Debug.Assert(false); return false; } PwCompareOptions cmpOpt = (PwCompareOptions.IgnoreParentGroup | PwCompareOptions.IgnoreHistory | PwCompareOptions.NullEmptyEquivStd); if(bIgnoreLastMod) cmpOpt |= PwCompareOptions.IgnoreLastMod; if(bIgnoreLastAccess) cmpOpt |= PwCompareOptions.IgnoreLastAccess; foreach(PwEntry pe in m_listHistory) { if(pe.EqualsEntry(peData, cmpOpt, MemProtCmpMode.None)) return true; } return false; } /// /// Delete old history items if there are too many or the history /// size is too large. /// If one or more history items have been deleted, true /// is returned. Otherwise false. /// public bool MaintainBackups(PwDatabase pwSettings) { if(pwSettings == null) { Debug.Assert(false); return false; } bool bDeleted = false; int nMaxItems = pwSettings.HistoryMaxItems; if(nMaxItems >= 0) { while(m_listHistory.UCount > (uint)nMaxItems) { RemoveOldestBackup(); bDeleted = true; } } long lMaxSize = pwSettings.HistoryMaxSize; if(lMaxSize >= 0) { while(true) { ulong uHistSize = 0; foreach(PwEntry pe in m_listHistory) { uHistSize += pe.GetSize(); } if(uHistSize > (ulong)lMaxSize) { RemoveOldestBackup(); bDeleted = true; } else break; } } return bDeleted; } private void RemoveOldestBackup() { DateTime dtMin = DateTime.MaxValue; uint idxRemove = uint.MaxValue; for(uint u = 0; u < m_listHistory.UCount; ++u) { PwEntry pe = m_listHistory.GetAt(u); if(TimeUtil.Compare(pe.LastModificationTime, dtMin, true) < 0) { idxRemove = u; dtMin = pe.LastModificationTime; } } if(idxRemove != uint.MaxValue) m_listHistory.RemoveAt(idxRemove); } public bool GetAutoTypeEnabled() { if(!m_listAutoType.Enabled) return false; if(m_pParentGroup != null) return m_pParentGroup.GetAutoTypeEnabledInherited(); return PwGroup.DefaultAutoTypeEnabled; } public string GetAutoTypeSequence() { string strSeq = m_listAutoType.DefaultSequence; PwGroup pg = m_pParentGroup; while(pg != null) { if(strSeq.Length != 0) break; strSeq = pg.DefaultAutoTypeSequence; pg = pg.ParentGroup; } if(strSeq.Length != 0) return strSeq; if(PwDefs.IsTanEntry(this)) return PwDefs.DefaultAutoTypeSequenceTan; return PwDefs.DefaultAutoTypeSequence; } public bool GetSearchingEnabled() { if(m_pParentGroup != null) return m_pParentGroup.GetSearchingEnabledInherited(); return PwGroup.DefaultSearchingEnabled; } /// /// Approximate the total size of this entry in bytes (including /// strings, binaries and history entries). /// /// Size in bytes. public ulong GetSize() { ulong uSize = 128; // Approx fixed length data foreach(KeyValuePair kvpStr in m_listStrings) { uSize += (ulong)kvpStr.Key.Length; uSize += (ulong)kvpStr.Value.Length; } foreach(KeyValuePair kvpBin in m_listBinaries) { uSize += (ulong)kvpBin.Key.Length; uSize += kvpBin.Value.Length; } uSize += (ulong)m_listAutoType.DefaultSequence.Length; foreach(AutoTypeAssociation a in m_listAutoType.Associations) { uSize += (ulong)a.WindowName.Length; uSize += (ulong)a.Sequence.Length; } foreach(PwEntry peHistory in m_listHistory) uSize += peHistory.GetSize(); uSize += (ulong)m_strOverrideUrl.Length; foreach(string strTag in m_vTags) uSize += (ulong)strTag.Length; return uSize; } public bool HasTag(string strTag) { if(string.IsNullOrEmpty(strTag)) { Debug.Assert(false); return false; } for(int i = 0; i < m_vTags.Count; ++i) { if(m_vTags[i].Equals(strTag, StrUtil.CaseIgnoreCmp)) return true; } return false; } public bool AddTag(string strTag) { if(string.IsNullOrEmpty(strTag)) { Debug.Assert(false); return false; } for(int i = 0; i < m_vTags.Count; ++i) { if(m_vTags[i].Equals(strTag, StrUtil.CaseIgnoreCmp)) return false; } m_vTags.Add(strTag); return true; } public bool RemoveTag(string strTag) { if(string.IsNullOrEmpty(strTag)) { Debug.Assert(false); return false; } for(int i = 0; i < m_vTags.Count; ++i) { if(m_vTags[i].Equals(strTag, StrUtil.CaseIgnoreCmp)) { m_vTags.RemoveAt(i); return true; } } return false; } public bool IsContainedIn(PwGroup pgContainer) { PwGroup pgCur = m_pParentGroup; while(pgCur != null) { if(pgCur == pgContainer) return true; pgCur = pgCur.ParentGroup; } return false; } public void SetUuid(PwUuid pwNewUuid, bool bAlsoChangeHistoryUuids) { this.Uuid = pwNewUuid; if(bAlsoChangeHistoryUuids) { foreach(PwEntry peHist in m_listHistory) { peHist.Uuid = pwNewUuid; } } } } public sealed class PwEntryComparer : IComparer { private string m_strFieldName; private bool m_bCaseInsensitive; private bool m_bCompareNaturally; public PwEntryComparer(string strFieldName, bool bCaseInsensitive, bool bCompareNaturally) { if(strFieldName == null) throw new ArgumentNullException("strFieldName"); m_strFieldName = strFieldName; m_bCaseInsensitive = bCaseInsensitive; m_bCompareNaturally = bCompareNaturally; } public int Compare(PwEntry a, PwEntry b) { string strA = a.Strings.ReadSafe(m_strFieldName); string strB = b.Strings.ReadSafe(m_strFieldName); if(m_bCompareNaturally) return StrUtil.CompareNaturally(strA, strB); #if KeePassRT return string.Compare(strA, strB, m_bCaseInsensitive ? StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture); #else return string.Compare(strA, strB, m_bCaseInsensitive); #endif } } } keepass2-2.25/KeePassLib/Delegates/0000775000175000017500000000000012261553104016771 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLib/Delegates/Handlers.cs0000664000175000017500000000373012261553104021063 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; namespace KeePassLib.Delegates { /// /// Function definition of a method that performs an action on a group. /// When traversing the internal tree, this function will be invoked /// for all visited groups. /// /// Currently visited group. /// You must return true if you want to continue the /// traversal. If you want to immediately stop the whole traversal, /// return false. public delegate bool GroupHandler(PwGroup pg); /// /// Function definition of a method that performs an action on an entry. /// When traversing the internal tree, this function will be invoked /// for all visited entries. /// /// Currently visited entry. /// You must return true if you want to continue the /// traversal. If you want to immediately stop the whole traversal, /// return false. public delegate bool EntryHandler(PwEntry pe); public delegate void VoidDelegate(); public delegate string StrPwEntryDelegate(string str, PwEntry pe); } keepass2-2.25/KeePassLib/Serialization/0000775000175000017500000000000012261553106017713 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLib/Serialization/KdbxFile.Read.Streamed.cs0000664000175000017500000006475612261553106024371 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Resources; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePassLib.Serialization { /// /// Serialization to KeePass KDBX files. /// public sealed partial class KdbxFile { private enum KdbContext { Null, KeePassFile, Meta, Root, MemoryProtection, CustomIcons, CustomIcon, Binaries, CustomData, CustomDataItem, RootDeletedObjects, DeletedObject, Group, GroupTimes, Entry, EntryTimes, EntryString, EntryBinary, EntryAutoType, EntryAutoTypeItem, EntryHistory } private bool m_bReadNextNode = true; private Stack m_ctxGroups = new Stack(); private PwGroup m_ctxGroup = null; private PwEntry m_ctxEntry = null; private string m_ctxStringName = null; private ProtectedString m_ctxStringValue = null; private string m_ctxBinaryName = null; private ProtectedBinary m_ctxBinaryValue = null; private string m_ctxATName = null; private string m_ctxATSeq = null; private bool m_bEntryInHistory = false; private PwEntry m_ctxHistoryBase = null; private PwDeletedObject m_ctxDeletedObject = null; private PwUuid m_uuidCustomIconID = PwUuid.Zero; private byte[] m_pbCustomIconData = null; private string m_strCustomDataKey = null; private string m_strCustomDataValue = null; private void ReadXmlStreamed(Stream readerStream, Stream sParentStream) { ReadDocumentStreamed(CreateXmlReader(readerStream), sParentStream); } internal static XmlReaderSettings CreateStdXmlReaderSettings() { XmlReaderSettings xrs = new XmlReaderSettings(); xrs.CloseInput = true; xrs.IgnoreComments = true; xrs.IgnoreProcessingInstructions = true; xrs.IgnoreWhitespace = true; #if !KeePassRT #if !KeePassLibSD xrs.ProhibitDtd = true; #endif xrs.ValidationType = ValidationType.None; #endif return xrs; } private static XmlReader CreateXmlReader(Stream readerStream) { XmlReaderSettings xrs = CreateStdXmlReaderSettings(); return XmlReader.Create(readerStream, xrs); } private void ReadDocumentStreamed(XmlReader xr, Stream sParentStream) { Debug.Assert(xr != null); if(xr == null) throw new ArgumentNullException("xr"); m_ctxGroups.Clear(); m_dictBinPool = new Dictionary(); KdbContext ctx = KdbContext.Null; uint uTagCounter = 0; bool bSupportsStatus = (m_slLogger != null); long lStreamLength = 1; try { sParentStream.Position.ToString(); // Test Position support lStreamLength = sParentStream.Length; } catch(Exception) { bSupportsStatus = false; } if(lStreamLength <= 0) { Debug.Assert(false); lStreamLength = 1; } m_bReadNextNode = true; while(true) { if(m_bReadNextNode) { if(!xr.Read()) break; } else m_bReadNextNode = true; switch(xr.NodeType) { case XmlNodeType.Element: ctx = ReadXmlElement(ctx, xr); break; case XmlNodeType.EndElement: ctx = EndXmlElement(ctx, xr); break; case XmlNodeType.XmlDeclaration: break; // Ignore default: Debug.Assert(false); break; } ++uTagCounter; if(((uTagCounter % 256) == 0) && bSupportsStatus) { Debug.Assert(lStreamLength == sParentStream.Length); uint uPct = (uint)((sParentStream.Position * 100) / lStreamLength); // Clip percent value in case the stream reports incorrect // position/length values (M120413) if(uPct > 100) { Debug.Assert(false); uPct = 100; } m_slLogger.SetProgress(uPct); } } Debug.Assert(ctx == KdbContext.Null); if(ctx != KdbContext.Null) throw new FormatException(); Debug.Assert(m_ctxGroups.Count == 0); if(m_ctxGroups.Count != 0) throw new FormatException(); } private KdbContext ReadXmlElement(KdbContext ctx, XmlReader xr) { Debug.Assert(xr.NodeType == XmlNodeType.Element); switch(ctx) { case KdbContext.Null: if(xr.Name == ElemDocNode) return SwitchContext(ctx, KdbContext.KeePassFile, xr); else ReadUnknown(xr); break; case KdbContext.KeePassFile: if(xr.Name == ElemMeta) return SwitchContext(ctx, KdbContext.Meta, xr); else if(xr.Name == ElemRoot) return SwitchContext(ctx, KdbContext.Root, xr); else ReadUnknown(xr); break; case KdbContext.Meta: if(xr.Name == ElemGenerator) ReadString(xr); // Ignore else if(xr.Name == ElemHeaderHash) { string strHash = ReadString(xr); if(!string.IsNullOrEmpty(strHash) && (m_pbHashOfHeader != null) && !m_bRepairMode) { byte[] pbHash = Convert.FromBase64String(strHash); if(!MemUtil.ArraysEqual(pbHash, m_pbHashOfHeader)) throw new IOException(KLRes.FileCorrupted); } } else if(xr.Name == ElemDbName) m_pwDatabase.Name = ReadString(xr); else if(xr.Name == ElemDbNameChanged) m_pwDatabase.NameChanged = ReadTime(xr); else if(xr.Name == ElemDbDesc) m_pwDatabase.Description = ReadString(xr); else if(xr.Name == ElemDbDescChanged) m_pwDatabase.DescriptionChanged = ReadTime(xr); else if(xr.Name == ElemDbDefaultUser) m_pwDatabase.DefaultUserName = ReadString(xr); else if(xr.Name == ElemDbDefaultUserChanged) m_pwDatabase.DefaultUserNameChanged = ReadTime(xr); else if(xr.Name == ElemDbMntncHistoryDays) m_pwDatabase.MaintenanceHistoryDays = ReadUInt(xr, 365); else if(xr.Name == ElemDbColor) { string strColor = ReadString(xr); if(!string.IsNullOrEmpty(strColor)) m_pwDatabase.Color = ColorTranslator.FromHtml(strColor); } else if(xr.Name == ElemDbKeyChanged) m_pwDatabase.MasterKeyChanged = ReadTime(xr); else if(xr.Name == ElemDbKeyChangeRec) m_pwDatabase.MasterKeyChangeRec = ReadLong(xr, -1); else if(xr.Name == ElemDbKeyChangeForce) m_pwDatabase.MasterKeyChangeForce = ReadLong(xr, -1); else if(xr.Name == ElemMemoryProt) return SwitchContext(ctx, KdbContext.MemoryProtection, xr); else if(xr.Name == ElemCustomIcons) return SwitchContext(ctx, KdbContext.CustomIcons, xr); else if(xr.Name == ElemRecycleBinEnabled) m_pwDatabase.RecycleBinEnabled = ReadBool(xr, true); else if(xr.Name == ElemRecycleBinUuid) m_pwDatabase.RecycleBinUuid = ReadUuid(xr); else if(xr.Name == ElemRecycleBinChanged) m_pwDatabase.RecycleBinChanged = ReadTime(xr); else if(xr.Name == ElemEntryTemplatesGroup) m_pwDatabase.EntryTemplatesGroup = ReadUuid(xr); else if(xr.Name == ElemEntryTemplatesGroupChanged) m_pwDatabase.EntryTemplatesGroupChanged = ReadTime(xr); else if(xr.Name == ElemHistoryMaxItems) m_pwDatabase.HistoryMaxItems = ReadInt(xr, -1); else if(xr.Name == ElemHistoryMaxSize) m_pwDatabase.HistoryMaxSize = ReadLong(xr, -1); else if(xr.Name == ElemLastSelectedGroup) m_pwDatabase.LastSelectedGroup = ReadUuid(xr); else if(xr.Name == ElemLastTopVisibleGroup) m_pwDatabase.LastTopVisibleGroup = ReadUuid(xr); else if(xr.Name == ElemBinaries) return SwitchContext(ctx, KdbContext.Binaries, xr); else if(xr.Name == ElemCustomData) return SwitchContext(ctx, KdbContext.CustomData, xr); else ReadUnknown(xr); break; case KdbContext.MemoryProtection: if(xr.Name == ElemProtTitle) m_pwDatabase.MemoryProtection.ProtectTitle = ReadBool(xr, false); else if(xr.Name == ElemProtUserName) m_pwDatabase.MemoryProtection.ProtectUserName = ReadBool(xr, false); else if(xr.Name == ElemProtPassword) m_pwDatabase.MemoryProtection.ProtectPassword = ReadBool(xr, true); else if(xr.Name == ElemProtUrl) m_pwDatabase.MemoryProtection.ProtectUrl = ReadBool(xr, false); else if(xr.Name == ElemProtNotes) m_pwDatabase.MemoryProtection.ProtectNotes = ReadBool(xr, false); // else if(xr.Name == ElemProtAutoHide) // m_pwDatabase.MemoryProtection.AutoEnableVisualHiding = ReadBool(xr, true); else ReadUnknown(xr); break; case KdbContext.CustomIcons: if(xr.Name == ElemCustomIconItem) return SwitchContext(ctx, KdbContext.CustomIcon, xr); else ReadUnknown(xr); break; case KdbContext.CustomIcon: if(xr.Name == ElemCustomIconItemID) m_uuidCustomIconID = ReadUuid(xr); else if(xr.Name == ElemCustomIconItemData) { string strData = ReadString(xr); if(!string.IsNullOrEmpty(strData)) m_pbCustomIconData = Convert.FromBase64String(strData); else { Debug.Assert(false); } } else ReadUnknown(xr); break; case KdbContext.Binaries: if(xr.Name == ElemBinary) { if(xr.MoveToAttribute(AttrId)) { string strKey = xr.Value; ProtectedBinary pbData = ReadProtectedBinary(xr); m_dictBinPool[strKey ?? string.Empty] = pbData; } else ReadUnknown(xr); } else ReadUnknown(xr); break; case KdbContext.CustomData: if(xr.Name == ElemStringDictExItem) return SwitchContext(ctx, KdbContext.CustomDataItem, xr); else ReadUnknown(xr); break; case KdbContext.CustomDataItem: if(xr.Name == ElemKey) m_strCustomDataKey = ReadString(xr); else if(xr.Name == ElemValue) m_strCustomDataValue = ReadString(xr); else ReadUnknown(xr); break; case KdbContext.Root: if(xr.Name == ElemGroup) { Debug.Assert(m_ctxGroups.Count == 0); if(m_ctxGroups.Count != 0) throw new FormatException(); m_pwDatabase.RootGroup = new PwGroup(false, false); m_ctxGroups.Push(m_pwDatabase.RootGroup); m_ctxGroup = m_ctxGroups.Peek(); return SwitchContext(ctx, KdbContext.Group, xr); } else if(xr.Name == ElemDeletedObjects) return SwitchContext(ctx, KdbContext.RootDeletedObjects, xr); else ReadUnknown(xr); break; case KdbContext.Group: if(xr.Name == ElemUuid) m_ctxGroup.Uuid = ReadUuid(xr); else if(xr.Name == ElemName) m_ctxGroup.Name = ReadString(xr); else if(xr.Name == ElemNotes) m_ctxGroup.Notes = ReadString(xr); else if(xr.Name == ElemIcon) m_ctxGroup.IconId = (PwIcon)ReadInt(xr, (int)PwIcon.Folder); else if(xr.Name == ElemCustomIconID) m_ctxGroup.CustomIconUuid = ReadUuid(xr); else if(xr.Name == ElemTimes) return SwitchContext(ctx, KdbContext.GroupTimes, xr); else if(xr.Name == ElemIsExpanded) m_ctxGroup.IsExpanded = ReadBool(xr, true); else if(xr.Name == ElemGroupDefaultAutoTypeSeq) m_ctxGroup.DefaultAutoTypeSequence = ReadString(xr); else if(xr.Name == ElemEnableAutoType) m_ctxGroup.EnableAutoType = StrUtil.StringToBoolEx(ReadString(xr)); else if(xr.Name == ElemEnableSearching) m_ctxGroup.EnableSearching = StrUtil.StringToBoolEx(ReadString(xr)); else if(xr.Name == ElemLastTopVisibleEntry) m_ctxGroup.LastTopVisibleEntry = ReadUuid(xr); else if(xr.Name == ElemGroup) { m_ctxGroup = new PwGroup(false, false); m_ctxGroups.Peek().AddGroup(m_ctxGroup, true); m_ctxGroups.Push(m_ctxGroup); return SwitchContext(ctx, KdbContext.Group, xr); } else if(xr.Name == ElemEntry) { m_ctxEntry = new PwEntry(false, false); m_ctxGroup.AddEntry(m_ctxEntry, true); m_bEntryInHistory = false; return SwitchContext(ctx, KdbContext.Entry, xr); } else ReadUnknown(xr); break; case KdbContext.Entry: if(xr.Name == ElemUuid) m_ctxEntry.Uuid = ReadUuid(xr); else if(xr.Name == ElemIcon) m_ctxEntry.IconId = (PwIcon)ReadInt(xr, (int)PwIcon.Key); else if(xr.Name == ElemCustomIconID) m_ctxEntry.CustomIconUuid = ReadUuid(xr); else if(xr.Name == ElemFgColor) { string strColor = ReadString(xr); if(!string.IsNullOrEmpty(strColor)) m_ctxEntry.ForegroundColor = ColorTranslator.FromHtml(strColor); } else if(xr.Name == ElemBgColor) { string strColor = ReadString(xr); if(!string.IsNullOrEmpty(strColor)) m_ctxEntry.BackgroundColor = ColorTranslator.FromHtml(strColor); } else if(xr.Name == ElemOverrideUrl) m_ctxEntry.OverrideUrl = ReadString(xr); else if(xr.Name == ElemTags) m_ctxEntry.Tags = StrUtil.StringToTags(ReadString(xr)); else if(xr.Name == ElemTimes) return SwitchContext(ctx, KdbContext.EntryTimes, xr); else if(xr.Name == ElemString) return SwitchContext(ctx, KdbContext.EntryString, xr); else if(xr.Name == ElemBinary) return SwitchContext(ctx, KdbContext.EntryBinary, xr); else if(xr.Name == ElemAutoType) return SwitchContext(ctx, KdbContext.EntryAutoType, xr); else if(xr.Name == ElemHistory) { Debug.Assert(m_bEntryInHistory == false); if(m_bEntryInHistory == false) { m_ctxHistoryBase = m_ctxEntry; return SwitchContext(ctx, KdbContext.EntryHistory, xr); } else ReadUnknown(xr); } else ReadUnknown(xr); break; case KdbContext.GroupTimes: case KdbContext.EntryTimes: ITimeLogger tl = ((ctx == KdbContext.GroupTimes) ? (ITimeLogger)m_ctxGroup : (ITimeLogger)m_ctxEntry); Debug.Assert(tl != null); if(xr.Name == ElemCreationTime) tl.CreationTime = ReadTime(xr); else if(xr.Name == ElemLastModTime) tl.LastModificationTime = ReadTime(xr); else if(xr.Name == ElemLastAccessTime) tl.LastAccessTime = ReadTime(xr); else if(xr.Name == ElemExpiryTime) tl.ExpiryTime = ReadTime(xr); else if(xr.Name == ElemExpires) tl.Expires = ReadBool(xr, false); else if(xr.Name == ElemUsageCount) tl.UsageCount = ReadULong(xr, 0); else if(xr.Name == ElemLocationChanged) tl.LocationChanged = ReadTime(xr); else ReadUnknown(xr); break; case KdbContext.EntryString: if(xr.Name == ElemKey) m_ctxStringName = ReadString(xr); else if(xr.Name == ElemValue) m_ctxStringValue = ReadProtectedString(xr); else ReadUnknown(xr); break; case KdbContext.EntryBinary: if(xr.Name == ElemKey) m_ctxBinaryName = ReadString(xr); else if(xr.Name == ElemValue) m_ctxBinaryValue = ReadProtectedBinary(xr); else ReadUnknown(xr); break; case KdbContext.EntryAutoType: if(xr.Name == ElemAutoTypeEnabled) m_ctxEntry.AutoType.Enabled = ReadBool(xr, true); else if(xr.Name == ElemAutoTypeObfuscation) m_ctxEntry.AutoType.ObfuscationOptions = (AutoTypeObfuscationOptions)ReadInt(xr, 0); else if(xr.Name == ElemAutoTypeDefaultSeq) m_ctxEntry.AutoType.DefaultSequence = ReadString(xr); else if(xr.Name == ElemAutoTypeItem) return SwitchContext(ctx, KdbContext.EntryAutoTypeItem, xr); else ReadUnknown(xr); break; case KdbContext.EntryAutoTypeItem: if(xr.Name == ElemWindow) m_ctxATName = ReadString(xr); else if(xr.Name == ElemKeystrokeSequence) m_ctxATSeq = ReadString(xr); else ReadUnknown(xr); break; case KdbContext.EntryHistory: if(xr.Name == ElemEntry) { m_ctxEntry = new PwEntry(false, false); m_ctxHistoryBase.History.Add(m_ctxEntry); m_bEntryInHistory = true; return SwitchContext(ctx, KdbContext.Entry, xr); } else ReadUnknown(xr); break; case KdbContext.RootDeletedObjects: if(xr.Name == ElemDeletedObject) { m_ctxDeletedObject = new PwDeletedObject(); m_pwDatabase.DeletedObjects.Add(m_ctxDeletedObject); return SwitchContext(ctx, KdbContext.DeletedObject, xr); } else ReadUnknown(xr); break; case KdbContext.DeletedObject: if(xr.Name == ElemUuid) m_ctxDeletedObject.Uuid = ReadUuid(xr); else if(xr.Name == ElemDeletionTime) m_ctxDeletedObject.DeletionTime = ReadTime(xr); else ReadUnknown(xr); break; default: ReadUnknown(xr); break; } return ctx; } private KdbContext EndXmlElement(KdbContext ctx, XmlReader xr) { Debug.Assert(xr.NodeType == XmlNodeType.EndElement); if((ctx == KdbContext.KeePassFile) && (xr.Name == ElemDocNode)) return KdbContext.Null; else if((ctx == KdbContext.Meta) && (xr.Name == ElemMeta)) return KdbContext.KeePassFile; else if((ctx == KdbContext.Root) && (xr.Name == ElemRoot)) return KdbContext.KeePassFile; else if((ctx == KdbContext.MemoryProtection) && (xr.Name == ElemMemoryProt)) return KdbContext.Meta; else if((ctx == KdbContext.CustomIcons) && (xr.Name == ElemCustomIcons)) return KdbContext.Meta; else if((ctx == KdbContext.CustomIcon) && (xr.Name == ElemCustomIconItem)) { if(!m_uuidCustomIconID.Equals(PwUuid.Zero) && (m_pbCustomIconData != null)) m_pwDatabase.CustomIcons.Add(new PwCustomIcon( m_uuidCustomIconID, m_pbCustomIconData)); else { Debug.Assert(false); } m_uuidCustomIconID = PwUuid.Zero; m_pbCustomIconData = null; return KdbContext.CustomIcons; } else if((ctx == KdbContext.Binaries) && (xr.Name == ElemBinaries)) return KdbContext.Meta; else if((ctx == KdbContext.CustomData) && (xr.Name == ElemCustomData)) return KdbContext.Meta; else if((ctx == KdbContext.CustomDataItem) && (xr.Name == ElemStringDictExItem)) { if((m_strCustomDataKey != null) && (m_strCustomDataValue != null)) m_pwDatabase.CustomData.Set(m_strCustomDataKey, m_strCustomDataValue); else { Debug.Assert(false); } m_strCustomDataKey = null; m_strCustomDataValue = null; return KdbContext.CustomData; } else if((ctx == KdbContext.Group) && (xr.Name == ElemGroup)) { if(PwUuid.Zero.Equals(m_ctxGroup.Uuid)) m_ctxGroup.Uuid = new PwUuid(true); // No assert (import) m_ctxGroups.Pop(); if(m_ctxGroups.Count == 0) { m_ctxGroup = null; return KdbContext.Root; } else { m_ctxGroup = m_ctxGroups.Peek(); return KdbContext.Group; } } else if((ctx == KdbContext.GroupTimes) && (xr.Name == ElemTimes)) return KdbContext.Group; else if((ctx == KdbContext.Entry) && (xr.Name == ElemEntry)) { // Create new UUID if absent if(PwUuid.Zero.Equals(m_ctxEntry.Uuid)) m_ctxEntry.Uuid = new PwUuid(true); // No assert (import) if(m_bEntryInHistory) { m_ctxEntry = m_ctxHistoryBase; return KdbContext.EntryHistory; } return KdbContext.Group; } else if((ctx == KdbContext.EntryTimes) && (xr.Name == ElemTimes)) return KdbContext.Entry; else if((ctx == KdbContext.EntryString) && (xr.Name == ElemString)) { m_ctxEntry.Strings.Set(m_ctxStringName, m_ctxStringValue); m_ctxStringName = null; m_ctxStringValue = null; return KdbContext.Entry; } else if((ctx == KdbContext.EntryBinary) && (xr.Name == ElemBinary)) { if(string.IsNullOrEmpty(m_strDetachBins)) m_ctxEntry.Binaries.Set(m_ctxBinaryName, m_ctxBinaryValue); else { SaveBinary(m_ctxBinaryName, m_ctxBinaryValue, m_strDetachBins); m_ctxBinaryValue = null; GC.Collect(); } m_ctxBinaryName = null; m_ctxBinaryValue = null; return KdbContext.Entry; } else if((ctx == KdbContext.EntryAutoType) && (xr.Name == ElemAutoType)) return KdbContext.Entry; else if((ctx == KdbContext.EntryAutoTypeItem) && (xr.Name == ElemAutoTypeItem)) { AutoTypeAssociation atAssoc = new AutoTypeAssociation(m_ctxATName, m_ctxATSeq); m_ctxEntry.AutoType.Add(atAssoc); m_ctxATName = null; m_ctxATSeq = null; return KdbContext.EntryAutoType; } else if((ctx == KdbContext.EntryHistory) && (xr.Name == ElemHistory)) { m_bEntryInHistory = false; return KdbContext.Entry; } else if((ctx == KdbContext.RootDeletedObjects) && (xr.Name == ElemDeletedObjects)) return KdbContext.Root; else if((ctx == KdbContext.DeletedObject) && (xr.Name == ElemDeletedObject)) { m_ctxDeletedObject = null; return KdbContext.RootDeletedObjects; } else { Debug.Assert(false); throw new FormatException(); } } private string ReadString(XmlReader xr) { XorredBuffer xb = ProcessNode(xr); if(xb != null) { byte[] pb = xb.ReadPlainText(); if(pb.Length == 0) return string.Empty; return StrUtil.Utf8.GetString(pb, 0, pb.Length); } m_bReadNextNode = false; // ReadElementString skips end tag return xr.ReadElementString(); } private string ReadStringRaw(XmlReader xr) { m_bReadNextNode = false; // ReadElementString skips end tag return xr.ReadElementString(); } private bool ReadBool(XmlReader xr, bool bDefault) { string str = ReadString(xr); if(str == ValTrue) return true; else if(str == ValFalse) return false; Debug.Assert(false); return bDefault; } private PwUuid ReadUuid(XmlReader xr) { string str = ReadString(xr); if(string.IsNullOrEmpty(str)) return PwUuid.Zero; return new PwUuid(Convert.FromBase64String(str)); } private int ReadInt(XmlReader xr, int nDefault) { string str = ReadString(xr); int n; if(StrUtil.TryParseIntInvariant(str, out n)) return n; // Backward compatibility if(StrUtil.TryParseInt(str, out n)) return n; Debug.Assert(false); return nDefault; } private uint ReadUInt(XmlReader xr, uint uDefault) { string str = ReadString(xr); uint u; if(StrUtil.TryParseUIntInvariant(str, out u)) return u; // Backward compatibility if(StrUtil.TryParseUInt(str, out u)) return u; Debug.Assert(false); return uDefault; } private long ReadLong(XmlReader xr, long lDefault) { string str = ReadString(xr); long l; if(StrUtil.TryParseLongInvariant(str, out l)) return l; // Backward compatibility if(StrUtil.TryParseLong(str, out l)) return l; Debug.Assert(false); return lDefault; } private ulong ReadULong(XmlReader xr, ulong uDefault) { string str = ReadString(xr); ulong u; if(StrUtil.TryParseULongInvariant(str, out u)) return u; // Backward compatibility if(StrUtil.TryParseULong(str, out u)) return u; Debug.Assert(false); return uDefault; } private DateTime ReadTime(XmlReader xr) { string str = ReadString(xr); DateTime dt; if(TimeUtil.TryDeserializeUtc(str, out dt)) return dt; Debug.Assert(false); return m_dtNow; } private ProtectedString ReadProtectedString(XmlReader xr) { XorredBuffer xb = ProcessNode(xr); if(xb != null) return new ProtectedString(true, xb); bool bProtect = false; if(m_format == KdbxFormat.PlainXml) { if(xr.MoveToAttribute(AttrProtectedInMemPlainXml)) { string strProtect = xr.Value; bProtect = ((strProtect != null) && (strProtect == ValTrue)); } } ProtectedString ps = new ProtectedString(bProtect, ReadString(xr)); return ps; } private ProtectedBinary ReadProtectedBinary(XmlReader xr) { if(xr.MoveToAttribute(AttrRef)) { string strRef = xr.Value; if(strRef != null) { ProtectedBinary pb = BinPoolGet(strRef); if(pb != null) return pb; else { Debug.Assert(false); } } else { Debug.Assert(false); } } bool bCompressed = false; if(xr.MoveToAttribute(AttrCompressed)) bCompressed = (xr.Value == ValTrue); XorredBuffer xb = ProcessNode(xr); if(xb != null) { Debug.Assert(!bCompressed); // See SubWriteValue(ProtectedBinary value) return new ProtectedBinary(true, xb); } string strValue = ReadString(xr); if(strValue.Length == 0) return new ProtectedBinary(); byte[] pbData = Convert.FromBase64String(strValue); if(bCompressed) pbData = MemUtil.Decompress(pbData); return new ProtectedBinary(false, pbData); } private void ReadUnknown(XmlReader xr) { Debug.Assert(false); // Unknown node! if(xr.IsEmptyElement) return; string strUnknownName = xr.Name; ProcessNode(xr); while(xr.Read()) { if(xr.NodeType == XmlNodeType.EndElement) break; if(xr.NodeType != XmlNodeType.Element) continue; ReadUnknown(xr); } Debug.Assert(xr.Name == strUnknownName); } private XorredBuffer ProcessNode(XmlReader xr) { // Debug.Assert(xr.NodeType == XmlNodeType.Element); XorredBuffer xb = null; if(xr.HasAttributes) { if(xr.MoveToAttribute(AttrProtected)) { if(xr.Value == ValTrue) { xr.MoveToElement(); string strEncrypted = ReadStringRaw(xr); byte[] pbEncrypted; if(strEncrypted.Length > 0) pbEncrypted = Convert.FromBase64String(strEncrypted); else pbEncrypted = new byte[0]; byte[] pbPad = m_randomStream.GetRandomBytes((uint)pbEncrypted.Length); xb = new XorredBuffer(pbEncrypted, pbPad); } } } return xb; } private static KdbContext SwitchContext(KdbContext ctxCurrent, KdbContext ctxNew, XmlReader xr) { if(xr.IsEmptyElement) return ctxCurrent; return ctxNew; } } } keepass2-2.25/KeePassLib/Serialization/KdbxFile.cs0000664000175000017500000003226612261553106021743 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml; using System.Text; using System.Globalization; using System.IO; using System.Diagnostics; #if !KeePassLibSD using System.IO.Compression; #endif using KeePassLib.Collections; using KeePassLib.Cryptography; using KeePassLib.Delegates; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePassLib.Serialization { /// /// The KdbxFile class supports saving the data to various /// formats. /// public enum KdbxFormat { /// /// The default, encrypted file format. /// Default = 0, /// /// Use this flag when exporting data to a plain-text XML file. /// PlainXml } /// /// Serialization to KeePass KDBX files. /// public sealed partial class KdbxFile { /// /// File identifier, first 32-bit value. /// internal const uint FileSignature1 = 0x9AA2D903; /// /// File identifier, second 32-bit value. /// internal const uint FileSignature2 = 0xB54BFB67; /// /// File version of files saved by the current KdbxFile class. /// KeePass 2.07 has version 1.01, 2.08 has 1.02, 2.09 has 2.00, /// 2.10 has 2.02, 2.11 has 2.04, 2.15 has 3.00, 2.20 has 3.01. /// The first 2 bytes are critical (i.e. loading will fail, if the /// file version is too high), the last 2 bytes are informational. /// private const uint FileVersion32 = 0x00030001; private const uint FileVersionCriticalMask = 0xFFFF0000; // KeePass 1.x signature internal const uint FileSignatureOld1 = 0x9AA2D903; internal const uint FileSignatureOld2 = 0xB54BFB65; // KeePass 2.x pre-release (alpha and beta) signature internal const uint FileSignaturePreRelease1 = 0x9AA2D903; internal const uint FileSignaturePreRelease2 = 0xB54BFB66; private const string ElemDocNode = "KeePassFile"; private const string ElemMeta = "Meta"; private const string ElemRoot = "Root"; private const string ElemGroup = "Group"; private const string ElemEntry = "Entry"; private const string ElemGenerator = "Generator"; private const string ElemHeaderHash = "HeaderHash"; private const string ElemDbName = "DatabaseName"; private const string ElemDbNameChanged = "DatabaseNameChanged"; private const string ElemDbDesc = "DatabaseDescription"; private const string ElemDbDescChanged = "DatabaseDescriptionChanged"; private const string ElemDbDefaultUser = "DefaultUserName"; private const string ElemDbDefaultUserChanged = "DefaultUserNameChanged"; private const string ElemDbMntncHistoryDays = "MaintenanceHistoryDays"; private const string ElemDbColor = "Color"; private const string ElemDbKeyChanged = "MasterKeyChanged"; private const string ElemDbKeyChangeRec = "MasterKeyChangeRec"; private const string ElemDbKeyChangeForce = "MasterKeyChangeForce"; private const string ElemRecycleBinEnabled = "RecycleBinEnabled"; private const string ElemRecycleBinUuid = "RecycleBinUUID"; private const string ElemRecycleBinChanged = "RecycleBinChanged"; private const string ElemEntryTemplatesGroup = "EntryTemplatesGroup"; private const string ElemEntryTemplatesGroupChanged = "EntryTemplatesGroupChanged"; private const string ElemHistoryMaxItems = "HistoryMaxItems"; private const string ElemHistoryMaxSize = "HistoryMaxSize"; private const string ElemLastSelectedGroup = "LastSelectedGroup"; private const string ElemLastTopVisibleGroup = "LastTopVisibleGroup"; private const string ElemMemoryProt = "MemoryProtection"; private const string ElemProtTitle = "ProtectTitle"; private const string ElemProtUserName = "ProtectUserName"; private const string ElemProtPassword = "ProtectPassword"; private const string ElemProtUrl = "ProtectURL"; private const string ElemProtNotes = "ProtectNotes"; // private const string ElemProtAutoHide = "AutoEnableVisualHiding"; private const string ElemCustomIcons = "CustomIcons"; private const string ElemCustomIconItem = "Icon"; private const string ElemCustomIconItemID = "UUID"; private const string ElemCustomIconItemData = "Data"; private const string ElemAutoType = "AutoType"; private const string ElemHistory = "History"; private const string ElemName = "Name"; private const string ElemNotes = "Notes"; private const string ElemUuid = "UUID"; private const string ElemIcon = "IconID"; private const string ElemCustomIconID = "CustomIconUUID"; private const string ElemFgColor = "ForegroundColor"; private const string ElemBgColor = "BackgroundColor"; private const string ElemOverrideUrl = "OverrideURL"; private const string ElemTimes = "Times"; private const string ElemTags = "Tags"; private const string ElemCreationTime = "CreationTime"; private const string ElemLastModTime = "LastModificationTime"; private const string ElemLastAccessTime = "LastAccessTime"; private const string ElemExpiryTime = "ExpiryTime"; private const string ElemExpires = "Expires"; private const string ElemUsageCount = "UsageCount"; private const string ElemLocationChanged = "LocationChanged"; private const string ElemGroupDefaultAutoTypeSeq = "DefaultAutoTypeSequence"; private const string ElemEnableAutoType = "EnableAutoType"; private const string ElemEnableSearching = "EnableSearching"; private const string ElemString = "String"; private const string ElemBinary = "Binary"; private const string ElemKey = "Key"; private const string ElemValue = "Value"; private const string ElemAutoTypeEnabled = "Enabled"; private const string ElemAutoTypeObfuscation = "DataTransferObfuscation"; private const string ElemAutoTypeDefaultSeq = "DefaultSequence"; private const string ElemAutoTypeItem = "Association"; private const string ElemWindow = "Window"; private const string ElemKeystrokeSequence = "KeystrokeSequence"; private const string ElemBinaries = "Binaries"; private const string AttrId = "ID"; private const string AttrRef = "Ref"; private const string AttrProtected = "Protected"; private const string AttrProtectedInMemPlainXml = "ProtectInMemory"; private const string AttrCompressed = "Compressed"; private const string ElemIsExpanded = "IsExpanded"; private const string ElemLastTopVisibleEntry = "LastTopVisibleEntry"; private const string ElemDeletedObjects = "DeletedObjects"; private const string ElemDeletedObject = "DeletedObject"; private const string ElemDeletionTime = "DeletionTime"; private const string ValFalse = "False"; private const string ValTrue = "True"; private const string ElemCustomData = "CustomData"; private const string ElemStringDictExItem = "Item"; private PwDatabase m_pwDatabase; // Not null, see constructor private XmlTextWriter m_xmlWriter = null; private CryptoRandomStream m_randomStream = null; private KdbxFormat m_format = KdbxFormat.Default; private IStatusLogger m_slLogger = null; private byte[] m_pbMasterSeed = null; private byte[] m_pbTransformSeed = null; private byte[] m_pbEncryptionIV = null; private byte[] m_pbProtectedStreamKey = null; private byte[] m_pbStreamStartBytes = null; // ArcFourVariant only for compatibility; KeePass will default to a // different (more secure) algorithm when *writing* databases private CrsAlgorithm m_craInnerRandomStream = CrsAlgorithm.ArcFourVariant; private Dictionary m_dictBinPool = new Dictionary(); private byte[] m_pbHashOfHeader = null; private byte[] m_pbHashOfFileOnDisk = null; private readonly DateTime m_dtNow = DateTime.Now; // Cache current time private const uint NeutralLanguageOffset = 0x100000; // 2^20, see 32-bit Unicode specs private const uint NeutralLanguageIDSec = 0x7DC5C; // See 32-bit Unicode specs private const uint NeutralLanguageID = NeutralLanguageOffset + NeutralLanguageIDSec; private static bool m_bLocalizedNames = false; private enum KdbxHeaderFieldID : byte { EndOfHeader = 0, Comment = 1, CipherID = 2, CompressionFlags = 3, MasterSeed = 4, TransformSeed = 5, TransformRounds = 6, EncryptionIV = 7, ProtectedStreamKey = 8, StreamStartBytes = 9, InnerRandomStreamID = 10 } public byte[] HashOfFileOnDisk { get { return m_pbHashOfFileOnDisk; } } private bool m_bRepairMode = false; public bool RepairMode { get { return m_bRepairMode; } set { m_bRepairMode = value; } } private string m_strDetachBins = null; /// /// Detach binaries when opening a file. If this isn't null, /// all binaries are saved to the specified path and are removed /// from the database. /// public string DetachBinaries { get { return m_strDetachBins; } set { m_strDetachBins = value; } } /// /// Default constructor. /// /// The PwDatabase instance that the /// class will load file data into or use to create a KDBX file. public KdbxFile(PwDatabase pwDataStore) { Debug.Assert(pwDataStore != null); if(pwDataStore == null) throw new ArgumentNullException("pwDataStore"); m_pwDatabase = pwDataStore; } /// /// Call this once to determine the current localization settings. /// public static void DetermineLanguageId() { // Test if localized names should be used. If localized names are used, // the m_bLocalizedNames value must be set to true. By default, localized // names should be used! (Otherwise characters could be corrupted // because of different code pages). unchecked { uint uTest = 0; foreach(char ch in PwDatabase.LocalizedAppName) uTest = uTest * 5 + ch; m_bLocalizedNames = (uTest != NeutralLanguageID); } } private void BinPoolBuild(PwGroup pgDataSource) { m_dictBinPool = new Dictionary(); if(pgDataSource == null) { Debug.Assert(false); return; } EntryHandler eh = delegate(PwEntry pe) { foreach(PwEntry peHistory in pe.History) { BinPoolAdd(peHistory.Binaries); } BinPoolAdd(pe.Binaries); return true; }; pgDataSource.TraverseTree(TraversalMethod.PreOrder, null, eh); } private void BinPoolAdd(ProtectedBinaryDictionary dict) { foreach(KeyValuePair kvp in dict) { BinPoolAdd(kvp.Value); } } private void BinPoolAdd(ProtectedBinary pb) { if(pb == null) { Debug.Assert(false); return; } if(BinPoolFind(pb) != null) return; // Exists already m_dictBinPool.Add(m_dictBinPool.Count.ToString( NumberFormatInfo.InvariantInfo), pb); } private string BinPoolFind(ProtectedBinary pb) { if(pb == null) { Debug.Assert(false); return null; } foreach(KeyValuePair kvp in m_dictBinPool) { if(pb.Equals(kvp.Value)) return kvp.Key; } return null; } private ProtectedBinary BinPoolGet(string strKey) { if(strKey == null) { Debug.Assert(false); return null; } ProtectedBinary pb; if(m_dictBinPool.TryGetValue(strKey, out pb)) return pb; return null; } private static void SaveBinary(string strName, ProtectedBinary pb, string strSaveDir) { if(pb == null) { Debug.Assert(false); return; } if(string.IsNullOrEmpty(strName)) strName = "File.bin"; string strPath; int iTry = 1; do { strPath = UrlUtil.EnsureTerminatingSeparator(strSaveDir, false); string strExt = UrlUtil.GetExtension(strName); string strDesc = UrlUtil.StripExtension(strName); strPath += strDesc; if(iTry > 1) strPath += " (" + iTry.ToString(NumberFormatInfo.InvariantInfo) + ")"; if(!string.IsNullOrEmpty(strExt)) strPath += "." + strExt; ++iTry; } while(File.Exists(strPath)); #if !KeePassLibSD byte[] pbData = pb.ReadData(); File.WriteAllBytes(strPath, pbData); MemUtil.ZeroByteArray(pbData); #else FileStream fs = new FileStream(strPath, FileMode.Create, FileAccess.Write, FileShare.None); byte[] pbData = pb.ReadData(); fs.Write(pbData, 0, pbData.Length); fs.Close(); #endif } } } keepass2-2.25/KeePassLib/Serialization/KdbxFile.Write.cs0000664000175000017500000006555412261553106023042 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml; using System.Security; using System.Security.Cryptography; using System.Drawing; using System.Globalization; using System.Diagnostics; #if !KeePassLibSD using System.IO.Compression; #else using KeePassLibSD; #endif using KeePassLib.Collections; using KeePassLib.Cryptography; using KeePassLib.Cryptography.Cipher; using KeePassLib.Delegates; using KeePassLib.Interfaces; using KeePassLib.Keys; using KeePassLib.Resources; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePassLib.Serialization { /// /// Serialization to KeePass KDBX files. /// public sealed partial class KdbxFile { // public void Save(string strFile, PwGroup pgDataSource, KdbxFormat format, // IStatusLogger slLogger) // { // bool bMadeUnhidden = UrlUtil.UnhideFile(strFile); // // IOConnectionInfo ioc = IOConnectionInfo.FromPath(strFile); // this.Save(IOConnection.OpenWrite(ioc), pgDataSource, format, slLogger); // // if(bMadeUnhidden) UrlUtil.HideFile(strFile, true); // Hide again // } /// /// Save the contents of the current PwDatabase to a KDBX file. /// /// Stream to write the KDBX file into. /// Group containing all groups and /// entries to write. If null, the complete database will /// be written. /// Format of the file to create. /// Logger that recieves status information. public void Save(Stream sSaveTo, PwGroup pgDataSource, KdbxFormat format, IStatusLogger slLogger) { Debug.Assert(sSaveTo != null); if(sSaveTo == null) throw new ArgumentNullException("sSaveTo"); m_format = format; m_slLogger = slLogger; HashingStreamEx hashedStream = new HashingStreamEx(sSaveTo, true, null); UTF8Encoding encNoBom = StrUtil.Utf8; CryptoRandom cr = CryptoRandom.Instance; try { m_pbMasterSeed = cr.GetRandomBytes(32); m_pbTransformSeed = cr.GetRandomBytes(32); m_pbEncryptionIV = cr.GetRandomBytes(16); m_pbProtectedStreamKey = cr.GetRandomBytes(32); m_craInnerRandomStream = CrsAlgorithm.Salsa20; m_randomStream = new CryptoRandomStream(m_craInnerRandomStream, m_pbProtectedStreamKey); m_pbStreamStartBytes = cr.GetRandomBytes(32); Stream writerStream; if(m_format == KdbxFormat.Default) { WriteHeader(hashedStream); // Also flushes the stream Stream sEncrypted = AttachStreamEncryptor(hashedStream); if((sEncrypted == null) || (sEncrypted == hashedStream)) throw new SecurityException(KLRes.CryptoStreamFailed); sEncrypted.Write(m_pbStreamStartBytes, 0, m_pbStreamStartBytes.Length); Stream sHashed = new HashedBlockStream(sEncrypted, true); if(m_pwDatabase.Compression == PwCompressionAlgorithm.GZip) writerStream = new GZipStream(sHashed, CompressionMode.Compress); else writerStream = sHashed; } else if(m_format == KdbxFormat.PlainXml) writerStream = hashedStream; else { Debug.Assert(false); throw new FormatException("KdbFormat"); } m_xmlWriter = new XmlTextWriter(writerStream, encNoBom); WriteDocument(pgDataSource); m_xmlWriter.Flush(); m_xmlWriter.Close(); writerStream.Close(); } finally { CommonCleanUpWrite(sSaveTo, hashedStream); } } private void CommonCleanUpWrite(Stream sSaveTo, HashingStreamEx hashedStream) { hashedStream.Close(); m_pbHashOfFileOnDisk = hashedStream.Hash; sSaveTo.Close(); m_xmlWriter = null; m_pbHashOfHeader = null; } private void WriteHeader(Stream s) { MemoryStream ms = new MemoryStream(); MemUtil.Write(ms, MemUtil.UInt32ToBytes(FileSignature1)); MemUtil.Write(ms, MemUtil.UInt32ToBytes(FileSignature2)); MemUtil.Write(ms, MemUtil.UInt32ToBytes(FileVersion32)); WriteHeaderField(ms, KdbxHeaderFieldID.CipherID, m_pwDatabase.DataCipherUuid.UuidBytes); int nCprID = (int)m_pwDatabase.Compression; WriteHeaderField(ms, KdbxHeaderFieldID.CompressionFlags, MemUtil.UInt32ToBytes((uint)nCprID)); WriteHeaderField(ms, KdbxHeaderFieldID.MasterSeed, m_pbMasterSeed); WriteHeaderField(ms, KdbxHeaderFieldID.TransformSeed, m_pbTransformSeed); WriteHeaderField(ms, KdbxHeaderFieldID.TransformRounds, MemUtil.UInt64ToBytes(m_pwDatabase.KeyEncryptionRounds)); WriteHeaderField(ms, KdbxHeaderFieldID.EncryptionIV, m_pbEncryptionIV); WriteHeaderField(ms, KdbxHeaderFieldID.ProtectedStreamKey, m_pbProtectedStreamKey); WriteHeaderField(ms, KdbxHeaderFieldID.StreamStartBytes, m_pbStreamStartBytes); int nIrsID = (int)m_craInnerRandomStream; WriteHeaderField(ms, KdbxHeaderFieldID.InnerRandomStreamID, MemUtil.UInt32ToBytes((uint)nIrsID)); WriteHeaderField(ms, KdbxHeaderFieldID.EndOfHeader, new byte[]{ (byte)'\r', (byte)'\n', (byte)'\r', (byte)'\n' }); byte[] pbHeader = ms.ToArray(); ms.Close(); SHA256Managed sha256 = new SHA256Managed(); m_pbHashOfHeader = sha256.ComputeHash(pbHeader); s.Write(pbHeader, 0, pbHeader.Length); s.Flush(); } private static void WriteHeaderField(Stream s, KdbxHeaderFieldID kdbID, byte[] pbData) { s.WriteByte((byte)kdbID); if(pbData != null) { ushort uLength = (ushort)pbData.Length; MemUtil.Write(s, MemUtil.UInt16ToBytes(uLength)); if(uLength > 0) s.Write(pbData, 0, pbData.Length); } else MemUtil.Write(s, MemUtil.UInt16ToBytes((ushort)0)); } private Stream AttachStreamEncryptor(Stream s) { MemoryStream ms = new MemoryStream(); Debug.Assert(m_pbMasterSeed != null); Debug.Assert(m_pbMasterSeed.Length == 32); ms.Write(m_pbMasterSeed, 0, 32); Debug.Assert(m_pwDatabase != null); Debug.Assert(m_pwDatabase.MasterKey != null); ProtectedBinary pbinKey = m_pwDatabase.MasterKey.GenerateKey32( m_pbTransformSeed, m_pwDatabase.KeyEncryptionRounds); Debug.Assert(pbinKey != null); if(pbinKey == null) throw new SecurityException(KLRes.InvalidCompositeKey); byte[] pKey32 = pbinKey.ReadData(); if((pKey32 == null) || (pKey32.Length != 32)) throw new SecurityException(KLRes.InvalidCompositeKey); ms.Write(pKey32, 0, 32); SHA256Managed sha256 = new SHA256Managed(); byte[] aesKey = sha256.ComputeHash(ms.ToArray()); ms.Close(); Array.Clear(pKey32, 0, 32); Debug.Assert(CipherPool.GlobalPool != null); ICipherEngine iEngine = CipherPool.GlobalPool.GetCipher(m_pwDatabase.DataCipherUuid); if(iEngine == null) throw new SecurityException(KLRes.FileUnknownCipher); return iEngine.EncryptStream(s, aesKey, m_pbEncryptionIV); } private void WriteDocument(PwGroup pgDataSource) { Debug.Assert(m_xmlWriter != null); if(m_xmlWriter == null) throw new InvalidOperationException(); PwGroup pgRoot = (pgDataSource ?? m_pwDatabase.RootGroup); uint uNumGroups, uNumEntries, uCurEntry = 0; pgRoot.GetCounts(true, out uNumGroups, out uNumEntries); BinPoolBuild(pgRoot); m_xmlWriter.Formatting = Formatting.Indented; m_xmlWriter.IndentChar = '\t'; m_xmlWriter.Indentation = 1; m_xmlWriter.WriteStartDocument(true); m_xmlWriter.WriteStartElement(ElemDocNode); WriteMeta(); m_xmlWriter.WriteStartElement(ElemRoot); StartGroup(pgRoot); Stack groupStack = new Stack(); groupStack.Push(pgRoot); GroupHandler gh = delegate(PwGroup pg) { Debug.Assert(pg != null); if(pg == null) throw new ArgumentNullException("pg"); while(true) { if(pg.ParentGroup == groupStack.Peek()) { groupStack.Push(pg); StartGroup(pg); break; } else { groupStack.Pop(); if(groupStack.Count <= 0) return false; EndGroup(); } } return true; }; EntryHandler eh = delegate(PwEntry pe) { Debug.Assert(pe != null); WriteEntry(pe, false); ++uCurEntry; if(m_slLogger != null) if(!m_slLogger.SetProgress((100 * uCurEntry) / uNumEntries)) return false; return true; }; if(!pgRoot.TraverseTree(TraversalMethod.PreOrder, gh, eh)) throw new InvalidOperationException(); while(groupStack.Count > 1) { m_xmlWriter.WriteEndElement(); groupStack.Pop(); } EndGroup(); WriteList(ElemDeletedObjects, m_pwDatabase.DeletedObjects); m_xmlWriter.WriteEndElement(); // Root m_xmlWriter.WriteEndElement(); // ElemDocNode m_xmlWriter.WriteEndDocument(); } private void WriteMeta() { m_xmlWriter.WriteStartElement(ElemMeta); WriteObject(ElemGenerator, PwDatabase.LocalizedAppName, false); // Generator name if(m_pbHashOfHeader != null) WriteObject(ElemHeaderHash, Convert.ToBase64String( m_pbHashOfHeader), false); WriteObject(ElemDbName, m_pwDatabase.Name, true); WriteObject(ElemDbNameChanged, m_pwDatabase.NameChanged); WriteObject(ElemDbDesc, m_pwDatabase.Description, true); WriteObject(ElemDbDescChanged, m_pwDatabase.DescriptionChanged); WriteObject(ElemDbDefaultUser, m_pwDatabase.DefaultUserName, true); WriteObject(ElemDbDefaultUserChanged, m_pwDatabase.DefaultUserNameChanged); WriteObject(ElemDbMntncHistoryDays, m_pwDatabase.MaintenanceHistoryDays); WriteObject(ElemDbColor, StrUtil.ColorToUnnamedHtml(m_pwDatabase.Color, true), false); WriteObject(ElemDbKeyChanged, m_pwDatabase.MasterKeyChanged); WriteObject(ElemDbKeyChangeRec, m_pwDatabase.MasterKeyChangeRec); WriteObject(ElemDbKeyChangeForce, m_pwDatabase.MasterKeyChangeForce); WriteList(ElemMemoryProt, m_pwDatabase.MemoryProtection); WriteCustomIconList(); WriteObject(ElemRecycleBinEnabled, m_pwDatabase.RecycleBinEnabled); WriteObject(ElemRecycleBinUuid, m_pwDatabase.RecycleBinUuid); WriteObject(ElemRecycleBinChanged, m_pwDatabase.RecycleBinChanged); WriteObject(ElemEntryTemplatesGroup, m_pwDatabase.EntryTemplatesGroup); WriteObject(ElemEntryTemplatesGroupChanged, m_pwDatabase.EntryTemplatesGroupChanged); WriteObject(ElemHistoryMaxItems, m_pwDatabase.HistoryMaxItems); WriteObject(ElemHistoryMaxSize, m_pwDatabase.HistoryMaxSize); WriteObject(ElemLastSelectedGroup, m_pwDatabase.LastSelectedGroup); WriteObject(ElemLastTopVisibleGroup, m_pwDatabase.LastTopVisibleGroup); WriteBinPool(); WriteList(ElemCustomData, m_pwDatabase.CustomData); m_xmlWriter.WriteEndElement(); } private void StartGroup(PwGroup pg) { m_xmlWriter.WriteStartElement(ElemGroup); WriteObject(ElemUuid, pg.Uuid); WriteObject(ElemName, pg.Name, true); WriteObject(ElemNotes, pg.Notes, true); WriteObject(ElemIcon, (int)pg.IconId); if(!pg.CustomIconUuid.Equals(PwUuid.Zero)) WriteObject(ElemCustomIconID, pg.CustomIconUuid); WriteList(ElemTimes, pg); WriteObject(ElemIsExpanded, pg.IsExpanded); WriteObject(ElemGroupDefaultAutoTypeSeq, pg.DefaultAutoTypeSequence, true); WriteObject(ElemEnableAutoType, StrUtil.BoolToStringEx(pg.EnableAutoType), false); WriteObject(ElemEnableSearching, StrUtil.BoolToStringEx(pg.EnableSearching), false); WriteObject(ElemLastTopVisibleEntry, pg.LastTopVisibleEntry); } private void EndGroup() { m_xmlWriter.WriteEndElement(); // Close group element } private void WriteEntry(PwEntry pe, bool bIsHistory) { Debug.Assert(pe != null); if(pe == null) throw new ArgumentNullException("pe"); m_xmlWriter.WriteStartElement(ElemEntry); WriteObject(ElemUuid, pe.Uuid); WriteObject(ElemIcon, (int)pe.IconId); if(!pe.CustomIconUuid.Equals(PwUuid.Zero)) WriteObject(ElemCustomIconID, pe.CustomIconUuid); WriteObject(ElemFgColor, StrUtil.ColorToUnnamedHtml(pe.ForegroundColor, true), false); WriteObject(ElemBgColor, StrUtil.ColorToUnnamedHtml(pe.BackgroundColor, true), false); WriteObject(ElemOverrideUrl, pe.OverrideUrl, true); WriteObject(ElemTags, StrUtil.TagsToString(pe.Tags, false), true); WriteList(ElemTimes, pe); WriteList(pe.Strings, true); WriteList(pe.Binaries); WriteList(ElemAutoType, pe.AutoType); if(!bIsHistory) WriteList(ElemHistory, pe.History, true); else { Debug.Assert(pe.History.UCount == 0); } m_xmlWriter.WriteEndElement(); } private void WriteList(ProtectedStringDictionary dictStrings, bool bEntryStrings) { Debug.Assert(dictStrings != null); if(dictStrings == null) throw new ArgumentNullException("dictStrings"); foreach(KeyValuePair kvp in dictStrings) WriteObject(kvp.Key, kvp.Value, bEntryStrings); } private void WriteList(ProtectedBinaryDictionary dictBinaries) { Debug.Assert(dictBinaries != null); if(dictBinaries == null) throw new ArgumentNullException("dictBinaries"); foreach(KeyValuePair kvp in dictBinaries) WriteObject(kvp.Key, kvp.Value, true); } private void WriteList(string name, AutoTypeConfig cfgAutoType) { Debug.Assert(name != null); Debug.Assert(cfgAutoType != null); if(cfgAutoType == null) throw new ArgumentNullException("cfgAutoType"); m_xmlWriter.WriteStartElement(name); WriteObject(ElemAutoTypeEnabled, cfgAutoType.Enabled); WriteObject(ElemAutoTypeObfuscation, (int)cfgAutoType.ObfuscationOptions); if(cfgAutoType.DefaultSequence.Length > 0) WriteObject(ElemAutoTypeDefaultSeq, cfgAutoType.DefaultSequence, true); foreach(AutoTypeAssociation a in cfgAutoType.Associations) WriteObject(ElemAutoTypeItem, ElemWindow, ElemKeystrokeSequence, new KeyValuePair(a.WindowName, a.Sequence)); m_xmlWriter.WriteEndElement(); } private void WriteList(string name, ITimeLogger times) { Debug.Assert(name != null); Debug.Assert(times != null); if(times == null) throw new ArgumentNullException("times"); m_xmlWriter.WriteStartElement(name); WriteObject(ElemCreationTime, times.CreationTime); WriteObject(ElemLastModTime, times.LastModificationTime); WriteObject(ElemLastAccessTime, times.LastAccessTime); WriteObject(ElemExpiryTime, times.ExpiryTime); WriteObject(ElemExpires, times.Expires); WriteObject(ElemUsageCount, times.UsageCount); WriteObject(ElemLocationChanged, times.LocationChanged); m_xmlWriter.WriteEndElement(); // Name } private void WriteList(string name, PwObjectList value, bool bIsHistory) { Debug.Assert(name != null); Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_xmlWriter.WriteStartElement(name); foreach(PwEntry pe in value) WriteEntry(pe, bIsHistory); m_xmlWriter.WriteEndElement(); } private void WriteList(string name, PwObjectList value) { Debug.Assert(name != null); Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_xmlWriter.WriteStartElement(name); foreach(PwDeletedObject pdo in value) WriteObject(ElemDeletedObject, pdo); m_xmlWriter.WriteEndElement(); } private void WriteList(string name, MemoryProtectionConfig value) { Debug.Assert(name != null); Debug.Assert(value != null); m_xmlWriter.WriteStartElement(name); WriteObject(ElemProtTitle, value.ProtectTitle); WriteObject(ElemProtUserName, value.ProtectUserName); WriteObject(ElemProtPassword, value.ProtectPassword); WriteObject(ElemProtUrl, value.ProtectUrl); WriteObject(ElemProtNotes, value.ProtectNotes); // WriteObject(ElemProtAutoHide, value.AutoEnableVisualHiding); m_xmlWriter.WriteEndElement(); } private void WriteList(string name, StringDictionaryEx value) { Debug.Assert(name != null); Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_xmlWriter.WriteStartElement(name); foreach(KeyValuePair kvp in value) WriteObject(ElemStringDictExItem, ElemKey, ElemValue, kvp); m_xmlWriter.WriteEndElement(); } private void WriteCustomIconList() { if(m_pwDatabase.CustomIcons.Count == 0) return; m_xmlWriter.WriteStartElement(ElemCustomIcons); foreach(PwCustomIcon pwci in m_pwDatabase.CustomIcons) { m_xmlWriter.WriteStartElement(ElemCustomIconItem); WriteObject(ElemCustomIconItemID, pwci.Uuid); string strData = Convert.ToBase64String(pwci.ImageDataPng); WriteObject(ElemCustomIconItemData, strData, false); m_xmlWriter.WriteEndElement(); } m_xmlWriter.WriteEndElement(); } private void WriteObject(string name, string value, bool bFilterValueXmlChars) { Debug.Assert(name != null); Debug.Assert(value != null); m_xmlWriter.WriteStartElement(name); if(bFilterValueXmlChars) m_xmlWriter.WriteString(StrUtil.SafeXmlString(value)); else m_xmlWriter.WriteString(value); m_xmlWriter.WriteEndElement(); } private void WriteObject(string name, bool value) { Debug.Assert(name != null); WriteObject(name, value ? ValTrue : ValFalse, false); } private void WriteObject(string name, PwUuid value) { Debug.Assert(name != null); Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); WriteObject(name, Convert.ToBase64String(value.UuidBytes), false); } private void WriteObject(string name, int value) { Debug.Assert(name != null); m_xmlWriter.WriteStartElement(name); m_xmlWriter.WriteString(value.ToString(NumberFormatInfo.InvariantInfo)); m_xmlWriter.WriteEndElement(); } private void WriteObject(string name, uint value) { Debug.Assert(name != null); m_xmlWriter.WriteStartElement(name); m_xmlWriter.WriteString(value.ToString(NumberFormatInfo.InvariantInfo)); m_xmlWriter.WriteEndElement(); } private void WriteObject(string name, long value) { Debug.Assert(name != null); m_xmlWriter.WriteStartElement(name); m_xmlWriter.WriteString(value.ToString(NumberFormatInfo.InvariantInfo)); m_xmlWriter.WriteEndElement(); } private void WriteObject(string name, ulong value) { Debug.Assert(name != null); m_xmlWriter.WriteStartElement(name); m_xmlWriter.WriteString(value.ToString(NumberFormatInfo.InvariantInfo)); m_xmlWriter.WriteEndElement(); } private void WriteObject(string name, DateTime value) { Debug.Assert(name != null); WriteObject(name, TimeUtil.SerializeUtc(value), false); } private void WriteObject(string name, string strKeyName, string strValueName, KeyValuePair kvp) { m_xmlWriter.WriteStartElement(name); m_xmlWriter.WriteStartElement(strKeyName); m_xmlWriter.WriteString(StrUtil.SafeXmlString(kvp.Key)); m_xmlWriter.WriteEndElement(); m_xmlWriter.WriteStartElement(strValueName); m_xmlWriter.WriteString(StrUtil.SafeXmlString(kvp.Value)); m_xmlWriter.WriteEndElement(); m_xmlWriter.WriteEndElement(); } private void WriteObject(string name, ProtectedString value, bool bIsEntryString) { Debug.Assert(name != null); Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_xmlWriter.WriteStartElement(ElemString); m_xmlWriter.WriteStartElement(ElemKey); m_xmlWriter.WriteString(StrUtil.SafeXmlString(name)); m_xmlWriter.WriteEndElement(); m_xmlWriter.WriteStartElement(ElemValue); bool bProtected = value.IsProtected; if(bIsEntryString) { // Adjust memory protection setting (which might be different // from the database default, e.g. due to an import which // didn't specify the correct setting) if(name == PwDefs.TitleField) bProtected = m_pwDatabase.MemoryProtection.ProtectTitle; else if(name == PwDefs.UserNameField) bProtected = m_pwDatabase.MemoryProtection.ProtectUserName; else if(name == PwDefs.PasswordField) bProtected = m_pwDatabase.MemoryProtection.ProtectPassword; else if(name == PwDefs.UrlField) bProtected = m_pwDatabase.MemoryProtection.ProtectUrl; else if(name == PwDefs.NotesField) bProtected = m_pwDatabase.MemoryProtection.ProtectNotes; } if(bProtected && (m_format != KdbxFormat.PlainXml)) { m_xmlWriter.WriteAttributeString(AttrProtected, ValTrue); byte[] pbEncoded = value.ReadXorredString(m_randomStream); if(pbEncoded.Length > 0) m_xmlWriter.WriteBase64(pbEncoded, 0, pbEncoded.Length); } else { string strValue = value.ReadString(); // If names should be localized, we need to apply the language-dependent // string transformation here. By default, language-dependent conversions // should be applied, otherwise characters could be rendered incorrectly // (code page problems). if(m_bLocalizedNames) { StringBuilder sb = new StringBuilder(); foreach(char ch in strValue) { char chMapped = ch; // Symbols and surrogates must be moved into the correct code // page area if(char.IsSymbol(ch) || char.IsSurrogate(ch)) { System.Globalization.UnicodeCategory cat = CharUnicodeInfo.GetUnicodeCategory(ch); // Map character to correct position in code page chMapped = (char)((int)cat * 32 + ch); } else if(char.IsControl(ch)) { if(ch >= 256) // Control character in high ANSI code page { // Some of the control characters map to corresponding ones // in the low ANSI range (up to 255) when calling // ToLower on them with invariant culture (see // http://lists.ximian.com/pipermail/mono-patches/2002-February/086106.html ) #if !KeePassLibSD chMapped = char.ToLowerInvariant(ch); #else chMapped = char.ToLower(ch); #endif } } sb.Append(chMapped); } strValue = sb.ToString(); // Correct string for current code page } if((m_format == KdbxFormat.PlainXml) && bProtected) m_xmlWriter.WriteAttributeString(AttrProtectedInMemPlainXml, ValTrue); m_xmlWriter.WriteString(StrUtil.SafeXmlString(strValue)); } m_xmlWriter.WriteEndElement(); // ElemValue m_xmlWriter.WriteEndElement(); // ElemString } private void WriteObject(string name, ProtectedBinary value, bool bAllowRef) { Debug.Assert(name != null); Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_xmlWriter.WriteStartElement(ElemBinary); m_xmlWriter.WriteStartElement(ElemKey); m_xmlWriter.WriteString(StrUtil.SafeXmlString(name)); m_xmlWriter.WriteEndElement(); m_xmlWriter.WriteStartElement(ElemValue); string strRef = (bAllowRef ? BinPoolFind(value) : null); if(strRef != null) { m_xmlWriter.WriteAttributeString(AttrRef, strRef); } else SubWriteValue(value); m_xmlWriter.WriteEndElement(); // ElemValue m_xmlWriter.WriteEndElement(); // ElemBinary } private void SubWriteValue(ProtectedBinary value) { if(value.IsProtected && (m_format != KdbxFormat.PlainXml)) { m_xmlWriter.WriteAttributeString(AttrProtected, ValTrue); byte[] pbEncoded = value.ReadXorredData(m_randomStream); if(pbEncoded.Length > 0) m_xmlWriter.WriteBase64(pbEncoded, 0, pbEncoded.Length); } else { if(m_pwDatabase.Compression == PwCompressionAlgorithm.GZip) { m_xmlWriter.WriteAttributeString(AttrCompressed, ValTrue); byte[] pbRaw = value.ReadData(); byte[] pbCmp = MemUtil.Compress(pbRaw); m_xmlWriter.WriteBase64(pbCmp, 0, pbCmp.Length); } else { byte[] pbRaw = value.ReadData(); m_xmlWriter.WriteBase64(pbRaw, 0, pbRaw.Length); } } } private void WriteObject(string name, PwDeletedObject value) { Debug.Assert(name != null); Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_xmlWriter.WriteStartElement(name); WriteObject(ElemUuid, value.Uuid); WriteObject(ElemDeletionTime, value.DeletionTime); m_xmlWriter.WriteEndElement(); } private void WriteBinPool() { m_xmlWriter.WriteStartElement(ElemBinaries); foreach(KeyValuePair kvp in m_dictBinPool) { m_xmlWriter.WriteStartElement(ElemBinary); m_xmlWriter.WriteAttributeString(AttrId, kvp.Key); SubWriteValue(kvp.Value); m_xmlWriter.WriteEndElement(); } m_xmlWriter.WriteEndElement(); } [Obsolete] public static bool WriteEntries(Stream msOutput, PwDatabase pwDatabase, PwEntry[] vEntries) { return WriteEntries(msOutput, vEntries); } /// /// Write entries to a stream. /// /// Output stream to which the entries will be written. /// Entries to serialize. /// Returns true, if the entries were written successfully /// to the stream. public static bool WriteEntries(Stream msOutput, PwEntry[] vEntries) { /* KdbxFile f = new KdbxFile(pwDatabase); f.m_format = KdbxFormat.PlainXml; XmlTextWriter xtw = null; try { xtw = new XmlTextWriter(msOutput, StrUtil.Utf8); } catch(Exception) { Debug.Assert(false); return false; } if(xtw == null) { Debug.Assert(false); return false; } f.m_xmlWriter = xtw; xtw.Formatting = Formatting.Indented; xtw.IndentChar = '\t'; xtw.Indentation = 1; xtw.WriteStartDocument(true); xtw.WriteStartElement(ElemRoot); foreach(PwEntry pe in vEntries) f.WriteEntry(pe, false); xtw.WriteEndElement(); xtw.WriteEndDocument(); xtw.Flush(); xtw.Close(); return true; */ PwDatabase pd = new PwDatabase(); pd.New(new IOConnectionInfo(), new CompositeKey()); foreach(PwEntry peCopy in vEntries) pd.RootGroup.AddEntry(peCopy.CloneDeep(), true); KdbxFile f = new KdbxFile(pd); f.Save(msOutput, null, KdbxFormat.PlainXml, null); return true; } } } keepass2-2.25/KeePassLib/Serialization/FileLock.cs0000664000175000017500000001617212261553106021741 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Threading; using System.Diagnostics; using KeePassLib.Cryptography; using KeePassLib.Resources; using KeePassLib.Utility; namespace KeePassLib.Serialization { public sealed class FileLockException : Exception { private readonly string m_strMsg; public override string Message { get { return m_strMsg; } } public FileLockException(string strBaseFile, string strUser) { StringBuilder sb = new StringBuilder(); if(!string.IsNullOrEmpty(strBaseFile)) { sb.Append(strBaseFile); sb.Append(MessageService.NewParagraph); } sb.Append(KLRes.FileLockedWrite); sb.Append(MessageService.NewLine); if(!string.IsNullOrEmpty(strUser)) sb.Append(strUser); else sb.Append("?"); sb.Append(MessageService.NewParagraph); sb.Append(KLRes.TryAgainSecs); m_strMsg = sb.ToString(); } } public sealed class FileLock : IDisposable { private const string LockFileExt = ".lock"; private const string LockFileHeader = "KeePass Lock File"; private IOConnectionInfo m_iocLockFile; private sealed class LockFileInfo { public readonly string ID; public readonly DateTime Time; public readonly string UserName; public readonly string Machine; public readonly string Domain; private LockFileInfo(string strID, string strTime, string strUserName, string strMachine, string strDomain) { this.ID = (strID ?? string.Empty).Trim(); DateTime dt; if(TimeUtil.TryDeserializeUtc(strTime.Trim(), out dt)) this.Time = dt; else { Debug.Assert(false); this.Time = DateTime.UtcNow; } this.UserName = (strUserName ?? string.Empty).Trim(); this.Machine = (strMachine ?? string.Empty).Trim(); this.Domain = (strDomain ?? string.Empty).Trim(); if(this.Domain.Equals(this.Machine, StrUtil.CaseIgnoreCmp)) this.Domain = string.Empty; } public string GetOwner() { StringBuilder sb = new StringBuilder(); sb.Append((this.UserName.Length > 0) ? this.UserName : "?"); bool bMachine = (this.Machine.Length > 0); bool bDomain = (this.Domain.Length > 0); if(bMachine || bDomain) { sb.Append(" ("); sb.Append(this.Machine); if(bMachine && bDomain) sb.Append(" @ "); sb.Append(this.Domain); sb.Append(")"); } return sb.ToString(); } public static LockFileInfo Load(IOConnectionInfo iocLockFile) { Stream s = null; try { s = IOConnection.OpenRead(iocLockFile); if(s == null) return null; StreamReader sr = new StreamReader(s, StrUtil.Utf8); string str = sr.ReadToEnd(); sr.Close(); if(str == null) { Debug.Assert(false); return null; } str = StrUtil.NormalizeNewLines(str, false); string[] v = str.Split('\n'); if((v == null) || (v.Length < 6)) { Debug.Assert(false); return null; } if(!v[0].StartsWith(LockFileHeader)) { Debug.Assert(false); return null; } return new LockFileInfo(v[1], v[2], v[3], v[4], v[5]); } catch(FileNotFoundException) { } catch(Exception) { Debug.Assert(false); } finally { if(s != null) s.Close(); } return null; } // Throws on error public static LockFileInfo Create(IOConnectionInfo iocLockFile) { LockFileInfo lfi; Stream s = null; try { byte[] pbID = CryptoRandom.Instance.GetRandomBytes(16); string strTime = TimeUtil.SerializeUtc(DateTime.Now); #if (!KeePassLibSD && !KeePassRT) lfi = new LockFileInfo(Convert.ToBase64String(pbID), strTime, Environment.UserName, Environment.MachineName, Environment.UserDomainName); #else lfi = new LockFileInfo(Convert.ToBase64String(pbID), strTime, string.Empty, string.Empty, string.Empty); #endif StringBuilder sb = new StringBuilder(); #if !KeePassLibSD sb.AppendLine(LockFileHeader); sb.AppendLine(lfi.ID); sb.AppendLine(strTime); sb.AppendLine(lfi.UserName); sb.AppendLine(lfi.Machine); sb.AppendLine(lfi.Domain); #else sb.Append(LockFileHeader + MessageService.NewLine); sb.Append(lfi.ID + MessageService.NewLine); sb.Append(strTime + MessageService.NewLine); sb.Append(lfi.UserName + MessageService.NewLine); sb.Append(lfi.Machine + MessageService.NewLine); sb.Append(lfi.Domain + MessageService.NewLine); #endif byte[] pbFile = StrUtil.Utf8.GetBytes(sb.ToString()); s = IOConnection.OpenWrite(iocLockFile); if(s == null) throw new IOException(iocLockFile.GetDisplayName()); s.Write(pbFile, 0, pbFile.Length); } finally { if(s != null) s.Close(); } return lfi; } } public FileLock(IOConnectionInfo iocBaseFile) { if(iocBaseFile == null) throw new ArgumentNullException("strBaseFile"); m_iocLockFile = iocBaseFile.CloneDeep(); m_iocLockFile.Path += LockFileExt; LockFileInfo lfiEx = LockFileInfo.Load(m_iocLockFile); if(lfiEx != null) { m_iocLockFile = null; // Otherwise Dispose deletes the existing one throw new FileLockException(iocBaseFile.GetDisplayName(), lfiEx.GetOwner()); } LockFileInfo.Create(m_iocLockFile); } ~FileLock() { Dispose(false); } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } private void Dispose(bool bDisposing) { if(m_iocLockFile == null) return; bool bFileDeleted = false; for(int r = 0; r < 5; ++r) { // if(!OwnLockFile()) { bFileDeleted = true; break; } try { IOConnection.DeleteFile(m_iocLockFile); bFileDeleted = true; } catch(Exception) { Debug.Assert(false); } if(bFileDeleted) break; if(bDisposing) Thread.Sleep(50); } if(bDisposing && !bFileDeleted) IOConnection.DeleteFile(m_iocLockFile); // Possibly with exception m_iocLockFile = null; } // private bool OwnLockFile() // { // if(m_iocLockFile == null) { Debug.Assert(false); return false; } // if(m_strLockID == null) { Debug.Assert(false); return false; } // LockFileInfo lfi = LockFileInfo.Load(m_iocLockFile); // if(lfi == null) return false; // return m_strLockID.Equals(lfi.ID); // } } } keepass2-2.25/KeePassLib/Serialization/IOConnectionInfo.cs0000664000175000017500000002046412261553106023413 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Net; using System.ComponentModel; using System.Xml.Serialization; using System.Diagnostics; using KeePassLib.Interfaces; using KeePassLib.Utility; namespace KeePassLib.Serialization { public enum IOCredSaveMode { /// /// Do not remember user name or password. /// NoSave = 0, /// /// Remember the user name only, not the password. /// UserNameOnly, /// /// Save both user name and password. /// SaveCred } public enum IOCredProtMode { None = 0, Obf } /* public enum IOFileFormatHint { None = 0, Deprecated } */ public sealed class IOConnectionInfo : IDeepCloneable { // private IOFileFormatHint m_ioHint = IOFileFormatHint.None; private string m_strUrl = string.Empty; public string Path { get { return m_strUrl; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_strUrl = value; } } private string m_strUser = string.Empty; [DefaultValue("")] public string UserName { get { return m_strUser; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_strUser = value; } } private string m_strPassword = string.Empty; [DefaultValue("")] public string Password { get { return m_strPassword; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_strPassword = value; } } private IOCredProtMode m_ioCredProtMode = IOCredProtMode.None; public IOCredProtMode CredProtMode { get { return m_ioCredProtMode; } set { m_ioCredProtMode = value; } } private IOCredSaveMode m_ioCredSaveMode = IOCredSaveMode.NoSave; public IOCredSaveMode CredSaveMode { get { return m_ioCredSaveMode; } set { m_ioCredSaveMode = value; } } private bool m_bComplete = false; [XmlIgnore] internal bool IsComplete // Credentials etc. fully specified { get { return m_bComplete; } set { m_bComplete = value; } } /* public IOFileFormatHint FileFormatHint { get { return m_ioHint; } set { m_ioHint = value; } } */ public IOConnectionInfo CloneDeep() { return (IOConnectionInfo)this.MemberwiseClone(); } /* /// /// Serialize the current connection info to a string. Credentials /// are only serialized if the SaveCredentials property /// is true. /// /// Input object to be serialized. /// Serialized object as string. public static string SerializeToString(IOConnectionInfo iocToCompile) { Debug.Assert(iocToCompile != null); if(iocToCompile == null) throw new ArgumentNullException("iocToCompile"); string strUrl = iocToCompile.Path; string strUser = TransformUnreadable(iocToCompile.UserName, true); string strPassword = TransformUnreadable(iocToCompile.Password, true); string strAll = strUrl + strUser + strPassword + "CUN"; char chSep = StrUtil.GetUnusedChar(strAll); if(chSep == char.MinValue) throw new FormatException(); StringBuilder sb = new StringBuilder(); sb.Append(chSep); sb.Append(strUrl); sb.Append(chSep); if(iocToCompile.CredSaveMode == IOCredSaveMode.SaveCred) { sb.Append('C'); sb.Append(chSep); sb.Append(strUser); sb.Append(chSep); sb.Append(strPassword); } else if(iocToCompile.CredSaveMode == IOCredSaveMode.UserNameOnly) { sb.Append('U'); sb.Append(chSep); sb.Append(strUser); sb.Append(chSep); } else // Don't remember credentials { sb.Append('N'); sb.Append(chSep); sb.Append(chSep); } return sb.ToString(); } public static IOConnectionInfo UnserializeFromString(string strToDecompile) { Debug.Assert(strToDecompile != null); if(strToDecompile == null) throw new ArgumentNullException("strToDecompile"); if(strToDecompile.Length <= 1) throw new ArgumentException(); char chSep = strToDecompile[0]; string[] vParts = strToDecompile.Substring(1, strToDecompile.Length - 1).Split(new char[]{ chSep }); if(vParts.Length < 4) throw new ArgumentException(); IOConnectionInfo s = new IOConnectionInfo(); s.Path = vParts[0]; if(vParts[1] == "C") s.CredSaveMode = IOCredSaveMode.SaveCred; else if(vParts[1] == "U") s.CredSaveMode = IOCredSaveMode.UserNameOnly; else s.CredSaveMode = IOCredSaveMode.NoSave; s.UserName = TransformUnreadable(vParts[2], false); s.Password = TransformUnreadable(vParts[3], false); return s; } */ /* /// /// Very simple string protection. Doesn't really encrypt the input /// string, only encodes it that it's not readable on the first glance. /// /// The string to encode/decode. /// If true, the string will be encoded, /// otherwise it'll be decoded. /// Encoded/decoded string. private static string TransformUnreadable(string strToEncode, bool bEncode) { Debug.Assert(strToEncode != null); if(strToEncode == null) throw new ArgumentNullException("strToEncode"); if(bEncode) { byte[] pbUtf8 = StrUtil.Utf8.GetBytes(strToEncode); unchecked { for(int iPos = 0; iPos < pbUtf8.Length; ++iPos) pbUtf8[iPos] += (byte)(iPos * 11); } return Convert.ToBase64String(pbUtf8); } else // Decode { byte[] pbBase = Convert.FromBase64String(strToEncode); unchecked { for(int iPos = 0; iPos < pbBase.Length; ++iPos) pbBase[iPos] -= (byte)(iPos * 11); } return StrUtil.Utf8.GetString(pbBase, 0, pbBase.Length); } } */ public string GetDisplayName() { string str = m_strUrl; if(m_strUser.Length > 0) str += " (" + m_strUser + ")"; return str; } public bool IsEmpty() { return (m_strUrl.Length > 0); } public static IOConnectionInfo FromPath(string strPath) { IOConnectionInfo ioc = new IOConnectionInfo(); ioc.Path = strPath; ioc.CredSaveMode = IOCredSaveMode.NoSave; return ioc; } public bool CanProbablyAccess() { if(IsLocalFile()) return File.Exists(m_strUrl); return true; } public bool IsLocalFile() { // Not just ":/", see e.g. AppConfigEx.ChangePathRelAbs return (m_strUrl.IndexOf(@"://") < 0); } public void ClearCredentials(bool bDependingOnRememberMode) { if((bDependingOnRememberMode == false) || (m_ioCredSaveMode == IOCredSaveMode.NoSave)) { m_strUser = string.Empty; } if((bDependingOnRememberMode == false) || (m_ioCredSaveMode == IOCredSaveMode.NoSave) || (m_ioCredSaveMode == IOCredSaveMode.UserNameOnly)) { m_strPassword = string.Empty; } } public void Obfuscate(bool bObf) { if(bObf && (m_ioCredProtMode == IOCredProtMode.None)) { m_strPassword = StrUtil.Obfuscate(m_strPassword); m_ioCredProtMode = IOCredProtMode.Obf; } else if(!bObf && (m_ioCredProtMode == IOCredProtMode.Obf)) { m_strPassword = StrUtil.Deobfuscate(m_strPassword); m_ioCredProtMode = IOCredProtMode.None; } } } } keepass2-2.25/KeePassLib/Serialization/OldFormatException.cs0000664000175000017500000000350612261553106024014 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePassLib.Resources; using KeePassLib.Utility; namespace KeePassLib.Serialization { public sealed class OldFormatException : Exception { private string m_strFormat = string.Empty; private OldFormatType m_type = OldFormatType.Unknown; public enum OldFormatType { Unknown = 0, KeePass1x = 1 } public override string Message { get { string str = KLRes.OldFormat + ((m_strFormat.Length > 0) ? (@" (" + m_strFormat + @")") : string.Empty) + "."; if(m_type == OldFormatType.KeePass1x) str += MessageService.NewParagraph + KLRes.KeePass1xHint; return str; } } public OldFormatException(string strFormatName) { if(strFormatName != null) m_strFormat = strFormatName; } public OldFormatException(string strFormatName, OldFormatType t) { if(strFormatName != null) m_strFormat = strFormatName; m_type = t; } } } keepass2-2.25/KeePassLib/Serialization/IOConnection.cs0000664000175000017500000003346512261553106022604 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Net; using System.Diagnostics; #if (!KeePassLibSD && !KeePassRT) using System.Net.Cache; using System.Net.Security; #endif #if !KeePassRT using System.Security.Cryptography.X509Certificates; #endif using KeePassLib.Native; using KeePassLib.Utility; namespace KeePassLib.Serialization { #if (!KeePassLibSD && !KeePassRT) public sealed class IOWebClient : WebClient { protected override WebRequest GetWebRequest(Uri address) { WebRequest request = base.GetWebRequest(address); IOConnection.ConfigureWebRequest(request); return request; } } #endif public static class IOConnection { #if (!KeePassLibSD && !KeePassRT) private static ProxyServerType m_pstProxyType = ProxyServerType.System; private static string m_strProxyAddr = string.Empty; private static string m_strProxyPort = string.Empty; private static string m_strProxyUserName = string.Empty; private static string m_strProxyPassword = string.Empty; private static bool m_bSslCertsAcceptInvalid = false; internal static bool SslCertsAcceptInvalid { // get { return m_bSslCertsAcceptInvalid; } set { m_bSslCertsAcceptInvalid = value; } } #endif // Web request methods public const string WrmDeleteFile = "DELETEFILE"; public const string WrmMoveFile = "MOVEFILE"; // Web request headers public const string WrhMoveFileTo = "MoveFileTo"; public static event EventHandler IOAccessPre; #if (!KeePassLibSD && !KeePassRT) // Allow self-signed certificates, expired certificates, etc. private static bool AcceptCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; } internal static void SetProxy(ProxyServerType pst, string strAddr, string strPort, string strUserName, string strPassword) { m_pstProxyType = pst; m_strProxyAddr = (strAddr ?? string.Empty); m_strProxyPort = (strPort ?? string.Empty); m_strProxyUserName = (strUserName ?? string.Empty); m_strProxyPassword = (strPassword ?? string.Empty); } internal static void ConfigureWebRequest(WebRequest request) { if(request == null) { Debug.Assert(false); return; } // No throw // WebDAV support if(request is HttpWebRequest) { request.PreAuthenticate = true; // Also auth GET if(request.Method == WebRequestMethods.Http.Post) request.Method = WebRequestMethods.Http.Put; } // else if(request is FtpWebRequest) // { // Debug.Assert(((FtpWebRequest)request).UsePassive); // } // Not implemented and ignored in Mono < 2.10 try { request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); } catch(NotImplementedException) { } catch(Exception) { Debug.Assert(false); } try { IWebProxy prx; if(GetWebProxy(out prx)) request.Proxy = prx; } catch(Exception) { Debug.Assert(false); } } internal static void ConfigureWebClient(WebClient wc) { // Not implemented and ignored in Mono < 2.10 try { wc.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); } catch(NotImplementedException) { } catch(Exception) { Debug.Assert(false); } try { IWebProxy prx; if(GetWebProxy(out prx)) wc.Proxy = prx; } catch(Exception) { Debug.Assert(false); } } private static bool GetWebProxy(out IWebProxy prx) { prx = null; if(m_pstProxyType == ProxyServerType.None) return true; // Use null proxy if(m_pstProxyType == ProxyServerType.Manual) { try { if(m_strProxyPort.Length > 0) prx = new WebProxy(m_strProxyAddr, int.Parse(m_strProxyPort)); else prx = new WebProxy(m_strProxyAddr); if((m_strProxyUserName.Length > 0) || (m_strProxyPassword.Length > 0)) prx.Credentials = new NetworkCredential(m_strProxyUserName, m_strProxyPassword); return true; // Use manual proxy } catch(Exception exProxy) { string strInfo = m_strProxyAddr; if(m_strProxyPort.Length > 0) strInfo += ":" + m_strProxyPort; MessageService.ShowWarning(strInfo, exProxy.Message); } return false; // Use default } if((m_strProxyUserName.Length == 0) && (m_strProxyPassword.Length == 0)) return false; // Use default proxy, no auth try { prx = WebRequest.DefaultWebProxy; if(prx == null) prx = WebRequest.GetSystemWebProxy(); if(prx == null) throw new InvalidOperationException(); prx.Credentials = new NetworkCredential(m_strProxyUserName, m_strProxyPassword); return true; } catch(Exception) { Debug.Assert(false); } return false; } private static void PrepareWebAccess() { if(m_bSslCertsAcceptInvalid) ServicePointManager.ServerCertificateValidationCallback = IOConnection.AcceptCertificate; else ServicePointManager.ServerCertificateValidationCallback = null; } private static IOWebClient CreateWebClient(IOConnectionInfo ioc) { PrepareWebAccess(); IOWebClient wc = new IOWebClient(); ConfigureWebClient(wc); if((ioc.UserName.Length > 0) || (ioc.Password.Length > 0)) wc.Credentials = new NetworkCredential(ioc.UserName, ioc.Password); else if(NativeLib.IsUnix()) // Mono requires credentials wc.Credentials = new NetworkCredential("anonymous", string.Empty); return wc; } private static WebRequest CreateWebRequest(IOConnectionInfo ioc) { PrepareWebAccess(); WebRequest req = WebRequest.Create(ioc.Path); ConfigureWebRequest(req); if((ioc.UserName.Length > 0) || (ioc.Password.Length > 0)) req.Credentials = new NetworkCredential(ioc.UserName, ioc.Password); else if(NativeLib.IsUnix()) // Mono requires credentials req.Credentials = new NetworkCredential("anonymous", string.Empty); return req; } public static Stream OpenRead(IOConnectionInfo ioc) { RaiseIOAccessPreEvent(ioc, IOAccessType.Read); if(StrUtil.IsDataUri(ioc.Path)) { byte[] pbData = StrUtil.DataUriToData(ioc.Path); if(pbData != null) return new MemoryStream(pbData, false); } if(ioc.IsLocalFile()) return OpenReadLocal(ioc); return CreateWebClient(ioc).OpenRead(new Uri(ioc.Path)); } #else public static Stream OpenRead(IOConnectionInfo ioc) { RaiseIOAccessPreEvent(ioc, IOAccessType.Read); return OpenReadLocal(ioc); } #endif private static Stream OpenReadLocal(IOConnectionInfo ioc) { return new FileStream(ioc.Path, FileMode.Open, FileAccess.Read, FileShare.Read); } #if (!KeePassLibSD && !KeePassRT) public static Stream OpenWrite(IOConnectionInfo ioc) { if(ioc == null) { Debug.Assert(false); return null; } RaiseIOAccessPreEvent(ioc, IOAccessType.Write); if(ioc.IsLocalFile()) return OpenWriteLocal(ioc); Uri uri = new Uri(ioc.Path); // Mono does not set HttpWebRequest.Method to POST for writes, // so one needs to set the method to PUT explicitly if(NativeLib.IsUnix() && (uri.Scheme.Equals(Uri.UriSchemeHttp, StrUtil.CaseIgnoreCmp) || uri.Scheme.Equals(Uri.UriSchemeHttps, StrUtil.CaseIgnoreCmp))) return CreateWebClient(ioc).OpenWrite(uri, WebRequestMethods.Http.Put); return CreateWebClient(ioc).OpenWrite(uri); } #else public static Stream OpenWrite(IOConnectionInfo ioc) { RaiseIOAccessPreEvent(ioc, IOAccessType.Write); return OpenWriteLocal(ioc); } #endif private static Stream OpenWriteLocal(IOConnectionInfo ioc) { return new FileStream(ioc.Path, FileMode.Create, FileAccess.Write, FileShare.None); } public static bool FileExists(IOConnectionInfo ioc) { return FileExists(ioc, false); } public static bool FileExists(IOConnectionInfo ioc, bool bThrowErrors) { if(ioc == null) { Debug.Assert(false); return false; } RaiseIOAccessPreEvent(ioc, IOAccessType.Exists); if(ioc.IsLocalFile()) return File.Exists(ioc.Path); #if (!KeePassLibSD && !KeePassRT) if(ioc.Path.StartsWith("ftp://", StrUtil.CaseIgnoreCmp)) { bool b = SendCommand(ioc, WebRequestMethods.Ftp.GetDateTimestamp); if(!b && bThrowErrors) throw new InvalidOperationException(); return b; } #endif try { Stream s = OpenRead(ioc); if(s == null) throw new FileNotFoundException(); try { s.ReadByte(); } catch(Exception) { } // We didn't download the file completely; close may throw // an exception -- that's okay try { s.Close(); } catch(Exception) { } } catch(Exception) { if(bThrowErrors) throw; return false; } return true; } public static void DeleteFile(IOConnectionInfo ioc) { RaiseIOAccessPreEvent(ioc, IOAccessType.Delete); if(ioc.IsLocalFile()) { File.Delete(ioc.Path); return; } #if (!KeePassLibSD && !KeePassRT) WebRequest req = CreateWebRequest(ioc); if(req != null) { if(req is HttpWebRequest) req.Method = "DELETE"; else if(req is FtpWebRequest) req.Method = WebRequestMethods.Ftp.DeleteFile; else if(req is FileWebRequest) { File.Delete(UrlUtil.FileUrlToPath(ioc.Path)); return; } else req.Method = WrmDeleteFile; DisposeResponse(req.GetResponse(), true); } #endif } /// /// Rename/move a file. For local file system and WebDAV, the /// specified file is moved, i.e. the file destination can be /// in a different directory/path. In contrast, for FTP the /// file is renamed, i.e. its destination must be in the same /// directory/path. /// /// Source file path. /// Target file path. public static void RenameFile(IOConnectionInfo iocFrom, IOConnectionInfo iocTo) { RaiseIOAccessPreEvent(iocFrom, iocTo, IOAccessType.Move); if(iocFrom.IsLocalFile()) { File.Move(iocFrom.Path, iocTo.Path); return; } #if (!KeePassLibSD && !KeePassRT) WebRequest req = CreateWebRequest(iocFrom); if(req != null) { if(req is HttpWebRequest) { req.Method = "MOVE"; req.Headers.Set("Destination", iocTo.Path); // Full URL supported } else if(req is FtpWebRequest) { req.Method = WebRequestMethods.Ftp.Rename; string strTo = UrlUtil.GetFileName(iocTo.Path); // We're affected by .NET bug 621450: // https://connect.microsoft.com/VisualStudio/feedback/details/621450/problem-renaming-file-on-ftp-server-using-ftpwebrequest-in-net-framework-4-0-vs2010-only // Prepending "./", "%2E/" or "Dummy/../" doesn't work. ((FtpWebRequest)req).RenameTo = strTo; } else if(req is FileWebRequest) { File.Move(UrlUtil.FileUrlToPath(iocFrom.Path), UrlUtil.FileUrlToPath(iocTo.Path)); return; } else { req.Method = WrmMoveFile; req.Headers.Set(WrhMoveFileTo, iocTo.Path); } DisposeResponse(req.GetResponse(), true); } #endif // using(Stream sIn = IOConnection.OpenRead(iocFrom)) // { // using(Stream sOut = IOConnection.OpenWrite(iocTo)) // { // MemUtil.CopyStream(sIn, sOut); // sOut.Close(); // } // // sIn.Close(); // } // DeleteFile(iocFrom); } #if (!KeePassLibSD && !KeePassRT) private static bool SendCommand(IOConnectionInfo ioc, string strMethod) { try { WebRequest req = CreateWebRequest(ioc); req.Method = strMethod; DisposeResponse(req.GetResponse(), true); } catch(Exception) { return false; } return true; } #endif private static void DisposeResponse(WebResponse wr, bool bGetStream) { if(wr == null) return; try { if(bGetStream) { Stream s = wr.GetResponseStream(); if(s != null) s.Close(); } } catch(Exception) { Debug.Assert(false); } try { wr.Close(); } catch(Exception) { Debug.Assert(false); } } public static byte[] ReadFile(IOConnectionInfo ioc) { Stream sIn = null; MemoryStream ms = null; try { sIn = IOConnection.OpenRead(ioc); if(sIn == null) return null; ms = new MemoryStream(); MemUtil.CopyStream(sIn, ms); return ms.ToArray(); } catch(Exception) { } finally { if(sIn != null) sIn.Close(); if(ms != null) ms.Close(); } return null; } private static void RaiseIOAccessPreEvent(IOConnectionInfo ioc, IOAccessType t) { RaiseIOAccessPreEvent(ioc, null, t); } private static void RaiseIOAccessPreEvent(IOConnectionInfo ioc, IOConnectionInfo ioc2, IOAccessType t) { if(ioc == null) { Debug.Assert(false); return; } // ioc2 may be null if(IOConnection.IOAccessPre != null) { IOConnectionInfo ioc2Lcl = ((ioc2 != null) ? ioc2.CloneDeep() : null); IOAccessEventArgs e = new IOAccessEventArgs(ioc.CloneDeep(), ioc2Lcl, t); IOConnection.IOAccessPre(null, e); } } } } keepass2-2.25/KeePassLib/Serialization/HashedBlockStream.cs0000664000175000017500000001731712261553106023576 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using System.Security.Cryptography; using System.Diagnostics; using System.Text; using KeePassLib.Native; using KeePassLib.Utility; #if KeePassLibSD using KeePassLibSD; #endif namespace KeePassLib.Serialization { public sealed class HashedBlockStream : Stream { private const int m_nDefaultBufferSize = 1024 * 1024; // 1 MB private Stream m_sBaseStream; private bool m_bWriting; private bool m_bVerify; private bool m_bEos = false; private BinaryReader m_brInput; private BinaryWriter m_bwOutput; private byte[] m_pbBuffer; private int m_nBufferPos = 0; private uint m_uBufferIndex = 0; public override bool CanRead { get { return !m_bWriting; } } public override bool CanSeek { get { return false; } } public override bool CanWrite { get { return m_bWriting; } } public override long Length { get { throw new NotSupportedException(); } } public override long Position { get { throw new NotSupportedException(); } set { throw new NotSupportedException(); } } public HashedBlockStream(Stream sBaseStream, bool bWriting) { Initialize(sBaseStream, bWriting, 0, true); } public HashedBlockStream(Stream sBaseStream, bool bWriting, int nBufferSize) { Initialize(sBaseStream, bWriting, nBufferSize, true); } public HashedBlockStream(Stream sBaseStream, bool bWriting, int nBufferSize, bool bVerify) { Initialize(sBaseStream, bWriting, nBufferSize, bVerify); } private void Initialize(Stream sBaseStream, bool bWriting, int nBufferSize, bool bVerify) { if(sBaseStream == null) throw new ArgumentNullException("sBaseStream"); if(nBufferSize < 0) throw new ArgumentOutOfRangeException("nBufferSize"); if(nBufferSize == 0) nBufferSize = m_nDefaultBufferSize; m_sBaseStream = sBaseStream; m_bWriting = bWriting; m_bVerify = bVerify; UTF8Encoding utf8 = StrUtil.Utf8; if(m_bWriting == false) // Reading mode { if(m_sBaseStream.CanRead == false) throw new InvalidOperationException(); m_brInput = new BinaryReader(sBaseStream, utf8); m_pbBuffer = new byte[0]; } else // Writing mode { if(m_sBaseStream.CanWrite == false) throw new InvalidOperationException(); m_bwOutput = new BinaryWriter(sBaseStream, utf8); m_pbBuffer = new byte[nBufferSize]; } } public override void Flush() { if(m_bWriting) m_bwOutput.Flush(); } #if KeePassRT protected override void Dispose(bool disposing) { if(!disposing) return; #else public override void Close() { #endif if(m_sBaseStream != null) { if(m_bWriting == false) // Reading mode { m_brInput.Close(); m_brInput = null; } else // Writing mode { if(m_nBufferPos == 0) // No data left in buffer WriteHashedBlock(); // Write terminating block else { WriteHashedBlock(); // Write remaining buffered data WriteHashedBlock(); // Write terminating block } Flush(); m_bwOutput.Close(); m_bwOutput = null; } m_sBaseStream.Close(); m_sBaseStream = null; } } public override long Seek(long lOffset, SeekOrigin soOrigin) { throw new NotSupportedException(); } public override void SetLength(long lValue) { throw new NotSupportedException(); } public override int Read(byte[] pbBuffer, int nOffset, int nCount) { if(m_bWriting) throw new InvalidOperationException(); int nRemaining = nCount; while(nRemaining > 0) { if(m_nBufferPos == m_pbBuffer.Length) { if(ReadHashedBlock() == false) return nCount - nRemaining; // Bytes actually read } int nCopy = Math.Min(m_pbBuffer.Length - m_nBufferPos, nRemaining); Array.Copy(m_pbBuffer, m_nBufferPos, pbBuffer, nOffset, nCopy); nOffset += nCopy; m_nBufferPos += nCopy; nRemaining -= nCopy; } return nCount; } private bool ReadHashedBlock() { if(m_bEos) return false; // End of stream reached already m_nBufferPos = 0; if(m_brInput.ReadUInt32() != m_uBufferIndex) throw new InvalidDataException(); ++m_uBufferIndex; byte[] pbStoredHash = m_brInput.ReadBytes(32); if((pbStoredHash == null) || (pbStoredHash.Length != 32)) throw new InvalidDataException(); int nBufferSize = 0; try { nBufferSize = m_brInput.ReadInt32(); } catch(NullReferenceException) // Mono bug workaround (LaunchPad 783268) { if(!NativeLib.IsUnix()) throw; } if(nBufferSize < 0) throw new InvalidDataException(); if(nBufferSize == 0) { for(int iHash = 0; iHash < 32; ++iHash) { if(pbStoredHash[iHash] != 0) throw new InvalidDataException(); } m_bEos = true; m_pbBuffer = new byte[0]; return false; } m_pbBuffer = m_brInput.ReadBytes(nBufferSize); if((m_pbBuffer == null) || ((m_pbBuffer.Length != nBufferSize) && m_bVerify)) throw new InvalidDataException(); if(m_bVerify) { SHA256Managed sha256 = new SHA256Managed(); byte[] pbComputedHash = sha256.ComputeHash(m_pbBuffer); if((pbComputedHash == null) || (pbComputedHash.Length != 32)) throw new InvalidOperationException(); for(int iHashPos = 0; iHashPos < 32; ++iHashPos) { if(pbStoredHash[iHashPos] != pbComputedHash[iHashPos]) throw new InvalidDataException(); } } return true; } public override void Write(byte[] pbBuffer, int nOffset, int nCount) { if(!m_bWriting) throw new InvalidOperationException(); while(nCount > 0) { if(m_nBufferPos == m_pbBuffer.Length) WriteHashedBlock(); int nCopy = Math.Min(m_pbBuffer.Length - m_nBufferPos, nCount); Array.Copy(pbBuffer, nOffset, m_pbBuffer, m_nBufferPos, nCopy); nOffset += nCopy; m_nBufferPos += nCopy; nCount -= nCopy; } } private void WriteHashedBlock() { m_bwOutput.Write(m_uBufferIndex); ++m_uBufferIndex; if(m_nBufferPos > 0) { SHA256Managed sha256 = new SHA256Managed(); #if !KeePassLibSD byte[] pbHash = sha256.ComputeHash(m_pbBuffer, 0, m_nBufferPos); #else byte[] pbHash; if(m_nBufferPos == m_pbBuffer.Length) pbHash = sha256.ComputeHash(m_pbBuffer); else { byte[] pbData = new byte[m_nBufferPos]; Array.Copy(m_pbBuffer, 0, pbData, 0, m_nBufferPos); pbHash = sha256.ComputeHash(pbData); } #endif m_bwOutput.Write(pbHash); } else { m_bwOutput.Write((ulong)0); // Zero hash m_bwOutput.Write((ulong)0); m_bwOutput.Write((ulong)0); m_bwOutput.Write((ulong)0); } m_bwOutput.Write(m_nBufferPos); if(m_nBufferPos > 0) m_bwOutput.Write(m_pbBuffer, 0, m_nBufferPos); m_nBufferPos = 0; } } } keepass2-2.25/KeePassLib/Serialization/FileTransactionEx.cs0000664000175000017500000001025712261553106023631 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; #if (!KeePassLibSD && !KeePassRT) using System.Security.AccessControl; #endif using KeePassLib.Native; using KeePassLib.Utility; namespace KeePassLib.Serialization { public sealed class FileTransactionEx { private bool m_bTransacted; private IOConnectionInfo m_iocBase; private IOConnectionInfo m_iocTemp; private bool m_bMadeUnhidden = false; private const string StrTempSuffix = ".tmp"; public FileTransactionEx(IOConnectionInfo iocBaseFile) { Initialize(iocBaseFile, true); } public FileTransactionEx(IOConnectionInfo iocBaseFile, bool bTransacted) { Initialize(iocBaseFile, bTransacted); } private void Initialize(IOConnectionInfo iocBaseFile, bool bTransacted) { if(iocBaseFile == null) throw new ArgumentNullException("iocBaseFile"); m_bTransacted = bTransacted; m_iocBase = iocBaseFile.CloneDeep(); // Prevent transactions for FTP URLs under .NET 4.0 in order to // avoid/workaround .NET bug 621450: // https://connect.microsoft.com/VisualStudio/feedback/details/621450/problem-renaming-file-on-ftp-server-using-ftpwebrequest-in-net-framework-4-0-vs2010-only if(m_iocBase.Path.StartsWith("ftp:", StrUtil.CaseIgnoreCmp) && (Environment.Version.Major >= 4) && !NativeLib.IsUnix()) m_bTransacted = false; if(m_bTransacted) { m_iocTemp = m_iocBase.CloneDeep(); m_iocTemp.Path += StrTempSuffix; } else m_iocTemp = m_iocBase; } public Stream OpenWrite() { if(!m_bTransacted) m_bMadeUnhidden = UrlUtil.UnhideFile(m_iocTemp.Path); else // m_bTransacted { try { IOConnection.DeleteFile(m_iocTemp); } catch(Exception) { } } return IOConnection.OpenWrite(m_iocTemp); } public void CommitWrite() { if(m_bTransacted) CommitWriteTransaction(); else // !m_bTransacted { if(m_bMadeUnhidden) UrlUtil.HideFile(m_iocTemp.Path, true); // Hide again } } private void CommitWriteTransaction() { bool bMadeUnhidden = UrlUtil.UnhideFile(m_iocBase.Path); #if (!KeePassLibSD && !KeePassRT) FileSecurity bkSecurity = null; bool bEfsEncrypted = false; #endif if(IOConnection.FileExists(m_iocBase)) { #if (!KeePassLibSD && !KeePassRT) if(m_iocBase.IsLocalFile()) { try { FileAttributes faBase = File.GetAttributes(m_iocBase.Path); bEfsEncrypted = ((long)(faBase & FileAttributes.Encrypted) != 0); DateTime tCreation = File.GetCreationTime(m_iocBase.Path); bkSecurity = File.GetAccessControl(m_iocBase.Path); File.SetCreationTime(m_iocTemp.Path, tCreation); } catch(Exception) { Debug.Assert(false); } } #endif IOConnection.DeleteFile(m_iocBase); } IOConnection.RenameFile(m_iocTemp, m_iocBase); #if (!KeePassLibSD && !KeePassRT) if(m_iocBase.IsLocalFile()) { try { if(bEfsEncrypted) { try { File.Encrypt(m_iocBase.Path); } catch(Exception) { Debug.Assert(false); } } if(bkSecurity != null) File.SetAccessControl(m_iocBase.Path, bkSecurity); } catch(Exception) { Debug.Assert(false); } } #endif if(bMadeUnhidden) UrlUtil.HideFile(m_iocBase.Path, true); // Hide again } } } keepass2-2.25/KeePassLib/Serialization/BinaryReaderEx.cs0000664000175000017500000000467312261553106023120 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePassLib.Utility; namespace KeePassLib.Serialization { public sealed class BinaryReaderEx { private Stream m_s; // private Encoding m_enc; // See constructor private string m_strReadExcp; public string ReadExceptionText { get { return m_strReadExcp; } set { m_strReadExcp = value; } } private Stream m_sCopyTo = null; /// /// If this property is set to a non-null stream, all data that /// is read from the input stream is automatically written to /// the copy stream (before returning the read data). /// public Stream CopyDataTo { get { return m_sCopyTo; } set { m_sCopyTo = value; } } public BinaryReaderEx(Stream input, Encoding encoding, string strReadExceptionText) { if(input == null) throw new ArgumentNullException("input"); m_s = input; // m_enc = encoding; // Not used yet m_strReadExcp = strReadExceptionText; } public byte[] ReadBytes(int nCount) { try { byte[] pb = MemUtil.Read(m_s, nCount); if((pb == null) || (pb.Length != nCount)) { if(m_strReadExcp != null) throw new IOException(m_strReadExcp); else throw new EndOfStreamException(); } if(m_sCopyTo != null) m_sCopyTo.Write(pb, 0, pb.Length); return pb; } catch(Exception) { if(m_strReadExcp != null) throw new IOException(m_strReadExcp); else throw; } } public byte ReadByte() { byte[] pb = ReadBytes(1); return pb[0]; } } } keepass2-2.25/KeePassLib/Serialization/KdbxFile.Read.cs0000664000175000017500000003031212261553106022603 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using System.Security; using System.Security.Cryptography; using System.Xml; #if !KeePassLibSD using System.IO.Compression; #else using KeePassLibSD; #endif using KeePassLib.Cryptography; using KeePassLib.Cryptography.Cipher; using KeePassLib.Interfaces; using KeePassLib.Keys; using KeePassLib.Resources; using KeePassLib.Utility; namespace KeePassLib.Serialization { /// /// Serialization to KeePass KDBX files. /// public sealed partial class KdbxFile { /// /// Load a KDB file from a file. /// /// File to load. /// Format specifier. /// Status logger (optional). public void Load(string strFilePath, KdbxFormat kdbFormat, IStatusLogger slLogger) { IOConnectionInfo ioc = IOConnectionInfo.FromPath(strFilePath); Load(IOConnection.OpenRead(ioc), kdbFormat, slLogger); } /// /// Load a KDB file from a stream. /// /// Stream to read the data from. Must contain /// a KDBX stream. /// Format specifier. /// Status logger (optional). public void Load(Stream sSource, KdbxFormat kdbFormat, IStatusLogger slLogger) { Debug.Assert(sSource != null); if(sSource == null) throw new ArgumentNullException("sSource"); m_format = kdbFormat; m_slLogger = slLogger; HashingStreamEx hashedStream = new HashingStreamEx(sSource, false, null); UTF8Encoding encNoBom = StrUtil.Utf8; try { BinaryReaderEx br = null; BinaryReaderEx brDecrypted = null; Stream readerStream = null; if(kdbFormat == KdbxFormat.Default) { br = new BinaryReaderEx(hashedStream, encNoBom, KLRes.FileCorrupted); ReadHeader(br); Stream sDecrypted = AttachStreamDecryptor(hashedStream); if((sDecrypted == null) || (sDecrypted == hashedStream)) throw new SecurityException(KLRes.CryptoStreamFailed); brDecrypted = new BinaryReaderEx(sDecrypted, encNoBom, KLRes.FileCorrupted); byte[] pbStoredStartBytes = brDecrypted.ReadBytes(32); if((m_pbStreamStartBytes == null) || (m_pbStreamStartBytes.Length != 32)) throw new InvalidDataException(); for(int iStart = 0; iStart < 32; ++iStart) { if(pbStoredStartBytes[iStart] != m_pbStreamStartBytes[iStart]) throw new InvalidCompositeKeyException(); } Stream sHashed = new HashedBlockStream(sDecrypted, false, 0, !m_bRepairMode); if(m_pwDatabase.Compression == PwCompressionAlgorithm.GZip) readerStream = new GZipStream(sHashed, CompressionMode.Decompress); else readerStream = sHashed; } else if(kdbFormat == KdbxFormat.PlainXml) readerStream = hashedStream; else { Debug.Assert(false); throw new FormatException("KdbFormat"); } if(kdbFormat != KdbxFormat.PlainXml) // Is an encrypted format { if(m_pbProtectedStreamKey == null) { Debug.Assert(false); throw new SecurityException("Invalid protected stream key!"); } m_randomStream = new CryptoRandomStream(m_craInnerRandomStream, m_pbProtectedStreamKey); } else m_randomStream = null; // No random stream for plain-text files #if KeePassDebug_WriteXml // FileStream fsOut = new FileStream("Raw.xml", FileMode.Create, // FileAccess.Write, FileShare.None); // try // { // while(true) // { // int b = readerStream.ReadByte(); // if(b == -1) break; // fsOut.WriteByte((byte)b); // } // } // catch(Exception) { } // fsOut.Close(); #endif ReadXmlStreamed(readerStream, hashedStream); // ReadXmlDom(readerStream); readerStream.Close(); // GC.KeepAlive(br); // GC.KeepAlive(brDecrypted); } catch(CryptographicException) // Thrown on invalid padding { throw new CryptographicException(KLRes.FileCorrupted); } finally { CommonCleanUpRead(sSource, hashedStream); } } private void CommonCleanUpRead(Stream sSource, HashingStreamEx hashedStream) { hashedStream.Close(); m_pbHashOfFileOnDisk = hashedStream.Hash; sSource.Close(); // Reset memory protection settings (to always use reasonable // defaults) m_pwDatabase.MemoryProtection = new MemoryProtectionConfig(); // Remove old backups (this call is required here in order to apply // the default history maintenance settings for people upgrading from // KeePass <= 2.14 to >= 2.15; also it ensures history integrity in // case a different application has created the KDBX file and ignored // the history maintenance settings) m_pwDatabase.MaintainBackups(); // Don't mark database as modified m_pbHashOfHeader = null; } private void ReadHeader(BinaryReaderEx br) { MemoryStream msHeader = new MemoryStream(); Debug.Assert(br.CopyDataTo == null); br.CopyDataTo = msHeader; byte[] pbSig1 = br.ReadBytes(4); uint uSig1 = MemUtil.BytesToUInt32(pbSig1); byte[] pbSig2 = br.ReadBytes(4); uint uSig2 = MemUtil.BytesToUInt32(pbSig2); if((uSig1 == FileSignatureOld1) && (uSig2 == FileSignatureOld2)) throw new OldFormatException(PwDefs.ShortProductName + @" 1.x", OldFormatException.OldFormatType.KeePass1x); if((uSig1 == FileSignature1) && (uSig2 == FileSignature2)) { } else if((uSig1 == FileSignaturePreRelease1) && (uSig2 == FileSignaturePreRelease2)) { } else throw new FormatException(KLRes.FileSigInvalid); byte[] pb = br.ReadBytes(4); uint uVersion = MemUtil.BytesToUInt32(pb); if((uVersion & FileVersionCriticalMask) > (FileVersion32 & FileVersionCriticalMask)) throw new FormatException(KLRes.FileVersionUnsupported + MessageService.NewParagraph + KLRes.FileNewVerReq); while(true) { if(ReadHeaderField(br) == false) break; } br.CopyDataTo = null; byte[] pbHeader = msHeader.ToArray(); msHeader.Close(); SHA256Managed sha256 = new SHA256Managed(); m_pbHashOfHeader = sha256.ComputeHash(pbHeader); } private bool ReadHeaderField(BinaryReaderEx brSource) { Debug.Assert(brSource != null); if(brSource == null) throw new ArgumentNullException("brSource"); byte btFieldID = brSource.ReadByte(); ushort uSize = MemUtil.BytesToUInt16(brSource.ReadBytes(2)); byte[] pbData = null; if(uSize > 0) { string strPrevExcpText = brSource.ReadExceptionText; brSource.ReadExceptionText = KLRes.FileHeaderEndEarly; pbData = brSource.ReadBytes(uSize); brSource.ReadExceptionText = strPrevExcpText; } bool bResult = true; KdbxHeaderFieldID kdbID = (KdbxHeaderFieldID)btFieldID; switch(kdbID) { case KdbxHeaderFieldID.EndOfHeader: bResult = false; // Returning false indicates end of header break; case KdbxHeaderFieldID.CipherID: SetCipher(pbData); break; case KdbxHeaderFieldID.CompressionFlags: SetCompressionFlags(pbData); break; case KdbxHeaderFieldID.MasterSeed: m_pbMasterSeed = pbData; CryptoRandom.Instance.AddEntropy(pbData); break; case KdbxHeaderFieldID.TransformSeed: m_pbTransformSeed = pbData; CryptoRandom.Instance.AddEntropy(pbData); break; case KdbxHeaderFieldID.TransformRounds: m_pwDatabase.KeyEncryptionRounds = MemUtil.BytesToUInt64(pbData); break; case KdbxHeaderFieldID.EncryptionIV: m_pbEncryptionIV = pbData; break; case KdbxHeaderFieldID.ProtectedStreamKey: m_pbProtectedStreamKey = pbData; CryptoRandom.Instance.AddEntropy(pbData); break; case KdbxHeaderFieldID.StreamStartBytes: m_pbStreamStartBytes = pbData; break; case KdbxHeaderFieldID.InnerRandomStreamID: SetInnerRandomStreamID(pbData); break; default: Debug.Assert(false); if(m_slLogger != null) m_slLogger.SetText(KLRes.UnknownHeaderId + @": " + kdbID.ToString() + "!", LogStatusType.Warning); break; } return bResult; } private void SetCipher(byte[] pbID) { if((pbID == null) || (pbID.Length != 16)) throw new FormatException(KLRes.FileUnknownCipher); m_pwDatabase.DataCipherUuid = new PwUuid(pbID); } private void SetCompressionFlags(byte[] pbFlags) { int nID = (int)MemUtil.BytesToUInt32(pbFlags); if((nID < 0) || (nID >= (int)PwCompressionAlgorithm.Count)) throw new FormatException(KLRes.FileUnknownCompression); m_pwDatabase.Compression = (PwCompressionAlgorithm)nID; } private void SetInnerRandomStreamID(byte[] pbID) { uint uID = MemUtil.BytesToUInt32(pbID); if(uID >= (uint)CrsAlgorithm.Count) throw new FormatException(KLRes.FileUnknownCipher); m_craInnerRandomStream = (CrsAlgorithm)uID; } private Stream AttachStreamDecryptor(Stream s) { MemoryStream ms = new MemoryStream(); Debug.Assert(m_pbMasterSeed.Length == 32); if(m_pbMasterSeed.Length != 32) throw new FormatException(KLRes.MasterSeedLengthInvalid); ms.Write(m_pbMasterSeed, 0, 32); byte[] pKey32 = m_pwDatabase.MasterKey.GenerateKey32(m_pbTransformSeed, m_pwDatabase.KeyEncryptionRounds).ReadData(); if((pKey32 == null) || (pKey32.Length != 32)) throw new SecurityException(KLRes.InvalidCompositeKey); ms.Write(pKey32, 0, 32); SHA256Managed sha256 = new SHA256Managed(); byte[] aesKey = sha256.ComputeHash(ms.ToArray()); ms.Close(); Array.Clear(pKey32, 0, 32); if((aesKey == null) || (aesKey.Length != 32)) throw new SecurityException(KLRes.FinalKeyCreationFailed); ICipherEngine iEngine = CipherPool.GlobalPool.GetCipher(m_pwDatabase.DataCipherUuid); if(iEngine == null) throw new SecurityException(KLRes.FileUnknownCipher); return iEngine.DecryptStream(s, aesKey, m_pbEncryptionIV); } [Obsolete] public static List ReadEntries(PwDatabase pwDatabase, Stream msData) { return ReadEntries(msData); } /// /// Read entries from a stream. /// /// Input stream to read the entries from. /// Extracted entries. public static List ReadEntries(Stream msData) { /* KdbxFile f = new KdbxFile(pwDatabase); f.m_format = KdbxFormat.PlainXml; XmlDocument doc = new XmlDocument(); doc.Load(msData); XmlElement el = doc.DocumentElement; if(el.Name != ElemRoot) throw new FormatException(); List vEntries = new List(); foreach(XmlNode xmlChild in el.ChildNodes) { if(xmlChild.Name == ElemEntry) { PwEntry pe = f.ReadEntry(xmlChild); pe.Uuid = new PwUuid(true); foreach(PwEntry peHistory in pe.History) peHistory.Uuid = pe.Uuid; vEntries.Add(pe); } else { Debug.Assert(false); } } return vEntries; */ PwDatabase pd = new PwDatabase(); KdbxFile f = new KdbxFile(pd); f.Load(msData, KdbxFormat.PlainXml, null); List vEntries = new List(); foreach(PwEntry pe in pd.RootGroup.Entries) { pe.SetUuid(new PwUuid(true), true); vEntries.Add(pe); } return vEntries; } } } keepass2-2.25/KeePassLib/Interfaces/0000775000175000017500000000000012261553104017157 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLib/Interfaces/IDeepCloneable.cs0000664000175000017500000000237312261553104022306 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; namespace KeePassLib.Interfaces { /// /// Interface for objects that are deeply cloneable. /// /// Reference type. public interface IDeepCloneable where T : class { /// /// Deeply clone the object. /// /// Cloned object. T CloneDeep(); } } keepass2-2.25/KeePassLib/Interfaces/IStatusLogger.cs0000664000175000017500000000642712261553104022253 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; namespace KeePassLib.Interfaces { /// /// Status message types. /// public enum LogStatusType { /// /// Default type: simple information type. /// Info = 0, /// /// Warning message. /// Warning, /// /// Error message. /// Error, /// /// Additional information. Depends on lines above. /// AdditionalInfo } /// /// Status logging interface. /// public interface IStatusLogger { /// /// Function which needs to be called when logging is started. /// /// This string should roughly describe /// the operation, of which the status is logged. /// Specifies whether the /// operation is written to the log or not. void StartLogging(string strOperation, bool bWriteOperationToLog); /// /// Function which needs to be called when logging is ended /// (i.e. when no more messages will be logged and when the /// percent value won't change any more). /// void EndLogging(); /// /// Set the current progress in percent. /// /// Percent of work finished. /// Returns true if the caller should continue /// the current work. bool SetProgress(uint uPercent); /// /// Set the current status text. /// /// Status text. /// Type of the message. /// Returns true if the caller should continue /// the current work. bool SetText(string strNewText, LogStatusType lsType); /// /// Check if the user cancelled the current work. /// /// Returns true if the caller should continue /// the current work. bool ContinueWork(); } public sealed class NullStatusLogger : IStatusLogger { public void StartLogging(string strOperation, bool bWriteOperationToLog) { } public void EndLogging() { } public bool SetProgress(uint uPercent) { return true; } public bool SetText(string strNewText, LogStatusType lsType) { return true; } public bool ContinueWork() { return true; } } } keepass2-2.25/KeePassLib/Interfaces/IStructureItem.cs0000664000175000017500000000207512261553104022442 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; namespace KeePassLib.Interfaces { public interface IStructureItem : ITimeLogger // Provides LocationChanged { PwUuid Uuid { get; set; } PwGroup ParentGroup { get; } } } keepass2-2.25/KeePassLib/Interfaces/IUIOperations.cs0000664000175000017500000000253612261553104022206 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; namespace KeePassLib.Interfaces { public interface IUIOperations { /// /// Let the user interface save the current database. /// /// If true, the UI will not ask for /// whether to synchronize or overwrite, it'll simply overwrite the /// file. /// Returns true if the file has been saved. bool UIFileSave(bool bForceSave); } } keepass2-2.25/KeePassLib/Interfaces/IXmlSerializerEx.cs0000664000175000017500000000215512261553104022711 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml; namespace KeePassLib.Interfaces { public interface IXmlSerializerEx { void Serialize(XmlWriter xmlWriter, object o); object Deserialize(Stream s); } } keepass2-2.25/KeePassLib/Interfaces/ITimeLogger.cs0000664000175000017500000000525112261553104021660 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; namespace KeePassLib.Interfaces { /// /// Interface for objects that support various times (creation time, last /// access time, last modification time and expiry time). Offers /// several helper functions (for example a function to touch the current /// object). /// public interface ITimeLogger { /// /// The date/time when the object was created. /// DateTime CreationTime { get; set; } /// /// The date/time when the object was last modified. /// DateTime LastModificationTime { get; set; } /// /// The date/time when the object was last accessed. /// DateTime LastAccessTime { get; set; } /// /// The date/time when the object expires. /// DateTime ExpiryTime { get; set; } /// /// Flag that determines if the object does expire. /// bool Expires { get; set; } /// /// Get or set the usage count of the object. To increase the usage /// count by one, use the Touch function. /// ulong UsageCount { get; set; } /// /// The date/time when the location of the object was last changed. /// DateTime LocationChanged { get; set; } /// /// Touch the object. This function updates the internal last access /// time. If the parameter is true, /// the last modification time gets updated, too. Each time you call /// Touch, the usage count of the object is increased by one. /// /// Update last modification time. void Touch(bool bModified); } } keepass2-2.25/KeePassLib/Resources/0000775000175000017500000000000012271476254017061 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLib/Resources/KLRes.Generated.cs0000664000175000017500000003402312271476254022267 0ustar jtaylorjtaylor// This is a generated file! // Do not edit manually, changes will be overwritten. using System; using System.Collections.Generic; namespace KeePassLib.Resources { /// /// A strongly-typed resource class, for looking up localized strings, etc. /// public static class KLRes { private static string TryGetEx(Dictionary dictNew, string strName, string strDefault) { string strTemp; if(dictNew.TryGetValue(strName, out strTemp)) return strTemp; return strDefault; } public static void SetTranslatedStrings(Dictionary dictNew) { if(dictNew == null) throw new ArgumentNullException("dictNew"); m_strCryptoStreamFailed = TryGetEx(dictNew, "CryptoStreamFailed", m_strCryptoStreamFailed); m_strEncAlgorithmAes = TryGetEx(dictNew, "EncAlgorithmAes", m_strEncAlgorithmAes); m_strErrorInClipboard = TryGetEx(dictNew, "ErrorInClipboard", m_strErrorInClipboard); m_strFatalError = TryGetEx(dictNew, "FatalError", m_strFatalError); m_strFatalErrorText = TryGetEx(dictNew, "FatalErrorText", m_strFatalErrorText); m_strFileCorrupted = TryGetEx(dictNew, "FileCorrupted", m_strFileCorrupted); m_strFileHeaderEndEarly = TryGetEx(dictNew, "FileHeaderEndEarly", m_strFileHeaderEndEarly); m_strFileLoadFailed = TryGetEx(dictNew, "FileLoadFailed", m_strFileLoadFailed); m_strFileLockedWrite = TryGetEx(dictNew, "FileLockedWrite", m_strFileLockedWrite); m_strFileNewVerReq = TryGetEx(dictNew, "FileNewVerReq", m_strFileNewVerReq); m_strFileSaveCorruptionWarning = TryGetEx(dictNew, "FileSaveCorruptionWarning", m_strFileSaveCorruptionWarning); m_strFileSaveFailed = TryGetEx(dictNew, "FileSaveFailed", m_strFileSaveFailed); m_strFileSigInvalid = TryGetEx(dictNew, "FileSigInvalid", m_strFileSigInvalid); m_strFileUnknownCipher = TryGetEx(dictNew, "FileUnknownCipher", m_strFileUnknownCipher); m_strFileUnknownCompression = TryGetEx(dictNew, "FileUnknownCompression", m_strFileUnknownCompression); m_strFileVersionUnsupported = TryGetEx(dictNew, "FileVersionUnsupported", m_strFileVersionUnsupported); m_strFinalKeyCreationFailed = TryGetEx(dictNew, "FinalKeyCreationFailed", m_strFinalKeyCreationFailed); m_strFrameworkNotImplExcp = TryGetEx(dictNew, "FrameworkNotImplExcp", m_strFrameworkNotImplExcp); m_strInvalidCompositeKey = TryGetEx(dictNew, "InvalidCompositeKey", m_strInvalidCompositeKey); m_strInvalidCompositeKeyHint = TryGetEx(dictNew, "InvalidCompositeKeyHint", m_strInvalidCompositeKeyHint); m_strInvalidDataWhileDecoding = TryGetEx(dictNew, "InvalidDataWhileDecoding", m_strInvalidDataWhileDecoding); m_strKeePass1xHint = TryGetEx(dictNew, "KeePass1xHint", m_strKeePass1xHint); m_strKeyFileDbSel = TryGetEx(dictNew, "KeyFileDbSel", m_strKeyFileDbSel); m_strMasterSeedLengthInvalid = TryGetEx(dictNew, "MasterSeedLengthInvalid", m_strMasterSeedLengthInvalid); m_strOldFormat = TryGetEx(dictNew, "OldFormat", m_strOldFormat); m_strTryAgainSecs = TryGetEx(dictNew, "TryAgainSecs", m_strTryAgainSecs); m_strUnknownHeaderId = TryGetEx(dictNew, "UnknownHeaderId", m_strUnknownHeaderId); m_strUserAccountKeyError = TryGetEx(dictNew, "UserAccountKeyError", m_strUserAccountKeyError); } private static readonly string[] m_vKeyNames = { "CryptoStreamFailed", "EncAlgorithmAes", "ErrorInClipboard", "FatalError", "FatalErrorText", "FileCorrupted", "FileHeaderEndEarly", "FileLoadFailed", "FileLockedWrite", "FileNewVerReq", "FileSaveCorruptionWarning", "FileSaveFailed", "FileSigInvalid", "FileUnknownCipher", "FileUnknownCompression", "FileVersionUnsupported", "FinalKeyCreationFailed", "FrameworkNotImplExcp", "InvalidCompositeKey", "InvalidCompositeKeyHint", "InvalidDataWhileDecoding", "KeePass1xHint", "KeyFileDbSel", "MasterSeedLengthInvalid", "OldFormat", "TryAgainSecs", "UnknownHeaderId", "UserAccountKeyError" }; public static string[] GetKeyNames() { return m_vKeyNames; } private static string m_strCryptoStreamFailed = @"Failed to initialize encryption/decryption stream!"; /// /// Look up a localized string similar to /// 'Failed to initialize encryption/decryption stream!'. /// public static string CryptoStreamFailed { get { return m_strCryptoStreamFailed; } } private static string m_strEncAlgorithmAes = @"AES/Rijndael (256-Bit Key)"; /// /// Look up a localized string similar to /// 'AES/Rijndael (256-Bit Key)'. /// public static string EncAlgorithmAes { get { return m_strEncAlgorithmAes; } } private static string m_strErrorInClipboard = @"An extended error report has been copied to the clipboard."; /// /// Look up a localized string similar to /// 'An extended error report has been copied to the clipboard.'. /// public static string ErrorInClipboard { get { return m_strErrorInClipboard; } } private static string m_strFatalError = @"Fatal Error"; /// /// Look up a localized string similar to /// 'Fatal Error'. /// public static string FatalError { get { return m_strFatalError; } } private static string m_strFatalErrorText = @"A fatal error has occurred!"; /// /// Look up a localized string similar to /// 'A fatal error has occurred!'. /// public static string FatalErrorText { get { return m_strFatalErrorText; } } private static string m_strFileCorrupted = @"The file is corrupted."; /// /// Look up a localized string similar to /// 'The file is corrupted.'. /// public static string FileCorrupted { get { return m_strFileCorrupted; } } private static string m_strFileHeaderEndEarly = @"The file header is corrupted! Some header data was declared but is not present."; /// /// Look up a localized string similar to /// 'The file header is corrupted! Some header data was declared but is not present.'. /// public static string FileHeaderEndEarly { get { return m_strFileHeaderEndEarly; } } private static string m_strFileLoadFailed = @"Failed to load the specified file!"; /// /// Look up a localized string similar to /// 'Failed to load the specified file!'. /// public static string FileLoadFailed { get { return m_strFileLoadFailed; } } private static string m_strFileLockedWrite = @"The file is locked, because the following user is currently writing to it:"; /// /// Look up a localized string similar to /// 'The file is locked, because the following user is currently writing to it:'. /// public static string FileLockedWrite { get { return m_strFileLockedWrite; } } private static string m_strFileNewVerReq = @"A newer KeePass version is required to open this file."; /// /// Look up a localized string similar to /// 'A newer KeePass version is required to open this file.'. /// public static string FileNewVerReq { get { return m_strFileNewVerReq; } } private static string m_strFileSaveCorruptionWarning = @"The target file might be corrupted. Please try saving again. If that fails, save the database to a different location."; /// /// Look up a localized string similar to /// 'The target file might be corrupted. Please try saving again. If that fails, save the database to a different location.'. /// public static string FileSaveCorruptionWarning { get { return m_strFileSaveCorruptionWarning; } } private static string m_strFileSaveFailed = @"Failed to save the current database to the specified location!"; /// /// Look up a localized string similar to /// 'Failed to save the current database to the specified location!'. /// public static string FileSaveFailed { get { return m_strFileSaveFailed; } } private static string m_strFileSigInvalid = @"The file signature is invalid. Either the file isn't a KeePass database file at all or it is corrupted."; /// /// Look up a localized string similar to /// 'The file signature is invalid. Either the file isn't a KeePass database file at all or it is corrupted.'. /// public static string FileSigInvalid { get { return m_strFileSigInvalid; } } private static string m_strFileUnknownCipher = @"The file is encrypted using an unknown encryption algorithm!"; /// /// Look up a localized string similar to /// 'The file is encrypted using an unknown encryption algorithm!'. /// public static string FileUnknownCipher { get { return m_strFileUnknownCipher; } } private static string m_strFileUnknownCompression = @"The file is compressed using an unknown compression algorithm!"; /// /// Look up a localized string similar to /// 'The file is compressed using an unknown compression algorithm!'. /// public static string FileUnknownCompression { get { return m_strFileUnknownCompression; } } private static string m_strFileVersionUnsupported = @"The file version is unsupported."; /// /// Look up a localized string similar to /// 'The file version is unsupported.'. /// public static string FileVersionUnsupported { get { return m_strFileVersionUnsupported; } } private static string m_strFinalKeyCreationFailed = @"Failed to create the final encryption/decryption key!"; /// /// Look up a localized string similar to /// 'Failed to create the final encryption/decryption key!'. /// public static string FinalKeyCreationFailed { get { return m_strFinalKeyCreationFailed; } } private static string m_strFrameworkNotImplExcp = @"The .NET framework/runtime under which KeePass is currently running does not support this operation."; /// /// Look up a localized string similar to /// 'The .NET framework/runtime under which KeePass is currently running does not support this operation.'. /// public static string FrameworkNotImplExcp { get { return m_strFrameworkNotImplExcp; } } private static string m_strInvalidCompositeKey = @"The composite key is invalid!"; /// /// Look up a localized string similar to /// 'The composite key is invalid!'. /// public static string InvalidCompositeKey { get { return m_strInvalidCompositeKey; } } private static string m_strInvalidCompositeKeyHint = @"Make sure the composite key is correct and try again."; /// /// Look up a localized string similar to /// 'Make sure the composite key is correct and try again.'. /// public static string InvalidCompositeKeyHint { get { return m_strInvalidCompositeKeyHint; } } private static string m_strInvalidDataWhileDecoding = @"Found invalid data while decoding."; /// /// Look up a localized string similar to /// 'Found invalid data while decoding.'. /// public static string InvalidDataWhileDecoding { get { return m_strInvalidDataWhileDecoding; } } private static string m_strKeePass1xHint = @"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."; /// /// Look up a localized string similar to /// '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.'. /// public static string KeePass1xHint { get { return m_strKeePass1xHint; } } private static string m_strKeyFileDbSel = @"Database files cannot be used as key files."; /// /// Look up a localized string similar to /// 'Database files cannot be used as key files.'. /// public static string KeyFileDbSel { get { return m_strKeyFileDbSel; } } private static string m_strMasterSeedLengthInvalid = @"The length of the master key seed is invalid!"; /// /// Look up a localized string similar to /// 'The length of the master key seed is invalid!'. /// public static string MasterSeedLengthInvalid { get { return m_strMasterSeedLengthInvalid; } } private static string m_strOldFormat = @"The selected file appears to be an old format"; /// /// Look up a localized string similar to /// 'The selected file appears to be an old format'. /// public static string OldFormat { get { return m_strOldFormat; } } private static string m_strTryAgainSecs = @"Please try it again in a few seconds."; /// /// Look up a localized string similar to /// 'Please try it again in a few seconds.'. /// public static string TryAgainSecs { get { return m_strTryAgainSecs; } } private static string m_strUnknownHeaderId = @"Unknown header ID!"; /// /// Look up a localized string similar to /// 'Unknown header ID!'. /// public static string UnknownHeaderId { get { return m_strUnknownHeaderId; } } private static string m_strUserAccountKeyError = @"The operating system did not grant KeePass read/write access to the user profile folder, where the protected user key is stored."; /// /// Look up a localized string similar to /// 'The operating system did not grant KeePass read/write access to the user profile folder, where the protected user key is stored.'. /// public static string UserAccountKeyError { get { return m_strUserAccountKeyError; } } } } keepass2-2.25/KeePassLib/Resources/KSRes.Generated.cs0000664000175000017500000000216312271476254022276 0ustar jtaylorjtaylor// This is a generated file! // Do not edit manually, changes will be overwritten. using System; using System.Collections.Generic; namespace KeePassLib.Resources { /// /// A strongly-typed resource class, for looking up localized strings, etc. /// public static class KSRes { private static string TryGetEx(Dictionary dictNew, string strName, string strDefault) { string strTemp; if(dictNew.TryGetValue(strName, out strTemp)) return strTemp; return strDefault; } public static void SetTranslatedStrings(Dictionary dictNew) { if(dictNew == null) throw new ArgumentNullException("dictNew"); m_strTest = TryGetEx(dictNew, "Test", m_strTest); } private static readonly string[] m_vKeyNames = { "Test" }; public static string[] GetKeyNames() { return m_vKeyNames; } private static string m_strTest = @"Test"; /// /// Look up a localized string similar to /// 'Test'. /// public static string Test { get { return m_strTest; } } } } keepass2-2.25/KeePassLib/KeePassLib.pfx0000664000175000017500000000333410576764760017623 0ustar jtaylorjtaylor00 *H 0}0 *H 00 *H  00 *H  05D?*dI& |i&fKG;#!΀%R[m)ZwQoT>ybv[O$Rd3OWo7c4;תBvft87 5SG LLP4AiF2L[+ )$as(Q+Oݷ+hț[#~)[jgriL8V(C3=JpzĺV 3:|<`N8+؃8, tjؚyD5֙,X2ut_."h/^+ɳ)oAL̒*Yv3V윎,J3kgLp/s(AqPԼH^˪Ͳ;6L$ 8̒/Ya\J7zl0+/eϬ!!v,(7w&ٝ|mQZmI];8FVW.";> r'E gӟ.4{j<(C ҉v9&g>+9= 9}z7Dݗ]2>y%o,^9߸E69Rd_yYaļI6h>'3s=7haT<$t\1BOJuHsw3dMBjW"F~aؒz>um+yj8S!X*ZР#D!;*q^1-28=p'>[ɠ> !\8CY5qM~}dWBx~I`߃m@%wz'mBqlCd |~E~Q4nvwm0d΢pJ4\Z46`W|Uc Ut10;00+&cr{ 5FL~!4Sqn.Ckeepass2-2.25/KeePassLib/Security/0000775000175000017500000000000012261553104016703 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLib/Security/XorredBuffer.cs0000664000175000017500000000764012261553104021636 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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. XorredBuffer objects are immutable and /// thread-safe. /// public sealed class XorredBuffer { private byte[] m_pbData; // Never null private byte[] m_pbXorPad; // Always valid for m_pbData /// /// 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. /// The XorredBuffer object takes ownership of the two byte /// arrays, i.e. the caller must not use or modify them afterwards. /// /// Protected data (XOR pad applied). /// XOR pad that can be 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) { if(pbProtectedData == null) { Debug.Assert(false); throw new ArgumentNullException("pbProtectedData"); } if(pbXorPad == null) { Debug.Assert(false); throw new ArgumentNullException("pbXorPad"); } Debug.Assert(pbProtectedData.Length == pbXorPad.Length); if(pbProtectedData.Length != pbXorPad.Length) throw new ArgumentException(); m_pbData = pbProtectedData; m_pbXorPad = pbXorPad; } /// /// Get a copy of the plain-text. The caller is responsible /// for clearing the byte array safely after using it. /// /// Unprotected plain-text byte array. public byte[] ReadPlainText() { byte[] pbPlain = new byte[m_pbData.Length]; for(int i = 0; i < pbPlain.Length; ++i) pbPlain[i] = (byte)(m_pbData[i] ^ m_pbXorPad[i]); return pbPlain; } /* 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; for(int i = 0; i < m_pbData.Length; ++i) { byte bt1 = (byte)(m_pbData[i] ^ m_pbXorPad[i]); byte bt2 = (byte)(xb.m_pbData[i] ^ 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; for(int i = 0; i < m_pbData.Length; ++i) { if((byte)(m_pbData[i] ^ m_pbXorPad[i]) != pb[i]) return false; } return true; } */ } } keepass2-2.25/KeePassLib/Security/ProtectedBinary.cs0000664000175000017500000001661412261553104022340 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Cryptography; using System.Diagnostics; using KeePassLib.Cryptography; using KeePassLib.Utility; #if KeePassLibSD using KeePassLibSD; #endif namespace KeePassLib.Security { /// /// Represents a protected binary, i.e. a byte array that is encrypted /// in memory. A ProtectedBinary object is immutable and /// thread-safe. /// public sealed class ProtectedBinary : IEquatable { private const int PmBlockSize = 16; // In-memory protection is supported only on Windows 2000 SP3 and // higher. private static bool m_bProtectionSupported; private byte[] m_pbData; // Never null // The real length of the data. This value can be different than // m_pbData.Length, as the length of m_pbData always is a multiple // of PmBlockSize (required for fast in-memory protection). private uint m_uDataLen; private bool m_bProtected; private object m_objSync = new object(); /// /// A flag specifying whether the ProtectedBinary object has /// turned on in-memory protection or not. /// public bool IsProtected { get { return m_bProtected; } } /// /// Length of the stored data. /// public uint Length { get { return m_uDataLen; } } static ProtectedBinary() { try // Test whether ProtectedMemory is supported { byte[] pbDummy = new byte[PmBlockSize * 2]; ProtectedMemory.Protect(pbDummy, MemoryProtectionScope.SameProcess); m_bProtectionSupported = true; } catch(Exception) // Windows 98 / ME { m_bProtectionSupported = false; } } /// /// Construct a new, empty protected binary data object. Protection /// is disabled. /// public ProtectedBinary() { Init(false, new byte[0]); } /// /// Construct a new protected binary data object. /// /// If this paremeter is true, /// the data will be encrypted in memory. If it is false, the /// data is stored in plain-text in the process memory. /// Value of the protected object. /// The input parameter is not modified and /// ProtectedBinary doesn't take ownership of the data, /// i.e. the caller is responsible for clearing it. public ProtectedBinary(bool bEnableProtection, byte[] pbData) { Init(bEnableProtection, pbData); } /// /// Construct a new protected binary data object. Copy the data from /// a XorredBuffer object. /// /// Enable protection or not. /// XorredBuffer object used to /// initialize the ProtectedBinary object. /// Thrown if the input /// parameter is null. public ProtectedBinary(bool bEnableProtection, XorredBuffer xbProtected) { Debug.Assert(xbProtected != null); if(xbProtected == null) throw new ArgumentNullException("xbProtected"); byte[] pb = xbProtected.ReadPlainText(); Init(bEnableProtection, pb); MemUtil.ZeroByteArray(pb); } private void Init(bool bEnableProtection, byte[] pbData) { if(pbData == null) throw new ArgumentNullException("pbData"); m_bProtected = bEnableProtection; m_uDataLen = (uint)pbData.Length; int nBlocks = (int)m_uDataLen / PmBlockSize; if((nBlocks * PmBlockSize) < (int)m_uDataLen) ++nBlocks; Debug.Assert((nBlocks * PmBlockSize) >= (int)m_uDataLen); m_pbData = new byte[nBlocks * PmBlockSize]; Array.Copy(pbData, m_pbData, (int)m_uDataLen); // Data size must be > 0, otherwise 'Protect' throws if(m_bProtected && m_bProtectionSupported && (m_uDataLen > 0)) ProtectedMemory.Protect(m_pbData, MemoryProtectionScope.SameProcess); } /// /// Get a copy of the protected data as a byte array. /// Please note that the returned byte array is not protected and /// can therefore been read by any other application. /// Make sure that your clear it properly after usage. /// /// Unprotected byte array. This is always a copy of the internal /// protected data and can therefore be cleared safely. public byte[] ReadData() { if(m_uDataLen == 0) return new byte[0]; byte[] pbReturn = new byte[m_uDataLen]; if(m_bProtected && m_bProtectionSupported) { lock(m_objSync) { ProtectedMemory.Unprotect(m_pbData, MemoryProtectionScope.SameProcess); Array.Copy(m_pbData, pbReturn, (int)m_uDataLen); ProtectedMemory.Protect(m_pbData, MemoryProtectionScope.SameProcess); } } else Array.Copy(m_pbData, pbReturn, (int)m_uDataLen); return pbReturn; } /// /// Read the protected data and return it protected with a sequence /// of bytes generated by a random stream. /// /// Random number source. /// Protected data. /// Thrown if the input /// parameter is null. public byte[] ReadXorredData(CryptoRandomStream crsRandomSource) { Debug.Assert(crsRandomSource != null); if(crsRandomSource == null) throw new ArgumentNullException("crsRandomSource"); byte[] pbData = ReadData(); 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; } public override int GetHashCode() { int h = (m_bProtected ? 0x7B11D289 : 0); byte[] pb = ReadData(); unchecked { for(int i = 0; i < pb.Length; ++i) h = (h << 3) + h + (int)pb[i]; } MemUtil.ZeroByteArray(pb); return h; } public override bool Equals(object obj) { return Equals(obj as ProtectedBinary); } public bool Equals(ProtectedBinary other) { if(other == null) return false; // No assert if(m_bProtected != other.m_bProtected) return false; if(m_uDataLen != other.m_uDataLen) return false; byte[] pbL = ReadData(); byte[] pbR = other.ReadData(); bool bEq = MemUtil.ArraysEqual(pbL, pbR); MemUtil.ZeroByteArray(pbL); MemUtil.ZeroByteArray(pbR); #if DEBUG if(bEq) { Debug.Assert(GetHashCode() == other.GetHashCode()); } #endif return bEq; } } } keepass2-2.25/KeePassLib/Security/ProtectedString.cs0000664000175000017500000001744712261553104022367 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Text; using System.Diagnostics; using KeePassLib.Cryptography; using KeePassLib.Utility; #if KeePassLibSD using KeePassLibSD; #endif // SecureString objects are limited to 65536 characters, don't use namespace KeePassLib.Security { /// /// Represents an in-memory encrypted string. /// ProtectedString objects are immutable and thread-safe. /// #if (DEBUG && !KeePassLibSD) [DebuggerDisplay(@"{ReadString()}")] #endif public sealed class ProtectedString { // Exactly one of the following will be non-null private ProtectedBinary m_pbUtf8 = null; private string m_strPlainText = null; private bool m_bIsProtected; private static ProtectedString m_psEmpty = new ProtectedString(); public static ProtectedString Empty { get { return m_psEmpty; } } /// /// A flag specifying whether the ProtectedString object /// has turned on in-memory protection or not. /// public bool IsProtected { get { return m_bIsProtected; } } public bool IsEmpty { get { ProtectedBinary pBin = m_pbUtf8; // Local ref for thread-safety if(pBin != null) return (pBin.Length == 0); Debug.Assert(m_strPlainText != null); return (m_strPlainText.Length == 0); } } private int m_nCachedLength = -1; public int Length { get { if(m_nCachedLength >= 0) return m_nCachedLength; ProtectedBinary pBin = m_pbUtf8; // Local ref for thread-safety if(pBin != null) { byte[] pbPlain = pBin.ReadData(); m_nCachedLength = StrUtil.Utf8.GetCharCount(pbPlain); MemUtil.ZeroByteArray(pbPlain); } else { Debug.Assert(m_strPlainText != null); m_nCachedLength = m_strPlainText.Length; } return m_nCachedLength; } } /// /// Construct a new protected string object. Protection is /// disabled. /// public ProtectedString() { Init(false, string.Empty); } /// /// 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) { Init(bEnableProtection, 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; the caller /// is responsible for clearing it. public ProtectedString(bool bEnableProtection, byte[] vUtf8Value) { Init(bEnableProtection, vUtf8Value); } /// /// 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) { if(xbProtected == null) throw new ArgumentNullException("xbProtected"); byte[] pb = xbProtected.ReadPlainText(); Init(bEnableProtection, pb); MemUtil.ZeroByteArray(pb); } private void Init(bool bEnableProtection, string str) { if(str == null) throw new ArgumentNullException("str"); m_bIsProtected = bEnableProtection; // The string already is in memory and immutable, // protection would be useless m_strPlainText = str; } private void Init(bool bEnableProtection, byte[] pbUtf8) { if(pbUtf8 == null) throw new ArgumentNullException("pbUtf8"); m_bIsProtected = bEnableProtection; if(bEnableProtection) m_pbUtf8 = new ProtectedBinary(true, pbUtf8); else m_strPlainText = StrUtil.Utf8.GetString(pbUtf8, 0, pbUtf8.Length); } /// /// Convert the protected string to a normal string object. /// Be careful with this function, the returned string object /// isn't protected anymore and stored in plain-text in the /// process memory. /// /// Plain-text string. Is never null. public string ReadString() { if(m_strPlainText != null) return m_strPlainText; byte[] pb = ReadUtf8(); string str = ((pb.Length == 0) ? string.Empty : StrUtil.Utf8.GetString(pb, 0, pb.Length)); // No need to clear pb // As the text is now visible in process memory anyway, // there's no need to protect it anymore m_strPlainText = str; m_pbUtf8 = null; // Thread-safe order return str; } /// /// 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() { ProtectedBinary pBin = m_pbUtf8; // Local ref for thread-safety if(pBin != null) return pBin.ReadData(); return StrUtil.Utf8.GetBytes(m_strPlainText); } /// /// Read the protected string and return it protected with a sequence /// of bytes generated by a random stream. /// /// 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"); 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; } public ProtectedString WithProtection(bool bProtect) { if(bProtect == m_bIsProtected) return this; byte[] pb = ReadUtf8(); ProtectedString ps = new ProtectedString(bProtect, pb); MemUtil.ZeroByteArray(pb); return ps; } } } keepass2-2.25/KeePassLib/Collections/0000775000175000017500000000000012261553104017352 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLib/Collections/StringDictionaryEx.cs0000664000175000017500000000676612261553104023511 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; using System.Collections.Generic; using System.Text; using System.Diagnostics; using KeePassLib.Interfaces; #if KeePassLibSD using KeePassLibSD; #endif namespace KeePassLib.Collections { public sealed class StringDictionaryEx : IDeepCloneable, IEnumerable> { private SortedDictionary m_vDict = new SortedDictionary(); public int Count { get { return m_vDict.Count; } } public StringDictionaryEx() { } IEnumerator IEnumerable.GetEnumerator() { return m_vDict.GetEnumerator(); } public IEnumerator> GetEnumerator() { return m_vDict.GetEnumerator(); } public StringDictionaryEx CloneDeep() { StringDictionaryEx plNew = new StringDictionaryEx(); foreach(KeyValuePair kvpStr in m_vDict) plNew.Set(kvpStr.Key, kvpStr.Value); return plNew; } public string Get(string strName) { Debug.Assert(strName != null); if(strName == null) throw new ArgumentNullException("strName"); string s; if(m_vDict.TryGetValue(strName, out s)) return s; return null; } public bool Exists(string strName) { Debug.Assert(strName != null); if(strName == null) throw new ArgumentNullException("strName"); return m_vDict.ContainsKey(strName); } /// /// Set a string. /// /// Identifier of the string field to modify. /// New value. This parameter must not be null. /// Thrown if one of the input /// parameters is null. public void Set(string strField, string strNewValue) { Debug.Assert(strField != null); if(strField == null) throw new ArgumentNullException("strField"); Debug.Assert(strNewValue != null); if(strNewValue == null) throw new ArgumentNullException("strNewValue"); m_vDict[strField] = strNewValue; } /// /// Delete a string. /// /// Name of the string field to delete. /// Returns true if the field has been successfully /// removed, otherwise the return value is false. /// Thrown if the input /// parameter is null. public bool Remove(string strField) { Debug.Assert(strField != null); if(strField == null) throw new ArgumentNullException("strField"); return m_vDict.Remove(strField); } } } keepass2-2.25/KeePassLib/Collections/ProtectedBinaryDictionary.cs0000664000175000017500000001233412261553104025030 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; using System.Collections.Generic; using System.Text; using System.Diagnostics; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; #if KeePassLibSD using KeePassLibSD; #endif namespace KeePassLib.Collections { /// /// A list of ProtectedBinary objects (dictionary). /// public sealed class ProtectedBinaryDictionary : IDeepCloneable, IEnumerable> { private SortedDictionary m_vBinaries = new SortedDictionary(); /// /// Get the number of binaries in this entry. /// public uint UCount { get { return (uint)m_vBinaries.Count; } } /// /// Construct a new list of protected binaries. /// public ProtectedBinaryDictionary() { } IEnumerator IEnumerable.GetEnumerator() { return m_vBinaries.GetEnumerator(); } public IEnumerator> GetEnumerator() { return m_vBinaries.GetEnumerator(); } public void Clear() { m_vBinaries.Clear(); } /// /// Clone the current ProtectedBinaryList object, including all /// stored protected strings. /// /// New ProtectedBinaryList object. public ProtectedBinaryDictionary CloneDeep() { ProtectedBinaryDictionary plNew = new ProtectedBinaryDictionary(); foreach(KeyValuePair kvpBin in m_vBinaries) { // ProtectedBinary objects are immutable plNew.Set(kvpBin.Key, kvpBin.Value); } return plNew; } public bool EqualsDictionary(ProtectedBinaryDictionary dict) { if(dict == null) { Debug.Assert(false); return false; } if(m_vBinaries.Count != dict.m_vBinaries.Count) return false; foreach(KeyValuePair kvp in m_vBinaries) { ProtectedBinary pb = dict.Get(kvp.Key); if(pb == null) return false; if(!pb.Equals(kvp.Value)) return false; } return true; } /// /// Get one of the stored binaries. /// /// Binary identifier. /// Protected binary. If the binary identified by /// cannot be found, the function /// returns null. /// Thrown if the input /// parameter is null. public ProtectedBinary Get(string strName) { Debug.Assert(strName != null); if(strName == null) throw new ArgumentNullException("strName"); ProtectedBinary pb; if(m_vBinaries.TryGetValue(strName, out pb)) return pb; return null; } /// /// Set a binary object. /// /// Identifier of the binary field to modify. /// New value. This parameter must not be null. /// Thrown if any of the input /// parameters is null. public void Set(string strField, ProtectedBinary pbNewValue) { Debug.Assert(strField != null); if(strField == null) throw new ArgumentNullException("strField"); Debug.Assert(pbNewValue != null); if(pbNewValue == null) throw new ArgumentNullException("pbNewValue"); m_vBinaries[strField] = pbNewValue; } /// /// Remove a binary object. /// /// Identifier of the binary field to remove. /// Returns true if the object has been successfully /// removed, otherwise false. /// Thrown if the input parameter /// is null. public bool Remove(string strField) { Debug.Assert(strField != null); if(strField == null) throw new ArgumentNullException("strField"); return m_vBinaries.Remove(strField); } public string KeysToString() { if(m_vBinaries.Count == 0) return string.Empty; StringBuilder sb = new StringBuilder(); foreach(KeyValuePair kvp in m_vBinaries) { if(sb.Length > 0) sb.Append(", "); sb.Append(kvp.Key); } return sb.ToString(); } } } keepass2-2.25/KeePassLib/Collections/PwObjectPool.cs0000664000175000017500000000420212261553104022246 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePassLib.Delegates; using KeePassLib.Interfaces; #if KeePassLibSD using KeePassLibSD; #endif namespace KeePassLib.Collections { public sealed class PwObjectPool { private SortedDictionary m_dict = new SortedDictionary(); public static PwObjectPool FromGroupRecursive(PwGroup pgRoot, bool bEntries) { if(pgRoot == null) throw new ArgumentNullException("pgRoot"); PwObjectPool p = new PwObjectPool(); if(!bEntries) p.m_dict[pgRoot.Uuid] = pgRoot; GroupHandler gh = delegate(PwGroup pg) { p.m_dict[pg.Uuid] = pg; return true; }; EntryHandler eh = delegate(PwEntry pe) { p.m_dict[pe.Uuid] = pe; return true; }; pgRoot.TraverseTree(TraversalMethod.PreOrder, bEntries ? null : gh, bEntries ? eh : null); return p; } public IStructureItem Get(PwUuid pwUuid) { IStructureItem pItem; m_dict.TryGetValue(pwUuid, out pItem); return pItem; } public bool ContainsOnlyType(Type t) { foreach(KeyValuePair kvp in m_dict) { if(kvp.Value.GetType() != t) return false; } return true; } } } keepass2-2.25/KeePassLib/Collections/PwObjectList.cs0000664000175000017500000002112512261553104022253 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; using System.Collections.Generic; using System.Diagnostics; using KeePassLib.Interfaces; namespace KeePassLib.Collections { /// /// List of objects that implement IDeepCloneable, /// and cannot be null. /// /// Type specifier. public sealed class PwObjectList : IEnumerable where T : class, IDeepCloneable { private List m_vObjects = new List(); /// /// Get number of objects in this list. /// public uint UCount { get { return (uint)m_vObjects.Count; } } /// /// Construct a new list of objects. /// public PwObjectList() { } IEnumerator IEnumerable.GetEnumerator() { return m_vObjects.GetEnumerator(); } public IEnumerator GetEnumerator() { return m_vObjects.GetEnumerator(); } public void Clear() { // Do not destroy contained objects! m_vObjects.Clear(); } /// /// Clone the current PwObjectList, including all /// stored objects (deep copy). /// /// New PwObjectList. public PwObjectList CloneDeep() { PwObjectList pl = new PwObjectList(); foreach(T po in m_vObjects) pl.Add(po.CloneDeep()); return pl; } public PwObjectList CloneShallow() { PwObjectList tNew = new PwObjectList(); foreach(T po in m_vObjects) tNew.Add(po); return tNew; } public List CloneShallowToList() { PwObjectList tNew = CloneShallow(); return tNew.m_vObjects; } /// /// Add an object to this list. /// /// Object to be added. /// Thrown if the input /// parameter is null. public void Add(T pwObject) { Debug.Assert(pwObject != null); if(pwObject == null) throw new ArgumentNullException("pwObject"); m_vObjects.Add(pwObject); } public void Add(PwObjectList vObjects) { Debug.Assert(vObjects != null); if(vObjects == null) throw new ArgumentNullException("vObjects"); foreach(T po in vObjects) { m_vObjects.Add(po); } } public void Add(List vObjects) { Debug.Assert(vObjects != null); if(vObjects == null) throw new ArgumentNullException("vObjects"); foreach(T po in vObjects) { m_vObjects.Add(po); } } public void Insert(uint uIndex, T pwObject) { Debug.Assert(pwObject != null); if(pwObject == null) throw new ArgumentNullException("pwObject"); m_vObjects.Insert((int)uIndex, pwObject); } /// /// Get an object of the list. /// /// Index of the object to get. Must be valid, otherwise an /// exception is thrown. /// Reference to an existing T object. Is never null. public T GetAt(uint uIndex) { Debug.Assert(uIndex < m_vObjects.Count); if(uIndex >= m_vObjects.Count) throw new ArgumentOutOfRangeException("uIndex"); return m_vObjects[(int)uIndex]; } public void SetAt(uint uIndex, T pwObject) { Debug.Assert(pwObject != null); if(pwObject == null) throw new ArgumentNullException("pwObject"); if(uIndex >= (uint)m_vObjects.Count) throw new ArgumentOutOfRangeException("uIndex"); m_vObjects[(int)uIndex] = pwObject; } /// /// Get a range of objects. /// /// Index of the first object to be /// returned (inclusive). /// Index of the last object to be /// returned (inclusive). /// public List GetRange(uint uStartIndexIncl, uint uEndIndexIncl) { if(uStartIndexIncl >= (uint)m_vObjects.Count) throw new ArgumentOutOfRangeException("uStartIndexIncl"); if(uEndIndexIncl >= (uint)m_vObjects.Count) throw new ArgumentOutOfRangeException("uEndIndexIncl"); if(uStartIndexIncl > uEndIndexIncl) throw new ArgumentException(); List list = new List((int)(uEndIndexIncl - uStartIndexIncl) + 1); for(uint u = uStartIndexIncl; u <= uEndIndexIncl; ++u) { list.Add(m_vObjects[(int)u]); } return list; } public int IndexOf(T pwReference) { Debug.Assert(pwReference != null); if(pwReference == null) throw new ArgumentNullException("pwReference"); return m_vObjects.IndexOf(pwReference); } /// /// Delete an object of this list. The object to be deleted is identified /// by a reference handle. /// /// Reference of the object to be deleted. /// Returns true if the object was deleted, false if /// the object wasn't found in this list. /// Thrown if the input /// parameter is null. public bool Remove(T pwReference) { Debug.Assert(pwReference != null); if(pwReference == null) throw new ArgumentNullException("pwReference"); return m_vObjects.Remove(pwReference); } public void RemoveAt(uint uIndex) { m_vObjects.RemoveAt((int)uIndex); } /// /// Move an object up or down. /// /// The object to be moved. /// Move one up. If false, move one down. public void MoveOne(T tObject, bool bUp) { Debug.Assert(tObject != null); if(tObject == null) throw new ArgumentNullException("tObject"); int nCount = m_vObjects.Count; if(nCount <= 1) return; int nIndex = m_vObjects.IndexOf(tObject); Debug.Assert(nIndex >= 0); if(bUp && (nIndex > 0)) // No assert for top item { T tTemp = m_vObjects[nIndex - 1]; m_vObjects[nIndex - 1] = m_vObjects[nIndex]; m_vObjects[nIndex] = tTemp; } else if(!bUp && (nIndex != (nCount - 1))) // No assert for bottom item { T tTemp = m_vObjects[nIndex + 1]; m_vObjects[nIndex + 1] = m_vObjects[nIndex]; m_vObjects[nIndex] = tTemp; } } /// /// Move some of the objects in this list to the top/bottom. /// /// List of objects to be moved. /// Move to top. If false, move to bottom. public void MoveTopBottom(T[] vObjects, bool bTop) { Debug.Assert(vObjects != null); if(vObjects == null) throw new ArgumentNullException("vObjects"); if(vObjects.Length == 0) return; int nCount = m_vObjects.Count; foreach(T t in vObjects) m_vObjects.Remove(t); if(bTop) { int nPos = 0; foreach(T t in vObjects) { m_vObjects.Insert(nPos, t); ++nPos; } } else // Move to bottom { foreach(T t in vObjects) m_vObjects.Add(t); } Debug.Assert(nCount == m_vObjects.Count); if(nCount != m_vObjects.Count) throw new ArgumentException("At least one of the T objects in the vObjects list doesn't exist!"); } public void Sort(IComparer tComparer) { if(tComparer == null) throw new ArgumentNullException("tComparer"); m_vObjects.Sort(tComparer); } public static PwObjectList FromArray(T[] tArray) { if(tArray == null) throw new ArgumentNullException("tArray"); PwObjectList l = new PwObjectList(); foreach(T t in tArray) { l.Add(t); } return l; } public static PwObjectList FromList(List tList) { if(tList == null) throw new ArgumentNullException("tList"); PwObjectList l = new PwObjectList(); l.Add(tList); return l; } } } keepass2-2.25/KeePassLib/Collections/AutoTypeConfig.cs0000664000175000017500000001331112261553104022600 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using KeePassLib.Interfaces; namespace KeePassLib.Collections { [Flags] public enum AutoTypeObfuscationOptions { None = 0, UseClipboard = 1 } public sealed class AutoTypeAssociation : IEquatable, IDeepCloneable { private string m_strWindow = string.Empty; public string WindowName { get { return m_strWindow; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_strWindow = value; } } private string m_strSequence = string.Empty; public string Sequence { get { return m_strSequence; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_strSequence = value; } } public AutoTypeAssociation() { } public AutoTypeAssociation(string strWindow, string strSeq) { if(strWindow == null) throw new ArgumentNullException("strWindow"); if(strSeq == null) throw new ArgumentNullException("strSeq"); m_strWindow = strWindow; m_strSequence = strSeq; } public bool Equals(AutoTypeAssociation other) { if(other == null) return false; if(m_strWindow != other.m_strWindow) return false; if(m_strSequence != other.m_strSequence) return false; return true; } public AutoTypeAssociation CloneDeep() { return (AutoTypeAssociation)this.MemberwiseClone(); } } /// /// A list of auto-type associations. /// public sealed class AutoTypeConfig : IEquatable, IDeepCloneable { private bool m_bEnabled = true; private AutoTypeObfuscationOptions m_atooObfuscation = AutoTypeObfuscationOptions.None; private string m_strDefaultSequence = string.Empty; private List m_lWindowAssocs = new List(); /// /// Specify whether auto-type is enabled or not. /// public bool Enabled { get { return m_bEnabled; } set { m_bEnabled = value; } } /// /// Specify whether the typing should be obfuscated. /// public AutoTypeObfuscationOptions ObfuscationOptions { get { return m_atooObfuscation; } set { m_atooObfuscation = value; } } /// /// The default keystroke sequence that is auto-typed if /// no matching window is found in the Associations /// container. /// public string DefaultSequence { get { return m_strDefaultSequence; } set { Debug.Assert(value != null); if(value == null) throw new ArgumentNullException("value"); m_strDefaultSequence = value; } } /// /// Get all auto-type window/keystroke sequence pairs. /// public IEnumerable Associations { get { return m_lWindowAssocs; } } public int AssociationsCount { get { return m_lWindowAssocs.Count; } } /// /// Construct a new auto-type associations list. /// public AutoTypeConfig() { } /// /// Remove all associations. /// public void Clear() { m_lWindowAssocs.Clear(); } /// /// Clone the auto-type associations list. /// /// New, cloned object. public AutoTypeConfig CloneDeep() { AutoTypeConfig newCfg = new AutoTypeConfig(); newCfg.m_bEnabled = m_bEnabled; newCfg.m_atooObfuscation = m_atooObfuscation; newCfg.m_strDefaultSequence = m_strDefaultSequence; foreach(AutoTypeAssociation a in m_lWindowAssocs) newCfg.Add(a.CloneDeep()); return newCfg; } public bool Equals(AutoTypeConfig other) { if(other == null) { Debug.Assert(false); return false; } if(m_bEnabled != other.m_bEnabled) return false; if(m_atooObfuscation != other.m_atooObfuscation) return false; if(m_strDefaultSequence != other.m_strDefaultSequence) return false; if(m_lWindowAssocs.Count != other.m_lWindowAssocs.Count) return false; for(int i = 0; i < m_lWindowAssocs.Count; ++i) { if(!m_lWindowAssocs[i].Equals(other.m_lWindowAssocs[i])) return false; } return true; } public void Add(AutoTypeAssociation a) { Debug.Assert(a != null); if(a == null) throw new ArgumentNullException("a"); m_lWindowAssocs.Add(a); } public AutoTypeAssociation GetAt(int iIndex) { if((iIndex < 0) || (iIndex >= m_lWindowAssocs.Count)) throw new ArgumentOutOfRangeException("iIndex"); return m_lWindowAssocs[iIndex]; } public void RemoveAt(int iIndex) { if((iIndex < 0) || (iIndex >= m_lWindowAssocs.Count)) throw new ArgumentOutOfRangeException("iIndex"); m_lWindowAssocs.RemoveAt(iIndex); } } } keepass2-2.25/KeePassLib/Collections/ProtectedStringDictionary.cs0000664000175000017500000002322512261553104025053 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; using System.Collections.Generic; using System.Diagnostics; using System.Text; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; #if KeePassLibSD using KeePassLibSD; #endif namespace KeePassLib.Collections { /// /// A list of ProtectedString objects (dictionary). /// public sealed class ProtectedStringDictionary : IDeepCloneable, IEnumerable> { private SortedDictionary m_vStrings = new SortedDictionary(); /// /// Get the number of strings in this entry. /// public uint UCount { get { return (uint)m_vStrings.Count; } } /// /// Construct a new list of protected strings. /// public ProtectedStringDictionary() { } IEnumerator IEnumerable.GetEnumerator() { return m_vStrings.GetEnumerator(); } public IEnumerator> GetEnumerator() { return m_vStrings.GetEnumerator(); } public void Clear() { m_vStrings.Clear(); } /// /// Clone the current ProtectedStringList object, including all /// stored protected strings. /// /// New ProtectedStringList object. public ProtectedStringDictionary CloneDeep() { ProtectedStringDictionary plNew = new ProtectedStringDictionary(); foreach(KeyValuePair kvpStr in m_vStrings) { // ProtectedString objects are immutable plNew.Set(kvpStr.Key, kvpStr.Value); } return plNew; } [Obsolete] public bool EqualsDictionary(ProtectedStringDictionary dict) { return EqualsDictionary(dict, PwCompareOptions.None, MemProtCmpMode.None); } [Obsolete] public bool EqualsDictionary(ProtectedStringDictionary dict, MemProtCmpMode mpCompare) { return EqualsDictionary(dict, PwCompareOptions.None, mpCompare); } public bool EqualsDictionary(ProtectedStringDictionary dict, PwCompareOptions pwOpt, MemProtCmpMode mpCompare) { if(dict == null) { Debug.Assert(false); return false; } bool bNeEqStd = ((pwOpt & PwCompareOptions.NullEmptyEquivStd) != PwCompareOptions.None); if(!bNeEqStd) { if(m_vStrings.Count != dict.m_vStrings.Count) return false; } foreach(KeyValuePair kvp in m_vStrings) { bool bStdField = PwDefs.IsStandardField(kvp.Key); ProtectedString ps = dict.Get(kvp.Key); if(bNeEqStd && (ps == null) && bStdField) ps = ProtectedString.Empty; if(ps == null) return false; if(mpCompare == MemProtCmpMode.Full) { if(ps.IsProtected != kvp.Value.IsProtected) return false; } else if(mpCompare == MemProtCmpMode.CustomOnly) { if(!bStdField && (ps.IsProtected != kvp.Value.IsProtected)) return false; } if(ps.ReadString() != kvp.Value.ReadString()) return false; } if(bNeEqStd) { foreach(KeyValuePair kvp in dict.m_vStrings) { ProtectedString ps = Get(kvp.Key); if(ps != null) continue; // Compared previously if(!PwDefs.IsStandardField(kvp.Key)) return false; if(!kvp.Value.IsEmpty) return false; } } return true; } /// /// Get one of the protected strings. /// /// String identifier. /// Protected string. If the string identified by /// cannot be found, the function /// returns null. /// Thrown if the input parameter /// is null. public ProtectedString Get(string strName) { Debug.Assert(strName != null); if(strName == null) throw new ArgumentNullException("strName"); ProtectedString ps; if(m_vStrings.TryGetValue(strName, out ps)) return ps; return null; } /// /// Get one of the protected strings. The return value is never null. /// If the requested string cannot be found, an empty protected string /// object is returned. /// /// String identifier. /// Returns a protected string object. If the standard string /// has not been set yet, the return value is an empty string (""). /// Thrown if the input /// parameter is null. public ProtectedString GetSafe(string strName) { Debug.Assert(strName != null); if(strName == null) throw new ArgumentNullException("strName"); ProtectedString ps; if(m_vStrings.TryGetValue(strName, out ps)) return ps; return ProtectedString.Empty; } /// /// Test if a named string exists. /// /// Name of the string to try. /// Returns true if the string exists, otherwise false. /// Thrown if /// is null. public bool Exists(string strName) { Debug.Assert(strName != null); if(strName == null) throw new ArgumentNullException("strName"); return m_vStrings.ContainsKey(strName); } /// /// Get one of the protected strings. If the string doesn't exist, the /// return value is an empty string (""). /// /// Name of the requested string. /// Requested string value or an empty string, if the named /// string doesn't exist. /// Thrown if the input /// parameter is null. public string ReadSafe(string strName) { Debug.Assert(strName != null); if(strName == null) throw new ArgumentNullException("strName"); ProtectedString ps; if(m_vStrings.TryGetValue(strName, out ps)) return ps.ReadString(); return string.Empty; } /// /// Get one of the entry strings. If the string doesn't exist, the /// return value is an empty string (""). If the string is /// in-memory protected, the return value is PwDefs.HiddenPassword. /// /// Name of the requested string. /// Returns the requested string in plain-text or /// PwDefs.HiddenPassword if the string cannot be found. /// Thrown if the input /// parameter is null. public string ReadSafeEx(string strName) { Debug.Assert(strName != null); if(strName == null) throw new ArgumentNullException("strName"); ProtectedString ps; if(m_vStrings.TryGetValue(strName, out ps)) { if(ps.IsProtected) return PwDefs.HiddenPassword; return ps.ReadString(); } return string.Empty; } /// /// Set a string. /// /// Identifier of the string field to modify. /// New value. This parameter must not be null. /// Thrown if one of the input /// parameters is null. public void Set(string strField, ProtectedString psNewValue) { Debug.Assert(strField != null); if(strField == null) throw new ArgumentNullException("strField"); Debug.Assert(psNewValue != null); if(psNewValue == null) throw new ArgumentNullException("psNewValue"); m_vStrings[strField] = psNewValue; } /// /// Delete a string. /// /// Name of the string field to delete. /// Returns true if the field has been successfully /// removed, otherwise the return value is false. /// Thrown if the input /// parameter is null. public bool Remove(string strField) { Debug.Assert(strField != null); if(strField == null) throw new ArgumentNullException("strField"); return m_vStrings.Remove(strField); } public List GetKeys() { List v = new List(); foreach(string strKey in m_vStrings.Keys) v.Add(strKey); return v; } public void EnableProtection(string strField, bool bProtect) { ProtectedString ps = Get(strField); if(ps == null) return; // Nothing to do, no assert if(ps.IsProtected != bProtect) { byte[] pbData = ps.ReadUtf8(); Set(strField, new ProtectedString(bProtect, pbData)); MemUtil.ZeroByteArray(pbData); } } } } keepass2-2.25/KeePassLibSD/0000775000175000017500000000000012273663444015337 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/Native/0000775000175000017500000000000010603243136016550 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/BouncyCastle/0000775000175000017500000000000011643263772017732 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/BouncyCastle/IDigest.cs0000664000175000017500000000337010455733704021611 0ustar jtaylorjtaylorusing System; namespace Org.BouncyCastle.Crypto { /** * interface that a message digest conforms to. */ public interface IDigest { /** * return the algorithm name * * @return the algorithm name */ string AlgorithmName { get; } /** * return the size, in bytes, of the digest produced by this message digest. * * @return the size, in bytes, of the digest produced by this message digest. */ int GetDigestSize(); /** * return the size, in bytes, of the internal buffer used by this digest. * * @return the size, in bytes, of the internal buffer used by this digest. */ int GetByteLength(); /** * update the message digest with a single byte. * * @param inByte the input byte to be entered. */ void Update(byte input); /** * update the message digest with a block of bytes. * * @param input the byte array containing the data. * @param inOff the offset into the byte array where the data starts. * @param len the length of the data. */ void BlockUpdate(byte[] input, int inOff, int length); /** * Close the digest, producing the final digest value. The doFinal * call leaves the digest reset. * * @param output the array the digest is to be copied into. * @param outOff the offset into the out array the digest is to start at. */ int DoFinal(byte[] output, int outOff); /** * reset the digest back to it's initial state. */ void Reset(); } } keepass2-2.25/KeePassLibSD/BouncyCastle/Pack.cs0000664000175000017500000000624511300560320021121 0ustar jtaylorjtaylorusing System; namespace Org.BouncyCastle.Crypto.Utilities { internal sealed class Pack { private Pack() { } internal static void UInt32_To_BE(uint n, byte[] bs) { bs[0] = (byte)(n >> 24); bs[1] = (byte)(n >> 16); bs[2] = (byte)(n >> 8); bs[3] = (byte)(n ); } internal static void UInt32_To_BE(uint n, byte[] bs, int off) { bs[ off] = (byte)(n >> 24); bs[++off] = (byte)(n >> 16); bs[++off] = (byte)(n >> 8); bs[++off] = (byte)(n ); } internal static uint BE_To_UInt32(byte[] bs) { uint n = (uint)bs[0] << 24; n |= (uint)bs[1] << 16; n |= (uint)bs[2] << 8; n |= (uint)bs[3]; return n; } internal static uint BE_To_UInt32(byte[] bs, int off) { uint n = (uint)bs[off] << 24; n |= (uint)bs[++off] << 16; n |= (uint)bs[++off] << 8; n |= (uint)bs[++off]; return n; } internal static ulong BE_To_UInt64(byte[] bs) { uint hi = BE_To_UInt32(bs); uint lo = BE_To_UInt32(bs, 4); return ((ulong)hi << 32) | (ulong)lo; } internal static ulong BE_To_UInt64(byte[] bs, int off) { uint hi = BE_To_UInt32(bs, off); uint lo = BE_To_UInt32(bs, off + 4); return ((ulong)hi << 32) | (ulong)lo; } internal static void UInt64_To_BE(ulong n, byte[] bs) { UInt32_To_BE((uint)(n >> 32), bs); UInt32_To_BE((uint)(n ), bs, 4); } internal static void UInt64_To_BE(ulong n, byte[] bs, int off) { UInt32_To_BE((uint)(n >> 32), bs, off); UInt32_To_BE((uint)(n ), bs, off + 4); } internal static void UInt32_To_LE(uint n, byte[] bs) { bs[0] = (byte)(n ); bs[1] = (byte)(n >> 8); bs[2] = (byte)(n >> 16); bs[3] = (byte)(n >> 24); } internal static void UInt32_To_LE(uint n, byte[] bs, int off) { bs[ off] = (byte)(n ); bs[++off] = (byte)(n >> 8); bs[++off] = (byte)(n >> 16); bs[++off] = (byte)(n >> 24); } internal static uint LE_To_UInt32(byte[] bs) { uint n = (uint)bs[0]; n |= (uint)bs[1] << 8; n |= (uint)bs[2] << 16; n |= (uint)bs[3] << 24; return n; } internal static uint LE_To_UInt32(byte[] bs, int off) { uint n = (uint)bs[off]; n |= (uint)bs[++off] << 8; n |= (uint)bs[++off] << 16; n |= (uint)bs[++off] << 24; return n; } internal static ulong LE_To_UInt64(byte[] bs) { uint lo = LE_To_UInt32(bs); uint hi = LE_To_UInt32(bs, 4); return ((ulong)hi << 32) | (ulong)lo; } internal static ulong LE_To_UInt64(byte[] bs, int off) { uint lo = LE_To_UInt32(bs, off); uint hi = LE_To_UInt32(bs, off + 4); return ((ulong)hi << 32) | (ulong)lo; } internal static void UInt64_To_LE(ulong n, byte[] bs) { UInt32_To_LE((uint)(n ), bs); UInt32_To_LE((uint)(n >> 32), bs, 4); } internal static void UInt64_To_LE(ulong n, byte[] bs, int off) { UInt32_To_LE((uint)(n ), bs, off); UInt32_To_LE((uint)(n >> 32), bs, off + 4); } } } keepass2-2.25/KeePassLibSD/BouncyCastle/License.html0000664000175000017500000000353011323612002022156 0ustar jtaylorjtaylor License

The Bouncy Castle Cryptographic C#® API

License:

The Bouncy Castle License
Copyright (c) 2000-2010 The Legion Of The Bouncy Castle (http://www.bouncycastle.org)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sub license, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

keepass2-2.25/KeePassLibSD/BouncyCastle/Sha256Digest.cs0000664000175000017500000001764611303020430022356 0ustar jtaylorjtaylorusing System; using Org.BouncyCastle.Crypto.Utilities; namespace Org.BouncyCastle.Crypto.Digests { /** * Draft FIPS 180-2 implementation of SHA-256. Note: As this is * based on a draft this implementation is subject to change. * *
    *         block  word  digest
    * SHA-1   512    32    160
    * SHA-256 512    32    256
    * SHA-384 1024   64    384
    * SHA-512 1024   64    512
    * 
*/ public class Sha256Digest : GeneralDigest { private const int DigestLength = 32; private uint H1, H2, H3, H4, H5, H6, H7, H8; private uint[] X = new uint[64]; private int xOff; public Sha256Digest() { initHs(); } /** * Copy constructor. This will copy the state of the provided * message digest. */ public Sha256Digest(Sha256Digest t) : base(t) { H1 = t.H1; H2 = t.H2; H3 = t.H3; H4 = t.H4; H5 = t.H5; H6 = t.H6; H7 = t.H7; H8 = t.H8; Array.Copy(t.X, 0, X, 0, t.X.Length); xOff = t.xOff; } public override string AlgorithmName { get { return "SHA-256"; } } public override int GetDigestSize() { return DigestLength; } internal override void ProcessWord( byte[] input, int inOff) { X[xOff] = Pack.BE_To_UInt32(input, inOff); if (++xOff == 16) { ProcessBlock(); } } internal override void ProcessLength( long bitLength) { if (xOff > 14) { ProcessBlock(); } X[14] = (uint)((ulong)bitLength >> 32); X[15] = (uint)((ulong)bitLength); } public override int DoFinal( byte[] output, int outOff) { Finish(); Pack.UInt32_To_BE((uint)H1, output, outOff); Pack.UInt32_To_BE((uint)H2, output, outOff + 4); Pack.UInt32_To_BE((uint)H3, output, outOff + 8); Pack.UInt32_To_BE((uint)H4, output, outOff + 12); Pack.UInt32_To_BE((uint)H5, output, outOff + 16); Pack.UInt32_To_BE((uint)H6, output, outOff + 20); Pack.UInt32_To_BE((uint)H7, output, outOff + 24); Pack.UInt32_To_BE((uint)H8, output, outOff + 28); Reset(); return DigestLength; } /** * reset the chaining variables */ public override void Reset() { base.Reset(); initHs(); xOff = 0; Array.Clear(X, 0, X.Length); } private void initHs() { /* SHA-256 initial hash value * The first 32 bits of the fractional parts of the square roots * of the first eight prime numbers */ H1 = 0x6a09e667; H2 = 0xbb67ae85; H3 = 0x3c6ef372; H4 = 0xa54ff53a; H5 = 0x510e527f; H6 = 0x9b05688c; H7 = 0x1f83d9ab; H8 = 0x5be0cd19; } internal override void ProcessBlock() { // // expand 16 word block into 64 word blocks. // for (int ti = 16; ti <= 63; ti++) { X[ti] = Theta1(X[ti - 2]) + X[ti - 7] + Theta0(X[ti - 15]) + X[ti - 16]; } // // set up working variables. // uint a = H1; uint b = H2; uint c = H3; uint d = H4; uint e = H5; uint f = H6; uint g = H7; uint h = H8; int t = 0; for(int i = 0; i < 8; ++i) { // t = 8 * i h += Sum1Ch(e, f, g) + K[t] + X[t]; d += h; h += Sum0Maj(a, b, c); ++t; // t = 8 * i + 1 g += Sum1Ch(d, e, f) + K[t] + X[t]; c += g; g += Sum0Maj(h, a, b); ++t; // t = 8 * i + 2 f += Sum1Ch(c, d, e) + K[t] + X[t]; b += f; f += Sum0Maj(g, h, a); ++t; // t = 8 * i + 3 e += Sum1Ch(b, c, d) + K[t] + X[t]; a += e; e += Sum0Maj(f, g, h); ++t; // t = 8 * i + 4 d += Sum1Ch(a, b, c) + K[t] + X[t]; h += d; d += Sum0Maj(e, f, g); ++t; // t = 8 * i + 5 c += Sum1Ch(h, a, b) + K[t] + X[t]; g += c; c += Sum0Maj(d, e, f); ++t; // t = 8 * i + 6 b += Sum1Ch(g, h, a) + K[t] + X[t]; f += b; b += Sum0Maj(c, d, e); ++t; // t = 8 * i + 7 a += Sum1Ch(f, g, h) + K[t] + X[t]; e += a; a += Sum0Maj(b, c, d); ++t; } H1 += a; H2 += b; H3 += c; H4 += d; H5 += e; H6 += f; H7 += g; H8 += h; // // reset the offset and clean out the word buffer. // xOff = 0; Array.Clear(X, 0, 16); } private static uint Sum1Ch( uint x, uint y, uint z) { // return Sum1(x) + Ch(x, y, z); return (((x >> 6) | (x << 26)) ^ ((x >> 11) | (x << 21)) ^ ((x >> 25) | (x << 7))) + ((x & y) ^ ((~x) & z)); } private static uint Sum0Maj( uint x, uint y, uint z) { // return Sum0(x) + Maj(x, y, z); return (((x >> 2) | (x << 30)) ^ ((x >> 13) | (x << 19)) ^ ((x >> 22) | (x << 10))) + ((x & y) ^ (x & z) ^ (y & z)); } // /* SHA-256 functions */ // private static uint Ch( // uint x, // uint y, // uint z) // { // return ((x & y) ^ ((~x) & z)); // } // // private static uint Maj( // uint x, // uint y, // uint z) // { // return ((x & y) ^ (x & z) ^ (y & z)); // } // // private static uint Sum0( // uint x) // { // return ((x >> 2) | (x << 30)) ^ ((x >> 13) | (x << 19)) ^ ((x >> 22) | (x << 10)); // } // // private static uint Sum1( // uint x) // { // return ((x >> 6) | (x << 26)) ^ ((x >> 11) | (x << 21)) ^ ((x >> 25) | (x << 7)); // } private static uint Theta0( uint x) { return ((x >> 7) | (x << 25)) ^ ((x >> 18) | (x << 14)) ^ (x >> 3); } private static uint Theta1( uint x) { return ((x >> 17) | (x << 15)) ^ ((x >> 19) | (x << 13)) ^ (x >> 10); } /* SHA-256 Constants * (represent the first 32 bits of the fractional parts of the * cube roots of the first sixty-four prime numbers) */ private static readonly uint[] K = { 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 }; } } keepass2-2.25/KeePassLibSD/BouncyCastle/GeneralDigest.cs0000664000175000017500000000545011150602156022764 0ustar jtaylorjtaylorusing System; namespace Org.BouncyCastle.Crypto.Digests { /** * base implementation of MD4 family style digest as outlined in * "Handbook of Applied Cryptography", pages 344 - 347. */ public abstract class GeneralDigest : IDigest { private const int BYTE_LENGTH = 64; private byte[] xBuf; private int xBufOff; private long byteCount; internal GeneralDigest() { xBuf = new byte[4]; } internal GeneralDigest(GeneralDigest t) { xBuf = new byte[t.xBuf.Length]; Array.Copy(t.xBuf, 0, xBuf, 0, t.xBuf.Length); xBufOff = t.xBufOff; byteCount = t.byteCount; } public void Update(byte input) { xBuf[xBufOff++] = input; if (xBufOff == xBuf.Length) { ProcessWord(xBuf, 0); xBufOff = 0; } byteCount++; } public void BlockUpdate( byte[] input, int inOff, int length) { // // fill the current word // while ((xBufOff != 0) && (length > 0)) { Update(input[inOff]); inOff++; length--; } // // process whole words. // while (length > xBuf.Length) { ProcessWord(input, inOff); inOff += xBuf.Length; length -= xBuf.Length; byteCount += xBuf.Length; } // // load in the remainder. // while (length > 0) { Update(input[inOff]); inOff++; length--; } } public void Finish() { long bitLength = (byteCount << 3); // // add the pad bytes. // Update((byte)128); while (xBufOff != 0) Update((byte)0); ProcessLength(bitLength); ProcessBlock(); } public virtual void Reset() { byteCount = 0; xBufOff = 0; Array.Clear(xBuf, 0, xBuf.Length); } public int GetByteLength() { return BYTE_LENGTH; } internal abstract void ProcessWord(byte[] input, int inOff); internal abstract void ProcessLength(long bitLength); internal abstract void ProcessBlock(); public abstract string AlgorithmName { get; } public abstract int GetDigestSize(); public abstract int DoFinal(byte[] output, int outOff); } } keepass2-2.25/KeePassLibSD/InvalidDataException.cs0000664000175000017500000000210312261553106021707 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePassLib.Resources; namespace KeePassLibSD { public sealed class InvalidDataException : Exception { public override string Message { get { return KLRes.InvalidDataWhileDecoding; } } } } keepass2-2.25/KeePassLibSD/GZipStream.cs0000664000175000017500000000523112261553106017702 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 ICSharpCode.SharpZipLib.GZip; namespace KeePassLibSD { public enum CompressionMode { Compress = 0, Decompress } public sealed class GZipStream : Stream { private Stream m_gzStream = null; private CompressionMode m_cprMode; public GZipStream(Stream sBase, CompressionMode cm) { if(cm == CompressionMode.Compress) m_gzStream = new GZipOutputStream(sBase); else m_gzStream = new GZipInputStream(sBase); m_cprMode = cm; } public override bool CanRead { get { return m_gzStream.CanRead; } } public override bool CanSeek { get { return m_gzStream.CanSeek; } } public override bool CanWrite { get { return m_gzStream.CanWrite; } } public override long Length { get { return m_gzStream.Length; } } public override long Position { get { return m_gzStream.Position; } set { m_gzStream.Position = value; } } public override void Flush() { m_gzStream.Flush(); } public override void Close() { if(m_gzStream == null) return; if(m_cprMode == CompressionMode.Compress) { m_gzStream.Flush(); ((GZipOutputStream)m_gzStream).Finish(); } m_gzStream.Close(); m_gzStream = null; } public override long Seek(long offset, SeekOrigin origin) { return m_gzStream.Seek(offset, origin); } public override void SetLength(long value) { m_gzStream.SetLength(value); } public override int Read(byte[] buffer, int offset, int count) { return m_gzStream.Read(buffer, offset, count); } public override void Write(byte[] buffer, int offset, int count) { m_gzStream.Write(buffer, offset, count); } } } keepass2-2.25/KeePassLibSD/SecureStringEx.cs0000664000175000017500000000245112261553106020570 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; namespace KeePassLib { public sealed class SecureString { private string m_secString = string.Empty; public int Length { get { return m_secString.Length; } } public void AppendChar(char ch) { m_secString += ch; } public string ReadAsString() { return m_secString; } public void Clear() { m_secString = string.Empty; } } } keepass2-2.25/KeePassLibSD/Translation/0000775000175000017500000000000010756005016017622 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/Keys/0000775000175000017500000000000010573311160016234 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/Utility/0000775000175000017500000000000010573311214016764 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/SharpZipLib/0000775000175000017500000000000011643263772017526 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/SharpZipLib/Main.cs0000664000175000017500000000336510572513660020742 0ustar jtaylorjtaylor// Main.cs // // Copyright (C) 2001 Mike Krueger // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. // keepass2-2.25/KeePassLibSD/SharpZipLib/GZip/0000775000175000017500000000000011643263772020377 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/SharpZipLib/GZip/GzipInputStream.cs0000664000175000017500000002561610667050302024031 0ustar jtaylorjtaylor// GzipInputStream.cs // // Copyright (C) 2001 Mike Krueger // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using System.IO; using ICSharpCode.SharpZipLib.Checksums; using ICSharpCode.SharpZipLib.Zip.Compression; using ICSharpCode.SharpZipLib.Zip.Compression.Streams; namespace ICSharpCode.SharpZipLib.GZip { /// /// This filter stream is used to decompress a "GZIP" format stream. /// The "GZIP" format is described baseInputStream RFC 1952. /// /// author of the original java version : John Leuner /// /// This sample shows how to unzip a gzipped file /// /// using System; /// using System.IO; /// /// using ICSharpCode.SharpZipLib.Core; /// using ICSharpCode.SharpZipLib.GZip; /// /// class MainClass /// { /// public static void Main(string[] args) /// { /// using (Stream inStream = new GZipInputStream(File.OpenRead(args[0]))) /// using (FileStream outStream = File.Create(Path.GetFileNameWithoutExtension(args[0]))) { /// byte[] buffer = new byte[4096]; /// StreamUtils.Copy(inStream, outStream, buffer); /// } /// } /// } /// /// public class GZipInputStream : InflaterInputStream { #region Instance Fields /// /// CRC-32 value for uncompressed data /// protected Crc32 crc = new Crc32(); /// /// Indicates end of stream /// protected bool eos; // Have we read the GZIP header yet? bool readGZIPHeader; #endregion #region Constructors /// /// Creates a GZipInputStream with the default buffer size /// /// /// The stream to read compressed data from (baseInputStream GZIP format) /// public GZipInputStream(Stream baseInputStream) : this(baseInputStream, 4096) { } /// /// Creates a GZIPInputStream with the specified buffer size /// /// /// The stream to read compressed data from (baseInputStream GZIP format) /// /// /// Size of the buffer to use /// public GZipInputStream(Stream baseInputStream, int size) : base(baseInputStream, new Inflater(true), size) { } #endregion #region Stream overrides /// /// Reads uncompressed data into an array of bytes /// /// /// The buffer to read uncompressed data into /// /// /// The offset indicating where the data should be placed /// /// /// The number of uncompressed bytes to be read /// /// Returns the number of bytes actually read. public override int Read(byte[] buffer, int offset, int count) { // We first have to read the GZIP header, then we feed all the // rest of the data to the base class. // // As we do that we continually update the CRC32. Once the data is // finished, we check the CRC32 // // This means we don't need our own buffer, as everything is done // in baseInputStream the superclass. if (!readGZIPHeader) { ReadHeader(); } if (eos) { return 0; } // We don't have to read the header, so we just grab data from the superclass int bytesRead = base.Read(buffer, offset, count); if (bytesRead > 0) { crc.Update(buffer, offset, bytesRead); } if (inf.IsFinished) { ReadFooter(); } return bytesRead; } #endregion #region Support routines void ReadHeader() { // 1. Check the two magic bytes Crc32 headCRC = new Crc32(); int magic = baseInputStream.ReadByte(); if (magic < 0) { throw new EndOfStreamException("EOS reading GZIP header"); } headCRC.Update(magic); if (magic != (GZipConstants.GZIP_MAGIC >> 8)) { throw new GZipException("Error GZIP header, first magic byte doesn't match"); } magic = baseInputStream.ReadByte(); if (magic < 0) { throw new EndOfStreamException("EOS reading GZIP header"); } if (magic != (GZipConstants.GZIP_MAGIC & 0xFF)) { throw new GZipException("Error GZIP header, second magic byte doesn't match"); } headCRC.Update(magic); // 2. Check the compression type (must be 8) int compressionType = baseInputStream.ReadByte(); if ( compressionType < 0 ) { throw new EndOfStreamException("EOS reading GZIP header"); } if ( compressionType != 8 ) { throw new GZipException("Error GZIP header, data not in deflate format"); } headCRC.Update(compressionType); // 3. Check the flags int flags = baseInputStream.ReadByte(); if (flags < 0) { throw new EndOfStreamException("EOS reading GZIP header"); } headCRC.Update(flags); /* This flag byte is divided into individual bits as follows: bit 0 FTEXT bit 1 FHCRC bit 2 FEXTRA bit 3 FNAME bit 4 FCOMMENT bit 5 reserved bit 6 reserved bit 7 reserved */ // 3.1 Check the reserved bits are zero if ((flags & 0xd0) != 0) { throw new GZipException("Reserved flag bits in GZIP header != 0"); } // 4.-6. Skip the modification time, extra flags, and OS type for (int i=0; i< 6; i++) { int readByte = baseInputStream.ReadByte(); if (readByte < 0) { throw new EndOfStreamException("EOS reading GZIP header"); } headCRC.Update(readByte); } // 7. Read extra field if ((flags & GZipConstants.FEXTRA) != 0) { // Skip subfield id for (int i=0; i< 2; i++) { int readByte = baseInputStream.ReadByte(); if (readByte < 0) { throw new EndOfStreamException("EOS reading GZIP header"); } headCRC.Update(readByte); } if (baseInputStream.ReadByte() < 0 || baseInputStream.ReadByte() < 0) { throw new EndOfStreamException("EOS reading GZIP header"); } int len1, len2; len1 = baseInputStream.ReadByte(); len2 = baseInputStream.ReadByte(); if ((len1 < 0) || (len2 < 0)) { throw new EndOfStreamException("EOS reading GZIP header"); } headCRC.Update(len1); headCRC.Update(len2); int extraLen = (len1 << 8) | len2; for (int i = 0; i < extraLen;i++) { int readByte = baseInputStream.ReadByte(); if (readByte < 0) { throw new EndOfStreamException("EOS reading GZIP header"); } headCRC.Update(readByte); } } // 8. Read file name if ((flags & GZipConstants.FNAME) != 0) { int readByte; while ( (readByte = baseInputStream.ReadByte()) > 0) { headCRC.Update(readByte); } if (readByte < 0) { throw new EndOfStreamException("EOS reading GZIP header"); } headCRC.Update(readByte); } // 9. Read comment if ((flags & GZipConstants.FCOMMENT) != 0) { int readByte; while ( (readByte = baseInputStream.ReadByte()) > 0) { headCRC.Update(readByte); } if (readByte < 0) { throw new EndOfStreamException("EOS reading GZIP header"); } headCRC.Update(readByte); } // 10. Read header CRC if ((flags & GZipConstants.FHCRC) != 0) { int tempByte; int crcval = baseInputStream.ReadByte(); if (crcval < 0) { throw new EndOfStreamException("EOS reading GZIP header"); } tempByte = baseInputStream.ReadByte(); if (tempByte < 0) { throw new EndOfStreamException("EOS reading GZIP header"); } crcval = (crcval << 8) | tempByte; if (crcval != ((int) headCRC.Value & 0xffff)) { throw new GZipException("Header CRC value mismatch"); } } readGZIPHeader = true; } void ReadFooter() { byte[] footer = new byte[8]; int avail = inf.RemainingInput; if (avail > 8) { avail = 8; } System.Array.Copy(inputBuffer.RawData, inputBuffer.RawLength - inf.RemainingInput, footer, 0, avail); int needed = 8 - avail; while (needed > 0) { int count = baseInputStream.Read(footer, 8 - needed, needed); if (count <= 0) { throw new EndOfStreamException("EOS reading GZIP footer"); } needed -= count; // Jewel Jan 16 } int crcval = (footer[0] & 0xff) | ((footer[1] & 0xff) << 8) | ((footer[2] & 0xff) << 16) | (footer[3] << 24); if (crcval != (int) crc.Value) { throw new GZipException("GZIP crc sum mismatch, theirs \"" + crcval + "\" and ours \"" + (int) crc.Value); } // NOTE The total here is the original total modulo 2 ^ 32. uint total = (uint)((uint)footer[4] & 0xff) | (uint)(((uint)footer[5] & 0xff) << 8) | (uint)(((uint)footer[6] & 0xff) << 16) | (uint)((uint)footer[7] << 24); if ((inf.TotalOut & 0xffffffff) != total) { throw new GZipException("Number of bytes mismatch in footer"); } // Should we support multiple gzip members. // Difficult, since there may be some bytes still in baseInputStream dataBuffer eos = true; } #endregion } } keepass2-2.25/KeePassLibSD/SharpZipLib/GZip/GzipOutputStream.cs0000664000175000017500000001573610666321562024244 0ustar jtaylorjtaylor// GZipOutputStream.cs // // Copyright (C) 2001 Mike Krueger // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using System.IO; using ICSharpCode.SharpZipLib.Checksums; using ICSharpCode.SharpZipLib.Zip.Compression; using ICSharpCode.SharpZipLib.Zip.Compression.Streams; namespace ICSharpCode.SharpZipLib.GZip { /// /// This filter stream is used to compress a stream into a "GZIP" stream. /// The "GZIP" format is described in RFC 1952. /// /// author of the original java version : John Leuner /// /// This sample shows how to gzip a file /// /// using System; /// using System.IO; /// /// using ICSharpCode.SharpZipLib.GZip; /// using ICSharpCode.SharpZipLib.Core; /// /// class MainClass /// { /// public static void Main(string[] args) /// { /// using (Stream s = new GZipOutputStream(File.Create(args[0] + ".gz"))) /// using (FileStream fs = File.OpenRead(args[0])) { /// byte[] writeData = new byte[4096]; /// Streamutils.Copy(s, fs, writeData); /// } /// } /// } /// } /// /// public class GZipOutputStream : DeflaterOutputStream { #region Instance Fields /// /// CRC-32 value for uncompressed data /// protected Crc32 crc = new Crc32(); bool headerWritten_; #endregion #region Constructors /// /// Creates a GzipOutputStream with the default buffer size /// /// /// The stream to read data (to be compressed) from /// public GZipOutputStream(Stream baseOutputStream) : this(baseOutputStream, 4096) { } /// /// Creates a GZipOutputStream with the specified buffer size /// /// /// The stream to read data (to be compressed) from /// /// /// Size of the buffer to use /// public GZipOutputStream(Stream baseOutputStream, int size) : base(baseOutputStream, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size) { } #endregion #region Public API /// /// Sets the active compression level (1-9). The new level will be activated /// immediately. /// /// The compression level to set. /// /// Level specified is not supported. /// /// public void SetLevel(int level) { if (level < Deflater.BEST_SPEED) { throw new ArgumentOutOfRangeException("level"); } deflater_.SetLevel(level); } /// /// Get the current compression level. /// /// The current compression level. public int GetLevel() { return deflater_.GetLevel(); } #endregion #region Stream overrides /// /// Write given buffer to output updating crc /// /// Buffer to write /// Offset of first byte in buf to write /// Number of bytes to write public override void Write(byte[] buffer, int offset, int count) { if ( ! headerWritten_ ) { WriteHeader(); } crc.Update(buffer, offset, count); base.Write(buffer, offset, count); } /// /// Writes remaining compressed output data to the output stream /// and closes it. /// public override void Close() { try { Finish(); } finally { if( IsStreamOwner ) { baseOutputStream_.Close(); } } } #endregion #region DeflaterOutputStream overrides /// /// Finish compression and write any footer information required to stream /// public override void Finish() { // If no data has been written a header should be added. if ( !headerWritten_ ) { WriteHeader(); } base.Finish(); int totalin = deflater_.TotalIn; int crcval = (int) (crc.Value & 0xffffffff); byte[] gzipFooter = { (byte) crcval, (byte) (crcval >> 8), (byte) (crcval >> 16), (byte) (crcval >> 24), (byte) totalin, (byte) (totalin >> 8), (byte) (totalin >> 16), (byte) (totalin >> 24) }; baseOutputStream_.Write(gzipFooter, 0, gzipFooter.Length); } #endregion #region Support Routines void WriteHeader() { if ( !headerWritten_ ) { headerWritten_ = true; int mod_time = (int)((DateTime.Now.Ticks - new DateTime(1970, 1, 1).Ticks) / 10000000L); // Ticks give back 100ns intervals byte[] gzipHeader = { // The two magic bytes (byte) (GZipConstants.GZIP_MAGIC >> 8), (byte) (GZipConstants.GZIP_MAGIC & 0xff), // The compression type (byte) Deflater.DEFLATED, // The flags (not set) 0, // The modification time (byte) mod_time, (byte) (mod_time >> 8), (byte) (mod_time >> 16), (byte) (mod_time >> 24), // The extra flags 0, // The OS type (unknown) (byte) 255 }; baseOutputStream_.Write(gzipHeader, 0, gzipHeader.Length); } } #endregion } } keepass2-2.25/KeePassLibSD/SharpZipLib/GZip/GZIPConstants.cs0000664000175000017500000000617210572513656023401 0ustar jtaylorjtaylor// GZipConstants.cs // // Copyright (C) 2001 Mike Krueger // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. namespace ICSharpCode.SharpZipLib.GZip { /// /// This class contains constants used for gzip. /// sealed public class GZipConstants { /// /// Magic number found at start of GZIP header /// public const int GZIP_MAGIC = 0x1F8B; /* The flag byte is divided into individual bits as follows: bit 0 FTEXT bit 1 FHCRC bit 2 FEXTRA bit 3 FNAME bit 4 FCOMMENT bit 5 reserved bit 6 reserved bit 7 reserved */ /// /// Flag bit mask for text /// public const int FTEXT = 0x1; /// /// Flag bitmask for Crc /// public const int FHCRC = 0x2; /// /// Flag bit mask for extra /// public const int FEXTRA = 0x4; /// /// flag bitmask for name /// public const int FNAME = 0x8; /// /// flag bit mask indicating comment is present /// public const int FCOMMENT = 0x10; /// /// Initialise default instance. /// /// Constructor is private to prevent instances being created. GZipConstants() { } } } keepass2-2.25/KeePassLibSD/SharpZipLib/GZip/GZipException.cs0000664000175000017500000000644510671211416023453 0ustar jtaylorjtaylor// GZipException.cs // // Copyright 2004 John Reilly // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; #if !NETCF_1_0 && !NETCF_2_0 using System.Runtime.Serialization; #endif using ICSharpCode.SharpZipLib; namespace ICSharpCode.SharpZipLib.GZip { /// /// GZipException represents a Gzip specific exception /// #if !NETCF_1_0 && !NETCF_2_0 [Serializable] #endif public class GZipException : SharpZipBaseException { #if !NETCF_1_0 && !NETCF_2_0 /// /// Deserialization constructor /// /// for this constructor /// for this constructor protected GZipException(SerializationInfo info, StreamingContext context) : base(info, context) { } #endif /// /// Initialise a new instance of GZipException /// public GZipException() { } /// /// Initialise a new instance of GZipException with its message string. /// /// A that describes the error. public GZipException(string message) : base(message) { } /// /// Initialise a new instance of . /// /// A that describes the error. /// The that caused this exception. public GZipException(string message, Exception innerException) : base (message, innerException) { } } } keepass2-2.25/KeePassLibSD/SharpZipLib/Encryption/0000775000175000017500000000000011643263772021660 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/SharpZipLib/Encryption/PkzipClassic.cs0000664000175000017500000003471210670213350024577 0ustar jtaylorjtaylor// // PkzipClassic encryption // // Copyright 2004 John Reilly // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. // #if !NETCF_1_0 using System; using System.Security.Cryptography; using ICSharpCode.SharpZipLib.Checksums; namespace ICSharpCode.SharpZipLib.Encryption { /// /// PkzipClassic embodies the classic or original encryption facilities used in Pkzip archives. /// While it has been superceded by more recent and more powerful algorithms, its still in use and /// is viable for preventing casual snooping /// public abstract class PkzipClassic : SymmetricAlgorithm { /// /// Generates new encryption keys based on given seed /// /// The seed value to initialise keys with. /// A new key value. static public byte[] GenerateKeys(byte[] seed) { if ( seed == null ) { throw new ArgumentNullException("seed"); } if ( seed.Length == 0 ) { throw new ArgumentException("Length is zero", "seed"); } uint[] newKeys = new uint[] { 0x12345678, 0x23456789, 0x34567890 }; for (int i = 0; i < seed.Length; ++i) { newKeys[0] = Crc32.ComputeCrc32(newKeys[0], seed[i]); newKeys[1] = newKeys[1] + (byte)newKeys[0]; newKeys[1] = newKeys[1] * 134775813 + 1; newKeys[2] = Crc32.ComputeCrc32(newKeys[2], (byte)(newKeys[1] >> 24)); } byte[] result = new byte[12]; result[0] = (byte)(newKeys[0] & 0xff); result[1] = (byte)((newKeys[0] >> 8) & 0xff); result[2] = (byte)((newKeys[0] >> 16) & 0xff); result[3] = (byte)((newKeys[0] >> 24) & 0xff); result[4] = (byte)(newKeys[1] & 0xff); result[5] = (byte)((newKeys[1] >> 8) & 0xff); result[6] = (byte)((newKeys[1] >> 16) & 0xff); result[7] = (byte)((newKeys[1] >> 24) & 0xff); result[8] = (byte)(newKeys[2] & 0xff); result[9] = (byte)((newKeys[2] >> 8) & 0xff); result[10] = (byte)((newKeys[2] >> 16) & 0xff); result[11] = (byte)((newKeys[2] >> 24) & 0xff); return result; } } /// /// PkzipClassicCryptoBase provides the low level facilities for encryption /// and decryption using the PkzipClassic algorithm. /// class PkzipClassicCryptoBase { /// /// Transform a single byte /// /// /// The transformed value /// protected byte TransformByte() { uint temp = ((keys[2] & 0xFFFF) | 2); return (byte)((temp * (temp ^ 1)) >> 8); } /// /// Set the key schedule for encryption/decryption. /// /// The data use to set the keys from. protected void SetKeys(byte[] keyData) { if ( keyData == null ) { throw new ArgumentNullException("keyData"); } if ( keyData.Length != 12 ) { throw new InvalidOperationException("Key length is not valid"); } keys = new uint[3]; keys[0] = (uint)((keyData[3] << 24) | (keyData[2] << 16) | (keyData[1] << 8) | keyData[0]); keys[1] = (uint)((keyData[7] << 24) | (keyData[6] << 16) | (keyData[5] << 8) | keyData[4]); keys[2] = (uint)((keyData[11] << 24) | (keyData[10] << 16) | (keyData[9] << 8) | keyData[8]); } /// /// Update encryption keys /// protected void UpdateKeys(byte ch) { keys[0] = Crc32.ComputeCrc32(keys[0], ch); keys[1] = keys[1] + (byte)keys[0]; keys[1] = keys[1] * 134775813 + 1; keys[2] = Crc32.ComputeCrc32(keys[2], (byte)(keys[1] >> 24)); } /// /// Reset the internal state. /// protected void Reset() { keys[0] = 0; keys[1] = 0; keys[2] = 0; } #region Instance Fields uint[] keys; #endregion } /// /// PkzipClassic CryptoTransform for encryption. /// class PkzipClassicEncryptCryptoTransform : PkzipClassicCryptoBase, ICryptoTransform { /// /// Initialise a new instance of /// /// The key block to use. internal PkzipClassicEncryptCryptoTransform(byte[] keyBlock) { SetKeys(keyBlock); } #region ICryptoTransform Members /// /// Transforms the specified region of the specified byte array. /// /// The input for which to compute the transform. /// The offset into the byte array from which to begin using data. /// The number of bytes in the byte array to use as data. /// The computed transform. public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount) { byte[] result = new byte[inputCount]; TransformBlock(inputBuffer, inputOffset, inputCount, result, 0); return result; } /// /// Transforms the specified region of the input byte array and copies /// the resulting transform to the specified region of the output byte array. /// /// The input for which to compute the transform. /// The offset into the input byte array from which to begin using data. /// The number of bytes in the input byte array to use as data. /// The output to which to write the transform. /// The offset into the output byte array from which to begin writing data. /// The number of bytes written. public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset) { for (int i = inputOffset; i < inputOffset + inputCount; ++i) { byte oldbyte = inputBuffer[i]; outputBuffer[outputOffset++] = (byte)(inputBuffer[i] ^ TransformByte()); UpdateKeys(oldbyte); } return inputCount; } /// /// Gets a value indicating whether the current transform can be reused. /// public bool CanReuseTransform { get { return true; } } /// /// Gets the size of the input data blocks in bytes. /// public int InputBlockSize { get { return 1; } } /// /// Gets the size of the output data blocks in bytes. /// public int OutputBlockSize { get { return 1; } } /// /// Gets a value indicating whether multiple blocks can be transformed. /// public bool CanTransformMultipleBlocks { get { return true; } } #endregion #region IDisposable Members /// /// Cleanup internal state. /// public void Dispose() { Reset(); } #endregion } /// /// PkzipClassic CryptoTransform for decryption. /// class PkzipClassicDecryptCryptoTransform : PkzipClassicCryptoBase, ICryptoTransform { /// /// Initialise a new instance of . /// /// The key block to decrypt with. internal PkzipClassicDecryptCryptoTransform(byte[] keyBlock) { SetKeys(keyBlock); } #region ICryptoTransform Members /// /// Transforms the specified region of the specified byte array. /// /// The input for which to compute the transform. /// The offset into the byte array from which to begin using data. /// The number of bytes in the byte array to use as data. /// The computed transform. public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount) { byte[] result = new byte[inputCount]; TransformBlock(inputBuffer, inputOffset, inputCount, result, 0); return result; } /// /// Transforms the specified region of the input byte array and copies /// the resulting transform to the specified region of the output byte array. /// /// The input for which to compute the transform. /// The offset into the input byte array from which to begin using data. /// The number of bytes in the input byte array to use as data. /// The output to which to write the transform. /// The offset into the output byte array from which to begin writing data. /// The number of bytes written. public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset) { for (int i = inputOffset; i < inputOffset + inputCount; ++i) { byte newByte = (byte)(inputBuffer[i] ^ TransformByte()); outputBuffer[outputOffset++] = newByte; UpdateKeys(newByte); } return inputCount; } /// /// Gets a value indicating whether the current transform can be reused. /// public bool CanReuseTransform { get { return true; } } /// /// Gets the size of the input data blocks in bytes. /// public int InputBlockSize { get { return 1; } } /// /// Gets the size of the output data blocks in bytes. /// public int OutputBlockSize { get { return 1; } } /// /// Gets a value indicating whether multiple blocks can be transformed. /// public bool CanTransformMultipleBlocks { get { return true; } } #endregion #region IDisposable Members /// /// Cleanup internal state. /// public void Dispose() { Reset(); } #endregion } /// /// Defines a wrapper object to access the Pkzip algorithm. /// This class cannot be inherited. /// public sealed class PkzipClassicManaged : PkzipClassic { /// /// Get / set the applicable block size in bits. /// /// The only valid block size is 8. public override int BlockSize { get { return 8; } set { if (value != 8) { throw new CryptographicException("Block size is invalid"); } } } /// /// Get an array of legal key sizes. /// public override KeySizes[] LegalKeySizes { get { KeySizes[] keySizes = new KeySizes[1]; keySizes[0] = new KeySizes(12 * 8, 12 * 8, 0); return keySizes; } } /// /// Generate an initial vector. /// public override void GenerateIV() { // Do nothing. } /// /// Get an array of legal block sizes. /// public override KeySizes[] LegalBlockSizes { get { KeySizes[] keySizes = new KeySizes[1]; keySizes[0] = new KeySizes(1 * 8, 1 * 8, 0); return keySizes; } } /// /// Get / set the key value applicable. /// public override byte[] Key { get { if ( key_ == null ) { GenerateKey(); } return (byte[]) key_.Clone(); } set { if ( value == null ) { throw new ArgumentNullException("value"); } if ( value.Length != 12 ) { throw new CryptographicException("Key size is illegal"); } key_ = (byte[]) value.Clone(); } } /// /// Generate a new random key. /// public override void GenerateKey() { key_ = new byte[12]; Random rnd = new Random(); rnd.NextBytes(key_); } /// /// Create an encryptor. /// /// The key to use for this encryptor. /// Initialisation vector for the new encryptor. /// Returns a new PkzipClassic encryptor public override ICryptoTransform CreateEncryptor( byte[] rgbKey, byte[] rgbIV) { key_ = rgbKey; return new PkzipClassicEncryptCryptoTransform(Key); } /// /// Create a decryptor. /// /// Keys to use for this new decryptor. /// Initialisation vector for the new decryptor. /// Returns a new decryptor. public override ICryptoTransform CreateDecryptor( byte[] rgbKey, byte[] rgbIV) { key_ = rgbKey; return new PkzipClassicDecryptCryptoTransform(Key); } #region Instance Fields byte[] key_; #endregion } } #endif keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/0000775000175000017500000000000011643263772020270 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/SharpZipLib/Zip/ZipFile.cs0000664000175000017500000034555610670304112022162 0ustar jtaylorjtaylor// ZipFile.cs // // Copyright (C) 2001 Mike Krueger // Copyright (C) 2004 John Reilly // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using System.Collections; using System.IO; using System.Text; using System.Globalization; #if !NETCF_1_0 using System.Security.Cryptography; using ICSharpCode.SharpZipLib.Encryption; #endif using ICSharpCode.SharpZipLib.Core; using ICSharpCode.SharpZipLib.Checksums; using ICSharpCode.SharpZipLib.Zip.Compression.Streams; using ICSharpCode.SharpZipLib.Zip.Compression; namespace ICSharpCode.SharpZipLib.Zip { #region Keys Required Event Args /// /// Arguments used with KeysRequiredEvent /// public class KeysRequiredEventArgs : EventArgs { #region Constructors /// /// Initialise a new instance of /// /// The name of the file for which keys are required. public KeysRequiredEventArgs(string name) { fileName = name; } /// /// Initialise a new instance of /// /// The name of the file for which keys are required. /// The current key value. public KeysRequiredEventArgs(string name, byte[] keyValue) { fileName = name; key = keyValue; } #endregion #region Properties /// /// Get the name of the file for which keys are required. /// public string FileName { get { return fileName; } } /// /// Get/set the key value /// public byte[] Key { get { return key; } set { key = value; } } #endregion #region Instance Fields string fileName; byte[] key; #endregion } #endregion #region Test Definitions /// /// The strategy to apply to testing. /// public enum TestStrategy { /// /// Find the first error only. /// FindFirstError, /// /// Find all possible errors. /// FindAllErrors, } /// /// The operation in progress reported by a during testing. /// /// TestArchive public enum TestOperation { /// /// Setting up testing. /// Initialising, /// /// Testing an individual entries header /// EntryHeader, /// /// Testing an individual entries data /// EntryData, /// /// Testing an individual entry has completed. /// EntryComplete, /// /// Running miscellaneous tests /// MiscellaneousTests, /// /// Testing is complete /// Complete, } /// /// Status returned returned by during testing. /// /// TestArchive public class TestStatus { #region Constructors /// /// Initialise a new instance of /// /// The this status applies to. public TestStatus(ZipFile file) { file_ = file; } #endregion #region Properties /// /// Get the current in progress. /// public TestOperation Operation { get { return operation_; } } /// /// Get the this status is applicable to. /// public ZipFile File { get { return file_; } } /// /// Get the current/last entry tested. /// public ZipEntry Entry { get { return entry_; } } /// /// Get the number of errors detected so far. /// public int ErrorCount { get { return errorCount_; } } /// /// Get the number of bytes tested so far for the current entry. /// public long BytesTested { get { return bytesTested_; } } /// /// Get a value indicating wether the last entry test was valid. /// public bool EntryValid { get { return entryValid_; } } #endregion #region Internal API internal void AddError() { errorCount_++; entryValid_ = false; } internal void SetOperation(TestOperation operation) { operation_ = operation; } internal void SetEntry(ZipEntry entry) { entry_ = entry; entryValid_ = true; bytesTested_ = 0; } internal void SetBytesTested(long value) { bytesTested_ = value; } #endregion #region Instance Fields ZipFile file_; ZipEntry entry_; bool entryValid_; int errorCount_; long bytesTested_; TestOperation operation_; #endregion } /// /// Delegate invoked during testing if supplied indicating current progress and status. /// /// If the message is non-null an error has occured. If the message is null /// the operation as found in status has started. public delegate void ZipTestResultHandler(TestStatus status, string message); #endregion #region Update Definitions /// /// The possible ways of applying updates to an archive. /// public enum FileUpdateMode { /// /// Perform all updates on temporary files ensuring that the original file is saved. /// Safe, /// /// Update the archive directly, which is faster but less safe. /// Direct, } #endregion #region ZipFile Class /// /// This class represents a Zip archive. You can ask for the contained /// entries, or get an input stream for a file entry. The entry is /// automatically decompressed. /// /// You can also update the archive adding or deleting entries. /// /// This class is thread safe for input: You can open input streams for arbitrary /// entries in different threads. ///
///
Author of the original java version : Jochen Hoenicke ///
/// /// /// using System; /// using System.Text; /// using System.Collections; /// using System.IO; /// /// using ICSharpCode.SharpZipLib.Zip; /// /// class MainClass /// { /// static public void Main(string[] args) /// { /// using (ZipFile zFile = new ZipFile(args[0])) { /// Console.WriteLine("Listing of : " + zFile.Name); /// Console.WriteLine(""); /// Console.WriteLine("Raw Size Size Date Time Name"); /// Console.WriteLine("-------- -------- -------- ------ ---------"); /// foreach (ZipEntry e in zFile) { /// if ( e.IsFile ) { /// DateTime d = e.DateTime; /// Console.WriteLine("{0, -10}{1, -10}{2} {3} {4}", e.Size, e.CompressedSize, /// d.ToString("dd-MM-yy"), d.ToString("HH:mm"), /// e.Name); /// } /// } /// } /// } /// } /// /// public class ZipFile : IEnumerable, IDisposable { #region KeyHandling /// /// Delegate for handling keys/password setting during compresion/decompression. /// public delegate void KeysRequiredEventHandler( object sender, KeysRequiredEventArgs e ); /// /// Event handler for handling encryption keys. /// public KeysRequiredEventHandler KeysRequired; /// /// Handles getting of encryption keys when required. /// /// The file for which encryption keys are required. void OnKeysRequired(string fileName) { if (KeysRequired != null) { KeysRequiredEventArgs krea = new KeysRequiredEventArgs(fileName, key); KeysRequired(this, krea); key = krea.Key; } } /// /// Get/set the encryption key value. /// byte[] Key { get { return key; } set { key = value; } } #if !NETCF_1_0 /// /// Password to be used for encrypting/decrypting files. /// /// Set to null if no password is required. public string Password { set { if ( (value == null) || (value.Length == 0) ) { key = null; } else { key = PkzipClassic.GenerateKeys(ZipConstants.ConvertToArray(value)); } } } #endif /// /// Get a value indicating wether encryption keys are currently available. /// bool HaveKeys { get { return key != null; } } #endregion #region Constructors /// /// Opens a Zip file with the given name for reading. /// /// The name of the file to open. /// /// An i/o error occurs /// /// /// The file doesn't contain a valid zip archive. /// public ZipFile(string name) { name_ = name; baseStream_ = File.OpenRead(name); isStreamOwner = true; try { ReadEntries(); } catch { DisposeInternal(true); throw; } } /// /// Opens a Zip file reading the given . /// /// The to read archive data from. /// /// An i/o error occurs. /// /// /// The file doesn't contain a valid zip archive. /// public ZipFile(FileStream file) { if ( file == null ) { throw new ArgumentNullException("file"); } if ( !file.CanSeek ) { throw new ArgumentException("Stream is not seekable", "file"); } baseStream_ = file; name_ = file.Name; isStreamOwner = true; try { ReadEntries(); } catch { DisposeInternal(true); throw; } } /// /// Opens a Zip file reading the given . /// /// The to read archive data from. /// /// An i/o error occurs /// /// /// The file doesn't contain a valid zip archive.
/// The stream provided cannot seek ///
public ZipFile(Stream stream) { if ( stream == null ) { throw new ArgumentNullException("stream"); } if ( !stream.CanSeek ) { throw new ArgumentException("Stream is not seekable", "stream"); } baseStream_ = stream; isStreamOwner = true; if ( baseStream_.Length > 0 ) { try { ReadEntries(); } catch { DisposeInternal(true); throw; } } else { entries_ = new ZipEntry[0]; isNewArchive_ = true; } } /// /// Initialises a default instance with no entries and no file storage. /// internal ZipFile() { entries_ = new ZipEntry[0]; isNewArchive_ = true; } #endregion #region Destructors and Closing /// /// Finalize this instance. /// ~ZipFile() { Dispose(false); } /// /// Closes the ZipFile. If the stream is owned then this also closes the underlying input stream. /// Once closed, no further instance methods should be called. /// /// /// An i/o error occurs. /// public void Close() { DisposeInternal(true); GC.SuppressFinalize(this); } #endregion #region Creators /// /// Create a new whose data will be stored in a file. /// /// The name of the archive to create. /// Returns the newly created public static ZipFile Create(string fileName) { if ( fileName == null ) { throw new ArgumentNullException("fileName"); } FileStream fs = File.Create(fileName); ZipFile result = new ZipFile(); result.name_ = fileName; result.baseStream_ = fs; result.isStreamOwner = true; return result; } /// /// Create a new whose data will be stored on a stream. /// /// The stream providing data storage. /// Returns the newly created public static ZipFile Create(Stream outStream) { if ( outStream == null ) { throw new ArgumentNullException("outStream"); } if ( !outStream.CanWrite ) { throw new ArgumentException("Stream is not writeable", "outStream"); } if ( !outStream.CanSeek ) { throw new ArgumentException("Stream is not seekable", "outStream"); } ZipFile result = new ZipFile(); result.baseStream_ = outStream; return result; } #endregion #region Properties /// /// Get/set a flag indicating if the underlying stream is owned by the ZipFile instance. /// If the flag is true then the stream will be closed when Close is called. /// /// /// The default value is true in all cases. /// public bool IsStreamOwner { get { return isStreamOwner; } set { isStreamOwner = value; } } /// /// Get a value indicating wether /// this archive is embedded in another file or not. /// public bool IsEmbeddedArchive { // Not strictly correct in all circumstances currently get { return offsetOfFirstEntry > 0; } } /// /// Get a value indicating that this archive is a new one. /// public bool IsNewArchive { get { return isNewArchive_; } } /// /// Gets the comment for the zip file. /// public string ZipFileComment { get { return comment_; } } /// /// Gets the name of this zip file. /// public string Name { get { return name_; } } /// /// Gets the number of entries in this zip file. /// /// /// The Zip file has been closed. /// [Obsolete("Use the Count property instead")] public int Size { get { if (entries_ != null) { return entries_.Length; } else { throw new InvalidOperationException("ZipFile is closed"); } } } /// /// Get the number of entries contained in this . /// public long Count { get { if (entries_ != null) { return entries_.Length; } else { throw new InvalidOperationException("ZipFile is closed"); } } } /// /// Indexer property for ZipEntries /// [System.Runtime.CompilerServices.IndexerNameAttribute("EntryByIndex")] public ZipEntry this[int index] { get { return (ZipEntry) entries_[index].Clone(); } } #endregion #region Input Handling /// /// Gets an enumerator for the Zip entries in this Zip file. /// /// Returns an for this archive. /// /// The Zip file has been closed. /// public IEnumerator GetEnumerator() { if (entries_ == null) { throw new InvalidOperationException("ZipFile has closed"); } return new ZipEntryEnumerator(entries_); } /// /// Return the index of the entry with a matching name /// /// Entry name to find /// If true the comparison is case insensitive /// The index position of the matching entry or -1 if not found /// /// The Zip file has been closed. /// public int FindEntry(string name, bool ignoreCase) { if (entries_ == null) { throw new InvalidOperationException("ZipFile has been closed"); } // TODO: This will be slow as the next ice age for huge archives! for (int i = 0; i < entries_.Length; i++) { if (string.Compare(name, entries_[i].Name, ignoreCase, CultureInfo.InvariantCulture) == 0) { return i; } } return -1; } /// /// Searches for a zip entry in this archive with the given name. /// String comparisons are case insensitive /// /// /// The name to find. May contain directory components separated by slashes ('/'). /// /// /// A clone of the zip entry, or null if no entry with that name exists. /// /// /// The Zip file has been closed. /// public ZipEntry GetEntry(string name) { if (entries_ == null) { throw new InvalidOperationException("ZipFile has been closed"); } int index = FindEntry(name, true); return (index >= 0) ? (ZipEntry) entries_[index].Clone() : null; } /// /// Gets an input stream for reading the given zip entry data in an uncompressed form. /// Normally the should be an entry returned by GetEntry(). /// /// The to obtain a data for /// An input containing data for this /// /// The ZipFile has already been closed /// /// /// The compression method for the entry is unknown /// /// /// The entry is not found in the ZipFile /// public Stream GetInputStream(ZipEntry entry) { if ( entry == null ) { throw new ArgumentNullException("entry"); } if ( entries_ == null ) { throw new InvalidOperationException("ZipFile has closed"); } long index = entry.ZipFileIndex; if ( (index < 0) || (index >= entries_.Length) || (entries_[index].Name != entry.Name) ) { index = FindEntry(entry.Name, true); if (index < 0) { throw new ZipException("Entry cannot be found"); } } return GetInputStream(index); } /// /// Creates an input stream reading a zip entry /// /// The index of the entry to obtain an input stream for. /// /// An input containing data for this /// /// /// The ZipFile has already been closed /// /// /// The compression method for the entry is unknown /// /// /// The entry is not found in the ZipFile /// public Stream GetInputStream(long entryIndex) { if ( entries_ == null ) { throw new InvalidOperationException("ZipFile is not open"); } long start = LocateEntry(entries_[entryIndex]); CompressionMethod method = entries_[entryIndex].CompressionMethod; Stream result = new PartialInputStream(baseStream_, start, entries_[entryIndex].CompressedSize); if (entries_[entryIndex].IsCrypted == true) { #if NETCF_1_0 throw new ZipException("decryption not supported for Compact Framework 1.0"); #else result = CreateAndInitDecryptionStream(result, entries_[entryIndex]); if (result == null) { throw new ZipException("Unable to decrypt this entry"); } #endif } switch (method) { case CompressionMethod.Stored: // read as is. break; case CompressionMethod.Deflated: // No need to worry about ownership and closing as underlying stream close does nothing. result = new InflaterInputStream(result, new Inflater(true)); break; default: throw new ZipException("Unsupported compression method " + method); } return result; } #endregion #region Archive Testing /// /// Test an archive for integrity/validity /// /// Perform low level data Crc check /// true if all tests pass, false otherwise /// Testing will terminate on the first error found. public bool TestArchive(bool testData) { return TestArchive(testData, TestStrategy.FindFirstError, null); } /// /// Test an archive for integrity/validity /// /// Perform low level data Crc check /// The to apply. /// The handler to call during testing. /// true if all tests pass, false otherwise public bool TestArchive(bool testData, TestStrategy strategy, ZipTestResultHandler resultHandler) { TestStatus status = new TestStatus(this); if ( resultHandler != null ) { resultHandler(status, null); } HeaderTest test = testData ? (HeaderTest.Header | HeaderTest.Extract) : HeaderTest.Header; bool testing = true; try { int entryIndex = 0; while ( testing && (entryIndex < Count) ) { if ( resultHandler != null ) { status.SetEntry(this[entryIndex]); status.SetOperation(TestOperation.EntryHeader); resultHandler(status, null); } try { TestLocalHeader(this[entryIndex], test); } catch(ZipException ex) { status.AddError(); if ( resultHandler != null ) { resultHandler(status, string.Format("Exception during test - '{0}'", ex.Message)); } if ( strategy == TestStrategy.FindFirstError ) { testing = false; } } if ( testing && testData && this[entryIndex].IsFile ) { if ( resultHandler != null ) { status.SetOperation(TestOperation.EntryData); resultHandler(status, null); } Stream entryStream = this.GetInputStream(this[entryIndex]); Crc32 crc = new Crc32(); byte[] buffer = new byte[4096]; long totalBytes = 0; int bytesRead; while ((bytesRead = entryStream.Read(buffer, 0, buffer.Length)) > 0) { crc.Update(buffer, 0, bytesRead); if ( resultHandler != null ) { totalBytes += bytesRead; status.SetBytesTested(totalBytes); resultHandler(status, null); } } if (this[entryIndex].Crc != crc.Value) { status.AddError(); if ( resultHandler != null ) { resultHandler(status, "CRC mismatch"); } if ( strategy == TestStrategy.FindFirstError ) { testing = false; } } if (( this[entryIndex].Flags & (int)GeneralBitFlags.Descriptor) != 0 ) { ZipHelperStream helper = new ZipHelperStream(baseStream_); DescriptorData data = new DescriptorData(); helper.ReadDataDescriptor(this[entryIndex].LocalHeaderRequiresZip64, data); if (this[entryIndex].Crc != data.Crc) { status.AddError(); } if (this[entryIndex].CompressedSize != data.CompressedSize) { status.AddError(); } if (this[entryIndex].Size != data.Size) { status.AddError(); } } } if ( resultHandler != null ) { status.SetOperation(TestOperation.EntryComplete); resultHandler(status, null); } entryIndex += 1; } if ( resultHandler != null ) { status.SetOperation(TestOperation.MiscellaneousTests); resultHandler(status, null); } // TODO: the 'Corrina Johns' test where local headers are missing from // the central directory. They are therefore invisible to many archivers. } catch (Exception ex) { status.AddError(); if ( resultHandler != null ) { resultHandler(status, string.Format("Exception during test - '{0}'", ex.Message)); } } if ( resultHandler != null ) { status.SetOperation(TestOperation.Complete); status.SetEntry(null); resultHandler(status, null); } return (status.ErrorCount == 0); } [Flags] enum HeaderTest { Extract = 0x01, // Check that this header represents an entry whose data can be extracted Header = 0x02, // Check that this header contents are valid } /// /// Test a local header against that provided from the central directory /// /// /// The entry to test against /// /// The type of tests to carry out. /// The offset of the entries data in the file long TestLocalHeader(ZipEntry entry, HeaderTest tests) { lock(baseStream_) { bool testHeader = (tests & HeaderTest.Header) != 0; bool testData = (tests & HeaderTest.Extract) != 0; baseStream_.Seek(offsetOfFirstEntry + entry.Offset, SeekOrigin.Begin); if ((int)ReadLEUint() != ZipConstants.LocalHeaderSignature) { throw new ZipException(string.Format("Wrong local header signature @{0:X}", offsetOfFirstEntry + entry.Offset)); } short extractVersion = ( short )ReadLEUshort(); short localFlags = ( short )ReadLEUshort(); short compressionMethod = ( short )ReadLEUshort(); short fileTime = ( short )ReadLEUshort(); short fileDate = ( short )ReadLEUshort(); uint crcValue = ReadLEUint(); long compressedSize = ReadLEUint(); long size = ReadLEUint(); int storedNameLength = ReadLEUshort(); int extraDataLength = ReadLEUshort(); byte[] nameData = new byte[storedNameLength]; StreamUtils.ReadFully(baseStream_, nameData); byte[] extraData = new byte[extraDataLength]; StreamUtils.ReadFully(baseStream_, extraData); ZipExtraData ed = new ZipExtraData(extraData); // Extra data / zip64 checks if (ed.Find(1)) { // TODO Check for tag values being distinct.. Multiple zip64 tags means what? // Zip64 extra data but 'extract version' is too low if (extractVersion < ZipConstants.VersionZip64) { throw new ZipException( string.Format("Extra data contains Zip64 information but version {0}.{1} is not high enough", extractVersion / 10, extractVersion % 10)); } // Zip64 extra data but size fields dont indicate its required. if (((uint)size != uint.MaxValue) && ((uint)compressedSize != uint.MaxValue)) { throw new ZipException("Entry sizes not correct for Zip64"); } size = ed.ReadLong(); compressedSize = ed.ReadLong(); } else { // No zip64 extra data but entry requires it. if ((extractVersion >= ZipConstants.VersionZip64) && (((uint)size == uint.MaxValue) || ((uint)compressedSize == uint.MaxValue))) { throw new ZipException("Required Zip64 extended information missing"); } } if ( testData ) { if ( entry.IsFile ) { if ( !entry.IsCompressionMethodSupported() ) { throw new ZipException("Compression method not supported"); } if ( (extractVersion > ZipConstants.VersionMadeBy) || ((extractVersion > 20) && (extractVersion < ZipConstants.VersionZip64)) ) { throw new ZipException(string.Format("Version required to extract this entry not supported ({0})", extractVersion)); } if ( (localFlags & ( int )(GeneralBitFlags.Patched | GeneralBitFlags.StrongEncryption | GeneralBitFlags.EnhancedCompress | GeneralBitFlags.HeaderMasked)) != 0 ) { throw new ZipException("The library does not support the zip version required to extract this entry"); } } } if ( testHeader ) { if ((extractVersion <= 63) && // Ignore later versions as we dont know about them.. (extractVersion != 10) && (extractVersion != 11) && (extractVersion != 20) && (extractVersion != 21) && (extractVersion != 25) && (extractVersion != 27) && (extractVersion != 45) && (extractVersion != 46) && (extractVersion != 50) && (extractVersion != 51) && (extractVersion != 52) && (extractVersion != 61) && (extractVersion != 62) && (extractVersion != 63) ) { throw new ZipException(string.Format("Version required to extract this entry is invalid ({0})", extractVersion)); } // Local entry flags dont have reserved bit set on. if ( (localFlags & ( int )(GeneralBitFlags.ReservedPKware4 | GeneralBitFlags.ReservedPkware14 | GeneralBitFlags.ReservedPkware15)) != 0 ) { throw new ZipException("Reserved bit flags cannot be set."); } // Encryption requires extract version >= 20 if ( ((localFlags & ( int )GeneralBitFlags.Encrypted) != 0) && (extractVersion < 20) ) { throw new ZipException(string.Format("Version required to extract this entry is too low for encryption ({0})", extractVersion)); } // Strong encryption requires encryption flag to be set and extract version >= 50. if ( (localFlags & (int)GeneralBitFlags.StrongEncryption) != 0 ) { if ( (localFlags & (int)GeneralBitFlags.Encrypted) == 0 ) { throw new ZipException("Strong encryption flag set but encryption flag is not set"); } if ( extractVersion < 50 ) { throw new ZipException(string.Format("Version required to extract this entry is too low for encryption ({0})", extractVersion)); } } // Patched entries require extract version >= 27 if ( ((localFlags & ( int )GeneralBitFlags.Patched) != 0) && (extractVersion < 27) ) { throw new ZipException(string.Format("Patched data requires higher version than ({0})", extractVersion)); } // Central header flags match local entry flags. if ( localFlags != entry.Flags ) { throw new ZipException("Central header/local header flags mismatch"); } // Central header compression method matches local entry if ( entry.CompressionMethod != ( CompressionMethod )compressionMethod ) { throw new ZipException("Central header/local header compression method mismatch"); } // Strong encryption and extract version match if ( (localFlags & ( int )GeneralBitFlags.StrongEncryption) != 0 ) { if ( extractVersion < 62 ) { throw new ZipException("Strong encryption flag set but version not high enough"); } } if ( (localFlags & ( int )GeneralBitFlags.HeaderMasked) != 0 ) { if ( (fileTime != 0) || (fileDate != 0) ) { throw new ZipException("Header masked set but date/time values non-zero"); } } if ( (localFlags & ( int )GeneralBitFlags.Descriptor) == 0 ) { if ( crcValue != (uint)entry.Crc ) { throw new ZipException("Central header/local header crc mismatch"); } } // Crc valid for empty entry. // This will also apply to streamed entries where size isnt known and the header cant be patched if ( (size == 0) && (compressedSize == 0) ) { if ( crcValue != 0 ) { throw new ZipException("Invalid CRC for empty entry"); } } // TODO: make test more correct... can't compare lengths as was done originally as this can fail for MBCS strings // Assuming a code page at this point is not valid? Best is to store the name length in the ZipEntry probably if ( entry.Name.Length > storedNameLength ) { throw new ZipException("File name length mismatch"); } // Name data has already been read convert it and compare. string localName = ZipConstants.ConvertToStringExt(localFlags, nameData); // Central directory and local entry name match if ( localName != entry.Name ) { throw new ZipException("Central header and local header file name mismatch"); } // Directories have zero size. if ( entry.IsDirectory ) { if ( (compressedSize != 0) || (size != 0) ) { throw new ZipException("Directory cannot have size"); } } if ( !ZipNameTransform.IsValidName(localName, true) ) { throw new ZipException("Name is invalid"); } } // Tests that apply to both data and header. // Size can be verified only if it is known in the local header. // it will always be known in the central header. if ((localFlags & (int)GeneralBitFlags.Descriptor) == 0 || (size != 0 || compressedSize != 0)) { if (size != entry.Size) { throw new ZipException( string.Format("Size mismatch between central header({0}) and local header({1})", entry.Size, size)); } if (compressedSize != entry.CompressedSize) { throw new ZipException( string.Format("Compressed size mismatch between central header({0}) and local header({1})", entry.CompressedSize, compressedSize)); } } int extraLength = storedNameLength + extraDataLength; return offsetOfFirstEntry + entry.Offset + ZipConstants.LocalHeaderBaseSize + extraLength; } } #endregion #region Updating const int DefaultBufferSize = 4096; /// /// The kind of update to apply. /// enum UpdateCommand { Copy, // Copy original file contents. Modify, // Change encryption, compression, attributes, name, time etc, of an existing file. Add, // Add a new file to the archive. } #region Properties /// /// Get / set the to apply to names when updating. /// public INameTransform NameTransform { get { return updateEntryFactory_.NameTransform; } set { updateEntryFactory_.NameTransform = value; } } /// /// Get/set the used to generate values /// during updates. /// public IEntryFactory EntryFactory { get { return updateEntryFactory_; } set { if (value == null) { updateEntryFactory_ = new ZipEntryFactory(); } else { updateEntryFactory_ = value; } } } /// /// Get /set the buffer size to be used when updating this zip file. /// public int BufferSize { get { return bufferSize_; } set { if ( value < 1024 ) { #if NETCF_1_0 throw new ArgumentOutOfRangeException("value"); #else throw new ArgumentOutOfRangeException("value", "cannot be below 1024"); #endif } if ( bufferSize_ != value ) { bufferSize_ = value; copyBuffer_ = null; } } } /// /// Get a value indicating an update has been started. /// public bool IsUpdating { get { return updates_ != null; } } /// /// Get / set a value indicating how Zip64 Extension usage is determined when adding entries. /// public UseZip64 UseZip64 { get { return useZip64_; } set { useZip64_ = value; } } #endregion #region Immediate updating // TBD: Direct form of updating // // public void Update(IEntryMatcher deleteMatcher) // { // } // // public void Update(IScanner addScanner) // { // } #endregion #region Deferred Updating /// /// Begin updating this archive. /// /// The archive storage for use during the update. /// The data source to utilise during updating. public void BeginUpdate(IArchiveStorage archiveStorage, IDynamicDataSource dataSource) { if ( IsEmbeddedArchive ) { throw new ZipException ("Cannot update embedded/SFX archives"); } if ( archiveStorage == null ) { throw new ArgumentNullException("archiveStorage"); } if ( dataSource == null ) { throw new ArgumentNullException("dataSource"); } archiveStorage_ = archiveStorage; updateDataSource_ = dataSource; // NOTE: the baseStream_ may not currently support writing or seeking. updateIndex_ = new Hashtable(); if ( entries_ != null ) { updates_ = new ArrayList(entries_.Length); foreach(ZipEntry entry in entries_) { int index = updates_.Add(new ZipUpdate(entry)); updateIndex_.Add(entry.Name, index); } } else { updates_ = new ArrayList(); } updateCount_ = updates_.Count; contentsEdited_ = false; commentEdited_ = false; newComment_ = null; } /// /// Begin updating to this archive. /// /// The storage to use during the update. public void BeginUpdate(IArchiveStorage archiveStorage) { BeginUpdate(archiveStorage, new DynamicDiskDataSource()); } /// /// Begin updating this archive. /// /// /// /// public void BeginUpdate() { if ( Name == null ) { BeginUpdate(new MemoryArchiveStorage(), new DynamicDiskDataSource()); } else { BeginUpdate(new DiskArchiveStorage(this), new DynamicDiskDataSource()); } } /// /// Commit current updates, updating this archive. /// /// /// public void CommitUpdate() { CheckUpdating(); try { updateIndex_.Clear(); updateIndex_=null; if( contentsEdited_ ) { RunUpdates(); } else if( commentEdited_ ) { UpdateCommentOnly(); } else { // Create an empty archive if none existed originally. if( (entries_!=null)&&(entries_.Length==0) ) { byte[] theComment=(newComment_!=null)?newComment_.RawComment:ZipConstants.ConvertToArray(comment_); using( ZipHelperStream zhs=new ZipHelperStream(baseStream_) ) { zhs.WriteEndOfCentralDirectory(0, 0, 0, theComment); } } } } finally { PostUpdateCleanup(); } } /// /// Abort updating leaving the archive unchanged. /// /// /// public void AbortUpdate() { PostUpdateCleanup(); } /// /// Set the file comment to be recorded when the current update is commited. /// /// The comment to record. public void SetComment(string comment) { CheckUpdating(); newComment_ = new ZipString(comment); if ( newComment_.RawLength > 0xffff ) { newComment_ = null; throw new ZipException("Comment length exceeds maximum - 65535"); } // We dont take account of the original and current comment appearing to be the same // as encoding may be different. commentEdited_ = true; } #endregion #region Adding Entries void AddUpdate(ZipUpdate update) { contentsEdited_ = true; int index = FindExistingUpdate(update.Entry.Name); if (index >= 0) { if ( updates_[index] == null ) { updateCount_ += 1; } // Direct replacement is faster than delete and add. updates_[index] = update; } else { index = updates_.Add(update); updateCount_ += 1; updateIndex_.Add(update.Entry.Name, index); } } /// /// Add a new entry to the archive. /// /// The name of the file to add. /// The compression method to use. /// Ensure Unicode text is used for name and comment for this entry. public void Add(string fileName, CompressionMethod compressionMethod, bool useUnicodeText ) { if (fileName == null) { throw new ArgumentNullException("fileName"); } if (!ZipEntry.IsCompressionMethodSupported(compressionMethod)) { throw new ZipException("Compression method not supported"); } CheckUpdating(); contentsEdited_ = true; ZipEntry entry = EntryFactory.MakeFileEntry(fileName); entry.IsUnicodeText = useUnicodeText; entry.CompressionMethod = compressionMethod; AddUpdate(new ZipUpdate(fileName, entry)); } /// /// Add a new entry to the archive. /// /// The name of the file to add. /// The compression method to use. public void Add(string fileName, CompressionMethod compressionMethod) { if ( fileName == null ) { throw new ArgumentNullException("fileName"); } if ( !ZipEntry.IsCompressionMethodSupported(compressionMethod) ) { throw new ZipException("Compression method not supported"); } CheckUpdating(); contentsEdited_ = true; ZipEntry entry = EntryFactory.MakeFileEntry(fileName); entry.CompressionMethod = compressionMethod; AddUpdate(new ZipUpdate(fileName, entry)); } /// /// Add a file to the archive. /// /// The name of the file to add. public void Add(string fileName) { if ( fileName == null ) { throw new ArgumentNullException("fileName"); } CheckUpdating(); AddUpdate(new ZipUpdate(fileName, EntryFactory.MakeFileEntry(fileName))); } /// /// Add a file entry with data. /// /// The source of the data for this entry. /// The name to give to the entry. public void Add(IStaticDataSource dataSource, string entryName) { if ( dataSource == null ) { throw new ArgumentNullException("dataSource"); } CheckUpdating(); AddUpdate(new ZipUpdate(dataSource, EntryFactory.MakeFileEntry(entryName))); } /// /// Add a file entry with data. /// /// The source of the data for this entry. /// The name to give to the entry. /// The compression method to use. public void Add(IStaticDataSource dataSource, string entryName, CompressionMethod compressionMethod) { if ( dataSource == null ) { throw new ArgumentNullException("dataSource"); } CheckUpdating(); ZipEntry entry = EntryFactory.MakeFileEntry(entryName, false); entry.CompressionMethod = compressionMethod; AddUpdate(new ZipUpdate(dataSource, entry)); } /// /// Add a file entry with data. /// /// The source of the data for this entry. /// The name to give to the entry. /// The compression method to use. /// Ensure Unicode text is used for name and comments for this entry. public void Add(IStaticDataSource dataSource, string entryName, CompressionMethod compressionMethod, bool useUnicodeText) { if (dataSource == null) { throw new ArgumentNullException("dataSource"); } CheckUpdating(); ZipEntry entry = EntryFactory.MakeFileEntry(entryName, false); entry.IsUnicodeText = useUnicodeText; entry.CompressionMethod = compressionMethod; AddUpdate(new ZipUpdate(dataSource, entry)); } /// /// Add a that contains no data. /// /// The entry to add. /// This can be used to add directories, volume labels, or empty file entries. public void Add(ZipEntry entry) { if ( entry == null ) { throw new ArgumentNullException("entry"); } CheckUpdating(); if ( (entry.Size != 0) || (entry.CompressedSize != 0) ) { throw new ZipException("Entry cannot have any data"); } AddUpdate(new ZipUpdate(UpdateCommand.Add, entry)); } /// /// Add a directory entry to the archive. /// /// The directory to add. public void AddDirectory(string directoryName) { if ( directoryName == null ) { throw new ArgumentNullException("directoryName"); } CheckUpdating(); ZipEntry dirEntry = EntryFactory.MakeDirectoryEntry(directoryName); AddUpdate(new ZipUpdate(UpdateCommand.Add, dirEntry)); } #endregion #region Modifying Entries /* Modify not yet ready for public consumption. Direct modification of an entry should not overwrite original data before its read. Safe mode is trivial in this sense. public void Modify(ZipEntry original, ZipEntry updated) { if ( original == null ) { throw new ArgumentNullException("original"); } if ( updated == null ) { throw new ArgumentNullException("updated"); } CheckUpdating(); contentsEdited_ = true; updates_.Add(new ZipUpdate(original, updated)); } */ #endregion #region Deleting Entries /// /// Delete an entry by name /// /// The filename to delete /// True if the entry was found and deleted; false otherwise. public bool Delete(string fileName) { CheckUpdating(); bool result = false; int index = FindExistingUpdate(fileName); if ( (index >= 0) && (updates_[index] != null) ) { result = true; contentsEdited_ = true; updates_[index] = null; updateCount_ -= 1; } else { throw new ZipException("Cannot find entry to delete"); } return result; } /// /// Delete a from the archive. /// /// The entry to delete. public void Delete(ZipEntry entry) { CheckUpdating(); int index = FindExistingUpdate(entry); if ( index >= 0 ) { contentsEdited_ = true; updates_[index] = null; updateCount_ -= 1; } else { throw new ZipException("Cannot find entry to delete"); } } #endregion #region Update Support #region Writing Values/Headers void WriteLEShort(int value) { baseStream_.WriteByte(( byte )(value & 0xff)); baseStream_.WriteByte(( byte )((value >> 8) & 0xff)); } /// /// Write an unsigned short in little endian byte order. /// void WriteLEUshort(ushort value) { baseStream_.WriteByte(( byte )(value & 0xff)); baseStream_.WriteByte(( byte )(value >> 8)); } /// /// Write an int in little endian byte order. /// void WriteLEInt(int value) { WriteLEShort(value & 0xffff); WriteLEShort(value >> 16); } /// /// Write an unsigned int in little endian byte order. /// void WriteLEUint(uint value) { WriteLEUshort((ushort)(value & 0xffff)); WriteLEUshort((ushort)(value >> 16)); } /// /// Write a long in little endian byte order. /// void WriteLeLong(long value) { WriteLEInt(( int )(value & 0xffffffff)); WriteLEInt(( int )(value >> 32)); } void WriteLEUlong(ulong value) { WriteLEUint(( uint )(value & 0xffffffff)); WriteLEUint(( uint )(value >> 32)); } void WriteLocalEntryHeader(ZipUpdate update) { ZipEntry entry = update.OutEntry; // TODO: Local offset will require adjusting for multi-disk zip files. entry.Offset = baseStream_.Position; // TODO: Need to clear any entry flags that dont make sense or throw an exception here. if (update.Command != UpdateCommand.Copy) { if (entry.CompressionMethod == CompressionMethod.Deflated) { if (entry.Size == 0) { // No need to compress - no data. entry.CompressedSize = entry.Size; entry.Crc = 0; entry.CompressionMethod = CompressionMethod.Stored; } } else if (entry.CompressionMethod == CompressionMethod.Stored) { entry.Flags &= ~(int)GeneralBitFlags.Descriptor; } if (HaveKeys) { entry.IsCrypted = true; if (entry.Crc < 0) { entry.Flags |= (int)GeneralBitFlags.Descriptor; } } else { entry.IsCrypted = false; } switch (useZip64_) { case UseZip64.Dynamic: if (entry.Size < 0) { entry.ForceZip64(); } break; case UseZip64.On: entry.ForceZip64(); break; case UseZip64.Off: // Do nothing. The entry itself may be using Zip64 independantly. break; } } // Write the local file header WriteLEInt(ZipConstants.LocalHeaderSignature); WriteLEShort(entry.Version); WriteLEShort(entry.Flags); WriteLEShort((byte)entry.CompressionMethod); WriteLEInt(( int )entry.DosTime); if ( !entry.HasCrc ) { // Note patch address for updating CRC later. update.CrcPatchOffset = baseStream_.Position; WriteLEInt(( int )0); } else { WriteLEInt(unchecked(( int )entry.Crc)); } if (entry.LocalHeaderRequiresZip64) { WriteLEInt(-1); WriteLEInt(-1); } else { if ( (entry.CompressedSize < 0) || (entry.Size < 0) ) { update.SizePatchOffset = baseStream_.Position; } WriteLEInt(( int )entry.CompressedSize); WriteLEInt(( int )entry.Size); } byte[] name = ZipConstants.ConvertToArray(entry.Flags, entry.Name); if ( name.Length > 0xFFFF ) { throw new ZipException("Entry name too long."); } ZipExtraData ed = new ZipExtraData(entry.ExtraData); if ( entry.LocalHeaderRequiresZip64 ) { ed.StartNewEntry(); // Local entry header always includes size and compressed size. // NOTE the order of these fields is reversed when compared to the normal headers! ed.AddLeLong(entry.Size); ed.AddLeLong(entry.CompressedSize); ed.AddNewEntry(1); } else { ed.Delete(1); } entry.ExtraData = ed.GetEntryData(); WriteLEShort(name.Length); WriteLEShort(entry.ExtraData.Length); if ( name.Length > 0 ) { baseStream_.Write(name, 0, name.Length); } if ( entry.LocalHeaderRequiresZip64 ) { if ( !ed.Find(1) ) { throw new ZipException("Internal error cannot find extra data"); } update.SizePatchOffset = baseStream_.Position + ed.CurrentReadIndex; } if ( entry.ExtraData.Length > 0 ) { baseStream_.Write(entry.ExtraData, 0, entry.ExtraData.Length); } } int WriteCentralDirectoryHeader(ZipEntry entry) { if ( entry.CompressedSize < 0 ) { throw new ZipException("Attempt to write central directory entry with unknown csize"); } if ( entry.Size < 0 ) { throw new ZipException("Attempt to write central directory entry with unknown size"); } if ( entry.Crc < 0 ) { throw new ZipException("Attempt to write central directory entry with unknown crc"); } // Write the central file header WriteLEInt(ZipConstants.CentralHeaderSignature); // Version made by WriteLEShort(ZipConstants.VersionMadeBy); // Version required to extract WriteLEShort(entry.Version); WriteLEShort(entry.Flags); unchecked { WriteLEShort((byte)entry.CompressionMethod); WriteLEInt((int)entry.DosTime); WriteLEInt((int)entry.Crc); } if ( (entry.IsZip64Forced()) || (entry.CompressedSize >= 0xffffffff) ) { WriteLEInt(-1); } else { WriteLEInt((int)(entry.CompressedSize & 0xffffffff)); } if ( (entry.IsZip64Forced()) || (entry.Size >= 0xffffffff) ) { WriteLEInt(-1); } else { WriteLEInt((int)entry.Size); } byte[] name = ZipConstants.ConvertToArray(entry.Flags, entry.Name); if ( name.Length > 0xFFFF ) { throw new ZipException("Entry name is too long."); } WriteLEShort(name.Length); // Central header extra data is different to local header version so regenerate. ZipExtraData ed = new ZipExtraData(entry.ExtraData); if ( entry.CentralHeaderRequiresZip64 ) { ed.StartNewEntry(); if ( (entry.Size >= 0xffffffff) || (useZip64_ == UseZip64.On) ) { ed.AddLeLong(entry.Size); } if ( (entry.CompressedSize >= 0xffffffff) || (useZip64_ == UseZip64.On) ) { ed.AddLeLong(entry.CompressedSize); } if ( entry.Offset >= 0xffffffff ) { ed.AddLeLong(entry.Offset); } // Number of disk on which this file starts isnt supported and is never written here. ed.AddNewEntry(1); } else { // Should have already be done when local header was added. ed.Delete(1); } byte[] centralExtraData = ed.GetEntryData(); WriteLEShort(centralExtraData.Length); WriteLEShort(entry.Comment != null ? entry.Comment.Length : 0); WriteLEShort(0); // disk number WriteLEShort(0); // internal file attributes // External file attributes... if ( entry.ExternalFileAttributes != -1 ) { WriteLEInt(entry.ExternalFileAttributes); } else { if ( entry.IsDirectory ) { WriteLEUint(16); } else { WriteLEUint(0); } } if ( entry.Offset >= 0xffffffff ) { WriteLEUint(0xffffffff); } else { WriteLEUint((uint)(int)entry.Offset); } if ( name.Length > 0 ) { baseStream_.Write(name, 0, name.Length); } if ( centralExtraData.Length > 0 ) { baseStream_.Write(centralExtraData, 0, centralExtraData.Length); } byte[] rawComment = (entry.Comment != null) ? Encoding.ASCII.GetBytes(entry.Comment) : new byte[0]; if ( rawComment.Length > 0 ) { baseStream_.Write(rawComment, 0, rawComment.Length); } return ZipConstants.CentralHeaderBaseSize + name.Length + centralExtraData.Length + rawComment.Length; } #endregion void PostUpdateCleanup() { if( archiveStorage_!=null ) { archiveStorage_.Dispose(); archiveStorage_=null; } updateDataSource_=null; updates_ = null; updateIndex_ = null; } string GetTransformedFileName(string name) { return (NameTransform != null) ? NameTransform.TransformFile(name) : name; } string GetTransformedDirectoryName(string name) { return (NameTransform != null) ? NameTransform.TransformDirectory(name) : name; } /// /// Get a raw memory buffer. /// /// Returns a raw memory buffer. byte[] GetBuffer() { if ( copyBuffer_ == null ) { copyBuffer_ = new byte[bufferSize_]; } return copyBuffer_; } void CopyDescriptorBytes(ZipUpdate update, Stream dest, Stream source) { int bytesToCopy = GetDescriptorSize(update); if ( bytesToCopy > 0 ) { byte[] buffer = GetBuffer(); while ( bytesToCopy > 0 ) { int readSize = Math.Min(buffer.Length, bytesToCopy); int bytesRead = source.Read(buffer, 0, readSize); if ( bytesRead > 0 ) { dest.Write(buffer, 0, bytesRead); bytesToCopy -= bytesRead; } else { throw new ZipException("Unxpected end of stream"); } } } } void CopyBytes(ZipUpdate update, Stream destination, Stream source, long bytesToCopy, bool updateCrc) { if ( destination == source ) { throw new InvalidOperationException("Destination and source are the same"); } // NOTE: Compressed size is updated elsewhere. Crc32 crc = new Crc32(); byte[] buffer = GetBuffer(); long targetBytes = bytesToCopy; long totalBytesRead = 0; int bytesRead; do { int readSize = buffer.Length; if ( bytesToCopy < readSize ) { readSize = (int)bytesToCopy; } bytesRead = source.Read(buffer, 0, readSize); if ( bytesRead > 0 ) { if ( updateCrc ) { crc.Update(buffer, 0, bytesRead); } destination.Write(buffer, 0, bytesRead); bytesToCopy -= bytesRead; totalBytesRead += bytesRead; } } while ( (bytesRead > 0) && (bytesToCopy > 0) ); if ( totalBytesRead != targetBytes ) { throw new ZipException(string.Format("Failed to copy bytes expected {0} read {1}", targetBytes, totalBytesRead)); } if ( updateCrc ) { update.OutEntry.Crc = crc.Value; } } /// /// Get the size of the source descriptor for a . /// /// The update to get the size for. /// The descriptor size, zero if there isnt one. int GetDescriptorSize(ZipUpdate update) { int result = 0; if ( (update.Entry.Flags & (int)GeneralBitFlags.Descriptor) != 0) { result = ZipConstants.DataDescriptorSize - 4; if ( update.Entry.LocalHeaderRequiresZip64 ) { result = ZipConstants.Zip64DataDescriptorSize - 4; } } return result; } void CopyDescriptorBytesDirect(ZipUpdate update, Stream stream, ref long destinationPosition, long sourcePosition) { int bytesToCopy = GetDescriptorSize(update); while ( bytesToCopy > 0 ) { int readSize = (int)bytesToCopy; byte[] buffer = GetBuffer(); stream.Position = sourcePosition; int bytesRead = stream.Read(buffer, 0, readSize); if ( bytesRead > 0 ) { stream.Position = destinationPosition; stream.Write(buffer, 0, bytesRead); bytesToCopy -= bytesRead; destinationPosition += bytesRead; sourcePosition += bytesRead; } else { throw new ZipException("Unxpected end of stream"); } } } void CopyEntryDataDirect(ZipUpdate update, Stream stream, bool updateCrc, ref long destinationPosition, ref long sourcePosition) { long bytesToCopy = update.Entry.CompressedSize; // NOTE: Compressed size is updated elsewhere. Crc32 crc = new Crc32(); byte[] buffer = GetBuffer(); long targetBytes = bytesToCopy; long totalBytesRead = 0; int bytesRead; do { int readSize = buffer.Length; if ( bytesToCopy < readSize ) { readSize = (int)bytesToCopy; } stream.Position = sourcePosition; bytesRead = stream.Read(buffer, 0, readSize); if ( bytesRead > 0 ) { if ( updateCrc ) { crc.Update(buffer, 0, bytesRead); } stream.Position = destinationPosition; stream.Write(buffer, 0, bytesRead); destinationPosition += bytesRead; sourcePosition += bytesRead; bytesToCopy -= bytesRead; totalBytesRead += bytesRead; } } while ( (bytesRead > 0) && (bytesToCopy > 0) ); if ( totalBytesRead != targetBytes ) { throw new ZipException(string.Format("Failed to copy bytes expected {0} read {1}", targetBytes, totalBytesRead)); } if ( updateCrc ) { update.OutEntry.Crc = crc.Value; } } int FindExistingUpdate(ZipEntry entry) { int result = -1; string convertedName = GetTransformedFileName(entry.Name); if (updateIndex_.ContainsKey(convertedName)) { result = (int)updateIndex_[convertedName]; } /* // This is slow like the coming of the next ice age but takes less storage and may be useful // for CF? for (int index = 0; index < updates_.Count; ++index) { ZipUpdate zu = ( ZipUpdate )updates_[index]; if ( (zu.Entry.ZipFileIndex == entry.ZipFileIndex) && (string.Compare(convertedName, zu.Entry.Name, true, CultureInfo.InvariantCulture) == 0) ) { result = index; break; } } */ return result; } int FindExistingUpdate(string fileName) { int result = -1; string convertedName = GetTransformedFileName(fileName); if (updateIndex_.ContainsKey(convertedName)) { result = (int)updateIndex_[convertedName]; } /* // This is slow like the coming of the next ice age but takes less storage and may be useful // for CF? for ( int index = 0; index < updates_.Count; ++index ) { if ( string.Compare(convertedName, (( ZipUpdate )updates_[index]).Entry.Name, true, CultureInfo.InvariantCulture) == 0 ) { result = index; break; } } */ return result; } /// /// Get an output stream for the specified /// /// The entry to get an output stream for. /// The output stream obtained for the entry. Stream GetOutputStream(ZipEntry entry) { Stream result = baseStream_; if ( entry.IsCrypted == true ) { #if NETCF_1_0 throw new ZipException("Encryption not supported for Compact Framework 1.0"); #else result = CreateAndInitEncryptionStream(result, entry); #endif } switch ( entry.CompressionMethod ) { case CompressionMethod.Stored: result = new UncompressedStream(result); break; case CompressionMethod.Deflated: DeflaterOutputStream dos = new DeflaterOutputStream(result, new Deflater(9, true)); dos.IsStreamOwner = false; result = dos; break; default: throw new ZipException("Unknown compression method " + entry.CompressionMethod); } return result; } void AddEntry(ZipFile workFile, ZipUpdate update) { Stream source = null; if ( update.Entry.IsFile ) { source = update.GetSource(); if ( source == null ) { source = updateDataSource_.GetSource(update.Entry, update.Filename); } } if ( source != null ) { using ( source ) { long sourceStreamLength = source.Length; if ( update.OutEntry.Size < 0 ) { update.OutEntry.Size = sourceStreamLength; } else { // Check for errant entries. if ( update.OutEntry.Size != sourceStreamLength ) { throw new ZipException("Entry size/stream size mismatch"); } } workFile.WriteLocalEntryHeader(update); long dataStart = workFile.baseStream_.Position; using ( Stream output = workFile.GetOutputStream(update.OutEntry) ) { CopyBytes(update, output, source, sourceStreamLength, true); } long dataEnd = workFile.baseStream_.Position; update.OutEntry.CompressedSize = dataEnd - dataStart; if ((update.OutEntry.Flags & (int)GeneralBitFlags.Descriptor) == (int)GeneralBitFlags.Descriptor) { ZipHelperStream helper = new ZipHelperStream(workFile.baseStream_); helper.WriteDataDescriptor(update.OutEntry); } } } else { workFile.WriteLocalEntryHeader(update); update.OutEntry.CompressedSize = 0; } } void ModifyEntry(ZipFile workFile, ZipUpdate update) { workFile.WriteLocalEntryHeader(update); long dataStart = workFile.baseStream_.Position; // TODO: This is slow if the changes don't effect the data!! if ( update.Entry.IsFile && (update.Filename != null) ) { using ( Stream output = workFile.GetOutputStream(update.OutEntry) ) { using ( Stream source = this.GetInputStream(update.Entry) ) { CopyBytes(update, output, source, source.Length, true); } } } long dataEnd = workFile.baseStream_.Position; update.Entry.CompressedSize = dataEnd - dataStart; } void CopyEntryDirect(ZipFile workFile, ZipUpdate update, ref long destinationPosition) { bool skipOver = false; if ( update.Entry.Offset == destinationPosition ) { skipOver = true; } if ( !skipOver ) { baseStream_.Position = destinationPosition; workFile.WriteLocalEntryHeader(update); destinationPosition = baseStream_.Position; } long sourcePosition = 0; const int NameLengthOffset = 26; // TODO: Add base for SFX friendly handling long entryDataOffset = update.Entry.Offset + NameLengthOffset; baseStream_.Seek(entryDataOffset, SeekOrigin.Begin); // Clumsy way of handling retrieving the original name and extra data length for now. // TODO: Stop re-reading name and data length in CopyEntryDirect. uint nameLength = ReadLEUshort(); uint extraLength = ReadLEUshort(); sourcePosition = baseStream_.Position + nameLength + extraLength; if ( skipOver ) { destinationPosition += (sourcePosition - entryDataOffset) + NameLengthOffset + // Header size update.Entry.CompressedSize + GetDescriptorSize(update); } else { if ( update.Entry.CompressedSize > 0 ) { CopyEntryDataDirect(update, baseStream_, false, ref destinationPosition, ref sourcePosition ); } CopyDescriptorBytesDirect(update, baseStream_, ref destinationPosition, sourcePosition); } } void CopyEntry(ZipFile workFile, ZipUpdate update) { workFile.WriteLocalEntryHeader(update); if ( update.Entry.CompressedSize > 0 ) { const int NameLengthOffset = 26; long entryDataOffset = update.Entry.Offset + NameLengthOffset; // TODO: This wont work for SFX files! baseStream_.Seek(entryDataOffset, SeekOrigin.Begin); uint nameLength = ReadLEUshort(); uint extraLength = ReadLEUshort(); baseStream_.Seek(nameLength + extraLength, SeekOrigin.Current); CopyBytes(update, workFile.baseStream_, baseStream_, update.Entry.CompressedSize, false); } CopyDescriptorBytes(update, workFile.baseStream_, baseStream_); } void Reopen(Stream source) { if ( source == null ) { throw new ZipException("Failed to reopen archive - no source"); } isNewArchive_ = false; baseStream_ = source; ReadEntries(); } void Reopen() { if (Name == null) { throw new InvalidOperationException("Name is not known cannot Reopen"); } Reopen(File.OpenRead(Name)); } void UpdateCommentOnly() { long baseLength = baseStream_.Length; ZipHelperStream updateFile = null; if ( archiveStorage_.UpdateMode == FileUpdateMode.Safe ) { Stream copyStream = archiveStorage_.MakeTemporaryCopy(baseStream_); updateFile = new ZipHelperStream(copyStream); updateFile.IsStreamOwner = true; baseStream_.Close(); baseStream_ = null; } else { if (archiveStorage_.UpdateMode == FileUpdateMode.Direct) { // TODO: archiveStorage wasnt originally intended for this use. // Need to revisit this to tidy up handling as archive storage currently doesnt // handle the original stream well. // The problem is when using an existing zip archive with an in memory archive storage. // The open stream wont support writing but the memory storage should open the same file not an in memory one. // Need to tidy up the archive storage interface and contract basically. baseStream_ = archiveStorage_.OpenForDirectUpdate(baseStream_); updateFile = new ZipHelperStream(baseStream_); } else { baseStream_.Close(); baseStream_ = null; updateFile = new ZipHelperStream(Name); } } using ( updateFile ) { long locatedCentralDirOffset = updateFile.LocateBlockWithSignature(ZipConstants.EndOfCentralDirectorySignature, baseLength, ZipConstants.EndOfCentralRecordBaseSize, 0xffff); if ( locatedCentralDirOffset < 0 ) { throw new ZipException("Cannot find central directory"); } const int CentralHeaderCommentSizeOffset = 16; updateFile.Position += CentralHeaderCommentSizeOffset; byte[] rawComment = newComment_.RawComment; updateFile.WriteLEShort(rawComment.Length); updateFile.Write(rawComment, 0, rawComment.Length); updateFile.SetLength(updateFile.Position); } if ( archiveStorage_.UpdateMode == FileUpdateMode.Safe ) { Reopen(archiveStorage_.ConvertTemporaryToFinal()); } else { ReadEntries(); } } /// /// Class used to sort updates. /// class UpdateComparer : IComparer { /// /// Compares two objects and returns a value indicating whether one is /// less than, equal to or greater than the other. /// /// First object to compare /// Second object to compare. /// Compare result. public int Compare( object x, object y) { ZipUpdate zx = x as ZipUpdate; ZipUpdate zy = y as ZipUpdate; int result; if (zx == null) { if (zy == null) { result = 0; } else { result = -1; } } else if (zy == null) { result = 1; } else { int xCmdValue = ((zx.Command == UpdateCommand.Copy) || (zx.Command == UpdateCommand.Modify)) ? 0 : 1; int yCmdValue = ((zy.Command == UpdateCommand.Copy) || (zy.Command == UpdateCommand.Modify)) ? 0 : 1; result = xCmdValue - yCmdValue; if (result == 0) { long offsetDiff = zx.Entry.Offset - zy.Entry.Offset; if (offsetDiff < 0) { result = -1; } else if (offsetDiff == 0) { result = 0; } else { result = 1; } } } return result; } } void RunUpdates() { long sizeEntries = 0; long endOfStream = 0; bool allOk = true; bool directUpdate = false; long destinationPosition = 0; // NOT SFX friendly ZipFile workFile; if ( IsNewArchive ) { workFile = this; workFile.baseStream_.Position = 0; directUpdate = true; } else if ( archiveStorage_.UpdateMode == FileUpdateMode.Direct ) { workFile = this; workFile.baseStream_.Position = 0; directUpdate = true; // Sort the updates by offset within copies/modifies, then adds. // This ensures that data required by copies will not be overwritten. updates_.Sort(new UpdateComparer()); } else { workFile = ZipFile.Create(archiveStorage_.GetTemporaryOutput()); workFile.UseZip64 = UseZip64; if (key != null) { workFile.key = (byte[])key.Clone(); } } try { foreach ( ZipUpdate update in updates_ ) { if (update != null) { switch (update.Command) { case UpdateCommand.Copy: if (directUpdate) { CopyEntryDirect(workFile, update, ref destinationPosition); } else { CopyEntry(workFile, update); } break; case UpdateCommand.Modify: // TODO: Direct modifying of an entry will take some legwork. ModifyEntry(workFile, update); break; case UpdateCommand.Add: if (!IsNewArchive && directUpdate) { workFile.baseStream_.Position = destinationPosition; } AddEntry(workFile, update); if (directUpdate) { destinationPosition = workFile.baseStream_.Position; } break; } } } if ( !IsNewArchive && directUpdate ) { workFile.baseStream_.Position = destinationPosition; } long centralDirOffset = workFile.baseStream_.Position; foreach ( ZipUpdate update in updates_ ) { if (update != null) { sizeEntries += workFile.WriteCentralDirectoryHeader(update.OutEntry); } } byte[] theComment = (newComment_ != null) ? newComment_.RawComment : ZipConstants.ConvertToArray(comment_); using ( ZipHelperStream zhs = new ZipHelperStream(workFile.baseStream_) ) { zhs.WriteEndOfCentralDirectory(updateCount_, sizeEntries, centralDirOffset, theComment); } endOfStream = workFile.baseStream_.Position; // And now patch entries... foreach ( ZipUpdate update in updates_ ) { if (update != null) { // If the size of the entry is zero leave the crc as 0 as well. // The calculated crc will be all bits on... if ((update.CrcPatchOffset > 0) && (update.OutEntry.CompressedSize > 0)) { workFile.baseStream_.Position = update.CrcPatchOffset; workFile.WriteLEInt((int)update.OutEntry.Crc); } if (update.SizePatchOffset > 0) { workFile.baseStream_.Position = update.SizePatchOffset; if (update.OutEntry.LocalHeaderRequiresZip64) { workFile.WriteLeLong(update.OutEntry.Size); workFile.WriteLeLong(update.OutEntry.CompressedSize); } else { workFile.WriteLEInt((int)update.OutEntry.CompressedSize); workFile.WriteLEInt((int)update.OutEntry.Size); } } } } } catch(Exception) { allOk = false; } finally { if ( directUpdate ) { if ( allOk ) { workFile.baseStream_.Flush(); workFile.baseStream_.SetLength(endOfStream); } } else { workFile.Close(); } } if ( allOk ) { if ( directUpdate ) { isNewArchive_ = false; workFile.baseStream_.Flush(); ReadEntries(); } else { baseStream_.Close(); Reopen(archiveStorage_.ConvertTemporaryToFinal()); } } else { workFile.Close(); if ( !directUpdate && (workFile.Name != null) ) { File.Delete(workFile.Name); } } } void CheckUpdating() { if ( updates_ == null ) { throw new ZipException("Cannot update until BeginUpdate has been called"); } } #endregion #region ZipUpdate class /// /// Represents a pending update to a Zip file. /// class ZipUpdate { #region Constructors public ZipUpdate(string fileName, ZipEntry entry) { command_ = UpdateCommand.Add; entry_ = entry; filename_ = fileName; } [Obsolete] public ZipUpdate(string fileName, string entryName, CompressionMethod compressionMethod) { command_ = UpdateCommand.Add; entry_ = new ZipEntry(entryName); entry_.CompressionMethod = compressionMethod; filename_ = fileName; } [Obsolete] public ZipUpdate(string fileName, string entryName) : this(fileName, entryName, CompressionMethod.Deflated) { // Do nothing. } [Obsolete] public ZipUpdate(IStaticDataSource dataSource, string entryName, CompressionMethod compressionMethod) { command_ = UpdateCommand.Add; entry_ = new ZipEntry(entryName); entry_.CompressionMethod = compressionMethod; dataSource_ = dataSource; } public ZipUpdate(IStaticDataSource dataSource, ZipEntry entry) { command_ = UpdateCommand.Add; entry_ = entry; dataSource_ = dataSource; } public ZipUpdate(ZipEntry original, ZipEntry updated) { throw new ZipException("Modify not currently supported"); /* command_ = UpdateCommand.Modify; entry_ = ( ZipEntry )original.Clone(); outEntry_ = ( ZipEntry )updated.Clone(); */ } public ZipUpdate(UpdateCommand command, ZipEntry entry) { command_ = command; entry_ = ( ZipEntry )entry.Clone(); } /// /// Copy an existing entry. /// /// The existing entry to copy. public ZipUpdate(ZipEntry entry) : this(UpdateCommand.Copy, entry) { // Do nothing. } #endregion /// /// Get the for this update. /// /// This is the source or original entry. public ZipEntry Entry { get { return entry_; } } /// /// Get the that will be written to the updated/new file. /// public ZipEntry OutEntry { get { if ( outEntry_ == null ) { outEntry_ = (ZipEntry)entry_.Clone(); } return outEntry_; } } /// /// Get the command for this update. /// public UpdateCommand Command { get { return command_; } } /// /// Get the filename if any for this update. Null if none exists. /// public string Filename { get { return filename_; } } /// /// Get/set the location of the size patch for this update. /// public long SizePatchOffset { get { return sizePatchOffset_; } set { sizePatchOffset_ = value; } } /// /// Get /set the location of the crc patch for this update. /// public long CrcPatchOffset { get { return crcPatchOffset_; } set { crcPatchOffset_ = value; } } public Stream GetSource() { Stream result = null; if ( dataSource_ != null ) { result = dataSource_.GetSource(); } return result; } #region Instance Fields ZipEntry entry_; ZipEntry outEntry_; UpdateCommand command_; IStaticDataSource dataSource_; string filename_; long sizePatchOffset_ = -1; long crcPatchOffset_ = -1; #endregion } #endregion #endregion #region Disposing #region IDisposable Members void IDisposable.Dispose() { Close(); } #endregion void DisposeInternal(bool disposing) { if ( !isDisposed_ ) { isDisposed_ = true; entries_ = null; if ( IsStreamOwner && (baseStream_ != null) ) { lock(baseStream_) { baseStream_.Close(); } } } } /// /// Releases the unmanaged resources used by the this instance and optionally releases the managed resources. /// /// true to release both managed and unmanaged resources; /// false to release only unmanaged resources. protected virtual void Dispose(bool disposing) { DisposeInternal(disposing); } #endregion #region Internal routines #region Reading /// /// Read an unsigned short in little endian byte order. /// /// Returns the value read. /// /// The stream ends prematurely /// ushort ReadLEUshort() { int data1 = baseStream_.ReadByte(); if ( data1 < 0 ) { throw new EndOfStreamException("End of stream"); } int data2 = baseStream_.ReadByte(); if ( data2 < 0 ) { throw new EndOfStreamException("End of stream"); } return unchecked((ushort)((ushort)data1 | (ushort)(data2 << 8))); } /// /// Read a uint in little endian byte order. /// /// Returns the value read. /// /// An i/o error occurs. /// /// /// The file ends prematurely /// uint ReadLEUint() { return (uint)(ReadLEUshort() | (ReadLEUshort() << 16)); } ulong ReadLEUlong() { return ReadLEUint() | ((ulong)ReadLEUint() << 32); } #endregion // NOTE this returns the offset of the first byte after the signature. long LocateBlockWithSignature(int signature, long endLocation, int minimumBlockSize, int maximumVariableData) { using ( ZipHelperStream les = new ZipHelperStream(baseStream_) ) { return les.LocateBlockWithSignature(signature, endLocation, minimumBlockSize, maximumVariableData); } } /// /// Search for and read the central directory of a zip file filling the entries array. /// /// /// An i/o error occurs. /// /// /// The central directory is malformed or cannot be found /// void ReadEntries() { // Search for the End Of Central Directory. When a zip comment is // present the directory will start earlier // // The search is limited to 64K which is the maximum size of a trailing comment field to aid speed. // This should be compatible with both SFX and ZIP files but has only been tested for Zip files // If a SFX file has the Zip data attached as a resource and there are other resources occuring later then // this could be invalid. // Could also speed this up by reading memory in larger blocks. if (baseStream_.CanSeek == false) { throw new ZipException("ZipFile stream must be seekable"); } long locatedEndOfCentralDir = LocateBlockWithSignature(ZipConstants.EndOfCentralDirectorySignature, baseStream_.Length, ZipConstants.EndOfCentralRecordBaseSize, 0xffff); if (locatedEndOfCentralDir < 0) { throw new ZipException("Cannot find central directory"); } // Read end of central directory record ushort thisDiskNumber = ReadLEUshort(); ushort startCentralDirDisk = ReadLEUshort(); ulong entriesForThisDisk = ReadLEUshort(); ulong entriesForWholeCentralDir = ReadLEUshort(); ulong centralDirSize = ReadLEUint(); long offsetOfCentralDir = ReadLEUint(); uint commentSize = ReadLEUshort(); if ( commentSize > 0 ) { byte[] comment = new byte[commentSize]; StreamUtils.ReadFully(baseStream_, comment); comment_ = ZipConstants.ConvertToString(comment); } else { comment_ = string.Empty; } bool isZip64 = false; // Check if zip64 header information is required. if ( (thisDiskNumber == 0xffff) || (startCentralDirDisk == 0xffff) || (entriesForThisDisk == 0xffff) || (entriesForWholeCentralDir == 0xffff) || (centralDirSize == 0xffffffff) || (offsetOfCentralDir == 0xffffffff) ) { isZip64 = true; long offset = LocateBlockWithSignature(ZipConstants.Zip64CentralDirLocatorSignature, locatedEndOfCentralDir, 0, 0x1000); if ( offset < 0 ) { throw new ZipException("Cannot find Zip64 locator"); } // number of the disk with the start of the zip64 end of central directory 4 bytes // relative offset of the zip64 end of central directory record 8 bytes // total number of disks 4 bytes ReadLEUint(); // startDisk64 is not currently used ulong offset64 = ReadLEUlong(); uint totalDisks = ReadLEUint(); baseStream_.Position = (long)offset64; long sig64 = ReadLEUint(); if ( sig64 != ZipConstants.Zip64CentralFileHeaderSignature ) { throw new ZipException(string.Format("Invalid Zip64 Central directory signature at {0:X}", offset64)); } // NOTE: Record size = SizeOfFixedFields + SizeOfVariableData - 12. ulong recordSize = ( ulong )ReadLEUlong(); int versionMadeBy = ReadLEUshort(); int versionToExtract = ReadLEUshort(); uint thisDisk = ReadLEUint(); uint centralDirDisk = ReadLEUint(); entriesForThisDisk = ReadLEUlong(); entriesForWholeCentralDir = ReadLEUlong(); centralDirSize = ReadLEUlong(); offsetOfCentralDir = (long)ReadLEUlong(); // NOTE: zip64 extensible data sector (variable size) is ignored. } entries_ = new ZipEntry[entriesForThisDisk]; // SFX/embedded support, find the offset of the first entry vis the start of the stream // This applies to Zip files that are appended to the end of an SFX stub. // Or are appended as a resource to an executable. // Zip files created by some archivers have the offsets altered to reflect the true offsets // and so dont require any adjustment here... // TODO: Difficulty with Zip64 and SFX offset handling needs resolution - maths? if ( !isZip64 && (offsetOfCentralDir < locatedEndOfCentralDir - (4 + (long)centralDirSize)) ) { offsetOfFirstEntry = locatedEndOfCentralDir - (4 + (long)centralDirSize + offsetOfCentralDir); if (offsetOfFirstEntry <= 0) { throw new ZipException("Invalid embedded zip archive"); } } baseStream_.Seek(offsetOfFirstEntry + offsetOfCentralDir, SeekOrigin.Begin); for (ulong i = 0; i < entriesForThisDisk; i++) { if (ReadLEUint() != ZipConstants.CentralHeaderSignature) { throw new ZipException("Wrong Central Directory signature"); } int versionMadeBy = ReadLEUshort(); int versionToExtract = ReadLEUshort(); int bitFlags = ReadLEUshort(); int method = ReadLEUshort(); uint dostime = ReadLEUint(); uint crc = ReadLEUint(); long csize = (long)ReadLEUint(); long size = (long)ReadLEUint(); int nameLen = ReadLEUshort(); int extraLen = ReadLEUshort(); int commentLen = ReadLEUshort(); int diskStartNo = ReadLEUshort(); // Not currently used int internalAttributes = ReadLEUshort(); // Not currently used uint externalAttributes = ReadLEUint(); long offset = ReadLEUint(); byte[] buffer = new byte[Math.Max(nameLen, commentLen)]; StreamUtils.ReadFully(baseStream_, buffer, 0, nameLen); string name = ZipConstants.ConvertToStringExt(bitFlags, buffer, nameLen); ZipEntry entry = new ZipEntry(name, versionToExtract, versionMadeBy, (CompressionMethod)method); entry.Crc = crc & 0xffffffffL; entry.Size = size & 0xffffffffL; entry.CompressedSize = csize & 0xffffffffL; entry.Flags = bitFlags; entry.DosTime = (uint)dostime; entry.ZipFileIndex = (long)i; entry.Offset = offset; entry.ExternalFileAttributes = (int)externalAttributes; if ((bitFlags & 8) == 0) { entry.CryptoCheckValue = (byte)(crc >> 24); } else { entry.CryptoCheckValue = (byte)((dostime >> 8) & 0xff); } if (extraLen > 0) { byte[] extra = new byte[extraLen]; StreamUtils.ReadFully(baseStream_, extra); entry.ExtraData = extra; } entry.ProcessExtraData(false); if (commentLen > 0) { StreamUtils.ReadFully(baseStream_, buffer, 0, commentLen); entry.Comment = ZipConstants.ConvertToStringExt(bitFlags, buffer, commentLen); } entries_[i] = entry; } } /// /// Locate the data for a given entry. /// /// /// The start offset of the data. /// /// /// The stream ends prematurely /// /// /// The local header signature is invalid, the entry and central header file name lengths are different /// or the local and entry compression methods dont match /// long LocateEntry(ZipEntry entry) { return TestLocalHeader(entry, HeaderTest.Extract); } #if !NETCF_1_0 Stream CreateAndInitDecryptionStream(Stream baseStream, ZipEntry entry) { CryptoStream result = null; if ( (entry.Version < ZipConstants.VersionStrongEncryption) || (entry.Flags & (int)GeneralBitFlags.StrongEncryption) == 0) { PkzipClassicManaged classicManaged = new PkzipClassicManaged(); OnKeysRequired(entry.Name); if (HaveKeys == false) { throw new ZipException("No password available for encrypted stream"); } result = new CryptoStream(baseStream, classicManaged.CreateDecryptor(key, null), CryptoStreamMode.Read); CheckClassicPassword(result, entry); } else { throw new ZipException("Decryption method not supported"); } return result; } Stream CreateAndInitEncryptionStream(Stream baseStream, ZipEntry entry) { CryptoStream result = null; if ( (entry.Version < ZipConstants.VersionStrongEncryption) || (entry.Flags & (int)GeneralBitFlags.StrongEncryption) == 0) { PkzipClassicManaged classicManaged = new PkzipClassicManaged(); OnKeysRequired(entry.Name); if (HaveKeys == false) { throw new ZipException("No password available for encrypted stream"); } // Closing a CryptoStream will close the base stream as well so wrap it in an UncompressedStream // which doesnt do this. result = new CryptoStream(new UncompressedStream(baseStream), classicManaged.CreateEncryptor(key, null), CryptoStreamMode.Write); if ( (entry.Crc < 0) || (entry.Flags & 8) != 0) { WriteEncryptionHeader(result, entry.DosTime << 16); } else { WriteEncryptionHeader(result, entry.Crc); } } return result; } static void CheckClassicPassword(CryptoStream classicCryptoStream, ZipEntry entry) { byte[] cryptbuffer = new byte[ZipConstants.CryptoHeaderSize]; StreamUtils.ReadFully(classicCryptoStream, cryptbuffer); if (cryptbuffer[ZipConstants.CryptoHeaderSize - 1] != entry.CryptoCheckValue) { throw new ZipException("Invalid password"); } } #endif static void WriteEncryptionHeader(Stream stream, long crcValue) { byte[] cryptBuffer = new byte[ZipConstants.CryptoHeaderSize]; Random rnd = new Random(); rnd.NextBytes(cryptBuffer); cryptBuffer[11] = (byte)(crcValue >> 24); stream.Write(cryptBuffer, 0, cryptBuffer.Length); } #endregion #region Instance Fields bool isDisposed_; string name_; string comment_; Stream baseStream_; bool isStreamOwner; long offsetOfFirstEntry; ZipEntry[] entries_; byte[] key; bool isNewArchive_; // Default is dynamic which is not backwards compatible and can cause problems // with XP's built in compression which cant read Zip64 archives. // However it does avoid the situation were a large file is added and cannot be completed correctly. UseZip64 useZip64_ = UseZip64.Dynamic ; #region Zip Update Instance Fields ArrayList updates_; long updateCount_; // Count is managed manually as updates_ can contain nulls! Hashtable updateIndex_; IArchiveStorage archiveStorage_; IDynamicDataSource updateDataSource_; bool contentsEdited_; int bufferSize_ = DefaultBufferSize; byte[] copyBuffer_; ZipString newComment_; bool commentEdited_; IEntryFactory updateEntryFactory_ = new ZipEntryFactory(); string tempDirectory_ = string.Empty; #endregion #endregion #region Support Classes /// /// Represents a string from a which is stored as an array of bytes. /// class ZipString { #region Constructors /// /// Initialise a with a string. /// /// The textual string form. public ZipString(string comment) { comment_ = comment; isSourceString_ = true; } /// /// Initialise a using a string in its binary 'raw' form. /// /// public ZipString(byte[] rawString) { rawComment_ = rawString; } #endregion /// /// Get a value indicating the original source of data for this instance. /// True if the source was a string; false if the source was binary data. /// public bool IsSourceString { get { return isSourceString_; } } /// /// Get the length of the comment when represented as raw bytes. /// public int RawLength { get { MakeBytesAvailable(); return rawComment_.Length; } } /// /// Get the comment in its 'raw' form as plain bytes. /// public byte[] RawComment { get { MakeBytesAvailable(); return (byte[])rawComment_.Clone(); } } /// /// Reset the comment to its initial state. /// public void Reset() { if ( isSourceString_ ) { rawComment_ = null; } else { comment_ = null; } } void MakeTextAvailable() { if ( comment_ == null ) { comment_ = ZipConstants.ConvertToString(rawComment_); } } void MakeBytesAvailable() { if ( rawComment_ == null ) { rawComment_ = ZipConstants.ConvertToArray(comment_); } } /// /// Implicit conversion of comment to a string. /// /// The to convert to a string. /// The textual equivalent for the input value. static public implicit operator string(ZipString zipString) { zipString.MakeTextAvailable(); return zipString.comment_; } #region Instance Fields string comment_; byte[] rawComment_; bool isSourceString_; #endregion } /// /// An enumerator for Zip entries /// class ZipEntryEnumerator : IEnumerator { #region Constructors public ZipEntryEnumerator(ZipEntry[] entries) { array = entries; } #endregion #region IEnumerator Members public object Current { get { return array[index]; } } public void Reset() { index = -1; } public bool MoveNext() { return (++index < array.Length); } #endregion #region Instance Fields ZipEntry[] array; int index = -1; #endregion } /// /// An is a stream that you can write uncompressed data /// to and flush, but cannot read, seek or do anything else to. /// class UncompressedStream : Stream { #region Constructors public UncompressedStream(Stream baseStream) { baseStream_ = baseStream; } #endregion /// /// Close this stream instance. /// public override void Close() { // Do nothing } /// /// Gets a value indicating whether the current stream supports reading. /// public override bool CanRead { get { return false; } } /// /// Write any buffered data to underlying storage. /// public override void Flush() { baseStream_.Flush(); } /// /// Gets a value indicating whether the current stream supports writing. /// public override bool CanWrite { get { return baseStream_.CanWrite; } } /// /// Gets a value indicating whether the current stream supports seeking. /// public override bool CanSeek { get { return false; } } /// /// Get the length in bytes of the stream. /// public override long Length { get { return 0; } } /// /// Gets or sets the position within the current stream. /// public override long Position { get { return baseStream_.Position; } set { } } public override int Read(byte[] buffer, int offset, int count) { return 0; } public override long Seek(long offset, SeekOrigin origin) { return 0; } public override void SetLength(long value) { } public override void Write(byte[] buffer, int offset, int count) { baseStream_.Write(buffer, offset, count); } #region Instance Fields Stream baseStream_; #endregion } /// /// A is an /// whose data is only a part or subsection of a file. /// class PartialInputStream : InflaterInputStream { #region Constructors /// /// Initialise a new instance of the class. /// /// The underlying stream to use for IO. /// The start of the partial data. /// The length of the partial data. public PartialInputStream(Stream baseStream, long start, long length) : base(baseStream) { baseStream_ = baseStream; filepos_ = start; end_ = start + length; } #endregion /// /// Skip the specified number of input bytes. /// /// The maximum number of input bytes to skip. /// The actuial number of input bytes skipped. public long SkipBytes(long count) { if (count < 0) { #if NETCF_1_0 throw new ArgumentOutOfRangeException("count"); #else throw new ArgumentOutOfRangeException("count", "is less than zero"); #endif } if (count > end_ - filepos_) { count = end_ - filepos_; } filepos_ += count; return count; } public override int Available { get { long amount = end_ - filepos_; if (amount > int.MaxValue) { return int.MaxValue; } return (int) amount; } } /// /// Read a byte from this stream. /// /// Returns the byte read or -1 on end of stream. public override int ReadByte() { if (filepos_ == end_) { // -1 is the correct value at end of stream. return -1; } lock( baseStream_ ) { baseStream_.Seek(filepos_++, SeekOrigin.Begin); return baseStream_.ReadByte(); } } /// /// Close this partial input stream. /// /// /// The underlying stream is not closed. Close the parent ZipFile class to do that. /// public override void Close() { // Do nothing at all! } public override int Read(byte[] buffer, int offset, int count) { if (count > end_ - filepos_) { count = (int) (end_ - filepos_); if (count == 0) { return 0; } } lock(baseStream_) { baseStream_.Seek(filepos_, SeekOrigin.Begin); int readCount = baseStream_.Read(buffer, offset, count); if (readCount > 0) { filepos_ += readCount; } return readCount; } } #region Instance Fields Stream baseStream_; long filepos_; long end_; #endregion } #endregion } #endregion #region DataSources /// /// Provides a static way to obtain a source of data for an entry. /// public interface IStaticDataSource { /// /// Get a source of data by creating a new stream. /// /// Returns a to use for compression input. /// Ideally a new stream is created and opened to achieve this, to avoid locking problems. Stream GetSource(); } /// /// Represents a source of data that can dynamically provide /// multiple data sources based on the parameters passed. /// public interface IDynamicDataSource { /// /// Get a data source. /// /// The to get a source for. /// The name for data if known. /// Returns a to use for compression input. /// Ideally a new stream is created and opened to achieve this, to avoid locking problems. Stream GetSource(ZipEntry entry, string name); } /// /// Default implementation of a for use with files stored on disk. /// class StaticDiskDataSource : IStaticDataSource { /// /// Initialise a new instnace of /// /// The name of the file to obtain data from. public StaticDiskDataSource(string fileName) { fileName_ = fileName; } #region IDataSource Members /// /// Get a providing data. /// /// Returns a provising data. public Stream GetSource() { return File.OpenRead(fileName_); } #endregion #region Instance Fields string fileName_; #endregion } /// /// Default implementation of for files stored on disk. /// class DynamicDiskDataSource : IDynamicDataSource { /// /// Initialise a default instance of . /// public DynamicDiskDataSource() { } #region IDataSource Members /// /// Get a providing data for an entry. /// /// The entry to provide data for. /// The file name for data if known. /// Returns a stream providing data; or null if not available public Stream GetSource(ZipEntry entry, string name) { Stream result = null; if ( name != null ) { result = File.OpenRead(name); } return result; } #endregion } #endregion #region Archive Storage /// /// Defines facilities for data storage when updating Zip Archives. /// public interface IArchiveStorage { /// /// Get the to apply during updates. /// FileUpdateMode UpdateMode { get; } /// /// Get an empty that can be used for temporary output. /// /// Returns a temporary output /// Stream GetTemporaryOutput(); /// /// Convert a temporary output stream to a final stream. /// /// The resulting final /// Stream ConvertTemporaryToFinal(); /// /// Make a temporary copy of the original stream. /// /// The to copy. /// Returns a temporary output that is a copy of the input. Stream MakeTemporaryCopy(Stream stream); /// /// Return a stream suitable for performing direct updates on the original source. /// /// The current stream. /// Returns a stream suitable for direct updating. /// This may be the current stream passed. Stream OpenForDirectUpdate(Stream stream); /// /// Dispose of this instance. /// void Dispose(); } /// /// An abstract suitable for extension by inheritance. /// abstract public class BaseArchiveStorage : IArchiveStorage { #region Constructors /// /// Initializes a new instance of the class. /// /// The update mode. public BaseArchiveStorage(FileUpdateMode updateMode) { updateMode_ = updateMode; } #endregion #region IArchiveStorage Members /// /// Gets a temporary output /// /// Returns the temporary output stream. /// public abstract Stream GetTemporaryOutput(); /// /// Converts the temporary to its final form. /// /// Returns a that can be used to read /// the final storage for the archive. /// public abstract Stream ConvertTemporaryToFinal(); /// /// Make a temporary copy of a . /// /// The to make a copy of. /// Returns a temporary output that is a copy of the input. public abstract Stream MakeTemporaryCopy(Stream stream); /// /// Return a stream suitable for performing direct updates on the original source. /// /// The to open for direct update. /// Returns a stream suitable for direct updating. public abstract Stream OpenForDirectUpdate(Stream stream); /// /// Disposes this instance. /// public abstract void Dispose(); /// /// Gets the update mode applicable. /// /// The update mode. public FileUpdateMode UpdateMode { get { return updateMode_; } } #endregion #region Instance Fields FileUpdateMode updateMode_; #endregion } /// /// An implementation suitable for hard disks. /// public class DiskArchiveStorage : BaseArchiveStorage { #region Constructors /// /// Initializes a new instance of the class. /// /// The file. /// The update mode. public DiskArchiveStorage(ZipFile file, FileUpdateMode updateMode) : base(updateMode) { if ( file.Name == null ) { throw new ZipException("Cant handle non file archives"); } fileName_ = file.Name; } /// /// Initializes a new instance of the class. /// /// The file. public DiskArchiveStorage(ZipFile file) : this(file, FileUpdateMode.Safe) { } #endregion #region IArchiveStorage Members /// /// Gets a temporary output for performing updates on. /// /// Returns the temporary output stream. public override Stream GetTemporaryOutput() { if ( temporaryName_ != null ) { temporaryName_ = GetTempFileName(temporaryName_, true); temporaryStream_ = File.OpenWrite(temporaryName_); } else { // Determine where to place files based on internal strategy. // Currently this is always done in system temp directory. temporaryName_ = Path.GetTempFileName(); temporaryStream_ = File.OpenWrite(temporaryName_); } return temporaryStream_; } /// /// Converts a temporary to its final form. /// /// Returns a that can be used to read /// the final storage for the archive. public override Stream ConvertTemporaryToFinal() { if ( temporaryStream_ == null ) { throw new ZipException("No temporary stream has been created"); } Stream result = null; string moveTempName = GetTempFileName(fileName_, false); bool newFileCreated = false; try { temporaryStream_.Close(); File.Move(fileName_, moveTempName); File.Move(temporaryName_, fileName_); newFileCreated = true; File.Delete(moveTempName); result = File.OpenRead(fileName_); } catch(Exception) { result = null; // Try to roll back changes... if ( !newFileCreated ) { File.Move(moveTempName, fileName_); File.Delete(temporaryName_); } throw; } return result; } /// /// Make a temporary copy of a stream. /// /// The to copy. /// Returns a temporary output that is a copy of the input. public override Stream MakeTemporaryCopy(Stream stream) { stream.Close(); temporaryName_ = GetTempFileName(fileName_, true); File.Copy(fileName_, temporaryName_, true); temporaryStream_ = new FileStream(temporaryName_, FileMode.Open, FileAccess.ReadWrite); return temporaryStream_; } /// /// Return a stream suitable for performing direct updates on the original source. /// /// The current stream. /// Returns a stream suitable for direct updating. /// If the stream is not null this is used as is. public override Stream OpenForDirectUpdate(Stream current) { Stream result; if ((current == null) || !current.CanWrite) { if (current != null) { current.Close(); } result = new FileStream(fileName_, FileMode.Open, FileAccess.ReadWrite); } else { result = current; } return result; } /// /// Disposes this instance. /// public override void Dispose() { if ( temporaryStream_ != null ) { temporaryStream_.Close(); } } #endregion #region Internal routines string GetTempFileName(string original, bool makeTempFile) { string result = null; if ( original == null ) { result = Path.GetTempFileName(); } else { int counter = 0; int suffixSeed = DateTime.Now.Second; while ( result == null ) { counter += 1; string newName = string.Format("{0}.{1}{2}.tmp", original, suffixSeed, counter); if ( !File.Exists(newName) ) { if ( makeTempFile) { try { // Try and create the file. using ( FileStream stream = File.Create(newName) ) { } result = newName; } catch { suffixSeed = DateTime.Now.Second; } } else { result = newName; } } } } return result; } #endregion #region Instance Fields Stream temporaryStream_; string fileName_; string temporaryName_; #endregion } /// /// An implementation suitable for in memory streams. /// public class MemoryArchiveStorage : BaseArchiveStorage { #region Constructors /// /// Initializes a new instance of the class. /// public MemoryArchiveStorage() : base(FileUpdateMode.Direct) { } /// /// Initializes a new instance of the class. /// /// The to use /// This constructor is for testing as memory streams dont really require safe mode. public MemoryArchiveStorage(FileUpdateMode updateMode) : base(updateMode) { } #endregion #region Properties /// /// Get the stream returned by if this was in fact called. /// public MemoryStream FinalStream { get { return finalStream_; } } #endregion #region IArchiveStorage Members /// /// Gets the temporary output /// /// Returns the temporary output stream. public override Stream GetTemporaryOutput() { temporaryStream_ = new MemoryStream(); return temporaryStream_; } /// /// Converts the temporary to its final form. /// /// Returns a that can be used to read /// the final storage for the archive. public override Stream ConvertTemporaryToFinal() { if ( temporaryStream_ == null ) { throw new ZipException("No temporary stream has been created"); } finalStream_ = new MemoryStream(temporaryStream_.ToArray()); return finalStream_; } /// /// Make a temporary copy of the original stream. /// /// The to copy. /// Returns a temporary output that is a copy of the input. public override Stream MakeTemporaryCopy(Stream stream) { temporaryStream_ = new MemoryStream(); stream.Position = 0; StreamUtils.Copy(stream, temporaryStream_, new byte[4096]); return temporaryStream_; } /// /// Return a stream suitable for performing direct updates on the original source. /// /// The original source stream /// Returns a stream suitable for direct updating. /// If the passed is not null this is used; /// otherwise a new is returned. public override Stream OpenForDirectUpdate(Stream stream) { Stream result; if ((stream == null) || !stream.CanWrite) { result = new MemoryStream(); if (stream != null) { stream.Position = 0; StreamUtils.Copy(stream, result, new byte[4096]); stream.Close(); } } else { result = stream; } return result; } /// /// Disposes this instance. /// public override void Dispose() { if ( temporaryStream_ != null ) { temporaryStream_.Close(); } } #endregion #region Instance Fields MemoryStream temporaryStream_; MemoryStream finalStream_; #endregion } #endregion } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/IEntryFactory.cs0000664000175000017500000000762110651200260023344 0ustar jtaylorjtaylor// IEntryFactory.cs // // Copyright 2006 John Reilly // // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using ICSharpCode.SharpZipLib.Core; namespace ICSharpCode.SharpZipLib.Zip { /// /// Defines factory methods for creating new values. /// public interface IEntryFactory { /// /// Create a for a file given its name /// /// The name of the file to create an entry for. /// Returns a file entry based on the passed. ZipEntry MakeFileEntry(string fileName); /// /// Create a for a file given its name /// /// The name of the file to create an entry for. /// If true get details from the file system if the file exists. /// Returns a file entry based on the passed. ZipEntry MakeFileEntry(string fileName, bool useFileSystem); /// /// Create a for a directory given its name /// /// The name of the directory to create an entry for. /// Returns a directory entry based on the passed. ZipEntry MakeDirectoryEntry(string directoryName); /// /// Create a for a directory given its name /// /// The name of the directory to create an entry for. /// If true get details from the file system for this directory if it exists. /// Returns a directory entry based on the passed. ZipEntry MakeDirectoryEntry(string directoryName, bool useFileSystem); /// /// Get/set the applicable. /// INameTransform NameTransform { get; set; } } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/ZipInputStream.cs0000664000175000017500000004662310670307032023553 0ustar jtaylorjtaylor// ZipInputStream.cs // // Copyright (C) 2001 Mike Krueger // Copyright (C) 2004 John Reilly // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using System.Text; using System.IO; using ICSharpCode.SharpZipLib.Checksums; using ICSharpCode.SharpZipLib.Zip.Compression; using ICSharpCode.SharpZipLib.Zip.Compression.Streams; #if !NETCF_1_0 using ICSharpCode.SharpZipLib.Encryption; #endif namespace ICSharpCode.SharpZipLib.Zip { /// /// This is an InflaterInputStream that reads the files baseInputStream an zip archive /// one after another. It has a special method to get the zip entry of /// the next file. The zip entry contains information about the file name /// size, compressed size, Crc, etc. /// It includes support for Stored and Deflated entries. ///
///
Author of the original java version : Jochen Hoenicke ///
/// /// This sample shows how to read a zip file /// /// using System; /// using System.Text; /// using System.IO; /// /// using ICSharpCode.SharpZipLib.Zip; /// /// class MainClass /// { /// public static void Main(string[] args) /// { /// using ( ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]))) { /// /// ZipEntry theEntry; /// while ((theEntry = s.GetNextEntry()) != null) { /// int size = 2048; /// byte[] data = new byte[2048]; /// /// Console.Write("Show contents (y/n) ?"); /// if (Console.ReadLine() == "y") { /// while (true) { /// size = s.Read(data, 0, data.Length); /// if (size > 0) { /// Console.Write(new ASCIIEncoding().GetString(data, 0, size)); /// } else { /// break; /// } /// } /// } /// } /// } /// } /// } /// /// public class ZipInputStream : InflaterInputStream { #region Instance Fields // Delegate for reading bytes from a stream. delegate int ReaderDelegate(byte[] b, int offset, int length); /// /// The current reader this instance. /// ReaderDelegate internalReader; Crc32 crc = new Crc32(); ZipEntry entry; long size; int method; int flags; string password; #endregion #region Constructors /// /// Creates a new Zip input stream, for reading a zip archive. /// /// The underlying providing data. public ZipInputStream(Stream baseInputStream) : base(baseInputStream, new Inflater(true)) { internalReader = new ReaderDelegate(ReadingNotAvailable); } #endregion /// /// Optional password used for encryption when non-null /// /// A password for all encrypted entries in this public string Password { get { return password; } set { password = value; } } /// /// Gets a value indicating if there is a current entry and it can be decompressed /// /// /// The entry can only be decompressed if the library supports the zip features required to extract it. /// See the ZipEntry Version property for more details. /// public bool CanDecompressEntry { get { return (entry != null) && entry.CanDecompress; } } /// /// Advances to the next entry in the archive /// /// /// The next entry in the archive or null if there are no more entries. /// /// /// If the previous entry is still open CloseEntry is called. /// /// /// Input stream is closed /// /// /// Password is not set, password is invalid, compression method is invalid, /// version required to extract is not supported /// public ZipEntry GetNextEntry() { if (crc == null) { throw new InvalidOperationException("Closed."); } if (entry != null) { CloseEntry(); } int header = inputBuffer.ReadLeInt(); if (header == ZipConstants.CentralHeaderSignature || header == ZipConstants.EndOfCentralDirectorySignature || header == ZipConstants.CentralHeaderDigitalSignature || header == ZipConstants.ArchiveExtraDataSignature || header == ZipConstants.Zip64CentralFileHeaderSignature) { // No more individual entries exist Close(); return null; } // -jr- 07-Dec-2003 Ignore spanning temporary signatures if found // Spanning signature is same as descriptor signature and is untested as yet. if ( (header == ZipConstants.SpanningTempSignature) || (header == ZipConstants.SpanningSignature) ) { header = inputBuffer.ReadLeInt(); } if (header != ZipConstants.LocalHeaderSignature) { throw new ZipException("Wrong Local header signature: 0x" + String.Format("{0:X}", header)); } short versionRequiredToExtract = (short)inputBuffer.ReadLeShort(); flags = inputBuffer.ReadLeShort(); method = inputBuffer.ReadLeShort(); uint dostime = (uint)inputBuffer.ReadLeInt(); int crc2 = inputBuffer.ReadLeInt(); csize = inputBuffer.ReadLeInt(); size = inputBuffer.ReadLeInt(); int nameLen = inputBuffer.ReadLeShort(); int extraLen = inputBuffer.ReadLeShort(); bool isCrypted = (flags & 1) == 1; byte[] buffer = new byte[nameLen]; inputBuffer.ReadRawBuffer(buffer); string name = ZipConstants.ConvertToStringExt(flags, buffer); entry = new ZipEntry(name, versionRequiredToExtract); entry.Flags = flags; entry.CompressionMethod = (CompressionMethod)method; if ((flags & 8) == 0) { entry.Crc = crc2 & 0xFFFFFFFFL; entry.Size = size & 0xFFFFFFFFL; entry.CompressedSize = csize & 0xFFFFFFFFL; entry.CryptoCheckValue = (byte)((crc2 >> 24) & 0xff); } else { // This allows for GNU, WinZip and possibly other archives, the PKZIP spec // says these values are zero under these circumstances. if (crc2 != 0) { entry.Crc = crc2 & 0xFFFFFFFFL; } if (size != 0) { entry.Size = size & 0xFFFFFFFFL; } if (csize != 0) { entry.CompressedSize = csize & 0xFFFFFFFFL; } entry.CryptoCheckValue = (byte)((dostime >> 8) & 0xff); } entry.DosTime = dostime; // If local header requires Zip64 is true then the extended header should contain // both values. // Handle extra data if present. This can set/alter some fields of the entry. if (extraLen > 0) { byte[] extra = new byte[extraLen]; inputBuffer.ReadRawBuffer(extra); entry.ExtraData = extra; } entry.ProcessExtraData(true); if ( entry.CompressedSize >= 0 ) { csize = entry.CompressedSize; } if ( entry.Size >= 0 ) { size = entry.Size; } if (method == (int)CompressionMethod.Stored && (!isCrypted && csize != size || (isCrypted && csize - ZipConstants.CryptoHeaderSize != size))) { throw new ZipException("Stored, but compressed != uncompressed"); } // Determine how to handle reading of data if this is attempted. if (entry.IsCompressionMethodSupported()) { internalReader = new ReaderDelegate(InitialRead); } else { internalReader = new ReaderDelegate(ReadingNotSupported); } return entry; } /// /// Read data descriptor at the end of compressed data. /// void ReadDataDescriptor() { if (inputBuffer.ReadLeInt() != ZipConstants.DataDescriptorSignature) { throw new ZipException("Data descriptor signature not found"); } entry.Crc = inputBuffer.ReadLeInt() & 0xFFFFFFFFL; if ( entry.LocalHeaderRequiresZip64 ) { csize = inputBuffer.ReadLeLong(); size = inputBuffer.ReadLeLong(); } else { csize = inputBuffer.ReadLeInt(); size = inputBuffer.ReadLeInt(); } entry.CompressedSize = csize; entry.Size = size; } /// /// Complete cleanup as the final part of closing. /// /// True if the crc value should be tested void CompleteCloseEntry(bool testCrc) { StopDecrypting(); if ((flags & 8) != 0) { ReadDataDescriptor(); } size = 0; if ( testCrc && ((crc.Value & 0xFFFFFFFFL) != entry.Crc) && (entry.Crc != -1)) { throw new ZipException("CRC mismatch"); } crc.Reset(); if (method == (int)CompressionMethod.Deflated) { inf.Reset(); } entry = null; } /// /// Closes the current zip entry and moves to the next one. /// /// /// The stream is closed /// /// /// The Zip stream ends early /// public void CloseEntry() { if (crc == null) { throw new InvalidOperationException("Closed"); } if (entry == null) { return; } if (method == (int)CompressionMethod.Deflated) { if ((flags & 8) != 0) { // We don't know how much we must skip, read until end. byte[] tmp = new byte[2048]; // Read will close this entry while (Read(tmp, 0, tmp.Length) > 0) { } return; } csize -= inf.TotalIn; inputBuffer.Available += inf.RemainingInput; } if ( (inputBuffer.Available > csize) && (csize >= 0) ) { inputBuffer.Available = (int)((long)inputBuffer.Available - csize); } else { csize -= inputBuffer.Available; inputBuffer.Available = 0; while (csize != 0) { int skipped = (int)base.Skip(csize & 0xFFFFFFFFL); if (skipped <= 0) { throw new ZipException("Zip archive ends early."); } csize -= skipped; } } CompleteCloseEntry(false); } /// /// Returns 1 if there is an entry available /// Otherwise returns 0. /// public override int Available { get { return entry != null ? 1 : 0; } } /// /// Returns the current size that can be read from the current entry if available /// /// Thrown if the entry size is not known. /// Thrown if no entry is currently available. public override long Length { get { if ( entry != null ) { if ( entry.Size >= 0 ) { return entry.Size; } else { throw new ZipException("Length not available for the current entry"); } } else { throw new InvalidOperationException("No current entry"); } } } /// /// Reads a byte from the current zip entry. /// /// /// The byte or -1 if end of stream is reached. /// public override int ReadByte() { byte[] b = new byte[1]; if (Read(b, 0, 1) <= 0) { return -1; } return b[0] & 0xff; } /// /// Handle attempts to read by throwing an . /// /// The destination array to store data in. /// The offset at which data read should be stored. /// The maximum number of bytes to read. /// Returns the number of bytes actually read. int ReadingNotAvailable(byte[] destination, int offset, int count) { throw new InvalidOperationException("Unable to read from this stream"); } /// /// Handle attempts to read from this entry by throwing an exception /// int ReadingNotSupported(byte[] destination, int offset, int count) { throw new ZipException("The compression method for this entry is not supported"); } /// /// Perform the initial read on an entry which may include /// reading encryption headers and setting up inflation. /// /// The destination to fill with data read. /// The offset to start reading at. /// The maximum number of bytes to read. /// The actual number of bytes read. int InitialRead(byte[] destination, int offset, int count) { if ( !CanDecompressEntry ) { throw new ZipException("Library cannot extract this entry. Version required is (" + entry.Version.ToString() + ")"); } // Handle encryption if required. if (entry.IsCrypted) { #if NETCF_1_0 throw new ZipException("Encryption not supported for Compact Framework 1.0"); #else if (password == null) { throw new ZipException("No password set."); } // Generate and set crypto transform... PkzipClassicManaged managed = new PkzipClassicManaged(); byte[] key = PkzipClassic.GenerateKeys(ZipConstants.ConvertToArray(password)); inputBuffer.CryptoTransform = managed.CreateDecryptor(key, null); byte[] cryptbuffer = new byte[ZipConstants.CryptoHeaderSize]; inputBuffer.ReadClearTextBuffer(cryptbuffer, 0, ZipConstants.CryptoHeaderSize); if (cryptbuffer[ZipConstants.CryptoHeaderSize - 1] != entry.CryptoCheckValue) { throw new ZipException("Invalid password"); } if (csize >= ZipConstants.CryptoHeaderSize) { csize -= ZipConstants.CryptoHeaderSize; } else if ( (entry.Flags & (int)GeneralBitFlags.Descriptor) == 0 ) { throw new ZipException(string.Format("Entry compressed size {0} too small for encryption", csize)); } #endif } else { #if !NETCF_1_0 inputBuffer.CryptoTransform = null; #endif } if ( (method == (int)CompressionMethod.Deflated) && (inputBuffer.Available > 0) ) { inputBuffer.SetInflaterInput(inf); } internalReader = new ReaderDelegate(BodyRead); return BodyRead(destination, offset, count); } /// /// Read a block of bytes from the stream. /// /// The destination for the bytes. /// The index to start storing data. /// The number of bytes to attempt to read. /// Returns the number of bytes read. /// Zero bytes read means end of stream. public override int Read(byte[] buffer, int offset, int count) { if ( buffer == null ) { throw new ArgumentNullException("buffer"); } if ( offset < 0 ) { #if NETCF_1_0 throw new ArgumentOutOfRangeException("offset"); #else throw new ArgumentOutOfRangeException("offset", "Cannot be negative"); #endif } if ( count < 0 ) { #if NETCF_1_0 throw new ArgumentOutOfRangeException("count"); #else throw new ArgumentOutOfRangeException("count", "Cannot be negative"); #endif } if ( (buffer.Length - offset) < count ) { throw new ArgumentException("Invalid offset/count combination"); } return internalReader(buffer, offset, count); } /// /// Reads a block of bytes from the current zip entry. /// /// /// The number of bytes read (this may be less than the length requested, even before the end of stream), or 0 on end of stream. /// /// /// An i/o error occured. /// /// /// The deflated stream is corrupted. /// /// /// The stream is not open. /// int BodyRead(byte[] buffer, int offset, int count) { if ( crc == null ) { throw new InvalidOperationException("Closed"); } if ( (entry == null) || (count <= 0) ) { return 0; } if ( offset + count > buffer.Length ) { throw new ArgumentException("Offset + count exceeds buffer size"); } bool finished = false; switch (method) { case (int)CompressionMethod.Deflated: count = base.Read(buffer, offset, count); if (count <= 0) { if (!inf.IsFinished) { throw new ZipException("Inflater not finished!"); } inputBuffer.Available = inf.RemainingInput; if ((flags & 8) == 0 && (inf.TotalIn != csize || inf.TotalOut != size)) { throw new ZipException("Size mismatch: " + csize + ";" + size + " <-> " + inf.TotalIn + ";" + inf.TotalOut); } inf.Reset(); finished = true; } break; case (int)CompressionMethod.Stored: if ( (count > csize) && (csize >= 0) ) { count = (int)csize; } if ( count > 0 ) { count = inputBuffer.ReadClearTextBuffer(buffer, offset, count); if (count > 0) { csize -= count; size -= count; } } if (csize == 0) { finished = true; } else { if (count < 0) { throw new ZipException("EOF in stored block"); } } break; } if (count > 0) { crc.Update(buffer, offset, count); } if (finished) { CompleteCloseEntry(true); } return count; } /// /// Closes the zip input stream /// public override void Close() { internalReader = new ReaderDelegate(ReadingNotAvailable); crc = null; entry = null; base.Close(); } } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/ZipHelperStream.cs0000664000175000017500000004307210653164004023667 0ustar jtaylorjtaylor// ZipHelperStream.cs // // Copyright 2006, 2007 John Reilly // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using System.IO; using System.Text; namespace ICSharpCode.SharpZipLib.Zip { /// /// Holds data pertinent to a data descriptor. /// public class DescriptorData { /// /// Get /set the compressed size of data. /// public long CompressedSize { get { return compressedSize; } set { compressedSize = value; } } /// /// Get / set the uncompressed size of data /// public long Size { get { return size; } set { size = value; } } /// /// Get /set the crc value. /// public long Crc { get { return crc; } set { crc = (value & 0xffffffff); } } #region Instance Fields long size; long compressedSize; long crc; #endregion } class EntryPatchData { public long SizePatchOffset { get { return sizePatchOffset_; } set { sizePatchOffset_ = value; } } public long CrcPatchOffset { get { return crcPatchOffset_; } set { crcPatchOffset_ = value; } } #region Instance Fields long sizePatchOffset_; long crcPatchOffset_; #endregion } /// /// This class assists with writing/reading from Zip files. /// internal class ZipHelperStream : Stream { #region Constructors /// /// Initialise an instance of this class. /// /// The name of the file to open. public ZipHelperStream(string name) { stream_ = new FileStream(name, FileMode.Open, FileAccess.ReadWrite); isOwner_ = true; } /// /// Initialise a new instance of . /// /// The stream to use. public ZipHelperStream(Stream stream) { stream_ = stream; } #endregion /// /// Get / set a value indicating wether the the underlying stream is owned or not. /// /// If the stream is owned it is closed when this instance is closed. public bool IsStreamOwner { get { return isOwner_; } set { isOwner_ = value; } } #region Base Stream Methods public override bool CanRead { get { return stream_.CanRead; } } public override bool CanSeek { get { return stream_.CanSeek; } } #if !NET_1_0 && !NET_1_1 && !NETCF_1_0 public override bool CanTimeout { get { return stream_.CanTimeout; } } #endif public override long Length { get { return stream_.Length; } } public override long Position { get { return stream_.Position; } set { stream_.Position = value; } } public override bool CanWrite { get { return stream_.CanWrite; } } public override void Flush() { stream_.Flush(); } public override long Seek(long offset, SeekOrigin origin) { return stream_.Seek(offset, origin); } public override void SetLength(long value) { stream_.SetLength(value); } public override int Read(byte[] buffer, int offset, int count) { return stream_.Read(buffer, offset, count); } public override void Write(byte[] buffer, int offset, int count) { stream_.Write(buffer, offset, count); } /// /// Close the stream. /// /// /// The underlying stream is closed only if is true. /// override public void Close() { Stream toClose = stream_; stream_ = null; if (isOwner_ && (toClose != null)) { isOwner_ = false; toClose.Close(); } } #endregion // Write the local file header // TODO: ZipHelperStream.WriteLocalHeader is not yet used and needs checking for ZipFile and ZipOuptutStream usage void WriteLocalHeader(ZipEntry entry, EntryPatchData patchData) { CompressionMethod method = entry.CompressionMethod; bool headerInfoAvailable = true; // How to get this? bool patchEntryHeader = false; WriteLEInt(ZipConstants.LocalHeaderSignature); WriteLEShort(entry.Version); WriteLEShort(entry.Flags); WriteLEShort((byte)method); WriteLEInt((int)entry.DosTime); if (headerInfoAvailable == true) { WriteLEInt((int)entry.Crc); if ( entry.LocalHeaderRequiresZip64 ) { WriteLEInt(-1); WriteLEInt(-1); } else { WriteLEInt(entry.IsCrypted ? (int)entry.CompressedSize + ZipConstants.CryptoHeaderSize : (int)entry.CompressedSize); WriteLEInt((int)entry.Size); } } else { if (patchData != null) { patchData.CrcPatchOffset = stream_.Position; } WriteLEInt(0); // Crc if ( patchData != null ) { patchData.SizePatchOffset = stream_.Position; } // For local header both sizes appear in Zip64 Extended Information if ( entry.LocalHeaderRequiresZip64 && patchEntryHeader ) { WriteLEInt(-1); WriteLEInt(-1); } else { WriteLEInt(0); // Compressed size WriteLEInt(0); // Uncompressed size } } byte[] name = ZipConstants.ConvertToArray(entry.Flags, entry.Name); if (name.Length > 0xFFFF) { throw new ZipException("Entry name too long."); } ZipExtraData ed = new ZipExtraData(entry.ExtraData); if (entry.LocalHeaderRequiresZip64 && (headerInfoAvailable || patchEntryHeader)) { ed.StartNewEntry(); if (headerInfoAvailable) { ed.AddLeLong(entry.Size); ed.AddLeLong(entry.CompressedSize); } else { ed.AddLeLong(-1); ed.AddLeLong(-1); } ed.AddNewEntry(1); if ( !ed.Find(1) ) { throw new ZipException("Internal error cant find extra data"); } if ( patchData != null ) { patchData.SizePatchOffset = ed.CurrentReadIndex; } } else { ed.Delete(1); } byte[] extra = ed.GetEntryData(); WriteLEShort(name.Length); WriteLEShort(extra.Length); if ( name.Length > 0 ) { stream_.Write(name, 0, name.Length); } if ( entry.LocalHeaderRequiresZip64 && patchEntryHeader ) { patchData.SizePatchOffset += stream_.Position; } if ( extra.Length > 0 ) { stream_.Write(extra, 0, extra.Length); } } /// /// Locates a block with the desired . /// /// The signature to find. /// Location, marking the end of block. /// Minimum size of the block. /// The maximum variable data. /// Eeturns the offset of the first byte after the signature; -1 if not found public long LocateBlockWithSignature(int signature, long endLocation, int minimumBlockSize, int maximumVariableData) { long pos = endLocation - minimumBlockSize; if ( pos < 0 ) { return -1; } long giveUpMarker = Math.Max(pos - maximumVariableData, 0); // TODO: This loop could be optimised for speed. do { if ( pos < giveUpMarker ) { return -1; } Seek(pos--, SeekOrigin.Begin); } while ( ReadLEInt() != signature ); return Position; } /// /// Write Zip64 end of central directory records (File header and locator). /// /// The number of entries in the central directory. /// The size of entries in the central directory. /// The offset of the dentral directory. public void WriteZip64EndOfCentralDirectory(long noOfEntries, long sizeEntries, long centralDirOffset) { long centralSignatureOffset = stream_.Position; WriteLEInt(ZipConstants.Zip64CentralFileHeaderSignature); WriteLELong(44); // Size of this record (total size of remaining fields in header or full size - 12) WriteLEShort(ZipConstants.VersionMadeBy); // Version made by WriteLEShort(ZipConstants.VersionZip64); // Version to extract WriteLEInt(0); // Number of this disk WriteLEInt(0); // number of the disk with the start of the central directory WriteLELong(noOfEntries); // No of entries on this disk WriteLELong(noOfEntries); // Total No of entries in central directory WriteLELong(sizeEntries); // Size of the central directory WriteLELong(centralDirOffset); // offset of start of central directory // zip64 extensible data sector not catered for here (variable size) // Write the Zip64 end of central directory locator WriteLEInt(ZipConstants.Zip64CentralDirLocatorSignature); // no of the disk with the start of the zip64 end of central directory WriteLEInt(0); // relative offset of the zip64 end of central directory record WriteLELong(centralSignatureOffset); // total number of disks WriteLEInt(1); } /// /// Write the required records to end the central directory. /// /// The number of entries in the directory. /// The size of the entries in the directory. /// The start of the central directory. /// The archive comment. (This can be null). public void WriteEndOfCentralDirectory(long noOfEntries, long sizeEntries, long startOfCentralDirectory, byte[] comment) { if ( (noOfEntries >= 0xffff) || (startOfCentralDirectory >= 0xffffffff) || (sizeEntries >= 0xffffffff) ) { WriteZip64EndOfCentralDirectory(noOfEntries, sizeEntries, startOfCentralDirectory); } WriteLEInt(ZipConstants.EndOfCentralDirectorySignature); // TODO: ZipFile Multi disk handling not done WriteLEShort(0); // number of this disk WriteLEShort(0); // no of disk with start of central dir // Number of entries if ( noOfEntries >= 0xffff ) { WriteLEUshort(0xffff); // Zip64 marker WriteLEUshort(0xffff); } else { WriteLEShort(( short )noOfEntries); // entries in central dir for this disk WriteLEShort(( short )noOfEntries); // total entries in central directory } // Size of the central directory if ( sizeEntries >= 0xffffffff ) { WriteLEUint(0xffffffff); // Zip64 marker } else { WriteLEInt(( int )sizeEntries); } // offset of start of central directory if ( startOfCentralDirectory >= 0xffffffff ) { WriteLEUint(0xffffffff); // Zip64 marker } else { WriteLEInt(( int )startOfCentralDirectory); } int commentLength = (comment != null) ? comment.Length : 0; if ( commentLength > 0xffff ) { throw new ZipException(string.Format("Comment length({0}) is too long can only be 64K", commentLength)); } WriteLEShort(commentLength); if ( commentLength > 0 ) { Write(comment, 0, comment.Length); } } #region LE value reading/writing /// /// Read an unsigned short in little endian byte order. /// /// Returns the value read. /// /// An i/o error occurs. /// /// /// The file ends prematurely /// public int ReadLEShort() { int byteValue1 = stream_.ReadByte(); if (byteValue1 < 0) { throw new EndOfStreamException(); } int byteValue2 = stream_.ReadByte(); if (byteValue2 < 0) { throw new EndOfStreamException(); } return byteValue1 | (byteValue2 << 8); } /// /// Read an int in little endian byte order. /// /// Returns the value read. /// /// An i/o error occurs. /// /// /// The file ends prematurely /// public int ReadLEInt() { return ReadLEShort() | (ReadLEShort() << 16); } /// /// Read a long in little endian byte order. /// /// The value read. public long ReadLELong() { return (uint)ReadLEInt() | ((long)ReadLEInt() << 32); } /// /// Write an unsigned short in little endian byte order. /// /// The value to write. public void WriteLEShort(int value) { stream_.WriteByte(( byte )(value & 0xff)); stream_.WriteByte(( byte )((value >> 8) & 0xff)); } /// /// Write a ushort in little endian byte order. /// /// The value to write. public void WriteLEUshort(ushort value) { stream_.WriteByte(( byte )(value & 0xff)); stream_.WriteByte(( byte )(value >> 8)); } /// /// Write an int in little endian byte order. /// /// The value to write. public void WriteLEInt(int value) { WriteLEShort(value); WriteLEShort(value >> 16); } /// /// Write a uint in little endian byte order. /// /// The value to write. public void WriteLEUint(uint value) { WriteLEUshort(( ushort )(value & 0xffff)); WriteLEUshort(( ushort )(value >> 16)); } /// /// Write a long in little endian byte order. /// /// The value to write. public void WriteLELong(long value) { WriteLEInt(( int )value); WriteLEInt(( int )(value >> 32)); } /// /// Write a ulong in little endian byte order. /// /// The value to write. public void WriteLEUlong(ulong value) { WriteLEUint(( uint )(value & 0xffffffff)); WriteLEUint(( uint )(value >> 32)); } #endregion /// /// Write a data descriptor. /// /// The entry to write a descriptor for. /// Returns the number of descriptor bytes written. public int WriteDataDescriptor(ZipEntry entry) { if (entry == null) { throw new ArgumentNullException("entry"); } int result=0; // Add data descriptor if flagged as required if ((entry.Flags & (int)GeneralBitFlags.Descriptor) != 0) { // The signature is not PKZIP originally but is now described as optional // in the PKZIP Appnote documenting trhe format. WriteLEInt(ZipConstants.DataDescriptorSignature); WriteLEInt(unchecked((int)(entry.Crc))); result+=8; if (entry.LocalHeaderRequiresZip64) { WriteLELong(entry.CompressedSize); WriteLELong(entry.Size); result+=16; } else { WriteLEInt((int)entry.CompressedSize); WriteLEInt((int)entry.Size); result+=8; } } return result; } /// /// Read data descriptor at the end of compressed data. /// /// if set to true [zip64]. /// The data to fill in. /// Returns the number of bytes read in the descriptor. public void ReadDataDescriptor(bool zip64, DescriptorData data) { int intValue = ReadLEInt(); // In theory this may not be a descriptor according to PKZIP appnote. // In practise its always there. if (intValue != ZipConstants.DataDescriptorSignature) { throw new ZipException("Data descriptor signature not found"); } data.Crc = ReadLEInt(); if (zip64) { data.CompressedSize = ReadLELong(); data.Size = ReadLELong(); } else { data.CompressedSize = ReadLEInt(); data.Size = ReadLEInt(); } } #region Instance Fields bool isOwner_; Stream stream_; #endregion } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/ZipOutputStream.cs0000664000175000017500000005735710670311516023764 0ustar jtaylorjtaylor// ZipOutputStream.cs // // Copyright (C) 2001 Mike Krueger // Copyright (C) 2004 John Reilly // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using System.IO; using System.Collections; using System.Text; using ICSharpCode.SharpZipLib.Checksums; using ICSharpCode.SharpZipLib.Zip.Compression; using ICSharpCode.SharpZipLib.Zip.Compression.Streams; namespace ICSharpCode.SharpZipLib.Zip { /// /// This is a DeflaterOutputStream that writes the files into a zip /// archive one after another. It has a special method to start a new /// zip entry. The zip entries contains information about the file name /// size, compressed size, CRC, etc. /// /// It includes support for Stored and Deflated entries. /// This class is not thread safe. ///
///
Author of the original java version : Jochen Hoenicke ///
/// This sample shows how to create a zip file /// /// using System; /// using System.IO; /// /// using ICSharpCode.SharpZipLib.Core; /// using ICSharpCode.SharpZipLib.Zip; /// /// class MainClass /// { /// public static void Main(string[] args) /// { /// string[] filenames = Directory.GetFiles(args[0]); /// byte[] buffer = new byte[4096]; /// /// using ( ZipOutputStream s = new ZipOutputStream(File.Create(args[1])) ) { /// /// s.SetLevel(9); // 0 - store only to 9 - means best compression /// /// foreach (string file in filenames) { /// ZipEntry entry = new ZipEntry(file); /// s.PutNextEntry(entry); /// /// using (FileStream fs = File.OpenRead(file)) { /// StreamUtils.Copy(fs, s, buffer); /// } /// } /// } /// } /// } /// /// public class ZipOutputStream : DeflaterOutputStream { #region Constructors /// /// Creates a new Zip output stream, writing a zip archive. /// /// /// The output stream to which the archive contents are written. /// public ZipOutputStream(Stream baseOutputStream) : base(baseOutputStream, new Deflater(Deflater.DEFAULT_COMPRESSION, true)) { } #endregion /// /// Gets a flag value of true if the central header has been added for this archive; false if it has not been added. /// /// No further entries can be added once this has been done. public bool IsFinished { get { return entries == null; } } /// /// Set the zip file comment. /// /// /// The comment text for the entire archive. /// /// /// The converted comment is longer than 0xffff bytes. /// public void SetComment(string comment) { // TODO: Its not yet clear how to handle unicode comments here. byte[] commentBytes = ZipConstants.ConvertToArray(comment); if (commentBytes.Length > 0xffff) { throw new ArgumentOutOfRangeException("comment"); } zipComment = commentBytes; } /// /// Sets the compression level. The new level will be activated /// immediately. /// /// The new compression level (1 to 9). /// /// Level specified is not supported. /// /// public void SetLevel(int level) { deflater_.SetLevel(level); defaultCompressionLevel = level; } /// /// Get the current deflater compression level /// /// The current compression level public int GetLevel() { return deflater_.GetLevel(); } /// /// Get / set a value indicating how Zip64 Extension usage is determined when adding entries. /// /// Older archivers may not understand Zip64 extensions. /// If backwards compatability is an issue be careful when adding entries to an archive. /// Setting this property to off is workable but less desirable as in those circumstances adding a file /// larger then 4GB will fail. public UseZip64 UseZip64 { get { return useZip64_; } set { useZip64_ = value; } } /// /// Write an unsigned short in little endian byte order. /// private void WriteLeShort(int value) { unchecked { baseOutputStream_.WriteByte((byte)(value & 0xff)); baseOutputStream_.WriteByte((byte)((value >> 8) & 0xff)); } } /// /// Write an int in little endian byte order. /// private void WriteLeInt(int value) { unchecked { WriteLeShort(value); WriteLeShort(value >> 16); } } /// /// Write an int in little endian byte order. /// private void WriteLeLong(long value) { unchecked { WriteLeInt((int)value); WriteLeInt((int)(value >> 32)); } } /// /// Starts a new Zip entry. It automatically closes the previous /// entry if present. /// All entry elements bar name are optional, but must be correct if present. /// If the compression method is stored and the output is not patchable /// the compression for that entry is automatically changed to deflate level 0 /// /// /// the entry. /// /// /// if entry passed is null. /// /// /// if an I/O error occured. /// /// /// if stream was finished /// /// /// Too many entries in the Zip file
/// Entry name is too long
/// Finish has already been called
///
public void PutNextEntry(ZipEntry entry) { if ( entry == null ) { throw new ArgumentNullException("entry"); } if (entries == null) { throw new InvalidOperationException("ZipOutputStream was finished"); } if (curEntry != null) { CloseEntry(); } if (entries.Count == int.MaxValue) { throw new ZipException("Too many entries for Zip file"); } CompressionMethod method = entry.CompressionMethod; int compressionLevel = defaultCompressionLevel; // Clear flags that the library manages internally entry.Flags &= (int)GeneralBitFlags.UnicodeText; patchEntryHeader = false; bool headerInfoAvailable = true; if (method == CompressionMethod.Stored) { // Cant store values in a data descriptor as you cant extract stored files // if the length isnt known. entry.Flags &= ~8; if (entry.CompressedSize >= 0) { if (entry.Size < 0) { entry.Size = entry.CompressedSize; } else if (entry.Size != entry.CompressedSize) { throw new ZipException("Method STORED, but compressed size != size"); } } else { if (entry.Size >= 0) { entry.CompressedSize = entry.Size; } } if (entry.Size < 0 || entry.Crc < 0) { if (CanPatchEntries == true) { headerInfoAvailable = false; } else { // Can't patch entries so storing is not possible. method = CompressionMethod.Deflated; compressionLevel = 0; } } } if (method == CompressionMethod.Deflated) { if (entry.Size == 0) { // No need to compress - no data. entry.CompressedSize = entry.Size; entry.Crc = 0; method = CompressionMethod.Stored; } else if ( (entry.CompressedSize < 0) || (entry.Size < 0) || (entry.Crc < 0) ) { headerInfoAvailable = false; } } if (headerInfoAvailable == false) { if (CanPatchEntries == false) { // Only way to record size and compressed size is to append a data descriptor // after compressed data. entry.Flags |= 8; } else { patchEntryHeader = true; } } if (Password != null) { entry.IsCrypted = true; if (entry.Crc < 0) { // Need to append a data descriptor as the crc isnt available for use // with encryption, the date is used instead. Setting the flag // indicates this to the decompressor. entry.Flags |= 8; } } entry.Offset = offset; entry.CompressionMethod = (CompressionMethod)method; curMethod = method; sizePatchPos = -1; if ( (useZip64_ == UseZip64.On) || ((entry.Size < 0) && (useZip64_ == UseZip64.Dynamic)) ) { entry.ForceZip64(); } // Write the local file header WriteLeInt(ZipConstants.LocalHeaderSignature); WriteLeShort(entry.Version); WriteLeShort(entry.Flags); WriteLeShort((byte)method); WriteLeInt((int)entry.DosTime); // TODO: Refactor header writing. Its done in several places. if (headerInfoAvailable == true) { WriteLeInt((int)entry.Crc); if ( entry.LocalHeaderRequiresZip64 ) { WriteLeInt(-1); WriteLeInt(-1); } else { WriteLeInt(entry.IsCrypted ? (int)entry.CompressedSize + ZipConstants.CryptoHeaderSize : (int)entry.CompressedSize); WriteLeInt((int)entry.Size); } } else { if (patchEntryHeader == true) { crcPatchPos = baseOutputStream_.Position; } WriteLeInt(0); // Crc if ( patchEntryHeader ) { sizePatchPos = baseOutputStream_.Position; } // For local header both sizes appear in Zip64 Extended Information if ( entry.LocalHeaderRequiresZip64 && patchEntryHeader ) { WriteLeInt(-1); WriteLeInt(-1); } else { WriteLeInt(0); // Compressed size WriteLeInt(0); // Uncompressed size } } byte[] name = ZipConstants.ConvertToArray(entry.Flags, entry.Name); if (name.Length > 0xFFFF) { throw new ZipException("Entry name too long."); } ZipExtraData ed = new ZipExtraData(entry.ExtraData); if (entry.LocalHeaderRequiresZip64 && (headerInfoAvailable || patchEntryHeader)) { ed.StartNewEntry(); if (headerInfoAvailable) { ed.AddLeLong(entry.Size); ed.AddLeLong(entry.CompressedSize); } else { ed.AddLeLong(-1); ed.AddLeLong(-1); } ed.AddNewEntry(1); if ( !ed.Find(1) ) { throw new ZipException("Internal error cant find extra data"); } if ( patchEntryHeader ) { sizePatchPos = ed.CurrentReadIndex; } } else { ed.Delete(1); } byte[] extra = ed.GetEntryData(); WriteLeShort(name.Length); WriteLeShort(extra.Length); if ( name.Length > 0 ) { baseOutputStream_.Write(name, 0, name.Length); } if ( entry.LocalHeaderRequiresZip64 && patchEntryHeader ) { sizePatchPos += baseOutputStream_.Position; } if ( extra.Length > 0 ) { baseOutputStream_.Write(extra, 0, extra.Length); } offset += ZipConstants.LocalHeaderBaseSize + name.Length + extra.Length; // Activate the entry. curEntry = entry; crc.Reset(); if (method == CompressionMethod.Deflated) { deflater_.Reset(); deflater_.SetLevel(compressionLevel); } size = 0; if (entry.IsCrypted == true) { if (entry.Crc < 0) { // so testing Zip will says its ok WriteEncryptionHeader(entry.DosTime << 16); } else { WriteEncryptionHeader(entry.Crc); } } } /// /// Closes the current entry, updating header and footer information as required /// /// /// An I/O error occurs. /// /// /// No entry is active. /// public void CloseEntry() { if (curEntry == null) { throw new InvalidOperationException("No open entry"); } // First finish the deflater, if appropriate if (curMethod == CompressionMethod.Deflated) { base.Finish(); } long csize = (curMethod == CompressionMethod.Deflated) ? deflater_.TotalOut : size; if (curEntry.Size < 0) { curEntry.Size = size; } else if (curEntry.Size != size) { throw new ZipException("size was " + size + ", but I expected " + curEntry.Size); } if (curEntry.CompressedSize < 0) { curEntry.CompressedSize = csize; } else if (curEntry.CompressedSize != csize) { throw new ZipException("compressed size was " + csize + ", but I expected " + curEntry.CompressedSize); } if (curEntry.Crc < 0) { curEntry.Crc = crc.Value; } else if (curEntry.Crc != crc.Value) { throw new ZipException("crc was " + crc.Value + ", but I expected " + curEntry.Crc); } offset += csize; if (curEntry.IsCrypted == true) { curEntry.CompressedSize += ZipConstants.CryptoHeaderSize; } // Patch the header if possible if (patchEntryHeader == true) { patchEntryHeader = false; long curPos = baseOutputStream_.Position; baseOutputStream_.Seek(crcPatchPos, SeekOrigin.Begin); WriteLeInt((int)curEntry.Crc); if ( curEntry.LocalHeaderRequiresZip64 ) { if ( sizePatchPos == -1 ) { throw new ZipException("Entry requires zip64 but this has been turned off"); } baseOutputStream_.Seek(sizePatchPos, SeekOrigin.Begin); WriteLeLong(curEntry.Size); WriteLeLong(curEntry.CompressedSize); } else { WriteLeInt((int)curEntry.CompressedSize); WriteLeInt((int)curEntry.Size); } baseOutputStream_.Seek(curPos, SeekOrigin.Begin); } // Add data descriptor if flagged as required if ((curEntry.Flags & 8) != 0) { WriteLeInt(ZipConstants.DataDescriptorSignature); WriteLeInt(unchecked((int)curEntry.Crc)); if ( curEntry.LocalHeaderRequiresZip64 ) { WriteLeLong(curEntry.CompressedSize); WriteLeLong(curEntry.Size); offset += ZipConstants.Zip64DataDescriptorSize; } else { WriteLeInt((int)curEntry.CompressedSize); WriteLeInt((int)curEntry.Size); offset += ZipConstants.DataDescriptorSize; } } entries.Add(curEntry); curEntry = null; } void WriteEncryptionHeader(long crcValue) { offset += ZipConstants.CryptoHeaderSize; InitializePassword(Password); byte[] cryptBuffer = new byte[ZipConstants.CryptoHeaderSize]; Random rnd = new Random(); rnd.NextBytes(cryptBuffer); cryptBuffer[11] = (byte)(crcValue >> 24); EncryptBlock(cryptBuffer, 0, cryptBuffer.Length); baseOutputStream_.Write(cryptBuffer, 0, cryptBuffer.Length); } /// /// Writes the given buffer to the current entry. /// /// The buffer containing data to write. /// The offset of the first byte to write. /// The number of bytes to write. /// Archive size is invalid /// No entry is active. public override void Write(byte[] buffer, int offset, int count) { if (curEntry == null) { throw new InvalidOperationException("No open entry."); } if ( buffer == null ) { throw new ArgumentNullException("buffer"); } if ( offset < 0 ) { #if NETCF_1_0 throw new ArgumentOutOfRangeException("offset"); #else throw new ArgumentOutOfRangeException("offset", "Cannot be negative"); #endif } if ( count < 0 ) { #if NETCF_1_0 throw new ArgumentOutOfRangeException("count"); #else throw new ArgumentOutOfRangeException("count", "Cannot be negative"); #endif } if ( (buffer.Length - offset) < count ) { throw new ArgumentException("Invalid offset/count combination"); } crc.Update(buffer, offset, count); size += count; switch (curMethod) { case CompressionMethod.Deflated: base.Write(buffer, offset, count); break; case CompressionMethod.Stored: if (Password != null) { CopyAndEncrypt(buffer, offset, count); } else { baseOutputStream_.Write(buffer, offset, count); } break; } } void CopyAndEncrypt(byte[] buffer, int offset, int count) { const int CopyBufferSize = 4096; byte[] localBuffer = new byte[CopyBufferSize]; while ( count > 0 ) { int bufferCount = (count < CopyBufferSize) ? count : CopyBufferSize; Array.Copy(buffer, offset, localBuffer, 0, bufferCount); EncryptBlock(localBuffer, 0, bufferCount); baseOutputStream_.Write(localBuffer, 0, bufferCount); count -= bufferCount; offset += bufferCount; } } /// /// Finishes the stream. This will write the central directory at the /// end of the zip file and flush the stream. /// /// /// This is automatically called when the stream is closed. /// /// /// An I/O error occurs. /// /// /// Comment exceeds the maximum length
/// Entry name exceeds the maximum length ///
public override void Finish() { if (entries == null) { return; } if (curEntry != null) { CloseEntry(); } long numEntries = entries.Count; long sizeEntries = 0; foreach (ZipEntry entry in entries) { WriteLeInt(ZipConstants.CentralHeaderSignature); WriteLeShort(ZipConstants.VersionMadeBy); WriteLeShort(entry.Version); WriteLeShort(entry.Flags); WriteLeShort((short)entry.CompressionMethod); WriteLeInt((int)entry.DosTime); WriteLeInt((int)entry.Crc); if ( entry.IsZip64Forced() || (entry.CompressedSize >= uint.MaxValue) ) { WriteLeInt(-1); } else { WriteLeInt((int)entry.CompressedSize); } if ( entry.IsZip64Forced() || (entry.Size >= uint.MaxValue) ) { WriteLeInt(-1); } else { WriteLeInt((int)entry.Size); } byte[] name = ZipConstants.ConvertToArray(entry.Flags, entry.Name); if (name.Length > 0xffff) { throw new ZipException("Name too long."); } ZipExtraData ed = new ZipExtraData(entry.ExtraData); if ( entry.CentralHeaderRequiresZip64 ) { ed.StartNewEntry(); if ( entry.IsZip64Forced() || (entry.Size >= 0xffffffff) ) { ed.AddLeLong(entry.Size); } if ( entry.IsZip64Forced() || (entry.CompressedSize >= 0xffffffff) ) { ed.AddLeLong(entry.CompressedSize); } if ( entry.Offset >= 0xffffffff ) { ed.AddLeLong(entry.Offset); } ed.AddNewEntry(1); } else { ed.Delete(1); } byte[] extra = ed.GetEntryData(); byte[] entryComment = (entry.Comment != null) ? ZipConstants.ConvertToArray(entry.Flags, entry.Comment) : new byte[0]; if (entryComment.Length > 0xffff) { throw new ZipException("Comment too long."); } WriteLeShort(name.Length); WriteLeShort(extra.Length); WriteLeShort(entryComment.Length); WriteLeShort(0); // disk number WriteLeShort(0); // internal file attributes // external file attributes if (entry.ExternalFileAttributes != -1) { WriteLeInt(entry.ExternalFileAttributes); } else { if (entry.IsDirectory) { // mark entry as directory (from nikolam.AT.perfectinfo.com) WriteLeInt(16); } else { WriteLeInt(0); } } if ( entry.Offset >= uint.MaxValue ) { WriteLeInt(-1); } else { WriteLeInt((int)entry.Offset); } if ( name.Length > 0 ) { baseOutputStream_.Write(name, 0, name.Length); } if ( extra.Length > 0 ) { baseOutputStream_.Write(extra, 0, extra.Length); } if ( entryComment.Length > 0 ) { baseOutputStream_.Write(entryComment, 0, entryComment.Length); } sizeEntries += ZipConstants.CentralHeaderBaseSize + name.Length + extra.Length + entryComment.Length; } using ( ZipHelperStream zhs = new ZipHelperStream(baseOutputStream_) ) { zhs.WriteEndOfCentralDirectory(numEntries, sizeEntries, offset, zipComment); } entries = null; } #region Instance Fields /// /// The entries for the archive. /// ArrayList entries = new ArrayList(); /// /// Used to track the crc of data added to entries. /// Crc32 crc = new Crc32(); /// /// The current entry being added. /// ZipEntry curEntry; int defaultCompressionLevel = Deflater.DEFAULT_COMPRESSION; CompressionMethod curMethod = CompressionMethod.Deflated; /// /// Used to track the size of data for an entry during writing. /// long size; /// /// Offset to be recorded for each entry in the central header. /// long offset; /// /// Comment for the entire archive recorded in central header. /// byte[] zipComment = new byte[0]; /// /// Flag indicating that header patching is required for the current entry. /// bool patchEntryHeader; /// /// Position to patch crc /// long crcPatchPos = -1; /// /// Position to patch size. /// long sizePatchPos = -1; // Default is dynamic which is not backwards compatible and can cause problems // with XP's built in compression which cant read Zip64 archives. // However it does avoid the situation were a large file is added and cannot be completed correctly. // NOTE: Setting the size for entries before they are added is the best solution! UseZip64 useZip64_ = UseZip64.Dynamic; #endregion } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/ZipExtraData.cs0000664000175000017500000006752110663721342023163 0ustar jtaylorjtaylor// // ZipExtraData.cs // // Copyright 2004-2007 John Reilly // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using System.Collections; using System.IO; namespace ICSharpCode.SharpZipLib.Zip { // TODO: Sort out wether tagged data is useful and what a good implementation might look like. // Its just a sketch of an idea at the moment. /// /// ExtraData tagged value interface. /// public interface ITaggedData { /// /// Get the ID for this tagged data value. /// short TagID { get; } /// /// Set the contents of this instance from the data passed. /// /// The data to extract contents from. /// The offset to begin extracting data from. /// The number of bytes to extract. void SetData(byte[] data, int offset, int count); /// /// Get the data representing this instance. /// /// Returns the data for this instance. byte[] GetData(); } /// /// A raw binary tagged value /// public class RawTaggedData : ITaggedData { /// /// Initialise a new instance. /// /// The tag ID. public RawTaggedData(short tag) { tag_ = tag; } #region ITaggedData Members /// /// Get the ID for this tagged data value. /// public short TagID { get { return tag_; } set { tag_ = value; } } /// /// Set the data from the raw values provided. /// /// The raw data to extract values from. /// The index to start extracting values from. /// The number of bytes available. public void SetData(byte[] data, int offset, int count) { if( data==null ) { throw new ArgumentNullException("data"); } data_=new byte[count]; Array.Copy(data, offset, data_, 0, count); } /// /// Get the binary data representing this instance. /// /// The raw binary data representing this instance. public byte[] GetData() { return data_; } #endregion /// /// Get /set the binary data representing this instance. /// /// The raw binary data representing this instance. public byte[] Data { get { return data_; } set { data_=value; } } #region Instance Fields /// /// The tag ID for this instance. /// protected short tag_; byte[] data_; #endregion } /// /// Class representing extended unix date time values. /// public class ExtendedUnixData : ITaggedData { /// /// Flags indicate which values are included in this instance. /// [Flags] public enum Flags : byte { /// /// The modification time is included /// ModificationTime = 0x01, /// /// The access time is included /// AccessTime = 0x02, /// /// The create time is included. /// CreateTime = 0x04, } #region ITaggedData Members /// /// Get the ID /// public short TagID { get { return 0x5455; } } /// /// Set the data from the raw values provided. /// /// The raw data to extract values from. /// The index to start extracting values from. /// The number of bytes available. public void SetData(byte[] data, int index, int count) { using (MemoryStream ms = new MemoryStream(data, index, count, false)) using (ZipHelperStream helperStream = new ZipHelperStream(ms)) { // bit 0 if set, modification time is present // bit 1 if set, access time is present // bit 2 if set, creation time is present flags_ = (Flags)helperStream.ReadByte(); if (((flags_ & Flags.ModificationTime) != 0) && (count >= 5)) { int iTime = helperStream.ReadLEInt(); modificationTime_ = (new System.DateTime(1970, 1, 1, 0, 0, 0).ToUniversalTime() + new TimeSpan(0, 0, 0, iTime, 0)).ToLocalTime(); } if ((flags_ & Flags.AccessTime) != 0) { int iTime = helperStream.ReadLEInt(); lastAccessTime_ = (new System.DateTime(1970, 1, 1, 0, 0, 0).ToUniversalTime() + new TimeSpan(0, 0, 0, iTime, 0)).ToLocalTime(); } if ((flags_ & Flags.CreateTime) != 0) { int iTime = helperStream.ReadLEInt(); createTime_ = (new System.DateTime(1970, 1, 1, 0, 0, 0).ToUniversalTime() + new TimeSpan(0, 0, 0, iTime, 0)).ToLocalTime(); } } } /// /// Get the binary data representing this instance. /// /// The raw binary data representing this instance. public byte[] GetData() { using (MemoryStream ms = new MemoryStream()) using (ZipHelperStream helperStream = new ZipHelperStream(ms)) { helperStream.IsStreamOwner = false; helperStream.WriteByte((byte)flags_); // Flags if ( (flags_ & Flags.ModificationTime) != 0) { TimeSpan span = modificationTime_.ToUniversalTime() - new System.DateTime(1970, 1, 1, 0, 0, 0).ToUniversalTime(); int seconds = (int)span.TotalSeconds; helperStream.WriteLEInt(seconds); } if ( (flags_ & Flags.AccessTime) != 0) { TimeSpan span = lastAccessTime_.ToUniversalTime() - new System.DateTime(1970, 1, 1, 0, 0, 0).ToUniversalTime(); int seconds = (int)span.TotalSeconds; helperStream.WriteLEInt(seconds); } if ( (flags_ & Flags.CreateTime) != 0) { TimeSpan span = createTime_.ToUniversalTime() - new System.DateTime(1970, 1, 1, 0, 0, 0).ToUniversalTime(); int seconds = (int)span.TotalSeconds; helperStream.WriteLEInt(seconds); } return ms.ToArray(); } } #endregion /// /// Test a value to see if is valid and can be represented here. /// /// The value to test. /// Returns true if the value is valid and can be represented; false if not. /// The standard Unix time is a signed integer data type, directly encoding the Unix time number, /// which is the number of seconds since 1970-01-01. /// Being 32 bits means the values here cover a range of about 136 years. /// The minimum representable time is 1901-12-13 20:45:52, /// and the maximum representable time is 2038-01-19 03:14:07. /// public static bool IsValidValue(DateTime value) { return (( value >= new DateTime(1901, 12, 13, 20, 45, 52)) || ( value <= new DateTime(2038, 1, 19, 03, 14, 07) )); } /// /// Get /set the Modification Time /// /// /// public DateTime ModificationTime { get { return modificationTime_; } set { if ( !IsValidValue(value) ) { throw new ArgumentOutOfRangeException("value"); } flags_ |= Flags.ModificationTime; modificationTime_=value; } } /// /// Get / set the Access Time /// /// /// public DateTime AccessTime { get { return lastAccessTime_; } set { if ( !IsValidValue(value) ) { throw new ArgumentOutOfRangeException("value"); } flags_ |= Flags.AccessTime; lastAccessTime_=value; } } /// /// Get / Set the Create Time /// /// /// public DateTime CreateTime { get { return createTime_; } set { if ( !IsValidValue(value) ) { throw new ArgumentOutOfRangeException("value"); } flags_ |= Flags.CreateTime; createTime_=value; } } /// /// Get/set the values to include. /// Flags Include { get { return flags_; } set { flags_ = value; } } #region Instance Fields Flags flags_; DateTime modificationTime_ = new DateTime(1970,1,1); DateTime lastAccessTime_ = new DateTime(1970, 1, 1); DateTime createTime_ = new DateTime(1970, 1, 1); #endregion } /// /// Class handling NT date time values. /// public class NTTaggedData : ITaggedData { /// /// Get the ID for this tagged data value. /// public short TagID { get { return 10; } } /// /// Set the data from the raw values provided. /// /// The raw data to extract values from. /// The index to start extracting values from. /// The number of bytes available. public void SetData(byte[] data, int index, int count) { using (MemoryStream ms = new MemoryStream(data, index, count, false)) using (ZipHelperStream helperStream = new ZipHelperStream(ms)) { helperStream.ReadLEInt(); // Reserved while (helperStream.Position < helperStream.Length) { int ntfsTag = helperStream.ReadLEShort(); int ntfsLength = helperStream.ReadLEShort(); if (ntfsTag == 1) { if (ntfsLength >= 24) { long lastModificationTicks = helperStream.ReadLELong(); lastModificationTime_ = DateTime.FromFileTime(lastModificationTicks); long lastAccessTicks = helperStream.ReadLELong(); lastAccessTime_ = DateTime.FromFileTime(lastAccessTicks); long createTimeTicks = helperStream.ReadLELong(); createTime_ = DateTime.FromFileTime(createTimeTicks); } break; } else { // An unknown NTFS tag so simply skip it. helperStream.Seek(ntfsLength, SeekOrigin.Current); } } } } /// /// Get the binary data representing this instance. /// /// The raw binary data representing this instance. public byte[] GetData() { using (MemoryStream ms = new MemoryStream()) using (ZipHelperStream helperStream = new ZipHelperStream(ms)) { helperStream.IsStreamOwner = false; helperStream.WriteLEInt(0); // Reserved helperStream.WriteLEShort(1); // Tag helperStream.WriteLEShort(24); // Length = 3 x 8. helperStream.WriteLELong(lastModificationTime_.ToFileTime()); helperStream.WriteLELong(lastAccessTime_.ToFileTime()); helperStream.WriteLELong(createTime_.ToFileTime()); return ms.ToArray(); } } /// /// Test a valuie to see if is valid and can be represented here. /// /// The value to test. /// Returns true if the value is valid and can be represented; false if not. /// /// NTFS filetimes are 64-bit unsigned integers, stored in Intel /// (least significant byte first) byte order. They determine the /// number of 1.0E-07 seconds (1/10th microseconds!) past WinNT "epoch", /// which is "01-Jan-1601 00:00:00 UTC". 28 May 60056 is the upper limit /// public static bool IsValidValue(DateTime value) { bool result = true; try { value.ToFileTimeUtc(); } catch { result = false; } return result; } /// /// Get/set the last modification time. /// public DateTime LastModificationTime { get { return lastModificationTime_; } set { if (! IsValidValue(value)) { throw new ArgumentOutOfRangeException("value"); } lastModificationTime_ = value; } } /// /// Get /set the create time /// public DateTime CreateTime { get { return createTime_; } set { if ( !IsValidValue(value)) { throw new ArgumentOutOfRangeException("value"); } createTime_ = value; } } /// /// Get /set the last access time. /// public DateTime LastAccessTime { get { return lastAccessTime_; } set { if (!IsValidValue(value)) { throw new ArgumentOutOfRangeException("value"); } lastAccessTime_ = value; } } #region Instance Fields DateTime lastAccessTime_ = DateTime.FromFileTime(0); DateTime lastModificationTime_ = DateTime.FromFileTime(0); DateTime createTime_ = DateTime.FromFileTime(0); #endregion } /// /// A factory that creates tagged data instances. /// interface ITaggedDataFactory { /// /// Get data for a specific tag value. /// /// The tag ID to find. /// The data to search. /// The offset to begin extracting data from. /// The number of bytes to extract. /// The located value found, or null if not found. ITaggedData Create(short tag, byte[] data, int offset, int count); } /// /// /// A class to handle the extra data field for Zip entries /// /// /// Extra data contains 0 or more values each prefixed by a header tag and length. /// They contain zero or more bytes of actual data. /// The data is held internally using a copy on write strategy. This is more efficient but /// means that for extra data created by passing in data can have the values modified by the caller /// in some circumstances. /// sealed public class ZipExtraData : IDisposable { #region Constructors /// /// Initialise a default instance. /// public ZipExtraData() { Clear(); } /// /// Initialise with known extra data. /// /// The extra data. public ZipExtraData(byte[] data) { if ( data == null ) { data_ = new byte[0]; } else { data_ = data; } } #endregion /// /// Get the raw extra data value /// /// Returns the raw byte[] extra data this instance represents. public byte[] GetEntryData() { if ( Length > ushort.MaxValue ) { throw new ZipException("Data exceeds maximum length"); } return (byte[])data_.Clone(); } /// /// Clear the stored data. /// public void Clear() { if ( (data_ == null) || (data_.Length != 0) ) { data_ = new byte[0]; } } /// /// Gets the current extra data length. /// public int Length { get { return data_.Length; } } /// /// Get a read-only for the associated tag. /// /// The tag to locate data for. /// Returns a containing tag data or null if no tag was found. public Stream GetStreamForTag(int tag) { Stream result = null; if ( Find(tag) ) { result = new MemoryStream(data_, index_, readValueLength_, false); } return result; } /// /// Get the tagged data for a tag. /// /// The tag to search for. /// Returns a tagged value or null if none found. private ITaggedData GetData(short tag) { ITaggedData result = null; if (Find(tag)) { result = Create(tag, data_, readValueStart_, readValueLength_); } return result; } ITaggedData Create(short tag, byte[] data, int offset, int count) { ITaggedData result = null; switch ( tag ) { case 0x000A: result = new NTTaggedData(); break; case 0x5455: result = new ExtendedUnixData(); break; default: result = new RawTaggedData(tag); break; } result.SetData(data_, readValueStart_, readValueLength_); return result; } /// /// Get the length of the last value found by /// /// This is only value if has previsouly returned true. public int ValueLength { get { return readValueLength_; } } /// /// Get the index for the current read value. /// /// This is only valid if has previously returned true. /// Initially it will be the index of the first byte of actual data. The value is updated after calls to /// , and . public int CurrentReadIndex { get { return index_; } } /// /// Get the number of bytes remaining to be read for the current value; /// public int UnreadCount { get { if ((readValueStart_ > data_.Length) || (readValueStart_ < 4) ) { throw new ZipException("Find must be called before calling a Read method"); } return readValueStart_ + readValueLength_ - index_; } } /// /// Find an extra data value /// /// The identifier for the value to find. /// Returns true if the value was found; false otherwise. public bool Find(int headerID) { readValueStart_ = data_.Length; readValueLength_ = 0; index_ = 0; int localLength = readValueStart_; int localTag = headerID - 1; // Trailing bytes that cant make up an entry (as there arent enough // bytes for a tag and length) are ignored! while ( (localTag != headerID) && (index_ < data_.Length - 3) ) { localTag = ReadShortInternal(); localLength = ReadShortInternal(); if ( localTag != headerID ) { index_ += localLength; } } bool result = (localTag == headerID) && ((index_ + localLength) <= data_.Length); if ( result ) { readValueStart_ = index_; readValueLength_ = localLength; } return result; } /// /// Add a new entry to extra data. /// /// The value to add. public void AddEntry(ITaggedData taggedData) { if (taggedData == null) { throw new ArgumentNullException("taggedData"); } AddEntry(taggedData.TagID, taggedData.GetData()); } /// /// Add a new entry to extra data /// /// The ID for this entry. /// The data to add. /// If the ID already exists its contents are replaced. public void AddEntry(int headerID, byte[] fieldData) { if ( (headerID > ushort.MaxValue) || (headerID < 0)) { throw new ArgumentOutOfRangeException("headerID"); } int addLength = (fieldData == null) ? 0 : fieldData.Length; if ( addLength > ushort.MaxValue ) { #if NETCF_1_0 throw new ArgumentOutOfRangeException("fieldData"); #else throw new ArgumentOutOfRangeException("fieldData", "exceeds maximum length"); #endif } // Test for new length before adjusting data. int newLength = data_.Length + addLength + 4; if ( Find(headerID) ) { newLength -= (ValueLength + 4); } if ( newLength > ushort.MaxValue ) { throw new ZipException("Data exceeds maximum length"); } Delete(headerID); byte[] newData = new byte[newLength]; data_.CopyTo(newData, 0); int index = data_.Length; data_ = newData; SetShort(ref index, headerID); SetShort(ref index, addLength); if ( fieldData != null ) { fieldData.CopyTo(newData, index); } } /// /// Start adding a new entry. /// /// Add data using , , , or . /// The new entry is completed and actually added by calling /// public void StartNewEntry() { newEntry_ = new MemoryStream(); } /// /// Add entry data added since using the ID passed. /// /// The identifier to use for this entry. public void AddNewEntry(int headerID) { byte[] newData = newEntry_.ToArray(); newEntry_ = null; AddEntry(headerID, newData); } /// /// Add a byte of data to the pending new entry. /// /// The byte to add. /// public void AddData(byte data) { newEntry_.WriteByte(data); } /// /// Add data to a pending new entry. /// /// The data to add. /// public void AddData(byte[] data) { if ( data == null ) { throw new ArgumentNullException("data"); } newEntry_.Write(data, 0, data.Length); } /// /// Add a short value in little endian order to the pending new entry. /// /// The data to add. /// public void AddLeShort(int toAdd) { unchecked { newEntry_.WriteByte(( byte )toAdd); newEntry_.WriteByte(( byte )(toAdd >> 8)); } } /// /// Add an integer value in little endian order to the pending new entry. /// /// The data to add. /// public void AddLeInt(int toAdd) { unchecked { AddLeShort(( short )toAdd); AddLeShort(( short )(toAdd >> 16)); } } /// /// Add a long value in little endian order to the pending new entry. /// /// The data to add. /// public void AddLeLong(long toAdd) { unchecked { AddLeInt(( int )(toAdd & 0xffffffff)); AddLeInt(( int )(toAdd >> 32)); } } /// /// Delete an extra data field. /// /// The identifier of the field to delete. /// Returns true if the field was found and deleted. public bool Delete(int headerID) { bool result = false; if ( Find(headerID) ) { result = true; int trueStart = readValueStart_ - 4; byte[] newData = new byte[data_.Length - (ValueLength + 4)]; Array.Copy(data_, 0, newData, 0, trueStart); int trueEnd = trueStart + ValueLength + 4; Array.Copy(data_, trueEnd, newData, trueStart, data_.Length - trueEnd); data_ = newData; } return result; } #region Reading Support /// /// Read a long in little endian form from the last found data value /// /// Returns the long value read. public long ReadLong() { ReadCheck(8); return (ReadInt() & 0xffffffff) | ((( long )ReadInt()) << 32); } /// /// Read an integer in little endian form from the last found data value. /// /// Returns the integer read. public int ReadInt() { ReadCheck(4); int result = data_[index_] + (data_[index_ + 1] << 8) + (data_[index_ + 2] << 16) + (data_[index_ + 3] << 24); index_ += 4; return result; } /// /// Read a short value in little endian form from the last found data value. /// /// Returns the short value read. public int ReadShort() { ReadCheck(2); int result = data_[index_] + (data_[index_ + 1] << 8); index_ += 2; return result; } /// /// Read a byte from an extra data /// /// The byte value read or -1 if the end of data has been reached. public int ReadByte() { int result = -1; if ( (index_ < data_.Length) && (readValueStart_ + readValueLength_ > index_) ) { result = data_[index_]; index_ += 1; } return result; } /// /// Skip data during reading. /// /// The number of bytes to skip. public void Skip(int amount) { ReadCheck(amount); index_ += amount; } void ReadCheck(int length) { if ((readValueStart_ > data_.Length) || (readValueStart_ < 4) ) { throw new ZipException("Find must be called before calling a Read method"); } if (index_ > readValueStart_ + readValueLength_ - length ) { throw new ZipException("End of extra data"); } } /// /// Internal form of that reads data at any location. /// /// Returns the short value read. int ReadShortInternal() { if ( index_ > data_.Length - 2) { throw new ZipException("End of extra data"); } int result = data_[index_] + (data_[index_ + 1] << 8); index_ += 2; return result; } void SetShort(ref int index, int source) { data_[index] = (byte)source; data_[index + 1] = (byte)(source >> 8); index += 2; } #endregion #region IDisposable Members /// /// Dispose of this instance. /// public void Dispose() { if ( newEntry_ != null ) { newEntry_.Close(); } } #endregion #region Instance Fields int index_; int readValueStart_; int readValueLength_; MemoryStream newEntry_; byte[] data_; #endregion } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/ZipEntryFactory.cs0000664000175000017500000003021710661645546023740 0ustar jtaylorjtaylor// ZipEntryFactory.cs // // Copyright 2006 John Reilly // // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using System.IO; using System.Text; using ICSharpCode.SharpZipLib.Core; namespace ICSharpCode.SharpZipLib.Zip { /// /// Basic implementation of /// public class ZipEntryFactory : IEntryFactory { #region Enumerations /// /// Defines the possible values to be used for the . /// public enum TimeSetting { /// /// Use the recorded LastWriteTime value for the file. /// LastWriteTime, /// /// Use the recorded LastWriteTimeUtc value for the file /// LastWriteTimeUtc, /// /// Use the recorded CreateTime value for the file. /// CreateTime, /// /// Use the recorded CreateTimeUtc value for the file. /// CreateTimeUtc, /// /// Use the recorded LastAccessTime value for the file. /// LastAccessTime, /// /// Use the recorded LastAccessTimeUtc value for the file. /// LastAccessTimeUtc, /// /// Use a fixed value. /// /// The actual value used can be /// specified via the constructor or /// using the with the setting set /// to which will use the when this class was constructed. /// The property can also be used to set this value. Fixed, } #endregion #region Constructors /// /// Initialise a new instance of the class. /// /// A default , and the LastWriteTime for files is used. public ZipEntryFactory() { nameTransform_ = new ZipNameTransform(); } /// /// Initialise a new instance of using the specified /// /// The time setting to use when creating Zip entries. public ZipEntryFactory(TimeSetting timeSetting) { timeSetting_ = timeSetting; nameTransform_ = new ZipNameTransform(); } /// /// Initialise a new instance of using the specified /// /// The time to set all values to. public ZipEntryFactory(DateTime time) { timeSetting_ = TimeSetting.Fixed; FixedDateTime = time; nameTransform_ = new ZipNameTransform(); } #endregion #region Properties /// /// Get / set the to be used when creating new values. /// /// /// Setting this property to null will cause a default name transform to be used. /// public INameTransform NameTransform { get { return nameTransform_; } set { if (value == null) { nameTransform_ = new ZipNameTransform(); } else { nameTransform_ = value; } } } /// /// Get / set the in use. /// public TimeSetting Setting { get { return timeSetting_; } set { timeSetting_ = value; } } /// /// Get / set the value to use when is set to /// public DateTime FixedDateTime { get { return fixedDateTime_; } set { if (value.Year < 1970) { throw new ArgumentException("Value is too old to be valid", "value"); } fixedDateTime_ = value; } } /// /// A bitmask defining the attributes to be retrieved from the actual file. /// /// The default is to get all possible attributes from the actual file. public int GetAttributes { get { return getAttributes_; } set { getAttributes_ = value; } } /// /// A bitmask defining which attributes are to be set on. /// /// By default no attributes are set on. public int SetAttributes { get { return setAttributes_; } set { setAttributes_ = value; } } /// /// Get set a value indicating wether unidoce text should be set on. /// public bool IsUnicodeText { get { return isUnicodeText_; } set { isUnicodeText_ = value; } } #endregion #region IEntryFactory Members /// /// Make a new for a file. /// /// The name of the file to create a new entry for. /// Returns a new based on the . public ZipEntry MakeFileEntry(string fileName) { return MakeFileEntry(fileName, true); } /// /// Make a new from a name. /// /// The name of the file to create a new entry for. /// If true entry detail is retrieved from the file system if the file exists. /// Returns a new based on the . public ZipEntry MakeFileEntry(string fileName, bool useFileSystem) { ZipEntry result = new ZipEntry(nameTransform_.TransformFile(fileName)); result.IsUnicodeText = isUnicodeText_; int externalAttributes = 0; bool useAttributes = (setAttributes_ != 0); FileInfo fi = null; if (useFileSystem) { fi = new FileInfo(fileName); } if ((fi != null) && fi.Exists) { switch (timeSetting_) { case TimeSetting.CreateTime: result.DateTime = fi.CreationTime; break; case TimeSetting.CreateTimeUtc: #if NETCF_1_0 || NETCF_2_0 result.DateTime = fi.CreationTime.ToUniversalTime(); #else result.DateTime = fi.CreationTimeUtc; #endif break; case TimeSetting.LastAccessTime: result.DateTime = fi.LastAccessTime; break; case TimeSetting.LastAccessTimeUtc: #if NETCF_1_0 || NETCF_2_0 result.DateTime = fi.LastAccessTime.ToUniversalTime(); #else result.DateTime = fi.LastAccessTimeUtc; #endif break; case TimeSetting.LastWriteTime: result.DateTime = fi.LastWriteTime; break; case TimeSetting.LastWriteTimeUtc: #if NETCF_1_0 || NETCF_2_0 result.DateTime = fi.LastWriteTime.ToUniversalTime(); #else result.DateTime = fi.LastWriteTimeUtc; #endif break; case TimeSetting.Fixed: result.DateTime = fixedDateTime_; break; default: throw new ZipException("Unhandled time setting in MakeFileEntry"); } result.Size = fi.Length; useAttributes = true; externalAttributes = ((int)fi.Attributes & getAttributes_); } else { if (timeSetting_ == TimeSetting.Fixed) { result.DateTime = fixedDateTime_; } } if (useAttributes) { externalAttributes |= setAttributes_; result.ExternalFileAttributes = externalAttributes; } return result; } /// /// Make a new for a directory. /// /// The raw untransformed name for the new directory /// Returns a new representing a directory. public ZipEntry MakeDirectoryEntry(string directoryName) { return MakeDirectoryEntry(directoryName, true); } /// /// Make a new for a directory. /// /// The raw untransformed name for the new directory /// If true entry detail is retrieved from the file system if the file exists. /// Returns a new representing a directory. public ZipEntry MakeDirectoryEntry(string directoryName, bool useFileSystem) { ZipEntry result = new ZipEntry(nameTransform_.TransformDirectory(directoryName)); result.Size=0; int externalAttributes = 0; DirectoryInfo di = null; if (useFileSystem) { di = new DirectoryInfo(directoryName); } if ((di != null) && di.Exists) { switch (timeSetting_) { case TimeSetting.CreateTime: result.DateTime = di.CreationTime; break; case TimeSetting.CreateTimeUtc: #if NETCF_1_0 || NETCF_2_0 result.DateTime = di.CreationTime.ToUniversalTime(); #else result.DateTime = di.CreationTimeUtc; #endif break; case TimeSetting.LastAccessTime: result.DateTime = di.LastAccessTime; break; case TimeSetting.LastAccessTimeUtc: #if NETCF_1_0 || NETCF_2_0 result.DateTime = di.LastAccessTime.ToUniversalTime(); #else result.DateTime = di.LastAccessTimeUtc; #endif break; case TimeSetting.LastWriteTime: result.DateTime = di.LastWriteTime; break; case TimeSetting.LastWriteTimeUtc: #if NETCF_1_0 || NETCF_2_0 result.DateTime = di.LastWriteTime.ToUniversalTime(); #else result.DateTime = di.LastWriteTimeUtc; #endif break; case TimeSetting.Fixed: result.DateTime = fixedDateTime_; break; default: throw new ZipException("Unhandled time setting in MakeDirectoryEntry"); } externalAttributes = ((int)di.Attributes & getAttributes_); } else { if (timeSetting_ == TimeSetting.Fixed) { result.DateTime = fixedDateTime_; } } // Always set directory attribute on. externalAttributes |= (setAttributes_ | 16); result.ExternalFileAttributes = externalAttributes; return result; } #endregion #region Instance Fields INameTransform nameTransform_; DateTime fixedDateTime_ = DateTime.Now; TimeSetting timeSetting_; bool isUnicodeText_; int getAttributes_ = -1; int setAttributes_; #endregion } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/Compression/0000775000175000017500000000000011643263772022571 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/SharpZipLib/Zip/Compression/DeflaterHuffman.cs0000664000175000017500000006235310670307274026157 0ustar jtaylorjtaylor// DeflaterHuffman.cs // // Copyright (C) 2001 Mike Krueger // Copyright (C) 2004 John Reilly // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; namespace ICSharpCode.SharpZipLib.Zip.Compression { /// /// This is the DeflaterHuffman class. /// /// This class is not thread safe. This is inherent in the API, due /// to the split of Deflate and SetInput. /// /// author of the original java version : Jochen Hoenicke /// public class DeflaterHuffman { const int BUFSIZE = 1 << (DeflaterConstants.DEFAULT_MEM_LEVEL + 6); const int LITERAL_NUM = 286; // Number of distance codes const int DIST_NUM = 30; // Number of codes used to transfer bit lengths const int BITLEN_NUM = 19; // repeat previous bit length 3-6 times (2 bits of repeat count) const int REP_3_6 = 16; // repeat a zero length 3-10 times (3 bits of repeat count) const int REP_3_10 = 17; // repeat a zero length 11-138 times (7 bits of repeat count) const int REP_11_138 = 18; const int EOF_SYMBOL = 256; // The lengths of the bit length codes are sent in order of decreasing // probability, to avoid transmitting the lengths for unused bit length codes. static readonly int[] BL_ORDER = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; static readonly byte[] bit4Reverse = { 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 }; static short[] staticLCodes; static byte[] staticLLength; static short[] staticDCodes; static byte[] staticDLength; class Tree { #region Instance Fields public short[] freqs; public byte[] length; public int minNumCodes; public int numCodes; short[] codes; int[] bl_counts; int maxLength; DeflaterHuffman dh; #endregion #region Constructors public Tree(DeflaterHuffman dh, int elems, int minCodes, int maxLength) { this.dh = dh; this.minNumCodes = minCodes; this.maxLength = maxLength; freqs = new short[elems]; bl_counts = new int[maxLength]; } #endregion /// /// Resets the internal state of the tree /// public void Reset() { for (int i = 0; i < freqs.Length; i++) { freqs[i] = 0; } codes = null; length = null; } public void WriteSymbol(int code) { // if (DeflaterConstants.DEBUGGING) { // freqs[code]--; // // Console.Write("writeSymbol("+freqs.length+","+code+"): "); // } dh.pending.WriteBits(codes[code] & 0xffff, length[code]); } /// /// Check that all frequencies are zero /// /// /// At least one frequency is non-zero /// public void CheckEmpty() { bool empty = true; for (int i = 0; i < freqs.Length; i++) { if (freqs[i] != 0) { //Console.WriteLine("freqs[" + i + "] == " + freqs[i]); empty = false; } } if (!empty) { throw new SharpZipBaseException("!Empty"); } } /// /// Set static codes and length /// /// new codes /// length for new codes public void SetStaticCodes(short[] staticCodes, byte[] staticLengths) { codes = staticCodes; length = staticLengths; } /// /// Build dynamic codes and lengths /// public void BuildCodes() { int numSymbols = freqs.Length; int[] nextCode = new int[maxLength]; int code = 0; codes = new short[freqs.Length]; // if (DeflaterConstants.DEBUGGING) { // //Console.WriteLine("buildCodes: "+freqs.Length); // } for (int bits = 0; bits < maxLength; bits++) { nextCode[bits] = code; code += bl_counts[bits] << (15 - bits); // if (DeflaterConstants.DEBUGGING) { // //Console.WriteLine("bits: " + ( bits + 1) + " count: " + bl_counts[bits] // +" nextCode: "+code); // } } #if DebugDeflation if ( DeflaterConstants.DEBUGGING && (code != 65536) ) { throw new SharpZipBaseException("Inconsistent bl_counts!"); } #endif for (int i=0; i < numCodes; i++) { int bits = length[i]; if (bits > 0) { // if (DeflaterConstants.DEBUGGING) { // //Console.WriteLine("codes["+i+"] = rev(" + nextCode[bits-1]+"), // +bits); // } codes[i] = BitReverse(nextCode[bits-1]); nextCode[bits-1] += 1 << (16 - bits); } } } public void BuildTree() { int numSymbols = freqs.Length; /* heap is a priority queue, sorted by frequency, least frequent * nodes first. The heap is a binary tree, with the property, that * the parent node is smaller than both child nodes. This assures * that the smallest node is the first parent. * * The binary tree is encoded in an array: 0 is root node and * the nodes 2*n+1, 2*n+2 are the child nodes of node n. */ int[] heap = new int[numSymbols]; int heapLen = 0; int maxCode = 0; for (int n = 0; n < numSymbols; n++) { int freq = freqs[n]; if (freq != 0) { // Insert n into heap int pos = heapLen++; int ppos; while (pos > 0 && freqs[heap[ppos = (pos - 1) / 2]] > freq) { heap[pos] = heap[ppos]; pos = ppos; } heap[pos] = n; maxCode = n; } } /* We could encode a single literal with 0 bits but then we * don't see the literals. Therefore we force at least two * literals to avoid this case. We don't care about order in * this case, both literals get a 1 bit code. */ while (heapLen < 2) { int node = maxCode < 2 ? ++maxCode : 0; heap[heapLen++] = node; } numCodes = Math.Max(maxCode + 1, minNumCodes); int numLeafs = heapLen; int[] childs = new int[4 * heapLen - 2]; int[] values = new int[2 * heapLen - 1]; int numNodes = numLeafs; for (int i = 0; i < heapLen; i++) { int node = heap[i]; childs[2 * i] = node; childs[2 * i + 1] = -1; values[i] = freqs[node] << 8; heap[i] = i; } /* Construct the Huffman tree by repeatedly combining the least two * frequent nodes. */ do { int first = heap[0]; int last = heap[--heapLen]; // Propagate the hole to the leafs of the heap int ppos = 0; int path = 1; while (path < heapLen) { if (path + 1 < heapLen && values[heap[path]] > values[heap[path+1]]) { path++; } heap[ppos] = heap[path]; ppos = path; path = path * 2 + 1; } /* Now propagate the last element down along path. Normally * it shouldn't go too deep. */ int lastVal = values[last]; while ((path = ppos) > 0 && values[heap[ppos = (path - 1)/2]] > lastVal) { heap[path] = heap[ppos]; } heap[path] = last; int second = heap[0]; // Create a new node father of first and second last = numNodes++; childs[2 * last] = first; childs[2 * last + 1] = second; int mindepth = Math.Min(values[first] & 0xff, values[second] & 0xff); values[last] = lastVal = values[first] + values[second] - mindepth + 1; // Again, propagate the hole to the leafs ppos = 0; path = 1; while (path < heapLen) { if (path + 1 < heapLen && values[heap[path]] > values[heap[path+1]]) { path++; } heap[ppos] = heap[path]; ppos = path; path = ppos * 2 + 1; } // Now propagate the new element down along path while ((path = ppos) > 0 && values[heap[ppos = (path - 1)/2]] > lastVal) { heap[path] = heap[ppos]; } heap[path] = last; } while (heapLen > 1); if (heap[0] != childs.Length / 2 - 1) { throw new SharpZipBaseException("Heap invariant violated"); } BuildLength(childs); } /// /// Get encoded length /// /// Encoded length, the sum of frequencies * lengths public int GetEncodedLength() { int len = 0; for (int i = 0; i < freqs.Length; i++) { len += freqs[i] * length[i]; } return len; } /// /// Scan a literal or distance tree to determine the frequencies of the codes /// in the bit length tree. /// public void CalcBLFreq(Tree blTree) { int max_count; /* max repeat count */ int min_count; /* min repeat count */ int count; /* repeat count of the current code */ int curlen = -1; /* length of current code */ int i = 0; while (i < numCodes) { count = 1; int nextlen = length[i]; if (nextlen == 0) { max_count = 138; min_count = 3; } else { max_count = 6; min_count = 3; if (curlen != nextlen) { blTree.freqs[nextlen]++; count = 0; } } curlen = nextlen; i++; while (i < numCodes && curlen == length[i]) { i++; if (++count >= max_count) { break; } } if (count < min_count) { blTree.freqs[curlen] += (short)count; } else if (curlen != 0) { blTree.freqs[REP_3_6]++; } else if (count <= 10) { blTree.freqs[REP_3_10]++; } else { blTree.freqs[REP_11_138]++; } } } /// /// Write tree values /// /// Tree to write public void WriteTree(Tree blTree) { int max_count; // max repeat count int min_count; // min repeat count int count; // repeat count of the current code int curlen = -1; // length of current code int i = 0; while (i < numCodes) { count = 1; int nextlen = length[i]; if (nextlen == 0) { max_count = 138; min_count = 3; } else { max_count = 6; min_count = 3; if (curlen != nextlen) { blTree.WriteSymbol(nextlen); count = 0; } } curlen = nextlen; i++; while (i < numCodes && curlen == length[i]) { i++; if (++count >= max_count) { break; } } if (count < min_count) { while (count-- > 0) { blTree.WriteSymbol(curlen); } } else if (curlen != 0) { blTree.WriteSymbol(REP_3_6); dh.pending.WriteBits(count - 3, 2); } else if (count <= 10) { blTree.WriteSymbol(REP_3_10); dh.pending.WriteBits(count - 3, 3); } else { blTree.WriteSymbol(REP_11_138); dh.pending.WriteBits(count - 11, 7); } } } void BuildLength(int[] childs) { this.length = new byte [freqs.Length]; int numNodes = childs.Length / 2; int numLeafs = (numNodes + 1) / 2; int overflow = 0; for (int i = 0; i < maxLength; i++) { bl_counts[i] = 0; } // First calculate optimal bit lengths int[] lengths = new int[numNodes]; lengths[numNodes-1] = 0; for (int i = numNodes - 1; i >= 0; i--) { if (childs[2 * i + 1] != -1) { int bitLength = lengths[i] + 1; if (bitLength > maxLength) { bitLength = maxLength; overflow++; } lengths[childs[2 * i]] = lengths[childs[2 * i + 1]] = bitLength; } else { // A leaf node int bitLength = lengths[i]; bl_counts[bitLength - 1]++; this.length[childs[2*i]] = (byte) lengths[i]; } } // if (DeflaterConstants.DEBUGGING) { // //Console.WriteLine("Tree "+freqs.Length+" lengths:"); // for (int i=0; i < numLeafs; i++) { // //Console.WriteLine("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]] // + " len: "+length[childs[2*i]]); // } // } if (overflow == 0) { return; } int incrBitLen = maxLength - 1; do { // Find the first bit length which could increase: while (bl_counts[--incrBitLen] == 0) ; // Move this node one down and remove a corresponding // number of overflow nodes. do { bl_counts[incrBitLen]--; bl_counts[++incrBitLen]++; overflow -= 1 << (maxLength - 1 - incrBitLen); } while (overflow > 0 && incrBitLen < maxLength - 1); } while (overflow > 0); /* We may have overshot above. Move some nodes from maxLength to * maxLength-1 in that case. */ bl_counts[maxLength-1] += overflow; bl_counts[maxLength-2] -= overflow; /* Now recompute all bit lengths, scanning in increasing * frequency. It is simpler to reconstruct all lengths instead of * fixing only the wrong ones. This idea is taken from 'ar' * written by Haruhiko Okumura. * * The nodes were inserted with decreasing frequency into the childs * array. */ int nodePtr = 2 * numLeafs; for (int bits = maxLength; bits != 0; bits--) { int n = bl_counts[bits-1]; while (n > 0) { int childPtr = 2*childs[nodePtr++]; if (childs[childPtr + 1] == -1) { // We found another leaf length[childs[childPtr]] = (byte) bits; n--; } } } // if (DeflaterConstants.DEBUGGING) { // //Console.WriteLine("*** After overflow elimination. ***"); // for (int i=0; i < numLeafs; i++) { // //Console.WriteLine("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]] // + " len: "+length[childs[2*i]]); // } // } } } #region Instance Fields /// /// Pending buffer to use /// public DeflaterPending pending; Tree literalTree; Tree distTree; Tree blTree; // Buffer for distances short[] d_buf; byte[] l_buf; int last_lit; int extra_bits; #endregion static DeflaterHuffman() { // See RFC 1951 3.2.6 // Literal codes staticLCodes = new short[LITERAL_NUM]; staticLLength = new byte[LITERAL_NUM]; int i = 0; while (i < 144) { staticLCodes[i] = BitReverse((0x030 + i) << 8); staticLLength[i++] = 8; } while (i < 256) { staticLCodes[i] = BitReverse((0x190 - 144 + i) << 7); staticLLength[i++] = 9; } while (i < 280) { staticLCodes[i] = BitReverse((0x000 - 256 + i) << 9); staticLLength[i++] = 7; } while (i < LITERAL_NUM) { staticLCodes[i] = BitReverse((0x0c0 - 280 + i) << 8); staticLLength[i++] = 8; } // Distance codes staticDCodes = new short[DIST_NUM]; staticDLength = new byte[DIST_NUM]; for (i = 0; i < DIST_NUM; i++) { staticDCodes[i] = BitReverse(i << 11); staticDLength[i] = 5; } } /// /// Construct instance with pending buffer /// /// Pending buffer to use public DeflaterHuffman(DeflaterPending pending) { this.pending = pending; literalTree = new Tree(this, LITERAL_NUM, 257, 15); distTree = new Tree(this, DIST_NUM, 1, 15); blTree = new Tree(this, BITLEN_NUM, 4, 7); d_buf = new short[BUFSIZE]; l_buf = new byte [BUFSIZE]; } /// /// Reset internal state /// public void Reset() { last_lit = 0; extra_bits = 0; literalTree.Reset(); distTree.Reset(); blTree.Reset(); } /// /// Write all trees to pending buffer /// /// The number/rank of treecodes to send. public void SendAllTrees(int blTreeCodes) { blTree.BuildCodes(); literalTree.BuildCodes(); distTree.BuildCodes(); pending.WriteBits(literalTree.numCodes - 257, 5); pending.WriteBits(distTree.numCodes - 1, 5); pending.WriteBits(blTreeCodes - 4, 4); for (int rank = 0; rank < blTreeCodes; rank++) { pending.WriteBits(blTree.length[BL_ORDER[rank]], 3); } literalTree.WriteTree(blTree); distTree.WriteTree(blTree); #if DebugDeflation if (DeflaterConstants.DEBUGGING) { blTree.CheckEmpty(); } #endif } /// /// Compress current buffer writing data to pending buffer /// public void CompressBlock() { for (int i = 0; i < last_lit; i++) { int litlen = l_buf[i] & 0xff; int dist = d_buf[i]; if (dist-- != 0) { // if (DeflaterConstants.DEBUGGING) { // Console.Write("["+(dist+1)+","+(litlen+3)+"]: "); // } int lc = Lcode(litlen); literalTree.WriteSymbol(lc); int bits = (lc - 261) / 4; if (bits > 0 && bits <= 5) { pending.WriteBits(litlen & ((1 << bits) - 1), bits); } int dc = Dcode(dist); distTree.WriteSymbol(dc); bits = dc / 2 - 1; if (bits > 0) { pending.WriteBits(dist & ((1 << bits) - 1), bits); } } else { // if (DeflaterConstants.DEBUGGING) { // if (litlen > 32 && litlen < 127) { // Console.Write("("+(char)litlen+"): "); // } else { // Console.Write("{"+litlen+"}: "); // } // } literalTree.WriteSymbol(litlen); } } #if DebugDeflation if (DeflaterConstants.DEBUGGING) { Console.Write("EOF: "); } #endif literalTree.WriteSymbol(EOF_SYMBOL); #if DebugDeflation if (DeflaterConstants.DEBUGGING) { literalTree.CheckEmpty(); distTree.CheckEmpty(); } #endif } /// /// Flush block to output with no compression /// /// Data to write /// Index of first byte to write /// Count of bytes to write /// True if this is the last block public void FlushStoredBlock(byte[] stored, int storedOffset, int storedLength, bool lastBlock) { #if DebugDeflation // if (DeflaterConstants.DEBUGGING) { // //Console.WriteLine("Flushing stored block "+ storedLength); // } #endif pending.WriteBits((DeflaterConstants.STORED_BLOCK << 1) + (lastBlock ? 1 : 0), 3); pending.AlignToByte(); pending.WriteShort(storedLength); pending.WriteShort(~storedLength); pending.WriteBlock(stored, storedOffset, storedLength); Reset(); } /// /// Flush block to output with compression /// /// Data to flush /// Index of first byte to flush /// Count of bytes to flush /// True if this is the last block public void FlushBlock(byte[] stored, int storedOffset, int storedLength, bool lastBlock) { literalTree.freqs[EOF_SYMBOL]++; // Build trees literalTree.BuildTree(); distTree.BuildTree(); // Calculate bitlen frequency literalTree.CalcBLFreq(blTree); distTree.CalcBLFreq(blTree); // Build bitlen tree blTree.BuildTree(); int blTreeCodes = 4; for (int i = 18; i > blTreeCodes; i--) { if (blTree.length[BL_ORDER[i]] > 0) { blTreeCodes = i+1; } } int opt_len = 14 + blTreeCodes * 3 + blTree.GetEncodedLength() + literalTree.GetEncodedLength() + distTree.GetEncodedLength() + extra_bits; int static_len = extra_bits; for (int i = 0; i < LITERAL_NUM; i++) { static_len += literalTree.freqs[i] * staticLLength[i]; } for (int i = 0; i < DIST_NUM; i++) { static_len += distTree.freqs[i] * staticDLength[i]; } if (opt_len >= static_len) { // Force static trees opt_len = static_len; } if (storedOffset >= 0 && storedLength + 4 < opt_len >> 3) { // Store Block // if (DeflaterConstants.DEBUGGING) { // //Console.WriteLine("Storing, since " + storedLength + " < " + opt_len // + " <= " + static_len); // } FlushStoredBlock(stored, storedOffset, storedLength, lastBlock); } else if (opt_len == static_len) { // Encode with static tree pending.WriteBits((DeflaterConstants.STATIC_TREES << 1) + (lastBlock ? 1 : 0), 3); literalTree.SetStaticCodes(staticLCodes, staticLLength); distTree.SetStaticCodes(staticDCodes, staticDLength); CompressBlock(); Reset(); } else { // Encode with dynamic tree pending.WriteBits((DeflaterConstants.DYN_TREES << 1) + (lastBlock ? 1 : 0), 3); SendAllTrees(blTreeCodes); CompressBlock(); Reset(); } } /// /// Get value indicating if internal buffer is full /// /// true if buffer is full public bool IsFull() { return last_lit >= BUFSIZE; } /// /// Add literal to buffer /// /// Literal value to add to buffer. /// Value indicating internal buffer is full public bool TallyLit(int literal) { // if (DeflaterConstants.DEBUGGING) { // if (lit > 32 && lit < 127) { // //Console.WriteLine("("+(char)lit+")"); // } else { // //Console.WriteLine("{"+lit+"}"); // } // } d_buf[last_lit] = 0; l_buf[last_lit++] = (byte)literal; literalTree.freqs[literal]++; return IsFull(); } /// /// Add distance code and length to literal and distance trees /// /// Distance code /// Length /// Value indicating if internal buffer is full public bool TallyDist(int distance, int length) { // if (DeflaterConstants.DEBUGGING) { // //Console.WriteLine("[" + distance + "," + length + "]"); // } d_buf[last_lit] = (short)distance; l_buf[last_lit++] = (byte)(length - 3); int lc = Lcode(length - 3); literalTree.freqs[lc]++; if (lc >= 265 && lc < 285) { extra_bits += (lc - 261) / 4; } int dc = Dcode(distance - 1); distTree.freqs[dc]++; if (dc >= 4) { extra_bits += dc / 2 - 1; } return IsFull(); } /// /// Reverse the bits of a 16 bit value. /// /// Value to reverse bits /// Value with bits reversed public static short BitReverse(int toReverse) { return (short) (bit4Reverse[toReverse & 0xF] << 12 | bit4Reverse[(toReverse >> 4) & 0xF] << 8 | bit4Reverse[(toReverse >> 8) & 0xF] << 4 | bit4Reverse[toReverse >> 12]); } static int Lcode(int length) { if (length == 255) { return 285; } int code = 257; while (length >= 8) { code += 4; length >>= 1; } return code + length; } static int Dcode(int distance) { int code = 0; while (distance >= 4) { code += 2; distance >>= 1; } return code + distance; } } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/Compression/DeflaterPending.cs0000664000175000017500000000453510572513600026146 0ustar jtaylorjtaylor// DeflaterPending.cs // // Copyright (C) 2001 Mike Krueger // Copyright (C) 2004 John Reilly // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. namespace ICSharpCode.SharpZipLib.Zip.Compression { /// /// This class stores the pending output of the Deflater. /// /// author of the original java version : Jochen Hoenicke /// public class DeflaterPending : PendingBuffer { /// /// Construct instance with default buffer size /// public DeflaterPending() : base(DeflaterConstants.PENDING_BUF_SIZE) { } } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/Compression/Deflater.cs0000664000175000017500000004352310572513600024641 0ustar jtaylorjtaylor// Deflater.cs // // Copyright (C) 2001 Mike Krueger // Copyright (C) 2004 John Reilly // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; namespace ICSharpCode.SharpZipLib.Zip.Compression { /// /// This is the Deflater class. The deflater class compresses input /// with the deflate algorithm described in RFC 1951. It has several /// compression levels and three different strategies described below. /// /// This class is not thread safe. This is inherent in the API, due /// to the split of deflate and setInput. /// /// author of the original java version : Jochen Hoenicke /// public class Deflater { #region Deflater Documentation /* * The Deflater can do the following state transitions: * * (1) -> INIT_STATE ----> INIT_FINISHING_STATE ---. * / | (2) (5) | * / v (5) | * (3)| SETDICT_STATE ---> SETDICT_FINISHING_STATE |(3) * \ | (3) | ,--------' * | | | (3) / * v v (5) v v * (1) -> BUSY_STATE ----> FINISHING_STATE * | (6) * v * FINISHED_STATE * \_____________________________________/ * | (7) * v * CLOSED_STATE * * (1) If we should produce a header we start in INIT_STATE, otherwise * we start in BUSY_STATE. * (2) A dictionary may be set only when we are in INIT_STATE, then * we change the state as indicated. * (3) Whether a dictionary is set or not, on the first call of deflate * we change to BUSY_STATE. * (4) -- intentionally left blank -- :) * (5) FINISHING_STATE is entered, when flush() is called to indicate that * there is no more INPUT. There are also states indicating, that * the header wasn't written yet. * (6) FINISHED_STATE is entered, when everything has been flushed to the * internal pending output buffer. * (7) At any time (7) * */ #endregion #region Public Constants /// /// The best and slowest compression level. This tries to find very /// long and distant string repetitions. /// public const int BEST_COMPRESSION = 9; /// /// The worst but fastest compression level. /// public const int BEST_SPEED = 1; /// /// The default compression level. /// public const int DEFAULT_COMPRESSION = -1; /// /// This level won't compress at all but output uncompressed blocks. /// public const int NO_COMPRESSION = 0; /// /// The compression method. This is the only method supported so far. /// There is no need to use this constant at all. /// public const int DEFLATED = 8; #endregion #region Local Constants private const int IS_SETDICT = 0x01; private const int IS_FLUSHING = 0x04; private const int IS_FINISHING = 0x08; private const int INIT_STATE = 0x00; private const int SETDICT_STATE = 0x01; // private static int INIT_FINISHING_STATE = 0x08; // private static int SETDICT_FINISHING_STATE = 0x09; private const int BUSY_STATE = 0x10; private const int FLUSHING_STATE = 0x14; private const int FINISHING_STATE = 0x1c; private const int FINISHED_STATE = 0x1e; private const int CLOSED_STATE = 0x7f; #endregion #region Constructors /// /// Creates a new deflater with default compression level. /// public Deflater() : this(DEFAULT_COMPRESSION, false) { } /// /// Creates a new deflater with given compression level. /// /// /// the compression level, a value between NO_COMPRESSION /// and BEST_COMPRESSION, or DEFAULT_COMPRESSION. /// /// if lvl is out of range. public Deflater(int level) : this(level, false) { } /// /// Creates a new deflater with given compression level. /// /// /// the compression level, a value between NO_COMPRESSION /// and BEST_COMPRESSION. /// /// /// true, if we should suppress the Zlib/RFC1950 header at the /// beginning and the adler checksum at the end of the output. This is /// useful for the GZIP/PKZIP formats. /// /// if lvl is out of range. public Deflater(int level, bool noZlibHeaderOrFooter) { if (level == DEFAULT_COMPRESSION) { level = 6; } else if (level < NO_COMPRESSION || level > BEST_COMPRESSION) { throw new ArgumentOutOfRangeException("level"); } pending = new DeflaterPending(); engine = new DeflaterEngine(pending); this.noZlibHeaderOrFooter = noZlibHeaderOrFooter; SetStrategy(DeflateStrategy.Default); SetLevel(level); Reset(); } #endregion /// /// Resets the deflater. The deflater acts afterwards as if it was /// just created with the same compression level and strategy as it /// had before. /// public void Reset() { state = (noZlibHeaderOrFooter ? BUSY_STATE : INIT_STATE); totalOut = 0; pending.Reset(); engine.Reset(); } /// /// Gets the current adler checksum of the data that was processed so far. /// public int Adler { get { return engine.Adler; } } /// /// Gets the number of input bytes processed so far. /// public int TotalIn { get { return engine.TotalIn; } } /// /// Gets the number of output bytes so far. /// public long TotalOut { get { return totalOut; } } /// /// Flushes the current input block. Further calls to deflate() will /// produce enough output to inflate everything in the current input /// block. This is not part of Sun's JDK so I have made it package /// private. It is used by DeflaterOutputStream to implement /// flush(). /// public void Flush() { state |= IS_FLUSHING; } /// /// Finishes the deflater with the current input block. It is an error /// to give more input after this method was called. This method must /// be called to force all bytes to be flushed. /// public void Finish() { state |= (IS_FLUSHING | IS_FINISHING); } /// /// Returns true if the stream was finished and no more output bytes /// are available. /// public bool IsFinished { get { return (state == FINISHED_STATE) && pending.IsFlushed; } } /// /// Returns true, if the input buffer is empty. /// You should then call setInput(). /// NOTE: This method can also return true when the stream /// was finished. /// public bool IsNeedingInput { get { return engine.NeedsInput(); } } /// /// Sets the data which should be compressed next. This should be only /// called when needsInput indicates that more input is needed. /// If you call setInput when needsInput() returns false, the /// previous input that is still pending will be thrown away. /// The given byte array should not be changed, before needsInput() returns /// true again. /// This call is equivalent to setInput(input, 0, input.length). /// /// /// the buffer containing the input data. /// /// /// if the buffer was finished() or ended(). /// public void SetInput(byte[] input) { SetInput(input, 0, input.Length); } /// /// Sets the data which should be compressed next. This should be /// only called when needsInput indicates that more input is needed. /// The given byte array should not be changed, before needsInput() returns /// true again. /// /// /// the buffer containing the input data. /// /// /// the start of the data. /// /// /// the number of data bytes of input. /// /// /// if the buffer was Finish()ed or if previous input is still pending. /// public void SetInput(byte[] input, int offset, int count) { if ((state & IS_FINISHING) != 0) { throw new InvalidOperationException("Finish() already called"); } engine.SetInput(input, offset, count); } /// /// Sets the compression level. There is no guarantee of the exact /// position of the change, but if you call this when needsInput is /// true the change of compression level will occur somewhere near /// before the end of the so far given input. /// /// /// the new compression level. /// public void SetLevel(int level) { if (level == DEFAULT_COMPRESSION) { level = 6; } else if (level < NO_COMPRESSION || level > BEST_COMPRESSION) { throw new ArgumentOutOfRangeException("level"); } if (this.level != level) { this.level = level; engine.SetLevel(level); } } /// /// Get current compression level /// /// Returns the current compression level public int GetLevel() { return level; } /// /// Sets the compression strategy. Strategy is one of /// DEFAULT_STRATEGY, HUFFMAN_ONLY and FILTERED. For the exact /// position where the strategy is changed, the same as for /// SetLevel() applies. /// /// /// The new compression strategy. /// public void SetStrategy(DeflateStrategy strategy) { engine.Strategy = strategy; } /// /// Deflates the current input block with to the given array. /// /// /// The buffer where compressed data is stored /// /// /// The number of compressed bytes added to the output, or 0 if either /// IsNeedingInput() or IsFinished returns true or length is zero. /// public int Deflate(byte[] output) { return Deflate(output, 0, output.Length); } /// /// Deflates the current input block to the given array. /// /// /// Buffer to store the compressed data. /// /// /// Offset into the output array. /// /// /// The maximum number of bytes that may be stored. /// /// /// The number of compressed bytes added to the output, or 0 if either /// needsInput() or finished() returns true or length is zero. /// /// /// If Finish() was previously called. /// /// /// If offset or length don't match the array length. /// public int Deflate(byte[] output, int offset, int length) { int origLength = length; if (state == CLOSED_STATE) { throw new InvalidOperationException("Deflater closed"); } if (state < BUSY_STATE) { // output header int header = (DEFLATED + ((DeflaterConstants.MAX_WBITS - 8) << 4)) << 8; int level_flags = (level - 1) >> 1; if (level_flags < 0 || level_flags > 3) { level_flags = 3; } header |= level_flags << 6; if ((state & IS_SETDICT) != 0) { // Dictionary was set header |= DeflaterConstants.PRESET_DICT; } header += 31 - (header % 31); pending.WriteShortMSB(header); if ((state & IS_SETDICT) != 0) { int chksum = engine.Adler; engine.ResetAdler(); pending.WriteShortMSB(chksum >> 16); pending.WriteShortMSB(chksum & 0xffff); } state = BUSY_STATE | (state & (IS_FLUSHING | IS_FINISHING)); } for (;;) { int count = pending.Flush(output, offset, length); offset += count; totalOut += count; length -= count; if (length == 0 || state == FINISHED_STATE) { break; } if (!engine.Deflate((state & IS_FLUSHING) != 0, (state & IS_FINISHING) != 0)) { if (state == BUSY_STATE) { // We need more input now return origLength - length; } else if (state == FLUSHING_STATE) { if (level != NO_COMPRESSION) { /* We have to supply some lookahead. 8 bit lookahead * is needed by the zlib inflater, and we must fill * the next byte, so that all bits are flushed. */ int neededbits = 8 + ((-pending.BitCount) & 7); while (neededbits > 0) { /* write a static tree block consisting solely of * an EOF: */ pending.WriteBits(2, 10); neededbits -= 10; } } state = BUSY_STATE; } else if (state == FINISHING_STATE) { pending.AlignToByte(); // Compressed data is complete. Write footer information if required. if (!noZlibHeaderOrFooter) { int adler = engine.Adler; pending.WriteShortMSB(adler >> 16); pending.WriteShortMSB(adler & 0xffff); } state = FINISHED_STATE; } } } return origLength - length; } /// /// Sets the dictionary which should be used in the deflate process. /// This call is equivalent to setDictionary(dict, 0, dict.Length). /// /// /// the dictionary. /// /// /// if SetInput () or Deflate () were already called or another dictionary was already set. /// public void SetDictionary(byte[] dictionary) { SetDictionary(dictionary, 0, dictionary.Length); } /// /// Sets the dictionary which should be used in the deflate process. /// The dictionary is a byte array containing strings that are /// likely to occur in the data which should be compressed. The /// dictionary is not stored in the compressed output, only a /// checksum. To decompress the output you need to supply the same /// dictionary again. /// /// /// The dictionary data /// /// /// The index where dictionary information commences. /// /// /// The number of bytes in the dictionary. /// /// /// If SetInput () or Deflate() were already called or another dictionary was already set. /// public void SetDictionary(byte[] dictionary, int index, int count) { if (state != INIT_STATE) { throw new InvalidOperationException(); } state = SETDICT_STATE; engine.SetDictionary(dictionary, index, count); } #region Instance Fields /// /// Compression level. /// int level; /// /// If true no Zlib/RFC1950 headers or footers are generated /// bool noZlibHeaderOrFooter; /// /// The current state. /// int state; /// /// The total bytes of output written. /// long totalOut; /// /// The pending output. /// DeflaterPending pending; /// /// The deflater engine. /// DeflaterEngine engine; #endregion } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/Compression/PendingBuffer.cs0000664000175000017500000002025310670213714025626 0ustar jtaylorjtaylor// PendingBuffer.cs // // Copyright (C) 2001 Mike Krueger // Copyright (C) 2004 John Reilly // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; namespace ICSharpCode.SharpZipLib.Zip.Compression { /// /// This class is general purpose class for writing data to a buffer. /// /// It allows you to write bits as well as bytes /// Based on DeflaterPending.java /// /// author of the original java version : Jochen Hoenicke /// public class PendingBuffer { #region Instance Fields /// /// Internal work buffer /// byte[] buffer_; int start; int end; uint bits; int bitCount; #endregion #region Constructors /// /// construct instance using default buffer size of 4096 /// public PendingBuffer() : this( 4096 ) { } /// /// construct instance using specified buffer size /// /// /// size to use for internal buffer /// public PendingBuffer(int bufferSize) { buffer_ = new byte[bufferSize]; } #endregion /// /// Clear internal state/buffers /// public void Reset() { start = end = bitCount = 0; } /// /// Write a byte to buffer /// /// /// The value to write /// public void WriteByte(int value) { #if DebugDeflation if (DeflaterConstants.DEBUGGING && (start != 0) ) { throw new SharpZipBaseException("Debug check: start != 0"); } #endif buffer_[end++] = unchecked((byte) value); } /// /// Write a short value to buffer LSB first /// /// /// The value to write. /// public void WriteShort(int value) { #if DebugDeflation if (DeflaterConstants.DEBUGGING && (start != 0) ) { throw new SharpZipBaseException("Debug check: start != 0"); } #endif buffer_[end++] = unchecked((byte) value); buffer_[end++] = unchecked((byte) (value >> 8)); } /// /// write an integer LSB first /// /// The value to write. public void WriteInt(int value) { #if DebugDeflation if (DeflaterConstants.DEBUGGING && (start != 0) ) { throw new SharpZipBaseException("Debug check: start != 0"); } #endif buffer_[end++] = unchecked((byte) value); buffer_[end++] = unchecked((byte) (value >> 8)); buffer_[end++] = unchecked((byte) (value >> 16)); buffer_[end++] = unchecked((byte) (value >> 24)); } /// /// Write a block of data to buffer /// /// data to write /// offset of first byte to write /// number of bytes to write public void WriteBlock(byte[] block, int offset, int length) { #if DebugDeflation if (DeflaterConstants.DEBUGGING && (start != 0) ) { throw new SharpZipBaseException("Debug check: start != 0"); } #endif System.Array.Copy(block, offset, buffer_, end, length); end += length; } /// /// The number of bits written to the buffer /// public int BitCount { get { return bitCount; } } /// /// Align internal buffer on a byte boundary /// public void AlignToByte() { #if DebugDeflation if (DeflaterConstants.DEBUGGING && (start != 0) ) { throw new SharpZipBaseException("Debug check: start != 0"); } #endif if (bitCount > 0) { buffer_[end++] = unchecked((byte) bits); if (bitCount > 8) { buffer_[end++] = unchecked((byte) (bits >> 8)); } } bits = 0; bitCount = 0; } /// /// Write bits to internal buffer /// /// source of bits /// number of bits to write public void WriteBits(int b, int count) { #if DebugDeflation if (DeflaterConstants.DEBUGGING && (start != 0) ) { throw new SharpZipBaseException("Debug check: start != 0"); } // if (DeflaterConstants.DEBUGGING) { // //Console.WriteLine("writeBits("+b+","+count+")"); // } #endif bits |= (uint)(b << bitCount); bitCount += count; if (bitCount >= 16) { buffer_[end++] = unchecked((byte) bits); buffer_[end++] = unchecked((byte) (bits >> 8)); bits >>= 16; bitCount -= 16; } } /// /// Write a short value to internal buffer most significant byte first /// /// value to write public void WriteShortMSB(int s) { #if DebugDeflation if (DeflaterConstants.DEBUGGING && (start != 0) ) { throw new SharpZipBaseException("Debug check: start != 0"); } #endif buffer_[end++] = unchecked((byte) (s >> 8)); buffer_[end++] = unchecked((byte) s); } /// /// Indicates if buffer has been flushed /// public bool IsFlushed { get { return end == 0; } } /// /// Flushes the pending buffer into the given output array. If the /// output array is to small, only a partial flush is done. /// /// The output array. /// The offset into output array. /// The maximum number of bytes to store. /// The number of bytes flushed. public int Flush(byte[] output, int offset, int length) { if (bitCount >= 8) { buffer_[end++] = unchecked((byte) bits); bits >>= 8; bitCount -= 8; } if (length > end - start) { length = end - start; System.Array.Copy(buffer_, start, output, offset, length); start = 0; end = 0; } else { System.Array.Copy(buffer_, start, output, offset, length); start += length; } return length; } /// /// Convert internal buffer to byte array. /// Buffer is empty on completion /// /// /// The internal buffer contents converted to a byte array. /// public byte[] ToByteArray() { byte[] result = new byte[end - start]; System.Array.Copy(buffer_, start, result, 0, result.Length); start = 0; end = 0; return result; } } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/Compression/Streams/0000775000175000017500000000000011643263772024207 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/SharpZipLib/Zip/Compression/Streams/StreamManipulator.cs0000664000175000017500000002224010670334034030172 0ustar jtaylorjtaylor// StreamManipulator.cs // // Copyright (C) 2001 Mike Krueger // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams { /// /// This class allows us to retrieve a specified number of bits from /// the input buffer, as well as copy big byte blocks. /// /// It uses an int buffer to store up to 31 bits for direct /// manipulation. This guarantees that we can get at least 16 bits, /// but we only need at most 15, so this is all safe. /// /// There are some optimizations in this class, for example, you must /// never peek more than 8 bits more than needed, and you must first /// peek bits before you may drop them. This is not a general purpose /// class but optimized for the behaviour of the Inflater. /// /// authors of the original java version : John Leuner, Jochen Hoenicke /// public class StreamManipulator { #region Instance Fields private byte[] window_; private int windowStart_; private int windowEnd_; private uint buffer_; private int bitsInBuffer_; #endregion #region Constructors /// /// Constructs a default StreamManipulator with all buffers empty /// public StreamManipulator() { } #endregion /// /// Get the next sequence of bits but don't increase input pointer. bitCount must be /// less or equal 16 and if this call succeeds, you must drop /// at least n - 8 bits in the next call. /// /// The number of bits to peek. /// /// the value of the bits, or -1 if not enough bits available. */ /// public int PeekBits(int bitCount) { if (bitsInBuffer_ < bitCount) { if (windowStart_ == windowEnd_) { return -1; // ok } buffer_ |= (uint)((window_[windowStart_++] & 0xff | (window_[windowStart_++] & 0xff) << 8) << bitsInBuffer_); bitsInBuffer_ += 16; } return (int)(buffer_ & ((1 << bitCount) - 1)); } /// /// Drops the next n bits from the input. You should have called PeekBits /// with a bigger or equal n before, to make sure that enough bits are in /// the bit buffer. /// /// The number of bits to drop. public void DropBits(int bitCount) { buffer_ >>= bitCount; bitsInBuffer_ -= bitCount; } /// /// Gets the next n bits and increases input pointer. This is equivalent /// to followed by , except for correct error handling. /// /// The number of bits to retrieve. /// /// the value of the bits, or -1 if not enough bits available. /// public int GetBits(int bitCount) { int bits = PeekBits(bitCount); if (bits >= 0) { DropBits(bitCount); } return bits; } /// /// Gets the number of bits available in the bit buffer. This must be /// only called when a previous PeekBits() returned -1. /// /// /// the number of bits available. /// public int AvailableBits { get { return bitsInBuffer_; } } /// /// Gets the number of bytes available. /// /// /// The number of bytes available. /// public int AvailableBytes { get { return windowEnd_ - windowStart_ + (bitsInBuffer_ >> 3); } } /// /// Skips to the next byte boundary. /// public void SkipToByteBoundary() { buffer_ >>= (bitsInBuffer_ & 7); bitsInBuffer_ &= ~7; } /// /// Returns true when SetInput can be called /// public bool IsNeedingInput { get { return windowStart_ == windowEnd_; } } /// /// Copies bytes from input buffer to output buffer starting /// at output[offset]. You have to make sure, that the buffer is /// byte aligned. If not enough bytes are available, copies fewer /// bytes. /// /// /// The buffer to copy bytes to. /// /// /// The offset in the buffer at which copying starts /// /// /// The length to copy, 0 is allowed. /// /// /// The number of bytes copied, 0 if no bytes were available. /// /// /// Length is less than zero /// /// /// Bit buffer isnt byte aligned /// public int CopyBytes(byte[] output, int offset, int length) { if (length < 0) { throw new ArgumentOutOfRangeException("length"); } if ((bitsInBuffer_ & 7) != 0) { // bits_in_buffer may only be 0 or a multiple of 8 throw new InvalidOperationException("Bit buffer is not byte aligned!"); } int count = 0; while ((bitsInBuffer_ > 0) && (length > 0)) { output[offset++] = (byte) buffer_; buffer_ >>= 8; bitsInBuffer_ -= 8; length--; count++; } if (length == 0) { return count; } int avail = windowEnd_ - windowStart_; if (length > avail) { length = avail; } System.Array.Copy(window_, windowStart_, output, offset, length); windowStart_ += length; if (((windowStart_ - windowEnd_) & 1) != 0) { // We always want an even number of bytes in input, see peekBits buffer_ = (uint)(window_[windowStart_++] & 0xff); bitsInBuffer_ = 8; } return count + length; } /// /// Resets state and empties internal buffers /// public void Reset() { buffer_ = 0; windowStart_ = windowEnd_ = bitsInBuffer_ = 0; } /// /// Add more input for consumption. /// Only call when IsNeedingInput returns true /// /// data to be input /// offset of first byte of input /// number of bytes of input to add. public void SetInput(byte[] buffer, int offset, int count) { if ( buffer == null ) { throw new ArgumentNullException("buffer"); } if ( offset < 0 ) { #if NETCF_1_0 throw new ArgumentOutOfRangeException("offset"); #else throw new ArgumentOutOfRangeException("offset", "Cannot be negative"); #endif } if ( count < 0 ) { #if NETCF_1_0 throw new ArgumentOutOfRangeException("count"); #else throw new ArgumentOutOfRangeException("count", "Cannot be negative"); #endif } if (windowStart_ < windowEnd_) { throw new InvalidOperationException("Old input was not completely processed"); } int end = offset + count; // We want to throw an ArrayIndexOutOfBoundsException early. // Note the check also handles integer wrap around. if ((offset > end) || (end > buffer.Length) ) { throw new ArgumentOutOfRangeException("count"); } if ((count & 1) != 0) { // We always want an even number of bytes in input, see PeekBits buffer_ |= (uint)((buffer[offset++] & 0xff) << bitsInBuffer_); bitsInBuffer_ += 8; } window_ = buffer; windowStart_ = offset; windowEnd_ = end; } } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/Compression/Streams/OutputWindow.cs0000664000175000017500000001666010572513576027237 0ustar jtaylorjtaylor// OutputWindow.cs // // Copyright (C) 2001 Mike Krueger // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams { /// /// Contains the output from the Inflation process. /// We need to have a window so that we can refer backwards into the output stream /// to repeat stuff.
/// Author of the original java version : John Leuner ///
public class OutputWindow { #region Constants const int WindowSize = 1 << 15; const int WindowMask = WindowSize - 1; #endregion #region Instance Fields byte[] window = new byte[WindowSize]; //The window is 2^15 bytes int windowEnd; int windowFilled; #endregion /// /// Write a byte to this output window /// /// value to write /// /// if window is full /// public void Write(int value) { if (windowFilled++ == WindowSize) { throw new InvalidOperationException("Window full"); } window[windowEnd++] = (byte) value; windowEnd &= WindowMask; } private void SlowRepeat(int repStart, int length, int distance) { while (length-- > 0) { window[windowEnd++] = window[repStart++]; windowEnd &= WindowMask; repStart &= WindowMask; } } /// /// Append a byte pattern already in the window itself /// /// length of pattern to copy /// distance from end of window pattern occurs /// /// If the repeated data overflows the window /// public void Repeat(int length, int distance) { if ((windowFilled += length) > WindowSize) { throw new InvalidOperationException("Window full"); } int repStart = (windowEnd - distance) & WindowMask; int border = WindowSize - length; if ( (repStart <= border) && (windowEnd < border) ) { if (length <= distance) { System.Array.Copy(window, repStart, window, windowEnd, length); windowEnd += length; } else { // We have to copy manually, since the repeat pattern overlaps. while (length-- > 0) { window[windowEnd++] = window[repStart++]; } } } else { SlowRepeat(repStart, length, distance); } } /// /// Copy from input manipulator to internal window /// /// source of data /// length of data to copy /// the number of bytes copied public int CopyStored(StreamManipulator input, int length) { length = Math.Min(Math.Min(length, WindowSize - windowFilled), input.AvailableBytes); int copied; int tailLen = WindowSize - windowEnd; if (length > tailLen) { copied = input.CopyBytes(window, windowEnd, tailLen); if (copied == tailLen) { copied += input.CopyBytes(window, 0, length - tailLen); } } else { copied = input.CopyBytes(window, windowEnd, length); } windowEnd = (windowEnd + copied) & WindowMask; windowFilled += copied; return copied; } /// /// Copy dictionary to window /// /// source dictionary /// offset of start in source dictionary /// length of dictionary /// /// If window isnt empty /// public void CopyDict(byte[] dictionary, int offset, int length) { if ( dictionary == null ) { throw new ArgumentNullException("dictionary"); } if (windowFilled > 0) { throw new InvalidOperationException(); } if (length > WindowSize) { offset += length - WindowSize; length = WindowSize; } System.Array.Copy(dictionary, offset, window, 0, length); windowEnd = length & WindowMask; } /// /// Get remaining unfilled space in window /// /// Number of bytes left in window public int GetFreeSpace() { return WindowSize - windowFilled; } /// /// Get bytes available for output in window /// /// Number of bytes filled public int GetAvailable() { return windowFilled; } /// /// Copy contents of window to output /// /// buffer to copy to /// offset to start at /// number of bytes to count /// The number of bytes copied /// /// If a window underflow occurs /// public int CopyOutput(byte[] output, int offset, int len) { int copyEnd = windowEnd; if (len > windowFilled) { len = windowFilled; } else { copyEnd = (windowEnd - windowFilled + len) & WindowMask; } int copied = len; int tailLen = len - copyEnd; if (tailLen > 0) { System.Array.Copy(window, WindowSize - tailLen, output, offset, tailLen); offset += tailLen; len = copyEnd; } System.Array.Copy(window, copyEnd - len, output, offset, len); windowFilled -= copied; if (windowFilled < 0) { throw new InvalidOperationException(); } return copied; } /// /// Reset by clearing window so GetAvailable returns 0 /// public void Reset() { windowFilled = windowEnd = 0; } } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/Compression/Streams/DeflaterOutputStream.cs0000664000175000017500000004030310670330500030640 0ustar jtaylorjtaylor// DeflaterOutputStream.cs // // Copyright (C) 2001 Mike Krueger // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using System.IO; using ICSharpCode.SharpZipLib.Checksums; using ICSharpCode.SharpZipLib.Zip.Compression; #if !NETCF_1_0 using System.Security.Cryptography; using ICSharpCode.SharpZipLib.Encryption; #endif namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams { /// /// A special stream deflating or compressing the bytes that are /// written to it. It uses a Deflater to perform actual deflating.
/// Authors of the original java version : Tom Tromey, Jochen Hoenicke ///
public class DeflaterOutputStream : Stream { #region Constructors /// /// Creates a new DeflaterOutputStream with a default Deflater and default buffer size. /// /// /// the output stream where deflated output should be written. /// public DeflaterOutputStream(Stream baseOutputStream) : this(baseOutputStream, new Deflater(), 512) { } /// /// Creates a new DeflaterOutputStream with the given Deflater and /// default buffer size. /// /// /// the output stream where deflated output should be written. /// /// /// the underlying deflater. /// public DeflaterOutputStream(Stream baseOutputStream, Deflater deflater) : this(baseOutputStream, deflater, 512) { } /// /// Creates a new DeflaterOutputStream with the given Deflater and /// buffer size. /// /// /// The output stream where deflated output is written. /// /// /// The underlying deflater to use /// /// /// The buffer size to use when deflating /// /// /// bufsize is less than or equal to zero. /// /// /// baseOutputStream does not support writing /// /// /// deflater instance is null /// public DeflaterOutputStream(Stream baseOutputStream, Deflater deflater, int bufferSize) { if ( baseOutputStream == null ) { throw new ArgumentNullException("baseOutputStream"); } if (baseOutputStream.CanWrite == false) { throw new ArgumentException("Must support writing", "baseOutputStream"); } if (deflater == null) { throw new ArgumentNullException("deflater"); } if (bufferSize <= 0) { throw new ArgumentOutOfRangeException("bufferSize"); } baseOutputStream_ = baseOutputStream; buffer_ = new byte[bufferSize]; deflater_ = deflater; } #endregion #region Public API /// /// Finishes the stream by calling finish() on the deflater. /// /// /// Not all input is deflated /// public virtual void Finish() { deflater_.Finish(); while (!deflater_.IsFinished) { int len = deflater_.Deflate(buffer_, 0, buffer_.Length); if (len <= 0) { break; } #if NETCF_1_0 if ( keys != null ) { #else if (cryptoTransform_ != null) { #endif EncryptBlock(buffer_, 0, len); } baseOutputStream_.Write(buffer_, 0, len); } if (!deflater_.IsFinished) { throw new SharpZipBaseException("Can't deflate all input?"); } baseOutputStream_.Flush(); #if NETCF_1_0 if ( keys != null ) { keys = null; } #else if (cryptoTransform_ != null) { cryptoTransform_.Dispose(); cryptoTransform_ = null; } #endif } /// /// Get/set flag indicating ownership of the underlying stream. /// When the flag is true will close the underlying stream also. /// public bool IsStreamOwner { get { return isStreamOwner_; } set { isStreamOwner_ = value; } } /// /// Allows client to determine if an entry can be patched after its added /// public bool CanPatchEntries { get { return baseOutputStream_.CanSeek; } } #endregion #region Encryption string password; #if NETCF_1_0 uint[] keys; #else ICryptoTransform cryptoTransform_; #endif /// /// Get/set the password used for encryption. /// /// When set to null or if the password is empty no encryption is performed public string Password { get { return password; } set { if ( (value != null) && (value.Length == 0) ) { password = null; } else { password = value; } } } /// /// Encrypt a block of data /// /// /// Data to encrypt. NOTE the original contents of the buffer are lost /// /// /// Offset of first byte in buffer to encrypt /// /// /// Number of bytes in buffer to encrypt /// protected void EncryptBlock(byte[] buffer, int offset, int length) { #if NETCF_1_0 for (int i = offset; i < offset + length; ++i) { byte oldbyte = buffer[i]; buffer[i] ^= EncryptByte(); UpdateKeys(oldbyte); } #else cryptoTransform_.TransformBlock(buffer, 0, length, buffer, 0); #endif } /// /// Initializes encryption keys based on given password /// /// The password. protected void InitializePassword(string password) { #if NETCF_1_0 keys = new uint[] { 0x12345678, 0x23456789, 0x34567890 }; byte[] rawPassword = ZipConstants.ConvertToArray(password); for (int i = 0; i < rawPassword.Length; ++i) { UpdateKeys((byte)rawPassword[i]); } #else PkzipClassicManaged pkManaged = new PkzipClassicManaged(); byte[] key = PkzipClassic.GenerateKeys(ZipConstants.ConvertToArray(password)); cryptoTransform_ = pkManaged.CreateEncryptor(key, null); #endif } #if NETCF_1_0 /// /// Encrypt a single byte /// /// /// The encrypted value /// protected byte EncryptByte() { uint temp = ((keys[2] & 0xFFFF) | 2); return (byte)((temp * (temp ^ 1)) >> 8); } /// /// Update encryption keys /// protected void UpdateKeys(byte ch) { keys[0] = Crc32.ComputeCrc32(keys[0], ch); keys[1] = keys[1] + (byte)keys[0]; keys[1] = keys[1] * 134775813 + 1; keys[2] = Crc32.ComputeCrc32(keys[2], (byte)(keys[1] >> 24)); } #endif #endregion #region Deflation Support /// /// Deflates everything in the input buffers. This will call /// def.deflate() until all bytes from the input buffers /// are processed. /// protected void Deflate() { while (!deflater_.IsNeedingInput) { int deflateCount = deflater_.Deflate(buffer_, 0, buffer_.Length); if (deflateCount <= 0) { break; } #if NETCF_1_0 if (keys != null) #else if (cryptoTransform_ != null) #endif { EncryptBlock(buffer_, 0, deflateCount); } baseOutputStream_.Write(buffer_, 0, deflateCount); } if (!deflater_.IsNeedingInput) { throw new SharpZipBaseException("DeflaterOutputStream can't deflate all input?"); } } #endregion #region Stream Overrides /// /// Gets value indicating stream can be read from /// public override bool CanRead { get { return false; } } /// /// Gets a value indicating if seeking is supported for this stream /// This property always returns false /// public override bool CanSeek { get { return false; } } /// /// Get value indicating if this stream supports writing /// public override bool CanWrite { get { return baseOutputStream_.CanWrite; } } /// /// Get current length of stream /// public override long Length { get { return baseOutputStream_.Length; } } /// /// Gets the current position within the stream. /// /// Any attempt to set position public override long Position { get { return baseOutputStream_.Position; } set { throw new NotSupportedException("Position property not supported"); } } /// /// Sets the current position of this stream to the given value. Not supported by this class! /// /// The offset relative to the to seek. /// The to seek from. /// The new position in the stream. /// Any access public override long Seek(long offset, SeekOrigin origin) { throw new NotSupportedException("DeflaterOutputStream Seek not supported"); } /// /// Sets the length of this stream to the given value. Not supported by this class! /// /// The new stream length. /// Any access public override void SetLength(long value) { throw new NotSupportedException("DeflaterOutputStream SetLength not supported"); } /// /// Read a byte from stream advancing position by one /// /// The byte read cast to an int. THe value is -1 if at the end of the stream. /// Any access public override int ReadByte() { throw new NotSupportedException("DeflaterOutputStream ReadByte not supported"); } /// /// Read a block of bytes from stream /// /// The buffer to store read data in. /// The offset to start storing at. /// The maximum number of bytes to read. /// The actual number of bytes read. Zero if end of stream is detected. /// Any access public override int Read(byte[] buffer, int offset, int count) { throw new NotSupportedException("DeflaterOutputStream Read not supported"); } /// /// Asynchronous reads are not supported a NotSupportedException is always thrown /// /// The buffer to read into. /// The offset to start storing data at. /// The number of bytes to read /// The async callback to use. /// The state to use. /// Returns an /// Any access public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { throw new NotSupportedException("DeflaterOutputStream BeginRead not currently supported"); } /// /// Asynchronous writes arent supported, a NotSupportedException is always thrown /// /// The buffer to write. /// The offset to begin writing at. /// The number of bytes to write. /// The to use. /// The state object. /// Returns an IAsyncResult. /// Any access public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { throw new NotSupportedException("BeginWrite is not supported"); } /// /// Flushes the stream by calling Flush on the deflater and then /// on the underlying stream. This ensures that all bytes are flushed. /// public override void Flush() { deflater_.Flush(); Deflate(); baseOutputStream_.Flush(); } /// /// Calls and closes the underlying /// stream when is true. /// public override void Close() { if ( !isClosed_ ) { isClosed_ = true; try { Finish(); #if NETCF_1_0 keys=null; #else if ( cryptoTransform_ != null ) { cryptoTransform_.Dispose(); cryptoTransform_ = null; } #endif } finally { if( isStreamOwner_ ) { baseOutputStream_.Close(); } } } } /// /// Writes a single byte to the compressed output stream. /// /// /// The byte value. /// public override void WriteByte(byte value) { byte[] b = new byte[1]; b[0] = value; Write(b, 0, 1); } /// /// Writes bytes from an array to the compressed stream. /// /// /// The byte array /// /// /// The offset into the byte array where to start. /// /// /// The number of bytes to write. /// public override void Write(byte[] buffer, int offset, int count) { deflater_.SetInput(buffer, offset, count); Deflate(); } #endregion #region Instance Fields /// /// This buffer is used temporarily to retrieve the bytes from the /// deflater and write them to the underlying output stream. /// byte[] buffer_; /// /// The deflater which is used to deflate the stream. /// protected Deflater deflater_; /// /// Base stream the deflater depends on. /// protected Stream baseOutputStream_; bool isClosed_; bool isStreamOwner_ = true; #endregion } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/Compression/Streams/InflaterInputStream.cs0000664000175000017500000005103610670310216030464 0ustar jtaylorjtaylor// InflaterInputStream.cs // // Copyright (C) 2001 Mike Krueger // Copyright (C) 2004 John Reilly // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using System.IO; #if !NETCF_1_0 using System.Security.Cryptography; #endif using ICSharpCode.SharpZipLib.Zip.Compression; using ICSharpCode.SharpZipLib.Checksums; namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams { /// /// An input buffer customised for use by /// /// /// The buffer supports decryption of incoming data. /// public class InflaterInputBuffer { #region Constructors /// /// Initialise a new instance of with a default buffer size /// /// The stream to buffer. public InflaterInputBuffer(Stream stream) : this(stream , 4096) { } /// /// Initialise a new instance of /// /// The stream to buffer. /// The size to use for the buffer /// A minimum buffer size of 1KB is permitted. Lower sizes are treated as 1KB. public InflaterInputBuffer(Stream stream, int bufferSize) { inputStream = stream; if ( bufferSize < 1024 ) { bufferSize = 1024; } rawData = new byte[bufferSize]; clearText = rawData; } #endregion /// /// Get the length of bytes bytes in the /// public int RawLength { get { return rawLength; } } /// /// Get the contents of the raw data buffer. /// /// This may contain encrypted data. public byte[] RawData { get { return rawData; } } /// /// Get the number of useable bytes in /// public int ClearTextLength { get { return clearTextLength; } } /// /// Get the contents of the clear text buffer. /// public byte[] ClearText { get { return clearText; } } /// /// Get/set the number of bytes available /// public int Available { get { return available; } set { available = value; } } /// /// Call passing the current clear text buffer contents. /// /// The inflater to set input for. public void SetInflaterInput(Inflater inflater) { if ( available > 0 ) { inflater.SetInput(clearText, clearTextLength - available, available); available = 0; } } /// /// Fill the buffer from the underlying input stream. /// public void Fill() { rawLength = 0; int toRead = rawData.Length; while (toRead > 0) { int count = inputStream.Read(rawData, rawLength, toRead); if ( count <= 0 ) { if (rawLength == 0) { throw new SharpZipBaseException("Unexpected EOF"); } break; } rawLength += count; toRead -= count; } #if !NETCF_1_0 if ( cryptoTransform != null ) { clearTextLength = cryptoTransform.TransformBlock(rawData, 0, rawLength, clearText, 0); } else #endif { clearTextLength = rawLength; } available = clearTextLength; } /// /// Read a buffer directly from the input stream /// /// The buffer to fill /// Returns the number of bytes read. public int ReadRawBuffer(byte[] buffer) { return ReadRawBuffer(buffer, 0, buffer.Length); } /// /// Read a buffer directly from the input stream /// /// The buffer to read into /// The offset to start reading data into. /// The number of bytes to read. /// Returns the number of bytes read. public int ReadRawBuffer(byte[] outBuffer, int offset, int length) { if ( length < 0 ) { throw new ArgumentOutOfRangeException("length"); } int currentOffset = offset; int currentLength = length; while ( currentLength > 0 ) { if ( available <= 0 ) { Fill(); if (available <= 0) { return 0; } } int toCopy = Math.Min(currentLength, available); System.Array.Copy(rawData, rawLength - (int)available, outBuffer, currentOffset, toCopy); currentOffset += toCopy; currentLength -= toCopy; available -= toCopy; } return length; } /// /// Read clear text data from the input stream. /// /// The buffer to add data to. /// The offset to start adding data at. /// The number of bytes to read. /// Returns the number of bytes actually read. public int ReadClearTextBuffer(byte[] outBuffer, int offset, int length) { if ( length < 0 ) { throw new ArgumentOutOfRangeException("length"); } int currentOffset = offset; int currentLength = length; while ( currentLength > 0 ) { if ( available <= 0 ) { Fill(); if (available <= 0) { return 0; } } int toCopy = Math.Min(currentLength, available); System.Array.Copy(clearText, clearTextLength - (int)available, outBuffer, currentOffset, toCopy); currentOffset += toCopy; currentLength -= toCopy; available -= toCopy; } return length; } /// /// Read a from the input stream. /// /// Returns the byte read. public int ReadLeByte() { if (available <= 0) { Fill(); if (available <= 0) { throw new ZipException("EOF in header"); } } byte result = (byte)(rawData[rawLength - available] & 0xff); available -= 1; return result; } /// /// Read an in little endian byte order. /// /// The short value read case to an int. public int ReadLeShort() { return ReadLeByte() | (ReadLeByte() << 8); } /// /// Read an in little endian byte order. /// /// The int value read. public int ReadLeInt() { return ReadLeShort() | (ReadLeShort() << 16); } /// /// Read a in little endian byte order. /// /// The long value read. public long ReadLeLong() { return (uint)ReadLeInt() | ((long)ReadLeInt() << 32); } #if !NETCF_1_0 /// /// Get/set the to apply to any data. /// /// Set this value to null to have no transform applied. public ICryptoTransform CryptoTransform { set { cryptoTransform = value; if ( cryptoTransform != null ) { if ( rawData == clearText ) { if ( internalClearText == null ) { internalClearText = new byte[4096]; } clearText = internalClearText; } clearTextLength = rawLength; if ( available > 0 ) { cryptoTransform.TransformBlock(rawData, rawLength - available, available, clearText, rawLength - available); } } else { clearText = rawData; clearTextLength = rawLength; } } } #endif #region Instance Fields int rawLength; byte[] rawData; int clearTextLength; byte[] clearText; #if !NETCF_1_0 byte[] internalClearText; #endif int available; #if !NETCF_1_0 ICryptoTransform cryptoTransform; #endif Stream inputStream; #endregion } /// /// This filter stream is used to decompress data compressed using the "deflate" /// format. The "deflate" format is described in RFC 1951. /// /// This stream may form the basis for other decompression filters, such /// as the GZipInputStream. /// /// Author of the original java version : John Leuner. /// public class InflaterInputStream : Stream { #region Constructors /// /// Create an InflaterInputStream with the default decompressor /// and a default buffer size of 4KB. /// /// /// The InputStream to read bytes from /// public InflaterInputStream(Stream baseInputStream) : this(baseInputStream, new Inflater(), 4096) { } /// /// Create an InflaterInputStream with the specified decompressor /// and a default buffer size of 4KB. /// /// /// The source of input data /// /// /// The decompressor used to decompress data read from baseInputStream /// public InflaterInputStream(Stream baseInputStream, Inflater inf) : this(baseInputStream, inf, 4096) { } /// /// Create an InflaterInputStream with the specified decompressor /// and the specified buffer size. /// /// /// The InputStream to read bytes from /// /// /// The decompressor to use /// /// /// Size of the buffer to use /// public InflaterInputStream(Stream baseInputStream, Inflater inflater, int bufferSize) { if (baseInputStream == null) { throw new ArgumentNullException("baseInputStream"); } if (inflater == null) { throw new ArgumentNullException("inflater"); } if (bufferSize <= 0) { throw new ArgumentOutOfRangeException("bufferSize"); } this.baseInputStream = baseInputStream; this.inf = inflater; inputBuffer = new InflaterInputBuffer(baseInputStream, bufferSize); } #endregion /// /// Get/set flag indicating ownership of underlying stream. /// When the flag is true will close the underlying stream also. /// /// /// The default value is true. /// public bool IsStreamOwner { get { return isStreamOwner; } set { isStreamOwner = value; } } /// /// Skip specified number of bytes of uncompressed data /// /// /// Number of bytes to skip /// /// /// The number of bytes skipped, zero if the end of /// stream has been reached /// /// /// Number of bytes to skip is less than zero /// public long Skip(long count) { if (count < 0) { throw new ArgumentOutOfRangeException("count"); } // v0.80 Skip by seeking if underlying stream supports it... if (baseInputStream.CanSeek) { baseInputStream.Seek(count, SeekOrigin.Current); return count; } else { int len = 2048; if (count < len) { len = (int) count; } byte[] tmp = new byte[len]; return (long)baseInputStream.Read(tmp, 0, tmp.Length); } } /// /// Clear any cryptographic state. /// protected void StopDecrypting() { #if !NETCF_1_0 inputBuffer.CryptoTransform = null; #endif } /// /// Returns 0 once the end of the stream (EOF) has been reached. /// Otherwise returns 1. /// public virtual int Available { get { return inf.IsFinished ? 0 : 1; } } /// /// Fills the buffer with more data to decompress. /// /// /// Stream ends early /// protected void Fill() { inputBuffer.Fill(); inputBuffer.SetInflaterInput(inf); } #region Stream Overrides /// /// Gets a value indicating whether the current stream supports reading /// public override bool CanRead { get { return baseInputStream.CanRead; } } /// /// Gets a value of false indicating seeking is not supported for this stream. /// public override bool CanSeek { get { return false; } } /// /// Gets a value of false indicating that this stream is not writeable. /// public override bool CanWrite { get { return false; } } /// /// A value representing the length of the stream in bytes. /// public override long Length { get { return inputBuffer.RawLength; } } /// /// The current position within the stream. /// Throws a NotSupportedException when attempting to set the position /// /// Attempting to set the position public override long Position { get { return baseInputStream.Position; } set { throw new NotSupportedException("InflaterInputStream Position not supported"); } } /// /// Flushes the baseInputStream /// public override void Flush() { baseInputStream.Flush(); } /// /// Sets the position within the current stream /// Always throws a NotSupportedException /// /// The relative offset to seek to. /// The defining where to seek from. /// The new position in the stream. /// Any access public override long Seek(long offset, SeekOrigin origin) { throw new NotSupportedException("Seek not supported"); } /// /// Set the length of the current stream /// Always throws a NotSupportedException /// /// The new length value for the stream. /// Any access public override void SetLength(long value) { throw new NotSupportedException("InflaterInputStream SetLength not supported"); } /// /// Writes a sequence of bytes to stream and advances the current position /// This method always throws a NotSupportedException /// /// Thew buffer containing data to write. /// The offset of the first byte to write. /// The number of bytes to write. /// Any access public override void Write(byte[] buffer, int offset, int count) { throw new NotSupportedException("InflaterInputStream Write not supported"); } /// /// Writes one byte to the current stream and advances the current position /// Always throws a NotSupportedException /// /// The byte to write. /// Any access public override void WriteByte(byte value) { throw new NotSupportedException("InflaterInputStream WriteByte not supported"); } /// /// Entry point to begin an asynchronous write. Always throws a NotSupportedException. /// /// The buffer to write data from /// Offset of first byte to write /// The maximum number of bytes to write /// The method to be called when the asynchronous write operation is completed /// A user-provided object that distinguishes this particular asynchronous write request from other requests /// An IAsyncResult that references the asynchronous write /// Any access public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { throw new NotSupportedException("InflaterInputStream BeginWrite not supported"); } /// /// Closes the input stream. When /// is true the underlying stream is also closed. /// public override void Close() { if ( !isClosed ) { isClosed = true; if ( isStreamOwner ) { baseInputStream.Close(); } } } /// /// Reads decompressed data into the provided buffer byte array /// /// /// The array to read and decompress data into /// /// /// The offset indicating where the data should be placed /// /// /// The number of bytes to decompress /// /// The number of bytes read. Zero signals the end of stream /// /// Inflater needs a dictionary /// public override int Read(byte[] buffer, int offset, int count) { if (inf.IsNeedingDictionary) { throw new SharpZipBaseException("Need a dictionary"); } int remainingBytes = count; while (true) { int bytesRead = inf.Inflate(buffer, offset, remainingBytes); offset += bytesRead; remainingBytes -= bytesRead; if (remainingBytes == 0 || inf.IsFinished) { break; } if ( inf.IsNeedingInput ) { Fill(); } else if ( bytesRead == 0 ) { throw new ZipException("Dont know what to do"); } } return count - remainingBytes; } #endregion #region Instance Fields /// /// Decompressor for this stream /// protected Inflater inf; /// /// Input buffer for this stream. /// protected InflaterInputBuffer inputBuffer; /// /// Base stream the inflater reads from. /// protected Stream baseInputStream; /// /// The compressed size /// protected long csize; /// /// Flag indicating wether this instance has been closed or not. /// bool isClosed; /// /// Flag indicating wether this instance is designated the stream owner. /// When closing if this flag is true the underlying stream is closed. /// bool isStreamOwner = true; #endregion } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/Compression/DeflaterEngine.cs0000664000175000017500000005715010670213676026001 0ustar jtaylorjtaylor// DeflaterEngine.cs // // Copyright (C) 2001 Mike Krueger // Copyright (C) 2004 John Reilly // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using ICSharpCode.SharpZipLib.Checksums; namespace ICSharpCode.SharpZipLib.Zip.Compression { /// /// Strategies for deflater /// public enum DeflateStrategy { /// /// The default strategy /// Default = 0, /// /// This strategy will only allow longer string repetitions. It is /// useful for random data with a small character set. /// Filtered = 1, /// /// This strategy will not look for string repetitions at all. It /// only encodes with Huffman trees (which means, that more common /// characters get a smaller encoding. /// HuffmanOnly = 2 } // DEFLATE ALGORITHM: // // The uncompressed stream is inserted into the window array. When // the window array is full the first half is thrown away and the // second half is copied to the beginning. // // The head array is a hash table. Three characters build a hash value // and they the value points to the corresponding index in window of // the last string with this hash. The prev array implements a // linked list of matches with the same hash: prev[index & WMASK] points // to the previous index with the same hash. // /// /// Low level compression engine for deflate algorithm which uses a 32K sliding window /// with secondary compression from Huffman/Shannon-Fano codes. /// public class DeflaterEngine : DeflaterConstants { #region Constants const int TooFar = 4096; #endregion #region Constructors /// /// Construct instance with pending buffer /// /// /// Pending buffer to use /// > public DeflaterEngine(DeflaterPending pending) { this.pending = pending; huffman = new DeflaterHuffman(pending); adler = new Adler32(); window = new byte[2 * WSIZE]; head = new short[HASH_SIZE]; prev = new short[WSIZE]; // We start at index 1, to avoid an implementation deficiency, that // we cannot build a repeat pattern at index 0. blockStart = strstart = 1; } #endregion /// /// Deflate drives actual compression of data /// /// True to flush input buffers /// Finish deflation with the current input. /// Returns true if progress has been made. public bool Deflate(bool flush, bool finish) { bool progress; do { FillWindow(); bool canFlush = flush && (inputOff == inputEnd); #if DebugDeflation if (DeflaterConstants.DEBUGGING) { Console.WriteLine("window: [" + blockStart + "," + strstart + "," + lookahead + "], " + compressionFunction + "," + canFlush); } #endif switch (compressionFunction) { case DEFLATE_STORED: progress = DeflateStored(canFlush, finish); break; case DEFLATE_FAST: progress = DeflateFast(canFlush, finish); break; case DEFLATE_SLOW: progress = DeflateSlow(canFlush, finish); break; default: throw new InvalidOperationException("unknown compressionFunction"); } } while (pending.IsFlushed && progress); // repeat while we have no pending output and progress was made return progress; } /// /// Sets input data to be deflated. Should only be called when NeedsInput() /// returns true /// /// The buffer containing input data. /// The offset of the first byte of data. /// The number of bytes of data to use as input. public void SetInput(byte[] buffer, int offset, int count) { if ( buffer == null ) { throw new ArgumentNullException("buffer"); } if ( offset < 0 ) { throw new ArgumentOutOfRangeException("offset"); } if ( count < 0 ) { throw new ArgumentOutOfRangeException("count"); } if (inputOff < inputEnd) { throw new InvalidOperationException("Old input was not completely processed"); } int end = offset + count; /* We want to throw an ArrayIndexOutOfBoundsException early. The * check is very tricky: it also handles integer wrap around. */ if ((offset > end) || (end > buffer.Length) ) { throw new ArgumentOutOfRangeException("count"); } inputBuf = buffer; inputOff = offset; inputEnd = end; } /// /// Determines if more input is needed. /// /// Return true if input is needed via SetInput public bool NeedsInput() { return (inputEnd == inputOff); } /// /// Set compression dictionary /// /// The buffer containing the dictionary data /// The offset in the buffer for the first byte of data /// The length of the dictionary data. public void SetDictionary(byte[] buffer, int offset, int length) { #if DebugDeflation if (DeflaterConstants.DEBUGGING && (strstart != 1) ) { throw new InvalidOperationException("strstart not 1"); } #endif adler.Update(buffer, offset, length); if (length < MIN_MATCH) { return; } if (length > MAX_DIST) { offset += length - MAX_DIST; length = MAX_DIST; } System.Array.Copy(buffer, offset, window, strstart, length); UpdateHash(); --length; while (--length > 0) { InsertString(); strstart++; } strstart += 2; blockStart = strstart; } /// /// Reset internal state /// public void Reset() { huffman.Reset(); adler.Reset(); blockStart = strstart = 1; lookahead = 0; totalIn = 0; prevAvailable = false; matchLen = MIN_MATCH - 1; for (int i = 0; i < HASH_SIZE; i++) { head[i] = 0; } for (int i = 0; i < WSIZE; i++) { prev[i] = 0; } } /// /// Reset Adler checksum /// public void ResetAdler() { adler.Reset(); } /// /// Get current value of Adler checksum /// public int Adler { get { return unchecked((int)adler.Value); } } /// /// Total data processed /// public int TotalIn { get { return totalIn; } } /// /// Get/set the deflate strategy /// public DeflateStrategy Strategy { get { return strategy; } set { strategy = value; } } /// /// Set the deflate level (0-9) /// /// The value to set the level to. public void SetLevel(int level) { if ( (level < 0) || (level > 9) ) { throw new ArgumentOutOfRangeException("level"); } goodLength = DeflaterConstants.GOOD_LENGTH[level]; max_lazy = DeflaterConstants.MAX_LAZY[level]; niceLength = DeflaterConstants.NICE_LENGTH[level]; max_chain = DeflaterConstants.MAX_CHAIN[level]; if (DeflaterConstants.COMPR_FUNC[level] != compressionFunction) { #if DebugDeflation if (DeflaterConstants.DEBUGGING) { Console.WriteLine("Change from " + compressionFunction + " to " + DeflaterConstants.COMPR_FUNC[level]); } #endif switch (compressionFunction) { case DEFLATE_STORED: if (strstart > blockStart) { huffman.FlushStoredBlock(window, blockStart, strstart - blockStart, false); blockStart = strstart; } UpdateHash(); break; case DEFLATE_FAST: if (strstart > blockStart) { huffman.FlushBlock(window, blockStart, strstart - blockStart, false); blockStart = strstart; } break; case DEFLATE_SLOW: if (prevAvailable) { huffman.TallyLit(window[strstart-1] & 0xff); } if (strstart > blockStart) { huffman.FlushBlock(window, blockStart, strstart - blockStart, false); blockStart = strstart; } prevAvailable = false; matchLen = MIN_MATCH - 1; break; } compressionFunction = COMPR_FUNC[level]; } } /// /// Fill the window /// public void FillWindow() { /* If the window is almost full and there is insufficient lookahead, * move the upper half to the lower one to make room in the upper half. */ if (strstart >= WSIZE + MAX_DIST) { SlideWindow(); } /* If there is not enough lookahead, but still some input left, * read in the input */ while (lookahead < DeflaterConstants.MIN_LOOKAHEAD && inputOff < inputEnd) { int more = 2 * WSIZE - lookahead - strstart; if (more > inputEnd - inputOff) { more = inputEnd - inputOff; } System.Array.Copy(inputBuf, inputOff, window, strstart + lookahead, more); adler.Update(inputBuf, inputOff, more); inputOff += more; totalIn += more; lookahead += more; } if (lookahead >= MIN_MATCH) { UpdateHash(); } } void UpdateHash() { /* if (DEBUGGING) { Console.WriteLine("updateHash: "+strstart); } */ ins_h = (window[strstart] << HASH_SHIFT) ^ window[strstart + 1]; } /// /// Inserts the current string in the head hash and returns the previous /// value for this hash. /// /// The previous hash value int InsertString() { short match; int hash = ((ins_h << HASH_SHIFT) ^ window[strstart + (MIN_MATCH -1)]) & HASH_MASK; #if DebugDeflation if (DeflaterConstants.DEBUGGING) { if (hash != (((window[strstart] << (2*HASH_SHIFT)) ^ (window[strstart + 1] << HASH_SHIFT) ^ (window[strstart + 2])) & HASH_MASK)) { throw new SharpZipBaseException("hash inconsistent: " + hash + "/" +window[strstart] + "," +window[strstart + 1] + "," +window[strstart + 2] + "," + HASH_SHIFT); } } #endif prev[strstart & WMASK] = match = head[hash]; head[hash] = unchecked((short)strstart); ins_h = hash; return match & 0xffff; } void SlideWindow() { Array.Copy(window, WSIZE, window, 0, WSIZE); matchStart -= WSIZE; strstart -= WSIZE; blockStart -= WSIZE; // Slide the hash table (could be avoided with 32 bit values // at the expense of memory usage). for (int i = 0; i < HASH_SIZE; ++i) { int m = head[i] & 0xffff; head[i] = (short)(m >= WSIZE ? (m - WSIZE) : 0); } // Slide the prev table. for (int i = 0; i < WSIZE; i++) { int m = prev[i] & 0xffff; prev[i] = (short)(m >= WSIZE ? (m - WSIZE) : 0); } } /// /// Find the best (longest) string in the window matching the /// string starting at strstart. /// /// Preconditions: /// /// strstart + MAX_MATCH <= window.length. /// /// /// True if a match greater than the minimum length is found bool FindLongestMatch(int curMatch) { int chainLength = this.max_chain; int niceLength = this.niceLength; short[] prev = this.prev; int scan = this.strstart; int match; int best_end = this.strstart + matchLen; int best_len = Math.Max(matchLen, MIN_MATCH - 1); int limit = Math.Max(strstart - MAX_DIST, 0); int strend = strstart + MAX_MATCH - 1; byte scan_end1 = window[best_end - 1]; byte scan_end = window[best_end]; // Do not waste too much time if we already have a good match: if (best_len >= this.goodLength) { chainLength >>= 2; } /* Do not look for matches beyond the end of the input. This is necessary * to make deflate deterministic. */ if (niceLength > lookahead) { niceLength = lookahead; } #if DebugDeflation if (DeflaterConstants.DEBUGGING && (strstart > 2 * WSIZE - MIN_LOOKAHEAD)) { throw new InvalidOperationException("need lookahead"); } #endif do { #if DebugDeflation if (DeflaterConstants.DEBUGGING && (curMatch >= strstart) ) { throw new InvalidOperationException("no future"); } #endif if (window[curMatch + best_len] != scan_end || window[curMatch + best_len - 1] != scan_end1 || window[curMatch] != window[scan] || window[curMatch + 1] != window[scan + 1]) { continue; } match = curMatch + 2; scan += 2; /* We check for insufficient lookahead only every 8th comparison; * the 256th check will be made at strstart + 258. */ while ( window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] && (scan < strend)) { // Do nothing } if (scan > best_end) { #if DebugDeflation if (DeflaterConstants.DEBUGGING && (ins_h == 0) ) Console.Error.WriteLine("Found match: " + curMatch + "-" + (scan - strstart)); #endif matchStart = curMatch; best_end = scan; best_len = scan - strstart; if (best_len >= niceLength) { break; } scan_end1 = window[best_end - 1]; scan_end = window[best_end]; } scan = strstart; } while ((curMatch = (prev[curMatch & WMASK] & 0xffff)) > limit && --chainLength != 0); matchLen = Math.Min(best_len, lookahead); return matchLen >= MIN_MATCH; } bool DeflateStored(bool flush, bool finish) { if (!flush && (lookahead == 0)) { return false; } strstart += lookahead; lookahead = 0; int storedLength = strstart - blockStart; if ((storedLength >= DeflaterConstants.MAX_BLOCK_SIZE) || // Block is full (blockStart < WSIZE && storedLength >= MAX_DIST) || // Block may move out of window flush) { bool lastBlock = finish; if (storedLength > DeflaterConstants.MAX_BLOCK_SIZE) { storedLength = DeflaterConstants.MAX_BLOCK_SIZE; lastBlock = false; } #if DebugDeflation if (DeflaterConstants.DEBUGGING) { Console.WriteLine("storedBlock[" + storedLength + "," + lastBlock + "]"); } #endif huffman.FlushStoredBlock(window, blockStart, storedLength, lastBlock); blockStart += storedLength; return !lastBlock; } return true; } bool DeflateFast(bool flush, bool finish) { if (lookahead < MIN_LOOKAHEAD && !flush) { return false; } while (lookahead >= MIN_LOOKAHEAD || flush) { if (lookahead == 0) { // We are flushing everything huffman.FlushBlock(window, blockStart, strstart - blockStart, finish); blockStart = strstart; return false; } if (strstart > 2 * WSIZE - MIN_LOOKAHEAD) { /* slide window, as FindLongestMatch needs this. * This should only happen when flushing and the window * is almost full. */ SlideWindow(); } int hashHead; if (lookahead >= MIN_MATCH && (hashHead = InsertString()) != 0 && strategy != DeflateStrategy.HuffmanOnly && strstart - hashHead <= MAX_DIST && FindLongestMatch(hashHead)) { // longestMatch sets matchStart and matchLen #if DebugDeflation if (DeflaterConstants.DEBUGGING) { for (int i = 0 ; i < matchLen; i++) { if (window[strstart + i] != window[matchStart + i]) { throw new SharpZipBaseException("Match failure"); } } } #endif bool full = huffman.TallyDist(strstart - matchStart, matchLen); lookahead -= matchLen; if (matchLen <= max_lazy && lookahead >= MIN_MATCH) { while (--matchLen > 0) { ++strstart; InsertString(); } ++strstart; } else { strstart += matchLen; if (lookahead >= MIN_MATCH - 1) { UpdateHash(); } } matchLen = MIN_MATCH - 1; if (!full) { continue; } } else { // No match found huffman.TallyLit(window[strstart] & 0xff); ++strstart; --lookahead; } if (huffman.IsFull()) { bool lastBlock = finish && (lookahead == 0); huffman.FlushBlock(window, blockStart, strstart - blockStart, lastBlock); blockStart = strstart; return !lastBlock; } } return true; } bool DeflateSlow(bool flush, bool finish) { if (lookahead < MIN_LOOKAHEAD && !flush) { return false; } while (lookahead >= MIN_LOOKAHEAD || flush) { if (lookahead == 0) { if (prevAvailable) { huffman.TallyLit(window[strstart-1] & 0xff); } prevAvailable = false; // We are flushing everything #if DebugDeflation if (DeflaterConstants.DEBUGGING && !flush) { throw new SharpZipBaseException("Not flushing, but no lookahead"); } #endif huffman.FlushBlock(window, blockStart, strstart - blockStart, finish); blockStart = strstart; return false; } if (strstart >= 2 * WSIZE - MIN_LOOKAHEAD) { /* slide window, as FindLongestMatch needs this. * This should only happen when flushing and the window * is almost full. */ SlideWindow(); } int prevMatch = matchStart; int prevLen = matchLen; if (lookahead >= MIN_MATCH) { int hashHead = InsertString(); if (strategy != DeflateStrategy.HuffmanOnly && hashHead != 0 && strstart - hashHead <= MAX_DIST && FindLongestMatch(hashHead)) { // longestMatch sets matchStart and matchLen // Discard match if too small and too far away if (matchLen <= 5 && (strategy == DeflateStrategy.Filtered || (matchLen == MIN_MATCH && strstart - matchStart > TooFar))) { matchLen = MIN_MATCH - 1; } } } // previous match was better if ((prevLen >= MIN_MATCH) && (matchLen <= prevLen) ) { #if DebugDeflation if (DeflaterConstants.DEBUGGING) { for (int i = 0 ; i < matchLen; i++) { if (window[strstart-1+i] != window[prevMatch + i]) throw new SharpZipBaseException(); } } #endif huffman.TallyDist(strstart - 1 - prevMatch, prevLen); prevLen -= 2; do { strstart++; lookahead--; if (lookahead >= MIN_MATCH) { InsertString(); } } while (--prevLen > 0); strstart ++; lookahead--; prevAvailable = false; matchLen = MIN_MATCH - 1; } else { if (prevAvailable) { huffman.TallyLit(window[strstart-1] & 0xff); } prevAvailable = true; strstart++; lookahead--; } if (huffman.IsFull()) { int len = strstart - blockStart; if (prevAvailable) { len--; } bool lastBlock = (finish && (lookahead == 0) && !prevAvailable); huffman.FlushBlock(window, blockStart, len, lastBlock); blockStart += len; return !lastBlock; } } return true; } #region Instance Fields // Hash index of string to be inserted int ins_h; /// /// Hashtable, hashing three characters to an index for window, so /// that window[index]..window[index+2] have this hash code. /// Note that the array should really be unsigned short, so you need /// to and the values with 0xffff. /// short[] head; /// /// prev[index & WMASK] points to the previous index that has the /// same hash code as the string starting at index. This way /// entries with the same hash code are in a linked list. /// Note that the array should really be unsigned short, so you need /// to and the values with 0xffff. /// short[] prev; int matchStart; // Length of best match int matchLen; // Set if previous match exists bool prevAvailable; int blockStart; /// /// Points to the current character in the window. /// int strstart; /// /// lookahead is the number of characters starting at strstart in /// window that are valid. /// So window[strstart] until window[strstart+lookahead-1] are valid /// characters. /// int lookahead; /// /// This array contains the part of the uncompressed stream that /// is of relevance. The current character is indexed by strstart. /// byte[] window; DeflateStrategy strategy; int max_chain, max_lazy, niceLength, goodLength; /// /// The current compression function. /// int compressionFunction; /// /// The input data for compression. /// byte[] inputBuf; /// /// The total bytes of input read. /// int totalIn; /// /// The offset into inputBuf, where input data starts. /// int inputOff; /// /// The end offset of the input data. /// int inputEnd; DeflaterPending pending; DeflaterHuffman huffman; /// /// The adler checksum /// Adler32 adler; #endregion } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/Compression/Inflater.cs0000664000175000017500000006052210614545554024667 0ustar jtaylorjtaylor// Inflater.cs // // Copyright (C) 2001 Mike Krueger // Copyright (C) 2004 John Reilly // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using ICSharpCode.SharpZipLib.Checksums; using ICSharpCode.SharpZipLib.Zip.Compression.Streams; namespace ICSharpCode.SharpZipLib.Zip.Compression { /// /// Inflater is used to decompress data that has been compressed according /// to the "deflate" standard described in rfc1951. /// /// By default Zlib (rfc1950) headers and footers are expected in the input. /// You can use constructor public Inflater(bool noHeader) passing true /// if there is no Zlib header information /// /// The usage is as following. First you have to set some input with /// SetInput(), then Inflate() it. If inflate doesn't /// inflate any bytes there may be three reasons: ///
    ///
  • IsNeedingInput() returns true because the input buffer is empty. /// You have to provide more input with SetInput(). /// NOTE: IsNeedingInput() also returns true when, the stream is finished. ///
  • ///
  • IsNeedingDictionary() returns true, you have to provide a preset /// dictionary with SetDictionary().
  • ///
  • IsFinished returns true, the inflater has finished.
  • ///
/// Once the first output byte is produced, a dictionary will not be /// needed at a later stage. /// /// author of the original java version : John Leuner, Jochen Hoenicke ///
public class Inflater { #region Constants/Readonly /// /// Copy lengths for literal codes 257..285 /// static readonly int[] CPLENS = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258 }; /// /// Extra bits for literal codes 257..285 /// static readonly int[] CPLEXT = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 }; /// /// Copy offsets for distance codes 0..29 /// static readonly int[] CPDIST = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 }; /// /// Extra bits for distance codes /// static readonly int[] CPDEXT = { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 }; /// /// These are the possible states for an inflater /// const int DECODE_HEADER = 0; const int DECODE_DICT = 1; const int DECODE_BLOCKS = 2; const int DECODE_STORED_LEN1 = 3; const int DECODE_STORED_LEN2 = 4; const int DECODE_STORED = 5; const int DECODE_DYN_HEADER = 6; const int DECODE_HUFFMAN = 7; const int DECODE_HUFFMAN_LENBITS = 8; const int DECODE_HUFFMAN_DIST = 9; const int DECODE_HUFFMAN_DISTBITS = 10; const int DECODE_CHKSUM = 11; const int FINISHED = 12; #endregion #region Instance Fields /// /// This variable contains the current state. /// int mode; /// /// The adler checksum of the dictionary or of the decompressed /// stream, as it is written in the header resp. footer of the /// compressed stream. /// Only valid if mode is DECODE_DICT or DECODE_CHKSUM. /// int readAdler; /// /// The number of bits needed to complete the current state. This /// is valid, if mode is DECODE_DICT, DECODE_CHKSUM, /// DECODE_HUFFMAN_LENBITS or DECODE_HUFFMAN_DISTBITS. /// int neededBits; int repLength; int repDist; int uncomprLen; /// /// True, if the last block flag was set in the last block of the /// inflated stream. This means that the stream ends after the /// current block. /// bool isLastBlock; /// /// The total number of inflated bytes. /// long totalOut; /// /// The total number of bytes set with setInput(). This is not the /// value returned by the TotalIn property, since this also includes the /// unprocessed input. /// long totalIn; /// /// This variable stores the noHeader flag that was given to the constructor. /// True means, that the inflated stream doesn't contain a Zlib header or /// footer. /// bool noHeader; StreamManipulator input; OutputWindow outputWindow; InflaterDynHeader dynHeader; InflaterHuffmanTree litlenTree, distTree; Adler32 adler; #endregion #region Constructors /// /// Creates a new inflater or RFC1951 decompressor /// RFC1950/Zlib headers and footers will be expected in the input data /// public Inflater() : this(false) { } /// /// Creates a new inflater. /// /// /// True if no RFC1950/Zlib header and footer fields are expected in the input data /// /// This is used for GZIPed/Zipped input. /// /// For compatibility with /// Sun JDK you should provide one byte of input more than needed in /// this case. /// public Inflater(bool noHeader) { this.noHeader = noHeader; this.adler = new Adler32(); input = new StreamManipulator(); outputWindow = new OutputWindow(); mode = noHeader ? DECODE_BLOCKS : DECODE_HEADER; } #endregion /// /// Resets the inflater so that a new stream can be decompressed. All /// pending input and output will be discarded. /// public void Reset() { mode = noHeader ? DECODE_BLOCKS : DECODE_HEADER; totalIn = 0; totalOut = 0; input.Reset(); outputWindow.Reset(); dynHeader = null; litlenTree = null; distTree = null; isLastBlock = false; adler.Reset(); } /// /// Decodes a zlib/RFC1950 header. /// /// /// False if more input is needed. /// /// /// The header is invalid. /// private bool DecodeHeader() { int header = input.PeekBits(16); if (header < 0) { return false; } input.DropBits(16); // The header is written in "wrong" byte order header = ((header << 8) | (header >> 8)) & 0xffff; if (header % 31 != 0) { throw new SharpZipBaseException("Header checksum illegal"); } if ((header & 0x0f00) != (Deflater.DEFLATED << 8)) { throw new SharpZipBaseException("Compression Method unknown"); } /* Maximum size of the backwards window in bits. * We currently ignore this, but we could use it to make the * inflater window more space efficient. On the other hand the * full window (15 bits) is needed most times, anyway. int max_wbits = ((header & 0x7000) >> 12) + 8; */ if ((header & 0x0020) == 0) { // Dictionary flag? mode = DECODE_BLOCKS; } else { mode = DECODE_DICT; neededBits = 32; } return true; } /// /// Decodes the dictionary checksum after the deflate header. /// /// /// False if more input is needed. /// private bool DecodeDict() { while (neededBits > 0) { int dictByte = input.PeekBits(8); if (dictByte < 0) { return false; } input.DropBits(8); readAdler = (readAdler << 8) | dictByte; neededBits -= 8; } return false; } /// /// Decodes the huffman encoded symbols in the input stream. /// /// /// false if more input is needed, true if output window is /// full or the current block ends. /// /// /// if deflated stream is invalid. /// private bool DecodeHuffman() { int free = outputWindow.GetFreeSpace(); while (free >= 258) { int symbol; switch (mode) { case DECODE_HUFFMAN: // This is the inner loop so it is optimized a bit while (((symbol = litlenTree.GetSymbol(input)) & ~0xff) == 0) { outputWindow.Write(symbol); if (--free < 258) { return true; } } if (symbol < 257) { if (symbol < 0) { return false; } else { // symbol == 256: end of block distTree = null; litlenTree = null; mode = DECODE_BLOCKS; return true; } } try { repLength = CPLENS[symbol - 257]; neededBits = CPLEXT[symbol - 257]; } catch (Exception) { throw new SharpZipBaseException("Illegal rep length code"); } goto case DECODE_HUFFMAN_LENBITS; // fall through case DECODE_HUFFMAN_LENBITS: if (neededBits > 0) { mode = DECODE_HUFFMAN_LENBITS; int i = input.PeekBits(neededBits); if (i < 0) { return false; } input.DropBits(neededBits); repLength += i; } mode = DECODE_HUFFMAN_DIST; goto case DECODE_HUFFMAN_DIST; // fall through case DECODE_HUFFMAN_DIST: symbol = distTree.GetSymbol(input); if (symbol < 0) { return false; } try { repDist = CPDIST[symbol]; neededBits = CPDEXT[symbol]; } catch (Exception) { throw new SharpZipBaseException("Illegal rep dist code"); } goto case DECODE_HUFFMAN_DISTBITS; // fall through case DECODE_HUFFMAN_DISTBITS: if (neededBits > 0) { mode = DECODE_HUFFMAN_DISTBITS; int i = input.PeekBits(neededBits); if (i < 0) { return false; } input.DropBits(neededBits); repDist += i; } outputWindow.Repeat(repLength, repDist); free -= repLength; mode = DECODE_HUFFMAN; break; default: throw new SharpZipBaseException("Inflater unknown mode"); } } return true; } /// /// Decodes the adler checksum after the deflate stream. /// /// /// false if more input is needed. /// /// /// If checksum doesn't match. /// private bool DecodeChksum() { while (neededBits > 0) { int chkByte = input.PeekBits(8); if (chkByte < 0) { return false; } input.DropBits(8); readAdler = (readAdler << 8) | chkByte; neededBits -= 8; } if ((int) adler.Value != readAdler) { throw new SharpZipBaseException("Adler chksum doesn't match: " + (int)adler.Value + " vs. " + readAdler); } mode = FINISHED; return false; } /// /// Decodes the deflated stream. /// /// /// false if more input is needed, or if finished. /// /// /// if deflated stream is invalid. /// private bool Decode() { switch (mode) { case DECODE_HEADER: return DecodeHeader(); case DECODE_DICT: return DecodeDict(); case DECODE_CHKSUM: return DecodeChksum(); case DECODE_BLOCKS: if (isLastBlock) { if (noHeader) { mode = FINISHED; return false; } else { input.SkipToByteBoundary(); neededBits = 32; mode = DECODE_CHKSUM; return true; } } int type = input.PeekBits(3); if (type < 0) { return false; } input.DropBits(3); if ((type & 1) != 0) { isLastBlock = true; } switch (type >> 1){ case DeflaterConstants.STORED_BLOCK: input.SkipToByteBoundary(); mode = DECODE_STORED_LEN1; break; case DeflaterConstants.STATIC_TREES: litlenTree = InflaterHuffmanTree.defLitLenTree; distTree = InflaterHuffmanTree.defDistTree; mode = DECODE_HUFFMAN; break; case DeflaterConstants.DYN_TREES: dynHeader = new InflaterDynHeader(); mode = DECODE_DYN_HEADER; break; default: throw new SharpZipBaseException("Unknown block type " + type); } return true; case DECODE_STORED_LEN1: { if ((uncomprLen = input.PeekBits(16)) < 0) { return false; } input.DropBits(16); mode = DECODE_STORED_LEN2; } goto case DECODE_STORED_LEN2; // fall through case DECODE_STORED_LEN2: { int nlen = input.PeekBits(16); if (nlen < 0) { return false; } input.DropBits(16); if (nlen != (uncomprLen ^ 0xffff)) { throw new SharpZipBaseException("broken uncompressed block"); } mode = DECODE_STORED; } goto case DECODE_STORED; // fall through case DECODE_STORED: { int more = outputWindow.CopyStored(input, uncomprLen); uncomprLen -= more; if (uncomprLen == 0) { mode = DECODE_BLOCKS; return true; } return !input.IsNeedingInput; } case DECODE_DYN_HEADER: if (!dynHeader.Decode(input)) { return false; } litlenTree = dynHeader.BuildLitLenTree(); distTree = dynHeader.BuildDistTree(); mode = DECODE_HUFFMAN; goto case DECODE_HUFFMAN; // fall through case DECODE_HUFFMAN: case DECODE_HUFFMAN_LENBITS: case DECODE_HUFFMAN_DIST: case DECODE_HUFFMAN_DISTBITS: return DecodeHuffman(); case FINISHED: return false; default: throw new SharpZipBaseException("Inflater.Decode unknown mode"); } } /// /// Sets the preset dictionary. This should only be called, if /// needsDictionary() returns true and it should set the same /// dictionary, that was used for deflating. The getAdler() /// function returns the checksum of the dictionary needed. /// /// /// The dictionary. /// public void SetDictionary(byte[] buffer) { SetDictionary(buffer, 0, buffer.Length); } /// /// Sets the preset dictionary. This should only be called, if /// needsDictionary() returns true and it should set the same /// dictionary, that was used for deflating. The getAdler() /// function returns the checksum of the dictionary needed. /// /// /// The dictionary. /// /// /// The index into buffer where the dictionary starts. /// /// /// The number of bytes in the dictionary. /// /// /// No dictionary is needed. /// /// /// The adler checksum for the buffer is invalid /// public void SetDictionary(byte[] buffer, int index, int count) { if ( buffer == null ) { throw new ArgumentNullException("buffer"); } if ( index < 0 ) { throw new ArgumentOutOfRangeException("index"); } if ( count < 0 ) { throw new ArgumentOutOfRangeException("count"); } if (!IsNeedingDictionary) { throw new InvalidOperationException("Dictionary is not needed"); } adler.Update(buffer, index, count); if ((int)adler.Value != readAdler) { throw new SharpZipBaseException("Wrong adler checksum"); } adler.Reset(); outputWindow.CopyDict(buffer, index, count); mode = DECODE_BLOCKS; } /// /// Sets the input. This should only be called, if needsInput() /// returns true. /// /// /// the input. /// public void SetInput(byte[] buffer) { SetInput(buffer, 0, buffer.Length); } /// /// Sets the input. This should only be called, if needsInput() /// returns true. /// /// /// The source of input data /// /// /// The index into buffer where the input starts. /// /// /// The number of bytes of input to use. /// /// /// No input is needed. /// /// /// The index and/or count are wrong. /// public void SetInput(byte[] buffer, int index, int count) { input.SetInput(buffer, index, count); totalIn += (long)count; } /// /// Inflates the compressed stream to the output buffer. If this /// returns 0, you should check, whether IsNeedingDictionary(), /// IsNeedingInput() or IsFinished() returns true, to determine why no /// further output is produced. /// /// /// the output buffer. /// /// /// The number of bytes written to the buffer, 0 if no further /// output can be produced. /// /// /// if buffer has length 0. /// /// /// if deflated stream is invalid. /// public int Inflate(byte[] buffer) { if ( buffer == null ) { throw new ArgumentNullException("buffer"); } return Inflate(buffer, 0, buffer.Length); } /// /// Inflates the compressed stream to the output buffer. If this /// returns 0, you should check, whether needsDictionary(), /// needsInput() or finished() returns true, to determine why no /// further output is produced. /// /// /// the output buffer. /// /// /// the offset in buffer where storing starts. /// /// /// the maximum number of bytes to output. /// /// /// the number of bytes written to the buffer, 0 if no further output can be produced. /// /// /// if count is less than 0. /// /// /// if the index and / or count are wrong. /// /// /// if deflated stream is invalid. /// public int Inflate(byte[] buffer, int offset, int count) { if ( buffer == null ) { throw new ArgumentNullException("buffer"); } if ( count < 0 ) { #if NETCF_1_0 throw new ArgumentOutOfRangeException("count"); #else throw new ArgumentOutOfRangeException("count", "count cannot be negative"); #endif } if ( offset < 0 ) { #if NETCF_1_0 throw new ArgumentOutOfRangeException("offset"); #else throw new ArgumentOutOfRangeException("offset", "offset cannot be negative"); #endif } if ( offset + count > buffer.Length ) { throw new ArgumentException("count exceeds buffer bounds"); } // Special case: count may be zero if (count == 0) { if (!IsFinished) { // -jr- 08-Nov-2003 INFLATE_BUG fix.. Decode(); } return 0; } int bytesCopied = 0; do { if (mode != DECODE_CHKSUM) { /* Don't give away any output, if we are waiting for the * checksum in the input stream. * * With this trick we have always: * IsNeedingInput() and not IsFinished() * implies more output can be produced. */ int more = outputWindow.CopyOutput(buffer, offset, count); if ( more > 0 ) { adler.Update(buffer, offset, more); offset += more; bytesCopied += more; totalOut += (long)more; count -= more; if (count == 0) { return bytesCopied; } } } } while (Decode() || ((outputWindow.GetAvailable() > 0) && (mode != DECODE_CHKSUM))); return bytesCopied; } /// /// Returns true, if the input buffer is empty. /// You should then call setInput(). /// NOTE: This method also returns true when the stream is finished. /// public bool IsNeedingInput { get { return input.IsNeedingInput; } } /// /// Returns true, if a preset dictionary is needed to inflate the input. /// public bool IsNeedingDictionary { get { return mode == DECODE_DICT && neededBits == 0; } } /// /// Returns true, if the inflater has finished. This means, that no /// input is needed and no output can be produced. /// public bool IsFinished { get { return mode == FINISHED && outputWindow.GetAvailable() == 0; } } /// /// Gets the adler checksum. This is either the checksum of all /// uncompressed bytes returned by inflate(), or if needsDictionary() /// returns true (and thus no output was yet produced) this is the /// adler checksum of the expected dictionary. /// /// /// the adler checksum. /// public int Adler { get { return IsNeedingDictionary ? readAdler : (int) adler.Value; } } /// /// Gets the total number of output bytes returned by Inflate(). /// /// /// the total number of output bytes. /// public long TotalOut { get { return totalOut; } } /// /// Gets the total number of processed compressed input bytes. /// /// /// The total number of bytes of processed input bytes. /// public long TotalIn { get { return totalIn - (long)RemainingInput; } } /// /// Gets the number of unprocessed input bytes. Useful, if the end of the /// stream is reached and you want to further process the bytes after /// the deflate stream. /// /// /// The number of bytes of the input which have not been processed. /// public int RemainingInput { // TODO: This should be a long? get { return input.AvailableBytes; } } } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/Compression/InflaterHuffmanTree.cs0000664000175000017500000001545710572513600027011 0ustar jtaylorjtaylor// InflaterHuffmanTree.cs // Copyright (C) 2001 Mike Krueger // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using ICSharpCode.SharpZipLib.Zip.Compression.Streams; namespace ICSharpCode.SharpZipLib.Zip.Compression { /// /// Huffman tree used for inflation /// public class InflaterHuffmanTree { #region Constants const int MAX_BITLEN = 15; #endregion #region Instance Fields short[] tree; #endregion /// /// Literal length tree /// public static InflaterHuffmanTree defLitLenTree; /// /// Distance tree /// public static InflaterHuffmanTree defDistTree; static InflaterHuffmanTree() { try { byte[] codeLengths = new byte[288]; int i = 0; while (i < 144) { codeLengths[i++] = 8; } while (i < 256) { codeLengths[i++] = 9; } while (i < 280) { codeLengths[i++] = 7; } while (i < 288) { codeLengths[i++] = 8; } defLitLenTree = new InflaterHuffmanTree(codeLengths); codeLengths = new byte[32]; i = 0; while (i < 32) { codeLengths[i++] = 5; } defDistTree = new InflaterHuffmanTree(codeLengths); } catch (Exception) { throw new SharpZipBaseException("InflaterHuffmanTree: static tree length illegal"); } } #region Constructors /// /// Constructs a Huffman tree from the array of code lengths. /// /// /// the array of code lengths /// public InflaterHuffmanTree(byte[] codeLengths) { BuildTree(codeLengths); } #endregion void BuildTree(byte[] codeLengths) { int[] blCount = new int[MAX_BITLEN + 1]; int[] nextCode = new int[MAX_BITLEN + 1]; for (int i = 0; i < codeLengths.Length; i++) { int bits = codeLengths[i]; if (bits > 0) { blCount[bits]++; } } int code = 0; int treeSize = 512; for (int bits = 1; bits <= MAX_BITLEN; bits++) { nextCode[bits] = code; code += blCount[bits] << (16 - bits); if (bits >= 10) { /* We need an extra table for bit lengths >= 10. */ int start = nextCode[bits] & 0x1ff80; int end = code & 0x1ff80; treeSize += (end - start) >> (16 - bits); } } /* -jr comment this out! doesnt work for dynamic trees and pkzip 2.04g if (code != 65536) { throw new SharpZipBaseException("Code lengths don't add up properly."); } */ /* Now create and fill the extra tables from longest to shortest * bit len. This way the sub trees will be aligned. */ tree = new short[treeSize]; int treePtr = 512; for (int bits = MAX_BITLEN; bits >= 10; bits--) { int end = code & 0x1ff80; code -= blCount[bits] << (16 - bits); int start = code & 0x1ff80; for (int i = start; i < end; i += 1 << 7) { tree[DeflaterHuffman.BitReverse(i)] = (short) ((-treePtr << 4) | bits); treePtr += 1 << (bits-9); } } for (int i = 0; i < codeLengths.Length; i++) { int bits = codeLengths[i]; if (bits == 0) { continue; } code = nextCode[bits]; int revcode = DeflaterHuffman.BitReverse(code); if (bits <= 9) { do { tree[revcode] = (short) ((i << 4) | bits); revcode += 1 << bits; } while (revcode < 512); } else { int subTree = tree[revcode & 511]; int treeLen = 1 << (subTree & 15); subTree = -(subTree >> 4); do { tree[subTree | (revcode >> 9)] = (short) ((i << 4) | bits); revcode += 1 << bits; } while (revcode < treeLen); } nextCode[bits] = code + (1 << (16 - bits)); } } /// /// Reads the next symbol from input. The symbol is encoded using the /// huffman tree. /// /// /// input the input source. /// /// /// the next symbol, or -1 if not enough input is available. /// public int GetSymbol(StreamManipulator input) { int lookahead, symbol; if ((lookahead = input.PeekBits(9)) >= 0) { if ((symbol = tree[lookahead]) >= 0) { input.DropBits(symbol & 15); return symbol >> 4; } int subtree = -(symbol >> 4); int bitlen = symbol & 15; if ((lookahead = input.PeekBits(bitlen)) >= 0) { symbol = tree[subtree | (lookahead >> 9)]; input.DropBits(symbol & 15); return symbol >> 4; } else { int bits = input.AvailableBits; lookahead = input.PeekBits(bits); symbol = tree[subtree | (lookahead >> 9)]; if ((symbol & 15) <= bits) { input.DropBits(symbol & 15); return symbol >> 4; } else { return -1; } } } else { int bits = input.AvailableBits; lookahead = input.PeekBits(bits); symbol = tree[lookahead]; if (symbol >= 0 && (symbol & 15) <= bits) { input.DropBits(symbol & 15); return symbol >> 4; } else { return -1; } } } } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/Compression/InflaterDynHeader.cs0000664000175000017500000001410410651200354026431 0ustar jtaylorjtaylor// InflaterDynHeader.cs // Copyright (C) 2001 Mike Krueger // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using ICSharpCode.SharpZipLib.Zip.Compression.Streams; namespace ICSharpCode.SharpZipLib.Zip.Compression { class InflaterDynHeader { #region Constants const int LNUM = 0; const int DNUM = 1; const int BLNUM = 2; const int BLLENS = 3; const int LENS = 4; const int REPS = 5; static readonly int[] repMin = { 3, 3, 11 }; static readonly int[] repBits = { 2, 3, 7 }; static readonly int[] BL_ORDER = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; #endregion #region Constructors public InflaterDynHeader() { } #endregion public bool Decode(StreamManipulator input) { decode_loop: for (;;) { switch (mode) { case LNUM: lnum = input.PeekBits(5); if (lnum < 0) { return false; } lnum += 257; input.DropBits(5); // System.err.println("LNUM: "+lnum); mode = DNUM; goto case DNUM; // fall through case DNUM: dnum = input.PeekBits(5); if (dnum < 0) { return false; } dnum++; input.DropBits(5); // System.err.println("DNUM: "+dnum); num = lnum+dnum; litdistLens = new byte[num]; mode = BLNUM; goto case BLNUM; // fall through case BLNUM: blnum = input.PeekBits(4); if (blnum < 0) { return false; } blnum += 4; input.DropBits(4); blLens = new byte[19]; ptr = 0; // System.err.println("BLNUM: "+blnum); mode = BLLENS; goto case BLLENS; // fall through case BLLENS: while (ptr < blnum) { int len = input.PeekBits(3); if (len < 0) { return false; } input.DropBits(3); // System.err.println("blLens["+BL_ORDER[ptr]+"]: "+len); blLens[BL_ORDER[ptr]] = (byte) len; ptr++; } blTree = new InflaterHuffmanTree(blLens); blLens = null; ptr = 0; mode = LENS; goto case LENS; // fall through case LENS: { int symbol; while (((symbol = blTree.GetSymbol(input)) & ~15) == 0) { /* Normal case: symbol in [0..15] */ // System.err.println("litdistLens["+ptr+"]: "+symbol); litdistLens[ptr++] = lastLen = (byte)symbol; if (ptr == num) { /* Finished */ return true; } } /* need more input ? */ if (symbol < 0) { return false; } /* otherwise repeat code */ if (symbol >= 17) { /* repeat zero */ // System.err.println("repeating zero"); lastLen = 0; } else { if (ptr == 0) { throw new SharpZipBaseException(); } } repSymbol = symbol-16; } mode = REPS; goto case REPS; // fall through case REPS: { int bits = repBits[repSymbol]; int count = input.PeekBits(bits); if (count < 0) { return false; } input.DropBits(bits); count += repMin[repSymbol]; // System.err.println("litdistLens repeated: "+count); if (ptr + count > num) { throw new SharpZipBaseException(); } while (count-- > 0) { litdistLens[ptr++] = lastLen; } if (ptr == num) { /* Finished */ return true; } } mode = LENS; goto decode_loop; } } } public InflaterHuffmanTree BuildLitLenTree() { byte[] litlenLens = new byte[lnum]; Array.Copy(litdistLens, 0, litlenLens, 0, lnum); return new InflaterHuffmanTree(litlenLens); } public InflaterHuffmanTree BuildDistTree() { byte[] distLens = new byte[dnum]; Array.Copy(litdistLens, lnum, distLens, 0, dnum); return new InflaterHuffmanTree(distLens); } #region Instance Fields byte[] blLens; byte[] litdistLens; InflaterHuffmanTree blTree; int mode; int lnum, dnum, blnum, num; int repSymbol; byte lastLen; int ptr; #endregion } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/Compression/DeflaterConstants.cs0000664000175000017500000001346410572513600026537 0ustar jtaylorjtaylor// DeflaterConstants.cs // // Copyright (C) 2001 Mike Krueger // Copyright (C) 2004 John Reilly // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; namespace ICSharpCode.SharpZipLib.Zip.Compression { /// /// This class contains constants used for deflation. /// public class DeflaterConstants { /// /// Set to true to enable debugging /// public const bool DEBUGGING = false; /// /// Written to Zip file to identify a stored block /// public const int STORED_BLOCK = 0; /// /// Identifies static tree in Zip file /// public const int STATIC_TREES = 1; /// /// Identifies dynamic tree in Zip file /// public const int DYN_TREES = 2; /// /// Header flag indicating a preset dictionary for deflation /// public const int PRESET_DICT = 0x20; /// /// Sets internal buffer sizes for Huffman encoding /// public const int DEFAULT_MEM_LEVEL = 8; /// /// Internal compression engine constant /// public const int MAX_MATCH = 258; /// /// Internal compression engine constant /// public const int MIN_MATCH = 3; /// /// Internal compression engine constant /// public const int MAX_WBITS = 15; /// /// Internal compression engine constant /// public const int WSIZE = 1 << MAX_WBITS; /// /// Internal compression engine constant /// public const int WMASK = WSIZE - 1; /// /// Internal compression engine constant /// public const int HASH_BITS = DEFAULT_MEM_LEVEL + 7; /// /// Internal compression engine constant /// public const int HASH_SIZE = 1 << HASH_BITS; /// /// Internal compression engine constant /// public const int HASH_MASK = HASH_SIZE - 1; /// /// Internal compression engine constant /// public const int HASH_SHIFT = (HASH_BITS + MIN_MATCH - 1) / MIN_MATCH; /// /// Internal compression engine constant /// public const int MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1; /// /// Internal compression engine constant /// public const int MAX_DIST = WSIZE - MIN_LOOKAHEAD; /// /// Internal compression engine constant /// public const int PENDING_BUF_SIZE = 1 << (DEFAULT_MEM_LEVEL + 8); /// /// Internal compression engine constant /// public static int MAX_BLOCK_SIZE = Math.Min(65535, PENDING_BUF_SIZE - 5); /// /// Internal compression engine constant /// public const int DEFLATE_STORED = 0; /// /// Internal compression engine constant /// public const int DEFLATE_FAST = 1; /// /// Internal compression engine constant /// public const int DEFLATE_SLOW = 2; /// /// Internal compression engine constant /// public static int[] GOOD_LENGTH = { 0, 4, 4, 4, 4, 8, 8, 8, 32, 32 }; /// /// Internal compression engine constant /// public static int[] MAX_LAZY = { 0, 4, 5, 6, 4, 16, 16, 32, 128, 258 }; /// /// Internal compression engine constant /// public static int[] NICE_LENGTH = { 0, 8, 16, 32, 16, 32, 128, 128, 258, 258 }; /// /// Internal compression engine constant /// public static int[] MAX_CHAIN = { 0, 4, 8, 32, 16, 32, 128, 256, 1024, 4096 }; /// /// Internal compression engine constant /// public static int[] COMPR_FUNC = { 0, 1, 1, 1, 1, 2, 2, 2, 2, 2 }; } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/ZipEntry.cs0000664000175000017500000010313010670213756022375 0ustar jtaylorjtaylor// ZipEntry.cs // // Copyright (C) 2001 Mike Krueger // Copyright (C) 2004 John Reilly // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using System.IO; namespace ICSharpCode.SharpZipLib.Zip { /// /// Defines known values for the property. /// public enum HostSystemID { /// /// Host system = MSDOS /// Msdos = 0, /// /// Host system = Amiga /// Amiga = 1, /// /// Host system = Open VMS /// OpenVms = 2, /// /// Host system = Unix /// Unix = 3, /// /// Host system = VMCms /// VMCms = 4, /// /// Host system = Atari ST /// AtariST = 5, /// /// Host system = OS2 /// OS2 = 6, /// /// Host system = Macintosh /// Macintosh = 7, /// /// Host system = ZSystem /// ZSystem = 8, /// /// Host system = Cpm /// Cpm = 9, /// /// Host system = Windows NT /// WindowsNT = 10, /// /// Host system = MVS /// MVS = 11, /// /// Host system = VSE /// Vse = 12, /// /// Host system = Acorn RISC /// AcornRisc = 13, /// /// Host system = VFAT /// Vfat = 14, /// /// Host system = Alternate MVS /// AlternateMvs = 15, /// /// Host system = BEOS /// BeOS = 16, /// /// Host system = Tandem /// Tandem = 17, /// /// Host system = OS400 /// OS400 = 18, /// /// Host system = OSX /// OSX = 19, /// /// Host system = WinZIP AES /// WinZipAES = 99, } /// /// This class represents an entry in a zip archive. This can be a file /// or a directory /// ZipFile and ZipInputStream will give you instances of this class as /// information about the members in an archive. ZipOutputStream /// uses an instance of this class when creating an entry in a Zip file. ///
///
Author of the original java version : Jochen Hoenicke ///
public class ZipEntry : ICloneable { [Flags] enum Known : byte { None = 0, Size = 0x01, CompressedSize = 0x02, Crc = 0x04, Time = 0x08, ExternalAttributes = 0x10, } #region Constructors /// /// Creates a zip entry with the given name. /// /// /// The name for this entry. Can include directory components. /// The convention for names is 'unix' style paths with relative names only. /// There are with no device names and path elements are separated by '/' characters. /// /// /// The name passed is null /// public ZipEntry(string name) : this(name, 0, ZipConstants.VersionMadeBy, CompressionMethod.Deflated) { } /// /// Creates a zip entry with the given name and version required to extract /// /// /// The name for this entry. Can include directory components. /// The convention for names is 'unix' style paths with no device names and /// path elements separated by '/' characters. This is not enforced see CleanName /// on how to ensure names are valid if this is desired. /// /// /// The minimum 'feature version' required this entry /// /// /// The name passed is null /// internal ZipEntry(string name, int versionRequiredToExtract) : this(name, versionRequiredToExtract, ZipConstants.VersionMadeBy, CompressionMethod.Deflated) { } /// /// Initializes an entry with the given name and made by information /// /// Name for this entry /// Version and HostSystem Information /// Minimum required zip feature version required to extract this entry /// Compression method for this entry. /// /// The name passed is null /// /// /// versionRequiredToExtract should be 0 (auto-calculate) or > 10 /// /// /// This constructor is used by the ZipFile class when reading from the central header /// It is not generally useful, use the constructor specifying the name only. /// internal ZipEntry(string name, int versionRequiredToExtract, int madeByInfo, CompressionMethod method) { if (name == null) { throw new System.ArgumentNullException("ZipEntry name"); } if ( name.Length > 0xffff ) { throw new ArgumentException("Name is too long", "name"); } if ( (versionRequiredToExtract != 0) && (versionRequiredToExtract < 10) ) { throw new ArgumentOutOfRangeException("versionRequiredToExtract"); } this.DateTime = System.DateTime.Now; this.name = name; this.versionMadeBy = (ushort)madeByInfo; this.versionToExtract = (ushort)versionRequiredToExtract; this.method = method; } /// /// Creates a deep copy of the given zip entry. /// /// /// The entry to copy. /// [Obsolete("Use Clone instead")] public ZipEntry(ZipEntry entry) { if ( entry == null ) { throw new ArgumentNullException("entry"); } known = entry.known; name = entry.name; size = entry.size; compressedSize = entry.compressedSize; crc = entry.crc; dosTime = entry.dosTime; method = entry.method; comment = entry.comment; versionToExtract = entry.versionToExtract; versionMadeBy = entry.versionMadeBy; externalFileAttributes = entry.externalFileAttributes; flags = entry.flags; zipFileIndex = entry.zipFileIndex; offset = entry.offset; forceZip64_ = entry.forceZip64_; if ( entry.extra != null ) { extra = new byte[entry.extra.Length]; Array.Copy(entry.extra, 0, extra, 0, entry.extra.Length); } } #endregion /// /// Get a value indicating wether the entry has a CRC value available. /// public bool HasCrc { get { return (known & Known.Crc) != 0; } } /// /// Get/Set flag indicating if entry is encrypted. /// A simple helper routine to aid interpretation of flags /// /// This is an assistant that interprets the flags property. public bool IsCrypted { get { return (flags & 1) != 0; } set { if (value) { flags |= 1; } else { flags &= ~1; } } } ///
/// Get / set a flag indicating wether entry name and comment text are /// encoded in unicode UTF8. /// /// This is an assistant that interprets the flags property. public bool IsUnicodeText { get { return ( flags & (int)GeneralBitFlags.UnicodeText ) != 0; } set { if ( value ) { flags |= (int)GeneralBitFlags.UnicodeText; } else { flags &= ~(int)GeneralBitFlags.UnicodeText; } } } /// /// Value used during password checking for PKZIP 2.0 / 'classic' encryption. /// internal byte CryptoCheckValue { get { return cryptoCheckValue_; } set { cryptoCheckValue_ = value; } } /// /// Get/Set general purpose bit flag for entry /// /// /// General purpose bit flag
///
/// Bit 0: If set, indicates the file is encrypted
/// Bit 1-2 Only used for compression type 6 Imploding, and 8, 9 deflating
/// Imploding:
/// Bit 1 if set indicates an 8K sliding dictionary was used. If clear a 4k dictionary was used
/// Bit 2 if set indicates 3 Shannon-Fanno trees were used to encode the sliding dictionary, 2 otherwise
///
/// Deflating:
/// Bit 2 Bit 1
/// 0 0 Normal compression was used
/// 0 1 Maximum compression was used
/// 1 0 Fast compression was used
/// 1 1 Super fast compression was used
///
/// Bit 3: If set, the fields crc-32, compressed size /// and uncompressed size are were not able to be written during zip file creation /// The correct values are held in a data descriptor immediately following the compressed data.
/// Bit 4: Reserved for use by PKZIP for enhanced deflating
/// Bit 5: If set indicates the file contains compressed patch data
/// Bit 6: If set indicates strong encryption was used.
/// Bit 7-10: Unused or reserved
/// Bit 11: If set the name and comments for this entry are in unicode.
/// Bit 12-15: Unused or reserved
///
/// /// public int Flags { get { return flags; } set { flags = value; } } /// /// Get/Set index of this entry in Zip file /// /// This is only valid when the entry is part of a public long ZipFileIndex { get { return zipFileIndex; } set { zipFileIndex = value; } } /// /// Get/set offset for use in central header /// public long Offset { get { return offset; } set { offset = value; } } /// /// Get/Set external file attributes as an integer. /// The values of this are operating system dependant see /// HostSystem for details /// public int ExternalFileAttributes { get { if ((known & Known.ExternalAttributes) == 0) { return -1; } else { return externalFileAttributes; } } set { externalFileAttributes = value; known |= Known.ExternalAttributes; } } /// /// Get the version made by for this entry or zero if unknown. /// The value / 10 indicates the major version number, and /// the value mod 10 is the minor version number /// public int VersionMadeBy { get { return (versionMadeBy & 0xff); } } /// /// Get a value indicating this entry is for a DOS/Windows system. /// public bool IsDOSEntry { get { return ((HostSystem == ( int )HostSystemID.Msdos) || (HostSystem == ( int )HostSystemID.WindowsNT)); } } /// /// Test the external attributes for this to /// see if the external attributes are Dos based (including WINNT and variants) /// and match the values /// /// The attributes to test. /// Returns true if the external attributes are known to be DOS/Windows /// based and have the same attributes set as the value passed. bool HasDosAttributes(int attributes) { bool result = false; if ( (known & Known.ExternalAttributes) != 0 ) { if ( ((HostSystem == (int)HostSystemID.Msdos) || (HostSystem == (int)HostSystemID.WindowsNT)) && (ExternalFileAttributes & attributes) == attributes) { result = true; } } return result; } /// /// Gets the compatability information for the external file attribute /// If the external file attributes are compatible with MS-DOS and can be read /// by PKZIP for DOS version 2.04g then this value will be zero. Otherwise the value /// will be non-zero and identify the host system on which the attributes are compatible. /// /// /// /// The values for this as defined in the Zip File format and by others are shown below. The values are somewhat /// misleading in some cases as they are not all used as shown. You should consult the relevant documentation /// to obtain up to date and correct information. The modified appnote by the infozip group is /// particularly helpful as it documents a lot of peculiarities. The document is however a little dated. /// /// 0 - MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems) /// 1 - Amiga /// 2 - OpenVMS /// 3 - Unix /// 4 - VM/CMS /// 5 - Atari ST /// 6 - OS/2 HPFS /// 7 - Macintosh /// 8 - Z-System /// 9 - CP/M /// 10 - Windows NTFS /// 11 - MVS (OS/390 - Z/OS) /// 12 - VSE /// 13 - Acorn Risc /// 14 - VFAT /// 15 - Alternate MVS /// 16 - BeOS /// 17 - Tandem /// 18 - OS/400 /// 19 - OS/X (Darwin) /// 99 - WinZip AES /// remainder - unused /// /// public int HostSystem { get { return (versionMadeBy >> 8) & 0xff; } set { versionMadeBy &= 0xff; versionMadeBy |= (ushort)((value & 0xff) << 8); } } /// /// Get minimum Zip feature version required to extract this entry /// /// /// Minimum features are defined as:
/// 1.0 - Default value
/// 1.1 - File is a volume label
/// 2.0 - File is a folder/directory
/// 2.0 - File is compressed using Deflate compression
/// 2.0 - File is encrypted using traditional encryption
/// 2.1 - File is compressed using Deflate64
/// 2.5 - File is compressed using PKWARE DCL Implode
/// 2.7 - File is a patch data set
/// 4.5 - File uses Zip64 format extensions
/// 4.6 - File is compressed using BZIP2 compression
/// 5.0 - File is encrypted using DES
/// 5.0 - File is encrypted using 3DES
/// 5.0 - File is encrypted using original RC2 encryption
/// 5.0 - File is encrypted using RC4 encryption
/// 5.1 - File is encrypted using AES encryption
/// 5.1 - File is encrypted using corrected RC2 encryption
/// 5.1 - File is encrypted using corrected RC2-64 encryption
/// 6.1 - File is encrypted using non-OAEP key wrapping
/// 6.2 - Central directory encryption (not confirmed yet)
/// 6.3 - File is compressed using LZMA
/// 6.3 - File is compressed using PPMD+
/// 6.3 - File is encrypted using Blowfish
/// 6.3 - File is encrypted using Twofish
///
/// public int Version { get { // Return recorded version if known. if (versionToExtract != 0) { return versionToExtract; } else { int result = 10; if ( CentralHeaderRequiresZip64 ) { result = ZipConstants.VersionZip64; } else if (CompressionMethod.Deflated == method) { result = 20; } else if (IsDirectory == true) { result = 20; } else if (IsCrypted == true) { result = 20; } else if (HasDosAttributes(0x08) ) { result = 11; } return result; } } } /// /// Get a value indicating wether this entry can be decompressed by the library. /// /// This is based on the and /// wether the compression method is supported. public bool CanDecompress { get { return (Version <= ZipConstants.VersionMadeBy) && ((Version == 10) || (Version == 11) || (Version == 20) || (Version == 45)) && IsCompressionMethodSupported(); } } /// /// Force this entry to be recorded using Zip64 extensions. /// public void ForceZip64() { forceZip64_ = true; } /// /// Get a value indicating wether Zip64 extensions were forced. /// /// A value of true if Zip64 extensions have been forced on; false if not. public bool IsZip64Forced() { return forceZip64_; } /// /// Gets a value indicating if the entry requires Zip64 extensions /// to store the full entry values. /// /// A value of true if a local header requires Zip64 extensions; false if not. public bool LocalHeaderRequiresZip64 { get { bool result = forceZip64_; if ( !result ) { ulong trueCompressedSize = compressedSize; if ( (versionToExtract == 0) && IsCrypted ) { trueCompressedSize += ZipConstants.CryptoHeaderSize; } // TODO: A better estimation of the true limit based on compression overhead should be used // to determine when an entry should use Zip64. result = ((this.size >= uint.MaxValue) || (trueCompressedSize >= uint.MaxValue)) && ((versionToExtract == 0) || (versionToExtract >= ZipConstants.VersionZip64)); } return result; } } /// /// Get a value indicating wether the central directory entry requires Zip64 extensions to be stored. /// public bool CentralHeaderRequiresZip64 { get { return LocalHeaderRequiresZip64 || (offset >= uint.MaxValue); } } /// /// Get/Set DosTime value. /// /// /// The MS-DOS date format can only represent dates between 1/1/1980 and 12/31/2107. /// public long DosTime { get { if ((known & Known.Time) == 0) { return 0; } else { return dosTime; } } set { unchecked { dosTime = (uint)value; } known |= Known.Time; } } /// /// Gets/Sets the time of last modification of the entry. /// /// /// The property is updated to match this as far as possible. /// public DateTime DateTime { get { uint sec = Math.Min(59, 2 * (dosTime & 0x1f)); uint min = Math.Min(59, (dosTime >> 5) & 0x3f); uint hrs = Math.Min(23, (dosTime >> 11) & 0x1f); uint mon = Math.Max(1, Math.Min(12, ((dosTime >> 21) & 0xf))); uint year = ((dosTime >> 25) & 0x7f) + 1980; int day = Math.Max(1, Math.Min(DateTime.DaysInMonth((int)year, (int)mon), (int)((dosTime >> 16) & 0x1f))); return new System.DateTime((int)year, (int)mon, day, (int)hrs, (int)min, (int)sec); } set { uint year = (uint) value.Year; uint month = (uint) value.Month; uint day = (uint) value.Day; uint hour = (uint) value.Hour; uint minute = (uint) value.Minute; uint second = (uint) value.Second; if ( year < 1980 ) { year = 1980; month = 1; day = 1; hour = 0; minute = 0; second = 0; } else if ( year > 2107 ) { year = 2107; month = 12; day = 31; hour = 23; minute = 59; second = 59; } DosTime = ((year - 1980) & 0x7f) << 25 | (month << 21) | (day << 16) | (hour << 11) | (minute << 5) | (second >> 1); } } /// /// Returns the entry name. /// /// /// The unix naming convention is followed. /// Path components in the entry should always separated by forward slashes ('/'). /// Dos device names like C: should also be removed. /// See the class, or /// public string Name { get { return name; } } /// /// Gets/Sets the size of the uncompressed data. /// /// /// The size or -1 if unknown. /// /// Setting the size before adding an entry to an archive can help /// avoid compatability problems with some archivers which dont understand Zip64 extensions. public long Size { get { return (known & Known.Size) != 0 ? (long)size : -1L; } set { this.size = (ulong)value; this.known |= Known.Size; } } /// /// Gets/Sets the size of the compressed data. /// /// /// The compressed entry size or -1 if unknown. /// public long CompressedSize { get { return (known & Known.CompressedSize) != 0 ? (long)compressedSize : -1L; } set { this.compressedSize = (ulong)value; this.known |= Known.CompressedSize; } } /// /// Gets/Sets the crc of the uncompressed data. /// /// /// Crc is not in the range 0..0xffffffffL /// /// /// The crc value or -1 if unknown. /// public long Crc { get { return (known & Known.Crc) != 0 ? crc & 0xffffffffL : -1L; } set { if (((ulong)crc & 0xffffffff00000000L) != 0) { throw new ArgumentOutOfRangeException("value"); } this.crc = (uint)value; this.known |= Known.Crc; } } /// /// Gets/Sets the compression method. Only Deflated and Stored are supported. /// /// /// The compression method for this entry /// /// /// public CompressionMethod CompressionMethod { get { return method; } set { if ( !IsCompressionMethodSupported(value) ) { throw new NotSupportedException("Compression method not supported"); } this.method = value; } } /// /// Gets/Sets the extra data. /// /// /// Extra data is longer than 64KB (0xffff) bytes. /// /// /// Extra data or null if not set. /// public byte[] ExtraData { get { // TODO: This is slightly safer but less efficient. Think about wether it should change. // return (byte[]) extra.Clone(); return extra; } set { if (value == null) { extra = null; } else { if (value.Length > 0xffff) { throw new System.ArgumentOutOfRangeException("value"); } extra = new byte[value.Length]; Array.Copy(value, 0, extra, 0, value.Length); } } } /// /// Process extra data fields updating the entry based on the contents. /// /// True if the extra data fields should be handled /// for a local header, rather than for a central header. /// internal void ProcessExtraData(bool localHeader) { ZipExtraData extraData = new ZipExtraData(this.extra); if ( extraData.Find(0x0001) ) { if ( (versionToExtract & 0xff) < ZipConstants.VersionZip64 ) { throw new ZipException("Zip64 Extended information found but version is not valid"); } // The recorded size will change but remember that this is zip64. forceZip64_ = true; if ( extraData.ValueLength < 4 ) { throw new ZipException("Extra data extended Zip64 information length is invalid"); } if ( localHeader || (size == uint.MaxValue) ) { size = (ulong)extraData.ReadLong(); } if ( localHeader || (compressedSize == uint.MaxValue) ) { compressedSize = (ulong)extraData.ReadLong(); } if ( !localHeader && (offset == uint.MaxValue) ) { offset = extraData.ReadLong(); } } else { if ( ((versionToExtract & 0xff) >= ZipConstants.VersionZip64) && ((size == uint.MaxValue) || (compressedSize == uint.MaxValue)) ) { throw new ZipException("Zip64 Extended information required but is missing."); } } if ( extraData.Find(10) ) { // No room for any tags. if ( extraData.ValueLength < 8 ) { throw new ZipException("NTFS Extra data invalid"); } extraData.ReadInt(); // Reserved while ( extraData.UnreadCount >= 4 ) { int ntfsTag = extraData.ReadShort(); int ntfsLength = extraData.ReadShort(); if ( ntfsTag == 1 ) { if ( ntfsLength >= 24 ) { long lastModification = extraData.ReadLong(); long lastAccess = extraData.ReadLong(); long createTime = extraData.ReadLong(); DateTime = System.DateTime.FromFileTime(lastModification); } break; } else { // An unknown NTFS tag so simply skip it. extraData.Skip(ntfsLength); } } } else if ( extraData.Find(0x5455) ) { int length = extraData.ValueLength; int flags = extraData.ReadByte(); // Can include other times but these are ignored. Length of data should // actually be 1 + 4 * no of bits in flags. if ( ((flags & 1) != 0) && (length >= 5) ) { int iTime = extraData.ReadInt(); DateTime = (new System.DateTime ( 1970, 1, 1, 0, 0, 0 ).ToUniversalTime() + new TimeSpan ( 0, 0, 0, iTime, 0 )).ToLocalTime(); } } } /// /// Gets/Sets the entry comment. /// /// /// If comment is longer than 0xffff. /// /// /// The comment or null if not set. /// /// /// A comment is only available for entries when read via the class. /// The class doesnt have the comment data available. /// public string Comment { get { return comment; } set { // This test is strictly incorrect as the length is in characters // while the storage limit is in bytes. // While the test is partially correct in that a comment of this length or greater // is definitely invalid, shorter comments may also have an invalid length // where there are multi-byte characters // The full test is not possible here however as the code page to apply conversions with // isnt available. if ( (value != null) && (value.Length > 0xffff) ) { #if NETCF_1_0 throw new ArgumentOutOfRangeException("value"); #else throw new ArgumentOutOfRangeException("value", "cannot exceed 65535"); #endif } comment = value; } } /// /// Gets a value indicating if the entry is a directory. /// however. /// /// /// A directory is determined by an entry name with a trailing slash '/'. /// The external file attributes can also indicate an entry is for a directory. /// Currently only dos/windows attributes are tested in this manner. /// The trailing slash convention should always be followed. /// public bool IsDirectory { get { int nameLength = name.Length; bool result = ((nameLength > 0) && ((name[nameLength - 1] == '/') || (name[nameLength - 1] == '\\'))) || HasDosAttributes(16) ; return result; } } /// /// Get a value of true if the entry appears to be a file; false otherwise /// /// /// This only takes account of DOS/Windows attributes. Other operating systems are ignored. /// For linux and others the result may be incorrect. /// public bool IsFile { get { return !IsDirectory && !HasDosAttributes(8); } } /// /// Test entry to see if data can be extracted. /// /// Returns true if data can be extracted for this entry; false otherwise. public bool IsCompressionMethodSupported() { return IsCompressionMethodSupported(CompressionMethod); } #region ICloneable Members /// /// Creates a copy of this zip entry. /// /// An that is a copy of the current instance. public object Clone() { ZipEntry result = (ZipEntry)this.MemberwiseClone(); // Ensure extra data is unique if it exists. if ( extra != null ) { result.extra = new byte[extra.Length]; Array.Copy(extra, 0, result.extra, 0, extra.Length); } return result; } #endregion /// /// Gets a string representation of this ZipEntry. /// /// A readable textual representation of this public override string ToString() { return name; } /// /// Test a compression method to see if this library /// supports extracting data compressed with that method /// /// The compression method to test. /// Returns true if the compression method is supported; false otherwise public static bool IsCompressionMethodSupported(CompressionMethod method) { return ( method == CompressionMethod.Deflated ) || ( method == CompressionMethod.Stored ); } /// /// Cleans a name making it conform to Zip file conventions. /// Devices names ('c:\') and UNC share names ('\\server\share') are removed /// and forward slashes ('\') are converted to back slashes ('/'). /// Names are made relative by trimming leading slashes which is compatible /// with the ZIP naming convention. /// /// The name to clean /// The 'cleaned' name. /// /// The Zip name transform class is more flexible. /// public static string CleanName(string name) { if (name == null) { return string.Empty; } if (Path.IsPathRooted(name) == true) { // NOTE: // for UNC names... \\machine\share\zoom\beet.txt gives \zoom\beet.txt name = name.Substring(Path.GetPathRoot(name).Length); } name = name.Replace(@"\", "/"); while ( (name.Length > 0) && (name[0] == '/')) { name = name.Remove(0, 1); } return name; } #region Instance Fields Known known; int externalFileAttributes = -1; // contains external attributes (O/S dependant) ushort versionMadeBy; // Contains host system and version information // only relevant for central header entries string name; ulong size; ulong compressedSize; ushort versionToExtract; // Version required to extract (library handles <= 2.0) uint crc; uint dosTime; CompressionMethod method = CompressionMethod.Deflated; byte[] extra; string comment; int flags; // general purpose bit flags long zipFileIndex = -1; // used by ZipFile long offset; // used by ZipFile and ZipOutputStream bool forceZip64_; byte cryptoCheckValue_; #endregion } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/ZipNameTransform.cs0000664000175000017500000002057310651204316024050 0ustar jtaylorjtaylor// ZipNameTransform.cs // // Copyright 2005 John Reilly // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using System.IO; using System.Text; using ICSharpCode.SharpZipLib.Core; namespace ICSharpCode.SharpZipLib.Zip { /// /// ZipNameTransform transforms names as per the Zip file naming convention. /// /// The use of absolute names is supported although its use is not valid /// according to Zip naming conventions, and should not be used if maximum compatability is desired. public class ZipNameTransform : INameTransform { #region Constructors /// /// Initialize a new instance of /// public ZipNameTransform() { } /// /// Initialize a new instance of /// /// The string to trim from front of paths if found. public ZipNameTransform(string trimPrefix) { TrimPrefix = trimPrefix; } #endregion /// /// Static constructor. /// static ZipNameTransform() { char[] invalidPathChars; #if NET_1_0 || NET_1_1 || NETCF_1_0 invalidPathChars = Path.InvalidPathChars; #else invalidPathChars = Path.GetInvalidPathChars(); #endif int howMany = invalidPathChars.Length + 2; InvalidEntryCharsRelaxed = new char[howMany]; Array.Copy(invalidPathChars, 0, InvalidEntryCharsRelaxed, 0, invalidPathChars.Length); InvalidEntryCharsRelaxed[howMany - 1] = '*'; InvalidEntryCharsRelaxed[howMany - 2] = '?'; howMany = invalidPathChars.Length + 4; InvalidEntryChars = new char[howMany]; Array.Copy(invalidPathChars, 0, InvalidEntryChars, 0, invalidPathChars.Length); InvalidEntryChars[howMany - 1] = ':'; InvalidEntryChars[howMany - 2] = '\\'; InvalidEntryChars[howMany - 3] = '*'; InvalidEntryChars[howMany - 4] = '?'; } /// /// Transform a directory name according to the Zip file naming conventions. /// /// The directory name to transform. /// The transformed name. public string TransformDirectory(string name) { name = TransformFile(name); if (name.Length > 0) { if ( !name.EndsWith("/") ) { name += "/"; } } else { throw new ZipException("Cannot have an empty directory name"); } return name; } /// /// Transform a windows file name according to the Zip file naming conventions. /// /// The file name to transform. /// The transformed name. public string TransformFile(string name) { if (name != null) { string lowerName = name.ToLower(); if ( (trimPrefix_ != null) && (lowerName.IndexOf(trimPrefix_) == 0) ) { name = name.Substring(trimPrefix_.Length); } // The following can throw exceptions when the name contains invalid characters if (Path.IsPathRooted(name) == true) { // NOTE: // for UNC names... \\machine\share\zoom\beet.txt gives \zoom\beet.txt name = name.Substring(Path.GetPathRoot(name).Length); } name = name.Replace(@"\", "/"); while ( (name.Length > 0) && (name[0] == '/')) { name = name.Remove(0, 1); } name = MakeValidName(name, '_'); } else { name = string.Empty; } return name; } /// /// Get/set the path prefix to be trimmed from paths if present. /// /// The prefix is trimmed before any conversion from /// a windows path is done. public string TrimPrefix { get { return trimPrefix_; } set { trimPrefix_ = value; if (trimPrefix_ != null) { trimPrefix_ = trimPrefix_.ToLower(); } } } /// /// Force a name to be valid by replacing invalid characters with a fixed value /// /// The name to force valid /// The replacement character to use. /// Returns a valid name static string MakeValidName(string name, char replacement) { int index = name.IndexOfAny(InvalidEntryChars); if (index > 0) { StringBuilder builder = new StringBuilder(name); while (index >= 0 ) { builder[index] = replacement; if (index >= name.Length) { index = -1; } else { index = name.IndexOfAny(InvalidEntryChars, index + 1); } } name = builder.ToString(); } return name; } /// /// Test a name to see if it is a valid name for a zip entry. /// /// The name to test. /// If true checking is relaxed about windows file names and absolute paths. /// Returns true if the name is a valid zip name; false otherwise. /// Zip path names are actually in Unix format, and should only contain relative paths. /// This means that any path stored should not contain a drive or /// device letter, or a leading slash. All slashes should forward slashes '/'. /// An empty name is valid for a file where the input comes from standard input. /// A null name is not considered valid. /// public static bool IsValidName(string name, bool relaxed) { bool result = (name != null); if ( result ) { if ( relaxed ) { result = name.IndexOfAny(InvalidEntryCharsRelaxed) < 0; } else { result = (name.IndexOfAny(InvalidEntryChars) < 0) && (name.IndexOf('/') != 0); } } return result; } /// /// Test a name to see if it is a valid name for a zip entry. /// /// The name to test. /// Returns true if the name is a valid zip name; false otherwise. /// Zip path names are actually in unix format, /// and should only contain relative paths if a path is present. /// This means that the path stored should not contain a drive or /// device letter, or a leading slash. All slashes should forward slashes '/'. /// An empty name is valid where the input comes from standard input. /// A null name is not considered valid. /// public static bool IsValidName(string name) { bool result = (name != null) && (name.IndexOfAny(InvalidEntryChars) < 0) && (name.IndexOf('/') != 0) ; return result; } #region Instance Fields string trimPrefix_; #endregion #region Class Fields static readonly char[] InvalidEntryChars; static readonly char[] InvalidEntryCharsRelaxed; #endregion } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/ZipConstants.cs0000664000175000017500000004626310654772400023263 0ustar jtaylorjtaylor// ZipConstants.cs // // Copyright (C) 2001 Mike Krueger // Copyright (C) 2004 John Reilly // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using System.Text; using System.Threading; #if NETCF_1_0 || NETCF_2_0 using System.Globalization; #endif namespace ICSharpCode.SharpZipLib.Zip { #region Enumerations /// /// Determines how entries are tested to see if they should use Zip64 extensions or not. /// public enum UseZip64 { /// /// Zip64 will not be forced on entries during processing. /// /// An entry can have this overridden if required Off, /// /// Zip64 should always be used. /// On, /// /// #ZipLib will determine use based on entry values when added to archive. /// Dynamic, } /// /// The kind of compression used for an entry in an archive /// public enum CompressionMethod { /// /// A direct copy of the file contents is held in the archive /// Stored = 0, /// /// Common Zip compression method using a sliding dictionary /// of up to 32KB and secondary compression from Huffman/Shannon-Fano trees /// Deflated = 8, /// /// An extension to deflate with a 64KB window. Not supported by #Zip currently /// Deflate64 = 9, /// /// Not supported by #Zip currently /// BZip2 = 11, /// /// WinZip special for AES encryption, Not supported by #Zip /// WinZipAES = 99, } /// /// Identifies the encryption algorithm used for an entry /// public enum EncryptionAlgorithm { /// /// No encryption has been used. /// None = 0, /// /// Encrypted using PKZIP 2.0 or 'classic' encryption. /// PkzipClassic = 1, /// /// DES encryption has been used. /// Des = 0x6601, /// /// RCS encryption has been used for encryption. /// RC2 = 0x6602, /// /// Triple DES encryption with 168 bit keys has been used for this entry. /// TripleDes168 = 0x6603, /// /// Triple DES with 112 bit keys has been used for this entry. /// TripleDes112 = 0x6609, /// /// AES 128 has been used for encryption. /// Aes128 = 0x660e, /// /// AES 192 has been used for encryption. /// Aes192 = 0x660f, /// /// AES 256 has been used for encryption. /// Aes256 = 0x6610, /// /// RC2 corrected has been used for encryption. /// RC2Corrected = 0x6702, /// /// Blowfish has been used for encryption. /// Blowfish = 0x6720, /// /// Twofish has been used for encryption. /// Twofish = 0x6721, /// /// RCS has been used for encryption. /// RC4 = 0x6801, /// /// An unknown algorithm has been used for encryption. /// Unknown = 0xffff } /// /// Defines the contents of the general bit flags field for an archive entry. /// [Flags] public enum GeneralBitFlags : int { /// /// Bit 0 if set indicates that the file is encrypted /// Encrypted = 0x0001, /// /// Bits 1 and 2 - Two bits defining the compression method (only for Method 6 Imploding and 8,9 Deflating) /// Method = 0x0006, /// /// Bit 3 if set indicates a trailing data desciptor is appended to the entry data /// Descriptor = 0x0008, /// /// Bit 4 is reserved for use with method 8 for enhanced deflation /// ReservedPKware4 = 0x0010, /// /// Bit 5 if set indicates the file contains Pkzip compressed patched data. /// Requires version 2.7 or greater. /// Patched = 0x0020, /// /// Bit 6 if set strong encryption has been used for this entry. /// StrongEncryption = 0x0040, /// /// Bit 7 is currently unused /// Unused7 = 0x0080, /// /// Bit 8 is currently unused /// Unused8 = 0x0100, /// /// Bit 9 is currently unused /// Unused9 = 0x0200, /// /// Bit 10 is currently unused /// Unused10 = 0x0400, /// /// Bit 11 if set indicates the filename and /// comment fields for this file must be encoded using UTF-8. /// UnicodeText = 0x0800, /// /// Bit 12 is documented as being reserved by PKware for enhanced compression. /// EnhancedCompress = 0x1000, /// /// Bit 13 if set indicates that values in the local header are masked to hide /// their actual values, and the central directory is encrypted. /// /// /// Used when encrypting the central directory contents. /// HeaderMasked = 0x2000, /// /// Bit 14 is documented as being reserved for use by PKware /// ReservedPkware14 = 0x4000, /// /// Bit 15 is documented as being reserved for use by PKware /// ReservedPkware15 = 0x8000 } #endregion /// /// This class contains constants used for Zip format files /// public sealed class ZipConstants { #region Versions /// /// The version made by field for entries in the central header when created by this library /// /// /// This is also the Zip version for the library when comparing against the version required to extract /// for an entry. See . /// public const int VersionMadeBy = 45; /// /// The version made by field for entries in the central header when created by this library /// /// /// This is also the Zip version for the library when comparing against the version required to extract /// for an entry. See ZipInputStream.CanDecompressEntry. /// [Obsolete("Use VersionMadeBy instead")] public const int VERSION_MADE_BY = 45; /// /// The minimum version required to support strong encryption /// public const int VersionStrongEncryption = 50; /// /// The minimum version required to support strong encryption /// [Obsolete("Use VersionStrongEncryption instead")] public const int VERSION_STRONG_ENCRYPTION = 50; /// /// The version required for Zip64 extensions /// public const int VersionZip64 = 45; #endregion #region Header Sizes /// /// Size of local entry header (excluding variable length fields at end) /// public const int LocalHeaderBaseSize = 30; /// /// Size of local entry header (excluding variable length fields at end) /// [Obsolete("Use LocalHeaderBaseSize instead")] public const int LOCHDR = 30; /// /// Size of Zip64 data descriptor /// public const int Zip64DataDescriptorSize = 24; /// /// Size of data descriptor /// public const int DataDescriptorSize = 16; /// /// Size of data descriptor /// [Obsolete("Use DataDescriptorSize instead")] public const int EXTHDR = 16; /// /// Size of central header entry (excluding variable fields) /// public const int CentralHeaderBaseSize = 46; /// /// Size of central header entry /// [Obsolete("Use CentralHeaderBaseSize instead")] public const int CENHDR = 46; /// /// Size of end of central record (excluding variable fields) /// public const int EndOfCentralRecordBaseSize = 22; /// /// Size of end of central record (excluding variable fields) /// [Obsolete("Use EndOfCentralRecordBaseSize instead")] public const int ENDHDR = 22; /// /// Size of 'classic' cryptographic header stored before any entry data /// public const int CryptoHeaderSize = 12; /// /// Size of cryptographic header stored before entry data /// [Obsolete("Use CryptoHeaderSize instead")] public const int CRYPTO_HEADER_SIZE = 12; #endregion #region Header Signatures /// /// Signature for local entry header /// public const int LocalHeaderSignature = 'P' | ('K' << 8) | (3 << 16) | (4 << 24); /// /// Signature for local entry header /// [Obsolete("Use LocalHeaderSignature instead")] public const int LOCSIG = 'P' | ('K' << 8) | (3 << 16) | (4 << 24); /// /// Signature for spanning entry /// public const int SpanningSignature = 'P' | ('K' << 8) | (7 << 16) | (8 << 24); /// /// Signature for spanning entry /// [Obsolete("Use SpanningSignature instead")] public const int SPANNINGSIG = 'P' | ('K' << 8) | (7 << 16) | (8 << 24); /// /// Signature for temporary spanning entry /// public const int SpanningTempSignature = 'P' | ('K' << 8) | ('0' << 16) | ('0' << 24); /// /// Signature for temporary spanning entry /// [Obsolete("Use SpanningTempSignature instead")] public const int SPANTEMPSIG = 'P' | ('K' << 8) | ('0' << 16) | ('0' << 24); /// /// Signature for data descriptor /// /// /// This is only used where the length, Crc, or compressed size isnt known when the /// entry is created and the output stream doesnt support seeking. /// The local entry cannot be 'patched' with the correct values in this case /// so the values are recorded after the data prefixed by this header, as well as in the central directory. /// public const int DataDescriptorSignature = 'P' | ('K' << 8) | (7 << 16) | (8 << 24); /// /// Signature for data descriptor /// /// /// This is only used where the length, Crc, or compressed size isnt known when the /// entry is created and the output stream doesnt support seeking. /// The local entry cannot be 'patched' with the correct values in this case /// so the values are recorded after the data prefixed by this header, as well as in the central directory. /// [Obsolete("Use DataDescriptorSignature instead")] public const int EXTSIG = 'P' | ('K' << 8) | (7 << 16) | (8 << 24); /// /// Signature for central header /// [Obsolete("Use CentralHeaderSignature instead")] public const int CENSIG = 'P' | ('K' << 8) | (1 << 16) | (2 << 24); /// /// Signature for central header /// public const int CentralHeaderSignature = 'P' | ('K' << 8) | (1 << 16) | (2 << 24); /// /// Signature for Zip64 central file header /// public const int Zip64CentralFileHeaderSignature = 'P' | ('K' << 8) | (6 << 16) | (6 << 24); /// /// Signature for Zip64 central file header /// [Obsolete("Use Zip64CentralFileHeaderSignature instead")] public const int CENSIG64 = 'P' | ('K' << 8) | (6 << 16) | (6 << 24); /// /// Signature for Zip64 central directory locator /// public const int Zip64CentralDirLocatorSignature = 'P' | ('K' << 8) | (6 << 16) | (7 << 24); /// /// Signature for archive extra data signature (were headers are encrypted). /// public const int ArchiveExtraDataSignature = 'P' | ('K' << 8) | (6 << 16) | (7 << 24); /// /// Central header digitial signature /// public const int CentralHeaderDigitalSignature = 'P' | ('K' << 8) | (5 << 16) | (5 << 24); /// /// Central header digitial signature /// [Obsolete("Use CentralHeaderDigitalSignaure instead")] public const int CENDIGITALSIG = 'P' | ('K' << 8) | (5 << 16) | (5 << 24); /// /// End of central directory record signature /// public const int EndOfCentralDirectorySignature = 'P' | ('K' << 8) | (5 << 16) | (6 << 24); /// /// End of central directory record signature /// [Obsolete("Use EndOfCentralDirectorySignature instead")] public const int ENDSIG = 'P' | ('K' << 8) | (5 << 16) | (6 << 24); #endregion #if NETCF_1_0 || NETCF_2_0 // This isnt so great but is better than nothing. // Trying to work out an appropriate OEM code page would be good. // 850 is a good default for english speakers particularly in Europe. static int defaultCodePage = CultureInfo.CurrentCulture.TextInfo.ANSICodePage; #else static int defaultCodePage = Thread.CurrentThread.CurrentCulture.TextInfo.OEMCodePage; #endif /// /// Default encoding used for string conversion. 0 gives the default system OEM code page. /// Dont use unicode encodings if you want to be Zip compatible! /// Using the default code page isnt the full solution neccessarily /// there are many variable factors, codepage 850 is often a good choice for /// European users, however be careful about compatability. /// public static int DefaultCodePage { get { return defaultCodePage; } set { defaultCodePage = value; } } /// /// Convert a portion of a byte array to a string. /// /// /// Data to convert to string /// /// /// Number of bytes to convert starting from index 0 /// /// /// data[0]..data[length - 1] converted to a string /// public static string ConvertToString(byte[] data, int count) { if ( data == null ) { return string.Empty; } return Encoding.GetEncoding(DefaultCodePage).GetString(data, 0, count); } /// /// Convert a byte array to string /// /// /// Byte array to convert /// /// /// dataconverted to a string /// public static string ConvertToString(byte[] data) { if ( data == null ) { return string.Empty; } return ConvertToString(data, data.Length); } /// /// Convert a byte array to string /// /// The applicable general purpose bits flags /// /// Byte array to convert /// /// The number of bytes to convert. /// /// dataconverted to a string /// public static string ConvertToStringExt(int flags, byte[] data, int count) { if ( data == null ) { return string.Empty; } if ( (flags & (int)GeneralBitFlags.UnicodeText) != 0 ) { return Encoding.UTF8.GetString(data, 0, count); } else { return ConvertToString(data, count); } } /// /// Convert a byte array to string /// /// /// Byte array to convert /// /// The applicable general purpose bits flags /// /// dataconverted to a string /// public static string ConvertToStringExt(int flags, byte[] data) { if ( data == null ) { return string.Empty; } if ( (flags & (int)GeneralBitFlags.UnicodeText) != 0 ) { return Encoding.UTF8.GetString(data, 0, data.Length); } else { return ConvertToString(data, data.Length); } } /// /// Convert a string to a byte array /// /// /// String to convert to an array /// /// Converted array public static byte[] ConvertToArray(string str) { if ( str == null ) { return new byte[0]; } return Encoding.GetEncoding(DefaultCodePage).GetBytes(str); } /// /// Convert a string to a byte array /// /// The applicable general purpose bits flags /// /// String to convert to an array /// /// Converted array public static byte[] ConvertToArray(int flags, string str) { if (str == null) { return new byte[0]; } if ((flags & (int)GeneralBitFlags.UnicodeText) != 0) { return Encoding.UTF8.GetBytes(str); } else { return ConvertToArray(str); } } /// /// Initialise default instance of ZipConstants /// /// /// Private to prevent instances being created. /// ZipConstants() { // Do nothing } } } keepass2-2.25/KeePassLibSD/SharpZipLib/Zip/ZipException.cs0000664000175000017500000000663210614545634023244 0ustar jtaylorjtaylor// ZipException.cs // // Copyright (C) 2001 Mike Krueger // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; #if !NETCF_1_0 && !NETCF_2_0 using System.Runtime.Serialization; #endif namespace ICSharpCode.SharpZipLib.Zip { /// /// Represents exception conditions specific to Zip archive handling /// #if !NETCF_1_0 && !NETCF_2_0 [Serializable] #endif public class ZipException : SharpZipBaseException { #if !NETCF_1_0 && !NETCF_2_0 /// /// Deserialization constructor /// /// for this constructor /// for this constructor protected ZipException(SerializationInfo info, StreamingContext context ) : base( info, context ) { } #endif /// /// Initializes a new instance of the ZipException class. /// public ZipException() { } /// /// Initializes a new instance of the ZipException class with a specified error message. /// /// The error message that explains the reason for the exception. public ZipException(string message) : base(message) { } /// /// Initialise a new instance of ZipException. /// /// A message describing the error. /// The exception that is the cause of the current exception. public ZipException(string message, Exception exception) : base(message, exception) { } } } keepass2-2.25/KeePassLibSD/SharpZipLib/Core/0000775000175000017500000000000011643263772020416 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/SharpZipLib/Core/INameTransform.cs0000664000175000017500000000467510572513654023643 0ustar jtaylorjtaylor// INameTransform.cs // // Copyright 2005 John Reilly // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. namespace ICSharpCode.SharpZipLib.Core { /// /// INameTransform defines how file system names are transformed for use with archives. /// public interface INameTransform { /// /// Given a file name determine the transformed value. /// /// The name to transform. /// The transformed file name. string TransformFile(string name); /// /// Given a directory name determine the transformed value. /// /// The name to transform. /// The transformed directory name string TransformDirectory(string name); } } keepass2-2.25/KeePassLibSD/SharpZipLib/Core/PathFilter.cs0000664000175000017500000002231310666320732023002 0ustar jtaylorjtaylor// PathFilter.cs // // Copyright 2005 John Reilly // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using System.IO; namespace ICSharpCode.SharpZipLib.Core { /// /// PathFilter filters directories and files using a form of regular expressions /// by full path name. /// See NameFilter for more detail on filtering. /// public class PathFilter : IScanFilter { #region Constructors /// /// Initialise a new instance of . /// /// The filter expression to apply. public PathFilter(string filter) { nameFilter_ = new NameFilter(filter); } #endregion #region IScanFilter Members /// /// Test a name to see if it matches the filter. /// /// The name to test. /// True if the name matches, false otherwise. public virtual bool IsMatch(string name) { bool result = false; if ( name != null ) { string cooked = (name.Length > 0) ? Path.GetFullPath(name) : ""; result = nameFilter_.IsMatch(cooked); } return result; } #endregion #region Instance Fields NameFilter nameFilter_; #endregion } /// /// ExtendedPathFilter filters based on name, file size, and the last write time of the file. /// /// Provides an example of how to customise filtering. public class ExtendedPathFilter : PathFilter { #region Constructors /// /// Initialise a new instance of ExtendedPathFilter. /// /// The filter to apply. /// The minimum file size to include. /// The maximum file size to include. public ExtendedPathFilter(string filter, long minSize, long maxSize) : base(filter) { MinSize = minSize; MaxSize = maxSize; } /// /// Initialise a new instance of ExtendedPathFilter. /// /// The filter to apply. /// The minimum to include. /// The maximum to include. public ExtendedPathFilter(string filter, DateTime minDate, DateTime maxDate) : base(filter) { MinDate = minDate; MaxDate = maxDate; } /// /// Initialise a new instance of ExtendedPathFilter. /// /// The filter to apply. /// The minimum file size to include. /// The maximum file size to include. /// The minimum to include. /// The maximum to include. public ExtendedPathFilter(string filter, long minSize, long maxSize, DateTime minDate, DateTime maxDate) : base(filter) { MinSize = minSize; MaxSize = maxSize; MinDate = minDate; MaxDate = maxDate; } #endregion #region IScanFilter Members /// /// Test a filename to see if it matches the filter. /// /// The filename to test. /// True if the filter matches, false otherwise. public override bool IsMatch(string name) { bool result = base.IsMatch(name); if ( result ) { FileInfo fileInfo = new FileInfo(name); result = (MinSize <= fileInfo.Length) && (MaxSize >= fileInfo.Length) && (MinDate <= fileInfo.LastWriteTime) && (MaxDate >= fileInfo.LastWriteTime) ; } return result; } #endregion #region Properties /// /// Get/set the minimum size for a file that will match this filter. /// public long MinSize { get { return minSize_; } set { if ( (value < 0) || (maxSize_ < value) ) { throw new ArgumentOutOfRangeException("value"); } minSize_ = value; } } /// /// Get/set the maximum size for a file that will match this filter. /// public long MaxSize { get { return maxSize_; } set { if ( (value < 0) || (minSize_ > value) ) { throw new ArgumentOutOfRangeException("value"); } maxSize_ = value; } } /// /// Get/set the minimum value that will match for this filter. /// /// Files with a LastWrite time less than this value are excluded by the filter. public DateTime MinDate { get { return minDate_; } set { if ( value > maxDate_ ) { throw new ArgumentException("Exceeds MaxDate", "value"); } minDate_ = value; } } /// /// Get/set the maximum value that will match for this filter. /// /// Files with a LastWrite time greater than this value are excluded by the filter. public DateTime MaxDate { get { return maxDate_; } set { if ( minDate_ > value ) { throw new ArgumentException("Exceeds MinDate", "value"); } maxDate_ = value; } } #endregion #region Instance Fields long minSize_; long maxSize_ = long.MaxValue; DateTime minDate_ = DateTime.MinValue; DateTime maxDate_ = DateTime.MaxValue; #endregion } /// /// NameAndSizeFilter filters based on name and file size. /// /// A sample showing how filters might be extended. [Obsolete("Use ExtendedPathFilter instead")] public class NameAndSizeFilter : PathFilter { /// /// Initialise a new instance of NameAndSizeFilter. /// /// The filter to apply. /// The minimum file size to include. /// The maximum file size to include. public NameAndSizeFilter(string filter, long minSize, long maxSize) : base(filter) { MinSize = minSize; MaxSize = maxSize; } /// /// Test a filename to see if it matches the filter. /// /// The filename to test. /// True if the filter matches, false otherwise. public override bool IsMatch(string name) { bool result = base.IsMatch(name); if ( result ) { FileInfo fileInfo = new FileInfo(name); long length = fileInfo.Length; result = (MinSize <= length) && (MaxSize >= length); } return result; } /// /// Get/set the minimum size for a file that will match this filter. /// public long MinSize { get { return minSize_; } set { if ( (value < 0) || (maxSize_ < value) ) { throw new ArgumentOutOfRangeException("value"); } minSize_ = value; } } /// /// Get/set the maximum size for a file that will match this filter. /// public long MaxSize { get { return maxSize_; } set { if ( (value < 0) || (minSize_ > value) ) { throw new ArgumentOutOfRangeException("value"); } maxSize_ = value; } } #region Instance Fields long minSize_; long maxSize_ = long.MaxValue; #endregion } } keepass2-2.25/KeePassLibSD/SharpZipLib/Core/NameFilter.cs0000664000175000017500000001747310614441140022767 0ustar jtaylorjtaylor// NameFilter.cs // // Copyright 2005 John Reilly // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using System.Collections; using System.Text.RegularExpressions; namespace ICSharpCode.SharpZipLib.Core { /// /// NameFilter is a string matching class which allows for both positive and negative /// matching. /// A filter is a sequence of independant regular expressions separated by semi-colons ';' /// Each expression can be prefixed by a plus '+' sign or a minus '-' sign to denote the expression /// is intended to include or exclude names. If neither a plus or minus sign is found include is the default /// A given name is tested for inclusion before checking exclusions. Only names matching an include spec /// and not matching an exclude spec are deemed to match the filter. /// An empty filter matches any name. /// /// The following expression includes all name ending in '.dat' with the exception of 'dummy.dat' /// "+\.dat$;-^dummy\.dat$" /// public class NameFilter : IScanFilter { #region Constructors /// /// Construct an instance based on the filter expression passed /// /// The filter expression. public NameFilter(string filter) { filter_ = filter; inclusions_ = new ArrayList(); exclusions_ = new ArrayList(); Compile(); } #endregion /// /// Test a string to see if it is a valid regular expression. /// /// The expression to test. /// True if expression is a valid false otherwise. public static bool IsValidExpression(string expression) { bool result = true; try { Regex exp = new Regex(expression, RegexOptions.IgnoreCase | RegexOptions.Singleline); } catch { result = false; } return result; } /// /// Test an expression to see if it is valid as a filter. /// /// The filter expression to test. /// True if the expression is valid, false otherwise. public static bool IsValidFilterExpression(string toTest) { if ( toTest == null ) { throw new ArgumentNullException("toTest"); } bool result = true; try { string[] items = toTest.Split(';'); for ( int i = 0; i < items.Length; ++i ) { if ( items[i] != null && items[i].Length > 0 ) { string toCompile; if ( items[i][0] == '+' ) { toCompile = items[i].Substring(1, items[i].Length - 1); } else if ( items[i][0] == '-' ) { toCompile = items[i].Substring(1, items[i].Length - 1); } else { toCompile = items[i]; } Regex testRegex = new Regex(toCompile, RegexOptions.IgnoreCase | RegexOptions.Singleline); } } } catch ( Exception ) { result = false; } return result; } /// /// Convert this filter to its string equivalent. /// /// The string equivalent for this filter. public override string ToString() { return filter_; } /// /// Test a value to see if it is included by the filter. /// /// The value to test. /// True if the value is included, false otherwise. public bool IsIncluded(string name) { bool result = false; if ( inclusions_.Count == 0 ) { result = true; } else { foreach ( Regex r in inclusions_ ) { if ( r.IsMatch(name) ) { result = true; break; } } } return result; } /// /// Test a value to see if it is excluded by the filter. /// /// The value to test. /// True if the value is excluded, false otherwise. public bool IsExcluded(string name) { bool result = false; foreach ( Regex r in exclusions_ ) { if ( r.IsMatch(name) ) { result = true; break; } } return result; } #region IScanFilter Members /// /// Test a value to see if it matches the filter. /// /// The value to test. /// True if the value matches, false otherwise. public bool IsMatch(string name) { return (IsIncluded(name) == true) && (IsExcluded(name) == false); } #endregion /// /// Compile this filter. /// void Compile() { // TODO: Check to see if combining RE's makes it faster/smaller. // simple scheme would be to have one RE for inclusion and one for exclusion. if ( filter_ == null ) { return; } // TODO: Allow for paths to include ';' string[] items = filter_.Split(';'); for ( int i = 0; i < items.Length; ++i ) { if ( (items[i] != null) && (items[i].Length > 0) ) { bool include = (items[i][0] != '-'); string toCompile; if ( items[i][0] == '+' ) { toCompile = items[i].Substring(1, items[i].Length - 1); } else if ( items[i][0] == '-' ) { toCompile = items[i].Substring(1, items[i].Length - 1); } else { toCompile = items[i]; } // NOTE: Regular expressions can fail to compile here for a number of reasons that cause an exception // these are left unhandled here as the caller is responsible for ensuring all is valid. // several functions IsValidFilterExpression and IsValidExpression are provided for such checking if ( include ) { inclusions_.Add(new Regex(toCompile, RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)); } else { exclusions_.Add(new Regex(toCompile, RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)); } } } } #region Instance Fields string filter_; ArrayList inclusions_; ArrayList exclusions_; #endregion } } keepass2-2.25/KeePassLibSD/SharpZipLib/Core/StreamUtils.cs0000664000175000017500000001604110666321272023215 0ustar jtaylorjtaylor// StreamUtils.cs // // Copyright 2005 John Reilly // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using System.IO; namespace ICSharpCode.SharpZipLib.Core { /// /// Provides simple " utilities. /// public sealed class StreamUtils { /// /// Read from a ensuring all the required data is read. /// /// The stream to read. /// The buffer to fill. static public void ReadFully(Stream stream, byte[] buffer) { ReadFully(stream, buffer, 0, buffer.Length); } /// /// Read from a " ensuring all the required data is read. /// /// The stream to read data from. /// The buffer to store data in. /// The offset at which to begin storing data. /// The number of bytes of data to store. static public void ReadFully(Stream stream, byte[] buffer, int offset, int count) { if ( stream == null ) { throw new ArgumentNullException("stream"); } if ( buffer == null ) { throw new ArgumentNullException("buffer"); } // Offset can equal length when buffer and count are 0. if ( (offset < 0) || (offset > buffer.Length) ) { throw new ArgumentOutOfRangeException("offset"); } if ( (count < 0) || (offset + count > buffer.Length) ) { throw new ArgumentOutOfRangeException("count"); } while ( count > 0 ) { int readCount = stream.Read(buffer, offset, count); if ( readCount <= 0 ) { throw new EndOfStreamException(); } offset += readCount; count -= readCount; } } /// /// Copy the contents of one to another. /// /// The stream to source data from. /// The stream to write data to. /// The buffer to use during copying. /// The progress handler delegate to use. /// The minimum between progress updates. /// The source for this event. /// The name to use with the event. static public void Copy(Stream source, Stream destination, byte[] buffer, ProgressHandler progressHandler, TimeSpan updateInterval, object sender, string name) { if (source == null) { throw new ArgumentNullException("source"); } if (destination == null) { throw new ArgumentNullException("destination"); } if (buffer == null) { throw new ArgumentNullException("buffer"); } // Ensure a reasonable size of buffer is used without being prohibitive. if (buffer.Length < 128) { throw new ArgumentException("Buffer is too small", "buffer"); } if (progressHandler == null) { throw new ArgumentNullException("progressHandler"); } bool copying = true; DateTime marker = DateTime.Now; long processed = 0; long target = 0; if (source.CanSeek) { target = source.Length - source.Position; } // Always fire 0% progress.. ProgressEventArgs args = new ProgressEventArgs(name, processed, target); progressHandler(sender, args); bool completeFired = false; while (copying) { int bytesRead = source.Read(buffer, 0, buffer.Length); if (bytesRead > 0) { processed += bytesRead; destination.Write(buffer, 0, bytesRead); } else { destination.Flush(); copying = false; } if (DateTime.Now - marker > updateInterval) { completeFired = (processed == target); marker = DateTime.Now; args = new ProgressEventArgs(name, processed, target); progressHandler(sender, args); copying = args.ContinueRunning; } } if (!completeFired) { args = new ProgressEventArgs(name, processed, target); progressHandler(sender, args); } } /// /// Copy the contents of one to another. /// /// The stream to source data from. /// The stream to write data to. /// The buffer to use during copying. static public void Copy(Stream source, Stream destination, byte[] buffer) { if ( source == null ) { throw new ArgumentNullException("source"); } if ( destination == null ) { throw new ArgumentNullException("destination"); } if ( buffer == null ) { throw new ArgumentNullException("buffer"); } // Ensure a reasonable size of buffer is used without being prohibitive. if ( buffer.Length < 128 ) { throw new ArgumentException("Buffer is too small", "buffer"); } bool copying = true; while ( copying ) { int bytesRead = source.Read(buffer, 0, buffer.Length); if ( bytesRead > 0 ) { destination.Write(buffer, 0, bytesRead); } else { destination.Flush(); copying = false; } } } /// /// Initialise an instance of /// private StreamUtils() { // Do nothing. } } } keepass2-2.25/KeePassLibSD/SharpZipLib/Core/IScanFilter.cs0000664000175000017500000000427610572513654023116 0ustar jtaylorjtaylor// IScanFilter.cs // // Copyright 2006 John Reilly // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; namespace ICSharpCode.SharpZipLib.Core { /// /// Scanning filters support filtering of names. /// public interface IScanFilter { /// /// Test a name to see if it 'matches' the filter. /// /// The name to test. /// Returns true if the name matches the filter, false if it does not match. bool IsMatch(string name); } } keepass2-2.25/KeePassLibSD/SharpZipLib/Core/FileSystemScanner.cs0000664000175000017500000003513710666320510024340 0ustar jtaylorjtaylor// FileSystemScanner.cs // // Copyright 2005 John Reilly // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; using System.IO; namespace ICSharpCode.SharpZipLib.Core { #region EventArgs /// /// Event arguments for scanning. /// public class ScanEventArgs : EventArgs { #region Constructors /// /// Initialise a new instance of /// /// The file or directory name. public ScanEventArgs(string name) { name_ = name; } #endregion /// /// The fie or directory name for this event. /// public string Name { get { return name_; } } /// /// Get set a value indicating if scanning should continue or not. /// public bool ContinueRunning { get { return continueRunning_; } set { continueRunning_ = value; } } #region Instance Fields string name_; bool continueRunning_ = true; #endregion } /// /// Event arguments during processing of a single file or directory. /// public class ProgressEventArgs : EventArgs { #region Constructors /// /// Initialise a new instance of /// /// The file or directory name if known. /// The number of bytes processed so far /// The total number of bytes to process, 0 if not known public ProgressEventArgs(string name, long processed, long target) { name_ = name; processed_ = processed; target_ = target; } #endregion /// /// The name for this event if known. /// public string Name { get { return name_; } } /// /// Get set a value indicating wether scanning should continue or not. /// public bool ContinueRunning { get { return continueRunning_; } set { continueRunning_ = value; } } /// /// Get a percentage representing how much of the has been processed /// /// 0.0 to 100.0 percent; 0 if target is not known. public float PercentComplete { get { if (target_ <= 0) { return 0; } else { return ((float)processed_ / (float)target_) * 100.0f; } } } /// /// The number of bytes processed so far /// public long Processed { get { return processed_; } } /// /// The number of bytes to process. /// /// Target may be 0 or negative if the value isnt known. public long Target { get { return target_; } } #region Instance Fields string name_; long processed_; long target_; bool continueRunning_ = true; #endregion } /// /// Event arguments for directories. /// public class DirectoryEventArgs : ScanEventArgs { #region Constructors /// /// Initialize an instance of . /// /// The name for this directory. /// Flag value indicating if any matching files are contained in this directory. public DirectoryEventArgs(string name, bool hasMatchingFiles) : base (name) { hasMatchingFiles_ = hasMatchingFiles; } #endregion /// /// Get a value indicating if the directory contains any matching files or not. /// public bool HasMatchingFiles { get { return hasMatchingFiles_; } } #region Instance Fields bool hasMatchingFiles_; #endregion } /// /// Arguments passed when scan failures are detected. /// public class ScanFailureEventArgs { #region Constructors /// /// Initialise a new instance of /// /// The name to apply. /// The exception to use. public ScanFailureEventArgs(string name, Exception e) { name_ = name; exception_ = e; continueRunning_ = true; } #endregion /// /// The applicable name. /// public string Name { get { return name_; } } /// /// The applicable exception. /// public Exception Exception { get { return exception_; } } /// /// Get / set a value indicating wether scanning should continue. /// public bool ContinueRunning { get { return continueRunning_; } set { continueRunning_ = value; } } #region Instance Fields string name_; Exception exception_; bool continueRunning_; #endregion } #endregion #region Delegates /// /// Delegate invoked before starting to process a directory. /// public delegate void ProcessDirectoryHandler(object sender, DirectoryEventArgs e); /// /// Delegate invoked before starting to process a file. /// /// The source of the event /// The event arguments. public delegate void ProcessFileHandler(object sender, ScanEventArgs e); /// /// Delegate invoked during processing of a file or directory /// /// The source of the event /// The event arguments. public delegate void ProgressHandler(object sender, ProgressEventArgs e); /// /// Delegate invoked when a file has been completely processed. /// /// The source of the event /// The event arguments. public delegate void CompletedFileHandler(object sender, ScanEventArgs e); /// /// Delegate invoked when a directory failure is detected. /// /// The source of the event /// The event arguments. public delegate void DirectoryFailureHandler(object sender, ScanFailureEventArgs e); /// /// Delegate invoked when a file failure is detected. /// /// The source of the event /// The event arguments. public delegate void FileFailureHandler(object sender, ScanFailureEventArgs e); #endregion /// /// FileSystemScanner provides facilities scanning of files and directories. /// public class FileSystemScanner { #region Constructors /// /// Initialise a new instance of /// /// The file filter to apply when scanning. public FileSystemScanner(string filter) { fileFilter_ = new PathFilter(filter); } /// /// Initialise a new instance of /// /// The file filter to apply. /// The directory filter to apply. public FileSystemScanner(string fileFilter, string directoryFilter) { fileFilter_ = new PathFilter(fileFilter); directoryFilter_ = new PathFilter(directoryFilter); } /// /// Initialise a new instance of /// /// The file filter to apply. public FileSystemScanner(IScanFilter fileFilter) { fileFilter_ = fileFilter; } /// /// Initialise a new instance of /// /// The file filter to apply. /// The directory filter to apply. public FileSystemScanner(IScanFilter fileFilter, IScanFilter directoryFilter) { fileFilter_ = fileFilter; directoryFilter_ = directoryFilter; } #endregion #region Delegates /// /// Delegate to invoke when a directory is processed. /// public ProcessDirectoryHandler ProcessDirectory; /// /// Delegate to invoke when a file is processed. /// public ProcessFileHandler ProcessFile; /// /// Delegate to invoke when processing for a file has finished. /// public CompletedFileHandler CompletedFile; /// /// Delegate to invoke when a directory failure is detected. /// public DirectoryFailureHandler DirectoryFailure; /// /// Delegate to invoke when a file failure is detected. /// public FileFailureHandler FileFailure; #endregion /// /// Raise the DirectoryFailure event. /// /// The directory name. /// The exception detected. void OnDirectoryFailure(string directory, Exception e) { if ( DirectoryFailure == null ) { alive_ = false; } else { ScanFailureEventArgs args = new ScanFailureEventArgs(directory, e); DirectoryFailure(this, args); alive_ = args.ContinueRunning; } } /// /// Raise the FileFailure event. /// /// The file name. /// The exception detected. void OnFileFailure(string file, Exception e) { if ( FileFailure == null ) { alive_ = false; } else { ScanFailureEventArgs args = new ScanFailureEventArgs(file, e); FileFailure(this, args); alive_ = args.ContinueRunning; } } /// /// Raise the ProcessFile event. /// /// The file name. void OnProcessFile(string file) { if ( ProcessFile != null ) { ScanEventArgs args = new ScanEventArgs(file); ProcessFile(this, args); alive_ = args.ContinueRunning; } } /// /// Raise the complete file event /// /// The file name void OnCompleteFile(string file) { if (CompletedFile != null) { ScanEventArgs args = new ScanEventArgs(file); CompletedFile(this, args); alive_ = args.ContinueRunning; } } /// /// Raise the ProcessDirectory event. /// /// The directory name. /// Flag indicating if the directory has matching files. void OnProcessDirectory(string directory, bool hasMatchingFiles) { if ( ProcessDirectory != null ) { DirectoryEventArgs args = new DirectoryEventArgs(directory, hasMatchingFiles); ProcessDirectory(this, args); alive_ = args.ContinueRunning; } } /// /// Scan a directory. /// /// The base directory to scan. /// True to recurse subdirectories, false to scan a single directory. public void Scan(string directory, bool recurse) { alive_ = true; ScanDir(directory, recurse); } void ScanDir(string directory, bool recurse) { try { string[] names = System.IO.Directory.GetFiles(directory); bool hasMatch = false; for (int fileIndex = 0; fileIndex < names.Length; ++fileIndex) { if ( !fileFilter_.IsMatch(names[fileIndex]) ) { names[fileIndex] = null; } else { hasMatch = true; } } OnProcessDirectory(directory, hasMatch); if ( alive_ && hasMatch ) { foreach (string fileName in names) { try { if ( fileName != null ) { OnProcessFile(fileName); if ( !alive_ ) { break; } } } catch (Exception e) { OnFileFailure(fileName, e); } } } } catch (Exception e) { OnDirectoryFailure(directory, e); } if ( alive_ && recurse ) { try { string[] names = System.IO.Directory.GetDirectories(directory); foreach (string fulldir in names) { if ((directoryFilter_ == null) || (directoryFilter_.IsMatch(fulldir))) { ScanDir(fulldir, true); if ( !alive_ ) { break; } } } } catch (Exception e) { OnDirectoryFailure(directory, e); } } } #region Instance Fields /// /// The file filter currently in use. /// IScanFilter fileFilter_; /// /// The directory filter currently in use. /// IScanFilter directoryFilter_; /// /// Flag indicating if scanning should continue running. /// bool alive_; #endregion } } keepass2-2.25/KeePassLibSD/SharpZipLib/SharpZipBaseException.cs0000664000175000017500000000726410670306750024271 0ustar jtaylorjtaylor// SharpZipBaseException.cs // // Copyright 2004 John Reilly // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; #if !NETCF_1_0 && !NETCF_2_0 using System.Runtime.Serialization; #endif namespace ICSharpCode.SharpZipLib { /// /// SharpZipBaseException is the base exception class for the SharpZipLibrary. /// All library exceptions are derived from this. /// /// NOTE: Not all exceptions thrown will be derived from this class. /// A variety of other exceptions are possible for example #if !NETCF_1_0 && !NETCF_2_0 [Serializable] #endif public class SharpZipBaseException : ApplicationException { #if !NETCF_1_0 && !NETCF_2_0 /// /// Deserialization constructor /// /// for this constructor /// for this constructor protected SharpZipBaseException(SerializationInfo info, StreamingContext context ) : base( info, context ) { } #endif /// /// Initializes a new instance of the SharpZipBaseException class. /// public SharpZipBaseException() { } /// /// Initializes a new instance of the SharpZipBaseException class with a specified error message. /// /// A message describing the exception. public SharpZipBaseException(string message) : base(message) { } /// /// Initializes a new instance of the SharpZipBaseException class with a specified /// error message and a reference to the inner exception that is the cause of this exception. /// /// A message describing the exception. /// The inner exception public SharpZipBaseException(string message, Exception innerException) : base(message, innerException) { } } } keepass2-2.25/KeePassLibSD/SharpZipLib/Checksums/0000775000175000017500000000000011643263772021453 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/SharpZipLib/Checksums/CRC32.cs0000664000175000017500000002206310614545556022561 0ustar jtaylorjtaylor// CRC32.cs - Computes CRC32 data checksum of a data stream // Copyright (C) 2001 Mike Krueger // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; namespace ICSharpCode.SharpZipLib.Checksums { /// /// Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: /// x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. /// /// Polynomials over GF(2) are represented in binary, one bit per coefficient, /// with the lowest powers in the most significant bit. Then adding polynomials /// is just exclusive-or, and multiplying a polynomial by x is a right shift by /// one. If we call the above polynomial p, and represent a byte as the /// polynomial q, also with the lowest power in the most significant bit (so the /// byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, /// where a mod b means the remainder after dividing a by b. /// /// This calculation is done using the shift-register method of multiplying and /// taking the remainder. The register is initialized to zero, and for each /// incoming bit, x^32 is added mod p to the register if the bit is a one (where /// x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by /// x (which is shifting right by one and adding x^32 mod p if the bit shifted /// out is a one). We start with the highest power (least significant bit) of /// q and repeat for all eight bits of q. /// /// The table is simply the CRC of all possible eight bit values. This is all /// the information needed to generate CRC's on data a byte at a time for all /// combinations of CRC register values and incoming bytes. /// public sealed class Crc32 : IChecksum { readonly static uint CrcSeed = 0xFFFFFFFF; readonly static uint[] CrcTable = new uint[] { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D }; internal static uint ComputeCrc32(uint oldCrc, byte value) { return (uint)(Crc32.CrcTable[(oldCrc ^ value) & 0xFF] ^ (oldCrc >> 8)); } /// /// The crc data checksum so far. /// uint crc; /// /// Returns the CRC32 data checksum computed so far. /// public long Value { get { return (long)crc; } set { crc = (uint)value; } } /// /// Resets the CRC32 data checksum as if no update was ever called. /// public void Reset() { crc = 0; } /// /// Updates the checksum with the int bval. /// /// /// the byte is taken as the lower 8 bits of value /// public void Update(int value) { crc ^= CrcSeed; crc = CrcTable[(crc ^ value) & 0xFF] ^ (crc >> 8); crc ^= CrcSeed; } /// /// Updates the checksum with the bytes taken from the array. /// /// /// buffer an array of bytes /// public void Update(byte[] buffer) { if (buffer == null) { throw new ArgumentNullException("buffer"); } Update(buffer, 0, buffer.Length); } /// /// Adds the byte array to the data checksum. /// /// /// The buffer which contains the data /// /// /// The offset in the buffer where the data starts /// /// /// The number of data bytes to update the CRC with. /// public void Update(byte[] buffer, int offset, int count) { if (buffer == null) { throw new ArgumentNullException("buffer"); } if ( count < 0 ) { #if NETCF_1_0 throw new ArgumentOutOfRangeException("count"); #else throw new ArgumentOutOfRangeException("count", "Count cannot be less than zero"); #endif } if (offset < 0 || offset + count > buffer.Length) { throw new ArgumentOutOfRangeException("offset"); } crc ^= CrcSeed; while (--count >= 0) { crc = CrcTable[(crc ^ buffer[offset++]) & 0xFF] ^ (crc >> 8); } crc ^= CrcSeed; } } } keepass2-2.25/KeePassLibSD/SharpZipLib/Checksums/Adler32.cs0000664000175000017500000001724510614545556023207 0ustar jtaylorjtaylor// Adler32.cs - Computes Adler32 data checksum of a data stream // Copyright (C) 2001 Mike Krueger // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. using System; namespace ICSharpCode.SharpZipLib.Checksums { /// /// Computes Adler32 checksum for a stream of data. An Adler32 /// checksum is not as reliable as a CRC32 checksum, but a lot faster to /// compute. /// /// The specification for Adler32 may be found in RFC 1950. /// ZLIB Compressed Data Format Specification version 3.3) /// /// /// From that document: /// /// "ADLER32 (Adler-32 checksum) /// This contains a checksum value of the uncompressed data /// (excluding any dictionary data) computed according to Adler-32 /// algorithm. This algorithm is a 32-bit extension and improvement /// of the Fletcher algorithm, used in the ITU-T X.224 / ISO 8073 /// standard. /// /// Adler-32 is composed of two sums accumulated per byte: s1 is /// the sum of all bytes, s2 is the sum of all s1 values. Both sums /// are done modulo 65521. s1 is initialized to 1, s2 to zero. The /// Adler-32 checksum is stored as s2*65536 + s1 in most- /// significant-byte first (network) order." /// /// "8.2. The Adler-32 algorithm /// /// The Adler-32 algorithm is much faster than the CRC32 algorithm yet /// still provides an extremely low probability of undetected errors. /// /// The modulo on unsigned long accumulators can be delayed for 5552 /// bytes, so the modulo operation time is negligible. If the bytes /// are a, b, c, the second sum is 3a + 2b + c + 3, and so is position /// and order sensitive, unlike the first sum, which is just a /// checksum. That 65521 is prime is important to avoid a possible /// large class of two-byte errors that leave the check unchanged. /// (The Fletcher checksum uses 255, which is not prime and which also /// makes the Fletcher check insensitive to single byte changes 0 - /// 255.) /// /// The sum s1 is initialized to 1 instead of zero to make the length /// of the sequence part of s2, so that the length does not have to be /// checked separately. (Any sequence of zeroes has a Fletcher /// checksum of zero.)" /// /// /// public sealed class Adler32 : IChecksum { /// /// largest prime smaller than 65536 /// const uint BASE = 65521; /// /// Returns the Adler32 data checksum computed so far. /// public long Value { get { return checksum; } } /// /// Creates a new instance of the Adler32 class. /// The checksum starts off with a value of 1. /// public Adler32() { Reset(); } /// /// Resets the Adler32 checksum to the initial value. /// public void Reset() { checksum = 1; } /// /// Updates the checksum with a byte value. /// /// /// The data value to add. The high byte of the int is ignored. /// public void Update(int value) { // We could make a length 1 byte array and call update again, but I // would rather not have that overhead uint s1 = checksum & 0xFFFF; uint s2 = checksum >> 16; s1 = (s1 + ((uint)value & 0xFF)) % BASE; s2 = (s1 + s2) % BASE; checksum = (s2 << 16) + s1; } /// /// Updates the checksum with an array of bytes. /// /// /// The source of the data to update with. /// public void Update(byte[] buffer) { if ( buffer == null ) { throw new ArgumentNullException("buffer"); } Update(buffer, 0, buffer.Length); } /// /// Updates the checksum with the bytes taken from the array. /// /// /// an array of bytes /// /// /// the start of the data used for this update /// /// /// the number of bytes to use for this update /// public void Update(byte[] buffer, int offset, int count) { if (buffer == null) { throw new ArgumentNullException("buffer"); } if (offset < 0) { #if NETCF_1_0 throw new ArgumentOutOfRangeException("offset"); #else throw new ArgumentOutOfRangeException("offset", "cannot be negative"); #endif } if ( count < 0 ) { #if NETCF_1_0 throw new ArgumentOutOfRangeException("count"); #else throw new ArgumentOutOfRangeException("count", "cannot be negative"); #endif } if (offset >= buffer.Length) { #if NETCF_1_0 throw new ArgumentOutOfRangeException("offset"); #else throw new ArgumentOutOfRangeException("offset", "not a valid index into buffer"); #endif } if (offset + count > buffer.Length) { #if NETCF_1_0 throw new ArgumentOutOfRangeException("count"); #else throw new ArgumentOutOfRangeException("count", "exceeds buffer size"); #endif } //(By Per Bothner) uint s1 = checksum & 0xFFFF; uint s2 = checksum >> 16; while (count > 0) { // We can defer the modulo operation: // s1 maximally grows from 65521 to 65521 + 255 * 3800 // s2 maximally grows by 3800 * median(s1) = 2090079800 < 2^31 int n = 3800; if (n > count) { n = count; } count -= n; while (--n >= 0) { s1 = s1 + (uint)(buffer[offset++] & 0xff); s2 = s2 + s1; } s1 %= BASE; s2 %= BASE; } checksum = (s2 << 16) | s1; } #region Instance Fields uint checksum; #endregion } } keepass2-2.25/KeePassLibSD/SharpZipLib/Checksums/IChecksum.cs0000664000175000017500000000672410572513626023662 0ustar jtaylorjtaylor// IChecksum.cs - Interface to compute a data checksum // Copyright (C) 2001 Mike Krueger // // This file was translated from java, it was part of the GNU Classpath // Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give you // permission to link this library with independent modules to produce an // executable, regardless of the license terms of these independent // modules, and to copy and distribute the resulting executable under // terms of your choice, provided that you also meet, for each linked // independent module, the terms and conditions of the license of that // module. An independent module is a module which is not derived from // or based on this library. If you modify this library, you may extend // this exception to your version of the library, but you are not // obligated to do so. If you do not wish to do so, delete this // exception statement from your version. namespace ICSharpCode.SharpZipLib.Checksums { /// /// Interface to compute a data checksum used by checked input/output streams. /// A data checksum can be updated by one byte or with a byte array. After each /// update the value of the current checksum can be returned by calling /// getValue. The complete checksum object can also be reset /// so it can be used again with new data. /// public interface IChecksum { /// /// Returns the data checksum computed so far. /// long Value { get; } /// /// Resets the data checksum as if no update was ever called. /// void Reset(); /// /// Adds one byte to the data checksum. /// /// /// the data value to add. The high byte of the int is ignored. /// void Update(int value); /// /// Updates the data checksum with the bytes taken from the array. /// /// /// buffer an array of bytes /// void Update(byte[] buffer); /// /// Adds the byte array to the data checksum. /// /// /// The buffer which contains the data /// /// /// The offset in the buffer where the data starts /// /// /// the number of data bytes to add. /// void Update(byte[] buffer, int offset, int count); } } keepass2-2.25/KeePassLibSD/Properties/0000775000175000017500000000000012271475522017467 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/Properties/AssemblyInfo.cs0000664000175000017500000000303712271475522022414 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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("KeePassLibSD")] [assembly: AssemblyDescription("KeePass Library")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Dominik Reichl")] [assembly: AssemblyProduct("KeePassLibSD")] [assembly: AssemblyCopyright("Copyright © 2003-2014 Dominik Reichl")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // COM settings [assembly: ComVisible(false)] // Assembly GUID [assembly: Guid("1d3c6f10-e10b-47be-a2f1-af2562d7d470")] // Assembly version information [assembly: AssemblyVersion("2.25.0.*")] keepass2-2.25/KeePassLibSD/KeePassLibSD.pfx0000664000175000017500000000333410576764760020301 0ustar jtaylorjtaylor00 *H 0}0 *H 00 *H  00 *H  05D?*dI& |i&fKG;#!΀%R[m)ZwQoT>ybv[O$Rd3OWo7c4;תBvft87 5SG LLP4AiF2L[+ )$as(Q+Oݷ+hț[#~)[jgriL8V(C3=JpzĺV 3:|<`N8+؃8, tjؚyD5֙,X2ut_."h/^+ɳ)oAL̒*Yv3V윎,J3kgLp/s(AqPԼH^˪Ͳ;6L$ 8̒/Ya\J7zl0+/eϬ!!v,(7w&ٝ|mQZmI];8FVW.";> r'E gӟ.4{j<(C ҉v9&g>+9= 9}z7Dݗ]2>y%o,^9߸E69Rd_yYaļI6h>'3s=7haT<$t\1BOJuHsw3dMBjW"F~aؒz>um+yj8S!X*ZР#D!;*q^1-28=p'>[ɠ> !\8CY5qM~}dWBx~I`߃m@%wz'mBqlCd |~E~Q4nvwm0d΢pJ4\Z46`W|Uc Ut10;00+&cr{ 5FL~!4Sqn.Ckeepass2-2.25/KeePassLibSD/Cryptography/0000775000175000017500000000000011643263772020032 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/Cryptography/Cipher/0000775000175000017500000000000010573311132021225 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/Cryptography/PasswordGenerator/0000775000175000017500000000000010666473134023502 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/SortedDictionary.cs0000664000175000017500000000415712261553106021151 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; using System.Collections.Generic; using System.Text; namespace KeePassLibSD { public sealed class SortedDictionary : IEnumerable> { private Dictionary m_dict = new Dictionary(); public int Count { get { return m_dict.Count; } } public TValue this[TKey pKey] { get { return m_dict[pKey]; } set { m_dict[pKey] = value; } } public ICollection Keys { get { return m_dict.Keys; } } public ICollection Values { get { return m_dict.Values; } } IEnumerator IEnumerable.GetEnumerator() { return m_dict.GetEnumerator(); } public IEnumerator> GetEnumerator() { return m_dict.GetEnumerator(); } public bool TryGetValue(TKey pKey, out TValue pValue) { return m_dict.TryGetValue(pKey, out pValue); } public void Clear() { m_dict.Clear(); } public void Add(TKey pKey, TValue pValue) { m_dict.Add(pKey, pValue); } public bool Remove(TKey pKey) { return m_dict.Remove(pKey); } public bool ContainsKey(TKey pKey) { return m_dict.ContainsKey(pKey); } } } keepass2-2.25/KeePassLibSD/KeePassLibSD.csproj0000664000175000017500000004264212003547730020770 0ustar jtaylorjtaylor Debug AnyCPU 9.0.30729 2.0 {DC15F71A-2117-4DEF-8C10-AA355B5E5979} Library Properties KeePassLibSD KeePassLibSD {4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} PocketPC 3C41C503-53EF-4c2a-8DD4-A8217CAD115E 4.20 KeePassLibSD v2.0 true KeePassLibSD.pfx 2.0 Pocket PC 2003 true full false ..\Build\KeePassLibSD\Debug\ TRACE;DEBUG;COMPACT_FRAMEWORK_V20;KeePassLibSD;NETCF_2_0 true true prompt 512 4 Off pdbonly true ..\Build\KeePassLibSD\Release\ TRACE;COMPACT_FRAMEWORK_V20;KeePassLibSD;NETCF_2_0 true true prompt 512 4 Off Collections\AutoTypeConfig.cs Collections\ProtectedBinaryDictionary.cs Collections\ProtectedStringDictionary.cs Collections\PwObjectList.cs Collections\PwObjectPool.cs Collections\StringDictionaryEx.cs Cryptography\Cipher\CipherPool.cs Cryptography\Cipher\ICipherEngine.cs Cryptography\Cipher\Salsa20Cipher.cs Cryptography\Cipher\StandardAesEngine.cs Cryptography\CryptoRandom.cs Cryptography\CryptoRandomStream.cs Cryptography\HashingStreamEx.cs Cryptography\HmacOtp.cs Cryptography\PasswordGenerator\CharSetBasedGenerator.cs Cryptography\PasswordGenerator\CustomPwGenerator.cs Cryptography\PasswordGenerator\CustomPwGeneratorPool.cs Cryptography\PasswordGenerator\PatternBasedGenerator.cs Cryptography\PasswordGenerator\PwCharSet.cs Cryptography\PasswordGenerator\PwGenerator.cs Cryptography\PasswordGenerator\PwProfile.cs Cryptography\PopularPasswords.cs Cryptography\QualityEstimation.cs Cryptography\SelfTest.cs Delegates\Handlers.cs Interfaces\IDeepCloneable.cs Interfaces\IStatusLogger.cs Interfaces\IStructureItem.cs Interfaces\ITimeLogger.cs Interfaces\IUIOperations.cs Interfaces\IXmlSerializerEx.cs Keys\CompositeKey.cs Keys\IUserKey.cs Keys\KcpCustomKey.cs Keys\KcpKeyFile.cs Keys\KcpPassword.cs Keys\KcpUserAccount.cs Keys\KeyProvider.cs Keys\KeyProviderPool.cs Keys\KeyValidator.cs Keys\KeyValidatorPool.cs Keys\UserKeyType.cs Native\NativeLib.cs Native\NativeMethods.cs PwCustomIcon.cs PwDatabase.cs PwDefs.cs PwDeletedObject.cs PwEntry.cs PwEnums.cs PwGroup.cs PwUuid.cs Resources\KLRes.Generated.cs Resources\KSRes.Generated.cs Security\ProtectedBinary.cs Security\ProtectedString.cs Security\XorredBuffer.cs Serialization\BinaryReaderEx.cs Serialization\FileLock.cs Serialization\FileTransactionEx.cs Serialization\HashedBlockStream.cs Serialization\IOConnection.cs Serialization\IOConnectionInfo.cs Serialization\KdbxFile.cs Serialization\KdbxFile.Read.cs Serialization\KdbxFile.Read.Streamed.cs Serialization\KdbxFile.Write.cs Serialization\OldFormatException.cs Translation\KPControlCustomization.cs Translation\KPFormCustomization.cs Translation\KPStringTable.cs Translation\KPStringTableItem.cs Translation\KPTranslation.cs Translation\KPTranslationProperties.cs Utility\AppLogEx.cs Utility\GfxUtil.cs Utility\MemUtil.cs Utility\MessageService.cs Utility\StrUtil.cs Utility\TimeUtil.cs Utility\UrlUtil.cs keepass2-2.25/KeePassLibSD/ProtectedData.cs0000664000175000017500000000342112261553106020377 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; namespace KeePassLib { public enum DataProtectionScope { CurrentUser } /// /// This ProtectedData class does NOT work like the original implementation /// in the non-CF .NET! The DataProtectionScope is useless and only /// declared to make it compatible with the original. Also, the optional /// entropy is ignored. /// public static class ProtectedData { public static byte[] Protect(byte[] userData, byte[] optionalEntropy, DataProtectionScope scope) { byte[] pb = new byte[userData.Length]; Array.Copy(userData, pb, userData.Length); ProtectedMemory.Protect(pb, MemoryProtectionScope.SameProcess); return pb; } public static byte[] Unprotect(byte[] encryptedData, byte[] optionalEntropy, DataProtectionScope scope) { return Protect(encryptedData, optionalEntropy, scope); } } } keepass2-2.25/KeePassLibSD/SHA256.cs0000664000175000017500000000247712261553106016536 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 Org.BouncyCastle.Crypto.Digests; namespace System.Security.Cryptography { // Implement a simplified version of the SHA256Managed // class that ships with non-CF .NET 2.0. public sealed class SHA256Managed { public byte[] ComputeHash(byte[] pbData) { Sha256Digest sha256 = new Sha256Digest(); sha256.BlockUpdate(pbData, 0, pbData.Length); byte[] pbHash = new byte[32]; sha256.DoFinal(pbHash, 0); return pbHash; } } } keepass2-2.25/KeePassLibSD/ProtectedMemory.cs0000664000175000017500000000320112261553106020772 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; namespace KeePassLib { public enum MemoryProtectionScope { SameProcess } /// /// This ProtectedMemory class does NOT work like the original implementation /// in the non-CF .NET! The MemoryProtectionScope is useless and only /// declared to make it compatible with the original. /// public static class ProtectedMemory { public static void Protect(byte[] userData, MemoryProtectionScope scope) { byte bt = 5; unchecked { for(int i = 0; i < userData.Length; ++i) { userData[i] ^= bt; bt += 13; } } } public static void Unprotect(byte[] encryptedData, MemoryProtectionScope scope) { Protect(encryptedData, scope); } } } keepass2-2.25/KeePassLibSD/Delegates/0000775000175000017500000000000010573311142017216 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/Serialization/0000775000175000017500000000000010573311176020145 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/Interfaces/0000775000175000017500000000000010573311152017405 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/Resources/0000775000175000017500000000000011105610210017261 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/ColorTranslator.cs0000664000175000017500000000312112261553106021001 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; namespace KeePassLib { public static class ColorTranslator { public static Color FromHtml(string strColor) { string str = strColor.Trim(new char[]{ '\r', '\n', ' ', '\t', '#' }); str = str.ToUpper(); if(str.Length != 6) { Debug.Assert(false); return Color.Empty; } int[] pb = new int[6]; for(int i = 0; i < 6; ++i) { if((str[i] >= '0') && (str[i] <= '9')) pb[i] = str[i] - '0'; else pb[i] = (str[i] - 'A') + 10; } int r = (pb[0] << 4) | pb[1]; int g = (pb[2] << 4) | pb[3]; int b = (pb[4] << 4) | pb[5]; return Color.FromArgb(r, g, b); } } } keepass2-2.25/KeePassLibSD/Security/0000775000175000017500000000000010573311170017131 5ustar jtaylorjtaylorkeepass2-2.25/KeePassLibSD/Collections/0000775000175000017500000000000010573311112017574 5ustar jtaylorjtaylorkeepass2-2.25/ReadMe_PFX.txt0000664000175000017500000000063211156222774015536 0ustar jtaylorjtaylorAll projects contain dummy PFX files. These PFX files are NOT the ones with which the KeePass distributions are signed, these are kept secret. In order to unlock the private keys of the dummy PFX files, use: "123123" (without the quotes) Official KeePass distributions are signed with private keys. You can find the corresponding public keys in the Ext/PublicKeys directory. keepass2-2.25/Docs/0000775000175000017500000000000012273661062014010 5ustar jtaylorjtaylorkeepass2-2.25/Docs/Chm/0000775000175000017500000000000012273661064014521 5ustar jtaylorjtaylorkeepass2-2.25/Docs/Chm/KeePass.hhp0000664000175000017500000000301112273657712016555 0ustar jtaylorjtaylor[OPTIONS] Compatibility=1.1 or later Compiled file=KeePass.chm Contents file=KeePassContents.hhc Default topic=help\base\index.html Display compile progress=No Full-text search=Yes Language=0x409 Englisch (USA) Title=KeePass Password Safe Help [FILES] help\base\autotype.html help\base\autourl.html help\base\cmdline.html help\base\configuration.html help\base\credits.html help\base\credits_icons_license.html help\base\disclaimer.html help\base\faq.html help\base\faq_tech.html help\base\fieldrefs.html help\base\firststeps.html help\base\importexport.html help\base\index.html help\base\integration.html help\base\keys.html help\base\license_lgpl.html help\base\multiuser.html help\base\placeholders.html help\base\pwgenerator.html help\base\repair.html help\base\secedits.html help\base\security.html help\base\tans.html help\base\usingpws.html help\v2\autotype_obfuscation.html help\v2\dbsettings.html help\v2\entry.html help\v2\guioptions.html help\v2\index.html help\v2\ioconnect.html help\v2\license.html help\v2\plugins.html help\v2\policy.html help\v2\setup.html help\v2\sync.html help\v2\translation.html help\v2\triggers.html help\v2\version.html help\v2\xml_replace.html help\v2_dev\customize.html help\v2_dev\plg_index.html help\v2_dev\scr_index.html help\v2_dev\scr_kps_index.html help\v2_dev\scr_sc_index.html images\grad_v_gw.gif images\back.gif images\grad_h_gw.gif images\grad_h_gw_186.gif images\grad_v_dlb.gif images\grad_v_dlb_tall_light.png [INFOTYPES] keepass2-2.25/Docs/Chm/help/0000775000175000017500000000000012273661064015451 5ustar jtaylorjtaylorkeepass2-2.25/Docs/Chm/help/base/0000775000175000017500000000000012273661062016361 5ustar jtaylorjtaylorkeepass2-2.25/Docs/Chm/help/base/autotype.html0000664000175000017500000005502712273660230021126 0ustar jtaylorjtaylor Auto-Type - KeePass
Auto-Type Icon

Auto-Type


Powerful feature that sends simulated keypresses to other applications.

Text  Basic Auto-Type Information

KeePass features an "Auto-Type" functionality. This feature allows you to define a sequence of keypresses, which KeePass can automatically perform for you. The simulated keypresses can be sent to any other currently open window of your choice (browser windows, login dialogs, ...).

By default, the sent keystroke sequence is {USERNAME}{TAB}{PASSWORD}{ENTER}, i.e. it first types the user name of the selected entry, then presses the Tab key, then types the password of the entry and finally presses the Enter key.

For TAN entries, the default sequence is {PASSWORD}, i.e. it just types the TAN into the target window, without pressing Enter.

Auto-Type can be configured individually for each entry using the Auto-Type tab page on the entry dialog (select an entry -> Edit Entry). On this page you can specify a default sequence and customize specific window/sequence associations.

Two-Channel Auto-Type Obfuscation is supported (making Auto-Type resistant against keyloggers).

Additionally, you can create customized window/sequence associations, which override the default sequence. You can specify different keystroke sequences for different windows for each entry. For example, imagine a webpage, to which you want to login, that has multiple pages where one can login. These pages could all look a bit different (on one you could additionally need to check some checkbox -- like often seen in forums). Here creating customized window/sequence associations solves the problems: you simply specify different auto-type sequences for each windows (identified by their window titles).

Invoking Auto-Type:
There are three different methods to invoke auto-type:

  • Invoke auto-type for an entry by using the context menu command Perform Auto-Type while the entry is selected.
  • Select the entry and press Ctrl+V (that's the menu shortcut for the context menu command above).
  • Using the system-wide auto-type hot key. KeePass will search all entries in the currently opened database for matching sequences.

All methods are explained in detail below.


Text  Context Menu: 'Perform Auto-Type' Command

This method is the one that requires the least amount of configuration and is the simpler one, but it has the disadvantage that you need to select the entry in KeePass which you want to auto-type.

The method is simple: right-click on an entry of your currently opened database and click 'Perform Auto-Type' (or alternatively press the Ctrl+V shortcut for this command). The window that previously got the focus (i.e. the one in which you worked before switching to KeePass) will be brought to the foreground and KeePass auto-types into this window.

The sequence which is auto-typed depends on the window's title. If you didn't specify any custom window/sequence associations, the default sequence is sent. If you created associations, KeePass uses the sequence of the first matching association. If none of the associations match, the default sequence is used.


Text  Global Auto-Type Hot Key

This is the more powerful method, but it also requires a little bit more work/knowledge, before it can be used.

Simple Global Auto-Type Example:

  1. Create an entry in KeePass titled Notepad with values for user name and password.
  2. Start Notepad - under 'Programs' -> 'Accessories'.
  3. Press Ctrl+Alt+A within Notepad. The user name and password will be typed into Notepad.

The KeePass entry title Notepad is matched with the window title of Notepad and the default Auto-Type sequence is typed.

How It Works - Details:

KeePass registers a system-wide hot key for auto-type. The advantage of this hot key is that you don't need to switch to the KeePass window and select the entry. You simply press the hot key while having the target window open (i.e. the window which will receive the simulated keypresses).

By default, the global hot key is Ctrl+Alt+A (i.e. hold the Ctrl and Alt keys, press 'A' and release all keys). You can change this hot key in the options dialog (main menu - 'Tools' - 'Options', tab 'Integration'): here, click into the textbox below "Global Auto-Type Hot Key Combination" and press the hot key that you wish to use. If the hot key is usable, it will appear in the textbox.

When you press the hot key, KeePass looks at the title of the currently opened window and searches the currently opened database for usable entries. If KeePass finds multiple entries that can be used, it displays a selection dialog. An entry is considered to be usable for the current window title when at least one of the following conditions is fulfilled:

  • The title of the entry is a substring of the currently active window title.
  • The entry has a window/sequence association, of which the window specifier matches the currently active window title.

The second condition has been mentioned already, but the first one is new. By using entry titles as filters for window titles, the configuration amount for auto-type is almost zero: you only need to make sure that the entry title is contained in the window title of the window into which you want the entry to be auto-typed. Of course, this is not always possible (for example, if a webpage has a very generic title like "Welcome"), here you need to use custom window/sequence associations.

Custom window/sequence associations can be specified on the 'Auto-Type' tab page of each entry.

The associations complement the KeePass entry title. Any associations specified will be used in addition to the KeePass entry title to determine a match.

Auto-Type window definitions, entry titles and URLs are Spr-compiled, i.e. placeholders, environment variables, field references, etc. can be used.


Text  Auto-Type Keystroke Sequences

An auto-type keystroke sequence is a one-line string that can contain placeholders and special key codes.

A complete list of all supported placeholders can be found on the page Placeholders. The special key codes can be found below.

Above you've seen already that the default auto-type is {USERNAME}{TAB}{PASSWORD}{ENTER}. Here, {USERNAME} and {PASSWORD} are placeholders: when auto-type is performed, these are replaced by the appropriate field values of the entry. {TAB} and {ENTER} are special key codes: these are replaced by the appropriate keypresses. Special key codes are the only way to specify special keys like Arrow-Down, Shift, Escape, etc.

Of course, keystroke sequences can also contain simple characters to be sent. For example, the following string is perfectly valid as keystroke sequence string:
{USERNAME}{TAB}Some text to be sent!{ENTER}.

Special key codes are case-insensitive.

Special Keys:
The following codes for special keys are supported:

Special KeyCode
Tab{TAB}
Enter{ENTER} or ~
Arrow Up{UP}
Arrow Down{DOWN}
Arrow Left{LEFT}
Arrow Right{RIGHT}
Insert{INSERT} or {INS}
Delete{DELETE} or {DEL}
Home{HOME}
End{END}
Page Up{PGUP}
Page Down{PGDN}
Space{SPACE}
Backspace{BACKSPACE}, {BS} or {BKSP}
Break{BREAK}
Caps-Lock{CAPSLOCK}
Escape{ESC}
Windows Key{WIN} (equ. to {LWIN})
Windows Key: left, right{LWIN}, {RWIN}
Apps / Menu{APPS}
Help{HELP}
Numlock{NUMLOCK}
Print Screen{PRTSC}
Scroll Lock{SCROLLLOCK}
F1 - F16{F1} - {F16}
Numeric Keypad +{ADD}
Numeric Keypad -{SUBTRACT}
Numeric Keypad *{MULTIPLY}
Numeric Keypad /{DIVIDE}
Numeric Keypad 0 to 9{NUMPAD0} to {NUMPAD9}
Shift+
Ctrl^
Alt%

Special KeyCode
+{+}
%{%}
^{^}
~{~}
(, ){(}, {)}
[, ]{[}, {]}
{, }{{}, {}}

Additionally, some special commands are supported:

Command SyntaxAction
{DELAY X}Delays X milliseconds.
{DELAY=X}Sets the default delay to X milliseconds for all following keypresses.
{CLEARFIELD}Clears the contents of the edit control that currently has the focus (only single-line edit controls).
{VKEY X}Sends the virtual key of value X.

Command SyntaxAction
{VKEY-NX X}Sends the non-extended virtual key of value X. If possible, use {VKEY X} instead.
{VKEY-EX X}Sends the extended virtual key of value X. If possible, use {VKEY X} instead.
Keys and special keys (not placeholders or commands) can be repeated by appending a number within the code. For example, {TAB 5} presses the Tab key 5 times.

For details on how to send special keys for which no explicit special key codes exist, please see: How can auto-type send other special keys?.

Finally, some examples:

{TITLE}{TAB}{USERNAME}{TAB}{PASSWORD}{ENTER}
Types the entry's title, a Tab, the user name, a Tab, the password of the currently selected entry, and presses Enter.

{TAB}{PASSWORD}{ENTER}
Presses the Tab key, enters the entry's password and presses Enter.

{USERNAME}{TAB}^v{ENTER}
Types the user name, presses Tab, presses Ctrl+v (which pastes data from the Windows clipboard in most applications), and presses Enter.


Toggling Checkboxes:
Sometimes you find checkboxes on websites ("Stay logged in on this computer" for example). You can toggle these checkboxes by sending a space character (' ') when auto-typing. For example:
{USERNAME}{TAB}{PASSWORD}{TAB} {TAB}{ENTER}
If there is a webform with a user name field, password field and a checkbox, this sequence would enter the user name, the password and toggle the checkbox that follows the password control.

Pressing Non-Default Buttons:
Pressing non-default buttons works the same as toggling checkboxes: send a space character (' '). Note that this should only be used for non-default buttons; for default buttons, {ENTER} should be sent instead.

Higher ANSI Characters:
The auto-type function supports sending of higher ANSI characters in range 126-255. This means that you can send special characters like ©, @, etc. without any problems; you can write them directly into the keystroke sequence definition.


Text  Target Window Filters

When creating a custom window/sequence association, you need to tell KeePass how the matching window titles look like. Here, KeePass supports simple wildcards:

String with WildcardMeaning
STRINGMatches all window titles that are named exactly "STRING".
STRING*Matches all window titles that start with "STRING".
*STRINGMatches all window titles that end with "STRING".
*STRING*Matches all window titles that have "STRING" somewhere in the window title. This includes the string being directly at the start or at the end of the window title.

Wildcards may also appear in the middle of patterns. For example, *Windows*Explorer* would match Windows Explorer.

Additionally, matching using regular expressions is supported. In order to tell KeePass that the pattern is a regular expression, enclose it in //. For example, //B.?g Window// would match Big Window, Bug Window and Bg Window.

By using wildcards, you can make your auto-type associations browser-independent. See the usage examples for more information.


Text  Change Default Auto-Type Sequence

The default auto-type sequence (i.e. the one which is used when you don't specify a custom one) is {USERNAME}{TAB}{PASSWORD}{ENTER}. KeePass allows you to change this default sequence. Normally you won't need to change it (use custom window/sequence definitions instead!), but it is quite useful when some other application is interfering with KeePass (for example a security software that always asks you for permission before allowing KeePass to auto-type).

By default, entries inherit the auto-type sequence of their containing group. Groups also inherit the auto-type sequence of their parent groups. There is only one top group (the first group contains all other groups). Consequently, if you change the auto-type sequence of this very first group, all other groups and their entries will use this sequence. Practically, this is a global override. To change it, right-click on the first group, choose 'Edit Group' and switch to the 'Auto-Type' tab.

Text  Usage Example

Now let's have a look at a real-world example: logging into a website. In this example, will we use the global auto-type hot key to fill out the login webpage. First open the test page, and afterwards create a new entry in KeePass with title Test Form and a user name and password of your choice.

Let's assume the global auto-type hot key is set to Ctrl+Alt+A (the default). KeePass is running in the background, you have opened your database and the workspace is unlocked.

When you now navigate to the test page and are being prompted for your user name and password, just click into the user name field and press Ctrl+Alt+A. KeePass enters the user name and password for you!

Why did this work? The window title of your browser window was "Test Form - KeePass - Internet Explorer" or "Test Form - KeePass - Mozilla Firefox", depending on the browser you are using. Because we gave the entry in KeePass the title Test Form, the entry title is contained in the window title, therefore KeePass uses this entry.

Here you see the huge advantages of auto-type: it not only doesn't require any additional browser software (the browser knows nothing of KeePass -- there are no helper browser plugins required), it is also browser-independent: the one entry that you created within KeePass works for Internet Explorer and Mozilla Firefox (and other browsers) without requiring any modifications or definitions.

When you would use window/sequence associations (instead of entry title matching), you can achieve the same browser-independent effect using wildcards: you could for example have used Test Form - KeePass - * as window filter. This filter matches both the Internet Explorer and the Firefox window.

keepass2-2.25/Docs/Chm/help/base/cmdline.html0000664000175000017500000002363012273660230020662 0ustar jtaylorjtaylor Command Line Options - KeePass
Command Line

Command Line Options


Command line options to automate KeePass tasks.

You can pass a file path in the command line in order to tell KeePass to open this file immediately after startup.

Switches can be either prefixed using a minus (-) or two minus characters (--). On Windows, a slash (/) is another alternative. The prefixes are equivalent; it doesn't matter which one you use.

Database file. The database file location is passed as argument. Only one database file is allowed. If the path contains a space, it must be enclosed in quotes (").

Password. Passwords can be passed using the -pw: option. In order to pass 'abc' as password, you would add the following argument to the command line: -pw:abc. Note that there must be no space between the ':' and the password. If your password contains a space, you must enclose it in quotes. For example: -pw:"my secret password".

Using the -pw: option is not recommended, because of security reasons (the operating system allows reading the command line options of other applications).

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 exists. The same rules as above apply, just that you specify the key file location: -keyfile:D:\pwsafe.key. You also need to quote the value, if it contains a space, tab or other whitespace characters.

Pre-selection. In order to just pre-select a key file, use the -preselect: option. For example, if you lock your database with a password and a key file, but just want to type in the password (so, without selecting the key file manually), your command line would look like this:

KeePass.exe "C:\My Documents\MyDatabase.kdb" -preselect:C:\pwsafe.key

KeePass would then show a prompt for the password for the database, but in the key file list, the C:\pwsafe.key file is selected already. When using the preselect switch, KeePass by default activates the key file switch and sets the focus to the password edit window.

Note the difference! The preselect switch just pre-selects the key file for you and displays the login prompt. In contrast, the keyfile switch doesn't prompt you for the (maybe missing) password.

Other. The -minimize command line argument makes KeePass start up minimized.

The -auto-type command line argument makes other already opened KeePass instances perform a global auto-type.

Additionally, the -useraccount switch is supported. If specified, the current user account credentials will be used.

The -iocredfromrecent switch makes KeePass load file system credentials (not database key) from the most recently used files list. Alternatively, the file system credentials can be specified using the -iousername and -iopassword parameters. The optional -ioiscomplete switch tells KeePass that the path and file system credentials are complete (the 'Open URL' dialog will not be displayed then).

The -pw-enc parameter is similar to -pw, but it requires the password to be encrypted. Encrypted passwords can be generated using the {PASSWORD_ENC} placeholder.

The -entry-url-open option makes other already opened KeePass instances search for an entry and open its URL. The entry is identified by its UUID, which you can pass as -uuid: command line parameter.

Analogously to the -auto-type option, -auto-type-selected performs auto-type for the currently selected entry.

The order of the arguments is arbitrary.


Text  Usage Examples

Open the database file 'C:\My Documents\MyDatabase.kdb' (KeePass will prompt you for the password and/or key file location):

KeePass.exe "C:\My Documents\MyDatabase.kdb"

If you got a database that is locked with a password 'abc', you could open it like this:

KeePass.exe "C:\My Documents\MyDatabaseWithPw.kdb" -pw:abc

If your USB stick always mounts to drive F: and you've locked your database with a key file on the USB stick, you could open your database as follows:

KeePass.exe "C:\My Documents\MyDatabaseWithFile.kdb" -keyfile:F:\pwsafe.key

If you've locked your database using a password and a key file, you can combine the two switches and open your database as follows:

KeePass.exe "C:\My Documents\MyDatabaseWithTwo.kdb" -pw:abc -keyfile:F:\pwsafe.key

You have locked your database using a password and a key file, but only want to have the key file pre-selected (i.e. you want to get prompted for the password), your command line would look like this:

KeePass.exe "C:\My Documents\MyDatabaseWithTwo.kdb" -preselect:F:\pwsafe.key

Text  Starting KeePass using a Batch File

Batch files can be used to start KeePass. Mostly you want to specify some of the parameters listed above. You can theoretically simply put the command line (i.e. application path and parameters) into the batch file, but this is not recommended as the command window will stay open until KeePass is closed. The following method is recommended instead:

START "" KeePass.exe ..\MyDb.kdb -pw:MySecretPw

This START command will run KeePass (which opens the ..\MyDb.kdb file using MySecretPw as password). KeePass is assumed to be in the same directory (working directory) as the batch file, otherwise you need to specify a different path.

START executes the given command line and immediately exits, i.e. it doesn't wait until the application is terminated. Consequently, the command window will disappear after KeePass has been started.

Please note the two quotes (") after the START command. These quotes are required if the application path contains quotes (in the example above, the quotes could also be removed). If you want to learn more about the START command syntax, type START /? into the command window.


Text  Closing/Locking KeePass using a Batch File

To close all currently running KeePass instances, call KeePass.exe with the '--exit-all' parameter:

KeePass.exe --exit-all

All KeePass windows will attempt to close. If a database has been modified, KeePass will ask you whether you want to save or not. If you wish to save in any case (i.e. a forced exit without any confirmation dialog), enable the 'Automatically save database on exit and workspace locking' option in 'Tools' - 'Options...' - 'Advanced'.

The KeePass instance that has been created by the command above is not visible (i.e. it does not show a main window) and will immediately terminate after sending close requests to the other instances.

The --lock-all and --unlock-all command line options lock/unlock the workspaces of all other KeePass instances.

keepass2-2.25/Docs/Chm/help/base/faq.html0000664000175000017500000001603712273660230020021 0ustar jtaylorjtaylor Administrative FAQ - KeePass
Help

Administrative FAQ


Frequently Asked Questions about the project, licensing, ...

Info  How can I help you?

If you like KeePass and would like to help the developers in some way:

  • Donate
    This is the best way of helping, if you don't have that much time or experience in application development.
  • Make a translation
    If you have some free time, you could make a translation of KeePass (of course only if you're language isn't offered already).
  • Test new releases and report bugs
    KeePass is under constant development, new features get implemented, bugs get fixed. If you have some free time, you could test new releases thoroughly and report bugs. If you're a programmer, look through the sources to find bugs and maybe even submit fixes.
  • Spread the word
    If you like KeePass, tell all your friends how great KeePass is, publish articles about it, press it on CDs/DVDs, ship USB sticks preinstalled with it, submit it to software archives, talk in forums about it, etc.!

Info  May KeePass be used in a company?

Yes. KeePass is free software and you don't have to pay any fees. You may freely use KeePass under the terms of its license.

But of course, if you like KeePass, donations are always greatly appreciated.

You might be interested in this page: Customization (2.x).

Info  What about a centralized KeePass Internet server?

The idea on the first glance sounds simple and useful: there should be a centralized KeePass Internet server, on which all users can store their passwords. By having Internet connection, you'd have access to all your passwords.

Note that this idea is different from simply providing webspace. KeePass 2.x already supports storing databases on servers using HTTP/FTP. The point is having one server for all users.

When creating such a server, there are several difficulties:

  • A fairly complex synchronization and caching mechanism will be required. You won't want to transfer the complete database, otherwise the service will be unusable for everyone storing attachments, etc.

  • Directly related to the previous point: in order to do synchronization, the server needs to be able to read and understand databases, i.e. some dedicated KeePass server would need to be written. While the transport way could be secure HTTPS, the server certainly has some user data as plain text in memory for some time. One needs to be very careful here. What to do if the server gets compromised? The security implications would be horrible, if an attacker could read any user data.

  • How to avoid server compromises? If a normal Internet server is compromised, the security implications are minimal: in the worst case all user accounts and data for this website are lost. But with KeePass server, whole identities would be lost. An attacker couldn't only impersonate someone on this particular server, but on the complete Internet and real world, depending on what is stored in the databases.

    Therefore, banking-level security systems would be required for a KeePass server. Keeping PHP / ASP / Linux / Windows (or whatever will be used) up-to-date definitely is not enough here.

  • Basically you offer people webspace for their databases, therefore the service obviously will cost something. By charging people, they expect reliability and you need to make up-time guarantees. Therefore, at least 2 servers are required (by different hosters), which need to be synchronized.

Summary: a centralized Internet server currently is out of range. If someone wants to start a company providing such a service, feel free to use KeePass as base application (of course respect the Open Source terms).

But what can and probably will be done later is a local intranet KeePass server (for companies for example). Employees could log in to the company's password server and use it. But a centralized Internet server — no chance.

keepass2-2.25/Docs/Chm/help/base/security.html0000664000175000017500000004366112273660230021124 0ustar jtaylorjtaylor Security - KeePass
Locked

Security


Detailed information about the security of KeePass.


Key  Database Encryption

KeePass database files are encrypted. KeePass encrypts the complete database, i.e. not only your passwords. The user names, notes, etc. are encrypted, too.

Databases are encrypted using one of the following block ciphers:

Cipher Block Size Key Size
Advanced Encryption Standard (AES / Rijndael) 128 bits 256 bits
Twofish 128 bits 256 bits

These algorithms are well-known, analyzed thoroughly and considered to be very secure (see [1] for comments by the NIST on AES for example). AES e.g. became effective as a U.S. Federal government standard and is approved by the National Security Agency (NSA) for top secret information.

KeePass 2.x doesn't support Twofish, but additional encryption algorithms can be provided by plugins.

The block ciphers are used in the CBC (cipher-block chaining) block cipher mode. In CBC mode, plaintext patterns are concealed.

For both algorithms, a 128-bit initialization vector (IV) is generated randomly each time you save the database. This allows multiple databases to be encrypted using the same key without observable patterns being revealed.


Key  Hashing and Key Derivation

In order to generate the 256-bit key for the block ciphers, the Secure Hash Algorithm SHA-256 is used. This algorithm compresses the user key provided by the user (consisting of password and/or key file) to a fixed-size key of 256 bits. This transformation is one-way, i.e. it is computationally infeasible to invert the hash function or find a second message that compresses to the same hash.

The recently discovered attack against SHA-1 [2] doesn't affect the security of SHA-256. SHA-256 is still considered as being very secure [3].

Key Derivation:
If only a password is used (i.e. no key file), the password plus a 128-bit random salt are hashed using SHA-256 to form the final key (but note there is some preprocessing: Protection against Dictionary Attacks). The random salt prevents attacks that are based on pre-computed hashes.

When using both password and key file, the final key is derived as follows: SHA-256(SHA-256(password), key file contents), i.e. the hash of the master password is concatenated with the key file bytes and the resulting byte string is hashed with SHA-256 again. If the key file doesn't contain exactly 32 bytes (256 bits), they are hashed with SHA-256, too, to form a 256-bit key. The formula above then changes to: SHA-256(SHA-256(password), SHA-256(key file contents)).


Binary  Random Number Generation

KeePass needs to generate several random bytes (for the IV, the master key salt, etc.). For this, several pseudo-random sources are used: current tick count, performance counter, system date/time, mouse cursor position, memory status (free virtual memory, etc.), active window, clipboard owner, various process and thread IDs, various window handles (active window, desktop, ...), window message stack, process heap status, process startup information and several system information structures. Additionally, KeePass uses random bytes provided by the system's default CSP RNG.

This pseudo-random data is collected in a random pool. To generate 16 random bytes, the pool is hashed (SHA-256) with a counter. The counter is increased after 16 generated bytes. This way, as many secure random bytes can be produced efficiently as needed.


Key  Protection against Dictionary Attacks

KeePass supports a protection against guessing and dictionary attacks.

You can't really prevent these attacks: nothing prevents an attacker to just try all possible keys and look if the database decrypts. But what we can do (and KeePass does) is to make it harder: by adding a constant work factor to the key initialization, we can make them as hard as we want.

To generate the final 256-bit key that is used for the block cipher, KeePass first hashes the user's password using SHA-256, encrypts the result N times using the Advanced Encryption Standard (AES) algorithm (called key transformation rounds from on now), and then hashes it again using SHA-256. For AES, a random 256-bit key is used, which is stored in the database file. As the AES transformations aren't pre-computable (key is random), an attacker has to perform all the encryptions, too, otherwise he cannot try and see if the current key is correct.

An attacker now needs much more time to try a key. If he can only try a few keys per second, a dictionary attack is not practical anymore. N is a work factor, only indirectly a time factor. A super computer can try a key a lot faster than a standard PC, but anyway testing one key with N transformation rounds will take N times longer than trying a key with no transformation rounds on the super computer.

By default, KeePass sets N to 6000 encryption rounds (full encryptions are meant; N has nothing to do with the internal encryption rounds of AES). This number has been chosen in order to provide compatibility with portable device versions (PocketPC processors are slower, therefore the key computation takes longer).

If you are using KeePass on PC only, it is highly recommended to increase the number of key transformation rounds. You can change the number in the database options dialog. Right of the field for the rounds, you'll find a button. When clicking this button, KeePass computes the rounds number that leads to a 1-second delay. Waiting 1 second at database opening isn't a problem, but for an attacker of course it is. But, the number can be freely set to a number of your choice; the button only should give you a rough idea how many rounds can be computed in 1 second on your computer.

This protection feature is only useful for master passwords; key files are random anyway, there's no need to transform the key file contents. Guessing the key file contents is equally hard to a brute-force attack on the final key.

KeePass uses multithreading to compute the transformations (the master key is split up to two parts of 128 bits, which is the AES block size). On dual/multi core processors, the computation can be twice as fast as on a single core processor.

On Windows Vista and higher, KeePass can use Windows' CNG/BCrypt API for the key transformations, which is about 50% faster than the KeePass built-in key transformation code.

KeePassX: In contrast to KeePass, the Linux port project 'KeePassX' only partially supports protection against dictionary and guessing attacks.


Application Protection  Process Memory Protection

While KeePass is running, sensitive data (like the hash of the master key and entry passwords) is stored encrypted in process memory.

This means that even if you would dump the KeePass process memory to disk, you couldn't find the passwords.

For example, when you are copying a password to the clipboard, KeePass first decrypts the password field, copies it to the clipboard and immediately re-encrypts it using the random key.

Additionally, KeePass erases all security-critical memory when it's not needed anymore, i.e. it overwrites these memory areas before releasing them (this applies to all security-critical memory, not only the password fields).

KeePass ≥ 1.15 and 2.x use the Windows DPAPI for in-memory encrypting the sensitive data. With DPAPI, the key for in-memory encryption is stored in a secure, non-swappable memory area managed by Windows. If DPAPI is not available or disabled (advanced KeePass options, by default using DPAPI is enabled), KeePass uses the ARC4 encryption algorithm with a random key. Note that this is less secure than DPAPI, mainly not because ARC4 cryptographically isn't that strong, but because the key for in-memory encryption is also stored in swappable process memory.


Desktop  Enter Master Key on Secure Desktop (Protection against Keyloggers)

Note: KeePass was one of the first (maybe even the first) password manager that allows entering the master key on a secure desktop!

KeePass 2.x has an option (in 'Tools' -> 'Options' -> tab 'Security') to show the master key dialog on a secure desktop (supported on Windows ≥ 2000), similar to Windows' User Account Control (UAC). Almost no keylogger works on a secure desktop.

The option is disabled by default for compatibility reasons.

Note that auto-type can be secured against keyloggers, too, by using Two-Channel Auto-Type Obfuscation.

Key  Locking the Workspace

When locking the workspace, KeePass closes the database file and only remembers its path.

This provides maximum security: unlocking the workspace is as hard as opening the database file the normal way. Also, it prevents data loss (the computer can crash while KeePass is locked, without doing any damage to the database).


Plugins  Plugin Security

A separate page exist about the security of plugins: Plugin Security.


Black Box  Self-Tests

Each time you start KeePass, the program performs a quick self-test to see whether the block ciphers and the hash algorithms work correctly and pass their test-vectors. If one of the algorithms doesn't pass its test vectors, KeePass shows a security exception message box.


Terminal  Specialized Spyware

This section gives answers to questions like the following:

  • Would encrypting the configuration file increase security by preventing changes by a malicious program?
  • Would encrypting the application (executable file, eventually together with the configuration file) increase security by preventing changes by a malicious program?
  • Would an option to prevent plugins from being loaded increase security?
  • Would storing security options in the database (to override the settings of the KeePass instance) increase security?
  • Would locking the main window in such a way that only auto-type is allowed increase security?

The answer to all these questions is: no. Adding any of these features would not increase security.

All security features in KeePass protect against generic threats like keyloggers, clipboard monitors, password control monitors, etc. (and against non-runtime attacks on the database, memory dump analyzers, ...). However in all the questions above we're assuming that there's a spyware program running on the system that's specialized on attacking KeePass.

In this situation, the best security features will fail. This is law #1 of the 10 Immutable Laws of Security [4] [5]: "If a bad guy can persuade you to run his program on your computer, it's not your computer anymore".

For example, consider the following very simple spyware specialized for KeePass: an application that waits for KeePass to be started, then hides the started application and imitates KeePass itself. All interactions (like entering a password for decrypting the configuration, etc.) can be simulated. The only way to discover this spyware is to use a program that the spyware doesn't know about or can't manipulate (secure desktop); in any case it can't be KeePass.


References  References and Further Reading

[1] National Institute of Standards and Technology: Report on the Development of the Advanced Encryption Standard (AES) (PDF).

[2] Bruce Schneier's blog: SHA-1 broken.

[3] Bruce Schneier's blog: Cryptanalysis of SHA-1, with comments about the impact of that discovery and what to do now.

[4] Scott Culp, Microsoft TechNet Essay, 2000: 10 Immutable Laws of Security.

[5] Jesper M. Johansson, Microsoft TechNet Magazine, 2008: Revisiting the 10 Immutable Laws of Security, Part 1.

keepass2-2.25/Docs/Chm/help/base/firststeps.html0000664000175000017500000001727012273660230021460 0ustar jtaylorjtaylor First Steps Tutorial - KeePass
Help

First Steps Tutorial


A short tutorial showing you the basic usage of KeePass.

This short tutorial will show you how to actually use KeePass. It describes only the basic usage, advanced features are covered on separate pages.


Creating a new database

The very first step is creating a new password database. KeePass will store all your passwords in such a database. To create one, click 'File - New...' in the main menu or click the leftmost toolbar button. A window will appear, which prompts you for a master password and/or key file. The database will be encrypted with the password you enter here. The password you enter here will be the only password you'll ever have to remember from on now. It should be long and built up of mixed characters. Keep in mind that when someone gets your database file and guesses the password, he could access all passwords you stored in the database.

For this tutorial, we'll just use a password, not a key file. Click into the password edit field and enter a password of your choice. The password edit control isn't limited in length, so feel free to even enter a whole sentence (just keep in mind that you'll need to remember it).

After clicking [OK], a second dialog appears. In this dialog you can configure some generic database properties. For now, just leave everything as it is and click [OK].

Now you see the main window. On the left, you see the entry groups. On the right, you see the actual password entries. The password entries are grouped together into the password groups you see on the left. So, depending on which group on the left you selected, it'll show you the entries in this group in the right view. KeePass has created a few default groups for you, but you're totally free to delete them and create your own ones.


Adding an entry

Time to store your very first password in the KeePass database! Right-click into the right password entry view and choose 'Add Entry...'. A window will pop up. In this window you can now edit your entry: enter some title for it, an username, an URL, the actual password, etc. If you don't need some of the fields, just leave them empty. When you're done, click [OK].

You'll see your new entry in the password list on the right now.


Using entries

You got the new entry in the password list now. What can you actually do with it now? Right-click onto the entry.

You have several options now. You can for example copy the username of the entry to the Windows clipboard. When you've copied it, you can post it into any other program of your choice. The same works for copying passwords.

Alternatively, you can drag&drop fields into other windows. To see an example of how this works, see this page: Drag&Dropping Fields.

KeePass can open the URL you specified. To do this, just click 'URL(s) - Open URL(s)' in the context menu. KeePass will start the default browser and open the specified URL.


Saving the database

It's time to save our database. Click onto the 'Save' toolbar button (looks like a disk; 3rd toolbar button). As you're saving the database the first time, you now have to specify a location where you want the database file to be stored.


More

That's it! You've made the first steps in using KeePass! You can now have a look at the more advanced features of KeePass.

Passwords and Key Files: In the tutorial above we've encrypted the database using a password. But KeePass also supports key files, i.e. you can lock your database using a file (which you can carry around on your USB stick for example). It even supports combining those two methods for maximum security.

TAN Entries: TAN entries are one-time passwords. Many banks are using TANs for better security. KeePass supports TAN entries, by making them expire automatically when using them.

Auto-Type: The auto-typing functionality is a very powerful feature. In the tutorial above you've copied the username and password of an entry to the clipboard. Wouldn't it be nice if KeePass would just type those strings for you into other windows? Wouldn't it be nice if you could define whole sequences of keypresses that KeePass should type for you? That's exactly what the Auto-Typing feature does: it sends simulated keypresses for you to other windows!

URL Field Capabilities: The URL field supports URLs of course. In the tutorial, you've learned that you can enter simple URLs into this field and KeePass will open the browser window for you. But the URL field can do more! It actually supports many different protocols (not just http) and supports executing Windows command lines through the cmd:// virtual protocol. The field also features a powerful substitution engine, replacing codes by other fields (username, password, ...) of this entry.

Command Line Capabilities: You can open .kdb files by passing the filename to the KeePass executable file. But did you know that you can also send the password for the database and key file location over the command line? You can also use the command line to pre-select a key file for you.

Plugins: KeePass features a powerful plugin architecture. If you miss some functionality, have a look at the plugins page to see if there are other people that have already written plugins for this. Many plugins exist to import/export data from/to other file formats.

keepass2-2.25/Docs/Chm/help/base/credits.html0000664000175000017500000002626112273660230020707 0ustar jtaylorjtaylor Acknowledgements - KeePass
Help

Acknowledgements / Credits


Thanks to various people for contributions and/or work.

At this place I want to thank a lot of people very much for their help, source code, suggestions and other contributions (in no particular order).


Info  Donation Acknowledgements

Developing high-quality applications takes much time and resources. Donations make it possible to keep up the current development standard. Therefore, thanks a lot to all who donated to the project.

More information about donations and a list of people who donated can be found here: KeePass Donations.


Info  Source Code Acknowledgements

KeePass uses some classes and libraries written by different people and given away for free. Here I want to thank them for writing these classes and libraries.

Author Class / Library
Szymon Stefanek C++ implementation of the AES/Rijndael encryption algorithm.
Brian Gladman C implementation of the SHA-2 (256/384/512) hashing algorithms.
Brent Corkum MFC class for XP-style menu (BCMenu).
Davide Calabro MFC class for buttons with icons (CButtonST).
Peter Mares MFC class for window side banners (CKCSideBannerWnd).
Chris Maunder MFC class for system tray icons (CSystemTray).
Hans Dietrich MFC class for hyperlinks in dialogs (XHyperLink).
Alvaro Mendez MFC class for validating edit controls (CAMSEdit).
PJ Naughter MFC classes for checking for single instance and version information (CSingleInstance, CVersionInfo).
Lallous Class for sending simulated keystrokes to other applications (CSendKeys).
Bouncy Castle Developers Class for computing SHA-256 hashes (Bouncy Castle).
Mike Krueger, John Reilly Library to handle GZip files (SharpZipLib).

Author Resource
Mark Burnett List of 10000 Top Passwords, which KeePass uses in its password quality estimation algorithm.


Info  Translation Acknowledgements

Thanks a lot to all people who created translations for KeePass (see translations page).


Info  Plugin Acknowledgements

Very many thanks to all people who wrote plugins for KeePass (see plugins page). Without you, KeePass would be a lot less powerful and useful!


Info  Tools Acknowledgements

Thanks to Jordan Russell for creating Inno Setup. This tool is used to create the nice KeePass installation program.


Info  Hosting/Distribution Acknowledgements


Thanks to SourceForge.net for hosting the KeePass downloads / translations / plugins and for providing the project support platform (forums, feature requests / bug trackers, ...) for free.
Thanks to domain)FACTORY for hosting the KeePass website.
Thanks to datensysteme-lenk for hosting the German KeePass support forum in the past.

Info  Suggestions and Forum Support Acknowledgements

Thanks to all the people answering questions of others in the KeePass forums! A product is only as good as its support is, and I alone could never provide such an excellent individual help platform.

Two persons should be mentioned here, because of an extraordinary amount of suggestions (features, bug reports, ...) and helping others in the forums: Paul Tannard and Michael Scheer.


Info  Special Acknowledgements

Thanks to Daniel Turini for suggesting "KeePass" as the name of the project.

An especially big thanks to Bill Rubin. He not only contributed a lot of source code to KeePass, he also had an enormous amount of feature and improvement suggestions, helped people in the KeePass forums, and wrote a KeePass plugin for backing up databases. He's also the reason why many of the sections in the KeePass Help are very precise, helpful, clear and easy to understand. In our countless hours long IM chats, we not only discussed much about the design of KeePass, Bill also told me a lot about C++ and other stuff. Thanks!


Info  Icons Acknowledgements

Thanks a lot to Christopher Bolin for creating the main KeePass icon (see top left on this page) and its variations.

Thanks to David Vignoni for creating the nice 'Nuvola' icon theme. Most of the icons used in KeePass and on its website are icons of this theme. You can find the original images on the website of the author. Usage of the icons is allowed under the terms of the LGPL license (which you can find here: GNU Lesser General Public License), plus an addition. The original distribution notice can be found here: 'Nuvola' Icon Theme License.

keepass2-2.25/Docs/Chm/help/base/pwgenerator.html0000664000175000017500000003410212273660230021600 0ustar jtaylorjtaylor Password Generator - KeePass
Security

Password Generator


Details about the built-in password generator of KeePass.


Help  Generation Based on Character Sets

This password generation method is the recommended way to generate random passwords. Other methods (pattern-based generation, ...) should only be used if passwords must follow special rules or fulfill certain conditions.

Generation based on a character set is very simple. You simply let KeePass know which characters can be used (i.e. upper-case letters, digits, ...) and KeePass will randomly pick characters out of the set.

Defining a Character Set:
The character set can be defined directly in the password generator window. For convenience, KeePass offers adding commonly used ranges of characters to the set. This is done by ticking the appropriate check box. Additionally to these predefined character ranges, you can specify characters manually: all characters that you enter in the 'Also include the following characters' text box will be directly added to the character set.

The characters that you enter in the 'Also include the following characters' text box are included in the character set from which the password generator randomly chooses characters from. This means that these additional characters are allowed to appear in the generated passwords, but they are not forced to. If you want to force that some characters appear in the generated passwords, you have to use the pattern-based generation.

Character Sets are Sets:
In mathematical terms, character sets are sets, not vectors. This means that characters can not be added twice to the set. Either a character is in the set or it is not.

For example, if you enter 'AAAAB' into the additional characters box, this is exactly the same set as 'AB'. 'A' will not be 4 times as likely as 'B'! If you need to follow rules like 'character A is more likely than B', you must use pattern-based generation + permuting password characters.

KeePass will 'optimize' your character set by removing all duplicate characters. If you'd enter the character set 'AAAAB' into the additional characters box, close and reopen the password generator, it'll show the shorter character set 'AB'. Similarly, if you tick the Digits check box and enter '3' into the additional box, the '3' will be ignored because it is already included in the Digits character range.


Help  Generation Based on Patterns

The password generator can create passwords using patterns. A pattern is a string defining the layout of the new password. The following placeholders are supported:

Placeholder Type Character Set
a Lower-Case Alphanumeric abcdefghijklmnopqrstuvwxyz 0123456789
A Mixed-Case Alphanumeric ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789
U Upper-Case Alphanumeric ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789
d Digit 0123456789
h Lower-Case Hex Character 0123456789 abcdef
H Upper-Case Hex Character 0123456789 ABCDEF
l Lower-Case Letter abcdefghijklmnopqrstuvwxyz
L Mixed-Case Letter ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
u Upper-Case Letter ABCDEFGHIJKLMNOPQRSTUVWXYZ
v Lower-Case Vowel aeiou
V Mixed-Case Vowel AEIOU aeiou
Z Upper-Case Vowel AEIOU
c Lower-Case Consonant bcdfghjklmnpqrstvwxyz
C Mixed-Case Consonant BCDFGHJKLMNPQRSTVWXYZ bcdfghjklmnpqrstvwxyz
z Upper-Case Consonant BCDFGHJKLMNPQRSTVWXYZ
p Punctuation ,.;:
b Bracket ()[]{}<>
s Printable 7-Bit Special Character !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
S Printable 7-Bit ASCII A-Z, a-z, 0-9, !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
x High ANSI Range [U+0080, U+00FF] except control and non-printable characters.
\ Escape (Fixed Char) Use following character as is.
{n} Escape (Repeat) Repeat the previous character n times.
[...] Custom Char Set Define a custom character set.

The \ placeholder is special: it's an escape character. The next character that follows the \ is written directly into the generated password. If you want a \ in your password at a specific place, you have to write \\.

Using the {n} code you can define how many times the previous placeholder should occur. The { } operator duplicates placeholders, not generated characters. Examples:
» d{4} is equivalent to dddd,
» dH{4}a is equivalent to dHHHHa and
» Hda{1}dH is equivalent to HdadH.

The [...] notation can be used to define a custom character set, from which the password generator will pick one character randomly. All characters between the '[' and ']' brackets follow the same rules as the placeholders above. Examples:
» [dp] generates exactly 1 random character out of the set digits + punctuation,
» [d\m\@]{5} generates 5 characters out of the set "0123456789m@",
» [u\_][u\_] generates 2 characters out of the set upper case + '_'.

More examples:

ddddd
Generates for example: 41922, 12733, 43960, 07660, 12390, 74680, ...

\H\e\x\:\ HHHHHH
Generates for example: 'Hex: 13567A', 'Hex: A6B99D', 'Hex: 02243C', ...

Common Password Patterns:

Name Pattern
WEP Hex Key - 40 Bit h{10}
WEP Hex Key - 128 Bit h{32}
WEP Hex Key - 256 Bit h{64}
Random MAC Address HH\-HH\-HH\-HH\-HH\-HH


Help  Generating Passwords that Follow Rules

Below are a few examples how the pattern generation feature can be used to generate passwords that follow certain rules.

Important! For all of the following examples you must enable the 'Randomly permute characters of password' option!

Rule Pattern
Must consist of 2 upper case, 2 lower case characters and 2 digits uulldd
Must consist of 9 digits and 1 letter d{9}L
Must consist of 10 alphanumeric characters, where at least 1 is a letter and at least 1 is a digit LdA{8}
Must consist of 10 alphanumeric characters, where at least 2 are upper case and at least are 2 lower case characters uullA{6}
Must consist of 9 characters out of the set "ABCDEF" and an '@' symbol somewhere in it \@[\A\B\C\D\E\F]{9}


Help  Security-Reducing Options

The password generator supports several options like 'Each character must occur at most once', 'Exclude look-alike characters', and a field to explicitly specify characters that should not appear in generated passwords.

These options are reducing the security of generated passwords. You should only enable them if you are forced to follow such rules by the website/application, for which you are generating the password.

The options can be found in the 'Advanced' dialog / tab page.

Tab Control If you enable a security-reducing option, an exclamation mark (!)
is appended to the 'Advanced' tab.

Help  Creating and Using Password Generator Profiles

Password generator options (character set, length, pattern, ...) can be saved as password generator profiles.

Creating/Modifying a Profile:

  1. Open the Password Generator window.
  2. Specify all options of the new profile.
  3. Click the Save As Save as Profile button.
  4. Enter the name of the new profile, or select an existing profile name from the drop-down list to overwrite it. Close the dialog with OK.
  5. If you want to immediately create a password using the new profile, click OK/Accept. Otherwise click Cancel/Close (the profile is not lost; profile management is independent of password generation).

Using a Profile:

To use a profile, simply select it from the drop-down profiles list in the password generator window. All settings of this profile will be restored accordingly.


Help  Configuring Settings of Automatically Generated Passwords for New Entries

When you create a new entry, KeePass will automatically generate a random password for it. The properties of these generated passwords can be configured in the password generator dialog.

To configure, specify the options of your choice and overwrite the '(Automatically generated passwords for new entries)' profile (see section above).

Disabling Automatically Generated Passwords:
To disable automatically generated passwords for new entries, select 'Generate using character set' and specify 0 as password length. Overwrite the appropriate profile (see above).

keepass2-2.25/Docs/Chm/help/base/integration.html0000664000175000017500000000754112273660230021575 0ustar jtaylorjtaylor Integration - KeePass
Help

Integration


How KeePass integrates into your operating system environment.

Info  Global Hot Key to Restore KeePass Window

To quickly switch back from an application to KeePass, you can use the global hot key that restores the KeePass main window.

If you have multiple instances of KeePass running, pressing the global hot key will restore the first instance that has been started.

The global hot key is Ctrl+Alt+K.

The hot key can freely be changed to a different key combination (or disabled) in the 'Options' dialog, tab page 'Integration'.

Info  Limit to Single Instance Option

If you enable the 'Limit to Single Instance' option, at most one KeePass instance can be running at a time. If you try to start a second KeePass instance, it is immediately terminated, and the first instance is brought to the foreground.

KeePass 2.x can open multiple databases in one instance/window (a tab bar appears, which allows you to conveniently switch between the databases).

When multiple databases are opened in one instance and you press the global auto-type hot key, auto-type searches in all opened databases for matching entries. Note that only exactly one KeePass instance can register the global hot key; so when you disable the single instance option and open databases in different instances, only the first instance searches for matching entries when global auto-type is invoked, not the others. keepass2-2.25/Docs/Chm/help/base/secedits.html0000664000175000017500000000530312273660230021047 0ustar jtaylorjtaylor Secure Edit Controls - KeePass
Help

Secure Edit Controls


KeePass supports security-enhanced edit controls.

KeePass was one of the first password managers featuring secure edit controls. The edit controls used in KeePass are resistant to password revealers and password control spies. Additionally, the entered passwords are protected against memory dumping attacks: the passwords aren't even visible in the process memory space of KeePass!

KeePass uses secure edit controls only when the hiding behind asterisks option is turned on! If you show the passwords in plaintext, they won't be protected (secure edit controls are just disabled then, replaced by standard Windows edit controls).

There are no selection limitations. Secure edit controls behave exactly like standard Windows edit controls. keepass2-2.25/Docs/Chm/help/base/keys.html0000664000175000017500000003163712273660230020230 0ustar jtaylorjtaylor Composite Master Key - KeePass
Help

Composite Master Key


This document details how KeePass locks its databases.

KeePass stores your passwords securely in an encrypted file (database). This database is locked with a master password, a key file and/or the current Windows account details. To open a database, all key sources (password, key file, ...) are required. Together, these key sources form the Composite Master Key.

KeePass does not support keys being used alternatively, i.e. it's not possible that you can open your database using a password or a key file. Either use a password, a key file, or both at once (both required), but not interchangeably.


Info  Master Passwords

If you use a master password, you only have to remember one password or passphrase (which should be good!) to open your database. KeePass features protection against brute-force and dictionary attacks on the master password, read the security information page for more about this.

If you forget this master password, all your other passwords in the database are lost, too. There isn't any backdoor or a key which can open all databases. There is no way of recovering your passwords.


Info  Key Files

You don't even have to remember a long, complicated master passphrase. The database can also be locked using a key file. A key file is basically a master password in a file. Key files are typically stronger than master passwords, because the key can be a lot more complicated; however it's also harder to keep them secret.

  • A key file can be used instead of a password, or in addition to a password (and the Windows user account in KeePass 2.x).
  • A key file can be any file you choose; although you should choose one with lots of random data.
  • A key file must not be modified, this will stop you opening the database. If you want to use a different key file, you can change the master key and use a new/different key file.
  • Key files must be backed up or you won't be able to open the database after a hard disk crash/re-build. It's just the same as forgetting the master password. There is no backdoor.

    Do not backup the key file to the same location as the database, use a different directory or disk. Test opening your database on another machine to confirm your backup works. For a detailed discussion on the difference between backing up the key file and the database, see the ABP FAQ.

Location. The point of a key file is that you have something to authenticate with (in contrast to master passwords, where you know something), for example a file on a USB stick. The key file content (i.e. the key data contained within the key file) needs to be kept secret. The point is not to keep the location of the key file secret — selecting a file out of thousands existing on your hard disk basically doesn't increase security at all, because it's very easy for malware/attackers to find out the correct file (for example by observing the last access times of files, the recently used files list of Windows, malware scanner logs, etc.). Trying to keep the key file location secret is security by obscurity, i.e. not really effective.

File Type and Existing Files. KeePass can generate key files for you, however you can also use any other, already existing file (like JPG image, DOC document, etc.).

In order to use an existing file as key file, click the 'Browse' button in the master key creation dialog.

Info  Windows User Account


KeePass can make the database dependent on the current Windows user account. If you enable this option, you can only open the database when you are logged in as the same Windows user when creating the database.

Warning Be very careful with using this option. If your Windows user account gets deleted, you won't be able to open your KeePass database anymore. Also, when using this option at home and your computer breaks (hard disk damaged), it is not enough to just create a new Windows account on the new installation with the same name and password; you need to copy the complete account (i.e. SID, ...). This is not a simple task, so if you don't know how to do this, it is highly recommended that you don't enable this option. Instructions on how to restore a backed up account can be found in a Microsoft TechNet article: How to recover a Vault corrupted by lost DPAPI keys.

You can change the password of the Windows user account freely; this does not affect the KeePass database. Note that changing the password (e.g. a user using the Control Panel or pressing Ctrl+Alt+Del and selecting 'Change Password') and resetting it to a new one (e.g. an administrator using a NET USER <User> <NewPassword> command) are two different things. After changing your password, you can still open your KeePass database. When resetting the password to a new one, access usually is not possible anymore (because the user's DPAPI keys are lost), but there are exceptions (for example when the user is in a domain, Windows can retrieve the user's DPAPI keys from a domain controller, or a home user can use a previously created Password Reset Disk). Details can be found in the MSDN article Windows Data Protection and in the support article How to troubleshoot the Data Protection API (DPAPI).

If you decide to use this option, it is highly recommended not to rely on it exclusively, but to additionally use one of the other two options (password or key file).

Protection using user accounts is unsupported on Windows 98 / ME.

Info  For Administrators: Specifying Minimum Properties of Master Keys

Administrators can specify a minimum length and/or the minimum estimated quality that master passwords must have in order to be accepted. You can tell KeePass to check these two minimum requirements by adding/editing appropriate definitions in the INI/XML configuration file.

The contents of the MinimumLength node in Security/MasterPassword can contain the minimum master password length in characters. For example, by setting the contents to 10, KeePass will only accept master passwords that have at least 10 characters.

The contents of the MinimumQuality node in Security/MasterPassword can contain the minimum estimated quality in bits that master passwords must have. For example, by setting the contents to 32, only master passwords with an estimated quality of at least 32 bits will be accepted.

By specifying KeyCreationFlags and/or KeyPromptFlags (in the UI node), you can force states (enabled, disabled, checked, unchecked) of key source controls in the master key creation and prompt dialogs. These values can be bitwise combinations of one or more of the following flags:

Flag (Hex)Flag (Dec) Description
0x00 Don't force any states (default).
0x11 Enable password.
0x22 Enable key file.
0x44 Enable user account.
0x88 Enable 'hide password' button.
0x100256 Disable password.
0x200512 Disable key file.
0x4001024 Disable user account.
0x8002048 Disable 'hide password' button.
0x1000065536 Check password.
0x20000131072 Check key file.
0x40000262144 Check user account.
0x80000524288 Check 'hide password' option/button.
0x100000016777216 Uncheck password.
0x200000033554432 Uncheck key file.
0x400000067108864 Uncheck user account.
0x8000000134217728 Uncheck 'hide password' option/button.

The values of KeyCreationFlags and KeyPromptFlags must be specified in decimal notation.

For example, if you want to enforce using the user account option, you could check and disable the control (such that the user can't uncheck it anymore) by specifying 263168 as value (0x40000 + 0x400 = 0x40400 = 263168). keepass2-2.25/Docs/Chm/help/base/faq_tech.html0000664000175000017500000007142012273660230021021 0ustar jtaylorjtaylor Technical FAQ - KeePass
Help

Technical FAQ


Frequently Asked Questions about the usage of KeePass.

Configuration: Installation / Integration: Security: Usage:

Info  I've saved my options, but when I reopen KeePass I get the old options. What's wrong?

KeePass supports two different locations for storing configuration information: the global configuration file in the KeePass directory and a local, user-dependent one in the user's private configuration folder. Most likely you do not have write access to your global configuration file.

For more details, see Cascading Configuration.


Info  Why doesn't KeePass 2.x run on my computer?

Symptoms: When trying to run KeePass 2.x on Windows ≤ XP, an error message like the following is displayed:
"A required .DLL file, MSCOREE.DLL, was not found" or
"The application failed to initialize properly (0xc0000135)".

Cause: KeePass 2.x requires Microsoft .NET Framework ≥ 2.0.

Resolution: Install Microsoft .NET Framework 2.0 or higher. It is available as a free download from the Microsoft website: Microsoft .NET Framework download. Alternatively, you can install it through Windows Update (the framework is an optional component).

KeePass 1.x does not require this framework.


Info  Why does KeePass 2.x crash when starting it from a network drive/share?

Symptoms: When trying to run KeePass 2.x from a network drive/share, you get an error message like the following:
"Application has generated an exception that could not be handled" or
"KeePass has encountered a problem and needs to close".

Cause: The strict default security policy by the Microsoft .NET Framework disallows running .NET applications from a network drive/share.

Recommended resolution: Copy/install KeePass 2.x onto a local hard disk, and run the copy.

Alternative, not recommended resolution: Configure the security policy to allow running .NET applications from network drives/shares. Ask your administrator to do this (administrative rights are required). If you have administrative rights and want to do it yourself, you can use the Code Access Security Policy Tool (Caspol.exe) that ships with the .NET framework (helpful instructions can be found here and here).


Info  Why does KeePass 2.x show a FIPS compliance error at startup?

Symptoms: When trying to run KeePass 2.x, you get an error message like the following:
"This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.".

Cause: KeePass uses the AES/Rijndael encryption and SHA-256 hashing algorithms, for which the Microsoft .NET Framework provides implementations. These implementations might not be FIPS compliant. If the local security policy of the system enforces the usage of FIPS compliant implementations, KeePass cannot run and shows an error message.

Resolution: Configure the local security policy of the system to allow FIPS non-compliant algorithm implementations. To do this, go to Control Panel -> Administrative Tools -> Local Security Policy, open Local Policies -> Security Options, and change the option 'System cryptography: Use FIPS compliant algorithms for encryption, hashing, and signing' to 'Disabled'.

Alternative resolution: Download and run the following Windows registry file: FipsDisable.reg. By running this file (i.e. importing the modifications in this file into the registry), FIPS compliance enforcement is disabled.

Note: Currently only weaker cryptographic algorithms in the Microsoft .NET Framework are FIPS compliant. As security is the top priority for the KeePass project, an option to use these weaker FIPS compliant algorithms will not be added. Future .NET frameworks might have FIPS compliant implementations of the algorithms that KeePass requires.


Info  Why doesn't the CHM help file work?

Symptoms: When trying to open the KeePass CHM help file from a remote computer or shared network drive, it's not displayed correctly (navigation aborted, ...).

Solution: See Microsoft Security Bulletin MS05-026.


Info  Where can I find more application icons for Windows shortcuts?


Application icons are icons in Windows ICO format. They can be used in Windows shortcuts and/or as file association icons. The KeePass executable contains various application icons which can be used for these purposes.

Additional application icons are available from the "Ext/Icons" directory of the KeePass source code download. Most of them, shown at right, are slight variations of the main KeePass icon.

Even more, contributed icons (by users) can be found on the plugins page.

If you have multiple KeePass databases, you can use differently colored KeePass application icons in order to distinguish them.

These icons are not included in the binary distribution because this would make the application file too large.

Application Icons

Info  How can I add more client icons for password entries?


Client icons are the icons used for password entries and groups within KeePass. Each entry can be assigned its own icon.

You can import your own icons into KeePass databases. For this, click the 'Add...' button in the icon picker dialog.

Images are automatically resized to 16x16, if they are larger or smaller. Supported formats are BMP, EMF, GIF, ICO, JPEG, PNG, TIFF and WMF.
Application Icons

Info  Does KeePass support a mini mode?


A mini mode is not supported yet.

Info  Why doesn't KeePass lock after Auto-Type?


This does not apply to KeePass 2.x.

Info  Why doesn't Auto-Type work correctly on Polish systems?

On Polish systems, the default auto-type hot key Ctrl+Alt+A conflicts with a system command and is frequently used in typing. Therefore, auto-type is often executed accidentally.

The global auto-type hot key can be changed to a different key combination in the KeePass options (see Auto-Type for details).


Info  Why doesn't printing work in KeePass 1.x?

Symptoms: When trying to print a password list in KeePass 1.x, nothing happens after clicking OK in the 'Print Options' dialog.

Cause: KeePass 1.x uses the application associated with .html files to print the password list. If this application doesn't support the "print" shell verb (like Mozilla Firefox), nothing happens.

Resolution: Associate .html files with a different application that supports the "print" shell verb (like Internet Explorer).

Alternative Resolution / Workaround: Click 'File' -> 'Print Preview' in KeePass 1.x and manually print the document in the application that just opened the file.


Info  Why does KeePass try to connect to the Internet?

KeePass has an option to automatically check for updates on each program start. In order to check for updates, KeePass downloads a small version information file and compares the available version with the installed version. No personal information is sent to the KeePass web server.

Automatic update checks are performed unintrusively in the background. A notification is only displayed when an update is available. Updates are not downloaded or installed automatically.

The option is disabled by default. You can enable/disable it in 'Tools' -> 'Options' -> tab 'Advanced'.


Info  Is Auto-Type keylogger-safe?

Is the Auto-Type feature resistant to keyloggers?

By default: no. The Auto-Type method in KeePass 2.x works the same as the one in 1.x and consequently is not keylogger-safe.

However, KeePass features an alternative method called Two-Channel Auto-Type Obfuscation (TCATO), which renders keyloggers completely useless. This is an opt-in feature (because it doesn't work with all windows) and must be enabled for entries manually. See the TCATO documentation for details.


Key  Can Auto-Type locate child controls?

No. Auto-Type only checks whether the title of the currently active top level window matches.

Browsers like Mozilla Firefox completely draw the window (all controls) themselves, without using standard Windows controls. Consequently it is technically impossible for KeePass to check whether an URL matches (methods like creating a screenshot and using optical character recognition are not reliable and secure). Also, it's impossible to check which child control currently has the focus. These problems can only be avoided by using browser integration plugins, i.e. not using auto-type at all.

The user must make sure that the focus is placed in the correct control before starting auto-type.


Info  Could you add the ... encryption algorithm to KeePass?


Only Rijndael (AES) is supported, but KeePass supports additional algorithms through encryption plugins. You can find encryption plugins on the plugins page.

If you'd like to implement an algorithm, have a look at the ArcFourCipher sample plugin.

Info  Why doesn't KeePass lock when Windows locks and a KeePass sub-dialog is open?

KeePass automatically tries to lock its workspace when Windows is locked, with one exception: when a KeePass sub-dialog (like the 'Edit Entry' window) is currently opened, the workspace is not locked.

To understand why this behavior makes sense, it is first important to know what happens when the workspace is locked. When locking, KeePass completely closes the database and only remembers several view parameters, like the last selected group, the top visible entry, selected entries, etc. From a security point of view, this achieves best security possible: breaking a locked workspace is equal to breaking the database itself.

Now back to the original question. Let's assume an edit dialog is open and the workstation locks. What should KeePass do now? Obviously, it's too late to ask the user what to do (the workstation is locked already and no window can't be displayed), consequently KeePass must make an automatic decision. There are several possibilities:

  • Do not save the database and lock.
    In this case, all unsaved data of the database would be lost. This not only applies to the data entered in the current dialog, but to all other entries that have been modified previously.
  • Save the database and lock.
    In this case, possibly unwanted changes are saved. Often you open files, try something, having in mind that you can just close the file without saving the changes. KeePass has an option 'Automatically save database when KeePass closes or the workspace is locked'. If this option is enabled and no sub-dialog is open, it's clear what to do: try to save the database and if successful: lock the workspace. But what to do with the unsaved changes in the sub-dialog? Should it be saved automatically, taking away the possibility of pressing the 'Cancel' button?
  • Save to a temporary location and lock.
    While this sounds the best alternative at first glance, there are several problems with it, too. First of all, saving to a temporary location could fail (for example there could be too few disk space or some other program like virus scanner could have blocked it). Secondly, saving to a temporary location isn't uncritical from a security point of view. When having to choose such a location, mostly the user's temporary directory on the hard disk is chosen (because it likely has enough free space, required rights for access, etc.). Therefore, KeePass databases could be leaked and accumulated there. It's not clear what should happen if the computer is shutdown or crashes while being locked. When the database is opened the next time, should it use the database stored in the temporary directory instead? What should happen if the 'real' database has been modified in the meanwhile (quite a realistic situation if you're carrying your database on an USB stick)?

Obviously, none of these alternatives is satisfactory. Therefore, KeePass implements the following simple and easy to understand behavior:

When Windows is locked and a KeePass sub-dialog is opened, the KeePass workspace is not locked.

This simple concept avoids all the problems above. The user is responsible for the state of the program.

Security consequence: the database is left open when Windows locks. Normally, you are the only one who can log back in to Windows. When someone else logs in (like administrator), he can't use your programs anyway. By default, KeePass keeps in-memory passwords encrypted, therefore it does not matter if Windows caches the process to disk at some time. So, your passwords are pretty safe anyway.

Note. On Windows ≤ XP, the 'Terminal Services' Windows service should be enabled. If this service is disabled, locking KeePass when Windows locks might not work. This service isn't required on newer operating systems.


Info  Printing creates a temporary file. Will it be erased securely?

KeePass creates a temporary HTML file when printing password lists and showing print previews. This file is securely erased (i.e. overwritten multiple times before being removed from the file system tree) when closing the database.

You must wait for the file being printed completely before closing KeePass (and close the print preview before closing KeePass), otherwise it could happen that the printing application blocks KeePass from deleting the file.

There is no way around the temporary file in the current printing system. If you want to write a plugin that directly sends the data to the printer, you can find a plugin development tutorial here: KeePass 2.x Plugin Development.


Info  Why the estimated quality of a password suddenly drops?

For estimating the quality/strength of a password, KeePass not only uses statistical methods (like checking which character ranges are used, repeating characters and differences), it also has a built-in list of common passwords and checks for patterns. When completing a common password or a repetition, the estimated quality can drop.

Details can be found on the Password Quality Estimation help page.


Info  How to store and work with large amounts of (formatted) text?


KeePass has a built-in editor that allows working conveniently with large amounts of (formatted) texts.

To add a large text to an entry, import the file as attachment (or click 'Attach' -> 'Create Empty Attachment'). The built-in editor supports *.TXT (simple text) and *.RTF (formatted text) files.

In order to edit an attachment, right-click onto the entry in the main window, point on 'Attachments' and click 'Edit YourFile.*'. Alternatively, if the text file is the only attachment, you can even open it by just double-clicking onto it in the main window (enable showing the attachment column in 'View' -> 'Show Columns' -> 'Attachments'). Alternatively, it's also possible to click the name of the attachment in the entry details view in the main window.

For TXT files, the built-in editor supports standard operations like cut, copy, paste, undo, word wrap, etc. For RTF files, additionally standard formatting commands are available: choosing the font, font size, bold, italic, underline, strikeout, text and background colors, align left / center / right, etc.
Editor screenshot


Info  Can an e-mail address field be added?

A few times it has been requested that a standard entry field for e-mail addresses is added (on the main tab page in the entry editing dialog). The short answer: an e-mail address field will not be added due to usability reasons. Now the long answer.

First of all, let's assume that most of the entries stored in KeePass contain information for logging in to websites. When you register an account for a website, you often have to specify a user name as well as an e-mail address. When you regularly log in later, you usually only need to provide either user name + password or e-mail + password (never user name + e-mail + password). Here the first part (which is either user name or e-mail) serves as identification: you tell the website who you are. The second part (password) provides authentication: you prove to the website that you're really the one who you claim to be.

There are various methods how KeePass can transfer data to other applications. All of these methods by default assume that the content of the user name field is used for identification. For example, the default auto-type sequence of an entry is {USERNAME}{TAB}{PASSWORD}{ENTER}, the default KeeForm configuration uses the user name, etc. Now on the one hand some websites require an e-mail address instead of a user name. On the other hand we want the default data transfer configuration to work for most websites (such that the work that the user has to put into the configuration is kept minimal and only needed for websites using special login forms).

The solution is simple: instead of interpreting the 'User Name' field strictly as a field containing a user name, users should rather interpret it as a field in which the data required for identification is stored. This data can consist of a user name, an e-mail address or something else (e.g. an account number for an online banking website). By handling it like this, the default data transfer configuration will work for most websites, i.e. zero amount of work needs to be put into the configuration. If you had to provide both a user name and an e-mail address at registration time, the other information (which isn't required on a regular basis) can be stored e.g. in the notes field or a custom string field of the KeePass entry.

Now assume a separate e-mail field would be added. When users store both a user name and an e-mail address, KeePass cannot know which of the two is required for identification. So, in order to setup data transfer for the entry, users would be forced to choose which of the two fields should be used.

So, adding an e-mail field would be a step back in usability, because it forces users to put additional time into data transfer configuration. The current system ('User Name' containing identification information, without a separate e-mail field) doesn't require this, and thus is the better solution.

For users that are willing to manually configure the data transfer for each entry, there are multiple ways to get a separate e-mail address field. After switching to the 'Advanced' tab in the entry editing dialog, an e-mail address field can be added as custom string. If the field should appear on the main tab page of the dialog, the KPEntryTemplates plugin can be used.

keepass2-2.25/Docs/Chm/help/base/configuration.html0000664000175000017500000002547012273660230022122 0ustar jtaylorjtaylor Configuration - KeePass
Configuration

Configuration


Details about how and where KeePass stores its configuration.

KeePass supports multiple locations for storing configuration information: the global configuration file in the KeePass application directory, a local user-dependent one in the user's private configuration folder, and an enforced configuration file in the KeePass application directory. The first one is called global, because everyone using this KeePass installation will write to the same configuration file (and possibly overwriting settings of other users). The second one is called local, because changes made to this configuration file only affect the current user.

Configuration files are stored in XML format.

ConfigurationLocationTypical File Path
Global Application Directory C:\Program Files (x86)\KeePass Password Safe 2\KeePass.config.xml
Global (Virtualized) Windows Vista/7/8 Virtual Store C:\Users\User Name\AppData\Local\VirtualStore\Program Files (x86)\KeePass Password Safe 2\KeePass.config.xml
Local User Application Data C:\Users\User Name\AppData\Roaming\KeePass\KeePass.config.xml
Enforced Application Directory C:\Program Files (x86)\KeePass Password Safe 2\KeePass.config.enforced.xml

On 32-bit systems, the name of the program files folder is 'Program Files' instead of 'Program Files (x86)'.


Text  Installation by Administrator, Usage by User

If you use the KeePass installer and install the program with administrator rights, the program directory will be write-protected when working as a normal/limited user. KeePass will use local configuration files, i.e. save and load the configuration from a file in your user directory.

Multiple users can use the locally installed KeePass. Configuration settings will not be shared and can be configured individually by each user.


Text  Portable Version

If you downloaded the portable version of KeePass (ZIP package), KeePass will try to store its configuration in the application directory. No configuration settings will be stored in the user directory (if the global configuration file is writable).


Text  Create Portable Version of Installed KeePass

If you are currently using a locally installed version of KeePass (installed by the KeePass installer) and want to create a portable version of it, first copy all files of KeePass to the portable device. Then get the configuration file from your user directory (application data, see above) and copy it over the configuration file on the portable device.


Text  For Network Administrators: Enforced Configuration

KeePass can be forced to load specific configuration settings. Enforced configuration settings are loaded from KeePass.enforced.ini (KeePass 1.x) and KeePass.config.enforced.xml (KeePass 2.x) files in the application directory (where KeePass.exe is stored).

Configuration items that are not present in the enforced configuration file are loaded normally from global/local configuration files.

Example (2.x). The following KeePass.config.enforced.xml file enforces the values/states of the settings 'Clipboard auto-clear time (seconds)', 'Lock workspace when minimizing main window' and 'Lock workspace when locking the computer or switching the user'. All other settings can be configured by the user.
<?xml version="1.0" encoding="utf-8"?>
<Configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<Security>
		<WorkspaceLocking>
			<LockOnWindowMinimize>true</LockOnWindowMinimize>
			<LockOnSessionSwitch>true</LockOnSessionSwitch>
		</WorkspaceLocking>
		<ClipboardClearAfterSeconds>20</ClipboardClearAfterSeconds>
	</Security>
</Configuration>
Enforced Options

UI disabled. KeePass 2.x disables most user interface items that are enforced. This can be seen in the screenshot for the example above: the enforced settings are drawn using gray text and clicking on them has no effect.

Security. Users must not have write access to the enforced configuration file (otherwise they could modify it, e.g. using a text editor).

Furthermore, this method only is effective as long as your users run the KeePass installation on the network drive. If they copy KeePass to their hard drives and run it from there, the options you set are not enforced (the local KeePass installation doesn't know anything of the enforced configuration file on the network drive in this case).

All data nodes (leaf nodes) are optional, however preceding non-leaf nodes with the same tag name in parent nodes of data leafs that you want to enforce are mandatory. For example, to enforce hiding user names and passwords using asterisks by default, the enforced configuration file would look like the following:
<?xml version="1.0" encoding="utf-8"?>
<Configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<MainWindow>
		<EntryListColumns>
			<Column />
			<Column>
				<Name>UserName</Name>
				<HideWithAsterisks>true</HideWithAsterisks>
			</Column>
			<Column>
				<Name>Password</Name>
				<HideWithAsterisks>true</HideWithAsterisks>
			</Column>
		</EntryListColumns>
	</MainWindow>
</Configuration>
In this example, the empty <Column /> non-leaf node (representing the title field) has the same tag name as the following sibling nodes ("Column"), and therefore is required.

Text  Technical Details

This section explains in detail how loading and saving the configuration works.

When KeePass starts up and finds both global and local configuration files, it must decide the order in which KeePass tries to get the configuration items. This is controlled by the (Kee)PreferUserConfiguration flag in the global configuration file. If it is not present, it defaults to false.

The flag is set to true in the global configuration file of the KeePass installer package. The portable ZIP package does not contain a configuration file, consequently the flag defaults to false.

Loading:
  • Try to get the configuration item from the enforced configuration file. If found, use this one.
  • If the PreferUserConfiguration flag is true, use the item from the local configuration file, otherwise use the one of the global one. If the global one doesn't exist or doesn't contain this item, use the default value.
Saving:
  • If the PreferUserConfiguration flag is true, try to store all configuration items into the local configuration file. If this fails, try to store them into the global configuration file. If this fails, report error.
  • If the PreferUserConfiguration flag is false, try to store all items into the global configuration file. If this fails try to store them into the local configuration file. If this fails, report error.
keepass2-2.25/Docs/Chm/help/base/multiuser.html0000664000175000017500000001450612273660230021302 0ustar jtaylorjtaylor Multi-User - KeePass
Help

Multi-User


Details about multi-user features of KeePass.

People  General Information about Shared Databases

Both KeePass 1.x and 2.x allow multiple users working with one database, which is typically stored on a shared network drive or a file server.

All users use the same master password and/or key file to open the database. There are no per-group or per-entry access control lists (ACLs).

In order to restrict write access to the database file (i.e. only a select set of users may change the stored data), use file system access rights.


People  KeePass 1.x: Office-Style Locking


With KeePass 1.x, a database can be stored on a shared network drive and used by multiple users. When a user tries to open a database that is already opened by someone else, a prompt asks whether to open the database in read-only or normal mode (see image on the right).

By opening a database in normal mode, the current user takes ownership of the file (i.e. subsequent opening attempts will show the current user as owner).

KeePass 1.x does not provide synchronization, i.e. by saving the database you are saving your current data to disk. If another user has changed an entry in the meanwhile (i.e. since you loaded the database), these changes are overwritten.
KeePass 1.x Read-Only Prompt

If you want to use KeePass 1.x with a database on a shared network drive, it is recommended to let an administrator write to the database and let users only read it (ensure this using file system access rights). By using the -readonly command line switch, KeePass will automatically open a given database in read-only mode (i.e. not show the mode prompt). Users would open the database using a shortcut that contains this command line switch.

If there is no central administrator managing the database, users need to be careful to not overwrite each others changes.


People  KeePass 2.x: Synchronize or Overwrite


With KeePass 2.x, a database can be stored on a shared network drive and used by multiple users. When attempting to save, KeePass first checks whether the file on disk has been modified since it was loaded. If yes, KeePass asks whether to synchronize or overwrite the file (see image on the right).

By synchronizing, changes made by other users (file on disk) and changes made by the current user are merged. After the synchronization process has finished, the current user also sees the changes made by others (i.e. the data in the current KeePass instance is up-to-date).

If there is a conflict (multiple users edited the same entry), KeePass uses the latest version of the entry based on the last modification time.
KeePass 2.x Synchronize Prompt

Note: the synchronize prompt is only triggered by the 'Save' command, not by the 'Save As' command. When executing the 'Save As' command and manually selecting a file, this file will always be overwritten.

keepass2-2.25/Docs/Chm/help/base/repair.html0000664000175000017500000001001012273660230020515 0ustar jtaylorjtaylor Repairing Databases - KeePass
Help

Repairing Databases


KeePass can repair corrupted databases in some cases.

KeePass has quite some features to avoid database file corruption (transacted database writing, device buffer flushing, ...). However, data corruption can still be caused by other programs, the system or broken storage devices (note that KeePass by default is verifying the integrity of database files immediately after writing them, i.e. at this point of time, KeePass guarantees file integrity; however, KeePass of course can't do anything when the data becomes corrupted/unreadable at a later point of time).

In these cases, the database repair functionality might help you. Here, KeePass tries to read as much data as possible from the corrupted file.

Warning In repair mode, the integrity of the data is not checked (in order to rescue as much data as possible). When no integrity checks are performed, corrupted/malicious data might be incorporated into the database. Thus the repair functionality should only be used when there really is no other solution. If you use it, afterwards you should thoroughly check your whole database for corrupted/malicious data.

In order to use the repair functionality in KeePass 2.x, first create a new database file. Then, go 'File' -> 'Import' and import the corrupted database file, using 'KeePass KDBX (2.x) (Repair Mode)' as format.

Anyway, if you've lost the master key for the database, the repair functionality cannot help you. Also, if the header of the database (first few bytes) is corrupted, you're out of luck too: the repair functionality won't be able to restore any entries (because the header contains information required to decrypt the database).

The repair functionality should be seen as last hope. Regularly making backups of your databases is much better and has to be preferred. Backups have no cryptographic security implications. There are plugins that automate the backup process, see the KeePass plugins page.

keepass2-2.25/Docs/Chm/help/base/placeholders.html0000664000175000017500000005307312273660230021720 0ustar jtaylorjtaylor Placeholders - KeePass
Placeholder Icon

Placeholders


KeePass supports various placeholders.

In many places in KeePass (auto-type, URL field, triggers, ...), placeholders can be used.

Placeholders are case-insensitive.


Placeholder  Entry Field Placeholders


PlaceholderField
{TITLE}Title
{USERNAME}User name
{URL}URL
{PASSWORD}Password
{NOTES}Notes

Custom strings can be referenced using {S:Name}. For example, if you have a custom string named "eMail", you can use the placeholder {S:eMail}.

PlaceholderIs Replaced By
{URL:RMVSCM}Entry URL without scheme name.
{URL:SCM}Scheme name of the entry URL.
{URL:HOST}Host component of the entry URL.
{URL:PORT}Port number of the entry URL.
{URL:PATH}Path component of the entry URL.
{URL:QUERY}Query information of the entry URL.


Placeholder  Entry Field References

Fields of other entries can be inserted using Field References.


Placeholder  Paths and Date/Time Placeholders


PlaceholderIs Replaced By
{INTERNETEXPLORER}Path of Internet Explorer, if installed.
{FIREFOX}Path of Mozilla Firefox, if installed.
{OPERA}Path of Opera, if installed.
{GOOGLECHROME}Path of Google Chrome (or Chromium on Unix-like systems), if installed.
{SAFARI}Path of Safari, if installed.

PlaceholderIs Replaced By
{APPDIR}KeePass application directory path.

PlaceholderIs Replaced By
{GROUP}Name of the entry's parent group.
{GROUPPATH}Full group path of the entry.
{DB_PATH}Full path of the current database.
{DB_DIR}Directory of the current database.
{DB_NAME}File name (including extension) of the current database.
{DB_BASENAME}File name (excluding extension) of the current database.
{DB_EXT}File name extension of the current database.
{ENV_DIRSEP}Directory separator ('\' on Windows, '/' on Unix).
{ENV_PROGRAMFILES_X86}This is %ProgramFiles(x86)%, if it exists, otherwise %ProgramFiles%.

PlaceholderIs Replaced By
{DT_SIMPLE}Current local date/time as a simple, sortable string. For example, for 2012-07-25 17:05:34 the value is 20120725170534.
{DT_YEAR}Year component of the current local date/time.
{DT_MONTH}Month component of the current local date/time.
{DT_DAY}Day component of the current local date/time.
{DT_HOUR}Hour component of the current local date/time.
{DT_MINUTE}Minute component of the current local date/time.
{DT_SECOND}Seconds component of the current local date/time.
{DT_UTC_SIMPLE}Current UTC date/time as a simple, sortable string.
{DT_UTC_YEAR}Year component of the current UTC date/time.
{DT_UTC_MONTH}Month component of the current UTC date/time.
{DT_UTC_DAY}Day component of the current UTC date/time.
{DT_UTC_HOUR}Hour component of the current UTC date/time.
{DT_UTC_MINUTE}Minute component of the current UTC date/time.
{DT_UTC_SECOND}Seconds component of the current UTC date/time.


Placeholder  Environment Variables

System environment variables are supported. The name of the variable must be enclosed in '%' characters. For example %TEMP% is replaced by the user's temporary path.


Text  Text Transformations


PlaceholderAction
{T-REPLACE-RX:/Text/Search/Replace/} Searches the regular expression Search in Text and replaces all matches by Replace. See below.
{T-CONV:/Text/Type/} Convert Text to Type. See below.


{T-REPLACE-RX:/Text/Search/Replace/} – Replace Using Regular Expression:
This placeholder searches the regular expression Search in Text and replaces all matches by Replace.

All parameters are Spr-compiled, i.e. placeholders can be used within them.

The first character after the first ':' specifies the separator character. Any character except '}' can be used as separator character. It must not appear within the parameters. For example, {T-REPLACE-RX:/A/B/C/} and {T-REPLACE-RX:!A!B!C!} are equivalent. The last separator character (before the '}') is required.

Usage example. Let the user name field contain the e-mail address 'myname@myprovider.net' and the URL field '{T-REPLACE-RX:!{USERNAME}!.*@(.*)!http://$1!}'. When running the URL field, KeePass opens 'http://myprovider.net'.

{T-CONV:/Text/Type/} – Convert:
This placeholder converts Text to Type.

All parameters are Spr-compiled, i.e. placeholders can be used within them.

Supported types are:
  • Upper or U:
    Upper-case.
  • Lower or L:
    Lower-case.
  • Base64:
    The Base64 encoding of the UTF-8 representation of the text.
  • Hex:
    The Hex encoding of the UTF-8 representation of the text.
Usage example. Let the user name field contain 'Bob' and the URL field 'http://myprovider.net/?user={T-CONV:/{USERNAME}/L/}'. When running the URL field, KeePass opens 'http://myprovider.net/?user=bob'.

Placeholder  Other Placeholders


PlaceholderAction
{PICKCHARS}
{PICKCHARS:Fld:Opt}
Shows a dialog to pick certain characters from an entry string. See below.
{NEWPASSWORD}Generates a new password. See below.
{PASSWORD_ENC}Password in encrypted form. See below.
{HMACOTP}Generates a one-time password. See below.
{C:Comment}Comment; is removed.


{PICKCHARS} – Picking Characters:
Character Picking Dialog The {PICKCHARS} placeholder shows a dialog, in which you can pick characters of an entry string (like the password) at certain positions.

{PICKCHARS} without any parameters lets you pick an arbitrary amount of characters from the password of the entry. A different entry string can be specified by appending a ':' and the name of the field; e.g. {PICKCHARS:UserName}. The names of the standard fields are Title, UserName (without a space), Password, URL and Notes. A custom entry string can be referenced by its name (without an S: prefix).

Additionally, the placeholder supports various (optional!) options. Options are appended after the field name, separated by a ':'. If you want to specify multiple options, separate them by a comma ','. Options are key-value pairs, separated by a '='. The following options are supported:
  • ID: Specifies an alphanumeric ID for the placeholder (see below).
  • C or Count: Specifies the number of characters to pick from the string. When enough characters have been picked, the dialog closes automatically (i.e. you don't need to manually click [OK] anymore).
  • Hide: If set to False, the picked characters in the dialog are shown as plain text by default, i.e. not hidden by asterisks. By default, KeePass uses the hiding setting of passwords in the main window.
  • Conv: Specifies how to convert the picked characters. When this parameter is omitted, no conversion is performed, i.e. the selected characters are auto-typed directly. The option supports the following values:
    • D: Convert the picked characters to down arrow keypresses; e.g. '2', 'c' and 'C' are converted to 2 down arrow keypresses.

      A fixed number of down arrow keypresses can be added by specifying them using the Conv-Offset option. For example, if you specify Conv=D, Conv-Offset=1, then '2', 'c' and 'C' are converted to 3 down arrow keypresses.

      By using the Conv-Fmt option, you can specify the layout of comboboxes. By default, KeePass assumes a combobox containing values from 0 to 9 or from A to Z. If the combobox contains values 0-9A-Z (i.e. first all ten digits, immediately followed by all characters from A to Z), specify Conv=D, Conv-Fmt=0A. Similarly, if it contains values A-Z0-9, specify Conv=D, Conv-Fmt=A0. If digits start with 1 instead of 0 (i.e. the 0 appears after the 9), use 1A and A1 instead of 0A and A0.
If you want to show the character picking dialog multiple times within one sequence, assign different IDs to the placeholders. If an ID is specified multiple times (or no ID is specified and the placeholders are the same), KeePass shows the character picking dialog once and reuses the picked characters in all following placeholders with the same ID.

Usage examples:

{USERNAME}{TAB}{PICKCHARS:Password:C=5}{ENTER}
First a dialog is shown in which the user can pick exactly 5 characters from the entry password. Afterwards KeePass types the user name into the target window, presses Tab, types the 5 picked characters and presses Enter.

ComboBox Form {S:Memorable}{TAB}{PICKCHARS:Password:ID=1, C=1, Conv=D, Conv-Offset=1}{TAB}{PICKCHARS:Password:ID=2, C=1, Conv=D, Conv-Offset=1}{TAB}{PICKCHARS:Password:ID=3, C=1, Conv=D, Conv-Offset=1}{ENTER}
First the character picking dialog is shown three times and each time the user can pick exactly one character from the entry password. Afterwards the auto-type process starts: KeePass types the contents of a custom entry string named "Memorable" into the target window. The focus is switched to the next control by pressing Tab, and the first previously picked character is converted to down arrow keypresses (with one additional keypress; e.g. a '1' is converted to two down arrow keypresses). This is repeated two more times with the other picked characters, and finally Enter is pressed.

Note this is not equivalent to picking three characters at once. If you'd use {S:Memorable}{TAB}{PICKCHARS:Password:C=3, Conv=D, Conv-Offset=1}, all the down arrow keypresses are sent to the same, currently active control.

In some browsers (e.g. Opera), setting the focus to a combobox can be slow. If you experience auto-type failures, consider slowing down the focus changes, e.g. by adding {DELAY 250} after each {TAB}, or slowing down the whole sequence, e.g. by prepending {DELAY=150}.

{NEWPASSWORD} – Generating New Passwords:
The {NEWPASSWORD} placeholder generates a new password for the current entry, based on the "Automatically generated passwords for new entries" generator profile.

This placeholder is replaced once in an auto-type process, i.e. for a typical 'Old Password'-'New Password'-'Repeat New Password' dialog you can use {PASSWORD}{TAB}{NEWPASSWORD}{TAB}{NEWPASSWORD}{ENTER} as auto-type sequence.

{PASSWORD_ENC} – Encrypting Passwords:
The {PASSWORD_ENC} placeholder is replaced by the password of the current entry in encrypted form. The password is encrypted using credentials of the current Windows user. The encrypted password should not be stored and only works for the current user.

It is intended to be used in conjunction with the -pw-enc command line parameter (see the URL Field Capabilities page for an example how to define an URL to open an additional KeePass database). The placeholder cannot be used to transfer passwords to other applications (except KeePass), because the target applications don't know how to decrypt encrypted passwords generated by {PASSWORD_ENC}.

{HMACOTP} – Generating One-Time Passwords:
The {HMACOTP} placeholder generates a HMAC-based one-time password as specified in RFC 4226. The shared secret is the UTF-8 representation of the value of the 'HmacOtp-Secret' custom entry string field (case-sensitive), and the counter is stored in decimal form in the 'HmacOtp-Counter' field.

Usage example. Create a new entry, set its password to the {HMACOTP} placeholder, switch to the 'Advanced' tab, add a string named HmacOtp-Secret with value 12345678901234567890, and add a string named HmacOtp-Counter with value 0. When you now double-click onto the password cell of the entry in the entry list of the main window, an OTP is copied to the clipboard. When auto-typing, an OTP is sent as password. Each time you perform such an action, KeePass updates the counter value. With the secret key and counter values above, the following OTPs are generated: 755224, 287082, 359152, 969429, 338314, ... (more generated OTPs can be found in the example in RFC 4226). keepass2-2.25/Docs/Chm/help/base/credits_icons_license.html0000664000175000017500000001141012273660230023572 0ustar jtaylorjtaylor Acknowledgements - KeePass
Help

Nuvola Icons License


License of the 'Nuvola' icon theme by David Vignoni.

Usage of the 'Nuvola' icons is allowed under the terms of the LGPL license (which you can find here: GNU Lesser General Public License), plus an addition. Here's the original distribution notice:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This copyright and license notice covers the images in this directory.
Note the license notice contains an add-on.
************************************************************************

TITLE:	NUVOLA ICON THEME for KDE 3.x
AUTHOR:	David Vignoni | ICON KING
SITE:	http://www.icon-king.com
MAILING LIST: http://mail.icon-king.com/mailman/listinfo/nuvola_icon-king.com

Copyright (c)  2003-2004  David Vignoni.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation,
version 2.1 of the License.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library (see the the license.txt file); if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#######**** NOTE THIS ADD-ON ****#######
The GNU Lesser General Public License or LGPL is written for software libraries
in the first place. The LGPL has to be considered valid for this artwork
library too.
Nuvola icon theme for KDE 3.x is a special kind of software library, it is an
artwork library, it's elements can be used in a Graphical User Interface, or
GUI.
Source code, for this library means:
 - raster png image* .
The LGPL in some sections obliges you to make the files carry
notices. With images this is in some cases impossible or hardly usefull.
With this library a notice is placed at a prominent place in the directory
containing the elements. You may follow this practice.
The exception in section 6 of the GNU Lesser General Public License covers
the use of elements of this art library in a GUI.
dave [at] icon-king.com

Date:       15 october 2004
Version:    1.0

DESCRIPTION:

Icon theme for KDE 3.x.
Icons where designed using Adobe Illustrator, and then exported to PNG format.
Icons shadows and minor corrections were done using Adobe Photoshop.
Kiconedit was used to correct some 16x16 and 22x22 icons.

LICENSE

Released under GNU Lesser General Public License (LGPL)
Look at the license.txt file.

CONTACT

David Vignoni
e-mail :        david [at] icon-king.com
ICQ :           117761009
http:           http://www.icon-king.com
keepass2-2.25/Docs/Chm/help/base/tans.html0000664000175000017500000001044412273660230020213 0ustar jtaylorjtaylor TAN Support - KeePass
Help

TAN Support


KeePass supports Transaction Authentication Numbers (TANs).

KeePass supports TANs, i.e. passwords that can be used only once. These special passwords are used by some banks: you need to confirm transactions using such TANs. This provides additional security, as a spy cannot perform transactions, even if he knows the password of your banking account.


Text  Using the TAN Wizard to add TANs

You can use the KeePass TAN Wizard to add several TANs at once to your database. Just open the TAN wizard dialog (menu Tools - TAN Wizard) and enter all your TANs. The formatting doesn't really matter, KeePass just uses all alphanumerical strings, i.e. characters like line breaks, tabs, spaces, dots, etc. are interpreted as separators.

The wizard will then generate several TAN entries from the data you entered into the dialog. Each TAN is a standard KeePass entry. The title of a TAN entry always is set to "<TAN>". This tells KeePass that the entry is a TAN entry. You cannot change the title, user name and URL of a TAN. But you can freely add notes to a TAN entry, if you wish.


Text  Using TANs

When you use the TAN (e.g. execute the "Copy Password" command on it), its expiration date will be set to the current time, which expires the entry. It will get a red X as icon. If you later want to know when you used a specific TAN, you can just have a look at its expiration date.

When copying a TAN to the clipboard, the database is marked as modified. You must save the file in order to remember the usage of a TAN.

If you accidently used a TAN without needing it, you can reset it (i.e. remove the red X and show it as valid TAN again). To do this, open the TAN entry (right-click it and choose 'Edit/View Entry...'). Here, uncheck the 'Expires' checkbox. Click [OK] to close the dialog.

keepass2-2.25/Docs/Chm/help/base/autourl.html0000664000175000017500000002733312273660230020746 0ustar jtaylorjtaylor URL Field Capabilities - KeePass
URL Field

URL Field Capabilities


The URL field supports various special protocols and placeholders.

URL Field Capabibilities: Usage Tips & Tricks:

Text  Standard Capabilities

The URL field can execute any valid URL, for which you have defined a protocol handler. On most systems at least the http://, ftp:// and mailto: protocols are defined. KeePass supports all registered protocols that Internet Explorer supports.

For example, if you globally (i.e. using the Windows Explorer) register PuTTY for ssh:// URLs, KeePass will automatically use PuTTY for ssh:// URLs, too.


Terminal  Executing Command Lines

Instead of an URL, you can also execute command lines using the URL field. To tell KeePass that the line you entered is a command line, prefix it using cmd://. For example if you would like to execute Notepad, your URL could look like this:

cmd://C:\Windows\Notepad.exe C:\Test\MyTestFile.txt

The virtual cmd:// protocol also supports parameters for executable files, in contrast to the file:// protocol. This was the main reason why cmd:// was introduced; with file:// you aren't able to pass any parameters to started applications. Use the cmd:// protocol instead.

The paths for the cmd:// protocol don't need to be encoded. For example, you do not have to replace space characters by %20, as it is normally required for other URLs. KeePass just cuts away the cmd:// virtual protocol prefix and passes the remaining command line to the system.

If the file path contains spaces, you must enclose it in quotes (").

Environment Variables:
System environment variables are supported. The name of the variable must be enclosed in '%' characters. For example %TEMP% is replaced by the user's temporary path.

UNC Paths:
Windows-style UNC paths (starting with \\) are directly supported, i.e. do not need to be prefixed with cmd://.


Text  Placeholders

In the URL field, you can use several placeholders that will get automatically replaced when the URL is executed. For example:

http://www.yoursite.com/default.php?user={USERNAME}&pass={PASSWORD}

For this entry, KeePass will replace {USERNAME} by the data of the username field and {PASSWORD} by the data in the password field when you execute the link.

For a complete list of supported placeholders, see the page Placeholders.

Also note that the special placeholders are supported, too. For example, the {APPDIR} placeholder is replaced by the application directory path of the currently running KeePass instance. It's the absolute path of the directory containing the KeePass executable, without a trailing backslash. If you would like to start a new KeePass instance, you could set the URL to:

cmd://"{APPDIR}\KeePass.exe"

To use different browsers for entries, you can use URLs like the following:
cmd://{INTERNETEXPLORER} "http://www.yoursite.com"
cmd://{FIREFOX} "http://www.yoursite.com"
cmd://{OPERA} "http://www.yoursite.com"
cmd://{GOOGLECHROME} "http://www.yoursite.com"
cmd://{SAFARI} "http://www.yoursite.com"
The browser placeholder will be replaced by the browser's executable path (if the browser is installed).


Text  Changing the URL Handler (URL Override)


The URL field behavior can be overridden individually for each entry using the field 'Override URL' (tab 'Properties' in the entry dialog). This allows you to execute a specific URL, while still using the URL field to (only) store data. When double-clicking the URL field of the entry in the main window, the specified command line (in the URL override field) will be run.

Using a different browser:
If your default browser is Firefox and you want to open a specific site with Internet Explorer, specify the following in the URL override field:

cmd://{INTERNETEXPLORER} "{URL}"

KeePass will open Internet Explorer and pass the data from the URL field as the parameter. This uses a placeholder to find Internet Explorer.

Globally changing the URL behavior:
If you want to change the default URL action for an URL scheme (e.g. http://, https:// or ftp://), you can define an URL scheme override in 'Tools' -> 'Options' -> tab 'Integration' -> 'URL Scheme Overrides'. This for example allows to specify a browser as default for websites (in the dialog you can find several overrides for browsers like Internet Explorer, Mozilla Firefox, Opera and Google Chrome).

URL scheme overrides can also be used to define new protocols. For example, if you want to define a protocol kdbx:// that opens another KeePass database, specify the following as override for the kdbx scheme (on Windows):
cmd://"{APPDIR}\KeePass.exe" "{URL:RMVSCM}" -pw-enc:"{PASSWORD_ENC}"
or on Unix-like systems (Mono):
cmd://mono "{APPDIR}/KeePass.exe" "{URL:RMVSCM}" -pw-enc:"{PASSWORD_ENC}"
If an entry now has an URL looking like kdbx://PathToYourDatabase.kdbx and the master password for this database in the password field, double-clicking the URL of the entry in the main window opens the other database. The -pw-enc command line parameter and the {PASSWORD_ENC} placeholder allow passing the master password of the other database in encrypted form, i.e. process monitors and similar utilities aren't be able to read the master password.



Terminal  Starting RDP/TS Sessions

You can use the URL field of entries and the virtual cmd:// protocol to start remote desktop connections.

For this, enter the following in the URL field of an entry:

cmd://mstsc.exe

When you now double-click the URL field of the entry in the main window, a Windows remote desktop connection is initiated.

MSTSC is the Windows terminal server connection program (remote desktop connection). You can pass a path to an existing RDP file to the program to open it. For example, the following URL opens the specified RDP file:

cmd://mstsc.exe "C:\My Files\Connection.rdp"

MSTSC also supports several command line options:

  • /v:<Server[:Port]>
    Defines the terminal server to connect to.
  • /console
    Connects to the terminal session of the server.
  • /f
    Starts the client in full screen mode.
  • /w:<Width>
    Defines the width of the remote desktop screen.
  • /h:<Height>
    Defines the height of the remote desktop screen.
  • /edit
    Opens the specified RDP file for editing.
  • /migrate
    Migrates old connection files to new RDP files.

Terminal  Executing Built-In Shell Commands

The URL field can be used to start applications/documents and URLs. If you want to execute a built-in shell command, like COPY for example, this however doesn't work directly, because there is no COPY.EXE (in Windows 9x times there actually was one, but on all modern Windows operating systems these commands are built-in to the command line window).

In order to execute built-in shell commands, you need to pass them to the command line interpreter cmd.exe.

For the COPY command you would specify cmd.exe as executable file and /C COPY from to as arguments (where 'from' and 'to' are paths). The /C parameter tells cmd.exe to execute the command line that follows.

In the URL field, your URL would look like the following:
cmd://cmd.exe /C COPY from to
In other locations, like command lines in the trigger system, you can leave out the cmd:// URL prefix.

keepass2-2.25/Docs/Chm/help/base/usingpws.html0000664000175000017500000001066412273660230021131 0ustar jtaylorjtaylor Using Stored Passwords - KeePass
Help

Using Stored Passwords


How to transfer passwords stored in KeePass to other applications.

There are many different methods to copy passwords stored in KeePass to other applications:


Info  Context-Sensitive Entry List

Depending on which field you double-click in the entry list (main window), different actions are performed:

  • Title field: open the entry editing dialog for this entry.
  • User Name field: copy user name to clipboard.
  • URL field: open (in browser) or copy the URL to clipboard (behavior configurable in the options).
  • Password field: copy password to the clipboard.
  • Notes field: notes are copied to the clipboard.
  • Attachment field: [1.x] copy to clipboard, [2.x] open in internal editor / viewer.
  • Other fields (like time and UUID fields): copy the contents of that field to the clipboard.

Info  Drag&Drop

You can drag&drop all fields of KeePass entries into other windows:

Drag&Drop Screenshot


Info  Auto-Type

Auto-Type is a powerful feature that sends simulated keypresses to other applications.

You can find more details about it here: Auto-Type documentation page.


Info  KeeForm and other Plugins

There are a lot of plugins available integrating KeePass directly with other applications. For example, KeeForm (for Internet Explorer und Mozilla Firefox) allows completely automatic filling of webforms.

You can find these integration plugins on the KeePass Plugins page.

keepass2-2.25/Docs/Chm/help/base/disclaimer.html0000664000175000017500000002642112273660230021364 0ustar jtaylorjtaylor Disclaimer
Help

Disclaimer


This disclaimer applies to the KeePass program, website and help pages.


Disclaimer

1. Content

The author reserves the right not to be responsible for the topicality, correctness, completeness or quality of the information provided. Liability claims regarding damage caused by the use of any information provided, including any kind of information which is incomplete or incorrect, will therefore be rejected.

All offers are not-binding and without obligation. Parts of the pages or the complete publication including all offers and information might be extended, changed or partly or completely deleted by the author without separate announcement.

2. Referrals and links

The author is not responsible for any contents linked or referred to from his pages - unless he has full knowledge of illegal contents and would be able to prevent the visitors of his site from viewing those pages. If any damage occurs by the use of information presented there, only the author of the respective pages might be liable, not the one who has linked to these pages. Furthermore the author is not liable for any postings or messages published by users of discussion boards, guestbooks or mailinglists provided on his page.

3. Copyright

The author intended not to use any copyrighted material for the publication or, if not possible, to indicate the copyright of the respective object.

The copyright for any material created by the author is reserved. Any duplication or use of objects such as images, diagrams, sounds or texts in other electronic or printed publications is not permitted without the author's agreement.

4. Privacy policy

If the opportunity for the input of personal or business data (email addresses, name, addresses) is given, the input of these data takes place voluntarily. The use and payment of all offered services are permitted - if and so far technically possible and reasonable - without specification of any personal data or under specification of anonymized data or an alias. The use of published postal addresses, telephone or fax numbers and email addresses for marketing purposes is prohibited, offenders sending unwanted spam messages will be punished.

We use third-party advertising companies (Google) to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by Google, click here.

5. Legal validity of this disclaimer

This disclaimer is to be regarded as part of the internet publication which you were referred from. If sections or individual terms of this statement are not legal or correct, the content or validity of the other parts remain uninfluenced by this fact.



Haftungsausschluss

1. Inhalt des Onlineangebotes

Der Autor übernimmt keinerlei Gewähr für die Aktualität, Korrektheit, Vollständigkeit oder Qualität der bereitgestellten Informationen. Haftungsansprüche gegen den Autor, welche sich auf Schäden materieller oder ideeller Art beziehen, die durch die Nutzung oder Nichtnutzung der dargebotenen Informationen bzw. durch die Nutzung fehlerhafter und unvollständiger Informationen verursacht wurden, sind grundsätzlich ausgeschlossen, sofern seitens des Autors kein nachweislich vorsätzliches oder grob fahrlässiges Verschulden vorliegt.

Alle Angebote sind freibleibend und unverbindlich. Der Autor behält es sich ausdrücklich vor, Teile der Seiten oder das gesamte Angebot ohne gesonderte Ankündigung zu verändern, zu ergänzen, zu löschen oder die Veröffentlichung zeitweise oder endgültig einzustellen.

2. Verweise und Links

Bei direkten oder indirekten Verweisen auf fremde Webseiten ("Hyperlinks"), die außerhalb des Verantwortungsbereiches des Autors liegen, würde eine Haftungsverpflichtung ausschließlich in dem Fall in Kraft treten, in dem der Autor von den Inhalten Kenntnis hat und es ihm technisch möglich und zumutbar wäre, die Nutzung im Falle rechtswidriger Inhalte zu verhindern.

Der Autor erklärt hiermit ausdrücklich, dass zum Zeitpunkt der Linksetzung keine illegalen Inhalte auf den zu verlinkenden Seiten erkennbar waren. Auf die aktuelle und zukünftige Gestaltung, die Inhalte oder die Urheberschaft der verlinkten / verknüpften Seiten hat der Autor keinerlei Einfluss. Deshalb distanziert er sich hiermit ausdrücklich von allen Inhalten aller verlinkten / verknüpften Seiten, die nach der Linksetzung verändert wurden. Diese Feststellung gilt für alle innerhalb des eigenen Internetangebotes gesetzten Links und Verweise sowie für Fremdeinträge in vom Autor eingerichteten Gästebüchern, Diskussionsforen, Linkverzeichnissen, Mailinglisten und in allen anderen Formen von Datenbanken, auf deren Inhalt externe Schreibzugriffe möglich sind. Für illegale, fehlerhafte oder unvollständige Inhalte und insbesondere für Schäden, die aus der Nutzung oder Nichtnutzung solcherart dargebotener Informationen entstehen, haftet allein der Anbieter der Seite, auf welche verwiesen wurde, nicht derjenige, der über Links auf die jeweilige Veröffentlichung lediglich verweist.

3. Urheber- und Kennzeichenrecht

Der Autor ist bestrebt, in allen Publikationen die Urheberrechte der verwendeten Bilder, Grafiken, Tondokumente, Videosequenzen und Texte zu beachten, von ihm selbst erstellte Bilder, Grafiken, Tondokumente, Videosequenzen und Texte zu nutzen oder auf lizenzfreie Grafiken, Tondokumente, Videosequenzen und Texte zurückzugreifen.

Alle innerhalb des Internetangebotes genannten und ggf. durch Dritte geschützten Marken- und Warenzeichen unterliegen uneingeschränkt den Bestimmungen des jeweils gültigen Kennzeichenrechts und den Besitzrechten der jeweiligen eingetragenen Eigentümer. Allein aufgrund der bloßen Nennung ist nicht der Schluss zu ziehen, dass Markenzeichen nicht durch Rechte Dritter geschützt sind!

Das Copyright für veröffentlichte, vom Autor selbst erstellte Objekte bleibt allein beim Autor der Seiten. Eine Vervielfältigung oder Verwendung solcher Grafiken, Tondokumente, Videosequenzen und Texte in anderen elektronischen oder gedruckten Publikationen ist ohne ausdrückliche Zustimmung des Autors nicht gestattet.

4. Datenschutz

Sofern innerhalb des Internetangebotes die Möglichkeit zur Eingabe persönlicher oder geschäftlicher Daten (Emailadressen, Namen, Anschriften) besteht, so erfolgt die Preisgabe dieser Daten seitens des Nutzers auf ausdrücklich freiwilliger Basis. Die Inanspruchnahme und Bezahlung aller angebotenen Dienste ist - soweit technisch möglich und zumutbar - auch ohne Angabe solcher Daten bzw. unter Angabe anonymisierter Daten oder eines Pseudonyms gestattet. Die Nutzung der im Rahmen des Impressums oder vergleichbarer Angaben veröffentlichten Kontaktdaten wie Postanschriften, Telefon- und Faxnummern sowie Emailadressen durch Dritte zur übersendung von nicht ausdrücklich angeforderten Informationen ist nicht gestattet. Rechtliche Schritte gegen die Versender von sogenannten Spam-Mails bei Verstössen gegen dieses Verbot sind ausdrücklich vorbehalten.

Wir greifen auf Drittanbieter (Google) zurück, um Anzeigen zu schalten, wenn Sie unsere Website besuchen. Diese Unternehmen nutzen möglicherweise Informationen (dies schließt nicht Ihren Namen, Ihre Adresse, E-Mail-Adresse oder Telefonnummer ein) zu Ihren Besuchen dieser und anderer Websites, damit Anzeigen zu Produkten und Diensten geschaltet werden können, die Sie interessieren. Falls Sie mehr über diese Methoden erfahren möchten oder wissen möchten, welche Möglichkeiten Sie haben, damit diese Informationen nicht von Google verwendet werden können, klicken Sie hier.

5. Rechtswirksamkeit dieses Haftungsausschlusses

Dieser Haftungsausschluss ist als Teil des Internetangebotes zu betrachten, von dem aus auf diese Seite verwiesen wurde. Sofern Teile oder einzelne Formulierungen dieses Textes der geltenden Rechtslage nicht, nicht mehr oder nicht vollständig entsprechen sollten, bleiben die übrigen Teile des Dokumentes in ihrem Inhalt und ihrer Gültigkeit davon unberührt.

keepass2-2.25/Docs/Chm/help/base/fieldrefs.html0000664000175000017500000001360412273660230021212 0ustar jtaylorjtaylor Field References - KeePass
Split

Field References


How to put references to data in fields of other entries.

Text  Introduction

KeePass can insert data stored in different entries into fields of an entry. This means that multiple entries can share a common field (user name, password, ...), and by changing the actual data entry, all other entries will also use the new value.

To create a field reference, you can either use the convenient field references wizard (in the entry editing window, click the 'Tools' button at the bottom left and select 'Insert Field Reference'), or insert the placeholder manually (see the syntax below).

Note that field references are intended for referencing data stored in different entries. If you want to insert data from the same/current entry, you should use local placeholders, like {TITLE} and {S:FieldName}; see Placeholders.


Text  Placeholder Syntax

The placeholder syntax for field references is the following:

{REF:<WantedField>@<SearchIn>:<Text>}

The WantedField and SearchIn parts need to be replaced by 1-letter codes identifying the field:

CodeField
TTitle
UUser name
PPassword
AURL
NNotes
IUUID
OOther custom strings (KeePass 2.x only)

The Text part is the search string, i.e. this text must occur in the specified field of an entry to match.

If multiple entries match the specified search criterion, the first entry will be used. To avoid ambiguity, entries can be identified by their UUIDs, which are unique. Example: {REF:P@I:46C9B1FFBD4ABC4BBB260C6190BAD20C} would insert the password of the entry having 46C9B1FFBD4ABC4BBB260C6190BAD20C as UUID.

Referencing fields of other entries only works with standard fields, not with custom user strings. If you want to reference a custom user string, you need to place a redirection in a standard field of the entry with the custom string, using {S:<Name>}, and reference the standard field.

Custom strings can locally (i.e. within an entry) be referenced using {S:<Name>}, see the page Placeholders for details.

You can use the O code to make KeePass search the database for custom string fields (to identify the referenced source entry), but O cannot be used to retrieve data from custom fields (i.e. the code can't be used as WantedField).

Text  Example

Let's assume you have two entries: one with title "Mozilla Website" and one with "Mozilla Forums", and want to insert the user name of the website account into the URL of the forums entry. Within the forum entry's URL, you could reference the user name like this:
http://fictitious-forum.mozilla.org/?user={REF:U@T:Mozilla Website}

keepass2-2.25/Docs/Chm/help/base/importexport.html0000664000175000017500000004514612273660230022031 0ustar jtaylorjtaylor File Formats - KeePass
Help

Import / Export


KeePass supports importing/exporting data from/to various file formats.

KeePass 1.x supports importing data from CSV files (special form), CodeWallet, Password Safe, and Personal Vault.

KeePass 2.x supports importing data from CSV files (all), KeePass 1.x (KDB, XML and CSV), KeePass 2.x XML, 1Password Pro, 1PW, Alle meine Passworte, Any Password, CodeWallet, DataVault, DesktopKnox, FlexWallet, Handy Safe, Handy Safe Pro, Kaspersky Password Manager, KeePassX, LastPass, Mozilla Bookmarks, Network Password Manager, Norton Identity Safe, PassKeeper, Passphrase Keeper, Password Agent, Password Depot, Password Exporter, Password Gorilla, Password Keeper, Password Memory, Password Prompter, Password Safe, Passwords Plus, Passwort.Tresor, Personal Vault, PINs, Revelation, RoboForm, SafeWallet, Security TXT, SplashID, Steganos Password Manager 2007, Sticky Password, TurboPasswords, Whisper 32, ZDNet's Password Pro, and Spamex.com.

For both KeePass 1.x and 2.x, there are importer plugins available, which add more import capabilities/formats.


Unfortunately there isn't any standard password database format. Every password manager uses its own file format. Anyway, almost all support exporting to CSV or XML files. This sounds good at first glance, but CSV and XML files aren't specialized password database formats, they only specify a low-level layout of the stored data (for CSV: data fields are separated by commas; for XML: hierarchical form using tags). These formats do not specify the high-level arrangement of the data (for CSV: order/meaning of the fields; for XML: tag names and structure). Because of this, many users are confused when application #1 exports data to CSV/XML and application #2 can't read the CSV/XML file, although it claims that it can read those files.

This help page details the expected CSV and XML file formats. Knowing the formats which KeePass expects, you can reformat CSV and XML files exported by other password managers to match the KeePass formats. CSV files can be reformatted using e.g. OpenOffice Calc (see below). XML files can be reformatted using an XML editor.

KeePass can import many password database formats directly (see top of this page). Additionally, there are specialized KeePass Plugins available for importing more formats (like AnyPassword CSV, Oubliette files, PINs TXT, ZSafe files, and many more...). Using these plugins, you don't need to manually reformat the output of other password managers; you can directly import the exported files.

If no import plugin exists for importing data from your previous password manager, feel free to post a request for it in the KeePass Feature Requests Tracker and/or in the Open Discussion forum.


Text  File Format: CSV (KeePass 1.x)

KeePass imports and exports data from/to CSV files in the following format:

"Account","Login Name","Password","Web Site","Comments"

For a detailed example, download this file: ZIP Package FileSample_CSV.zip. This file is zipped only in order to ensure correct encoding (if not zipped, browsers or download managers could automatically convert the file to a different encoding). When importing a CSV file, it must not be zipped!

Important notes about the format:

  • The file must be encoded using UTF-8 (Unicode). Other encodings are not supported.
  • CSV files only support the following fields: title, user name, password, URL and notes. Other fields like last entry modification time, expiration time, icon, entry file attachments, etc. are not supported. If you want to transfer such information, you have to use a different format (like XML).
  • All fields must be enclosed in quotes ("). These quotes are mandatory, unquoted fields are not allowed.
  • Quotes (") in strings are encoded as \" (two characters). Backslashes (\) are encoded as \\.
  • Multiline comments are realized through normal line breaks. Encoding line breaks by \n is not supported.

Microsoft Excel by default does not enclose fields in quotes ("). It is recommended that you use OpenOffice Calc to create a correct CSV file (see below), or use the Generic CSV Importer of KeePass 2.x (import your CSV file into KeePass 2.x, then export the data to a KeePass 1.x KDB file), or fix the CSV file by manually adding the quotes using a text editor.

If you want to transfer data between KeePass 1.x databases, you must not change the default export options of KeePass. Do not export additional fields or uncheck any options, otherwise KeePass will not be able to re-import the CSV file, because it does not comply to the specification above any more.

Using OpenOffice Calc to create a CSV file:
OpenOffice Calc can be used to create CSV files that can be imported correctly into KeePass. Follow these steps:

  • Make sure you got 5 columns as described above.
  • Select everything, right-click and select 'Format Cells'. In the dialog, choose Text as category. Click [OK].
  • Go 'File' -> 'Save As...', choose a location and make sure that the check box 'Edit Filter Settings' is enabled. Click the 'Save' button.
  • Choose 'Unicode (UTF-8)' as character set. The field separator must be set to a comma. The text separator must be ". Make sure that the Fixed Column Width box is not checked. Click [OK].

Text  File Format: XML (KeePass 1.x)

This section describes the KeePass 1.x XML format. Note that this format is different from the XML format used by KeePass 2.x (anyway, KeePass 2.x can import KeePass 1.x XML files).

You can download a detailed XML sample file here: ZIP Package FileSample_XML.zip. This file is zipped only in order to ensure correct encoding (if not zipped, browsers or download managers could automatically convert the file to a different encoding). When importing a XML file, it of course must not be zipped!

Important notes about the format:

  • The files must be encoded using UTF-8 (Unicode). Other encodings are not supported.
  • The following five entities must be encoded: < > & " '. They are encoded by &lt; &gt; &amp; &quot; &apos;.
  • The UUID is a hex-encoded 16-byte string (i.e. an 32 ANSI hex character string in the XML file). It is unique (also across multiple databases) and can be used to identify entries.
  • Dates/times are encoded in the standard date/time XML format (YYYY-MM-DDTHH:mm:ss): first the date in form YYYY-MM-DD, a 'T' character, and the time in form HH:mm:ss.

Text  Generic CSV Importer

KeePass 2.x features a generic CSV importer. This tool can import almost all CSV formats. The CSV files are loaded and you can manually specify the encoding / character set, assign columns to data fields, and specify how the low-level structure looks like (usage of quotes, etc.).

To start the generic CSV file importer, click 'File' -> 'Import' and choose 'Generic CSV Importer'.

Generic CSV Importer

Details about the generic CSV importer (with descriptions of the options, examples, etc.) can be found on the Generic CSV Importer help page.


Text  How to Import CodeWallet TXT

CodeWallet is a password manager that supports different card types (fields). KeePass cannot know which of the CodeWallet fields correspond to the KeePass standard fields (title, user name, ...), because they don't have fixed names (language-dependent, user-customizable, ...). Therefore all fields from the CodeWallet file are imported into custom string fields of KeePass entries. After importing the file, you can move some of the strings to the correct standard fields (by clicking the 'Move' button on the second tab page of the entries dialog.


Text  How to Import PINs TXT

In order to successfully import a PINs TXT file, you need to do the following:

  • Switch PINs language to 'English'.
  • In PINs export dialog: Enable all fields.
  • In PINs export dialog: Set separator to 'tab'.
  • In PINs export dialog: Enable 'Quote texts'.

After exporting a TXT file using the settings above, import it using 'File -> Import' in KeePass 2.x.


Text  How to Import Data from RoboForm

  1. Export your logins to a HTML file. To do this, open RoboForm's Passcard Editor ('Edit Passcards' or 'RoboForm Editor' in the Windows start menu) and in the editor's main menu go 'Passcard' -> 'Print List' (in newer versions you have to click the 'RoboForm' button and go 'Print List' -> 'Logins'). In the dialog that opens, click the 'Save' button. Choose a location and file name, and click 'Save'.
  2. Open your KeePass 2.x database file and go 'File' -> 'Import'. Choose 'RoboForm HTML' as format and select the HTML file you just exported, then click 'OK'.

Text  How to Import Data from Steganos Password Manager 2007

Warning! It is possible that the transfer fails and that KeePass accidently overwrites your existing passwords in Steganos Password Manager. Therefore backup your SEF file before starting the import! In any case you should restore your passwords by restoring the backup you just created after the import process! Even if you think KeePass hasn't changed anything, restore from the backup!

Unfortunately Steganos Password Manager (SPM) lacks any form of export functionality. As the SEF file format (in which the data is stored) is proprietary and no specification is available, KeePass needs to try to get all the data out of the windows of SPM.

The import process works as follows. First you start SPM and open your password database. The main password management window should be open (i.e. the one which lists your items in the middle of the screen, and got toolbar-like buttons at the top). Make sure that all your items are displayed in the list (select the correct filter in the combobox above the item list).

Now switch to KeePass 2.x and open your KeePass database. Go File -> Import and choose Steganos Password Manager 2007. Click [OK]. Now read the rest before continuing.

After pressing the [Yes] button in the KeePass import confirmation dialog, you got 10 seconds to switch to the SPM window. Select the very first entry within the SPM window (but do not open it, just select it). This is important! The first entry must have the keyboard focus and must be selected.

When the 10 seconds are over, KeePass will start importing. You will see how KeePass opens the SPM items, copies the data, closes the item's window, select the next item, etc. Everything goes automatic now and you can just sit back and watch. Sometimes Windows playes a ding sound, this is normal.

Note that it can take quite some time to import your items. Do not do anything while KeePass is importing! One single mouse click or keypress can ruin the complete import process.

The last item will be scanned twice. When completed, KeePass will show a message "The import process has finished!".

It is possible that KeePass failed to import some items (mainly caused by SPM's unpredictable slow response times). It is highly recommended that you compare each of the entries.


Text  How to Import Data from PassKeeper 1.2

The import process works visually, exactly like the import method for Steganos Password Manager data. Please read all instructions in How to Import Data from Steganos Password Manager.


Text  How to Import 1PW and 1Password Pro CSV

KeePass can import CSV files exported by 1PW and 1Password Pro. When exporting the data, make sure:

  • Choose the tabulator (Tab) as field separator.
  • The option for enclosing fields in quotes must be enabled.
  • All fields must be exported, in the original order.
keepass2-2.25/Docs/Chm/help/base/license_lgpl.html0000664000175000017500000007043612273660230021715 0ustar jtaylorjtaylor LGPL License - KeePass
Help

LGPL License


GNU Lesser General Public License

		  GNU LESSER GENERAL PUBLIC LICENSE
		       Version 2.1, February 1999

 Copyright (C) 1991, 1999 Free Software Foundation, Inc.
     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

[This is the first released version of the Lesser GPL.  It also counts
 as the successor of the GNU Library Public License, version 2, hence
 the version number 2.1.]

			    Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.

  This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it.  You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.

  When we speak of free software, we are referring to freedom of use,
not price.  Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.

  To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights.  These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.

  For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you.  You must make sure that they, too, receive or can get the source
code.  If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it.  And you must show them these terms so they know their rights.

  We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.

  To protect each distributor, we want to make it very clear that
there is no warranty for the free library.  Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.

  Finally, software patents pose a constant threat to the existence of
any free program.  We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder.  Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.

  Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License.  This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License.  We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.

  When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library.  The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom.  The Lesser General
Public License permits more lax criteria for linking other code with
the library.

  We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License.  It also provides other free software developers Less
of an advantage over competing non-free programs.  These disadvantages
are the reason we use the ordinary General Public License for many
libraries.  However, the Lesser license provides advantages in certain
special circumstances.

  For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard.  To achieve this, non-free programs must be
allowed to use the library.  A more frequent case is that a free
library does the same job as widely used non-free libraries.  In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.

  In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software.  For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.

  Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.

  The precise terms and conditions for copying, distribution and
modification follow.  Pay close attention to the difference between a
"work based on the library" and a "work that uses the library".  The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.

		  GNU LESSER GENERAL PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".

  A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.

  The "Library", below, refers to any such software library or work
which has been distributed under these terms.  A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language.  (Hereinafter, translation is
included without limitation in the term "modification".)

  "Source code" for a work means the preferred form of the work for
making modifications to it.  For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.

  Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it).  Whether that is true depends on what the Library does
and what the program that uses the Library does.

  1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.

  You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.

  2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

    a) The modified work must itself be a software library.

    b) You must cause the files modified to carry prominent notices
    stating that you changed the files and the date of any change.

    c) You must cause the whole of the work to be licensed at no
    charge to all third parties under the terms of this License.

    d) If a facility in the modified Library refers to a function or a
    table of data to be supplied by an application program that uses
    the facility, other than as an argument passed when the facility
    is invoked, then you must make a good faith effort to ensure that,
    in the event an application does not supply such function or
    table, the facility still operates, and performs whatever part of
    its purpose remains meaningful.

    (For example, a function in a library to compute square roots has
    a purpose that is entirely well-defined independent of the
    application.  Therefore, Subsection 2d requires that any
    application-supplied function or table used by this function must
    be optional: if the application does not supply it, the square
    root function must still compute square roots.)

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.

In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

  3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library.  To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License.  (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.)  Do not make any other change in
these notices.

  Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.

  This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.

  4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.

  If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.

  5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library".  Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.

  However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library".  The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.

  When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library.  The
threshold for this to be true is not precisely defined by law.

  If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work.  (Executables containing this object code plus portions of the
Library will still fall under Section 6.)

  Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.

  6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.

  You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License.  You must supply a copy of this License.  If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License.  Also, you must do one
of these things:

    a) Accompany the work with the complete corresponding
    machine-readable source code for the Library including whatever
    changes were used in the work (which must be distributed under
    Sections 1 and 2 above); and, if the work is an executable linked
    with the Library, with the complete machine-readable "work that
    uses the Library", as object code and/or source code, so that the
    user can modify the Library and then relink to produce a modified
    executable containing the modified Library.  (It is understood
    that the user who changes the contents of definitions files in the
    Library will not necessarily be able to recompile the application
    to use the modified definitions.)

    b) Use a suitable shared library mechanism for linking with the
    Library.  A suitable mechanism is one that (1) uses at run time a
    copy of the library already present on the user's computer system,
    rather than copying library functions into the executable, and (2)
    will operate properly with a modified version of the library, if
    the user installs one, as long as the modified version is
    interface-compatible with the version that the work was made with.

    c) Accompany the work with a written offer, valid for at
    least three years, to give the same user the materials
    specified in Subsection 6a, above, for a charge no more
    than the cost of performing this distribution.

    d) If distribution of the work is made by offering access to copy
    from a designated place, offer equivalent access to copy the above
    specified materials from the same place.

    e) Verify that the user has already received a copy of these
    materials or that you have already sent this user a copy.

  For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it.  However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.

  It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system.  Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.

  7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:

    a) Accompany the combined library with a copy of the same work
    based on the Library, uncombined with any other library
    facilities.  This must be distributed under the terms of the
    Sections above.

    b) Give prominent notice with the combined library of the fact
    that part of it is a work based on the Library, and explaining
    where to find the accompanying uncombined form of the same work.

  8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License.  Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License.  However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.

  9. You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Library or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.

  10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.

  11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all.  For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.

If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded.  In such case, this License incorporates the limitation as if
written in the body of this License.

  13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.

Each version is given a distinguishing version number.  If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation.  If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.

  14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission.  For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this.  Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.

			    NO WARRANTY

  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.

		     END OF TERMS AND CONDITIONS

           How to Apply These Terms to Your New Libraries

  If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change.  You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).

  To apply these terms, attach the following notices to the library.  It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.

    <one line to give the library's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library 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
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Also add information on how to contact you by electronic and paper mail.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary.  Here is a sample; alter the names:

  Yoyodyne, Inc., hereby disclaims all copyright interest in the
  library `Frob' (a library for tweaking knobs) written by James Random Hacker.

  <signature of Ty Coon>, 1 April 1990
  Ty Coon, President of Vice

That's all there is to it!
keepass2-2.25/Docs/Chm/help/base/index.html0000664000175000017500000001155012273660230020354 0ustar jtaylorjtaylor Help Center - KeePass

KeePass Password Safe

KeePass: Copyright © 2003-2014 Dominik Reichl. The program is OSI Certified Open Source Software. OSI Certified is a certification mark of the Open Source Initiative. For more information see the License page.

Screenshot

Introduction

Today you need to remember many passwords. You need a password for the Windows network logon, your e-mail account, your website's FTP password, online passwords (like website member account), etc. etc. etc. The list is endless. Also, you should use different passwords for each account. Because if you use only one password everywhere and someone gets this password you have a problem... A serious problem. He would have access to your e-mail account, website, etc. Unimaginable.

But who can remember all those passwords? Nobody, but KeePass can. KeePass is a free, open source, light-weight and easy-to-use password manager for Windows.

The program stores your passwords in a highly encrypted database. This database consists of only one file, so it can be easily transferred from one computer to another.

KeePass supports password groups, you can sort your passwords (for example into Windows, Internet, My Website, etc.). You can drag&drop passwords into other windows. The powerful auto-type feature will type user names and passwords for you into other windows. The program can export the database to various formats. It can also import data from various other formats (more than 35 different formats of other password managers, a generic CSV importer, ...).

Of course, you can also print the password list or current view. Using the context menu of the password list you can quickly copy password or user name to the Windows clipboard. Searching in password database is possible.

The program ships with a strong random password generator (you can define the possible output characters, length, generation rules, etc.).

The program features a plugin architecture. Other people can write plugins for KeePass, extending its functionality: support for even more data import/export formats, backup features, network features, etc. See the plugins page on the KeePass website for downloadable plugins and an introduction on how to write your own plugins.

And the best: it's free and you have full access to its source code!

KeePass is distributed under the GPL license. See the file 'License.txt' in the downloadable KeePass package for details.

This documentation applies to KeePass 2.x.

keepass2-2.25/Docs/Chm/help/images/0000775000175000017500000000000012273661064016716 5ustar jtaylorjtaylorkeepass2-2.25/Docs/Chm/help/images/flagger_small.gif0000664000175000017500000000012312273660230022172 0ustar jtaylorjtaylorGIF89a , @,H *\( Ç#0HqċjLXǂ1nIra@;keepass2-2.25/Docs/Chm/help/images/b16x16_desktop.png0000664000175000017500000000206512273660230022101 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxA/  F9!M_fd栗YҸFC~0ycFNnb?_@WNB-ן"av? 52+,,ȖV]˄3& b Y3q- ~U ę`g2aő!mg)+l-觡ɰT)Okl'M8m@ @n0ȋT7tVbЖg`gr5þ />f8߾nj~@,BB"7؉e䔏f{ ?d`fʰk>i K=rV)m^|^ _31n۷ܸ L!C!Lψ}}]7&nbz[}naؕp~'9n+O?10e(t,+A0zB'0  ?179)"zןqE:X ~g&V_0( ^vf^/_2|p O^OA501P6!  0 㷆ǏI jɗvV=p9Ë O8=vbG  0.`0] va`JpƒE7:2xa >M/8=>~ݥ@MA Z l* r;6|/_?ߌ*wX != @ @6/+* {Ag5$42_$3-eaIENDB`keepass2-2.25/Docs/Chm/help/images/dlgbanner_bluecarbon.png0000664000175000017500000002330612273660230023552 0ustar jtaylorjtaylorPNG  IHDR<[ IDATx}yUoܛ^C ! @ҭaVPQi9{>m_;tcm7F_}Ђ $2$B@ܛcWթ3sQ+{׮Nj^mذK. ŗJCPFd,ۈ@ jBDU!^E$lUDDң [fVG^S`V1d-CUP(g?z(ԋsPEZ"3v\rɥ*TUURIc&2C@,< @)Zn*UUUM1 8D"fS w U^@= sRNP[롶&⏪㱻);jK.N$|;q^bbf x-V) `@kQ@@!ᏸsP}1`6|z ec-j}:Đ S Uz1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89_2YPNTt<~S6_8j pbl۸e6ֿn]es2r"@c%V@ }cPpLVV,xw27;2鲨#n{C(,nnn~;/ k>4L0PE)EeO~؍h&.J8\H$JZ|Ҁ)O&F+l E%IZe4M:ޞݯnoP5Lq ".W۸qÆ p7Μ>Y, v;MӫWp-9{~w~&kD9IENDB`keepass2-2.25/Docs/Chm/help/images/b16x16_rotate_cw.png0000664000175000017500000000150212273660230022412 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb?% X@c  /37ߏ3030$ J,Z~ŝ) /@,(9ۿ?ʂA._5kWu< F.`)-i'v =@A\߼4@yi)_?101 Tç? ͠)e \΁B" }e+ë'32 /+ 7N7! H 1} Va{'V]rg>a`a?@ O?~2c{38 (l_2010?@`@had@nP!HX lϯ y^3Hex $KR"@/Ġ 7\@iN|I ^O7D#S?3"(N"P$ 6z˖<- 20}!> `Yv IENDB`keepass2-2.25/Docs/Chm/help/images/b16x16_usbpendrive_unmount.png0000664000175000017500000000141112273660230024535 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb?% (Ē2ϟ f`dgx9Pq߿*i'()`/##+%"rK .*--Yg+#(iӜ"0߿@Ϳ4$ڬ =55u8. ( & p9_ Uoam-t6PÛ7߀^Ġ- #̰nui~>@ 7\{3335?^odeylPUU#@u6߿[ܬE54620|򛁍7??V.n.&1{odZ^baffdK3AAAZɣ ]kzi0 PjKKE?YY&/0Kp0HJ0ps30|kMY3۳w__VD7b>}'?߿lյ +7l5Ж W<}ΰb7oV @1Xhz֭;HJ=xpϷڀ@/)#''?(K|Eel`r>Sb@1R`G:GнIENDB`keepass2-2.25/Docs/Chm/help/images/b64x64_doc.png0000664000175000017500000000270212273660230021201 0ustar jtaylorjtaylorPNG  IHDR@@% tRNS/wIDATxZKK+YH AAt΍ .ww+.U62s!Y(kgN[Swh|o_:>>>;;cFUUL&kkkAB?ytt4??J DrXۛ21W.777KVTZ__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Sѐ,&k0_g A~ F0Ti sMMA/ t 2fLQL .N@DyoV{3-馏@ R b5dÁ$f=m#?goEMBW@€p롶ލcbbŏWvZSH3?Lo>aeK$4Cӈh!NPZĘ 46\al 1ye,w =| 1SB#nBClSGًvMTVvA$c܁W3-|BL'#2pO@Bne<]~oOSS\ZR":N<|NZ=hߥ=792%*V" BCǏOj===]$Dlll;;[fe.;;;<<(^}hIq؅#5fVr^h!1kt{7mlKi999=ِa!M 40+NWҦ(1B\d'LUEɜ^yyyQQQz9Hu(I9%^J{pz-SxSv`#W'zbz'x_ߘJF:*?ckM-_qK\=ۓ:tTqJ'('|e W}Nㄅ.M350`Xj=yMP׳k$| *7zMy3 6>1$gHdּw~2Ym-[0ne3\vH0~[;FJBEtQAlq1PrR͛jd 1 ~>z.+<YYY,C,zhENIbݳ\8esm[ ܿei{ד1,N/իW 5gN Y@2j>>Ww&K/# p̓OH2&-:zDÁ~rJɣǏUGK}IENDB`keepass2-2.25/Docs/Chm/help/images/b16x16_password.png0000664000175000017500000000166512273660230022277 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<GIDATxblUgؙ1|&u1[V3e@, 8ߌ 1*?)YfPd2cY'V/ u4SFIfk|ee:;ÅG5ew+L~#3 fbd`ddڣ.GVp]|vn%@OA  wJx T&KQ? ?}uϟ eؘ կ É_ Dd%ąĄxZ0~e`$4ňH2wG|!H@1 akkk##COO׮߿>}knnޙ0=€mlEUbo߾góg.cb`ddc`ff rs>};?~1| ee`cc)@Lps0~ϟ_ JJR ?fx5 3'ze|,,tqss6|  P `ddb7?|F! ?351P%\@5Wށm+T3#VNNv>>^p7߿l6 yxx=xp6?10{hWCh|oG@(y_ED~1~c`w}v1̟?Ƀځf] 2h!륳fkWW /_GBIEń^x&x҈׏VQg`akcg_888z ̴3nw013eՏZ& t U5>bgAD8C7} B wVZJ =::z _s~f`_/8Y˃W} )e=޿IENDB`keepass2-2.25/Docs/Chm/help/images/b16x16_help.png0000664000175000017500000000143312273660230021356 0ustar jtaylorjtaylorPNG  IHDRh6tRNS/IDATxEKl qmwmUUGH#HI8уGB$yTiVGWwٙ;C8ɋkS :ӿ{Q;PƩ `wKR ə#뜩SZ[j8z5;;[ he22Q)$SFЭmN?Xѳ6T-g6;2:eFEJT3CO^KgHhcGPtsR[tA1 kV!0F\>#wl5b\?% -4ڗ) f+ ׌~ܰC !S,{`/kDө]%ijBD;;͉Y (łBbN9hvo; q4A;?.=5,ǴuF*@eN#1~'`=aM'OO9uQ`T@,Shk(A(L:'CqǙ 0Sx.`gCv@o l(qD%LC¶*QlYw"jZ[E.ā&}ǟ:M̲`w[!53=+>Q#6=vε?%Sœg_}Q._ʺSl*_ھz[s7& @pS-;xG[(ȤZcIENDB`keepass2-2.25/Docs/Chm/help/images/b16x16_filesaveas.png0000664000175000017500000000176112273660230022554 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb?#c200@BL@VzIn؅\?w' X@Beڒ~Blj4?H^ < _=Z+&yS=>?  h; W/^`ng $ @`x33H ]/W?3X0>g`a W{0؀?h @?@1 fɻwƠ)DSe(tX}6^L LL c20|ə _TN0q)Eb7P;3$YAt̓s_2H)10< ù'u ĭx?U}e & Ŀ?_W1]ge`0W /41țx22F?F Ͼ0197ßO3Ch/݋of|,=^`0CR@]p?o~0~}Š '0\eaɑð~Ù,T^v_20( a(piGw9fjG[;X] oH0 ~0u)321(g2&10 Q s@A\o 30ea`ffx9gbc`bxt)LLg 3q20|_BIo |f_?dY~dc?X/@]pu̓\|wg>^Vg?!NYɗo ?aŻ߯9@g:|k㭏IENDB`keepass2-2.25/Docs/Chm/help/images/b64x64_file_locked.png0000664000175000017500000001001212273660230022665 0ustar jtaylorjtaylorPNG  IHDR@@iqgAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb?H8 ###vvv6w\@|Zơ9&&7@/u֜ׯ_  pS$'', 48ׯ_O{57d?841 ;Wّ @,B۷o8?ƆY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8/t钡|q?0.\e!L&S32Y !rjX;wxt^^n"L&޽W6m*M%N^o!+Dח>}c^\\ /<䓉D G}q8]ָaZaZmOOz=B,LZ֞j afX5 $m߾=YF$ݞFY6!jFs̙ ͖NZfYՖ`Xzr3fIlzF$HɏPdZf# 8(ЍMIENDB`keepass2-2.25/Docs/Chm/help/images/b16x16_chardevice.png0000664000175000017500000000177612273660230022535 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxbLKK[wgg`|{:߽{ĸk׮l+V``fff`aaWOqqQ@[nJիW@?P_~ @@eN:[>>~vb<<< `AF~o߾]     g| >|`xж ?f;Ï?tttA/ph#HǏ4 @񕁑/F`h@HsA]pEw@ak?2Ҙ<211}@,A߿WaaaNNN7 bl`x{5 e96>p X@1vdee$%% W3:3 bnY"(@,@11]wNN....Ǐ3ܺuɑƭ; 0hlV7 /^W f`ihh 0pppg^32hk3 ;bu2!~ ׇk?˲eKR 荿L*?~djnnyIAЂ?X2|agX Xvܸq}P!4~q!W;v/220?KJNQA9jڠh_%D > \=ғVTWax012<}aú߽{ @0o߾.={[Ǐ3Z{׫&&`gd`eeJdbbՓ_J0{IWIENDB`keepass2-2.25/Docs/Chm/help/images/b64x64_dataexchange.png0000664000175000017500000000634512273660230023057 0ustar jtaylorjtaylorPNG  IHDR@@% tRNS/ IDATxZ{tUՙ+ɽ7M$#Hp&X -Cd!}Nj˱-c-T,Q; :`1Ԣg$77nr=q!&&q>}{ en䍎ɿ:t8WĬڕ+W~FЁ}@ 999[lYP`kb;U֚VZiӦcǎ 'X566.^"oB 8အǴo$IZlٞ={9Rc@ggg~~doL|0Z[['Bk3?̀|r΅Y6'9mX+q5P?|@\GC<\%xmGKP*>),$K0O hhYBo2Di"e،aIp!QCg%tL!Jm{9p_0$P.eeUބ1$!$Q EA-x!o;#Z8PzTV۹ʎ7Ѻ0-SJ&FSo3{'lf3E/l[~S9eٴ@EdCA+QɷN~|wdэIM3mTbJ ּFa{q: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664000175000017500000000157012273660230021527 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe< IDATxb:a### [ZZ aǎ?ׯ_ |yyC flrп6HBC r@8@*}&ffQL@C~ 0ͪ ! F۷?0ܸAL@Ma6@MLp?|Ǐ7 \\@c ߿eb``(劉  2ۯ@6"Й?0||tG c1aw |@ۿ3f /`(3|OOop=??~3|`Ȕ@16S#1|_ ~?+O07v!"~O72} Šp637q 8؁Fvx؀9s) 13ac|_}7aW VV @, ڊ3|45Ege!ϟ 2@$yl@󗁏Yl_pjI(0x++(,]@,@0Mgf%FhEЈ c&" e4&b9ww ߿da~D0H-03/bNJʳ-+gq~'Y$jIENDB`keepass2-2.25/Docs/Chm/help/images/b64x64_blockdevice.png0000664000175000017500000001122612273660230022707 0ustar jtaylorjtaylorPNG  IHDR@@iqgAMA7tEXtSoftwareAdobe ImageReadyqe<(IDATxb?H0@4 F|Ј@#>h@ s** h> AuC}rX0C8IhU səyyw?j6r Q8hE)aO~~nnsNNo|0(C7PIhi4C ïP?Co6,^cuYwt}!'gHq+w*Yoj6GWW.G0=s20b`8DCUE 98$Āfbm- N30_aۉ˟n}{ ` q@ ĿQc^dvvv;+GG} ݻ bp  I" erawE~W l_h%0|[ݵݳo@$@?$dlSTufz ? piS/2\``8 i\QagkĠ/_$\nw 8|J/ad`pa_G/* b P`&\HQ3ٙR}xypC=lq/yP > ܬL ? XE`0 q7$B ?s&`@2zs?s% ȈASRFF>(ABI qPy9`l ?`É˗.20<L N##?pa? +,߳Gd`fH%~A 4w^`(}  -"@o*`{y1=\bAe?fm ).  hq` Y@dY`2e`|BMAZaǩ 3E'0VxiH@ ,A@|X, Ep RUidͰ`5OY0@J9n0D0X T?~_13؈3ae?~3x/mL% B@ u5 u8 .0,@glA J fS`U x+cb0d7!5-V+E Af(c >(0L49x|=C @_5p.B 0R?RG1Ug*Jp00\0e14d1a>J#"A!]e.';Sz|C<ZȽş䎬r@y6 ]B Z S-TŸn} 1ƈR37de{)/ 9^/450CGkƖ= 141a`H2e`dl.#RKQAxaA* gNar-z~1#:ao`xh@,hc7t@7V$ I<%.`1`{ 86"%,xlO%1}P[ W:4J Y @1\`;l3ragȰ21K,#AY*%8ep#/@<:,0|z5 C1("+ 0Dz ى :H0e gbL;7бPSR@w1,e:3s`_gBR O ?34=ð [@j3lTf`PP_ gdc4Ëwe<DԁaEFψ#l@|:C` DeLc-K 2a/ !D X 3#454b70 MAL8+Ps2 rdMXCiY5``#BK|&/A u`ypC_ 0b@2 Qu=QX>Ss A÷|y̠* (ĄY 30i7r@)9İtg_ d P<_b_ 6fh';3dzpi`,Ps,eefcå{'?I2HIK0033cLĀ;@ v>~~ !! <0p? |@x#Aݮ?JGP]RA^ܷ?Φ`]{9j? tۋ/=ifm+)u=q"?@큮&M<y`  ו`01d`ggfi|t ޻WK:glhc_ 4/cʅ/lXy l쐲(Q4w+W?`}7ljxu b2oزi#_+@~` 0^pN0/HXF  ʲ B?`I%t`V *Hbb"&-h! ?`) BcPi`h>.Cg @ X49wY4Mȉ̬nFv Fv<  {ngTF ./~9J_@MFA, wH@R/" *NA% Å~72K @[lAvh]` 8sp0|J0h@lgð IENDB`keepass2-2.25/Docs/Chm/help/images/b16x16_window_list.png0000664000175000017500000000162312273660230022771 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<%IDATxb?% X"3V_~b7?Fr-6JJ?@,:Z4 H5𗁉7# iqy)qQc#_| X/7_ C@z?&f& 2d~OVEo Kbaaga0PbbCNab`x5nn>?|ڍ^b_d@? O_1H2kps0} X~ @A ?~3c7;ñ~ XcbD%#h4@ ||| * `|WoLp9?0@/6~]0X@6#0p@9  ]v[+~wnR6ލB`ll߁ _^f`` ?~1@ @Oc @A @,5!/` &@J8 1\FثtO`r: ڒ*aN >SP2hP70H(P 4/?3×@ ?_K 3* *pW)pԀ ~6V`X10@APRCCASۀ셛 o=dPg F~e)!6N65HٿAyfC$5夊\1IENDB`keepass2-2.25/Docs/Chm/help/images/b16x16_kcmsystem.png0000664000175000017500000000165112273660230022447 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<;IDATxb?% X@###VƙLbbE[}heeo$7aBO>DDW޽}77O\Sojj+r@4 )HyxJ2bB:,XNNvO6ӿ ϟy5n@MdIWjj*7qr÷o?XYY޾}uIWWݼg1겗U ̀ mh31`pq4x Ù37~gk`cdq í[> ؀|&&Pd_F^1|  LLL ̬ ۶m2/@ xNŔ)^|PWW{뗿=y( hC-[V驿 {@17440Ɔ=`bb5555eUsQ  62cdܽ{7nj ďA@`| 0MU077ɓWV\_6 @ˏΞU]F!!ׯ?0 Wի/z97@ `)ِ=Yo||拥Kwu9bn@ \66Ι_~pm\\܊_~9 {ķv  d@j8bPĿ]` ZZ dϐIENDB`keepass2-2.25/Docs/Chm/help/images/b64x64_ktouch.png0000664000175000017500000000672112273660230021736 0ustar jtaylorjtaylorPNG  IHDR@@% tRNS/ IDATxZYl[gv>/VeB[-ˎ;3h(KSic_4A&}hgک14-hz/AdGe[ )w/},KxA >I߾9hǿ3O;BJTJQGgv,yh=D`)rlsJBuWfs6o%NLAdVƀ<UBW3_ƣ]G#v~07ttQ6{1,Sԭxv[H@Dc+j{a= ~ӯoK։`"G9je }7zO dģs玞ɥK$B!\I7}өOUwdHիj58]|Vİt)'RݵD0f>ů}9yPI1D33s_|xԔ1:; "7U>yZvV"5̂#``)X,B~G ]WyƀmGYC[x Pj?|o)dٷoZFUtc|?@k$(oMFkCj<&Fτ"(d JP"U*GZ6`&oWWt8po1a>㡭-8nSC",^ݸ}sթ)Z1 CCCϟ<0(BPh1s,;fˋeYDG`^3$H_pMIENDB`keepass2-2.25/Docs/Chm/help/images/b16x16_openterm.png0000664000175000017500000000163512273660230022263 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe</IDATxb?% XLLYIY@eBC!?x@,\... ߾f'33\FFF Ab;+ {7 ')Rv#(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P;I`Lֺ[vD6N6/L&#]]L+TP3Ky=59PE4ɖfyS.aqcɬ/_US= QZ,obҩ%%<pxrarX 렦JiM(-<&D\׍@f5nzT4Fpe*Wu`RXEºUUdtHFzfb|ee N 0R846,L !FbSI!>"R͜d"k)S.őQYqYCͮΜ9sQmߞ/~`%YqSg2â0&G:P$4{ɡK. mp,Pπa2gO(Waf[H>^OgYվUX fqb d"@U !'G x&3ȑ PLC,e{_Ls` @

t{ىh>/U\*p'd\(*A@)]=8=6֭]n]e>{;ko#P`;EMx3󮼲גTJ# B͕'2s.M||L85;mLf,<7Ǯo\8ձnٲe˗/&,$!<aޜ; U[v,.-~鍋qw䖟籣o/nܴi˖-7܇}xllllll|l,6>In²8'k4PU\>A ip *[lE 7B?G7o޴im;o]:10 0MӶmJ)^OEQUU4M\.@R[~}C\F"[ںuƍw~?crqs޽ҿag%^䮑?O&/Z9IENDB`keepass2-2.25/Docs/Chm/help/images/b64x64_desktop.png0000664000175000017500000001630012273660230022104 0ustar jtaylorjtaylorPNG  IHDR@@iqgAMA7tEXtSoftwareAdobe ImageReadyqe<RIDATxb?H0@Ăadd20b?K _d{$P;x  aF^ L} ߿fu( @ 00`˴M &w2{n1POX)4~(h)*𙏛AHWAJSNjAUu"P<CC)k?G01YY0HHs1caaRfSQ``bbfV`ly7m685}oLO/10f)(ԥļ 2=aw[dF(CnK2l~ < _^)1{/r:U~2Lc!L+ǁɏ ;lc"0s20cVgx&4K|)x&3o< a|/>oe!Џύ `84 ;Vcb`d`x{fO`xP  g5h4M(=~U10B dn'Xl?ý@ϟɽ@ϟ{Ȟ} 0$49R#~e`gVVgRg3P` >gH7,G J@%4U/|Jdd$|9ðF^10ß/aepwǷ;AW+@~ LN?%y(oF?"| F fVj "\ O>dxr68G#S=1`?ǁ9u\71 &t $$6%_.1{ѷG 5? ex_@2| E @Q7jkh`l*l 6Z jɷO n`5&4-2F%0ܓU$ p550x@A;82<PσJ< <;ȊV_NSJQAWW\Aۗ.]b!2 ;vg1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(, 38Al7^[s@`$ et0,b.a>} ;sN{޻0(@5K)l^d u5_K1}N،s;4.DT 9 䀎GcxP!33\S ;UߠAlGGGd޽{%\P0| R``__\b?>þ})P  B,XR5''MY@y䦧 ** ((L(13' Ps{+b\@JC!9XϫJFpw!0m)aZ2>CHp x`^RA nz"=j )Ev%ןݽ kbl 7lU=1@jpWOGXdfnMѹgp AذaCActt4< QDAW:X @ @) @)dLY Ab! haBq5rMp"Y {чqe"*;??pb")?* @$ (q Df|@,XKa-BN>yyJ1l ^"6tiF2)8`kNʔHw_k9+"FPę( u#_ GP3_CbM`~+K{8y>)î*FsA/2`4jw֑Qxj7p1APF@s c[ukccc h1ȁ` bĐՂ8G Pl@  0L@0{vJgAIW`R (bĐ{= A+א=: )4pȅ:C`CAq?M9`aBd,@d DA"m*~% ᵘ4Sv ǧKEɩ&m7$UYfD@uQ9h2ބ8ZJPO9DWpkߪҳcr Ev})TZrrȟ֘U{y3Fl73Imb.,-Q;Fa(x3m@w+5.6=%XãM &{nX:{LR۫@`4ic "*$(& C^3XH1~Q#As 0> (@!! ,Y}M >za 'F'vu,eSknԱLٱ!e; / h%@ p7H3K*jyX Ȇ @X =̟f&Pˏ~9I1Tݾ}\πrsˁ µq HMWUU5Au41U`P r h h10~eо bAlgP @|%έ e@j@`bM /`$?sk:=40`FxIENDB`keepass2-2.25/Docs/Chm/help/images/b16x16_package_system.png0000664000175000017500000000215112273660230023423 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxbc߿50ggcb``fefgbffb6fFff^!3f^fP/bM?_=66Qˮ201c`+)'P8cby9܀_\zɏ8}+ Û94?_@Lez{m-I~- ֔f`Vd`Pbi>?I;[kFUEb׏o?攒cb@7 K)v3>}Ư_8 KHH3|&;?y.?e`x_ YwdPQ@1a`cf6`,exo_4:]!N5O>31hjjk200 fkt.'w1޽Ƞ'.+`#yJCy)nF?| A& arb>!޶~2rZGFPZMW 1<+0rH(m?Lׯ (A.`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d:Ro4OGx7 Ad c!%YK5 L!k-"}J$w~$H a!-Yeے>S[;$QjFpPHҲ1R}G~B֒wd!&|2_[_>59z +uH$%ixZguw/Jnq7Mm-}ݠnӗgggRT&U kIS̸7D Tm5"CC ##_yZuFrU*b808G ° u@[o߳qvNa~~ҥEQ?8[RI {*rÇ=0Lww'?y't!e˟{lP̢1ڽ{wPhȢHDZ.3a4Q[{BP.jf+P,9̳={6@R_ATOY^7 ߽cbXYx X10 c(3bkc)*U~ Y``p018 `p 0= ,׮3toDZ 301ef JFɴ>7蝿aa`e{~3(L ,@w>2fgg ڸ?oUJlaA;b)KE}IENDB`keepass2-2.25/Docs/Chm/help/images/b16x16_dataexchange.png0000664000175000017500000000121512273660230023040 0ustar jtaylorjtaylorPNG  IHDRh6TIDATxmkQ}$&Tt)EhV ABςxkx ERZTZTtföw|3|||1FDZ40s PJID㌌1 5\Qցز, DdHmn[Dvp3k^QӴ DkXF=ٰ:/?Vto"a ؖ/m\.ֶqn^(wNHi# _ cD.˲: LW7=ٴҦ1"rd'LBgA۷/o?_l,)W}b16}V̋ۥcW \x{dJ$4B![mזWd"R-2Vk[O|#DT Jt?|dvNÙ|~cOS2LW1y4uotݰo^#{]rΑh7Ҁ}eQ@ f u]a{ys3IH1HitDZ-Q?]>uE(mەJE)uccc&lIENDB`keepass2-2.25/Docs/Chm/help/images/b16x16_keyboard_layout.png0000664000175000017500000000127312273660230023625 0ustar jtaylorjtaylorPNG  IHDRh6tRNS/pIDATxmOq?+}oPHC1!DNqq0Wc!$ėHbB%&RP)-PЖ׻9g~! n Z>d|W-K7>~:&G=TZK%k0ߏalecW۹0\fvA3ϽߏO B|":y$!W6Y-ۋӍ빋?W_tmxl4X{*{+%PvTʫܧfyTd-ri6g=iU{ؼ1 n@'p@#ƙ جv!kmQ"p3x7,F#*30Zy}p(D" j:78 As$,Df"! ,0tN,fNED6_*ZMl `n8VI(b :=~mG=-ٷ?]V(b =IEȱzy09򰼜\_STpnDr1lffd""@DtZQAS~cIENDB`keepass2-2.25/Docs/Chm/help/images/b16x16_warning.png0000664000175000017500000000165112273660230022075 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<;IDATxb\΀g`P~@sb)ϤNŬQ'o: a`P27wtf3b33` 4 /0|%;;[W74 @(.``.ib,i` " -"Ơt4 @,,,i>| 20s0誨pH0Bm ɚI00143wu1bfP` P @L<gv3ܽv̌Q@;M@ x.& , ",#''ׯ jsy @㓕Pۏkˁ]%.. -- IX. ~2qsqt @1AQFEڋc*Z  !^e 2#P(  tV>L%&| C~?iII9@쟿32Qd=h@`+#/5{0/ ?c>u*Cco/o `%8のA zWb,V`fuïW?o\ F =޾ ?>~l YY q7K%^o/^0f1~g?@Mt #а 9\%N/@l@_Lhge~ ld"IZ Y IENDB`keepass2-2.25/Docs/Chm/help/images/clienticons.gif0000664000175000017500000002617412273660230021723 0ustar jtaylorjtaylorGIF89ah#lƐ FN2֙NNGҰ PIJ5FK3h`gQ(hr*kIiO. OLh觐䊋giQ珬[4Gl l2OTiKo\ؐ78նvg F$#uwUKMPEg9qi٪ ne ɐHHMOq܇.puWi趺hjh Zk($_% m<\khhOvhhmNVUU.8wݙ-'TLKoFFKvvvwczSqugkȵ15V'sK.3D6nPh8n]q *c͹88 H./sg.i,F4fcY玓kV/L/cKܩn2.T34vi1h_kL7KJPp(: v08h4))lmNn 81YXXV>xl7OWykxZj .YP,wOӷwN טNڸڑPNٙ1xrw j5ytזk۲X/y0z4U0lz!2TZOzUXjZooQ8QYp0$e5;qّθT'UKYEZk,.%98[ .}K[1 9 #i4y9U9EdT^ڲG7 !l,hH*\ȰÇ#cBHR'5 Ӱ : TPA \@aQG .lpfazKxX,ƌG̛V1P3d:l!btRe S]*b,RB4c)?"D΋/4sfjyBz1lDٛoч` HiRd Cacf 39ţA3]`CB@ ʞ!+ř(.Q8Y'cdȏFA3$aL3QT g6L jR zaQG DF0G5Ў& "4CB3͘qC,aX=,Æ hh`XX X$y4xZg)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ڄ0ˮ 6L*[\ۆn臃x^ XffhE.t]*.h MPx] ޹=ݓ. X!6 *h|P ϘUŠ&Ё`ڸP@Q6+(Pj\0aٕX `\ӄo(`HNmڽ:)&Ņ(}Ѓn'`c6n, &0a5у˚\u:vڍ Z# ?[?(o8'0oH-s2Osؽ`0@?O"ȇVhD=pn(^*UXBI~hbaj+0i _fFJ800JkB)[cRx8014tv88`5V@X|6w@DX-)][؂ʔ`c6fgV1΃F v^:_M5@eW|v؂*KBb Epp[;M8z:9`a@TK=].~Faނ-`[ЁpXf=k4gƟ6> 9HGFÎV"*IM؄|FB5Pf-@S0SH{;sbFb2@n@k>لmh].Ze*Jc/ kŃΔ9fplqĞif |聝. \Koly>BNEX0z8MQ1L5hha@km.^*'`HLEH<0Y dŅFV w^7qpqή('K¦ Cg6lEЂ6m$M2nK@y[NhYx[8s[?/SelT2w111 i;-HoJnh''6(%_rbmbQ@`0MX'9hybP+oV/sP?[P:du#t!ٝvblCpgL;s dOk8=4* >H "4G*Ex 6Az_ :+؃#Px W%!6JЄYCW+f(ʊW6P/2,_E"6Z j=:yuءx`Ƀ')ZPyWF7?;keepass2-2.25/Docs/Chm/help/images/b16x16_file_locked.png0000664000175000017500000000174712273660230022676 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<yIDATxb:i? `Ȁ@FFFvC|ojj* ={v`q`3+ß"@߿ ߾eg0~{ X~enp+F_1b fO0J~cP@,F| 2 t133 aHݿ~ ,Ï_x @P _rJ c^[Ggș3"¼7#R+~e|PП??Μ=O.no__3ܼP? ] lb/t ߿~0eWf``/~1D2h* ï#\@,` 2/ 7e*yAhՀ6 b%'; JL \O l3 @@1fd􎁑OFY ɆNc[HM}Rl;(@z@I#0Çl L E?I7Di9ALr'S`4210Gʉ@:Ydx)˗> ҀjYX12Pa@Y^~ ˮb_IENDB`keepass2-2.25/Docs/Chm/help/images/b16x16_konsole.png0000664000175000017500000000125212273660230022077 0ustar jtaylorjtaylorP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ARS'.Oo21R d֐fp5(wnfp*b" , [؇tp{W-@$ C2Q gA(/ З/?20xڋ1#gsiV)q`p`ff8y7>ٳ`{DEjP^ȃ&,\0C CH;V 2 @0@$B 122|g`fl JIq3< xWvVfEii2(30r oX{[޼K@ f`@ !qq!`WUͰf<@,ĵa y1c+^f6> u_1[mW_3G/^1r=jŐjqqapz\Eš刖 r0@UfD ?;`~Z*$3,0o>FY12p O@~3h+13((gp "X9K l*(@QjlY_!@$ 1`OOFi ,@|F;0~>~co100p32 L=BL o?)`!X1! @Du8@/qe"2@MWpg`_}bՁy$ G{X]a3Ç'O>e66`+?'7#`$z_lKp} Ǐ_sAcW 7Ħ?h ~O=~2p r0l@`vYG1|pAr{Se`|بz9(pPA6"܄f ~ CY$$~.@a0IIQa3j*\e@=" X64Y!!Z#'&C?d(\101R ?0u PoCA$r3,@D@F=ǿ{d4<a|P,^]U7)x0CDl!@D99Yaǎ _aaVl/[|| 'Z1TUaغJ ZdP022S?DT!gwM3,A H#\@ H* L .]gG.-BͿ[#/ؼ;TÑ Ԃl($f@1P< Rb}(z &R - ޾}CyЦ)x xL>AeddY%-)ĘpmP'O< /7`jIPogj\QQ2Q`P r˝;w@v  p(Ӏ5/ 2vP @|%à i b5h 0y;V[\@?ih!ŜIJ@g0a ,IENDB`keepass2-2.25/Docs/Chm/help/images/b16x16_ktouch.png0000664000175000017500000000126712273660230021730 0ustar jtaylorjtaylorPNG  IHDRh6tRNS/lIDATxuKOQ{:tVHK&!ݸp傕#Q11DML1l\`@A )]:L\,x$Iη:@=lP!#aOlNJ$OwVzf-_?L5UZ^BZtmlopӟ>V+Ug?,U*e`./WƯԔ}nq}-_siIENDB`keepass2-2.25/Docs/Chm/help/images/b16x16_kdmconfig.png0000664000175000017500000000221412273660230022365 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb?Vn y9jꌿ^߲f[Od=^A á >g8S N.??~*DoJeacd`vAW_ZM+]bf_y\`Qo fxf%l+ºA'Grd@|ADMP e_~30z{'_Z3=']6cƛ3^d@A6'(0%> Vk 5/9ޡ#~Ma Ν`be abcc5Ϻ}G A @COE 5 EEX(Pޚѯ ;303|>AfQ@ͬ@=b3bgA5'1Q zt5(:vA  )%' Gp6YKVB |d)å?XX3s113H 2(jJ3(122g4]ۿE?3|c)+ "6 l< _O ~d b Ʈ|m'Wu}``02S8~] XϾ?ZW> g:`/\hˌnY# $Qp-O/o= F[I38b#1z ܜ LL g+k7o{8hP~C ladfſקw0 IENDB`keepass2-2.25/Docs/Chm/help/images/b64x64_winprops.png0000664000175000017500000001061512273660230022317 0ustar jtaylorjtaylorPNG  IHDR@@iqgAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb?H0@4 F| 2H[ &<<1 9 Fj1iP173ç3vπ~@,sy3j1|? L18*ՁYDhB2b WWo+F27 ~@heSNH[be,IɁ0qOQ1e3"a'샹n%&Íͻ| L @| >|9ûOlj,01V43`"Nŧ~(8bv PkoF&?fbkCVzb0 R1?> e @,Y BbWlJ%Xe!Y?L/F(0loh6DZ01n5!AGY$1$bZ${0&-?&&H@@aMp '0|z `(mPښ S? 78+#Z^bA1r(*`p[__\ر$@`gedQc +3<K@gK_NP2aš#2~CKHRꉉ^H P Q 445a1Ab ^ b ž` zvU~f1^ݸsӤD)CCdIXGDr 1GaU- U -8pAg2|A92/Y$O?R?R[2ц2#͝;nl^..)99gQII6`=#PݶUnϠ LȞ%K<)?" 06~ 4 |²e ccccPb(*ׯ =b L _`< 3XARC&!Rv9``d@ J/~f};k~ om0g.g`/ ٿ7o2f?>0H߿ŀs!'0[Q >yXψ k;/;0殮YpkNv^~ eW76.N@v00 [c\`@,;Kd;;B?R!Q 0>+< T 0|+`RO}4<0T ph&w <KP FD   |OϜ%9KKx`A.SJ 06(;pm`zyjсR  1ۼ@zJdyH00<}L̈@b0YX\`t?u/~ ,+Ą L O<?p#ېTt _E?AbahD 0 53;+<5a<FCĄ ,ok .~֏0@e_Q?c1 WDk`?f2"gPA$(880&ϯ^A%300@|Pu HI?4@)WZE hM?yŒۘGI}p [;ԾS`2e Giȃ_y`M<3?`?hl 7GCֆu lЬҰ ?FЌ0I??wA?(>^cXN.P6طO@g +AZFFi(?F^?P V@‚2 깁b) WUB 5 (Bi,iapgϞ1pB @`U x#Y-A77# >c:Au0(VYتí /0ty 3 VVH/-Dae`cxvLMj h}@a  <`49a`;G`7_ׯ}O7pg Dר`㉋Aѡ Zѱ?7 \#dx

S֛kW~{)1) D(4 Ap<QVV `*!F%du,##QXս' Og8 @[QZZ?}?(JM^ 4tu6<xD4rr%f]F`_ _}c{<×8~g0B߾c<ρeK(G]c`#_TA6 E -E0(I'PXk|Vcxw;7D$$tMl9'Wv`7Po`ࠖQB# Hhԋeرd1СФ by: _Y?{`@;Wk[v1C`- OP ڽU 'pC xDҐG1uuNc@O GtAA@t>ה30[j^ &E r O`?CbA9Lu@aN#w>YY!`AL[GB( v?~>x kfQcz` ; @Dx\@bb`2kPT-G"@o`@`L# "!,J%@ߠR{^<:~]T6` yY! Yi?~1,K`==#b`ccf`d-5/@Xgt<~|P3,IRF“8gXŒ1bc2th~ޣ 2dHp 30U- #kXo,Ǿ1%p6 l<h栯F^Ѝ_d |D%Z?73*q{b‰"e?lC6၃6ف8T}~ d @s{yZ;"Fp#\O6;!t9dx0@afPie a`2V/C|%Ó5|  sBPM8XcdG= > ~ @dl*.**@3)=h8Ј7@#>h@E*IENDB`keepass2-2.25/Docs/Chm/help/images/b16x16_kmultiple.png0000664000175000017500000000074712273660230022443 0ustar jtaylorjtaylorPNG  IHDRh6tRNS/IDATx}0/¿`*يhH)GUHh m;LGHiHA iTc֚B03I)jjxJhc2s8~7x<]5884M;JU~GeY;oߒ$N_p}Jq^0 ðnNf|<@D)%jRD*n<,ˈ"1/O(N`1Ɣ=~̸!HcLRiZJ$I|z"ʲ,MSt<(z}23"JӴK)2n1F)ffx_Z)SJ) VG$8\fy>70u$庘mol6KdIENDB`keepass2-2.25/Docs/Chm/help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.-1xS--{:"Vیy$3UCL4eF>?xMMjP\lIyaT{$IENDB`keepass2-2.25/Docs/Chm/help/images/b64x64_kcmsystem.png0000664000175000017500000001535412273660230022462 0ustar jtaylorjtaylorPNG  IHDR@@iqgAMA7tEXtSoftwareAdobe ImageReadyqe<~IDATxb?H0@4 X9tg6uL(3|߿  }} @e'j_ _z|/_>KHȀ/`؋  @I=Ĵ0琤X_|RoG_#}07͛ _?g5kܴi9ŋ @t .?c6YTTXeJ oɉIZ z)0)<7> \zWѣGqAUU`s##S={ x@t)@I\Spt{%0%iE;;BY))aVVF.yyp` _~h 2 A2`6K3Ƃ߿ fee;d`` P377dvvnn~ ¼hY7XAY΁mD,3prgjV6o߾ihh(*J3b߿ Xgf`./ȃcx%ûwe, pP15bPS[4,yIb~8KzzcbTW)**<,]G^[wU'##AFFADWnz l3|Z*@;0jKN&`۷֬YS:QQq%%`'%oPx3R2iA~pc`Ub(#ҥ g^[w1ׯX@d"?09-)2,X0sP**ZcA#/sOk` 9991/lHP`<XU0HJ T_`q.H`غo~ X3XX829Av^)44t D!eOXS߿p7o^f'iMM]G`6rVPPfVf~~`n`-fo0 ̀+  Đm n!@U '6cGMKz~0UH/߁'Wu̱\B1ߕ+֟;w;O3 e`J`/"U %%S]@Eoš !+o՚ 0D-Q`_PA`G^1|?8Y1|.)) nR5?woZ|N޵k>>zr~Akyyq7& R`@@@D2?O{bhI(l ;)See g` gP@u&@TC/66 7cYԪ~x!8XENLq::&:q606Fii}gwsԔ$L t`c TjZZ:e ݻw;8@e(5P |1؎6̀YO $?_ziǣGw޾ O PH; Hy %whSJm#t2ZF""|}J`7_ WP.## R!$b%mPij}XqՕΓ'w!l &M;7ϟ?~gV Іj'8l t0Sg!,`] ++쏫A-6Pgԕ=rμ $.0߼ylex.0;(5@QH? ll=9'Y 4GUUbZڡSMMWNMMe6RB?~f @8g +WΆpe8/C H-`)cP*@%=ȃ?Ο 1PKA6fieb ˝;7\>p [PDDX0((HBJAWރ#P Ҟw?gd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|w |ʗ{nYf^t ;u)~v_|ذuH>`m6sb ÃAU 4c $hM 0#ci B'1IO?0|zqA?Wx)`?ݻw'pQ`g6l @![=n g+Eׯ0z/1_B<3&`|pSܞAٓA\# ܼ< R " \,D?'dD Xg‌2h`h+xIhnTxzٳG&M{ 3™XY?Qߟܐ  @6088_C?&v^01f +Х44J3}"BVfJ?/3|<7pQL B@-L llYbКC&OtÆE@S pNe^ g"b 4AyA|?03`约 @kih3Fh~;O@s3 7 R|obJZbV` Z4H/ PX+/7(A ݿ7$XoX~fp)f=22X.q,oeb8 T} woxIBP Z}^).)<(fY_ ~bQR3d ̾vÊ_zd# 22z1>ޗYk> x@%?!p`l`b8Ǐ~rX?4TQTVVSWWgPc{ 4s 켁1J`X*p;B=h=;#4yIdxx4TMutt$̘%o޼z (xA>}z$޿?~+ȏl=C%٘V23JYZ1fwd7X~O@)h2B0h4[Z. FJJX )ͷo_=c ßoЮB kXF\l/p= hL 33ձϾI'%c@^L@, ] ̓?vd-_zkq(f<,|5:/~12 Kpۗ~:T~/@W_<C Up@ 1ߔ"@ak 22jZ11 01`W~ Iנy~P (X Y)tsh0o< ZR@Ɉ @#}8@PߎO-IENDB`keepass2-2.25/Docs/Chm/help/images/flageng_small.gif0000664000175000017500000000012612273660230022171 0ustar jtaylorjtaylorGIF89a , @/(*Hhܨc=II;keepass2-2.25/Docs/Chm/help/images/b64x64_chardevice.png0000664000175000017500000001213212273660230022527 0ustar jtaylorjtaylorPNG  IHDR@@iqgAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb?H0@4 F| ###D78K,A16q|zŀ<S,ϟG/_$ Fj?~(**fee,-- Br?0(#!Y?BFo߾2\vƍ˯~@@ l@wkiie3((( L3

jBJy@,X򆱌 3338ųfd(.. {i ++p)AA>`x && ~&{5D (5  O< =zkkkPKb@>|ݻ ?f wlNR–u@),--I']< ݏ?fx(P `Db!A>|<JV"jzD0'P) ,lrmX[^=@aņZ-, _\@$gAOE j@m gGQJ#h`z?Jk2 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keepass2-2.25/Docs/Chm/help/images/b16x16_blockdevice.png0000664000175000017500000000152012273660230022675 0ustar jtaylorjtaylorPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATxb?% (Ā)+44nI32F\< ɽsPE 20n{~K? 88&&IsL{{oebfbUYKj _ ϟ30{ 7gqv~pext-/@a{5D;Cs={a`*)~%90j T_ >@, ~}a^6{i2\޳a  fSC_Bs@OP ؀g8!2g-ow03,dcuC٫  /p30D&{aCIX 0׹22 0?YYr 230p00l<&jvDG20[Յ _dX>`byûL lߙa?@O @xD#Z0aㅿ | zsOA XBç 70nnVO_~1|şR ۟ .F; >WGt3N`-y&+2 W3Hsx^cR/C&{*$a w ?W@. dP@E= IENDB`keepass2-2.25/Docs/Chm/help/v2/0000775000175000017500000000000012273661064016000 5ustar jtaylorjtaylorkeepass2-2.25/Docs/Chm/help/v2/triggers.html0000664000175000017500000003431212273660230020511 0ustar jtaylorjtaylor Triggers - KeePass
Triggers

Triggers


Automate workflows using the trigger system.


Triggers  Trigger System Introduction

KeePass features a powerful event-condition-action trigger system. With this system, workflows can be automated. For example, you could define a trigger that automatically uploads your database to a backup server after saving the file locally.

A trigger starts to run when any of the specified events matches. When this happens, the conditions are checked. If all conditions are fulfilled, the actions of the trigger are performed. Actions are performed consecutively; if one action fails, typically the execution of the event is aborted (i.e. all following actions aren't performed).

A trigger must be both enabled and on in order to get executed. The enabled state is set by the user; a disabled trigger has no function. The on state is dependent on the state of the program. By enabling the 'Initially On' option, a trigger is on by default. If you enable the option 'Turn off after executing actions', the trigger will be off after running once. There are actions to turn triggers on and off, i.e. triggers can turn themselves and other triggers on and off, which allows to define a complex state-dependent system of triggers.

Note that most strings in the trigger system are Spr-compiled, i.e. placeholders, environment variables, etc. can be used.


Triggers  Events

  • Application initialized:
    This event occurs when KeePass has finished initializing, but didn't perform any main window automations (like opening a default database) yet.
    • Parameters: None.

  • Application started and ready:
    This event occurs when KeePass has started up, performed main window automations (like opening a default database) and is ready for user actions.
    • Parameters: None.

  • Application exit:
    This event occurs when KeePass is about to exit. Databases have been closed already, but resources (like fonts, ...) are still valid.
    • Parameters: None.

  • Opened database file:
    This event occurs right after a database file has been opened successfully.
    • File/URL: An optional event filter. If a filter is specified (i.e. something is entered in 'File/URL - Filter'), the trigger is only evaluated, if the filter matches the actual database file path. For example, if you enter F:\ as filter string and specify 'Starts with' as comparison method, the trigger will only be evaluated, if the database (that has just been opened) path starts with F:\.

  • Saving database file:
    This event occurs right before a database file is saved.
    • Parameters: See 'Opened database file' event.

  • Saved database file:
    This event occurs right after a database file has been saved successfully.
    • Parameters: See 'Opened database file' event.

  • Closing database file (before saving):
    This event occurs right before a database file is closed. It occurs before KeePass saves the database automatically or asks the user whether to save unsaved changes.
    • Parameters: See 'Opened database file' event.

  • Closing database file (after saving):
    This event occurs right before a database file is closed. The database file already was saved automatically or unsaved changes were saved/discarded depending on the user's choice.
    • Parameters: See 'Opened database file' event.

  • Copied entry data to clipboard:
    This event occurs when entry data (user name, password, ...) is copied to the Windows clipboard.
    • Value: An optional value (copied data) filter.

  • User interface state updated:
    This event occurs when KeePass has finished updating the state of the user interface (menus, toolbar, ...). The user interface state is updated after most user actions, like adding / editing / deleting entries and groups, etc.
    • Parameters: None.

  • Custom toolbar button clicked:
    This event occurs when the user clicks a custom toolbar button. Custom toolbar buttons can be added using the 'Add custom toolbar button' trigger action.
    • ID: ID of the toolbar button that must have been clicked (see action).

Triggers  Conditions

  • Environment variable:
    • Name: Name of the environment variable to check. The name must not be enclosed in percent (%) characters.
    • Value: The value that the specified environment variable must have for the condition to be true.

  • String:
    • String: A string (KeePass Spr-compiles this, i.e. you can e.g. use placeholders).
    • Value: The value that the specified, evaluated string must have for the condition to be true.

  • File exists:
    • File: The file that must exist in order for the condition to be true.

  • Remote host is reachable (ping):
    • Host: Host to send the ping to.

  • Active database has unsaved changes:
    Evaluates to true, if the active database (currently selected database tab in the main window) has unsaved changes.
    • Parameters: None.

Triggers  Actions

  • Execute command line / URL:
    The file/URL and arguments are parsed by the Spr engine before they are sent to the shell, i.e. generic and database-dependent placeholders can be used. If you want to use built-in shell commands, like COPY, please see: Executing Built-In Shell Commands.
    • File/URL: The string to be executed by the shell.
    • Arguments: Optional. If 'File/URL' points to an executable file, this string is sent to the executable as command line argument(s).
    • Wait for exit: If this option is checked, KeePass waits indefinitely for the started process to exit.

  • Change trigger on/off state:
    • Trigger name: Name of the target trigger whose on/off state should be changed. If this field is left empty, the target trigger is the current one.
    • New state: Specifies the new state of the target trigger.

  • Open database file:
    Open a KDBX database file (in a new tab). If the given database file is opened already, KeePass brings it to the foreground.
    • File/URL: Path of the database file to open. If it is an URL, the protocol (prefix) must be specified.
    • IO Connection - User Name / Password: Optional credentials that are used for connecting to the target file system (for example FTP account user name / password). These credentials are not used to decrypt the database.
    • Password / Key file / User account: Optional credentials that are used to decrypt the database file.

  • Save active database:
    Save the currently active database. This action always saves the database, even if there are no unsaved changes. To only save if there are unsaved changes, use the 'Active database has unsaved changes' trigger condition.
    • Parameters: None.

  • Synchronize active database with a file/URL:
    Synchronize the currently opened and active database with a file.
    • File/URL: Path of the database file to synchronize with. If it is an URL, the protocol (prefix) must be specified.
    • IO Connection - User Name / Password: Optional credentials that are used for connecting to the target file system (for example FTP account user name / password). These credentials are not used to decrypt the database.

  • Import into active database:
    Import a file into the currently opened and active database.
    • File/URL: Path of the source file to import. If it is an URL, the protocol (prefix) must be specified.
    • File format: Specifies the import format (see the import dialog for possible values).
    • Method: Specifies the behavior for groups/entries that exist in both the currently active database and the import file.
    • Password / Key file / User account: Optional credentials that are used to decrypt the import file, if required. If no credentials are specified, but the import file is encrypted, KeePass shows a key prompt dialog.

  • Export active database:
    Export the currently opened and active database to a file.
    • File/URL: Path of the target file to export to. If it is an URL, the protocol (prefix) must be specified.
    • File format: Specifies the export format (see the export dialog for possible values).

  • Close active database:
    Close the currently active database.
    • Parameters: None.

  • Activate database (select tab):
    • File/URL: Path of the database to activate. This may be a substring of the actual database path. For example, specifying MyDatabase would match a database C:\Documents\KeePass\MyDatabase.kdbx.

  • Wait:
    Wait for the specified amount of time.
    • Time span: Number of milliseconds to wait.

  • Perform global auto-type:
    Execute global auto-type (like pressing the global auto-type hot key).
    • Parameters: None.

  • Perform auto-type with selected entry:
    Executes auto-type with the currently selected entry as context.
    • Sequence: The keystroke sequence to send. If this field is empty, the default sequence is used.

  • Add custom toolbar button:
    Add a custom button to the toolbar in the main window.
    • ID: ID of the toolbar button (see the event handler).
    • Name: Text that is shown on the toolbar button.
    • Description: Text that is shown in the tooltip of the button.

  • Remove custom toolbar button:
    Remove a custom button from the toolbar in the main window.
    • ID: ID of the toolbar button (see the event handler).

Triggers  Examples

See the Trigger Examples page.

keepass2-2.25/Docs/Chm/help/v2/entry.html0000664000175000017500000001227512273660230020030 0ustar jtaylorjtaylor Entry Dialog - KeePass
VCard Document

Entry Dialog


Explains options in the entry dialog.

In this dialog you can edit properties of new and existing entries.


Info  General

On this tab page you can specify the main information about the account. Apart from filling in standard information (user name, password, etc.), you can also assign an Expiry Time. When this date is reached, the entry is automatically marked as expired (using a red X icon in the main window and showing the entry information using a striked-out font). The entry is not deleted when it expires.

By default, KeePass generates a secure, random password for new entries. You can freely replace this generated password with an own one or invoke the password generator again (using the button on the right of the 'Repeat Password' field) to generate a password having different properties. For details (including information how to disable automatically generated passwords), see Password Generator.

A standard user name for new entries can be specified in the database settings dialog.


Info  Advanced

On this tab page you can assign custom strings and file attachments to the entry.

Custom Strings:
Each entry can have an arbitrary amount of custom strings. These strings can hold any information of your choice (for example additional e-mail addresses, passwords, more URLs, etc.). The strings will be stored encrypted in the database (like all other database content).

To use the value of a custom field, you can right-click on the entry and select 'Copy Custom String', which is much easier than highlighting the data in the entry view and copying.

File Attachments / Binaries:
You can attach files to entries. The files will be imported into the KeePass database and associated with the entry. When importing files, KeePass does not delete the original source file! You need to delete them yourself, if you wish. File attachments are stored encrypted in the database (like all other database content).


Info  Auto-Type

On this page you can configure the auto-type behaviour for this entry. For more information, see the Auto-Type help page.


Reload Document  History

Each entry got its own history. Each time you change an entry, KeePass automatically creates a backup copy of the current, non-modified entry before saving the new values. These backup copies are listed on the History tab page. You can delete backup copies if you are sure that you won't need them anymore, or you can restore any of the backup copies.

keepass2-2.25/Docs/Chm/help/v2/policy.html0000664000175000017500000001324412273660230020163 0ustar jtaylorjtaylor Application Policy - KeePass
Settings

Application Policy


Details about the application policy system within KeePass.

Users  Help for Users

Application policy is a KeePass feature that enables administrators to prevent you from accidently compromising the security system of your company.

Operations like exporting password entries to non-encrypted files or printing for example can be prevented effectively using the application policy.

If you are using KeePass at home, you can ignore the application policy (everything allowed anyway) or reduce your rights using the policy yourself, in order to avoid accidental leakage of sensitive information.

In order to prevent changing the policy after it has been specified, it is recommended to use an enforced configuration file.


Administrator  Help for Administrators

KeePass can be installed on a network drive and a policy can be enforced (like not permitting users to print the password list).

The application policy enforcement is based on the mechanism how KeePass stores configuration settings. You first need to understand this method before you can continue creating a policy: Configuration.

A policy-enforcing KeePass installation looks like the following: the KeePass application files are stored on the network drive and all users are starting KeePass from this drive (i.e. they only have links to the executable on the network drive). By using an enforced configuration file on the network drive (remember that this file overrides all others), a policy can be enforced.

In order to create such an installation, follow these steps:

  1. Copy KeePass to a common network drive, which supports file permissions (like NTFS). All users must have access to it.
  2. Adjust the file permissions: allow users only to read and execute all KeePass files, don't allow write access.
  3. Adjust the file permissions for KeePass.exe: only Execute must be allowed, all other permissions should be disabled (including Read access).
  4. Start KeePass. Open the Options dialog, switch to the Policy tab and configure the policy. Exit KeePass.
  5. Rename the KeePass.config.xml file to KeePass.config.enforced.xml.

That's it. You created a policy that is enforced on all computers, including your own one (until you change the enforced configuration file on the network drive).


Locked  Policy Security

Recall what the policy mechanism looks like: KeePass and the configuration file are stored on the network drive. If you grant your users free access to the internet or allow them to insert CD-ROMs/DVDs/USB-Sticks, nothing prevents a user to download a fresh copy of KeePass and run it. In this case the policy isn't enforced, as the downloaded KeePass doesn't know anything of the enforced configuration file on the network drive.

Policy enforcement therefore only is effective if your users really use the KeePass version installed on the network drive.

keepass2-2.25/Docs/Chm/help/v2/setup.html0000664000175000017500000004400212273660230020020 0ustar jtaylorjtaylor Setup - KeePass
System

Installation / Portability


KeePass 2.x installation, uninstallation, portability and updates.

Setup  General information

When downloading KeePass, you have the choice between 3 different packages:

  • KeePass-2.xx-Setup.exe: An installer program for Windows.
  • KeePass-2.xx.zip: A KeePass ZIP package (portable version).
  • KeePass-2.xx-Source.zip: The source code.

The installer and the portable version are described in detail below.

The source code package contains everything you need to compile KeePass. It includes the C#/C++ source code and header files, resource files, sources for building the installer, etc.

Both installed and portable KeePass versions require a .NET framework, see the downloads page for details.

Updating KeePass:
When a new KeePass version has been released, you can update your existing KeePass installation, without losing any configuration settings. The steps are depending on which package you are using (installer or portable), see below.

Translations should also be updated when you install a new KeePass version. You can find the latest translation files here: KeePass Translations.


Setup  Installer program (KeePass-2.xx-Setup.exe file)

The KeePass development team provides an installer, which copies KeePass to your hard disk, creates shortcuts in the start menu and associates KDBX files with KeePass, if desired.

Additionally, KeePass is automatically configured to store its settings in the application data directory of the current user. This way multiple users can use one KeePass installation without overwriting each other's settings (each user has his own configuration file). The setup program must run with administrative rights, however KeePass runs fine without administrative rights once it is installed.

Installation:
To install KeePass, run the KeePass-2.xx-Setup.exe file and follow the wizard.

Updating:
Run the KeePass-2.xx-Setup.exe file. You do not need to uninstall the old version first. Your configuration options will not be lost.

Uninstallation:
In order to uninstall KeePass, run the uninstallation program, which is accessible by a shortcut in the start menu folder of KeePass, or in the program section of the system control panel. If you also want to remove your configuration settings, you need to delete the configuration file in the application data directory of your user profile, see Configuration.

Silent Installation:
The KeePass installer KeePass-2.xx-Setup.exe supports command line switches for silent installation, i.e. the program gets installed without asking the user for target directory or association options. The default settings of the installer are used.

The /SILENT command line switch performs a silent installation and shows a status dialog during the setup process. No questions will be asked though.

The /VERYSILENT command line switch performs a silent installation and does not show a status dialog during the setup process.

Destination Path:
The installer allows to choose the destination path to which KeePass is installed. However, when the installer detects an existing KeePass installation, it assumes that the user wants to perform an upgrade and thus doesn't display the destination path selection page; the old version will be overwritten by the new version. If you want to move an existing KeePass installation to a different path, first uninstall the old version; the installer of the new version will then display the destination path selection page again.

Options/Components:
The installation options/components are explained in detail here: What do the 2.x installation options/components mean in detail?.


Setup  Portable version (KeePass-2.xx.zip file)

The portable version can be carried around on portable devices (like USB sticks) and runs on any computer directly from the device, without any installation (provided that a .NET framework is installed). It doesn't store anything on your system (in contrast to the setup package, see above). KeePass doesn't create any new registry keys and it doesn't create any configuration files in your Windows or application data directory of your user profile.

Make sure that KeePass has write access to its application directory. Otherwise, if it doesn't have, it'll attempt to store the configuration options (nothing security-relevant though) into the application data directory of the currently logged on user. For more about that, see this page: Configuration.

Installation:
KeePass does not need to be installed. Just download the ZIP package, unpack it with your favorite ZIP program and KeePass is ready to be used. Copy it to a location of your choice (for example onto your USB stick); no additional configuration or installation is needed.

Updating:
Download the latest portable package of KeePass, unpack it and copy all new files over the old ones. Your configuration settings will not be lost (the settings are stored in the KeePass.config.xml file, which won't be overwritten, because KeePass ZIP packages don't include a KeePass.config.xml file).

Uninstallation:
Simply delete the KeePass folder. This will leave no trace of KeePass on your system.


Setup  Running KeePass under Mono (Linux, Mac OS X, BSD, ...)

In addition to Windows, KeePass 2.x runs fine under Mono, i.e. Linux, Mac OS X, BSD, etc.

Links to all supported packages can be found on the KeePass downloads page: http://keepass.info/download.html.

  • Debian/Ubuntu Linux:
    Install the keepass2 / KeePass 2.x for Debian/Ubuntu Linux package (e.g. using APT). A link to a page with more information about this package can be found on the downloads page.

  • OpenSUSE Linux:
    Install the keepass package (from the Mono community repository; link on the downloads page).

  • Mac OS X:
    Install the KeePass 2.x for Mac OS X package (link on the downloads page).

  • Other Unix-like systems:
    In order to run KeePass, follow these steps:
    1. Install Mono ≥ 2.6 (older versions will not work and are not supported). Depending on your platform, the packages to install are called mono-stable, MonoFramework, mono-devel or mono-2.0-devel; see the Mono project page, if you are unsure which packages to install.
    2. On some platforms, the Windows Forms implementation (System.Windows.Forms) is offered as a separate package. KeePass requires this package; so if you see one, install it, too.
    3. On some platforms, the Runtime namespace (System.Runtime) is offered as a separate package. KeePass requires this package; so if you see one, install it, too.
    4. If you want to use auto-type on Linux / Mac OS X / BSD / etc., you additionally need the xdotool package.
    5. Download the portable version of KeePass (file KeePass-2.xx.zip) and unpack it in a location of your choice.
    6. When being in the KeePass directory, run the command line "mono KeePass.exe". Alternatively, right-click onto the KeePass.exe file, choose "Open with Other Application" and type in mono as custom command.

    For the last step you might want to create a shortcut or shell script file with this command line (use an absolute path to KeePass.exe, if the shortcut / shell script file is in a different location).

    Clipboard:
    On some systems, Mono's clipboard routines don't work properly. In this case, install the xsel package. If xsel is installed, KeePass ≥ 2.20 uses this utility for clipboard operations.

    Global Auto-Type:
    In order to use global auto-type, you need to create an appropriate system-wide hot key. This only needs to be done manually once. KeePass performs global auto-type when it's invoked with the --auto-type command line option.

    Some examples how to create a system-wide hot key for global auto-type, for different operating systems:

    • KDE. On Linux systems with KDE, the hot key can be created in Computer -> System Settings -> Shortcuts and Gestures: in this dialog, go Edit -> New -> Global Shortcut -> Command/URL, specify the shortcut on the Trigger tab and enter
      mono /YourPathToKeePass/KeePass.exe --auto-type
      into the Command/URL field on the Action tab.
    • Ubuntu Linux ≥ 11.04 (Unity/GNOME). Open the dialog Keyboard Shortcuts in the system preferences, click the Add button, enter KeePass Auto-Type as name and
      mono /YourPathToKeePass/KeePass.exe --auto-type
      as command, then click [Apply]. Click on Disabled of the newly created item (such that the text 'New shortcut...' appears), press Ctrl+Alt+A, and close the dialog.
    • Ubuntu Linux ≤ 10.10 (GNOME).
      1. Press Alt-F2, enter gconf-editor and click [OK].
      2. Navigate to apps -> metacity -> keybinding_commands.
      3. Double-click one of the command_i items, enter
        mono /YourPathToKeePass/KeePass.exe --auto-type
        and click [OK].
      4. Click the global_keybindings node on the left.
      5. Double-click the appropriate run_command_i item (for example, when you've used command_5 in the previous steps, double-click run_command_5 now) and specify the hot key of your choice. For example, to use Ctrl+Alt+A as hot key, you'd enter <Control><Alt>a.

    Important: for global auto-type, the version of the xdotool package must be 2.20100818.3004 or higher! If your distribution only offers an older version, you can download and install the latest version of the package manually, see the xdotool website.


Setup  Portable KeePass using Mono

The approach below worked perfectly when this documentation was written. However, as this type of Mono installation is nowhere mentioned on the Mono website, it might stop working with a future Mono release.

Although almost all of today's PCs can run .NET applications (the .NET Framework is already preinstalled on Windows ≥ Vista, and for all major Linux / Mac OS X distributions Mono is available, which actually even is a dependency of the GNOME ≥ 2.16 desktop), you still might want to run KeePass 2.x on a PC without any .NET support, like an old Windows XP system where you don't have administrative rights to install the .NET Framework.

For such a situation, you can create a portable version of KeePass using Mono, which works on PCs without .NET. To do this, follow these steps (assuming a Windows PC):

  1. Download the latest portable ZIP package of KeePass 2.x (file KeePass-2.xx.zip). Unpack it to some location, e.g. a folder E:\KeePass on your USB stick.
  2. Download the latest Mono installer. Run it to locally install Mono on your current PC (e.g. on C:). KeePass doesn't require GTK+, GNOME or XSP, so you can disable the options for these during the installation.
  3. After installing Mono, copy the whole Mono application folder (e.g. C:\Program Files\Mono) to your USB stick, e.g. to E:\Mono.
  4. In order to simplify starting KeePass, create a batch file on your USB stick, e.g. E:\RunKeePass.bat. This batch file should run KeePass using the mono.exe application on the USB stick. For example, with the paths above, the content of the batch file would look like:
    START "" Mono\bin\mono.exe KeePass\KeePass.exe
    

In order to run KeePass on a PC without .NET support, simply plug in the USB stick and run the batch file.

The approach above should be seen as the very last possibility to run KeePass 2.x. Installing .NET support (either the .NET Framework or Mono) is highly recommended instead!

keepass2-2.25/Docs/Chm/help/v2/sync.html0000664000175000017500000001576312273660230017650 0ustar jtaylorjtaylor Synchronization - KeePass
Synchronization

Synchronization


Merge changes made in multiple copies of a database.

Help  Introduction and Requirements

KeePass 2.x features a powerful, built-in synchronization mechanism. Changes made in multiple copies of a database file can be merged safely.

After synchronizing two files A and B, both A and B are up-to-date (i.e. KeePass saves the merged data to both locations when performing a synchronization).

Requirements.

  • If the files to be synchronized are accessible via a protocol that KeePass supports by default (e.g. files on a local hard disk or a network share, FTP, HTTP/WebDAV, ..., see the page Loading/Saving From/To URL for details), then no plugins/extensions are required.
  • If one of the files to be synchronized should be accessed via SCP, SFTP or FTPS, you need the IOProtocolExt plugin, which adds support for these protocols to KeePass.
  • If one of the files to be synchronized is stored in an online storage (like e.g. Amazon's S3, DigitalBucket, ...), you need the KeeCloud or the KeePassSync plugin. Note that you do not need KeeCloud/KeePassSync in the other cases above (files on a local hard disk or network share, FTP, HTTP/WebDAV, SCP, SFTP, FTPS, ...).

Synchronization  Invoking a Synchronization

There are multiple ways how a synchronization can be invoked:

  • Manually. A synchronization can be started manually by navigating to 'File' -> 'Synchronize' and clicking 'Synchronize with File' or 'Synchronize with URL' (depending on whether the file to be synchronized with is stored on a local drive / network share or on a server accessible via an URL). If you've previously opened or synchronized with the target file, you can also simply point on 'Recent Files' (in the 'Synchronize' menu) and select the file. Manual synchronization is only possible when the currently opened database is a local file (files on a network share are here considered to be local files); when you've opened a file from a server using an URL, the 'Synchronize' menu is disabled.
  • Command 'Save'. When invoking the 'Save' command, KeePass checks whether the file on disk/server has been modified while you were editing it. If it has been modified, KeePass prompts whether you want to overwrite or synchronize with the file. Note this applies only to the 'Save' command, not the 'Save As' command. See the page Multi-User for details (section 'KeePass 2.x: Synchronize or Overwrite').
  • Triggers. In more complex situations you can use the synchronization trigger action. See the page Triggers for details.
  • Scripting. In order to perform a synchronization without opening KeePass, the synchronization command of KPScript can be used. See the KPScript help page Single Command Operations for details.

Synchronization  Technical Details

The synchronization algorithm is rather complex and it would take many pages to describe in detail how it's working. Developers interested in this can have a look into the KeePass source code. Here are the most important properties of the synchronization algorithm:

  • In order to decide which copy of an object is the latest one, KeePass mainly uses the last modification time of the object (which KeePass updates automatically each time the object is changed).
  • The synchronization is performed on entry level. This e.g. means that a combination of user name / password is always consistent (synchronization on field level will not be implemented, because combinations could become inconsistent with this).
  • In case of parallel updates and collisions, KeePass tries to store all information in an appropriate place. For example, when you have an entry E in a database A, make a copy B of A, change E in B, change E in A, and synchronize A and B, then E in A is treated as current and the changes made to E in B are stored as a history version of E (see tab 'History' in the entry dialog), i.e. the changes made in B aren't lost.
keepass2-2.25/Docs/Chm/help/v2/translation.html0000664000175000017500000000766612273660230021235 0ustar jtaylorjtaylor Translations - KeePass
Language

Installing Translations


How to install translations of KeePass 2.x.

Text  Installing User Interface Translations

To install a user interface translation, follow these steps:

  1. Download the translation file from the Translations page.
  2. Unpack the ZIP archive you just downloaded to some directory.
  3. Copy the <Language>.lngx file into the KeePass application directory (where KeePass.exe is located).
  4. Start KeePass. In the main menu, click 'View' - 'Change Language...'. In the dialog that opens, select your language. In the restarting prompt, click [Yes].

That's it! The user interface is now translated completely into your language!


Text  Additional Localized Content

For some languages (not for all) there is additional localized content available, like translated help files, tutorials, etc. All this content is available from the same page where the user interface translations are downloadable: Translations page.

If you'd like to create some translated content yourself, please first ask the KeePass team if the thing you're planning to create isn't in work already by someone else. If not, you'll make a lot of people very happy by creating translated content!

keepass2-2.25/Docs/Chm/help/v2/guioptions.html0000664000175000017500000000554012273660230021064 0ustar jtaylorjtaylor GUI Options - KeePass
System

GUI Options


Explains various Graphical User Interface (GUI) options.

Info  Dialog Banner Styles

KeePass supports various different dialog banner styles. These styles are independent from the operating system and can freely be used on all systems.

WinXP Login:
WinXP Login Style

WinVista Black:
WinVista Style

KeePass Win32:
Old KeePass Win32 Style

Blue Carbon:
Blue Carbon Style

keepass2-2.25/Docs/Chm/help/v2/version.html0000664000175000017500000000502212273660230020344 0ustar jtaylorjtaylor Compatibility - KeePass
System

Compatibility


Compatibility of KeePass editions.

KDBX files created by KeePass 2.x and KDB files created by KeePass 1.x are not compatible. KeePass 2.x supports a lot of features, which 1.x doesn't support, therefore these formats are incompatible.

But KeePass 2.x can import KDB files created by KeePass 1.x. For this, you need first need to create a new database in KeePass 2.x and import the 1.x database using 'File' -> 'Import'.

By 'File' -> 'Export', KeePass 2.x can also export data to 1.x KDB files. However note that not all 2.x fields are supported by 1.x (i.e. the export is lossy).

keepass2-2.25/Docs/Chm/help/v2/ioconnect.html0000664000175000017500000000673312273660230020652 0ustar jtaylorjtaylor Loading/Saving From/To URL - KeePass
Browsing

Loading/Saving From/To URL


KeePass can load/save databases from/to URLs.

In this dialog you can specify an URL, from/to which data is read/written.

By default, KeePass supports FTP, HTTP and WebDAV, but additional protocols might be available on your system (if specific providers are installed).

The IOProtocolExt plugin adds support for SCP, SFTP and FTPS.


Server  Example: Using FTP Server

In order to load/save your database from/to an FTP server, you first need to upload the database file to the server manually. This only needs to be done once.

Then start KeePass and go 'File' -> 'Open' -> 'Open URL...'. Enter the full database path on the server and don't forget the ftp:// prefix! This prefix is required, otherwise KeePass doesn't know which protocol to use. Enter the FTP credentials and click [OK]. KeePass will download the file and open it.

KeePass can remember the FTP credentials, if you wish. You can choose between remembering everything (user name and password), partially (user name only) and not remembering the credentials at all.

When you press the 'Save' button, KeePass will automatically upload the new database file to the server (same location as before, i.e. overwriting the previous one).

keepass2-2.25/Docs/Chm/help/v2/license.html0000664000175000017500000005366212273660230020316 0ustar jtaylorjtaylor License - KeePass
System

KeePass 2.x License


License terms of KeePass 2.x.

KeePass: Copyright © 2003-2014 Dominik Reichl.

The program is distributed under the terms of the GNU General Public License version 2 or later. The complete source code can be obtained from the Official KeePass Website.

GNU General Public License (copy from http://www.gnu.org/licenses/gpl.html):



GNU GENERAL PUBLIC LICENSE

Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble

The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too.

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.

We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.

Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and modification follow.

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.

1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.

You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.

2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:

a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.

In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.

3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:

a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.

If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.

4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.

5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.

6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.

7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.

It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.

This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.

8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.

9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.

10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.

NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.

one line to give the program's name and an idea of what it does.
Copyright (C) yyyy  name of author

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 Street, Fifth Floor, Boston, MA  02110-1301, USA.

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this when it starts in an interactive mode:

Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
type `show w'.  This is free software, and you are welcome
to redistribute it under certain conditions; type `show c'
for details.

The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:

Yoyodyne, Inc., hereby disclaims all copyright
interest in the program `Gnomovision'
(which makes passes at compilers) written
by James Hacker.

signature of Ty Coon, 1 April 1989
Ty Coon, President of Vice

This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License.


End GNU General Public License

Icon Theme

The icon theme used in KeePass has been created and is copyrighted by David Vignoni. For more information, see the Acknowledgements page.
keepass2-2.25/Docs/Chm/help/v2/autotype_obfuscation.html0000664000175000017500000002647212273660230023141 0ustar jtaylorjtaylor Two-Channel Auto-Type Obfuscation - KeePass
Auto-Type Icon

Two-Channel Auto-Type Obfuscation


Description of the Two-Channel Auto-Type Obfuscation feature in KeePass 2.x.

Text  Introduction: What is Two-Channel Auto-Type Obfuscation?

The Auto-Type feature of KeePass is very powerful: it sends simulated keypresses to other applications. This works with all Windows applications and for the target applications it's not possible to distinguish between real keypresses and the ones simulated by Auto-Type. This at the same time is the main disadvantage of Auto-Type, because keyloggers can eavesdrop the simulated keys. That's where Two-Channel Auto-Type Obfuscation (TCATO) comes into play.

TCATO makes standard keyloggers useless. It uses the Windows clipboard to transfer parts of the auto-typed text into the target application. Keyloggers can see the Ctrl-V presses, but do not log the actual contents pasted from the clipboard.

Clipboard spies don't work either, because only parts of the sensitive information is transferred on this way.

Anyway, it's not perfectly secure (and unfortunately cannot be made by theory). None of the currently available keyloggers or clipboard spies can eavesdrop an obfuscated auto-type process, but it is theoretically possible to write a dedicated spy application that specializes on logging obfuscated auto-type.


Text  When can Two-Channel Auto-Type Obfuscation be used?

TCATO cannot be used with all windows. The target window(s) must support clipboard operations and navigation within edit controls using arrow keys. Additionally, the target user interface must not contain automation features like jumping focus when maximum length of a text box is reached (as seen in registration number dialogs for example).

Rules of thumb:

  • Can be used in:
    • Browsers.
    • Windows programs with standard text boxes.
  • Can not be used in:
    • Console-based applications (interactive terminals, ...).

Because it doesn't work with all windows, it's an opt-in feature for each entry. You have to enable it explicitly on the 'Auto-Type' tab page in the 'Edit Entry' dialog.


Text  How to enable / configure Two-Channel Auto-Type Obfuscation?

All you need to do is to tick the checkbox "Two-channel auto-type obfuscation" of an entry ('Auto-Type' tab of the entry editing window); KeePass will do the rest.


Text  Technical Overview

Instead of simply sending simulated keypresses to the target application (as normal auto-type does), obfuscated auto-type does the following:

  • Enable clipboard event blocker.
  • Backup the current clipboard contents.
  • Intelligently split the text into parts.
  • For each part: check if the clipboard can be used.
    • If yes: Split it into two subparts (character-wise, like two flat intertwining combs). Copy/paste the first part, merge the rest by sending keypresses.
    • If no: Send it normally using simulated keypresses.
  • Restore previous clipboard contents.
  • Disable clipboard event blocker.

These steps are described in detail below.


Text  Clipboard Event Blocker

Because we are heavily using the clipboard, it is useful to block all current clipboard monitors. This means that no other applications will get notified when KeePass changes the clipboard.

For this, an invisible window is created and added to the top of the clipboard event handler chain. This window simply throws away all clipboard change messages it receives, practically blocking all other applications from receiving any events.


Text  Intelligently Splitting the Text

The text to be sent must first be split intelligently. Not all parts of the string can be sent using the clipboard: special key codes and key modifiers must be passed unchanged to the SendKeys function. For an example, have a look at the following string:

mymail@myprovider.com{TAB}MyTopSecretPassword{TAB} {TAB}{ENTER}

This is an example of a typical string sent by KeePass to another application. First it types the user's email address, then a tab, then the password, a tab, toggles a checkbox, another tab and finally presses the enter key. This sequence can be split into the following parts:

mymail@myprovider.com
{TAB}
MyTopSecretPassword
{TAB}
' ' (space)
{TAB}
{ENTER}

For each line, it is checked if the clipboard can be used. If the line contains a '{', '}', '(', ')', '+', '^', '%' or whitespace (space), it can only be sent by the SendKeys function directly. '+' for example presses the Shift key, it should not be copy/pasted as '+' character. Spaces can't be copy/pasted either, because they are usually used to toggle checkboxes.

In the example above, "mymail@myprovider.com" and "MyTopSecretPassword" can be sent using the clipboard.


Text  Splitting the Secrets

Let's transfer "mymail@myprovider.com" to the target application using the clipboard now. KeePass could simply copy it to the clipboard and send a Ctrl+V keypress to the target application, making it paste the clipboard contents. This would be perfectly secure against keyloggers because they only see the Ctrl+V keypress but not the actual contents pasted. But there's still a problem: a malicious application could monitor the clipboard based on time intervals (i.e. not using the events - we've blocked those). Although the duration of the complete copy/paste operation is only a few milliseconds, there's still a small chance that an attacker could get the data in the clipboard. Therefore, the secrets are split.

First, the secret string "mymail@myprovider.com" is randomly split character-wise into two parts like two flat intertwining combs:

 y  il m   o  d  .c
m ma  @ ypr vi er  om

The first string "yilmod.c" is now copied to the clipboard. The string sent by the SendKeys is now assembled as follows:

  • Begin with pasting from the clipboard: ^v.
  • Press the left arrow key n times, with n = length of the clipboard string.
  • Send the remaining characters and press the right arrow key to skip the ones that were already pasted from the clipboard.

In our example above, the key sequence would be assembled to:

^v{LEFT 8}m{RIGHT}ma{RIGHT}{RIGHT}@{RIGHT}ypr{RIGHT}vi{RIGHT}er{RIGHT}{RIGHT}om

This will first paste the clipboard contents, go to its start and fill in the remaining characters, building up the original string "mymail@myprovider.com".

The time in which the first string part remains in the clipboard is minimal. It is copied to the clipboard, pasted into the target application and immediately cleared. This process usually takes only a few milliseconds at maximum.

More about secret string splitting:
In the above example, the string "mymail@myprovider.com" was split and sent. If the string would be split differently each time, a malicious application could reassemble the string by capturing multiple auto-types and combining them. In order to prevent this, KeePass initializes the random number generator for splitting based on a hash of the string. This means that each string is split differently, but the partitions of a string are uniquely determined. So, by invoking auto-type multiple times, an attacker cannot reassemble the original string, because he always captures the same half part.

keepass2-2.25/Docs/Chm/help/v2/index.html0000664000175000017500000000043012273660230017764 0ustar jtaylorjtaylor Redirecting to KeePass Online Help Center...
keepass2-2.25/Docs/Chm/help/v2/plugins.html0000664000175000017500000001236012273660230020343 0ustar jtaylorjtaylor Plugins - KeePass
Settings

KeePass 2.x Plugins


Installation, uninstallation and security of KeePass plugins.

Plugin  Introduction

KeePass features a plugin framework. Plugins can provide additional functionality, like support of more file formats for import/export, network functionalities, backup features, etc.


Info  Online Resources

You can download the latest KeePass plugins (and their source code) from http://keepass.info/plugins.html.


Computer  Plugin Installation and Uninstallation

If the plugin doesn't provide explicit instructions how to install it, follow these steps:

  1. Download the plugin from the page above and unpack the ZIP file to a directory of your choice.
  2. Copy the unpacked plugin files into the KeePass directory (where the KeePass.exe is) or a subdirectory of it.
  3. Restart KeePass in order to load the new plugin.

In other words, to "install" a plugin you simply need to copy it somewhere into the KeePass directory.

To "uninstall" a plugin, delete the plugin files.


Locked  Security

What about the security of plugins? Can't malicious spyware plugins 'inject' themselves into KeePass?

If plugins can register themselves (i.e. have write access to the KeePass directory), they could also just replace the whole KeePass.exe. It's rather a problem of file access rights, not the plugin system.

If you worry about this, you can do the following:

  1. Install KeePass as administrator.
  2. Write-protect the KeePass directory. Nobody must have write access.
  3. Log on as normal user (with no administrator privileges).

This will solve the problem above. Since the KeePass directory is write-protected, no other program can copy files into it. KeePass requires the plugins to be in the application directory. Therefore, plugins cannot inject themselves anymore.


Computer  Plugin Cache

PLGX plugins are compiled and stored in a plugin cache directory on the user's system. This cache highly improves the startup performance of KeePass. Old files are normally deleted from the cache automatically (this can be disabled in the plugins dialog).

By default, the plugin cache is located in the user's application data directory. However, this can be overridden using the Application/PluginCachePath setting in the configuration file (this setting supports placeholders and environment variables). So, if you're for example using KeePass on a portable device and don't want the cache to be on the system, you could set the path to {APPDIR}\PluginCache.

keepass2-2.25/Docs/Chm/help/v2/xml_replace.html0000664000175000017500000002115512273660230021157 0ustar jtaylorjtaylor XML Replace - KeePass
People

XML Replace


About the XML replacement functionality.

Help  General Information

XML Replace is a powerful feature that modifies a database by manipulating its XML representation.

KeePass creates a KDBX XML DOM of the current database in memory, performs the operation specified by the user (e.g. remove nodes or replace text), tries to load the modified XML, and merges the current database with the modified database.

Warning This is a feature for experts. Use with caution!

A few links that might be helpful for working with XPath and regular expressions:

KeePass protects history entries; XML Replace cannot be used to modify these. Furthermore, any changes to database properties (database name/description, etc.) may be ignored.


Help  Usage Examples


Replace text in all entry titles and notes
Select nodes: //Entry/String[Key='Title' or Key='Notes']/Value
Action:Replace data
Data:Inner text
Find what:TheTextToFind
Replace with:TheReplacement
Within all entry titles and notes, this replaces all occurences of TheTextToFind by TheReplacement.

Replace all HTTP URLs by HTTPS URLs
Select nodes: //Entry/String[Key='URL']/Value
Action:Replace data
Data:Inner text
Find what:^http:
Replace with:https:
Regular expressions:Activated
Within all entry URL fields, this replaces all HTTP URLs by HTTPS URLs.

Replace group icons
Select nodes: //Group/IconID
Action:Replace data
Data:Inner text
Find what:^48$
Replace with:36
Regular expressions:Activated
This assigns the ZIP package icon to all groups that currently have a closed folder as icon.

All icon IDs can be found in the icon picker dialog.

Delete entry strings by name
Select nodes: //Entry/String[Key='TheName']
Action:Remove nodes
Removes all entry strings named TheName.

Delete entry attachments by name extension
Select nodes: //Entry/Binary[substring(Key, string-length(Key) - 3) = '.jpg']
Action:Remove nodes
Removes all entry attachments that have a name ending in '.jpg'.

The '3' in the node selection XPath expression is the length of '.jpg' - 1. If you'd e.g. want to search for attachments that have a name ending in '.abcde', you'd need to replace the '3' by '5'.

Reset background colors
Select nodes: //Entry/BackgroundColor
Action:Remove nodes
Sets the background color of all entries to the default (transparent/alternating).

Disable auto-type for entries with empty fields
Select nodes: //Entry/String[(Key='UserName' or Key='Password') and Value='']/../AutoType/Enabled
Action:Replace data
Data:Inner text
Find what:True
Replace with:False
Disables auto-type for all entries that have an empty user name field or an empty password field.
keepass2-2.25/Docs/Chm/help/v2/dbsettings.html0000664000175000017500000001545212273660230021035 0ustar jtaylorjtaylor Database Settings - KeePass
Settings

Database Settings


Describes the various database options.

On the database settings dialog, you can configure various database-related settings.


Info  General

On this tab page you can specify general things like the name of the database and a description. Additionally, you can set various defaults like a default user name for new entries (created in this database).


Info  Security Options

On this page you can specify various encryption-related settings. Only change this settings when you really know what you are doing.

Encryption Algorithm:
You can set the encryption algorithm, which is used to encrypt the database. All encryption algorithms offered by KeePass are well-known standard algorithms, regarded as very secure by the cryptography community. These standards are used by banks for example. All of the algorithms are unbroken; there is no "best" algorithm. If you don't know which algorithm to choose, use the Advanced Encryption Standard (AES, Rijndael) algorithm.

Key Transformation:
See Protection against Dictionary Attacks.

KeePass has a link button on this page to compute the number of key transformations your computer can do in 1 second. If you for example only want to wait 0.5 seconds, half the number resulted from the benchmark.


Info  Compression Options

KeePass databases can be compressed before being encrypted. Compression reduces the size of the database, but also slows down the database saving/loading process a bit.

It is recommended to use the GZip compression option. This algorithm is very fast (you won't notice any difference to saving the database without compression) and its compression rate is acceptable.

It is not recommended to save databases without compression.

On modern PCs, saving files with compression can actually be faster than saving without compression, because the compression process is performed by the CPU (which is very fast) and fewer data has to be transferred from/to the storage device. Especially when the device is slow (like saving to USB stick), compression can reduce the saving/loading time significantly.


Info  Templates

Templates are a great way to predefine often used user names or additional fields, or combinations of each.

  • A template is a normal KeePass entry with all required data already entered.
  • Templates must be kept in a single group.
  • Do not put real data entries in the template group.

First create a normal group in the main window and then set it as the templates group in 'File' -> 'Database Settings' -> tab 'Templates'.

In order to create a new entry based on a template in the templates group, click the drop-down arrow of the 'Add Entry' toolbar button and choose the template to be used.

keepass2-2.25/Docs/Chm/help/v2_dev/0000775000175000017500000000000012273661064016636 5ustar jtaylorjtaylorkeepass2-2.25/Docs/Chm/help/v2_dev/scr_kps_index.html0000664000175000017500000000724212273660230022356 0ustar jtaylorjtaylor KPS Script Files - KeePass
Console

KPS Script Files


How to use KPS script files to automate KeePass 2.x.

KPS script files are a lot more powerful than single command operations, but are also more complicated. You need to have heavy experience in C# programming and the KeePass 2.x internals. Within KPS files you can do everything that KeePass does.

What are KPS files?

KPS files are C# files that are loaded, compiled and executed by the KPScript.exe program. Within the script file, you got full access to the KeePass internals.

The main differences to "normal" C# files are:

  • No need for using directives.
  • No need to add a reference to the KeePass assembly.
  • No need to write a wrapper class. Simply start with Main(). The complete script file is embedded in a static class.

Here's the famous Hello World program as KPS script:

public static void Main()
{
	MessageService.ShowInfo("Hello World!");
}

For the most important namespaces, KPScript automatically adds using directives at the start of the file before compiling it. MessageService for example is located in KeePassLib.Utility, but as it's included automatically by KPScript, you can use it directly.


Executing a KPS file:

To run a KPS file, you simply pass it to KPScript:

KPScript.exe C:\KeePass\MyScriptFile.kps

It is important that the file extension is .kps, otherwise KPScript won't recognize the file and will interpret it as database for single command operations.

keepass2-2.25/Docs/Chm/help/v2_dev/plg_index.html0000664000175000017500000006144612273660230021502 0ustar jtaylorjtaylor Plugin Development - KeePass
Settings

Plugin Development


How to develop plugins for KeePass 2.x.

This documentation applies to KeePass 2.x plugins. 2.x plugins are fundamentally different from 1.x plugins. 1.x plugins cannot be loaded by KeePass 2.x.


Info  Requirements

Before you can start developing a KeePass plugin, you need the following prerequisites:


Info  Step-by-Step Tutorial

Start your favorite IDE and create a new C# Class Library project. In this tutorial the example plugin we're developing is called SamplePlugin. The first thing you need to do now is to add a reference to KeePass: go to the references dialog and select the KeePass.exe file. After you added the reference, the namespaces KeePass and KeePassLib should be available.

KeePass plugins all need to derive from a base KeePass plugin class (Plugin in the KeePass.Plugins namespace). By overriding methods of this class, you can customize the behaviour of your plugin.

A minimal plugin looks like this:

using System;
using System.Collections.Generic;

using KeePass.Plugins;

namespace SamplePlugin
{
	public sealed class SamplePluginExt : Plugin
	{
		private IPluginHost m_host = null;

		public override bool Initialize(IPluginHost host)
		{
			m_host = host;
			return true;
		}
	}
}

You can find a fully documented and extended version of this simple plugin on the KeePass plugins web page.

This plugin does exactly nothing, but it shows some important conventions already, which must be followed by all plugins:

  • The namespace must be named like the DLL file without extension. Our DLL file is named SamplePlugin.dll, therefore the namespace must be called SamplePlugin.
  • The main plugin class (which KeePass will instantiate when it loads your plugin) must be called exactly the same as the namespace plus "Ext". In this case: "SamplePlugin" + "Ext" = "SamplePluginExt".
  • The main plugin class must be derived from the KeePass.Plugins.Plugin base class.

The Initialize function is the most important one and you probably will always override it. In this function, you get an interface to the KeePass internals: an IPluginHost interface reference. By using this interface, you can access the KeePass main menu, the currently opened database, etc. The Initialize function is called immediately after KeePass loads your plugin. All initialization should be done in this function (not in the constructor of your plugin class!). If you successfully initialized everything, you must return true. If you return false, KeePass will immediately unload your plugin.

A second function that you will need very often is the Terminate function:

public override void Terminate()
{
}

This function is called shortly before KeePass unloads your plugin. You cannot abort this process (it's just a notification and your last chance to clean up all used resources, etc.). Immediately after you return from this function, KeePass can unload your plugin. It is highly recommended to free all resources in this function (not in the destructor of your plugin class!).

We're almost done! We now need to tell KeePass that our file is a KeePass plugin. This is done by editing the Version Information Block of the file. Open the file version editing dialog (in Visual Studio 2005: right-click onto the project name - 'Properties' - button 'Assembly Information'). All fields can be assigned freely except the Product Name field (for more information see Plugin Conventions). This field must be set to "KeePass Plugin" (without the quotes).

That's it! Now try to compile your plugin and copy the resulting DLL file into the KeePass directory. If you start KeePass and go to the plugins dialog, you should see your plugin in the list of loaded plugins!


Info  Common Operations

Adding Menu Items:

Very often you want to add some menu items for your plugin. When clicked by the user, your plugin should get some notification. This can be done like follows. First of all you need to get a reference to the KeePass main menu or one of the special submenus (like Import, Tools, etc.). For this you can use the IPluginHost interface, which you received in the Initialize function. Then you can use standard tool strip operations to add a new menu item for your plugin. A very simple example, which adds a menu item to the Tools menu:

private ToolStripSeparator m_tsSeparator = null;
private ToolStripMenuItem m_tsmiMenuItem = null;

public override bool Initialize(IPluginHost host)
{
	m_host = host;

	// Get a reference to the 'Tools' menu item container
	ToolStripItemCollection tsMenu = m_host.MainWindow.ToolsMenu.DropDownItems;

	// Add a separator at the bottom
	m_tsSeparator = new ToolStripSeparator();
	tsMenu.Add(m_tsSeparator);

	// Add menu item 'Do Something'
	m_tsmiMenuItem = new ToolStripMenuItem();
	m_tsmiMenuItem.Text = "Do Something";
	m_tsmiMenuItem.Click += this.OnMenuDoSomething;
	tsMenu.Add(m_tsmiMenuItem);
}

public override void Terminate()
{
	// Remove all of our menu items
	ToolStripItemCollection tsMenu = m_host.MainWindow.ToolsMenu.DropDownItems;
	m_tsmiMenuItem.Click -= this.OnMenuDoSomething;
	tsMenu.Remove(m_tsmiMenuItem);
	tsMenu.Remove(m_tsSeparator);
}

private void OnMenuDoSomething(object sender, EventArgs e)
{
	// Called when the menu item is clicked
}

If you are working with tool strips, you of course have to add a reference to System.Windows.Forms of the .NET framework.

It is highly recommended that you unlink all event handlers and remove all menu items created by your plugin in the Terminate function (as shown in the example above). After the Terminate function has been called, everything should look like before loading your plugin.

In the example, we created a separator and one menu item. To this menu item an event handler for the Click event is attached. There's nothing special, this is all standard Windows.Forms code.

For examples of adding popup menus, see the SamplePlugin sample plugin (obtainable from the KeePass plugins page).


Adding Groups and Entries:

For this, see the sample plugin and the KeePassLib documentation.


Info  Plugin Conventions

File Version Information Block:

KeePass uses the file version information block to detect if a DLL file is a KeePass plugin and retrieves information from it to show in the plugins dialog. The fields are used as follows:

  • Title: Should contain the full name of the plugin.
  • Description: Should contain a short description (not more than 5 lines) of your plugin.
  • Company: Should contain the author name of the plugin.
  • Product Name: Must be set to "KeePass Plugin" (without the quotes).
  • Copyright: Not used by KeePass; freely assignable by the plugin.
  • Trademarks: Not used by KeePass; freely assignable by the plugin.
  • Assembly Version: Should be set to the version of your plugin.
  • File Version: Should be set to the version of your plugin. It is up to you how you are versioning your plugin builds, but it should be a scheme that allows version comparisons (by comparing the version components). Do not use asterisks for creating a version number at build time.
  • GUID: Not used by KeePass; freely assignable by the plugin.

Namespace and Class Naming:

The namespace must be named like the DLL file without extension. For example, if the DLL file is named SecretImporter.dll, you must call the namespace SecretImporter.

The plugin class must be named like the namespace plus "Ext". For the SecretImporter plugin, this would be SecretImporterExt.


Exchange  Update Checking

The update check of KeePass ≥ 2.18 can also check for plugin updates. Update check support is optional; plugins don't have to support update checks.

In order to support update checks, plugin developers need to do the following:

  • Provide version information file. When an end-user invokes an update check, KeePass downloads a version information file, which specifies the current version numbers of one or more plugins. Every plugin author hosts an own version information file. The format of the version information file is described in detail below.
  • Let KeePass know. In order to be able to check the plugin's version, KeePass must know where your version information file is located. To let KeePass know, override the UpdateUrl string property of your plugin class (the one derived from Plugin) to return the full, absolute URL of your version information file. This should be an http:// URL, but an ftp:// URL is also acceptable.

Plugin developers have to update their version information file each time they release new versions of their plugins.

Version information file format.

  • The file is a simple text file. It must be encoded using UTF-8 without a byte order mark (KeePass ≥ 2.21 supports UTF-8 BOMs in version information files, however for compatibility with KeePass < 2.21 it is recommended not to use a BOM). All line endings are supported.
  • The first line of the file must start with a separator character of your choice. The separator character may be any character, but it must not appear within plugin names and versions. Suggested is ':'.
  • Each of the following lines specifies a plugin name and its currently available version, separated by the separator character that was specified in the header line.
  • As plugin name, the value of the 'Title' field in the version information block of the plugin must be specified. For managed plugins, this is the value specified using the AssemblyTitle assembly attribute.
  • As version number, the value of the file version in the version information block of the plugin must be specified. For managed plugins, this is the value specified using the AssemblyFileVersion assembly attribute. Trailing .0 may be removed (e.g. specify 1.3 instead of 1.3.0.0).
  • The file must end with a line containing only the separator character.
  • You may optionally compress your version information file using GZip (note this is not the same as Zip). The file name must then end with ".gz".

Example. Let's assume you're developing two plugins: MyPlugin1 (version 1.5) and MyPlugin2 (version 1.13.2.17). Then your version information file could look as follows:

:
MyPlugin1:1.5
MyPlugin2:1.13.2.17
:

If you've developed multiple plugins, it is recommended to create one version information file, list all your plugins in this file and specify the URL of the file in all your plugins. When KeePass checks for updates, it'll download your version information file only once. This reduces network traffic and is faster than downloading a version information file for every plugin separately.


Info  Can KeePass 2.x Plugins be written in Unmanaged C++?

Yes and no. You can write the complete logic of your plugin in unmanaged C++ (native Win32 APIs can be used). Anyway you must provide a managed interface to your plugin, i.e. you must export a managed class derived from the Plugin base class as described in the step-by-step tutorial.

Also, managed C++ will be required to modify the KeePass internals (i.e. entries, groups, main window, ...).

For an example how to use unmanaged APIs in a managed C++ plugin assembly, see the SamplePluginCpp sample plugin (obtainable from the KeePass plugins page).


Info  PLGX Files

PLGX is an optional plugin file format for KeePass ≥ 2.09. Instead of compiling your plugin to a DLL assembly, the plugin source code files can be packed into a PLGX file and KeePass will compile the plugin itself when loading it. The advantage of this approach is that plugins don't need to be recompiled by the plugin developers for each KeePass release anymore (as KeePass compiles the plugin itself, the generated plugin assembly references the current, correct KeePass assembly). Instead of shipping a plugin DLL assembly, you ship the PLGX.

For users, nothing changes. Instead of putting the plugin DLL assembly into the KeePass application directory, the PLGX file needs to be put there.

KeePass ≥ 2.14 also loads older plugin DLLs. However, an API within KeePass might have changed and .NET detects this when the plugin tries to call/access the method/class, not at loading time. This means that an incompatibility is detected relatively late and might crash KeePass. In contrast, when using the PLGX format, an incompatibility is detected immediately at loading time: if there is a problem, the compile process will just fail and KeePass can present an informative plugin incompatibility message to the user. Therefore, it is recommended that plugin developers create/ship PLGX files, not DLLs.

Creating PLGX files. PLGX files can be created from plugin sources by calling KeePass.exe with the --plgx-create command line parameter. If you additionally pass a path to the plugin sources directory (without terminating separator), KeePass will use this one; otherwise it'll show a folder browser dialog to allow you selecting the directory. If you want to pass the directory location using the command line, make sure that you're specifying a full, absolute path -- relative paths will not work.

In order to keep the size of the PLGX file small, it is recommended that you clean up the plugin sources directory before compiling the PLGX. Remove all unnecessary binary files (files in the bin and obj directory); especially, delete any plugin assembly DLL that you compiled yourself. Temporary files by the IDE (like .suo and .user files) can also be deleted.

PLGX features:

  • Extensible, object-oriented file format.
  • Compression support (data files are compressed using GZip).
  • .csproj support. KeePass retrieves all information required for compiling the plugin assembly from the .csproj file in the plugin sources.
  • Embedded resources support.
  • Referenced .NET assemblies support. References information is read from the .csproj file.
  • Referenced custom assemblies support. Third-party assemblies required by the plugin (references to DLLs) are supported, provided that the third-party assembly is located in the plugin source code directory (or any subdirectory of it).
  • ResX support. .resx files are automatically compiled to binary .resources files.
  • .NET 3.5 support (if the default compiler, which is the one of .NET 2.0, can't compile the code, KeePass tries using the .NET 3.5 compiler).
  • PLGX cache. PLGX files are compiled once and the generated assembly is stored in a cache. For all following KeePass starts, no compiling is required.
  • PLGX cache maintenance. The size of the PLGX cache can be seen in the KeePass plugins dialog. Here, the cache can also be marked to be cleared (it will be cleared when KeePass is started the next time). An option to automatically delete old files from the cache is supported and enabled by default.

PLGX limitations:

  • Currently only C# is supported (not Visual Basic or any other .NET language).
  • Linked resources (in different assemblies) are unsupported.
  • Dependencies on other projects are unsupported (reorganize your project to use custom assembly references instead).

Defining prerequisites. You can optionally specify a minimum KeePass version, a minimum installed .NET Framework, an operating system and the minimum size of a pointer (x86 vs. x64) using the --plgx-prereq-kp:, --plgx-prereq-net:, --plgx-prereq-os: and --plgx-prereq-ptr: command line options. If one of the plugin prerequisites isn't met, KeePass shows a detailed error message to the end-user (instead of a generic plugin incompatibility message). Build example:
KeePass.exe --plgx-create C:\YourPluginDir --plgx-prereq-kp:2.09 --plgx-prereq-net:3.5

Valid operating system values are Windows and Unix. When running on an unknown operating system, KeePass defaults to Windows. Pointer sizes (checking for x86 vs. x64) are specified in bytes; for example, to only allow running on x64, you specify --plgx-prereq-ptr:8.

Build commands. Optionally you can specify pre-build and post-build commands using --plgx-build-pre: and --plgx-build-post:. These commands are embedded in the PLGX file and executed when compiling the plugin on the end-user's system.

In the build commands, the placeholder {PLGX_TEMP_DIR} specifies the temporary directory (including a terminating separator), to which the files were extracted. In the post-build command, {PLGX_CACHE_DIR} is replaced by the cache directory of the plugin (including a terminating separator), into which the generated assembly was stored.

These build commands can for example be used to copy additional files into the cache directory. Example:
KeePass.exe --plgx-create C:\YourPluginDir --plgx-build-post:"cmd /c COPY """{PLGX_TEMP_DIR}MyFile.txt""" """{PLGX_CACHE_DIR}MyFile.txt""""

In order to specify a quote character on the command line, it has to be encoded using three quotes (this is Windows standard, see MSDN: SHELLEXECUTEINFO). So, the command line above will actually embed the post-build command cmd /c COPY "{PLGX_TEMP_DIR}MyFile.txt" "{PLGX_CACHE_DIR}MyFile.txt" into the PLGX, which is correct. It is highly recommended to surround paths including PLGX placeholders using quotes, otherwise the command will not run correctly if the path contains a space character (which happens very often).

If you need to run multiple commands, write them into a batch file and execute it (with cmd). If you need to perform more complex build tasks, write an own building executable and run it using the build commands (typically it is useful to pass the directory locations as arguments to your building executable), for example:
KeePass.exe --plgx-create C:\YourPluginDir --plgx-build-post:"{PLGX_TEMP_DIR}MyBuild.exe {PLGX_TEMP_DIR} {PLGX_CACHE_DIR}"

keepass2-2.25/Docs/Chm/help/v2_dev/scr_index.html0000664000175000017500000000655612273660230021510 0ustar jtaylorjtaylor Scripting Introduction - KeePass
Console

Scripting KeePass (2.x)


How to automate database operations in KeePass 2.x.

Prerequisites:

In order to automate KeePass, you need the KPScript plugin/extension. You can find the latest version of KPScript on the KeePass plugins web page. The KPScript.exe file needs to be copied into the directory where KeePass is installed (where the KeePass.exe file is).


There are two ways to automate KeePass: single command operations and KPS script files.

  • Single Command Operations: KPScript can be invoked using single commands. By passing the database location, its key, a command and eventually some parameters, simple operations like adding an entry can be performed. The syntax is very simple, no scripting knowledge is required. This method is ideal when you quickly want to do some small changes to the database. It is not recommended when you need to perform many operations, because for each command the database needs to be loaded from file, decrypted, modified, encrypted and written back to file.

  • KPS Script Files: These files are a lot more powerful than single command operations, but are also more complicated. You need to have heavy experience in C# programming and the KeePass 2.x internals. Within KPS files you can do everything that KeePass does.
keepass2-2.25/Docs/Chm/help/v2_dev/scr_sc_index.html0000664000175000017500000003103112273660230022157 0ustar jtaylorjtaylor Single Command Operations - KeePass
Console

Single Command Operations


How to use KPScript with single command operations to perform simple database operations.

KPScript can be invoked using single commands. By passing the database location, its key, a command and eventually some parameters, simple operations like adding an entry can be performed. The syntax is very simple, no scripting knowledge is required. This method is ideal when you quickly want to do some small changes to the database. It is not recommended when you need to perform many operations, because for each command the database needs to be loaded from file, decrypted, modified, encrypted and written back to file.

Commands are specified by passing -c:COMMAND to KPScript, where COMMAND is the command to execute (see below for a list of available commands).

The database location is passed to KPScript by just passing it as a parameter, without any option prefix.

The composite key for the database can be given to KPScript using one of the following ways:

  • Command Line Parameters.. Using the -pw:, -keyfile: and -useraccount parameters. For example, to pass "Secret" as password, you'd give KPScript the following parameter: -pw:Secret. If the password contains spaces or other special characters, it must be enclosed in quotes: -pw:"My Top Secret Password". Similarly, the -keyfile: parameter can specify the key file location. If -useraccount is passed to KPScript, the user account credentials of the currently logged on user are used, otherwise not.

  • Entering interactively using the command line. If you pass -keyprompt to KPScript, it will prompt you for the key. You can enter the password, key file location and user account directly in the console window.

  • Entering interactively using graphical user interface. If you pass -guikeyprompt to KPScript, it will prompt you for the key using the standard key dialog of KeePass.

Available Commands:

Please note that commands are added incrementally based on user requests. If you are missing a command, please let the KeePass team know and it will be added to the next release of KPScript.

Currently, the following commands are available:

  • ListGroups
  • ListEntries
  • GetEntryString
  • AddEntry
  • EditEntry
  • MoveEntry
  • DeleteEntry
  • DeleteAllEntries
  • Import
  • Export
  • Sync
  • ChangeMasterKey
  • DetachBins
  • GenPw

Command: ListGroups

This command lists all groups in a format that easily machine-readable. The output is not intended to be printed/used directly. Usage example:

KPScript -c:ListGroups "C:\KeePass\MyDb.kdbx" -pw:MyPassword
This will list all groups contained in the MyDb.kdbx database file.


Command: ListEntries

This command lists all entries in a format that easily machine-readable. The output is not intended to be printed/used directly. Usage example:

KPScript -c:ListEntries "C:\KeePass\MyDb.kdbx" -pw:MyPassword -keyfile:"C:\KeePass\MyDb.key"
Opens the MyDb.kdbx database using 'MyPassword' as password and the MyDb.key file as key file. It will output a list of all entries contained in the MyDb.kdbx database file.


Command: GetEntryString

Retrieves the value of an entry string field. The entry identification syntax is exactly the same as in the EditEntry command. The field name can be specified using the '-Field' parameter (supported field names are e.g. Title, UserName, Password, URL, Notes, etc.). Usage example:

KPScript -c:GetEntryString "C:\KeePass\MyDb.kdbx" -pw:MyPassword -Field:UserName -ref-Title:"Demo Account"
Opens the MyDb.kdbx database using 'MyPassword' as password. It outputs the user names of all entries that have the title "Demo Account".


Command: AddEntry

This command adds an entry to the database. To specify the entry details, use the standard string field identifiers as parameter names and their values for the contents. Supported standard string fields are: Title, UserName, Password, URL, and Notes. Usage examples:

KPScript -c:AddEntry "C:\KeePass\MyDb.kdbx" -pw:MyPw -Title:"New entry title"

KPScript -c:AddEntry "C:\KeePass\MyDb.kdbx" -pw:MyPw -Title:SomeWebsite -UserName:Don -Password:pao5j3eg -URL:http://website.com

The -GroupName: parameter can be used to specify the group in which the entry is created. For searching, KPScript performs a pre-order traversal and uses the first matching group (the name is case-sensitive). If no group with the specified name is found, it will be created in the root group. If you do not specify a group name, the entry will be created in the root group. Example:

KPScript -c:AddEntry "C:\KeePass\MyDb.kdbx" -pw:MyPw -Title:"My Provider" -GroupName:"Internet Sites"


Command: EditEntry

This command edits existing entries.

To identify the entries to be edited, string fields can be compared. The syntax is -ref-FIELDNAME:FIELDVALUE. Additionally to comparing string fields, some other entry fields can be compared. -refx-UUID: can be used to specify the UUID. -refx-Tags: can be used to specify tags (multiple tags must be separated using commas ',').

To specify one or more new entry string values, use the following syntax: -set-FIELDNAME:FIELDVALUE.

Usage examples:

KPScript -c:EditEntry "C:\KeePass\MyDb.kdbx" -pw:MyPw -ref-Title:"Existing entry title" -set-UserName:"New user name"

KPScript -c:EditEntry "C:\KeePass\MyDb.kdbx" -pw:MyPw -ref-UserName:MyName -set-UserName:NewName -set-Password:"Top Secret"

If you additionally pass -CreateBackup, KPScript will first create backups of entries before modifying them.


Command: MoveEntry

This command moves one or more existing entries. The entry identification syntax is exactly the same as in the EditEntry command.

The target group can be specified using the GroupTree parameter. '/' must be used as separator (e.g. -GroupTree:Internet/eMail moves the specified entries to the subgroup 'eMail' of the subgroup 'Internet').


Command: DeleteEntry

This command deletes one or more existing entries. The entry identification syntax is exactly the same as in the EditEntry command.


Command: DeleteAllEntries

This command deletes all entries (in all subgroups).


Command: Import

This command imports a file into the database. The format is specified by setting the "-Format" parameter (see names in the import dialog of KeePass). The file to import to is specified using the "-File" parameter.

The behavior for groups/entries that exist in both the current database and the import file can be specified using the optional "-MM" parameter. Possible values are "CreateNewUuids", "KeepExisting", "OverwriteExisting", "OverwriteIfNewer", and "Sync". By default, new UUIDs are created.

Usage example:

KPScript -c:Import "C:\KeePass\MyDb.kdbx" -pw:MyPw -Format:"KeePass XML (2.x)" -File:SourceFile.xml


Command: Export

This command exports the complete database. The format is specified by setting the "-Format" parameter (see names in the export dialog of KeePass). The file to export to is specified using the "-OutFile" parameter. Usage example:

KPScript -c:Export "C:\KeePass\MyDb.kdbx" -pw:MyPw -Format:"KeePass XML (2.x)" -OutFile:TargetFile.xml


Command: Sync

This command synchronizes the database with another one. The other database path has to be specified using the "-File" command line parameter. Usage example:

KPScript -c:Sync -guikeyprompt "C:\Path\A.kdbx" -File:"C:\Path\B.kdbx"


Command: ChangeMasterKey

This command changes the master key of the database. The new key values are specified using the standard options prefixed with 'new', i.e. -newpw:, -newkeyfile: and -newuseraccount (all are optional). Usage example:

KPScript -c:ChangeMasterKey "C:\KeePass\MyDb.kdbx" -pw:MyPw -newpw:MyNewPw


Command: DetachBins

This command saves all entry attachments (into the directory of the database) and removes them from the database. Usage example:

KPScript -c:DetachBins -guikeyprompt "C:\KeePass\MyDb.kdbx"


Command: GenPw

Generates passwords. The number of passwords can be specified using the optional -count: parameter. A password generator profile can be specified using the optional -profile: parameter (the names of all available profiles can be found in the password generator dialog). Usage examples:

KPScript -c:GenPw
Generates one password using the default generator profile.

KPScript -c:GenPw -count:5 -profile:"128-Bit Hex Key (built-in)"
Generates five 128-bit hex passwords (when no translation is used).


Help  Console Character Encoding

If you observe garbled special characters in the output, please read the page Console Character Encoding.

keepass2-2.25/Docs/Chm/help/v2_dev/customize.html0000664000175000017500000001316212273660230021543 0ustar jtaylorjtaylor Customization (2.x) - KeePass
Help

Customization (2.x)


KeePass 2.x features various options for network administrators to customize the program's appearance and behavior.

System  Preliminaries

Most options below are configured by directly editing the KeePass.config.xml configuration file. If you're planning to deploy a customized KeePass version, you should fully understand the KeePass configuration system, especially how to enforce some settings and leave others up to users.

Note that KeePass features a rich plugin framework. If there's no item in the XML file to configure what you're thinking about, you might want to write a plugin.


Key  Minimum Master Password Requirements

You can specify several properties that master passwords must have in order to be accepted (length, estimated quality, ...). See Specifying Minimum Master Password Properties.


Locked  Specifying UI Element States

The state (enabled, disabled, visible, hidden) of several user interface (UI) elements can be specified using the UIFlags value of the UI node in the configuration file. This can be a bitwise combination of one or more of the following flags:

Flag (Hex)Flag (Dec) Description
0x00 Don't force any states (default).
0x11 Disable 'Tools' -> 'Options' menu item.
0x22 Disable 'Tools' -> 'Plugins' menu item.
0x44 Disable 'Tools' -> 'Triggers' menu item.
0x88 Disable controls to specify after how many days the master key should/must be changed.
0x1000065536 Hide built-in profiles in the password generator context menu of the entry editing dialog.
0x20000131072 Show UI elements related to last access times.
Note: Databases are not marked as modified when a last access time changes. Thus, when only last access times are changed and the user closes the database (without saving manually first and without a save forced e.g. by a trigger or plugin), the changes to the last access times are lost.
Requirements: This flag is supported by KeePass 2.25 and higher.

The value of UIFlags must be specified in decimal notation.

For example, if you want to disable the 'Options' and 'Plugins' items in the 'Tools' menu, you'd specify 3 as value for the UIFlags node (0x1 + 0x2 = 0x3 = 3).

keepass2-2.25/Docs/Chm/screenshots/0000775000175000017500000000000012273661064017061 5ustar jtaylorjtaylorkeepass2-2.25/Docs/Chm/screenshots/keepass_2x/0000775000175000017500000000000012273661064021125 5ustar jtaylorjtaylorkeepass2-2.25/Docs/Chm/screenshots/keepass_2x/gencsvimp.png0000664000175000017500000004577712273660230023644 0ustar jtaylorjtaylorPNG  IHDR,f] pHYs B(x IDATxwxǕ{'c" g`bDɔlYE ږ~~{~7\uXQ$Q(Z(&1  Hȉ3`rz`"QIfz:TWsS&F   ӀyQw&xB"B%~ߛA"JD¥% zC g!!=޹JX1^u3sZߠ^1|X'ߊ-?@ 9ۘnznB[src@9+"7772}?~_?gHD* !}E2$ @`G y$a &` ! B07A/K%z <$JƒDC#eDT.B8y8oF&EQ8X!R42 w 0dpC6/(Klz!@<UB݋n师6 hqBtX.?P<8`޴*HvD]%\`D @$am8w (0DLO(")U*yN98q^4XAҊ /tL.IX"`LPTe/,t!-Z`(?D@EBO`+>#0G8 @L:p8BdG-!0ÀA#LT"4ҺC4FE#<A Q%!AC( BqA!8R]TiJC`o X;a @`v 9t>&0B"  @@"pDQN Q0 vW2Y:ҲrLe qBdp  kҐLa(1ƘH_~#2-BZRx}xyχlW2 "lf>0BFA>n!  BV4 xG)#0iOmMLUƀPR# B ?S *BB T *|pB B8\PJ9MG5jF,h`)؊R uInrQ!hcYKn{j  x> I &E3m}s -\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,X"ja$dp Fк ggviroD9ƛi^ Ȩuƹ lU?6y%[)UdŐu9A;kơg]cUbL=c*L8W̊vq7RM|v-a0b\&ɘ"BH:lA:g\"b?:_Fƈb$嘑Bz#Q˩AQ0!3(a@܏`\өjc8O7yu§9$Iu]"!*] M8')뎆MU_S4.i Do$)T-ʣr}̜~Nʽ-G^5IOR تm/௘td*1m9g{C2{ ǭBn@shܡ|; h|@ӹꯣcCv~7@aڗ \A5P(q+ ,W?c+ZVmåaҽ)N1C #3jFmDe6eSh^] ?6*~r0{z4toy)pƴ%rzjQeq>CMHjm˝.^d3~$Qf\rll0.!qI"Pu-Ux}ŪꨀKy`۰C[%+[]7~᧗ 4Sy|6ta=XW掔tK&؆5QbԩORǝ\#wE :7zHtUMwSq~Qe“lƒ$֪ ں`Mmj޹i%G1 ]4M#ZA:MQxum>ṅ_nge΄A!W$*$/gqU]ncLo\ *1V{8 o+O:(ÿoWF=ҋWuyഘ2)Pm2HN5FB-u:ШI˔ht&aڲn7D>=X1tP$Ta3ҝBN51V?"T3E_z/^0GlGPJ b@B(AUDOwM&р_:QkU<>%=Tn ?V?H9b0" Y5$OW:Uɲ2M=;u0|~3.*2MҸGsdmOwBhcDajaNҧ=wY87=yoAOr"x?$o?ߜ ( '/?]a_\T`cߑei kGJXKld" }4g@~N5zO93R3;tqoEDTiv&oWFFI_0E;\Sym{͞P;5Շ}z;;!68+}_eF/2LF}0χ\fbRFSBF#Z}CSA-yl*xgzE鐘"]xxmz]GkHIUI|xNWl#цXdu~y^+}@bQh- &1mB%j b3:d$9 !B.oHE.d>&tB紅оTM5ƶ0h? )𹽱6{UQv6#Y]R2δǚ>ݒ ]4gN`ɵoEMq{7^B;+ӎm:0< [  OznXJZ~0I=Qb^Z d Y5Nkeepass2-2.25/Docs/Chm/KeePassContents.hhc0000664000175000017500000001525712273660164020270 0ustar jtaylorjtaylor
keepass2-2.25/Docs/Chm/default.css0000664000175000017500000002217512273660230016660 0ustar jtaylorjtaylor/* Design Copyright (c) 2003-2014 Dominik Reichl */ body, p, div, h1, h2, h3, h4, h5, h6, ol, ul, li, td, th, dd, dt, a { font-family: Verdana, Arial, sans-serif; font-size: 13px; color: #000000; font-weight: normal; } /* --------------------------------------------------------------------- */ body { background-color: #FFFFFF; background-image: url(./images/back.gif); background-repeat: repeat; background-attachment: fixed; } p { margin-left: 0px; } ul { /* margin-left: 20px; list-style: disc; */ } h1 { font-size: 20px; font-weight: bold; } h2 { font-size: 18px; font-weight: bold; } h3 { font-size: 15px; font-weight: bold; } h4 { font-size: 13px; font-weight: bold; } h5 { font-size: 12px; font-weight: bold; } h6 { font-size: 10px; font-weight: normal; } hr { height: 1px; display: block; color: #000080; margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px; } pre { font-family: monospace; background-color: #E6E6E6; font-size: 11px; overflow: auto; display: block; } /* --------------------------------------------------------------------- */ a:visited { text-decoration: none; color: #0000DD; } a:active { text-decoration: none; color: #6699FF; } a:link { text-decoration: none; color: #0000DD; } a:hover { text-decoration: underline; color: #6699FF; } /* --------------------------------------------------------------------- */ div.menubox { border: 1px solid #C5C5C5; display: block; margin: 0px 1px 0px 0px; padding: 0px 0px 0px 0px; background-color: #FFFFFF; } div.menubox div.menutitle { background-color: #C5C5C5; background: url(./images/grad_h_gw.gif) repeat-y; display: block; font-weight: bold; font-size: 10px; padding: 1px 1px 1px 6px; vertical-align: middle; color: #005101; white-space: nowrap; } div.menubox div.menutitlewide { background-color: #C5C5C5; background: url(./images/grad_h_gw_186.gif) repeat-y; display: block; font-weight: bold; font-size: 10px; padding: 1px 1px 1px 6px; vertical-align: middle; color: #005101; white-space: nowrap; } div.menubox a { display: block; padding: 1px 1px 1px 1px; border-collapse: collapse; text-decoration: none; font-size: 11px; color: #000000; vertical-align: middle; } div.menubox a:visited, div.menubox a:active, div.menubox a:link { border: 1px solid #FFFFFF; } div.menubox a:hover { border: 1px solid #0A246A; -moz-border-radius: 2px; border-radius: 2px; background-color: #B6BDD2; background-image: -webkit-linear-gradient(top, #D9E5F9, #B8BED8); background-image: -moz-linear-gradient(top, #D9E5F9, #B8BED8); background-image: -ms-linear-gradient(top, #D9E5F9, #B8BED8); background-image: linear-gradient(to bottom, #D9E5F9, #B8BED8); } /* --------------------------------------------------------------------- */ table.tablebox, table.tablebox75 { background-color: #AFB5CF; margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px; border-left: 1px solid #AFB5CF; border-right: 0px none; border-top-width: 0px; border-bottom-width: 0px; border-collapse: collapse; } table.tablebox { width: 100%; } table.tablebox75 { width: 75%; margin-left: 12.5%; margin-right: 12.5%; } table.tablebox tr th, table.tablebox75 tr th { background-color: #EEEEEE; background: url(./images/grad_v_gw.gif) repeat-x top; font-weight: bold; border-bottom: 1px solid #AFB5CF; border-left: 0px none; border-right: 1px solid #AFB5CF; border-top: 1px solid #AFB5CF; padding: 2px 2px 2px 5px; empty-cells: show; white-space: nowrap; text-align: left; vertical-align: top; } table.tablebox tr td, table.tablebox75 tr td { background-color: #F0F0F0; font-weight: normal; border-bottom: 1px solid #AFB5CF; border-left: 0px none; border-right: 1px solid #AFB5CF; border-top: 0px none; padding: 5px 5px 5px 5px; empty-cells: show; text-align: left; vertical-align: top; } /* --------------------------------------------------------------------- */ img { border: 0px none; } img.singleimg { border: 0px none; vertical-align: middle; } /* --------------------------------------------------------------------- */ input.sansedit, textarea.fixededit { border: 1px solid #C5C5C5; padding-top: 1px; } input.sansedit:hover, input.sansedit:focus, textarea.fixededit:hover, textarea.fixededit:focus { border: 1px solid #000000; } input.sansedit { font-family: Verdana, Arial, sans-serif; font-size: 13px; } textarea.fixededit { font-family: monospace; display: block; } /* --------------------------------------------------------------------- */ div.tooltipex { position: absolute; display: none; background-color: #FFFFE0; padding: 1px 1px 1px 1px; -moz-opacity: 0.9; opacity: 0.9; border: 1px solid #000000; } /* --------------------------------------------------------------------- */ div.specificbox { border: 1px solid #808080; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; display: block; background-color: #EEF0FF; padding-top: 1px; padding-left: 2px; padding-right: 2px; padding-bottom: 2px; } div.specificbox div.specifictitle { font-size: 10px; font-weight: bold; border-left: 0px none; border-right: 0px none; border-bottom: thin dotted #808080; border-top: 0px none; text-align: left; margin-bottom: 3px; } /* --------------------------------------------------------------------- */ table.sectionsummary { width: 100%; border: thin solid #808080; -moz-box-shadow: 1px 1px 5px #808080; -webkit-box-shadow: 1px 1px 5px #808080; box-shadow: 1px 1px 5px #808080; background-color: #F0F8FF; margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px; } table.sectionsummary tr td { border: 0px; vertical-align: middle; font-size: 10px; font-weight: normal; margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px; border-collapse: collapse; } table.sectionsummary tr td h1 { display: inline; font-size: 20px; font-weight: normal; } /* --------------------------------------------------------------------- */ h2.sectiontitle { display: block; font-size: 13px; font-weight: bold; color: #000000; background: url(./images/grad_v_dlb_tall_light.png) repeat-x top; border: 1px solid #AFB5CF; color: #005101; min-height: 19px; vertical-align: middle; margin: 0px 0px 0px 0px; padding: 2px 0px 0px 6px; } /* --------------------------------------------------------------------- */ td.helptopheader { background-image: url(./help/images/b32x68_headerbg.png); background-repeat: repeat-x; } /* --------------------------------------------------------------------- */ p.pagebreak { page-break-after: always; } /* --------------------------------------------------------------------- */ div.tipdiv { background-color: #FFFFE0; padding: 1px 1px 1px 1px; border: 1px solid #000000; } .box100 { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; width: 100%; } /* --------------------------------------------------------------------- */ .il-m { background: transparent url('./images/il_main_v01.png') no-repeat; margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px; border: 0px none; overflow: hidden; display: inline-block; vertical-align: middle; } .spr-m-kp-h { background-position: -1px -1px; width: 75px; height: 75px; } .spr-m-home-mh { background-position: -78px -1px; width: 31px; height: 21px; } .spr-m-contact-mh { background-position: -78px -24px; width: 31px; height: 21px; } .spr-m-news-mh { background-position: -78px -47px; width: 31px; height: 21px; } .spr-m-scrsh-mh { background-position: -111px -1px; width: 31px; height: 21px; } .spr-m-dl-mh { background-position: -111px -24px; width: 31px; height: 21px; } .spr-m-lang-mh { background-position: -111px -47px; width: 31px; height: 21px; } .spr-m-ext-mh { background-position: -144px -1px; width: 31px; height: 21px; } .spr-m-write-mh { background-position: -144px -24px; width: 31px; height: 21px; } .spr-m-help-ml { background-position: -177px -1px; width: 31px; height: 16px; } .spr-m-info-ml { background-position: -177px -19px; width: 31px; height: 16px; } .spr-m-sec-ml { background-position: -177px -37px; width: 31px; height: 16px; } .spr-m-award-ml { background-position: -210px -1px; width: 31px; height: 16px; } .spr-m-links-ml { background-position: -210px -19px; width: 31px; height: 16px; } .spr-m-xmag-ml { background-position: -210px -37px; width: 31px; height: 16px; } .spr-m-donate-ml { background-position: -1px -78px; width: 31px; height: 16px; } .spr-m-osi-h { background-position: -1px -96px; width: 72px; height: 60px; } .spr-m-award-s { background-position: -1px -158px; width: 16px; height: 16px; } .spr-m-feed-s { background-position: -19px -158px; width: 16px; height: 16px; } .spr-m-w3valid-b { background-position: -1px -176px; width: 80px; height: 15px; } .spr-m-kp-b { background-position: -83px -176px; width: 80px; height: 15px; } keepass2-2.25/Docs/Chm/images/0000775000175000017500000000000012273661064015766 5ustar jtaylorjtaylorkeepass2-2.25/Docs/Chm/images/grad_v_dlb.gif0000664000175000017500000000100312273660230020524 0ustar jtaylorjtaylorGIF89adϰвҳӴԶַ׹ٺڻ۽ݾ޿,d@H*\ȰaB#JHŋ3jxǏ CIɓ(S$˗0cʜI͛3ɳϟ@ JhP H*]ʴӧPJTիXjʵׯ`v5@ٳhӪ]˶۷kȝKݻx˷o^ LÈ+^|Xǐ#KL˘3WϠCMӣ^ͺװc˞Mvsͻ ȓ+_μУ7?@سkνOӫ_Ͼ}˟O(h&X 6F(VhFv ($(,0(/V`8<@DiH&L6K;keepass2-2.25/Docs/Chm/images/osi_certified_72x60.gif0000664000175000017500000000444312273660230022132 0ustar jtaylorjtaylorGIF89aH<O0_0?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660230020416 0ustar jtaylorjtaylorGIF89ad,d@H*\ȰaB#JHŋ3jxǏ CIɓ(S$˗0cʜI͛3ɳϟ@ JhPH*]ʴӧPJԀիXjʵׯ`vU@ٳhӪ]˶۷kȝKݻx˷o^  LÈ+^|8ǐ#KL˘3WϠCMӣ ^ͺװc˞Mvsͻ ;ȓ+_μУ7_@سkνCOӫ_Ͼ}˟O?(h&X 6F(Vh;keepass2-2.25/Docs/Chm/images/back.gif0000664000175000017500000000040712273660230017350 0ustar jtaylorjtaylorGIF89a@ ,@ @H*\ȰÇ#JHŋ3jȱǏ CIɓ(S\ɲ˗0cʜI͛8sɳϟ@ Jѣ(]ʴӧPJJիXjʵׯ`ÊKٳhӪ]˶۷pʝKݻx˷߿ L0+^̸ǐ"L˘3k̹ϠCMӨS^ͺװc˞M۸sͻ Ǹkeepass2-2.25/Docs/Chm/images/grad_h_gw.gif0000664000175000017500000000135412273660230020373 0ustar jtaylorjtaylorGIF89a , @`X8C"0@⁋hԘc A.9I Rt/!ȄfM 8%LعO @腣0(Ui PnUv뇯@; >(E9z )䂓(U6h惙4mFȩ焟@V(jRNJz֮^%[A 8-ƌq=~kI{[;ST1Ҥ>Lje[1 ,h^K["PMWAklpnļ[pWA8Z趦\^E`b\dQvei\gguxvHҁ*%ӂ65ӃBE؄M'߅Yه߆tEt]vvw!(1AیKWT՗W=bEDnTbHHޒ+6/FGgeT7^eW;eA)&d h&hdlMp$PtW%xZ'|j'z(ڠBڡFXҢ+5JLEOUj'acrrY@keepass2-2.25/Docs/Chm/images/grad_v_dlb_tall_light.png0000664000175000017500000000172412273660230022760 0ustar jtaylorjtaylorPNG  IHDRd)PLTEHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHdSGIDATxC o1Y IP]A r(ȱ r)ȵ (ȳ SA^ ]OAd-H$D"H$D"H$D"H$D"H$D"H$D"H$D"H$D"H$I6SkHIENDB`keepass2-2.25/Docs/License_Install.txt0000664000175000017500000004414112261553372017626 0ustar jtaylorjtaylorKeePass: Copyright (c) 2003-2014 Dominik Reichl . The software is distributed under the terms of the GNU General Public License version 2 or later. GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. keepass2-2.25/Docs/License.txt0000664000175000017500000004415212261553376016146 0ustar jtaylorjtaylorKeePass: Copyright (c) 2003-2014 Dominik Reichl . The software is distributed under the terms of the GNU General Public License version 2 or later. GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. keepass2-2.25/Docs/History.txt0000664000175000017500000035377712273471376016247 0ustar jtaylorjtaylor2014-02-03: 2.25 - New auto-type key sending engine (improved support for sending Unicode characters and for sending keypresses into virtual machine/emulator windows; now largely compatible with the Neo keyboard layout; sequence parsing is faster, more flexible and optimizes the sequence; improved behavior for invalid sequences; differential delays, making the auto-type process less susceptible to externally caused delays; automatic cancelling is now more precise up to at most one keypress and also works on Unix-like systems; improved message processing during auto-type) - When trying to open an entry attachment that the built-in editor/viewer cannot handle, KeePass now extracts the attachment to a (EFS-encrypted) temporary file and opens it using the default application associated with this file; afterwards the user can choose between importing/discarding changes and KeePass deletes the temporary file securely - On Windows Vista and higher, the button in the entry editing dialog to open attachments is now a split button; the drop- down menu allows to choose between the built-in viewer, the built-in editor and an external application - Added 'XML Replace' functionality - Generic CSV importer: added option to merge imported groups with groups already existing in the database - Added support for importing Dashlane 2.3.2 CSV files - On Windows 8 and higher, some running Metro apps are now listed in the 'Edit Auto-Type Item' dialog - Added {T-CONV:/T/C/} placeholder (to convert text to upper- case, lower-case, or its UTF-8 representation to Base64 or Hex) - Added {SPACE} special key code (as alternative for the ' ' character, for improved readability of auto-type sequences) - XML merge (used e.g. when an enforced configuration file is present): added support for comments in inner nodes - Added UIFlags bit for showing last access times - In the history entry viewing dialog, the 'Open' and 'Save' commands are now available for attachments - When replacing the {PASSWORD_ENC} placeholder, KeePass now first Spr-compiles the entry password (i.e. placeholders, environment variables, etc. can be used) - Improved configuration loading performance - Improved displaying of fatal exceptions - Various code optimizations - Minor other improvements - Data inserted by entry URL component placeholders is now encoded correctly 2013-11-03: 2.24 - The URL override field in the entry editing dialog is now an editable combo box, where the drop-down list contains suggestions for browser overrides - Password quality estimations are now computed in separate threads to improve the UI responsiveness - The password generator profile 'Automatically generated passwords for new entries' is now available in the password generator context menu of the entry editing dialog - Added UIFlags bit for hiding built-in profiles in the password generator context menu of the entry editing dialog - Tags can be included in printouts now - Generic CSV importer: added support for importing tags - Added support for importing Norton Identity Safe 2013 CSV files - Mozilla Bookmarks JSON import: added support for importing tags - RoboForm import: URLs are now terminated using a '/', added support for the new file format and for the new note fields - Added support for showing modern task dialogs even when no form exists (requiring a theming activation context) - KeePass now terminates CtfMon child processes started by .NET/Windows, if they are not terminated automatically - Added workarounds for '#', '{', '}', '[', ']', '~' and diaeresis .NET SendKeys issues - Added workaround for 'xsel' hanging on Unix-like systems - Converted some PNG images as a workaround for a problem in Cairo/LibPNG on Unix-like systems - Installer: the version is now shown in the 'Version' field of the item in the Windows 'Programs and Features' dialog - TrlUtil: added 'Go to Next Untranslated' command - TrlUtil: added shortcut keys - The 'Open From URL' dialog is now brought to the foreground when trying to perform global auto-type while the database is locked and the main window is minimized to tray - Profiles are now shown directly in the password generator context menu of the entry editing dialog - After duplicating entries, KeePass now ensures that the copies are visible - User names of TAN entries are now dereferenced, if the option for showing dereferenced data in the main window is enabled - When creating an entry from a template, the new entry is now selected and focused - Empty fields are not included in detailed printouts anymore - Enhanced Internet Explorer detection - The '-preselect' command line option now works together with relative database file paths - Improved quoted app paths parsing - Extended culture invariance - Improved synchronization performance - Improved internal keypress routing - Last access times by default are not shown in the UI anymore - TrlUtil: improved dialog focusing when showing message boxes - KeePassLib/KPScript: improved support for running on systems without any GUI - Various code optimizations - Minor other improvements - Fixed a crash that could occur if the option 'Show expired entries (if any)' is enabled and a trigger switches to a different locked database when unlocking a database - The tab bar is now updated correctly after closing an inactive database by middle-clicking its tab - Column display orders that are unstable with respect to linear auto-adjusting assignment are now restored correctly 2013-07-20: 2.23 - New password quality estimation algorithm - Added toolbar buttons: 'Open URL(s)', 'Copy URL(s) to Clipboard' and 'Perform Auto-Type' - Added 'Generate Password' command in the context menu of the KeePass system tray icon - Added 'Copy history' option in the entry duplication dialog (enabled by default) - Added 'Duplicate Group' context menu command - In the MRU list, currently opened files now have an '[Opened]' suffix and are blue - When a dialog is displayed, (double) clicking the KeePass system tray icon now activates the dialog - Added {T-REPLACE-RX:...} placeholder, which replaces text using a regular expression - Added {VKEY-NX X} and {VKEY-EX X} special key codes - Added 'Perform auto-type with selected entry' trigger action - Added 'Import into active database' trigger action - Mozilla Bookmarks HTML import: added support for groups, bookmark descriptions and icons - Mozilla Bookmarks JSON import: bookmark descriptions are now imported into the note fields of entries - RoboForm import: added support for the new file format - Added support for importing Network Password Manager 4.0 CSV files - Enhanced SafeWallet XML importer to additionally support importing web entries and groups from very old export file versions (for newer versions this was already supported) - Added database repair mode warning - Added option to accept invalid SSL certificates (turned off by default) - Added user activity notification event for plugins - File transactions for FTP URLs are now always disabled when running under .NET 4.0 in order to workaround .NET bug 621450 - Added workaround for Mono list view item selection bug - Added workaround for Mono bug 649266; minimizing to tray now removes the task bar item and restoring does not result in a broken window anymore - Added workaround for Mono bug 5795; text and selections in password boxes are now drawn properly (a monospace font can only be used on Windows due to the bug) - Added workaround for Mono bug 12525; dialog banners are now drawn correctly again - Added workaround for Mono form loading bug - KPScript: added 'Import' command - KPScript: the 'ListEntries' command now also outputs date/time fields of entries - When the option for remembering the last used database is enabled, KeePass now remembers the last active database (instead of the last opened or saved database) - The 'Add Group' command and the F2 key in the groups tree view now open the group editing dialog; in-place tree node label editing is disabled - Custom string and plugin-provided columns in the 'Configure Columns' dialog are sorted alphabetically now - Improved behavior when closing inactive databases - Improved support for trigger actions during database closing - The 'Special' GUI character set now includes '|' and '~' - The 'High ANSI' character set now consists of the range [U+0080, U+00FF] except control and non-printable characters - The options dialog is now listed in the task bar when it is opened while KeePass is minimized to the system tray - A remembered user account usage state can now be preset even when the user account option is disabled using key prompt configuration flags - Improved initial input focus in key creation/prompt dialogs when key creation/prompt configuration flags are specified - During synchronization, the status dialog is now closed after all files have been saved - Improved behavior of the global KeePass activation hot key when a dialog is displayed - Changed auto-type command icon - Shortened product name in main window title - Improved data URI validation - Custom clipboard data is now encoded as data URI (with a vendor-specific MIME type) - Improved configuration loading performance - Enhanced IO connection problem diagnostics - Improved single instance checking on Unix-like systems - KeePassLibC DLLs and ShInstUtil are now explicitly marked as DEP- and ASLR-compatible (like the executable file) - Various UI improvements - Various code optimizations - Minor other improvements - The suffixes to the 'Inherit setting from parent' options on the 'Behavior' tab of the group editing dialog now correctly show the inherited settings of the current group's parent - When locked, the main window's title doesn't show the full path of the database anymore when the option 'Show full path in title bar (instead of file name only)' is turned off - The status bar is now updated correctly after sorting by a column 2013-04-05: 2.22 - When the option for remembering key sources is enabled, KeePass now also remembers whether the user account is required - Added 'View' -> 'Grouping in Entry List' menu - Added 'Close active database' trigger action - Added '-ioiscomplete' command line option, which tells KeePass that the path and file system credentials are complete (the 'Open URL' dialog will not be displayed then) - Added support for importing SafeWallet XML files (3.0.4 and 3.0.5) - Added support for importing TurboPasswords 5.0.1 CSV files - LastPass CSV importer: added support for group trees - Alle meine Passworte XML importer: added support for custom fields and group names with special characters - Password Safe XML importer: added support for the e-mail field - Added 'Help' button in the generic CSV importer dialog - Added workaround for .NET bug 642188; top visible list view items are now remembered in details view with groups enabled - Added workaround for Mono form title bar text update bug (which e.g. caused bug 801414) - After closing a character picking dialog, KeePass now explicitly activates the previous window - Improved behavior when cancelling the icon picker dialog - Main window activation redirection now works with all KeePass dialogs automatically - The window state of the current database is now remembered before opening another database - Previous parameters are now discarded when switching between different trigger event/condition/action types - Unified separators in group paths - The UI state is now updated after adding an entry and clicking an entry reference link in the entry view - The '-entry-url-open' command line option now searches for matching entries in all open databases - Improved database context determination when opening an URL - Added support for special values in date/time fields imported from KeePass 1.x - Improved HTML entity decoding (support for more entities and CDATA sections, improved performance, ...) - RoboForm HTML importer: URLs are converted to lower-case now and support for a special order rotation of attributes has been added - Removed Password Gorilla CSV importer; users should use the generic CSV importer (which can import more data than the old specialized CSV importer) - Improved file discoveries - Improved test form entry auto-type window definition - In the MSI package, the version is now included in the product name - Native key transformation library: replaced Boost threads by Windows API threads (because Boost threads can result in crashes on restricted Windows 7 x64 systems) - Various UI improvements - Various code optimizations - Minor other improvements 2013-02-03: 2.21 - Generic CSV importer: a group separator can be specified now (for importing group trees) - Internal data viewer: added hex viewer mode (which is now the default for unknown data types) - In the 'Show Entries by Tag' menu, the number of entries having a specific tag is now shown right of the tag - In the 'Add Tag' menu, a tag is now disabled if all selected entries already have this tag - Auto-Type: added support for right modifier keys - Added special key codes: {WIN}, {LWIN}, {RWIN}, {APPS}, {NUMPAD0} to {NUMPAD9} - Interleaved sending of keys is now prevented by default (if you e.g. have an auto-type sequence that triggers another auto-type, enable the new option 'Allow interleaved sending of keys' in 'Tools' -> 'Options' -> tab 'Advanced') - Added '-auto-type-selected' command line option (other running KeePass instances perform auto-type for the currently selected entry) - Added option to additionally show references when showing dereferenced data (enabled by default) - The selection in a secure edit control is now preserved when unhiding and hiding the content - The auto-type association editing dialog now does not hang anymore when a window of any other application hangs - When an application switches from the secure desktop to a different desktop, KeePass now shows a warning message box; clicking [OK] switches back to the secure desktop - Added 'OK'/'Cancel' buttons in the icon picker dialog - Added support for importing LastPass 2.0.2 CSV files - KeePass now shows an error message when the user accidentally attempts to use a database file as key file - Added support for UTF-16 surrogate pairs - Added UTF-8 BOM support for version information files - The KeePass version is now also shown in the components list in the 'About' dialog - File operations are now context-independent (this e.g. makes it possible to use the 'Activate database' trigger action during locking) - Plugins can now register their placeholders to be shown in the auto-type item editing dialog - Plugins can now subscribe to IO access events - Added workaround for .NET bug 694242; status dialogs now scale properly with the DPI resolution - Added workaround for Mono DataGridView.EditMode bug - Added workaround for Mono bug 586901; high Unicode characters in rich text boxes are displayed properly now - When the main window UI is being unblocked, the focus is not reset anymore, if a primary control has the focus - When opening the icon picker dialog, KeePass now ensures that the currently selected icon is visible - Internal data viewer: improved visibility updating - The e-mail box icon by default is not inherited by new entries anymore - The database is now marked as modified when auto-typing a TAN entry - Enhanced AnyPassword importer to additionally support CSV files exported by AnyPassword Pro 1.07 - Enhanced Password Safe XML importer (KeePass tries to fix the broken XML files exported by Password Safe 3.29 automatically) - IO credentials can be loaded over IPC now - Enhanced user switch detection - Even when an exception occurs, temporary files created during KDB exports are now deleted immediately - Improved behavior on Unix-like systems when the operating system does not grant KeePass access to the temporary directory - Improved critical sections that are not supposed to be re- entered by the same thread - Improved secure desktop name generation - When a dialog is closed, references within the global client image list to controls (event handlers) are removed now - .NET 4.5 is now preferred, if installed - PLGX plugins are now preferably compiled using the .NET 4.5 compiler, if KeePass is currently running under the 4.5 CLR - Updated KB links - Changed naming of translation files - The installer now always overwrites the KeePassLibC 1.x support libraries - Upgraded installer - Various code optimizations - Minor other improvements - When locking multiple databases and cancelling a 'Save Changes?' dialog, the UI is now updated correctly - '&' characters in dynamic menu texts, in dialog banner texts, in image combobox texts, in text box prompts and in tooltips are now displayed properly 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. Rasmussen) - Added management of working directories (a separate working directory is remembered for each file dialog context; working directories are remembered relatively to KeePass.exe; the management can be deactivated by turning off the new option 'Remember working directories') - Added option to cancel auto-type when the target window title changes - Added quick search box in the toolbar of the internal text editor - Files can now be attached to entries by using drag&drop from Windows Explorer to the attachments list in the entry editing dialog - Added '-pw-stdin' command line option to make KeePass read the master password from the StdIn stream - Added placeholders to get parts of the entry URL: {URL:SCM}, {URL:HOST}, {URL:PORT}, {URL:PATH} and {URL:QUERY} - Added a 'Details' button in the plugin load failure message box (when clicked, detailed error information for developers is shown) - Added warning icon left of the Windows user account option description in the master key creation dialog - Added support for more image file formats (e.g. when importing custom client icons) - Added support for importing DesktopKnox 3.2 XML files - The generic CSV importer now guesses whether the option to ignore the first row should be enabled or not (the user of course can still specify it manually, too) - Added support for exporting to KeePass 1.x CSV files - Added support for moving the PLGX cache to a different remote drive - The Spr engine is now extensible, i.e. plugins can provide additional transformations/placeholders - On Unix-like systems, KeePass now uses the 'xsel' utility for clipboard operations, if 'xsel' is installed (in order to work around Mono clipboard bugs) - Added Mono workaround to set the WM_CLASS property - Added workaround for Mono splitter bug - The 'PrepMonoDev.sh' script now removes the serialization assembly generating post build event - TrlUtil: added support for importing PO files - Improved FTP file existence checking - High DPI UI improvements - The database is not marked as modified anymore when using in- place label editing to fake-edit a group's name (i.e. when the final new name is the same as the previous one) - Password is not auto-repeated anymore when trying to unhide it fails due to the policy 'Unhide Passwords' being disabled - Improved menu accelerator and shortcut keys - Changed IO connection name display format - Improved browser detection on Mac OS X - Task dialog thread safety improvements - Added UI check during import for KPScript - Upgraded and improved installer (now uses Unicode, LZMA2 compression, ...) - Various UI improvements - Various code optimizations - Minor other improvements - On Windows systems, new line sequences in text to be shown in a standard multiline text box are now converted to Windows format 2012-05-01: 2.19 - New generic CSV importer (now supports multi-line fields, '\' as escape character, field & record separators and the text qualifier can be specified, white space characters can be removed from the beginning/end of fields, the fields and their order can be defined, supported fields now are group name & standard fields like e.g. title & custom strings & times & ignore column, the first row can be ignored, KeePass initially tries to guess the fields and their order based on the first row) - Native master key transformations are now computed in two threads on 64-bit systems, too; on dual/multi core processors this results in almost twice the performance as before (by doubling the amount of rounds you'll get the same waiting time as in 2.18, but the protection against dictionary and guessing attacks is doubled) - New XML configuration and translation deserializer to improve the startup performance - Added option to require a password repetition only when hiding using asterisks is enabled (enabled by default) - Entry attachments can now be renamed using in-place label editing (click on an already selected item to show an edit box) - Empty entry attachments can now be created using 'Attach' -> 'Create Empty Attachment' - Sizes of entry attachments are now shown in a column of the attachments list in the entry editing dialog - Added {ENV_PROGRAMFILES_X86} placeholder (this is %ProgramFiles(x86)%, if it exists, otherwise %ProgramFiles%) - Added auto-type option 'An entry matches if one of its tags is contained in the target window title' - URLs in HTML exports are now linkified - Import modules may now specify multiple default/equivalent file extensions (like e.g. 'htm' and 'html') - Added support for reading texts encoded using UTF-32 Big Endian - Enhanced text encoding detection (now detects UTF-32 LE/BE and UTF-16 LE/BE by zeros, improved UTF-8 detection, ...) - Added zoom function for images in internal data viewer - Drop-down image buttons in the entry editing dialog are now marked using small black triangle overlays - Added support for loading key files from URLs - Controls in the options dialog are now disabled when the options are enforced (using an enforced configuration file) - If KeePass is started with the '-debug' command line option, KeePass now shows a developer-friendly error message when opening a database file fails - Added 'Wait for exit' property in the 'Execute command line / URL' trigger action - The 'File exists' trigger condition now also supports URLs - Added two file closing trigger events (one raised before and one after saving the database file) - Plugins: added file closing events - Plugins: added events (AutoType.Sequence*) that allow plugins to provide auto-type sequence suggestions - Added workaround to support loading data from version information files even when they have incorrectly been decompressed by a web filter - Added workarounds for '', '|' and '' .NET SendKeys issues - Added workaround for topmost window .NET/Windows issue (the 'Always on Top' option now works even when switching to a different window while KeePass is starting up) - Added workaround for Mono dialog event ordering bug - Added workaround for Mono clipboard bugs on Mac OS X - KPScript: added 'MoveEntry', 'GetEntryString' and 'GenPw' commands - KPScript: added '-refx-UUID' and '-refx-Tags' entry identification parameters - When only deleting history entries (without changing any data field of an entry), no backup entry is created anymore - Unified text encoding handling for internal data viewer and editor, generic CSV importer and text encoding selection dialog - Improved font sizing in HTML exports/printouts - Improved encoding of group names in HTML exports/printouts - If an entry doesn't expire, 'Never expires' is now shown in the 'Expiry Time' column in HTML exports/printouts - The expiry edit control now accepts incomplete edits and the 'Expires' checkbox is checked immediately - The time component of the default expiry suggestion is now 00:00:00 - The last selected/focused item in the attachments list of the entry editing dialog is now selected/focused after editing an attachment - Improved field to standard field mapping function - Enhanced RoboForm importer to concatenate values of fields with conflicting names - Updated Spamex.com importer - Removed KeePass 1.x CSV importer; users should use the new generic CSV importer (which can import more data than the old specialized 1.x CSV importer) - When trying to open another database while a dialog is displayed, KeePass now just brings itself to the foreground without attempting to open the second database - More list views use the Vista Explorer style - Modifier keys without another key aren't registered as global hot key anymore - Improved default suggestions for custom sequences in the auto-type sequence editing dialog - Improved default focus in the auto-type sequence editing dialog - Added {C:Comment} placeholder in the auto-type sequence editing dialog - On Unix-like systems, the {GOOGLECHROME} placeholder now first searches for Google Chrome and then (if not found) for Chromium - Versions displayed in the update checking dialog now consist of at least two components - Added '@' and '`' to the printable 7-bit ASCII character set - Merged simple and extended special character spaces to one special character space - Reduced control character space from 60 to 32 - The first sample entry's URL now points to the KeePass website - Improved key transformation delay calculation - Improved key file loading performance - The main menu now isn't a tab stop anymore - Some configuration nodes are now allocated only on demand - Improved UI update when moving/copying entries to the currently active group or a subgroup of it using drag&drop - Improved behavior when closing an inactive database having unsaved changes - Changed versioning scheme in file version information blocks from digit- to component-based - Development snapshots don't ask anymore whether to enable the automatic update check (only stable releases do) - Improved PLGX cache directory naming - The PLGX cache directory by default is now located in the local application data folder instead of the roaming one - Improved support for PLGX plugins that are using LINQ - Various UI improvements - Various code optimizations - Minor other improvements - Fixed sorting of items in the most recently used files list - Fixed tab order in the 'Advanced' tab of the entry editing dialog 2012-01-05: 2.18 - The update check now also checks for plugin updates (if plugin developers provide version information files) - When starting KeePass 2.18 for the first time, it asks whether to enable the automatic update check or not (if not enabled already) - When closing the entry editing dialog by closing the window (using [X], Esc, ...) and there are unsaved changes, KeePass now asks whether to save or discard the changes; only when explicitly clicking the 'Cancel' button, KeePass doesn't prompt - When not hiding passwords using asterisks, they don't need to be repeated anymore - Password repetition boxes now provide instant visual feedback whether the password has been repeated correctly (if incorrect, the background color is changed to light red) - When clicking an '***' button to change the visibility of the entered password, KeePass now automatically transfers the input focus into the password box - Visibility of columns in the auto-type entry selection dialog can now be customized using the new 'Options' button - Added auto-type option 'An entry matches if the host component of its URL is contained in the target window title' - Added shortcut keys: Ctrl+Shift+O for 'Open URL', Ctrl+Shift+U for copying URLs to the clipboard, Ctrl+I for 'Add Entry', Ctrl+R for synchronizing with a file, Ctrl+Shift+R for synchronizing with a URL - Ensuring same keyboard layouts during auto-type is now optional (option enabled by default) - Plain text KDB4 XML exports now store the memory protection flag of strings in an attribute 'ProtectInMemory' - Added option to use database lock files (intended for storage providers that don't lock files while writing to them, like e.g. some FTP servers); the option is turned off by default (and especially for local files and files on a network share it's recommended to leave it turned off) - Added UIFlags bit for disabling the controls to specify after how many days the master key should/must be changed - Added support for in-memory protecting strings that are longer than 65536 characters - Added workaround for '@' .NET SendKeys issue - .NET 4.0 is now preferred, if installed - PLGX plugins are now preferably compiled using the .NET 4.0 compiler, if KeePass is currently running under the 4.0 CLR - Automatic update checks are now performed at maximum once per day (you can still check manually as often as you wish) - Auto-Type: entry titles and URLs are now Spr-compiled before being compared with the target window title - Decoupled the options 'Show expired entries' and 'Show entries that will expire soon' - Specifying the data hiding setting (using asterisks) in the column configuration dialog is now done using a checkbox - The entry view now preferably uses the hiding settings (asterisks) of the entry list columns - Improved entry expiry date calculation - Enhanced Password Agent importer to support version 2.6.2 - Enhanced SplashID importer to import last modification dates - Improved locating of system executables - Password generator profiles are now sorted by name - Separated built-in and user-defined password generator profiles (built-in profiles aren't stored in the configuration file anymore) - Improved naming of shortcut keys, and shortcut keys are now displayed in tooltips - Internal window manager can now close windows opened in other threads - Improved entry touching when closing the entry editing dialog by closing the window (using [X], Esc, ...) - Improved behavior when entering an invalid URL in the 'Open URL' dialog - Improved workaround for Mono tab bar height bug - ShInstUtil: improved Native Image Generator version detection - Unified in-memory protection - In-memory protection performance improvements - Developers: in-memory protected objects are now immutable and thread-safe - Various UI text improvements - Various code optimizations - Minor other improvements - The cached/temporary custom icons image list is now updated correctly after running the 'Delete unused custom icons' command 2011-10-19: 2.17 - Multiple auto-type sequences can now be defined for a window in one entry - The auto-type entry selection dialog now displays the sequence that will be typed - The auto-type entry selection dialog is now resizable; KeePass remembers the dialog's position, size and the list view column widths - Added auto-type option 'An entry matches if its URL is contained in the target window title' - Added two options to show dereferenced data in the main entry list (synchronously or asynchronously) - Dereferenced data fields are now shown in the entry view of the main window and the auto-type entry selection dialog (additionally to the references) - Field references in the entry view are now clickable; when clicking one, KeePass jumps to the data source entry - Added option in the 'Find' dialog to search in dereferenced data fields - Added option to search in dereferenced data fields when performing a quick search (toolbar in main window) - The 'Find' dialog now shows a status dialog while searching for entries - The main window now shows a status bar and the UI is disabled while performing a quick search - Added context menu commands to open the URL of an entry in a specific browser - Added {SAFARI} browser path placeholder - Added {C:...} comment placeholder - Added entry duplication options dialog (appending "- Copy" to entry titles, and/or replacing user names and passwords by field references to the original entries) - Added option to focus the quick search box when restoring from taskbar (disabled by default) - Added tray context menu command to show the options dialog - Source fields are now compiled before using them in a {PICKCHARS} dialog - Added 'Copy Link' rich text box context menu command - Before printing, the data/format dialog now shows a print dialog, in which the printer can be selected - Added application policy to ask for the current master key before printing - Added support for importing Passphrase Keeper 2.50 HTML files (in addition to the already supported 2.70 format) - KeePass now removes zone identifiers from itself, ShInstUtil and the CHM help file - Listing currently opened windows works under Unix-like systems now, too - Alternating item background colors are now also supported in list views with item groups - IOConnection now supports reading from data URIs (RFC 2397) - Group headers are now skipped when navigating in single selection list views using the arrow keys - Added detection support for the following web browsers on Unix-like systems: Firefox, Opera, Chromium, Epiphany, Arora, Galeon and Konqueror - Added documentation of the synchronization feature - Key provider plugins can now declare that they're compatible with the secure desktop mode, and a new property in the query context specifies whether the user currently is on the secure desktop - Added workaround for a list view sorting bug under Windows XP - Added workaround for a .NET bug where a cached window state gets out of sync with the real window state - Added workaround for a Mono WebRequest bug affecting WebDAV support - Items in the auto-type entry selection dialog can now be selected using a single click - When performing global auto-type, the Spr engine now uses the entry container database instead of the current database as data source - The generated passwords list in the password generator dialog now uses the password font (monospace by default) - The last modification time of an entry is now updated when a new password is generated using the {NEWPASSWORD} placeholder - The overlay icon for the taskbar button (on Windows 7) is now restored when Windows Explorer crashes and when starting in minimized and locked mode - Improved opening of CHM help file - The buttons in file save dialogs now have accelerator keys - Separated URL scheme overrides into built-in and custom ones - Improved tray command state updating - The default tray command is now rendered using a bold font - The main window is now disabled while searching and removing duplicate entries - Improved banner handling/updating in resizable dialogs - The 'Ctrl+U' shortcut hint is now moved either to the open or to the copy command, depending on whether the option 'Copy URLs to clipboard instead of opening them' is enabled or not - Improved command availability updating of rich text context menus - Quick searches are now invoked asynchronously - Improved quick search performance - The option to minimize the main window after locking the KeePass workspace is now enabled by default - When performing auto-type, newline characters are now converted to Enter keypresses - Auto-type on Unix-like systems: improved sending of backslash characters - On Unix-like systems, the default delay between auto-typed keystrokes is now 3 ms - Spr engine performance improvements - Changing the in-memory protection state of a custom entry string is now treated as a database change - Some options in the options dialog are now linked (e.g. the option 'Automatically search key files also on removable media' can only be enabled when 'Automatically search key files' is enabled) - Most items with default values aren't written to the configuration file anymore (resulting in a smaller file and making it possible to change defaults in future versions) - Path separators in the configuration file are now updated for the current operating system - Improved 'xdotool' version detection - Improved IO response handling when deleting/renaming files - Various UI text improvements - Various code optimizations - Minor other improvements - Status bar text is now correctly updated to 'Ready' after an unsuccessful/cancelled database opening attempt - Password generation based on patterns: escaped curly brackets are now parsed correctly 2011-07-12: 2.16 - When searching for a string containing a whitespace character, KeePass now splits the terms and reports all entries containing all of the terms (e.g. when you search for "Forum KeePass" without the quotes, all entries containing both "Forum" and "KeePass" are reported); the order of the terms is arbitrary; if you want to search for a term containing whitespace, enclose the term in quotes - When searching for a term starting with a minus ('-'), all entries that do not contain the term are reported (e.g. when you search for "Forum -KeePass" without the quotes, all entries containing "Forum" but not "KeePass" are reported) - Added dialog in the options to specify a web proxy (none, system or manual) and user name and password for it - Added option to always exit instead of locking the workspace - Added option to play the UAC sound when switching to a secure desktop (enabled by default) - Added filter box in the field references creation dialog - Added command to delete duplicate entries (entries are considered to be equal when their strings and attachments are the same, all other data is ignored; if one of two equal entries is in the recycle bin, it is deleted preferably; otherwise the decision is based on the last modification time) - Added command to delete empty groups - Added command to delete unused custom icons - For Unix-like systems: new file-based IPC broadcast mechanism (supporting multiple endpoints) - For Unix-like systems: added file-based global mutex mechanism - Auto-type on Unix-like systems: added support for sending square brackets and apostrophes - Two-channel auto-type obfuscation is now supported on Unix-like systems, too - Web access on Unix-like systems: added workarounds for non- implemented cache policy and credentials requirement - Added context menu command to empty the recycle bin (without deleting the recycle bin group) - On Windows Vista and higher, when trying to delete a group, the confirmation dialog now shows a short summary of the subgroups and entries that will be deleted, too - In the auto-type target window drop-down combobox, icons are now shown left of the window names - Added {CLEARFIELD} auto-type command (to clear the contents of single-line edit controls) - Added support for importing Sticky Password 5.0 XML files (formatted memos are imported as RTF file attachments, which you can edit using the internal KeePass editor; e.g. right- click on the entry in the main window and go 'Attachments' -> 'Edit Notes.rtf' or click on the attachment in the entry view at the bottom of the main window; see 'How to store and work with large amounts of formatted text?' in the FAQ) - Added support for importing Kaspersky Password Manager 5.0 XML files (formatted memos are imported the same as by the Sticky Password importer, see above) - Password Depot importer: added support for more fields (new time fields and usage count), time fields can be imported using the stored format specifier, vertical tabulators are removed, improved import of information cards, and auto-type sequences are converted now - Added ability to export links into the root directory of Windows/IE favorites - Windows/IE favorites export: added configuration items to specify a prefix and a suffix for exported links/files - In the entry editing dialog, KeePass now opens an attachment either in the internal editor or in the internal viewer, depending on whether the format is supported by the editor - When creating a new database, KeePass now automatically creates a second sample entry, which is configured for the test form in the online help center - Added configuration option to disable the 'Options', 'Plugins' and/or 'Triggers' menu items - Added workaround for Mono tab bar height bug - Added workaround for Mono FTP bug - Added workaround for Mono CryptoStream bug - Added workaround for a Mono bug related to focusing list view items - Added shell script to prepare the sources for MonoDevelop - Translations can now also be loaded from the KeePass application data directory - TrlUtil: added support for ellipses as alternative to 3 dots - KPScript: added 'DetachBins' command to save all entry attachments (into the directory of the database) and remove them from the database - After performing a quick-find, the search text is now selected - Improved quick-find deselection performance - On Unix-like systems, command line parameters prefixed with a '/' are now treated as absolute file paths instead of options - Improved IPC support on Unix-like systems - Locked databases can now be dismissed using the close command - Invalid target windows (like the taskbar, own KeePass windows, etc.) are not shown in the auto-type target window drop-down combobox anymore - Newly created entries are now selected and focused - The entry list is now focused when duplicating and selecting all entries - If KeePass is blocked from showing a dialog on the secure desktop, KeePass now shows the dialog on the normal desktop - Improved dialog initialization on the secure desktop - The current status is now shown while exporting Windows/IE favorites - Windows/IE favorites export: improved naming of containing folder when exporting selected entries only - Windows/IE favorites export: if a group doesn't contain any exportable entry, no directory is created for this group anymore - Improved data editor window position/size remembering - Key modifiers of shortcut key strings are translated now - Shortcut keys of group and entry commands are now also shown in the main menu - When no template entries are specified/found, this is now indicated in the 'Add Entry' toolbar drop-down menu - When deleting a group, its subgroups and entries are now added correctly to the list of deleted objects - Font handling improvements - Improved lock timeout updating when a dialog is displayed - Improved export error handling - Improved FIPS compliance problems self-test (error message immediately at start), and specified configuration option to prevent .NET from enforcing FIPS policy - Various code optimizations - Minor other improvements - Last modification time is now updated when restoring an older version of an entry - When duplicating an entry, the UUIDs of history items are now changed, too 2011-04-10: 2.15 - Added option to show the master key dialog on a secure desktop (similar to Windows' UAC; almost no keylogger works on a secure desktop; the option is disabled by default for compatibility reasons) - Added option to limit the number of history items per entry (the default is 10) - Added option to limit the history size per entry (the default is 6 MB) - Added {PICKCHARS} placeholder, which shows a dialog to pick certain characters from an entry string; various options like specifying the number of characters to pick and conversion to down arrow keypresses are supported; see the one page long documentation on the auto-type help page; the less powerful {PICKPASSWORDCHARS} is now obsolete (but still supported for backward compatibility) - The character picking dialog now remembers and restores its last position and size - KDBX file format: attachments are now stored in a pool within the file and entries reference these items; this reduces the file size a lot when there are history items of entries having attachments - KDBX file format: attachments are now compressed (if the compression option is enabled) before being Base64-encoded, compressed and encrypted; this results in a smaller file, because the compression algorithm works better on the raw data than on its encoded form - PLGX plugins can now be loaded on Unix-like systems, too - Added option to specify a database color; by specifying a color, the main window icon and the tray icon are recolored and the database tab (shown when multiple databases are opened in one window) gets a colored rectangle icon - New rich text builder, which supports using multiple languages in one text (e.g. different Chinese variants) - Added 'Sort By' popup menu in the 'View' menu - Added context menu commands to sort subgroups of a group - Added option to clear master key command line parameters after using them once (enabled by default) - Added application policies to ask for the current master key before changing the master key and/or exporting - Added option to also unhide source characters when unhiding the selected characters in the character picking dialog - Added ability to export custom icons - Added 'String' trigger condition - Added support for importing DataViz Passwords Plus 1.007 CSV files - Enhanced 1Password Pro importer to also support 1PW CSV files - Enhanced FlexWallet importer to also support version 2006 XML files (in addition to version 1.7 XML files) - Enabled auto-suggest for editable drop-down combo boxes (and auto-append where it makes sense) - Pressing Ctrl+Enter in the rich text boxes of the entry dialog and the custom string dialog now closes with OK (if possible) - Added option to cancel auto-type when the target window changes - Auto-type on Unix-like systems: added support for key modifiers - Added '--saveplgxcr' command line option to save compiler results in case the compilation of a PLGX plugin fails - Added workaround for % .NET SendKeys issue - Added workaround for Mono bug 620618 in the main entry list - Improved key file suggestion performance - When the master key change application policy is disabled and the master key expires (forced change), KeePass now shows the two information dialogs only once per opening - After removing the password column, hiding behind asterisks is suggested by default now when showing the column again - TAN entries now expire on auto-type, if the option for expiring TANs on use is enabled - Auto-type now sends acute and grave accents as separate characters - Auto-type now explicitly skips the taskbar window when searching for the target window - Multiple lines are now separated in the entry list and in the custom string list of the entry dialog by a space - RoboForm importer: improved multiline value support - Improved UNC path support - Improved entry list refresh performance - Improved UI state update performance - Entry list context menus are now configured instantly - Inapplicable group commands are now disabled - Improved control focusing - Improved clipboard handling - Copying and pasting whole entries is now also supported on Windows 98 and ME - Improved releasing of dialog resources - Improved keys/placeholders box in auto-type editing dialog - Improved user-friendliness in UAC dialogs - Tooltips of the tab close button and the password repeat box can be translated now - Improved help (moved placeholders to separate page, ...) - KeePassLibSD now uses the SHA-256 implementation of Bouncy Castle - Upgraded installer - Various code optimizations - Minor other improvements - Window titles are now trimmed, such that auto-type also works with windows whose titles have leading or trailing whitespace characters - Detection of XSL files works under Linux / Mac OS X now, too 2011-01-02: 2.14 - Added option to lock after some time of global user inactivity - Added option to lock when the remote control status changes - Auto-type on Unix-like systems: added special key code support (translation to X KeySyms) and support for {DELAY X} and {DELAY=X} - Added window activation support on Unix-like systems - Auto-type on Windows: added {VKEY X} special key code (sends virtual key X) - Added support for importing DataVault 4.7 CSV files - Added support for importing Revelation 0.4 XML files - Added 'Auto-Type - Without Context' application policy to disable the 'Perform Auto-Type' command (Ctrl+V), but still leave global auto-type available - Added option to collapse newly-created recycle bin tree nodes - Added 'Size' column in the history list of the entry dialog - Added trigger action to remove custom toolbar buttons - Added kdbx:// URL scheme overrides (for Windows and Unix-like systems; disabled by default) - Added KeePass.exe.config file to redirect old assemblies to the latest one, and explicitly declare .NET 4.0 runtime support - Added documentation for the '-pw-enc' command line parameter, the {PASSWORD_ENC} placeholder and URL overrides - Added workaround for ^/& .NET SendKeys issue - New locking timer (using a timeout instead of a countdown) - Improved locking when the Windows session is being ended or switched - Improved multi-database locking - Separated the options for locking when the computer is locked and the computer is about to be suspended - {FIREFOX} placeholder: added support for registry-redirected 32-bit Firefox installations on 64-bit Windows systems - File transactions: the NTFS/EFS encryption flag is now also preserved when the containing directory isn't encrypted - The IPC channel name on Unix-like systems is now dependent on the current user and machine name - KeePass now selects the parent group after deleting a group - Entries are now marked as modified when mass-changing their colors or icons - Key states are now queried on interrupt level - A {DELAY=X} global delay now affects all characters of a keystroke sequence when TCATO is enabled, too - Improved dialog closing when exiting automatically - Plugin-provided entry list columns can now be right-aligned at KeePass startup already - Removed KDBX DOM code - Installer: the KeePass start menu shortcut is now created directly in the programs folder; the other shortcuts have been removed (use the Control Panel for uninstalling and the 'Help' menu in KeePass to access the help) - Various code optimizations - Minor other improvements - Quotes in parameters for the 'Execute command line / URL' trigger action are now escaped correctly - Auto-type on Unix-like systems: window filters without wildcards now match correctly 2010-09-06: 2.13 - Password quality estimation algorithm: added check for about 1500 most common passwords (these are rated down to 1/8th of their statistical rating; Bloom filter-based implementation) - Global auto-type (using a system-wide hot key) is now possible on Unix-like systems (see the documentation for setup instructions, section 'Installation / Portability' in the 'KeePass 2.x' group; thanks to Jordan Sissel for enhancing 'xdotool') - Added IPC functionality for Unix-like systems - Added possibility to write export plugins that don't require an output file - Tag lists are sorted alphabetically now - Password text boxes now use a monospace font by default - Added option to select a different font for password text boxes (menu 'Tools' -> 'Options' -> tab 'Interface') - Added support for importing Password Prompter 1.2 DAT files - Added ability to export to Windows/IE favorites - Added ability to specify IO credentials in the 'Synchronize' trigger action - Added ability to specify IO credentials and a master key in the 'Open database file' trigger action - If IO credentials are stored, they are now obfuscated - Custom colors in the Windows color selection dialog are now remembered - Added high resolution version of the KeePass application icon - Improved lock overlay icon (higher resolution) - PLGX loader: added support for unversioned KeePass assembly references - Added workaround to avoid alpha transparency corruption when adding images to an image list - Improved image list generation performance - Added workaround to display the lock overlay icon when having enabled the option to start minimized and locked - Improved group and entries deletion confirmation dialogs (with preview; only Windows Vista and higher) - The password character picking dialog now offers the raw password characters instead of an auto-type encoded sequence - PINs importer: improved importing of expiry dates - Some button icons are now resized to 16x15 when the 16x16 icon is too large - Renamed character repetition option in the password generator for improved clarity - Improved workspace locking - Locking timer is now thread-safe - Added code to prevent loading libraries from the current working directory (to avoid binary planting attacks) - Removed Tomboy references (on Unix-like systems) - Various code optimizations - Minor other improvements - {NEWPASSWORD} placeholder: special characters in generated passwords are now transformed correctly based on context (auto-type, command line, etc.) 2010-07-09: 2.12 - Auto-type window definitions in custom window-sequence pairs are now Spr-compiled (i.e. placeholders, environment variables, etc. can be used) - Global auto-type delay: added support for multi-modified keys and special keys - Added 'New Database' application policy flag - Added 'Copy Whole Entries' application policy flag - Multi-monitor support: at startup, KeePass now ensures that the main window's normal area at least partially overlaps the virtual screen rectangle of at least one monitor - RoboForm importer: URLs without protocol prefix are now prefixed automatically (HTTP) - Entry-dependent placeholders can now be used in most trigger events, conditions and actions (the currently focused entry is used) - Auto-type on Unix-like systems: KeePass now shows an informative error message when trying to invoke auto-type without having installed the 'xdotool' package - New column engine: drag&dropping hidden fields works as expected again (the field data is transferred, not asterisks) - Improved restoration of a maximized main window - Improved error message when trying to import/export data from/to a KDB file on a non-Windows operating system - Minor other improvements 2010-07-03: 2.11 - Added entry tags (you can assign tags to entries in the entry editing window or by using the 'Selected Entries' context menu; to list all entries having a specific tag, choose the tag either in the 'Edit' main menu or in the 'Show Entries' toolbar drop-down button) - Completely new entry list column engine; the columns are dynamic now, custom entry strings can be shown in the list, to configure go 'View' -> 'Configure Columns...'; the column engine is also extensible now, i.e. plugins can provide new columns - Added 'Size' entry list column (shows the approximate memory required for the entry) - Added 'History (Count)' entry list column (double-clicking a cell of this column opens the entry editing window and automatically switches to the 'History' tab) - Added 'Expiry Time (Date Only)' entry list column - Added options to specify the number of days until the master key of a database is recommended to and/or must be changed - Added support for exporting selected entries to KDB - Added 'FileSaveAsDirectory' configuration key to specify the default directory for 'Save As' database file dialogs - Double-clicking a history entry in the entry editing dialog now opens/views the entry - It's now possible to tab from menus and toolbars to dialog controls - Added option to turn off hiding in-memory protected custom strings using asterisks in the entry view - Added workaround for FTP servers sending a 550 error after opening and closing a file without downloading data - Added 'Unhide Passwords' application policy flag - Password Depot importer: some icons are converted now - {GOOGLECHROME} placeholder: updated detection code to also support the latest versions of Chrome - The main window now uses the shell font by default - On Windows Vista and higher, Explorer-themed tree and list views are now used in the main window - On Windows 7 and higher, the main window peek preview is now disabled when the KeePass workspace is locked - Installer: added option to optimize the on-demand start-up performance of KeePass - TrlUtil: added 3 dots string validation - Improved entry list item selection performance (defer UI state update on selection change burst) - Improved special key code conversion in KDB importer - Icon picker dialog now has a 'Close' button - When sorting is enabled, the entry list view now doesn't get destroyed anymore when trying to move entries - Main window is now brought to the foreground when untraying - Removed grid lines option - Reduced size of MSI file - Various performance improvements - Various code optimizations - Minor other improvements - No file path is requested anymore when double-clicking an import source that doesn't require a file 2010-03-05: 2.10 - Translation system: added support for right-to-left scripts - Added {HMACOTP} placeholder to generate HMAC-based one-time passwords as specified in RFC 4226 (the shared secret is the UTF-8 representation of the value of the 'HmacOtp-Secret' custom entry string field, and the counter is stored in decimal form in the 'HmacOtp-Counter' field) - On Windows 7, KeePass now shows a 'locked' overlay icon on the taskbar button when the database is locked - On Windows 7, the database loading/saving progress is now shown on the taskbar button - Added option to disable automatic searching for key files - Added KDBX database repair functionality (in File -> Import) - Added support for expired root groups - Added global delay support for shifted special keys - Added 'Change Master Key' application policy flag - Added 'Edit Triggers' application policy flag - Added trigger action to activate a database (select tab) - Added configuration options to allow enforcing states (enabled, disabled, checked, unchecked) of key source controls in the master key creation and prompt dialogs (see 'Composite Master Key' documentation page) - Added option to disable the 'Save' command (instead of graying it out) if the database hasn't been modified - Added support for importing KeePassX 0.4.1 XML files - Added support for importing Handy Safe 5.12 TXT files - Added support for importing Handy Safe Pro 1.2 XML files - Added support for importing ZDNet's Password Pro 3.1.4 TXT files - Added dialog for selecting the encoding of text files to be attached to an entry - Added option to search for passwords in quick finds (disabled by default) - Added Ctrl+S shortcut in the internal data editor - Internal data editor window can now be maximized - Document tabs can now be closed by middle-clicking on them - Most strings in the trigger system are now Spr-compiled (i.e. placeholders, environment variables, etc. can be used) - Added '--lock-all' and '--unlock-all' command line options to lock/unlock the workspaces of all other KeePass instances - Added 'pw-enc' command line option and {PASSWORD_ENC} placeholder - Added preliminary auto-type support for Linux (right-click on an entry and select 'Perform Auto-Type'; the 'xdotool' package is required) - Added option to enforce using the system font when running under KDE and Gnome (option enabled by default) - HTML exports are now XHTML 1.0 compliant - Printing: added option to sort entries - Printing: group names are now shown as headings - KPScript: added '-CreateBackup' option for the EditEntry command (to create backups of entries before modifying them) - The PLGX plugin cache root path can now be specified in the configuration file (Application/PluginCachePath) - Plugin developers: added ability to write entropy providers that can update the internal pool of the cryptographically strong random number generator - Plugin developers: added some public PwEntryForm properties, events and methods - Plugin developers: added entry template events - Plugin developers: added group and entry touching events - Plugin developers: added main window focus changing event - Plugin developers: added support for writing format providers for the internal attachments viewer - Expired icons of groups are non-permanent now - Improved search performance and in-memory protection compatibility - The SendKeys class now always uses the SendInput method (not JournalHook anymore) - Improved auto-type delay handling - Two-channel auto-type obfuscation: added support for default delays - The default auto-type delay is now 10 ms - Improved top-most window auto-type support - Improved high DPI support (text rendering, banners, ...) - Temporary file transaction files are now deleted before writing to them - Broadcasted file IPC notification messages do not wait infinitely for hanging applications anymore - On Windows XP and higher, KeePass now uses alpha-transparent icons in the main entry list - In the entry editing dialog, when moving a custom string to a standard field, the string is now appended to the field (instead of overwriting the previous contents of the field) - Improved UTF-8 encoding (don't emit byte order marks) - Improved field to standard field mapping function - HTML exports do not contain byte-order marks anymore - For improved clarity, some controls are now renamed/changed dynamically when using the password generator without having a database open - Improved auto-type definition conversion for KDB exports - Standard field placeholders are now correctly removed when auto-typing, if the standard field doesn't exist - Improved icon picker cancel blocking when removing an icon - The default workspace locking time is now 300 seconds (but the option is still disabled by default) - Modern task dialogs are now displayed on 64-bit Windows systems, too - Improved file corruption error messages - Improved entry attachments renaming method - Double-clicking an attachment in the entry editing dialog now opens it in the internal viewer (the internal editor can only be invoked in the main window) - When attachments are edited using the internal editor, the entry's last modification time is now updated - Improved plugin loading (detect PLGX cache files) - If the application policy disallows clipboard operations, KeePass doesn't unnecessarily decrypt sensitive data anymore - Added tooltip for the 'View' toolbar drop-down button - Improved menu accelerator and shortcut keys - Upgraded installer - Installer: various minor improvements - Various performance improvements - Various code optimizations - Minor other improvements - No exception is thrown anymore when lowering the clipboard auto-clear time in the options below the value of a currently running clearing countdown - The 'Show expired entries' functionality now also works when there's exactly one matching entry 2009-09-12: 2.09 - Added option to use file transactions when writing databases (enabled by default; writing to a temporary file and replacing the actual file afterwards avoids data loss when KeePass is prevented from saving the database completely) - Added PLGX plugin file format - Enhanced database synchronization by structure merging (relocation/moving and reordering groups and entries) - Added synchronization 'Recent Files' list (in 'File' menu) - Synchronization / import: added merging of entry histories - Synchronization / import: backups of current entries are created automatically, if their data would be lost in the merging process - Database name, description, default user name, entry templates group and the recycle bin settings are now synchronized - Added {NEWPASSWORD} placeholder, which generates a new password for the current entry, based on the "Automatically generated passwords for new entries" generator profile; this placeholder is replaced once in an auto-type process, i.e. for a typical 'Old Password'-'New Password'-'Repeat New Password' dialog you can use {PASSWORD}{TAB}{NEWPASSWORD}{TAB}{NEWPASSWORD}{ENTER} - Added scheme-specific URL overrides (this way you can for example tell KeePass to open all http- and https-URLs with Firefox or Opera instead of the system default browser; PuTTY is set as handler for ssh-URLs by default; see Options -> Integration) - Added option to drop to the background when copying data to the clipboard - Added option to use alternating item background colors in the main entry list (option enabled by default) - The Ctrl+E shortcut key now jumps to the quick search box - Added auto-type sequence conversion routine to convert key codes between 1.x and 2.x format - Added workaround for internal queue issue in SendKeys.Flush - Added more simple clipboard backup routine to workaround clipboard issues when special formats are present - Added native clipboard clearing method to avoid empty data objects being left in the clipboard - Added import support for custom icons - Added {GOOGLECHROME} placeholder, which is replaced by the executable path of Google Chrome, if installed - Added {URL:RMVSCM} placeholder, which inserts the URL of the current entry without the scheme specifier - Added ability to search for UUIDs and group names - Toolbar searches now also search in UUIDs and group names - Added {DELAY=X} placeholder to specify a default delay of X milliseconds between standard keypresses in this sequence - Added option to disable verifying written database files - Attachment names in the entry view are now clickable (to open the attachments in the internal editor or viewer) - Added Unicode support in entry details view - Added option to render menus and toolbars with gradient backgrounds (enabled by default) - MRU lists now have numeric access keys - Added '--entry-url-open' command line option (specify the UUID of the entry as '--uuid:' command line parameter) - Added 'Application initialized' trigger event - Added 'User interface state updated' trigger event - Added host reachability trigger condition - Added 'Active database has unsaved changes' trigger condition - Added 'Save active database' trigger action - Added database file synchronization trigger action - Added database file export trigger action - KeePass now restores the last view when opening databases - Added system-wide hot key to execute auto-type for the currently selected entry (configurable in the options) - Added option to disable auto-type entry matching based on title (by default an entry matches if its title is contained in the target window title) - Added option to disable marking TAN entries as expired when using them - Added option to focus the quick search box when restoring from tray (disabled by default) - Added entry context menu commands to sort by UUID and file attachments - Custom string fields are now appended to the notes when exporting to KeePass 1.x KDB files - Enforced configuration files are now item-based (items not defined in the enforced configuration file are now loaded from the global/local configuration files instead of being set to defaults) - File transactions are used when writing configuration files - KPScript: added 'ChangeMasterKey' command - ShInstUtil: added check for the presence of .NET - TrlUtil: added command under 'Import' that loads 2.x LNGX files without checking base hashes - TrlUtil: added control docking support - Plugin developers: added static window addition and removal events to the GlobalWindowManager class - Plugin developers: added ability to write custom dialog banner generators (CustomGenerator of BannerFactory) - Plugin developers: the IOConnectionInfo of the database is now accessible through the key provider query context - Plugin developers: added static auto-type filter events (plugins can provide own placeholders, do sequence customizations like inserting delays, and provide alternative key sending methods) - Plugin developers: added UIStateUpdated main window event - Simple text boxes now convert rich text immediately - Improved entry change detection (avoid unnecessary backups when closing the entry dialog with [OK] but without any changes; detect by content instead of change events) - Header in entry selection dialog is now non-clickable - Entry list header now uses native sorting icons - Key providers are now remembered separately from key files - The main window is now the owner of the import method dialog - The global URL override is now also applied for main entry URLs in the entry details view - Improved grouping behavior when disabling entry sorting - Improved field mapping in RoboForm import - Root groups now support custom icons - In the entry dialog, string values are now copied to the clipboard instead of asterisks - Improved import/synchronization status dialog - Improved import/synchronization error message dialogs - Entry history items are now identified by the last modification time instead of last access time - The trigger system can now be accessed directly through 'Tools' -> 'Triggers...', not the options anymore - Changed order of commands in the 'Tools' menu - Improved auto-type target window validity checking - Ctrl-V does not make the main window lose the focus anymore if auto-type is disabled for the currently selected entry - When restoring from tray, the main window is now brought to the foreground - Double-clicking an icon in the icon picker dialog now chooses the icon and closes the dialog - When adding a custom icon to the database, the new icon is selected automatically - When opening a database by running KeePass.exe with the database file path as parameter (and single instance option enabled), the existing KeePass instance will not prompt for keys of previously locked databases anymore when restoring (they are just left in locked state) - Unlocking routine doesn't display multiple dialogs anymore - Improved shortcut key handling in main window - Master key change success message now has a distinguishable window title - Improved start position and focus of the URL dialog - Improved layout in options dialog - Improved UUID and UI updates when removing custom icons - Improved window deconstruction when closing with [X] - Improved user activity detection - Improved state updating of sorting context menu commands - Improved sorting by UUIDs - Improved naming of options to clarify their meaning - Converted ShInstUtil to a native application (in order to be able to show a warning in case .NET is not installed) - Plugins: improved IOConnection to allow using registered custom WebRequest descendants (WebRequest.RegisterPrefix) - TrlUtil: improved XML comments generation - Various code optimizations - Minor other improvements - Password profile derivation function doesn't incorrectly always add standard character ranges anymore - In-memory protection for the title field of new entries can be enabled now 2009-07-05: 2.08 - Key transformation library: KeePass can now use Windows' CNG/BCrypt API for key transformations (about 50% faster than the KeePass built-in key transformation code; by increasing the amount of rounds by 50%, you'll get the same waiting time as in 2.07, but the protection against dictionary and guessing attacks is raised by a factor of 1.5; only Windows Vista and higher) - Added support for sending keystrokes (auto-type) to windows that are using different keyboard layouts - Added option to remember key file paths (enabled by default) - Added internal editor for text files (text only and RTF formatted text; editor can edit entry attachments) - Internal data viewer: added support for showing rich text (text with formatting) - Added inheritable group settings for disabling auto-type and searching for all entries in this group (see tab 'Behavior'); for new recycle bins, both properties are set to disabled - Added new placeholders: {DB_PATH}, {DB_DIR}, {DB_NAME}, {DB_BASENAME}, {DB_EXT}, {ENV_DIRSEP}, {DT_SIMPLE}, {DT_YEAR}, {DT_MONTH}, {DT_DAY}, {DT_HOUR}, {DT_MINUTE}, {DT_SECOND}, {DT_UTC_SIMPLE}, {DT_UTC_YEAR}, {DT_UTC_MONTH}, {DT_UTC_DAY}, {DT_UTC_HOUR}, {DT_UTC_MINUTE}, {DT_UTC_SECOND} - The password character picking dialog now supports pre- defining the number of characters to pick; append :k in the placeholder to specify a length of k (for example, {PICKPASSWORDCHARS3:5} would be a placeholder with ID 3 and would pick 5 characters from the password); advantage: when having picked k characters, the dialog closes automatically, i.e. saves you to click [OK] - IDs in {PICKPASSWORDCHARSn} do not need to be consecutive anymore - The password character picking dialog now first dereferences passwords (i.e. placeholders can be used here, too) - Added '-minimize' command line option - Added '-iousername', '-iopassword' and '-iocredfromrecent' command line options - Added '--auto-type' command line option - Added support for importing FlexWallet 1.7 XML files - Added option to disable protecting the clipboard using the CF_CLIPBOARD_VIEWER_IGNORE clipboard format - Added support for WebDAV URLs (thanks to Ryan Press) - Added shortcut keys in master key prompt dialog - Added entry templates functionality (first specify an entry templates group in the database settings dialog, then use the 'Add Entry' toolbar drop-down button) - Added AceCustomConfig class (accessible through host interface), that allows plugins to store their configuration data in the KeePass configuration file - Added ability for plugins to store custom data in KDBX database files (PwDatabase.CustomData) - Added interface for custom password generation algorithm plugins - URLs in the entry preview window are now always clickable (especially including cmd:// URLs) - Added option to copy URLs to the clipboard instead of opening them (Options -> Interface, turned off by default) - Added option to automatically resize entry list columns when resizing the main window (turned off by default) - Added 'Sync' command in KPScript scripting tool - Added FIPS compliance problems self-test (see FAQ for details about FIPS compliance) - Added Rijndael/AES block size validation and configuration - Added NotifyIcon workaround for Mono under Mac OS X - Added confirmation box for empty master passwords - Added radio buttons in auto-type sequence editing dialog to choose between the default entry sequence and a custom one - Added hint that group notes are shown in group tooltips - Added test for KeePass 1.x plugins and an appropriate error message - Added interface for writing master password requirements validation plugins - Key provider plugin API: enhanced key query method by a context information object - Key provider plugin API: added 'DirectKey' property to key provider base class that allows returning keys that are directly written to the user key data stream - Key provider plugin API: added support for exclusive plugins - The '-keyfile' command line option now supports selecting key providers (plugins) - Auto-Type: added option to send an Alt keypress when only the Alt modifier is active (option enabled by default) - Added warning when trying to use only Alt or Alt-Shift as global hot key modifier - TrlUtil: added search functionality and toolbar - TrlUtil: version is now shown in the window title - Improved database file versioning and changed KDBX file signature in order to prevent older versions from corrupting newer files - ShInstUtil now first tries to uninstall a previous native image before creating a new one - Improved file corruption error messages (instead of index out of array bounds exception text, ...) - The 'Open in Browser' command now opens all selected entries instead of just the focused one - Data-editing commands in the 'Tools' menu in the entry dialog are now disabled when being in history viewing mode - Right arrow key now works correctly in group tree view - Entry list is now updated when selecting a group by pressing a A-Z, 0-9 or numpad key - Improved entry list performance and sorting behavior - Improved splitter distance remembering - Improved self-tests (KeePass now correctly terminates when a self-test fails) - The attachment column in the main window now shows the names of the attached files instead of the attachments count - Double-clicking an attachment field in the main window now edits (if possible) or shows the first attachment of the entry - Group modification times are now updated after editing groups - Improved scrolling of the entry list in item grouping mode - Changed history view to show last modification times, titles and user names of history entries - KeePass now also automatically prompts to unlock when restoring to a maximized window - Improved file system root directory support - Improved generic CSV importer preview performance - When saving a file, its path is not remembered anymore, if the option for opening the recently used file at startup is disabled - Improved auto-type input blocking - Instead of a blank text, the entry dialog now shows "(Default)" if the default auto-type sequence is used in a window-sequence association - Most broadcasted Windows messages do not wait for hanging applications anymore - Improved main window hiding at startup when the options to minimize after opening a database and to tray are enabled - Default tray action is now dependent on mouse button - New entries can now inherit custom icons from their parent groups - Improved maximized state handling when exiting while the main window is minimized - Improved state updating in key creation form - Improved MRU list updating performance - Improved plugin incompatibility error message - Deprecated {DOCDIR}, use {DB_DIR} instead ({DOCDIR} is still supported for backward compatibility though) - Last modification times of TAN entries are now updated - F12 cannot be registered as global hot key anymore, because it is reserved for kernel-mode / JIT debuggers - Improved auto-type statement conversion routine in KeePass 1.x KDB file importer - Improved column width calculation in file/data format dialog - Improved synchronization status bar messages - TrlUtil: base hash for forms is now computed using the form's client rectangle instead of its window size - Various code optimizations - Minor other improvements - Recycle bin is now cleared correctly when clearing the database 2009-03-14: 2.07 Beta - Added powerful trigger system (when events occur, check some conditions and execute a list of actions; see options dialog in 'Advanced'; more events / conditions / actions can be added later based on user requests, and can also be provided by plugins) - Native master key transformations (rounds) are now computed by the native KeePassLibC support library (which contains the new, highly optimized transformation code used by KeePass 1.15, in two threads); on dual/multi core processors this results in almost triple the performance as before (by tripling the amount of rounds you'll get the same waiting time as in 2.06, but the protection against dictionary and guessing attacks is tripled) - Added recycle bin (enabled by default, it can be disabled in the database settings dialog) - Added Salsa20 stream cipher for CryptoRandomStream (this algorithm is not only more secure than ArcFour, but also achieves a higher performance; CryptoRandomStream defaults to Salsa20 now; port developers: KeePass uses Salsa20 for the inner random stream in KDBX files) - KeePass is now storing file paths (last used file, MRU list) in relative form in the configuration file - Added support for importing 1Password Pro CSV files - Added support for importing KeePass 1.x XML files - Windows XP and higher: added support for double-buffering in all list views (including entry lists) - Windows Vista and higher: added support for alpha-blended marquee selection in all list views (including entry lists) - Added 'EditEntry', 'DeleteEntry', 'AddEntries' and 'DeleteAllEntries' commands in KPScript scripting tool - Added support for importing special ICO files - Added option to exit instead of locking the workspace after the specified time of inactivity - Added option to minimize the main window after locking the KeePass workspace - Added option to minimize the main window after opening a database - Added support for exporting to KDBX files - Added command to remove deleted objects information - TrlUtil now checks for duplicate accelerator keys in dialogs - Added controls in the entry editing dialog to specify a custom text foreground color for entries - KeePass now retrieves the default auto-type sequence from parent groups when adding new entries - The password character picking dialog can now be invoked multiple times when auto-typing (use {PICKPASSWORDCHARS}, {PICKPASSWORDCHARS2}, {PICKPASSWORDCHARS3}, etc.) - Added '-set-urloverride', '-clear-urloverride' and '-get-urloverride' command line options - Added '-set-translation' command line option - Added option to print custom string fields in details mode - Various entry listings now support custom foreground and background colors for entry items - Added 'click through' behavior for menus and toolbars - File association methods are now UAC aware - User interface is now blocked while saving to a file (in order to prevent accidental user actions that might interfere with the saving process) - Improved native modifier keys handling on 64-bit systems - Improved application startup performance - Added image list processing workaround for Windows 7 - OK button is now reenabled after manually activating the key file checkbox and selecting a file in the master key dialog - The master key dialog now appears in the task bar - When KeePass is minimized to tray and locked, pressing the global auto-type hot key doesn't restore the main window anymore - The installer now by default installs KeePass 1.x and 2.x into separate directories in the program files folder - The optional autorun registry keys of KeePass 1.x and 2.x do not collide anymore - File type association identifiers of KeePass 1.x and 2.x do not collide anymore - File MRU list now uses case-insensitive comparisons - Improved preview updates in Print and Data Viewer dialogs - Message service provider is thread safe now - Threading safety improvements in KPScript scripting plugin - Improved control state updates in password generator dialog - Improved master password validation in 'New Database' dialog - Times are now stored as UTC in KDBX files (ISO 8601 format) - Last access time fields are now updated when auto-typing, copying fields to the clipboard and drag&drop operations - KPScript scripting tool now supports in-memory protection - Database is not marked as modified anymore when closing the import dialog with Cancel - Added asterisks in application policy editing dialog to make clearer that changing the policy requires a KeePass restart - Double-clicking a format in the import/export dialog now automatically shows the file browsing dialog - Improved permanent entry deletion confirmation prompt - Improved font objects handling - Expired groups are now rendered using a striked out font - Improved auto-type statement conversion routine in KeePass 1.x KDB file importer - Clipboard clearing countdown is not started anymore when copying data fails (e.g. policy disabled) - Improved synchronization with URLs - The database maintenance dialog now only marks the database as modified when it actually has removed something - KeePass now broadcasts a shell notification after changing the KDBX file association - Improved warning message when trying to directly open KeePass 1.x KDB files - Improved Linux / Mac OS X compatibility - Improved MSI package (removed unnecessary dependency) - TrlUtil: improved NumericUpDown and RichTextBox handling - Installer now checks for minimum operating system version - Installer: file association is now a task, not a component - Installer: various other improvements - Various code optimizations - Minor other improvements - When cloning a group tree using drag&drop, KeePass now assigns correct parent group references to cloned groups and entries - Fixed crash when clicking 'Cancel' in the settings dialog when creating a new database 2008-11-01: 2.06 Beta - Translation system is now complete (translations to various languages will be published on the KeePass translations page when translators finish them) - When saving the database, KeePass now first checks whether the file on disk/server has been modified since it was loaded and if so, asks the user whether to synchronize with the changed file instead of overwriting it (i.e. multiple users can now use a shared database on a network drive) - Database files are now verified (read and hashed) after writing them to disk (in order to prevent data loss caused by damaged/broken devices and/or file systems) - Completely new auto-type/URL placeholder replacement and field reference engine - On Windows Vista, some of the message boxes are now displayed as modern task dialogs - KeePass is now also available as MSI package - Accessibility: added advanced option to optimize the user interface for screen readers (only enable this option if you're really using a screen reader) - Added standard client icons: Tux, feather, apple, generic Wiki icon, '$', certificate and BlackBerry - Secure edit controls in the master key and entry dialogs now accept text drops - Added ability to store notes for each group (see 'Notes' tab in the group editing window), these notes are shown in the tooltip of the group in the group tree of the main window - Group names in the entry details view are now clickable; click it to jump to the group of the entry (especially useful for jumping from search results to the real group of an entry) - Added 'GROUPPATH', 'DELAY' and 'PICKPASSWORDCHARS' special placeholders to auto-type sequence editing dialog - Wildcards (*) may now also appear in the middle of auto-type target window filters - For auto-type target window filters, regular expressions are now supported (enclose in //) - KeePass now shows an explicit file corruption warning message when saving to a file fails - Added option to prepend a special auto-type initialization sequence for Internet Explorer and Maxthon windows to fix a focus issue (option enabled by default) - Added ability to specify a minimum length and minimum estimated quality that master passwords must have (see help file -> Features -> Composite Master Key; for admins) - Added field reference creation dialog (accessible through the 'Tools' menu in the entry editing dialog) - Field references are dereferenced when copying data to the clipboard - Entry field references are now dereferenced in drag&drop operations - KeePass now follows field references in indirect auto-type sequence paths - Added internal field reference cache (highly improves performance of multiple-cyclic/recursive field references) - Added managed system power mode change handler - Added "Lock Workspace" tray context menu command - Moved all export commands into a new export dialog - Added context menu command to export the selected group only - Added context menu command to export selected entries only - Added support for importing Password Memory 2008 XML files - Added support for importing Password Keeper 7.0 CSV files - Added support for importing Passphrase Keeper 2.70 HTML files - Added support for importing data from PassKeeper 1.2 - Added support for importing Mozilla bookmarks JSON files (Firefox 3 bookmark files) - Added support for exporting to KeePass 1.x CSV files - Added XSL transformation file to export passwords only (useful for generating and exporting password lists) - Added support for writing databases to hidden files - When passing '/?', '--help' or similar on the command line, KeePass will now open the command line help - When single instance mode is enabled and a second instance is started with command line parameters, these parameters are now sent to the already open KeePass instance - KeePass now ships with a compiled XML serializer library, which highly improves startup performance - Added support for Uniform Naming Convention (UNC) paths (Windows) in the URL field (without cmd:// prefix) - Added option to exclude expired entries in the 'Find' dialog - Added option to exclude expired entries in quick searches (toolbar; disabled by default) - The box to enter the name of a custom string field is now a combobox that suggests previously-used names in its drop-down list - Added Shift, Control and Alt key modifiers to placeholder overview in the auto-type sequence editing dialog - Added support for 64 byte key files which don't contain hex keys - Added Ctrl-Shift-F accelerator for the 'Find in this Group' context menu command (group tree must have the focus) - Added export ability to KPScript plugin - Ctrl-Tab now also works in the password list, groups tree and entry details view - Added multi-user documentation - Plugin developers: DocumentManagerEx now has an ActiveDocumentSelected event - Plugin developers: instead of manually setting the parent group property and adding an object to a group, use the new AddEntry / AddGroup methods of PwGroup (can take ownership) - Plugins can now add new export file formats (in addition to import formats) - Plugins: added static message service event - When using the installation package and Windows Vista, settings are now stored in the user's profile directory (instead of Virtual Store; like on Windows XP and earlier) - Accessibility: multi-line edit controls do not accept tabs anymore (i.e. tab jumps to the next dialog control), and inserting a new line doesn't require pressing Ctrl anymore - When moving entries, KeePass doesn't switch to the target group anymore - When deleting entries from the search results, the entry list is not cleared anymore - Improved entry duplication method (now also works correctly in search results list and grouped list views) - A more useful error message is shown when checking for updates fails - Improved formats sorting in the import dialog - The 'Limit to single instance' option is now turned on by default (multiple databases are opened in tabs) - Removed 'sort up', 'sort down' and empty client icons - Improved program termination code (common clean-up) - Improved error message that is shown when reading/writing the protected user key fails - The key file selection dialog now by default shows all files - Plugins: improved event handlers (now using generic delegate) - Implemented several workarounds for Mono (1.9.1+) - Added conformance level specification for XSL transformations (in order to improve non-XML text exports using XSLT) - Improved key state toggling for auto-type on 64-bit systems - Removed several unnecessary .NET assembly dependencies - Threading safety improvements - Highly improved entry context menu performance when many entries are selected - Entry selection performance improvements in main window - Improved entries list view performance (state caching) - List view group assignment improvements (to avoid splitting) - Removed tab stops from quality progress bars - After moving entries to a different group, the original group is selected instead of the target group - Layout and text improvements in the master key creation form - Text in the URL field is now shown in blue (if it's black in the standard theme) - Improved auto-type tab in entry dialog (default sequence) - Improved AES/Rijndael cipher engine initialization - Improved build scripts - Various code optimizations - Minor other improvements - Installer: changed AppId to allow parallel installation of KeePass 1.x and 2.x - Minor other installer improvements - The 'View' -> 'Show Columns' -> 'Last Access Time' menu command now works correctly - The 'Clipboard' -> 'Paste Entries' menu command now assigns correct group references to pasted entries 2008-04-08: 2.05 Alpha - Added placeholders for referencing fields of other entries (dereferenced when starting URLs and performing auto-type, see the auto-type placeholders documentation) - Added natural sorting (when sorting the entry list, KeePass now performs a human-like comparison instead of a simple lexicographical one; this sorts entries with numbers more logically) - Added support for importing RoboForm passcards (HTML) - Added {DELAY X} auto-type command (to delay X milliseconds) - Added {GROUPPATH} placeholder (will be replaced by the group hierarchy path to the entry; groups are separated by dots) - When saving databases to removable media, KeePass now tries to lock and unlock the volume, which effectively flushes all system caches related to this drive (this prevents data loss caused by removing USB sticks without correctly unmounting in Windows first; but it only works when no other program is using the drive) - Added pattern placeholder 's' to generate special characters of the printable 7-bit ASCII character set - A " - Copy" suffix is now appended to duplicated entries - After duplicating entries, the new entries are selected - The list view item sorter now supports dates/times, i.e. sorting based on entry times is logically now, not lexicographically - Added GUI option to focus the entry list after a successful quick search (toolbar; disabled by default) - Several entry context menu commands are now only enabled if applicable (if the user name field of an entry is empty, the 'Copy User Name' command is disabled, etc.) - Added a 'Tools' button menu in the entry editing dialog - Tools button menu: Added command to select an application for the URL field (will be prefixed with cmd://) - Tools button menu: Added command to select a document for the URL field (will be prefixed with cmd://) - Added password generator option to exclude/omit user-specified characters in generated passwords - Added clearification paragraph in master key creation dialog about using the Windows user account as source (backup, ...) - Added menu command to synchronize with an URL (database stored on a server) - KeePass is now checking the network connection immediately when trying to close the URL dialog - Added file closed event arguments (IO connection info) - Added "file created" event for plugins - The document manager is now accessible by plugins - Improved field to standard field mapping function - KeePass now locks when the system is suspending (if the option for locking on locking Windows or switching user is enabled) - All documents are now locked when the session is ended or the user is switched (if the option for this is enabled) - Moving a group into one of its child groups does not make the group vanish anymore - Auto-type validator now supports "{{}" and "{}}" sequences (i.e. auto-type can send '{' and '}' characters) - Undo buffers of secure edit controls are now cleared correctly - Disabling sorting does not clear search results anymore - Entry editing dialog: Return and Esc work correctly now - Column sort order indicators are now rendered using text instead of images (improves Windows Vista compatibility) - Splitter positions are now saved correctly when exiting after minimizing the main window to tray - Added handler code for some more unsupported image file format features (when importing special ICO files) - Translation system is now about 75% complete - KeePass is now developed using Visual Studio 2008 - Minor UI improvements - Minor Windows installer improvements - The CSV importer does not crash anymore when clicking Cancel while trying to import entries into an empty folder - IO connection credentials saving works correctly now - Fixed duplicate accelerator keys in the entry context menu - Help button in master key creation dialog now works correctly 2008-01-06: 2.04 Alpha - Added key provider API (it now is very easy to write a plugin that provides additional key methods, like locking to USB device ID, certificates, smart cards, ... see the developers section in the online KeePass help center) - Added option to show entries of sub-groups in the entry list of a group (see 'View' -> 'Show Entries of Sub-Groups') - Added XML valid characters filter (to prevent XML document corruption by ASCII/DOS control characters) - Added context menu command to print selected entries only - Added option to disallow repeating characters in generated passwords (both character set-based and pattern-based) - Moved security-reducing / dangerous password generator options to a separate 'Advanced' tab page (if you enable a security-reducing option, an exclamation mark (!) is appended to the 'Advanced' tab text) - Added 'Get more languages' button to the translations dialog - Added textual cue for the quick-search edit control - The TAN wizard now shows the name of the group into which the TANs will be imported - Improved random number generator (it now additionally collects system entropy manually and hashes it with random numbers provided by the system's default CSP and a counter) - For determining the default text in the 'Override default sequence' edit box in the 'Edit Entry' window, KeePass now recursively traverses up the group tree - Last entry list sorting mode (column, ascending / descending) is now remembered and restored - First item in the auto-type entry selection window is now focused (allowing to immediately navigate using the keyboard) - Text in secure edit controls is now selected when the control gets the focus the first time - For TAN entries, only a command 'Copy TAN' is now shown in the context menu, others (that don't apply) are invisible - Regular expressions are validated before they are matched - KeePass now checks the auto-type string for invalid entry field references before sending it - The clipboard auto-clear information message is now shown in the status bar instead of the tray balloon tooltip - Matching entries are shown only once in the search results list, even when multiple fields match the search text - First item of search results is selected automatically, if no other item is already selected (selection restoration) - Entries with empty titles do not match all windows any more - Improved high DPI support in entry window - When having enabled the option to automatically lock the workspace after some time and saving a file fails, KeePass will prompt again after the specified amount of time instead of 1 second - KeePass now suggests the current file name as name for new files (save as, save as copy) - The password generator profile combo box can now show more profiles in the list without scrolling - Improved native methods exception handling (Mono) - Updated CHM documentation file - TAN wizard now assigns correct indices to TANs after new line characters - Copying KeePass entries to the clipboard now works together with the CF_CLIPBOARD_VIEWER_IGNORE clipboard format - KeePass now uses the correct client icons image list immediately after adding a custom icon to the database - Fixed 'generic error in GDI+' when trying to import a 16x16 icon (thanks to 'stroebele' for the patch) - File close button in the toolbar (multiple files) works now - Fixed minor bug in provider registration of cipher pool 2007-10-11: 2.03 Alpha - Added multi-document support (tabbed interface when multiple files are opened) - KeePass 2.x now runs on Windows 98 / ME, too! (with .NET 2.0) - Added option to permute passwords generated using a pattern (this allows generating passwords that follow complex rules) - Added option to start minimized and locked - Added support for importing Passwort.Tresor XML files - Added support for importing SplashID CSV files - Added '--exit-all' command line parameter; call KeePass.exe with this parameter to close all other open KeePass instances (if you do not wish to see the 'Save?' confirmation dialog, enable the 'Automatically save database on exit' option) - Added support for CF_CLIPBOARD_VIEWER_IGNORE clipboard format (clipboard viewers/extenders compliant with this format ignore data copied by KeePass) - Added support for synchronizing with multiple other databases (select multiple files in the file selection dialog) - Added ability to specify custom character sets in password generation patterns - Added pattern placeholder 'S' to generate printable 7-bit ASCII characters - Added pattern placeholder 'b' to generate brackets - Added support for starting very long command lines - Entry UUID is now shown on the 'Properties' tab page - Added Spanish language for installer - KeePass now creates a mutex in the global name space - Added menu command to save a copy of the current database - The database name is now shown in the title of the 'Enter Password' window - Added "Exit" command to tray icon context menu - Pressing the 'Enter' key in the password list now opens the currently selected entry for editing - Added '-GroupName:' parameter for 'AddEntry' command in the KPScript KeePass scripting tool (see plugins web page) - Added URL example in 'Open URL' dialog - Added support for plugin namespaces with dots (nested) - Added ability to specify the characters a TAN can consist of - '-' is now treated as TAN character by default, not as separator any more - Added ability to search using a regular expression - Notes in the entry list are now CR/LF-filtered - Added {PICKPASSWORDCHARS} placeholder, KeePass will show a dialog which allows you to pick certain characters - The password generator dialog is now shown in the Windows taskbar if the main window is minimized to tray - Caps lock is now disabled before auto-typing - Improved installer (added start menu link to the CHM help file, mutex checking at uninstallation, version information block, ...) - Plugin architecture: added cancellable default entry action event handler - Added support for subitem infotips in various list controls - Group name is now shown in the 'Find' dialog (if not root) - Pressing the 'Insert' key in the password list now opens the 'Add Entry' dialog - Last search settings are now remembered (except search text) - The column order in the main window is now remembered - Pressing F2 in the groups tree now initiates editing the name of the currently selected group - Pressing F2 in the password list now opens the editing dialog - The 'About' dialog is now automatically closed when clicking an hyperlink - Entries generated by 'Tools' - 'Password Generator' are now highlighted in the main window (visible and selected) - Extended auto-close functionality to some more dialogs - Protected user key is now stored in the application data directory instead of the registry (when upgrading from 2.02, first change the master key so it doesn't use the user account credentials option!) - Improved configuration file format (now using XML serialization, allowing serialization of complex structures) - Improved configuration saving/loading (avoid file system virtualization on Windows Vista when using the installer, improved out of the box support for installation by admin / usage by user, better limited user account handling, ...) - Improved password generator profile management (UI) - Improved password generator character set definition - Custom icons can be deleted from the database now - Changed password pattern placeholders to support ANSI - Removed plugin projects from core distribution (plugin source codes will be available separately, like in 1.x) - Window position and size is saved now when exiting KeePass while minimized - Splitter positions are restored correctly now when the main window is maximized - Password list refreshes now restore the previous view (including selected and focused items, ...) - Improved session ending handler - Improved help menu - Added more JPEG extensions in the icon dialog (JFIF/JFI/JIF) - Navigation through the group tree using the keyboard is now possible (entries list is updated) - Options dialog now remembers the last opened tab page - Synchronization: deletion information is merged correctly now - Improved importing status dialog - Improved search results presentation - Title field is now the first control in the focus cycle of the entry dialog - The auto-type entry selection dialog now also shows custom / imported icons - The quick-find box now has the focus after opening a database - The main window title now shows 'File - KeePass Password Safe' instead of 'KeePass Password Safe [File]'; improved tooltip text for tray icon - The 'Save Attachments' context menu command is disabled now if the currently selected entry doesn't have any attachments - A more useful error message is shown when trying to import an unsupported image format - Replaced 'Search All Fields' by an additional 'Other' option - Expired/used TAN entries are not shown in the expired entries dialog any more - UI now mostly follows the Windows Vista UI text guidelines - Improved UI behavior in options dialog - Improved text in password generator preview window - After activating a language, the restart dialog is only shown if the selected language is different from the current one - Online help browser is now started in a separate thread - Value field in 'Edit String' window now accepts 'Return' key - The name prompt in the 'Edit String' window now initially shows a prompt instead of an invalid field name warning - Expired entries are now also shown when unlocking the database - Expired entries are not shown any more in the auto-type entry selection dialog - Various dialogs: Return and Esc work correctly now - Improved key handling in password list - Updated SharpZipLib component in KeePassLibSD - Updated CHM documentation file - Deleting custom string fields of entries works correctly now - Fixed a small bug in the password list view restoration routines (the item above the previous top one was visible) - KeePass doesn't prevent Windows from shutting down any more when the 'Close button minimizes window' option is enabled - The "Application Policy Help" link in the options dialog works now - KeePass doesn't crash any more when viewing an history entry that has a custom/imported icon - Icon in group editing dialog is now initialized correctly - Last TAN is not ignored any more by the TAN wizard - Other minor features and bugfixes 2007-04-11: 2.02 Alpha - Added "Two-Channel Auto-Type Obfuscation" feature, which makes auto-type resistant against keyloggers; this is an opt- in feature, see the documentation - Added KDBX data integrity verification (partial content hashes); note: this is a breaking change to the KDBX format - Added internal data viewer to display attachments (text files, images, and web documents); see the new 'View' button in the 'Edit Entry' window and the new dynamic entry context menu popup 'Show In Internal Viewer' - External images can now be imported and used as entry icons - Added KeePassLibC and KeePassNtv 64-bit compatibility - Added Spamex.com import support - Added KeePass CSV 1.x import support - When adding a group, users are immediately prompted for a name (like Windows Explorer does when creating new folders) - Added prompts for various text boxes - The installer's version is now set to the KeePass version - The key prompt dialog now shows an 'Exit' button when unlocking a database - Added F1 menu shortcut for opening the help file/page - URL override is now displayed in the entry view - Added ability to check if the composite key is valid immdiately after starting to decrypt the file - Added ability to move groups on the same level (up / down), use either the context menu or the Alt+... shortcuts - The database isn't marked as modified any more when closing the 'Edit Entry' dialog with OK but without modifying anything - Added version information for native transformations library - Local file name isn't displayed any more in URL dialog - Improved path clipping (tray text, ...) - Improved data field retrieval in SPM 2007 import module - Improved attachments display/handling in 'Edit Entry' dialog - Improved entry context menu (added some keyboard shortcut indicators, updated icons, ...) - Improved performance of secure password edit controls - Clearified auto-type documentation - Installer uses best compression now - Improved auto-type state handling - In-memory protected custom strings are hidden by asterisks in the entry details window now - Improved entropy collection dialog - Updated import/export documentation - Added delete shortcut key for deleting groups - Instead of showing the number of attachments in the entry view, the actual attachment names are shown now - Improved asterisks hiding behavior in entry view - New entries now by default inherit the icon of their parent groups, except if it's a folder-like icon - Updated AES code in native library - Improved native library detection and configuration - Improved entry/group dragging behavior (window updates, ...) - A more useful error message is shown when you try to export to a KDB3 file without having KeePassLibC installed - Configuration class supports DLL assemblies - KeePass doesn't create an empty directory in the application data path any more, if the global config file is writable - Clipboard isn't cleared any more at exit if it doesn't contain data copied by KeePass - Empty auto-type sequences in custom window-sequence pairs now map to the inherited ones or default overrides, if specified - Cleaned up notify tray resources - Improved help menu - A *lot* code quality improvements - ShInstUtil doesn't crash any more when called without any parameter - Auto-type now sends modifier keys (+ for Shift, % for Alt, ...) and character groups correctly - Fixed alpha transparency multi-shadow bug in groups list - Overwrite confirmation now isn't displayed twice any more when saving an attachment from the 'Edit Entry' window - User interface state is updated after 'Select All' command - Auto-Type warnings are now shown correctly - Fixed auto-type definition in sample entry (when creating a new database) - The global auto-type hot key now also works when KeePass is locked and minimized to tray - Fixed bug in initialization of Random class (KeePass could have crashed 1 time in 2^32 starts) 2007-03-23: 2.01 Alpha - Improved auto-type engine (releases and restores modifier keys, improved focusing, etc.) - Implemented update-checking functionality - Added KPScript plugin (see source code package) for scripting (details about it can be found in the online help center) - Added Whisper 32 1.16 import support - Added Steganos Password Manager 2007 import support - Search results now show the full path of the container group - Entry windows (main password list, auto-type entry selection dialog, etc.) now show item tooltips when hovering over them - Added window box drop-down hint in the auto-type item dialog - Database maintenance history days setting is now remembered - Improved main window update after importing a file - Improved command line handling - If opening/starting external files fails, helpful messages are displayed now - Completely new exception handling mechanism in the Kdb4File class (allows to show more detailed messages) - New message service class (KeePassLib.Utility.MessageService) - Added option to disable remembering the password hiding setting in the 'Edit Entry' window - Added menu shortcuts for opening the current entry URL (Ctrl+U) and performing current entry auto-type (Ctrl+V) - Changed file extension to KDBX - Password generation profiles are now saved when the dialog is closed with 'Close'/'Cancel' - Entry URL overrides now precede the global URL override - Standard password generation profiles are now included in the executable file - Restructured plugin architecture, it's much clearer now (abstract base class, assembly-internal manager class, ...) - Only non-empty strings are now displayed in the entry view - Current working directory is set to the KeePass application directory before executing external files/URLs - Changed fields shown in the auto-type entry selection dialog: title, user name and URL are displayed instead of title, user name and password - Clearified clipboard commands in context menus - Help buttons now open the correct topics in the CHM - Fixed name in the installer script - Workspace is not locked any more if a window is open (this prevents data loss) - The 'Find' toolbar button works now - The OK button in the Import dialog is now enabled when you manually enter a path into the file text box - Fixed entry list focus bug - Fixed menu focus bug - The 'Copy Custom String' menu item doesn't disappear any more - Fixed enabled/disabled state of auto-type menu command 2007-03-17: 2.00 Alpha - Strings containing quotes are now passed correctly over the command-line - Created small help file with links to online resources - Rewrote cipher engines pool - Restructured KeePassLib - Added dialog for browser selection - Added option to disable searching for key files on removable media - Improved KDB3 support (especially added support for empty times as created by the KeePass Toolbar for example) - Added confirmations for deleting entries and groups - Fixed a lot of bugs and inconsistencies; added features - Fixed a bug in the 'Start KeePass at Windows startup' registration method - Added custom split container control to avoid focus problems - Clipboard is only cleared if it contains KeePass data - New system for configuration defaults - A LOT of other features, bugfixes, ... ... (a lot of versions here) ... 2006-10-07: 2.00 Pre-Alpha 29 - Various small additions and bugfixes 2006-10-06: 2.00 Pre-Alpha 28 - Implemented entry data drag-n-drop for main entry list - Implemented URL overriding - Added {} repeat operator in password generator - Added database maintenance dialog (deleting history entries) - Custom entry strings are now shown in the entry preview - Added alternative window layout: side by side - A lot of other features and bugfixes ... (some versions here) ... 2006-09-17: 2.00 Pre-Alpha 25 - Fixed exception that occured when WTS notifications are unavailable 2006-09-16: 2.00 Pre-Alpha 24 - Implemented quality progress bars (gradient bars) - Added special key codes into placeholder insertion field in the 'Edit AutoType' dialog - Currently opened windows are listed in the 'Edit AutoType' dialog - Entries can be copied/pasted to/from Windows clipboard - Added {APPDIR}, {DOCDIR} and {GROUP} codes - Foreground and background colors can be assigned to entries - Expired entries are displayed using a striked-out font - Password generator supports profiles now - Password generator supports patterns now - VariousImport: Added support for Password Exporter XML files - A _lot_ of other features and bugfixes 2006-09-07: 2.00 Pre-Alpha 23 - Internal release 2006-09-07: 2.00 Pre-Alpha 22 - Improved password quality estimation - Implemented secure edit controls (in key creation dialog, key prompt dialog and entry editing dialog) 2006-09-05: 2.00 Pre-Alpha 21 - Removed BZip2 compression - Added font selection for main window lists - Added file association creation/removal buttons in the options dialog - Installer supports associating KDB files with KeePass - Added option to run KeePass at Windows startup (for current user; see Options dialog, Integration page) - Added default tray action (sending/restoring to/from tray) - Added single-click option for default tray action - Added option to automatically open last used database on KeePass startup (see Options dialog, Advanced page) - Added option to automatically save the current database on exit and workspace locking (Options dialog, Advanced page) - Implemented system-wide KeePass application messages - Added 'Limit to single instance' option - Added option to check for update at KeePass startup - Added options to show expired entries and entries that will expire soon after opening a database - Added option to generate random passwords for new entries - Links in the entry view are clickable now - Links in the notes field of the entry dialog are clickable now - Fixed context menu auto-type command (inheriting defaults) - Improved entry list state updating performance - Classic databases are listed in the main MRU list, prefixed with '[Classic]' - Other features and bugfixes 2006-09-03: 2.00 Pre-Alpha 20 - First testing release ... (a lot of versions here) ... 2006-03-21: 2.00 Pre-Alpha 0 - Project started keepass2-2.25/ShInstUtil/0000775000175000017500000000000012273663444015174 5ustar jtaylorjtaylorkeepass2-2.25/ShInstUtil/ShInstUtil.rc0000664000175000017500000000534212273657250017572 0ustar jtaylorjtaylor// Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // German (Germany) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) #ifdef _WIN32 LANGUAGE LANG_GERMAN, SUBLANG_GERMAN #pragma code_page(1252) #endif //_WIN32 #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE BEGIN "resource.h\0" END 2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END 3 TEXTINCLUDE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED #endif // German (Germany) resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION 2,25,0,0 PRODUCTVERSION 2,25,0,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x4L FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "Dominik Reichl" VALUE "FileDescription", "ShInstUtil - KeePass Helper Utility" VALUE "FileVersion", "2, 25, 0, 0" VALUE "InternalName", "ShInstUtil" VALUE "LegalCopyright", "Copyright (c) 2007-2014 Dominik Reichl" VALUE "OriginalFilename", "ShInstUtil.exe" VALUE "ProductName", "ShInstUtil - KeePass Helper Utility" VALUE "ProductVersion", "2, 25, 0, 0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED keepass2-2.25/ShInstUtil/ShInstUtil.vcproj0000664000175000017500000001053512167520112020455 0ustar jtaylorjtaylor keepass2-2.25/ShInstUtil/ShInstUtil.sln0000664000175000017500000000156511632635050017755 0ustar jtaylorjtaylor Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ShInstUtil", "ShInstUtil.vcproj", "{C9FBA6FD-04AC-4B2F-8277-B852B8013DAE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C9FBA6FD-04AC-4B2F-8277-B852B8013DAE}.Debug|Win32.ActiveCfg = Debug|Win32 {C9FBA6FD-04AC-4B2F-8277-B852B8013DAE}.Debug|Win32.Build.0 = Debug|Win32 {C9FBA6FD-04AC-4B2F-8277-B852B8013DAE}.Release|Win32.ActiveCfg = Release|Win32 {C9FBA6FD-04AC-4B2F-8277-B852B8013DAE}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal keepass2-2.25/ShInstUtil/ShInstUtil.cpp0000664000175000017500000002203012261554706017740 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 */ #include "ShInstUtil.h" #pragma warning(push) #pragma warning(disable: 4996) // SCL warning #include #include #pragma warning(pop) static const std_string g_strNGenInstall = _T("ngen_install"); static const std_string g_strNGenUninstall = _T("ngen_uninstall"); static const std_string g_strNetCheck = _T("net_check"); static const std_string g_strPreLoadRegister = _T("preload_register"); static const std_string g_strPreLoadUnregister = _T("preload_unregister"); static LPCTSTR g_lpPathTrimChars = _T("\"' \t\r\n"); int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hInstance); UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); UNREFERENCED_PARAMETER(nCmdShow); INITCOMMONCONTROLSEX icc; ZeroMemory(&icc, sizeof(INITCOMMONCONTROLSEX)); icc.dwSize = sizeof(INITCOMMONCONTROLSEX); icc.dwICC = ICC_STANDARD_CLASSES; InitCommonControlsEx(&icc); std_string strCmdLine = GetCommandLine(); boost::trim_if(strCmdLine, boost::is_any_of(g_lpPathTrimChars)); std::transform(strCmdLine.begin(), strCmdLine.end(), strCmdLine.begin(), tolower); if((strCmdLine.size() >= g_strNGenInstall.size()) && (strCmdLine.substr( strCmdLine.size() - g_strNGenInstall.size()) == g_strNGenInstall)) { UpdateNativeImage(false); Sleep(200); UpdateNativeImage(true); } if((strCmdLine.size() >= g_strNGenUninstall.size()) && (strCmdLine.substr( strCmdLine.size() - g_strNGenUninstall.size()) == g_strNGenUninstall)) { UpdateNativeImage(false); } if((strCmdLine.size() >= g_strPreLoadRegister.size()) && (strCmdLine.substr( strCmdLine.size() - g_strPreLoadRegister.size()) == g_strPreLoadRegister)) { RegisterPreLoad(true); } if((strCmdLine.size() >= g_strPreLoadUnregister.size()) && (strCmdLine.substr( strCmdLine.size() - g_strPreLoadUnregister.size()) == g_strPreLoadUnregister)) { RegisterPreLoad(false); } if((strCmdLine.size() >= g_strNetCheck.size()) && (strCmdLine.substr( strCmdLine.size() - g_strNetCheck.size()) == g_strNetCheck)) { CheckDotNetInstalled(); } return 0; } void UpdateNativeImage(bool bInstall) { const std_string strNGen = FindNGen(); if(strNGen.size() == 0) return; const std_string strKeePassExe = GetKeePassExePath(); if(strKeePassExe.size() == 0) return; std_string strParam = (bInstall ? _T("") : _T("un")); strParam += _T("install \""); strParam += strKeePassExe + _T("\""); SHELLEXECUTEINFO sei; ZeroMemory(&sei, sizeof(SHELLEXECUTEINFO)); sei.cbSize = sizeof(SHELLEXECUTEINFO); sei.fMask = SEE_MASK_NOCLOSEPROCESS; sei.lpVerb = _T("open"); sei.lpFile = strNGen.c_str(); sei.lpParameters = strParam.c_str(); sei.nShow = SW_HIDE; ShellExecuteEx(&sei); if(sei.hProcess != NULL) { WaitForSingleObject(sei.hProcess, 16000); CloseHandle(sei.hProcess); } } void RegisterPreLoad(bool bRegister) { const std_string strPath = GetKeePassExePath(); if(strPath.size() == 0) return; HKEY hKey = NULL; if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_WRITE, &hKey) != ERROR_SUCCESS) return; if(hKey == NULL) return; const std_string strItemName = _T("KeePass 2 PreLoad"); std_string strItemValue = _T("\""); strItemValue += strPath; strItemValue += _T("\" --preload"); if(bRegister) RegSetValueEx(hKey, strItemName.c_str(), 0, REG_SZ, (const BYTE*)strItemValue.c_str(), static_cast((strItemValue.size() + 1) * sizeof(TCHAR))); else RegDeleteValue(hKey, strItemName.c_str()); RegCloseKey(hKey); } std_string GetNetInstallRoot() { std_string str; HKEY hNet = NULL; LONG lRes = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\.NETFramework"), 0, KEY_READ, &hNet); if((lRes != ERROR_SUCCESS) || (hNet == NULL)) return str; const DWORD cbData = 2050; BYTE pbData[cbData]; ZeroMemory(pbData, cbData * sizeof(BYTE)); DWORD dwData = cbData - 2; lRes = RegQueryValueEx(hNet, _T("InstallRoot"), NULL, NULL, pbData, &dwData); if(lRes == ERROR_SUCCESS) str = (LPCTSTR)(LPTSTR)pbData; RegCloseKey(hNet); return str; } std_string GetKeePassExePath() { const DWORD cbData = 2050; TCHAR tszName[cbData]; ZeroMemory(tszName, cbData * sizeof(TCHAR)); GetModuleFileName(NULL, tszName, cbData - 2); for(int i = static_cast(_tcslen(tszName)) - 1; i >= 0; --i) { if(tszName[i] == _T('\\')) break; else tszName[i] = 0; } std_string strPath = tszName; boost::trim_if(strPath, boost::is_any_of(g_lpPathTrimChars)); if(strPath.size() == 0) return strPath; return strPath + _T("KeePass.exe"); } void EnsureTerminatingSeparator(std_string& strPath) { if(strPath.size() == 0) return; if(strPath.c_str()[strPath.size() - 1] == _T('\\')) return; strPath += _T("\\"); } std_string FindNGen() { std_string strNGen; std_string strRoot = GetNetInstallRoot(); if(strRoot.size() == 0) return strNGen; EnsureTerminatingSeparator(strRoot); ULONGLONG ullVersion = 0; FindNGenRec(strRoot, strNGen, ullVersion); return strNGen; } #pragma warning(push) #pragma warning(disable: 4127) // Conditional expression is constant void FindNGenRec(const std_string& strPath, std_string& strNGenPath, ULONGLONG& ullVersion) { const std_string strSearch = strPath + _T("*.*"); const std_string strNGen = _T("ngen.exe"); WIN32_FIND_DATA wfd; ZeroMemory(&wfd, sizeof(WIN32_FIND_DATA)); HANDLE hFind = FindFirstFile(strSearch.c_str(), &wfd); if(hFind == INVALID_HANDLE_VALUE) return; while(true) { if((wfd.cFileName[0] == 0) || (_tcsicmp(wfd.cFileName, _T(".")) == 0) || (_tcsicmp(wfd.cFileName, _T("..")) == 0)) { } else if((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) FindNGenRec((strPath + wfd.cFileName) + _T("\\"), strNGenPath, ullVersion); else if(_tcsicmp(wfd.cFileName, strNGen.c_str()) == 0) { const std_string strFullPath = strPath + strNGen; const ULONGLONG ullThisVer = SiuGetFileVersion(strFullPath); if(ullThisVer >= ullVersion) { strNGenPath = strFullPath; ullVersion = ullThisVer; } } if(FindNextFile(hFind, &wfd) == FALSE) break; } FindClose(hFind); } #pragma warning(pop) ULONGLONG SiuGetFileVersion(const std_string& strFilePath) { DWORD dwDummy = 0; const DWORD dwVerSize = GetFileVersionInfoSize( strFilePath.c_str(), &dwDummy); if(dwVerSize == 0) return 0; boost::scoped_array vVerInfo(new BYTE[dwVerSize]); if(vVerInfo.get() == NULL) return 0; // Out of memory if(GetFileVersionInfo(strFilePath.c_str(), 0, dwVerSize, vVerInfo.get()) == FALSE) return 0; VS_FIXEDFILEINFO* pFileInfo = NULL; UINT uFixedInfoLen = 0; if(VerQueryValue(vVerInfo.get(), _T("\\"), (LPVOID*)&pFileInfo, &uFixedInfoLen) == FALSE) return 0; if(pFileInfo == NULL) return 0; return ((static_cast(pFileInfo->dwFileVersionMS) << 32) | static_cast(pFileInfo->dwFileVersionLS)); } void CheckDotNetInstalled() { OSVERSIONINFO osv; ZeroMemory(&osv, sizeof(OSVERSIONINFO)); osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osv); if(osv.dwMajorVersion >= 6) return; // .NET ships with Vista and higher const std_string strNGen = FindNGen(); if(strNGen.size() == 0) { std_string strMsg = _T("KeePass 2.x requires the Microsoft .NET Framework >= 2.0, "); strMsg += _T("however this framework currently doesn't seem to be installed "); strMsg += _T("on your computer. Without this framework, KeePass will not run.\r\n\r\n"); strMsg += _T("The Microsoft .NET Framework is available as free download from the "); strMsg += _T("Microsoft website.\r\n\r\n"); strMsg += _T("Do you want to visit the Microsoft website now?"); const int nRes = MessageBox(NULL, strMsg.c_str(), _T("KeePass Setup"), MB_ICONQUESTION | MB_YESNO); if(nRes == IDYES) { SHELLEXECUTEINFO sei; ZeroMemory(&sei, sizeof(SHELLEXECUTEINFO)); sei.cbSize = sizeof(SHELLEXECUTEINFO); sei.lpVerb = _T("open"); sei.lpFile = _T("http://msdn.microsoft.com/en-us/netframework/aa569263.aspx"); sei.nShow = SW_SHOW; ShellExecuteEx(&sei); } } } keepass2-2.25/ShInstUtil/ShInstUtil.h0000664000175000017500000000572312261554706017417 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 */ #ifndef ___SH_INST_UTIL_H___ #define ___SH_INST_UTIL_H___ #pragma once #ifndef VC_EXTRALEAN #define VC_EXTRALEAN #endif #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #ifndef WINVER #define WINVER 0x0501 #endif #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0501 #endif #ifndef _WIN32_WINDOWS #define _WIN32_WINDOWS 0x0410 #endif #ifndef _WIN32_IE #define _WIN32_IE 0x0600 #endif #ifndef MMNOMIDI #define MMNOMIDI #endif #ifndef MMNOAUX #define MMNOAUX #endif #ifndef MMNOMIXER #define MMNOMIXER #endif #if (_MSC_VER >= 1400) // Manifest linking #if defined(_M_IX86) #pragma comment(linker, "/manifestdependency:\"type='win32' " \ "name='Microsoft.Windows.Common-Controls' " \ "version='6.0.0.0' " \ "processorArchitecture='x86' " \ "publicKeyToken='6595b64144ccf1df' " \ "language='*'\"") #elif defined(_M_AMD64) #pragma comment(linker, "/manifestdependency:\"type='win32' " \ "name='Microsoft.Windows.Common-Controls' " \ "version='6.0.0.0' " \ "processorArchitecture='amd64' " \ "publicKeyToken='6595b64144ccf1df' " \ "language='*'\"") #elif defined(_M_IA64) #pragma comment(linker, "/manifestdependency:\"type='win32' " \ "name='Microsoft.Windows.Common-Controls' " \ "version='6.0.0.0' " \ "processorArchitecture='ia64' " \ "publicKeyToken='6595b64144ccf1df' " \ "language='*'\"") #endif #endif // (_MSC_VER >= 1400) #include #include #include #include #include #include #include typedef std::basic_string std_string; int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow); void UpdateNativeImage(bool bInstall); void RegisterPreLoad(bool bRegister); std_string GetNetInstallRoot(); std_string GetKeePassExePath(); void EnsureTerminatingSeparator(std_string& strPath); std_string FindNGen(); void FindNGenRec(const std_string& strPath, std_string& strNGenPath, ULONGLONG& ullVersion); ULONGLONG SiuGetFileVersion(const std_string& strFilePath); void CheckDotNetInstalled(); #endif // ___SH_INST_UTIL_H___ keepass2-2.25/ShInstUtil/Resource.h0000664000175000017500000000062711247000604017120 0ustar jtaylorjtaylor//{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by ShInstUtil.rc // Nchste Standardwerte fr neue Objekte // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 101 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1001 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif keepass2-2.25/ShInstUtil/Resources/0000775000175000017500000000000011643263774017150 5ustar jtaylorjtaylorkeepass2-2.25/ShInstUtil/Resources/TrustInfoManifest.xml0000664000175000017500000000064411247225200023300 0ustar jtaylorjtaylor keepass2-2.25/KeePass/0000775000175000017500000000000012273663444014461 5ustar jtaylorjtaylorkeepass2-2.25/KeePass/Native/0000775000175000017500000000000012267211056015676 5ustar jtaylorjtaylorkeepass2-2.25/KeePass/Native/NativeProgressDialog.cs0000664000175000017500000001051312261553106022317 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Runtime.InteropServices; using System.Diagnostics; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; namespace KeePass.Native { [Flags] public enum ProgDlgFlags { Normal = 0x0, Modal = 0x1, AutoTime = 0x2, NoTime = 0x4, NoMinimize = 0x8, NoProgressBar = 0x10, MarqueeProgress = 0x20, NoCancel = 0x40 } public sealed class NativeProgressDialog : IStatusLogger { private IProgressDialog m_p; private uint m_uFlags; private IntPtr m_hWndParent; private uint m_uLastPercent = 0; private const uint PDTIMER_RESET = 0x1; private const uint PDTIMER_PAUSE = 0x2; private const uint PDTIMER_RESUME = 0x3; public static bool IsSupported { get { return (WinUtil.IsAtLeastWindowsVista && !KeePassLib.Native.NativeLib.IsUnix()); } } public NativeProgressDialog(IntPtr hWndParent, ProgDlgFlags fl) { m_hWndParent = hWndParent; m_uFlags = (uint)fl; try { m_p = (IProgressDialog)(new Win32ProgressDialog()); } catch(Exception) { Debug.Assert(false); m_p = null; } } ~NativeProgressDialog() { EndLogging(); } public void StartLogging(string strOperation, bool bWriteOperationToLog) { if(m_p == null) { Debug.Assert(false); return; } m_p.SetTitle(PwDefs.ShortProductName); m_p.StartProgressDialog(m_hWndParent, IntPtr.Zero, m_uFlags, IntPtr.Zero); m_p.Timer(PDTIMER_RESET, IntPtr.Zero); m_p.SetLine(1, strOperation, false, IntPtr.Zero); m_p.SetProgress(0, 100); m_uLastPercent = 0; } public void EndLogging() { if(m_p == null) return; // Might be freed/null already, don't assert m_p.StopProgressDialog(); try { Marshal.ReleaseComObject(m_p); } catch(Exception) { Debug.Assert(false); } m_p = null; } public bool SetProgress(uint uPercent) { if(m_p == null) { Debug.Assert(false); return true; } if(uPercent != m_uLastPercent) { m_p.SetProgress(uPercent, 100); m_uLastPercent = uPercent; } return !m_p.HasUserCancelled(); } public bool SetText(string strNewText, LogStatusType lsType) { if(m_p == null) { Debug.Assert(false); return true; } m_p.SetLine(2, strNewText, false, IntPtr.Zero); return !m_p.HasUserCancelled(); } public bool ContinueWork() { if(m_p == null) { Debug.Assert(false); return true; } return !m_p.HasUserCancelled(); } } [ComImport] [Guid("EBBC7C04-315E-11D2-B62F-006097DF5BD4")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface IProgressDialog { void StartProgressDialog(IntPtr hwndParent, IntPtr punkEnableModless, uint dwFlags, IntPtr pvReserved); void StopProgressDialog(); void SetTitle([MarshalAs(UnmanagedType.LPWStr)] string pwzTitle); void SetAnimation(IntPtr hInstAnimation, uint idAnimation); [PreserveSig] [return: MarshalAs(UnmanagedType.Bool)] bool HasUserCancelled(); void SetProgress(uint dwCompleted, uint dwTotal); void SetProgress64(ulong ullCompleted, ulong ullTotal); void SetLine(uint dwLineNum, [MarshalAs(UnmanagedType.LPWStr)] string pwzString, [MarshalAs(UnmanagedType.Bool)] bool fCompactPath, IntPtr pvReserved); void SetCancelMsg([MarshalAs(UnmanagedType.LPWStr)] string pwzCancelMsg, IntPtr pvReserved); void Timer(uint dwTimerAction, IntPtr pvReserved); } [ComImport] [Guid("F8383852-FCD3-11D1-A6B9-006097DF5BD4")] internal class Win32ProgressDialog { } } */ keepass2-2.25/KeePass/Native/NativeMethods.Defs.cs0000664000175000017500000002701412267211056021663 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Text; using System.Security; using System.Runtime.InteropServices; using System.Diagnostics; using System.Windows.Forms; namespace KeePass.Native { internal static partial class NativeMethods { internal const int WM_KEYDOWN = 0x0100; internal const int WM_KEYUP = 0x0101; internal const int WM_DRAWCLIPBOARD = 0x0308; internal const int WM_CHANGECBCHAIN = 0x030D; internal const int WM_HOTKEY = 0x0312; internal const int WM_USER = 0x0400; internal const int WM_SYSCOMMAND = 0x0112; internal const int WM_POWERBROADCAST = 0x0218; internal const int WM_COPYDATA = 0x004A; // internal const int WM_MOUSEMOVE = 0x0200; internal const int WM_LBUTTONDOWN = 0x0201; internal const int WM_RBUTTONDOWN = 0x0204; internal const int WM_MBUTTONDOWN = 0x0207; // internal const int WM_MOUSEWHEEL = 0x020A; internal const int WM_NOTIFY = 0x004E; // See Control.ReflectMessageInternal; // http://msdn.microsoft.com/en-us/library/eeah46xd.aspx internal const int WM_REFLECT = 0x2000; internal const int WM_NOTIFY_REFLECT = (WM_NOTIFY + WM_REFLECT); internal const int WM_GETTEXTLENGTH = 0x000E; internal const int WM_GETICON = 0x007F; internal const int HWND_BROADCAST = 0xFFFF; internal const uint SMTO_NORMAL = 0x0000; internal const uint SMTO_BLOCK = 0x0001; internal const uint SMTO_ABORTIFHUNG = 0x0002; internal const uint SMTO_NOTIMEOUTIFNOTHUNG = 0x0008; internal const uint INPUT_MOUSE = 0; internal const uint INPUT_KEYBOARD = 1; internal const uint INPUT_HARDWARE = 2; internal const int VK_RETURN = 0x0D; internal const int VK_SHIFT = 0x10; internal const int VK_CONTROL = 0x11; internal const int VK_MENU = 0x12; internal const int VK_CAPITAL = 0x14; internal const int VK_LSHIFT = 0xA0; internal const int VK_RSHIFT = 0xA1; internal const int VK_LCONTROL = 0xA2; internal const int VK_RCONTROL = 0xA3; internal const int VK_LMENU = 0xA4; internal const int VK_RMENU = 0xA5; internal const int VK_LWIN = 0x5B; internal const int VK_RWIN = 0x5C; internal const int VK_SNAPSHOT = 0x2C; internal const int VK_F5 = 0x74; internal const int VK_F6 = 0x75; internal const int VK_F7 = 0x76; internal const int VK_F8 = 0x77; internal const uint KEYEVENTF_EXTENDEDKEY = 1; internal const uint KEYEVENTF_KEYUP = 2; internal const uint KEYEVENTF_UNICODE = 4; // internal const uint GW_CHILD = 5; internal const uint GW_HWNDNEXT = 2; internal const int GWL_STYLE = -16; internal const int GWL_EXSTYLE = -20; internal const int WS_VISIBLE = 0x10000000; internal const int SW_SHOW = 5; internal const int GCLP_HICON = -14; internal const int GCLP_HICONSM = -34; internal const int ICON_SMALL = 0; internal const int ICON_BIG = 1; internal const int ICON_SMALL2 = 2; internal const int EM_GETCHARFORMAT = WM_USER + 58; internal const int EM_SETCHARFORMAT = WM_USER + 68; internal const int ES_WANTRETURN = 0x1000; internal const int SCF_SELECTION = 0x0001; internal const uint CFM_LINK = 0x00000020; internal const uint CFE_LINK = 0x00000020; internal const int SC_MINIMIZE = 0xF020; internal const int SC_MAXIMIZE = 0xF030; internal const int IDANI_CAPTION = 3; internal const int PBT_APMQUERYSUSPEND = 0x0000; internal const int PBT_APMSUSPEND = 0x0004; internal const int ECM_FIRST = 0x1500; internal const int EM_SETCUEBANNER = ECM_FIRST + 1; internal const uint INVALID_FILE_ATTRIBUTES = 0xFFFFFFFFU; internal const uint FSCTL_LOCK_VOLUME = 589848; internal const uint FSCTL_UNLOCK_VOLUME = 589852; internal const int LVM_FIRST = 0x1000; internal const int LVM_ENSUREVISIBLE = LVM_FIRST + 19; internal const int LVM_SCROLL = LVM_FIRST + 20; // internal const int LVM_SETGROUPINFO = LVM_FIRST + 147; // >= Vista // internal const int LVM_GETGROUPINFOBYINDEX = LVM_FIRST + 153; // >= Vista internal const int WM_MOUSEACTIVATE = 0x21; internal const int MA_ACTIVATE = 1; internal const int MA_ACTIVATEANDEAT = 2; internal const int MA_NOACTIVATE = 3; internal const int MA_NOACTIVATEANDEAT = 4; internal const int BCM_SETSHIELD = 0x160C; internal const int SHCNE_ASSOCCHANGED = 0x08000000; internal const uint SHCNF_IDLIST = 0x0000; // internal const uint SW_INVALIDATE = 0x0002; internal const uint TVS_FULLROWSELECT = 0x1000; internal const uint TVS_NONEVENHEIGHT = 0x4000; internal const uint TVS_EX_DOUBLEBUFFER = 0x0004; internal const uint TVS_EX_FADEINOUTEXPANDOS = 0x0040; internal const int HDI_FORMAT = 0x0004; internal const int HDF_SORTUP = 0x0400; internal const int HDF_SORTDOWN = 0x0200; internal const int LVM_GETHEADER = LVM_FIRST + 31; internal const int HDM_FIRST = 0x1200; internal const int HDM_GETITEMA = HDM_FIRST + 3; internal const int HDM_GETITEMW = HDM_FIRST + 11; internal const int HDM_SETITEMA = HDM_FIRST + 4; internal const int HDM_SETITEMW = HDM_FIRST + 12; internal const int OFN_DONTADDTORECENT = 0x02000000; internal const uint SHGFI_DISPLAYNAME = 0x000000200; internal const uint SHGFI_ICON = 0x000000100; internal const uint SHGFI_TYPENAME = 0x000000400; internal const uint SHGFI_SMALLICON = 0x000000001; internal const uint MOD_ALT = 1; internal const uint MOD_CONTROL = 2; internal const uint MOD_SHIFT = 4; internal const uint MOD_WIN = 8; internal const int IDHOT_SNAPDESKTOP = -2; internal const int IDHOT_SNAPWINDOW = -1; internal const uint GHND = 0x0042; internal const uint GMEM_MOVEABLE = 0x0002; internal const uint GMEM_ZEROINIT = 0x0040; internal const uint CF_TEXT = 1; internal const uint CF_UNICODETEXT = 13; internal const uint SND_ASYNC = 0x0001; internal const uint SND_FILENAME = 0x00020000; internal const uint SND_NODEFAULT = 0x0002; // internal const uint PROCESS_QUERY_INFORMATION = 0x0400; internal const uint ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID = 0x04; // internal const uint DI_NORMAL = 0x0003; // internal const int LVN_FIRST = -100; // internal const int LVN_LINKCLICK = LVN_FIRST - 84; // internal const uint LVGF_NONE = 0x00000000; // internal const uint LVGF_HEADER = 0x00000001; // internal const uint LVGF_FOOTER = 0x00000002; // internal const uint LVGF_STATE = 0x00000004; // internal const uint LVGF_ALIGN = 0x00000008; // internal const uint LVGF_GROUPID = 0x00000010; // internal const uint LVGF_SUBTITLE = 0x00000100; // internal const uint LVGF_TASK = 0x00000200; // internal const uint LVGF_DESCRIPTIONTOP = 0x00000400; // internal const uint LVGF_DESCRIPTIONBOTTOM = 0x00000800; // internal const uint LVGF_TITLEIMAGE = 0x00001000; // internal const uint LVGF_EXTENDEDIMAGE = 0x00002000; // internal const uint LVGF_ITEMS = 0x00004000; // internal const uint LVGF_SUBSET = 0x00008000; // internal const uint LVGF_SUBSETITEMS = 0x00010000; // internal const uint LVGS_NORMAL = 0x00000000; // internal const uint LVGS_COLLAPSED = 0x00000001; // internal const uint LVGS_HIDDEN = 0x00000002; // internal const uint LVGS_NOHEADER = 0x00000004; // internal const uint LVGS_COLLAPSIBLE = 0x00000008; // internal const uint LVGS_FOCUSED = 0x00000010; // internal const uint LVGS_SELECTED = 0x00000020; // internal const uint LVGS_SUBSETED = 0x00000040; // internal const uint LVGS_SUBSETLINKFOCUSED = 0x00000080; // private const int TTN_FIRST = -520; // internal const int TTN_NEEDTEXTA = TTN_FIRST; // internal const int TTN_NEEDTEXTW = TTN_FIRST - 10; [return: MarshalAs(UnmanagedType.Bool)] internal delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam); internal enum ComboBoxButtonState : uint { STATE_SYSTEM_NONE = 0, STATE_SYSTEM_INVISIBLE = 0x00008000, STATE_SYSTEM_PRESSED = 0x00000008 } [Flags] internal enum DesktopFlags : uint { ReadObjects = 0x0001, CreateWindow = 0x0002, CreateMenu = 0x0004, HookControl = 0x0008, JournalRecord = 0x0010, JournalPlayback = 0x0020, Enumerate = 0x0040, WriteObjects = 0x0080, SwitchDesktop = 0x0100, } [Flags] internal enum EFileAccess : uint { GenericRead = 0x80000000, GenericWrite = 0x40000000, GenericExecute = 0x20000000, GenericAll = 0x10000000 } [Flags] internal enum EFileShare : uint { None = 0x00000000, Read = 0x00000001, Write = 0x00000002, Delete = 0x00000004 } internal enum ECreationDisposition : uint { CreateNew = 1, CreateAlways = 2, OpenExisting = 3, OpenAlways = 4, TruncateExisting = 5 } private enum ScrollBarDirection : int { SB_HORZ = 0, SB_VERT = 1, SB_CTL = 2, SB_BOTH = 3 } private enum ScrollInfoMask : uint { SIF_RANGE = 0x1, SIF_PAGE = 0x2, SIF_POS = 0x4, SIF_DISABLENOSCROLL = 0x8, SIF_TRACKPOS = 0x10, SIF_ALL = SIF_RANGE + SIF_PAGE + SIF_POS + SIF_TRACKPOS } [Flags] internal enum MessageBoxFlags : uint { // Buttons MB_ABORTRETRYIGNORE = 0x00000002, MB_CANCELTRYCONTINUE = 0x00000006, MB_HELP = 0x00004000, MB_OK = 0, MB_OKCANCEL = 0x00000001, MB_RETRYCANCEL = 0x00000005, MB_YESNO = 0x00000004, MB_YESNOCANCEL = 0x00000003, // Icons MB_ICONEXCLAMATION = 0x00000030, MB_ICONWARNING = 0x00000030, MB_ICONINFORMATION = 0x00000040, MB_ICONASTERISK = 0x00000040, MB_ICONQUESTION = 0x00000020, MB_ICONSTOP = 0x00000010, MB_ICONERROR = 0x00000010, MB_ICONHAND = 0x00000010, // Default buttons MB_DEFBUTTON1 = 0, MB_DEFBUTTON2 = 0x00000100, MB_DEFBUTTON3 = 0x00000200, MB_DEFBUTTON4 = 0x00000300, // Modality MB_APPLMODAL = 0, MB_SYSTEMMODAL = 0x00001000, MB_TASKMODAL = 0x00002000, // Other options MB_DEFAULT_DESKTOP_ONLY = 0x00020000, MB_RIGHT = 0x00080000, MB_RTLREADING = 0x00100000, MB_SETFOREGROUND = 0x00010000, MB_TOPMOST = 0x00040000, MB_SERVICE_NOTIFICATION = 0x00200000 } // See DialogResult /* internal enum CommandID { None = 0, OK = 1, // IDOK Cancel = 2, // IDCANCEL Abort = 3, // IDABORT Retry = 4, // IDRETRY Ignore = 5, // IDIGNORE Yes = 6, // IDYES No = 7, // IDNO Close = 8, // IDCLOSE Help = 9, // IDHELP TryAgain = 10, // IDTRYAGAIN Continue = 11, // IDCONTINUE TimeOut = 32000 // IDTIMEOUT } */ [Flags] internal enum ToolHelpFlags : uint { SnapHeapList = 0x00000001, SnapProcess = 0x00000002, SnapThread = 0x00000004, SnapModule = 0x00000008, SnapModule32 = 0x00000010, SnapAll = (SnapHeapList | SnapProcess | SnapThread | SnapModule), Inherit = 0x80000000U } } } keepass2-2.25/KeePass/Native/NativeMethods.Structs.cs0000664000175000017500000002042112267174434022454 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Text; using System.Security; using System.Runtime.InteropServices; using System.Diagnostics; using System.Windows.Forms; using System.Drawing; namespace KeePass.Native { internal static partial class NativeMethods { [StructLayout(LayoutKind.Sequential, Pack = 1)] internal struct MOUSEINPUT32_WithSkip { public uint __Unused0; // See INPUT32 structure public int X; public int Y; public uint MouseData; public uint Flags; public uint Time; public IntPtr ExtraInfo; } [StructLayout(LayoutKind.Sequential, Pack = 1)] internal struct KEYBDINPUT32_WithSkip { public uint __Unused0; // See INPUT32 structure public ushort VirtualKeyCode; public ushort ScanCode; public uint Flags; public uint Time; public IntPtr ExtraInfo; } [StructLayout(LayoutKind.Explicit)] internal struct INPUT32 { [FieldOffset(0)] public uint Type; [FieldOffset(0)] public MOUSEINPUT32_WithSkip MouseInput; [FieldOffset(0)] public KEYBDINPUT32_WithSkip KeyboardInput; } // INPUT.KI (40). vk: 8, sc: 10, fl: 12, t: 16, ex: 24 [StructLayout(LayoutKind.Explicit, Size = 40)] internal struct SpecializedKeyboardINPUT64 { [FieldOffset(0)] public uint Type; [FieldOffset(8)] public ushort VirtualKeyCode; [FieldOffset(10)] public ushort ScanCode; [FieldOffset(12)] public uint Flags; [FieldOffset(16)] public uint Time; [FieldOffset(24)] public IntPtr ExtraInfo; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] internal struct CHARFORMAT2 { public UInt32 cbSize; public UInt32 dwMask; public UInt32 dwEffects; public Int32 yHeight; public Int32 yOffset; public UInt32 crTextColor; public Byte bCharSet; public Byte bPitchAndFamily; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string szFaceName; public UInt16 wWeight; public UInt16 sSpacing; public Int32 crBackColor; public Int32 lcid; public UInt32 dwReserved; public Int16 sStyle; public Int16 wKerning; public Byte bUnderlineType; public Byte bAnimation; public Byte bRevAuthor; public Byte bReserved1; } [StructLayout(LayoutKind.Sequential)] internal struct RECT { public Int32 Left; public Int32 Top; public Int32 Right; public Int32 Bottom; public RECT(Rectangle rect) { this.Left = rect.Left; this.Top = rect.Top; this.Right = rect.Right; this.Bottom = rect.Bottom; } } [StructLayout(LayoutKind.Sequential)] internal struct COMBOBOXINFO { public Int32 cbSize; public RECT rcItem; public RECT rcButton; [MarshalAs(UnmanagedType.U4)] public ComboBoxButtonState buttonState; public IntPtr hwndCombo; public IntPtr hwndEdit; public IntPtr hwndList; } [StructLayout(LayoutKind.Sequential)] internal struct MARGINS { public Int32 Left; public Int32 Right; public Int32 Top; public Int32 Bottom; } [StructLayout(LayoutKind.Sequential)] internal struct COPYDATASTRUCT { public IntPtr dwData; public Int32 cbData; public IntPtr lpData; } [StructLayout(LayoutKind.Sequential)] private struct SCROLLINFO { public uint cbSize; public uint fMask; public int nMin; public int nMax; public uint nPage; public int nPos; public int nTrackPos; } [StructLayout(LayoutKind.Sequential)] internal struct HDITEM { public UInt32 mask; public Int32 cxy; [MarshalAs(UnmanagedType.LPTStr)] public string pszText; public IntPtr hbm; public Int32 cchTextMax; public Int32 fmt; public IntPtr lParam; public Int32 iImage; public Int32 iOrder; } [StructLayout(LayoutKind.Sequential)] internal struct NMHDR { public IntPtr hwndFrom; public IntPtr idFrom; public uint code; } [StructLayout(LayoutKind.Sequential)] private struct LASTINPUTINFO { public uint cbSize; public uint dwTime; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] private struct SHFILEINFO { public IntPtr hIcon; public int iIcon; public uint dwAttributes; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = KeePassLib.Native.NativeMethods.MAX_PATH)] public string szDisplayName; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)] public string szTypeName; } /* // LVGROUP for Windows Vista and higher [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] private struct LVGROUP { public uint cbSize; public uint mask; // [MarshalAs(UnmanagedType.LPWStr)] // public StringBuilder pszHeader; public IntPtr pszHeader; public int cchHeader; // [MarshalAs(UnmanagedType.LPWStr)] // public StringBuilder pszFooter; public IntPtr pszFooter; public int cchFooter; public int iGroupId; public uint stateMask; public uint state; public uint uAlign; // [MarshalAs(UnmanagedType.LPWStr)] // public StringBuilder pszSubtitle; public IntPtr pszSubtitle; public uint cchSubtitle; [MarshalAs(UnmanagedType.LPWStr)] public string pszTask; // public StringBuilder pszTask; // public IntPtr pszTask; public uint cchTask; // [MarshalAs(UnmanagedType.LPWStr)] // public StringBuilder pszDescriptionTop; public IntPtr pszDescriptionTop; public uint cchDescriptionTop; // [MarshalAs(UnmanagedType.LPWStr)] // public StringBuilder pszDescriptionBottom; public IntPtr pszDescriptionBottom; public uint cchDescriptionBottom; public int iTitleImage; public int iExtendedImage; public int iFirstItem; public uint cItems; // [MarshalAs(UnmanagedType.LPWStr)] // public StringBuilder pszSubsetTitle; public IntPtr pszSubsetTitle; public uint cchSubsetTitle; [Conditional("DEBUG")] internal void AssertSize() { if(IntPtr.Size == 4) { Debug.Assert(Marshal.SizeOf(this) == 96); } else if(IntPtr.Size == 8) { Debug.Assert(Marshal.SizeOf(this) == 152); } else { Debug.Assert(false); } } } */ internal const uint PROCESSENTRY32SizeUni32 = 556; internal const uint PROCESSENTRY32SizeUni64 = 568; [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] internal struct PROCESSENTRY32 { public uint dwSize; public uint cntUsage; public uint th32ProcessID; public UIntPtr th32DefaultHeapID; public uint th32ModuleID; public uint cntThreads; public uint th32ParentProcessID; public int pcPriClassBase; public uint dwFlags; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = KeePassLib.Native.NativeMethods.MAX_PATH)] public string szExeFile; } internal const uint ACTCTXSize32 = 32; internal const uint ACTCTXSize64 = 56; [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] internal struct ACTCTX { public uint cbSize; public uint dwFlags; [MarshalAs(UnmanagedType.LPTStr)] // Not LPWStr, see source code public string lpSource; public ushort wProcessorArchitecture; public ushort wLangId; [MarshalAs(UnmanagedType.LPTStr)] public string lpAssemblyDirectory; [MarshalAs(UnmanagedType.LPTStr)] public string lpResourceName; [MarshalAs(UnmanagedType.LPTStr)] public string lpApplicationName; public IntPtr hModule; } } } keepass2-2.25/KeePass/Native/NativeMethods.cs0000664000175000017500000004155012265306550021006 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Text; using System.Security; using System.Runtime.InteropServices; using System.Windows.Forms; using System.Diagnostics; using KeePass.UI; namespace KeePass.Native { internal static partial class NativeMethods { [DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool SetDllDirectory(string lpPathName); [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool IsWindow(IntPtr hWnd); [DllImport("User32.dll")] internal static extern IntPtr SendMessage(IntPtr hWnd, int nMsg, IntPtr wParam, IntPtr lParam); [DllImport("User32.dll", EntryPoint = "SendMessage")] internal static extern IntPtr SendMessageHDItem(IntPtr hWnd, int nMsg, IntPtr wParam, ref HDITEM hdItem); // [DllImport("User32.dll", EntryPoint = "SendMessage")] // private static extern IntPtr SendMessageLVGroup(IntPtr hWnd, int nMsg, // IntPtr wParam, ref LVGROUP lvGroup); [DllImport("User32.dll", SetLastError = true)] internal static extern IntPtr SendMessageTimeout(IntPtr hWnd, int nMsg, IntPtr wParam, IntPtr lParam, uint fuFlags, uint uTimeout, ref IntPtr lpdwResult); [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool PostMessage(IntPtr hWnd, int nMsg, IntPtr wParam, IntPtr lParam); // [DllImport("User32.dll")] // internal static extern uint GetMessagePos(); [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Auto)] internal static extern int RegisterWindowMessage(string lpString); // [DllImport("User32.dll")] // internal static extern IntPtr GetDesktopWindow(); [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Auto)] internal static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); [DllImport("User32.dll")] internal static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd); [DllImport("User32.dll")] internal static extern int GetWindowLong(IntPtr hWnd, int nIndex); [DllImport("User32.dll", SetLastError = true)] internal static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); [DllImport("User32.dll", EntryPoint = "GetClassLong")] private static extern IntPtr GetClassLongPtr32(IntPtr hWnd, int nIndex); [DllImport("User32.dll", EntryPoint = "GetClassLongPtr")] private static extern IntPtr GetClassLongPtr64(IntPtr hWnd, int nIndex); // [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Auto)] // private static extern int GetClassName(IntPtr hWnd, // StringBuilder lpClassName, int nMaxCount); [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool IsIconic(IntPtr hWnd); [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool IsZoomed(IntPtr hWnd); [DllImport("User32.dll", SetLastError = true)] private static extern int GetWindowTextLength(IntPtr hWnd); [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Auto)] private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount); [DllImport("User32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect); // [DllImport("User32.dll")] // internal static extern IntPtr GetActiveWindow(); [DllImport("User32.dll")] private static extern IntPtr GetForegroundWindow(); // Private, is wrapped [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool SetForegroundWindow(IntPtr hWnd); [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam); [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk); [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool UnregisterHotKey(IntPtr hWnd, int id); [DllImport("User32.dll", EntryPoint = "SendInput", SetLastError = true)] internal static extern uint SendInput32(uint nInputs, INPUT32[] pInputs, int cbSize); [DllImport("User32.dll", EntryPoint = "SendInput", SetLastError = true)] internal static extern uint SendInput64Special(uint nInputs, SpecializedKeyboardINPUT64[] pInputs, int cbSize); [DllImport("User32.dll")] internal static extern IntPtr GetMessageExtraInfo(); // [DllImport("User32.dll")] // internal static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, // IntPtr dwExtraInfo); [DllImport("User32.dll")] internal static extern uint MapVirtualKey(uint uCode, uint uMapType); [DllImport("User32.dll", CharSet = CharSet.Auto)] internal static extern ushort VkKeyScan(char ch); [DllImport("User32.dll", CharSet = CharSet.Auto)] internal static extern ushort VkKeyScanEx(char ch, IntPtr hKL); [DllImport("User32.dll")] internal static extern ushort GetKeyState(int vKey); [DllImport("User32.dll")] internal static extern ushort GetAsyncKeyState(int vKey); [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool BlockInput([MarshalAs(UnmanagedType.Bool)] bool fBlockIt); // [DllImport("User32.dll")] // [return: MarshalAs(UnmanagedType.Bool)] // internal static extern bool AttachThreadInput(uint idAttach, // uint idAttachTo, [MarshalAs(UnmanagedType.Bool)] bool fAttach); [DllImport("User32.dll")] internal static extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer); [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool ChangeClipboardChain(IntPtr hWndRemove, IntPtr hWndNewNext); [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool OpenClipboard(IntPtr hWndNewOwner); [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool EmptyClipboard(); [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool CloseClipboard(); [DllImport("User32.dll", SetLastError = true)] internal static extern IntPtr SetClipboardData(uint uFormat, IntPtr hMem); [DllImport("User32.dll", SetLastError = true)] internal static extern IntPtr GetClipboardData(uint uFormat); [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Auto)] internal static extern uint RegisterClipboardFormat(string lpszFormat); [DllImport("User32.dll")] internal static extern uint GetClipboardSequenceNumber(); [DllImport("Kernel32.dll")] internal static extern IntPtr GlobalAlloc(uint uFlags, UIntPtr dwBytes); [DllImport("Kernel32.dll")] internal static extern IntPtr GlobalFree(IntPtr hMem); [DllImport("Kernel32.dll")] internal static extern IntPtr GlobalLock(IntPtr hMem); [DllImport("Kernel32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool GlobalUnlock(IntPtr hMem); [DllImport("Kernel32.dll")] internal static extern UIntPtr GlobalSize(IntPtr hMem); [DllImport("ShlWApi.dll", CharSet = CharSet.Auto)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool PathCompactPathEx(StringBuilder pszOut, string szPath, uint cchMax, uint dwFlags); [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool DrawAnimatedRects(IntPtr hWnd, int idAni, [In] ref RECT lprcFrom, [In] ref RECT lprcTo); [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool GetComboBoxInfo(IntPtr hWnd, ref COMBOBOXINFO pcbi); [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Auto)] internal static extern IntPtr CreateDesktop(string lpszDesktop, string lpszDevice, IntPtr pDevMode, UInt32 dwFlags, [MarshalAs(UnmanagedType.U4)] DesktopFlags dwDesiredAccess, IntPtr lpSecurityAttributes); [DllImport("User32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool CloseDesktop(IntPtr hDesktop); // [DllImport("User32.dll", SetLastError = true)] // internal static extern IntPtr OpenDesktop(string lpszDesktop, // UInt32 dwFlags, [MarshalAs(UnmanagedType.Bool)] bool fInherit, // [MarshalAs(UnmanagedType.U4)] DesktopFlags dwDesiredAccess); [DllImport("User32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool SwitchDesktop(IntPtr hDesktop); [DllImport("User32.dll", SetLastError = true)] internal static extern IntPtr OpenInputDesktop(uint dwFlags, [MarshalAs(UnmanagedType.Bool)] bool fInherit, [MarshalAs(UnmanagedType.U4)] DesktopFlags dwDesiredAccess); [DllImport("User32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool GetUserObjectInformation(IntPtr hObj, int nIndex, IntPtr pvInfo, uint nLength, ref uint lpnLengthNeeded); [DllImport("User32.dll", SetLastError = true)] internal static extern IntPtr GetThreadDesktop(uint dwThreadId); [DllImport("User32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool SetThreadDesktop(IntPtr hDesktop); [DllImport("Kernel32.dll")] internal static extern uint GetCurrentThreadId(); // [DllImport("Imm32.dll")] // [return: MarshalAs(UnmanagedType.Bool)] // internal static extern bool ImmDisableIME(uint idThread); // [DllImport("Imm32.dll")] // internal static extern IntPtr ImmAssociateContext(IntPtr hWnd, IntPtr hIMC); [DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] internal static extern IntPtr CreateFile(string lpFileName, [MarshalAs(UnmanagedType.U4)] EFileAccess dwDesiredAccess, [MarshalAs(UnmanagedType.U4)] EFileShare dwShareMode, IntPtr lpSecurityAttributes, [MarshalAs(UnmanagedType.U4)] ECreationDisposition dwCreationDisposition, [MarshalAs(UnmanagedType.U4)] uint dwFlagsAndAttributes, IntPtr hTemplateFile); [DllImport("Kernel32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool CloseHandle(IntPtr hObject); [DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] internal static extern uint GetFileAttributes(string lpFileName); [DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool DeleteFile(string lpFileName); [DllImport("Kernel32.dll", ExactSpelling = true, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool DeviceIoControl(IntPtr hDevice, uint dwIoControlCode, IntPtr lpInBuffer, uint nInBufferSize, IntPtr lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, IntPtr lpOverlapped); [DllImport("ComCtl32.dll", CharSet = CharSet.Auto)] internal static extern Int32 TaskDialogIndirect([In] ref VtdConfig pTaskConfig, [Out] out int pnButton, [Out] out int pnRadioButton, [Out] [MarshalAs(UnmanagedType.Bool)] out bool pfVerificationFlagChecked); [DllImport("UxTheme.dll", ExactSpelling = true, CharSet = CharSet.Unicode)] internal static extern int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList); [DllImport("Shell32.dll")] internal static extern void SHChangeNotify(int wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2); [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool GetScrollInfo(IntPtr hwnd, int fnBar, ref SCROLLINFO lpsi); // [DllImport("User32.dll")] // private static extern int SetScrollInfo(IntPtr hwnd, int fnBar, // [In] ref SCROLLINFO lpsi, [MarshalAs(UnmanagedType.Bool)] bool fRedraw); // [DllImport("User32.dll")] // private static extern int ScrollWindowEx(IntPtr hWnd, int dx, int dy, // IntPtr prcScroll, IntPtr prcClip, IntPtr hrgnUpdate, IntPtr prcUpdate, // uint flags); [DllImport("User32.dll")] internal static extern IntPtr GetKeyboardLayout(uint idThread); [DllImport("User32.dll")] internal static extern IntPtr ActivateKeyboardLayout(IntPtr hkl, uint uFlags); [DllImport("User32.dll")] internal static extern uint GetWindowThreadProcessId(IntPtr hWnd, [Out] out uint lpdwProcessId); // [DllImport("UxTheme.dll")] // internal static extern IntPtr OpenThemeData(IntPtr hWnd, // [MarshalAs(UnmanagedType.LPWStr)] string pszClassList); // [DllImport("UxTheme.dll")] // internal static extern uint CloseThemeData(IntPtr hTheme); // [DllImport("UxTheme.dll")] // internal extern static uint DrawThemeBackground(IntPtr hTheme, IntPtr hdc, // int iPartId, int iStateId, ref RECT pRect, ref RECT pClipRect); // [DllImport("Gdi32.dll")] // [return: MarshalAs(UnmanagedType.Bool)] // internal static extern bool DeleteObject(IntPtr hObject); [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii); [DllImport("Shell32.dll", CharSet = CharSet.Auto)] private static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbFileInfo, uint uFlags); [DllImport("User32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool DestroyIcon(IntPtr hIcon); // [DllImport("User32.dll", SetLastError = true)] // [return: MarshalAs(UnmanagedType.Bool)] // internal static extern bool DrawIconEx(IntPtr hdc, int xLeft, int yTop, // IntPtr hIcon, int cxWidth, int cyWidth, uint istepIfAniCur, // IntPtr hbrFlickerFreeDraw, uint diFlags); [DllImport("WinMM.dll", CharSet = CharSet.Auto)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool PlaySound(string pszSound, IntPtr hmod, uint fdwSound); [DllImport("Shell32.dll", CharSet = CharSet.Auto)] internal static extern IntPtr ShellExecute(IntPtr hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd); [DllImport("User32.dll", CharSet = CharSet.Auto)] internal static extern int MessageBox(IntPtr hWnd, string lpText, string lpCaption, [MarshalAs(UnmanagedType.U4)] MessageBoxFlags uType); // [DllImport("User32.dll")] // [return: MarshalAs(UnmanagedType.Bool)] // internal static extern bool SetProcessDPIAware(); [DllImport("Kernel32.dll")] internal static extern IntPtr CreateToolhelp32Snapshot( [MarshalAs(UnmanagedType.U4)] ToolHelpFlags dwFlags, uint th32ProcessID); [DllImport("Kernel32.dll", CharSet = CharSet.Auto)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool Process32First(IntPtr hSnapshot, ref PROCESSENTRY32 lppe); [DllImport("Kernel32.dll", CharSet = CharSet.Auto)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool Process32Next(IntPtr hSnapshot, ref PROCESSENTRY32 lppe); // [DllImport("Kernel32.dll", SetLastError = true)] // internal static extern IntPtr OpenProcess(uint dwDesiredAccess, // [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, uint dwProcessId); // [DllImport("User32.dll")] // [return: MarshalAs(UnmanagedType.Bool)] // internal static extern bool IsImmersiveProcess(IntPtr hProcess); [DllImport("Kernel32.dll", CharSet = CharSet.Auto)] internal static extern IntPtr CreateActCtx(ref ACTCTX pActCtx); [DllImport("Kernel32.dll")] internal static extern void ReleaseActCtx(IntPtr hActCtx); [DllImport("Kernel32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool ActivateActCtx(IntPtr hActCtx, ref UIntPtr lpCookie); [DllImport("Kernel32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool DeactivateActCtx(uint dwFlags, UIntPtr ulCookie); } } keepass2-2.25/KeePass/Native/NativeMethods.Unix.cs0000664000175000017500000002220012261553106021714 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Windows.Forms; using System.IO; using System.Runtime.InteropServices; using System.Reflection; using System.Diagnostics; using KeePass.UI; using KeePass.Util; using KeePassLib; using KeePassLib.Utility; using KeeNativeLib = KeePassLib.Native; namespace KeePass.Native { internal static partial class NativeMethods { [StructLayout(LayoutKind.Sequential)] private struct XClassHint { public IntPtr res_name; public IntPtr res_class; } /* private const string PathLibDo = "/usr/lib/gnome-do/libdo"; private const UnmanagedType NtvStringType = UnmanagedType.LPStr; [DllImport(PathLibDo)] internal static extern void gnomedo_keybinder_init(); [DllImport(PathLibDo)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool gnomedo_keybinder_bind( [MarshalAs(NtvStringType)] string strKey, BindKeyHandler lpfnHandler); [DllImport(PathLibDo)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool gnomedo_keybinder_unbind( [MarshalAs(NtvStringType)] string strKey, BindKeyHandler lpfnHandler); internal delegate void BindKeyHandler([MarshalAs(NtvStringType)] string strKey, IntPtr lpUserData); */ /* private const string PathLibTomBoy = "/usr/lib/tomboy/libtomboy.so"; [DllImport(PathLibTomBoy)] internal static extern void tomboy_keybinder_init(); [DllImport(PathLibTomBoy)] internal static extern void tomboy_keybinder_bind(string strKey, BindKeyHandler lpHandler); [DllImport(PathLibTomBoy)] internal static extern void tomboy_keybinder_unbind(string strKey, BindKeyHandler lpHandler); internal delegate void BindKeyHandler(string strKey, IntPtr lpUserData); */ [DllImport("libX11")] private static extern int XSetClassHint(IntPtr display, IntPtr window, IntPtr class_hints); private static bool LoseFocusUnix(Form fCurrent) { if(fCurrent == null) { Debug.Assert(false); return true; } try { string strCurrent = RunXDoTool("getwindowfocus -f"); long lCurrent; long.TryParse(strCurrent.Trim(), out lCurrent); UIUtil.SetWindowState(fCurrent, FormWindowState.Minimized); int nStart = Environment.TickCount; while((Environment.TickCount - nStart) < 1000) { Application.DoEvents(); string strActive = RunXDoTool("getwindowfocus -f"); long lActive; long.TryParse(strActive.Trim(), out lActive); if(lActive != lCurrent) break; } return true; } catch(Exception) { Debug.Assert(false); } return false; } internal static bool TryXDoTool() { return !string.IsNullOrEmpty(RunXDoTool("help")); } internal static bool TryXDoTool(bool bRequireWindowNameSupport) { if(!bRequireWindowNameSupport) return TryXDoTool(); string str = RunXDoTool("getactivewindow getwindowname"); if(string.IsNullOrEmpty(str)) return false; return !(str.Trim().Equals("usage: getactivewindow", StrUtil.CaseIgnoreCmp)); } internal static string RunXDoTool(string strParams) { try { Application.DoEvents(); // E.g. for clipboard updates string strOutput = KeeNativeLib.NativeLib.RunConsoleApp( "xdotool", strParams); Application.DoEvents(); // E.g. for clipboard updates return (strOutput ?? string.Empty); } catch(Exception) { Debug.Assert(false); } return string.Empty; } private static Type m_tXplatUIX11 = null; private static Type GetXplatUIX11Type(bool bThrowOnError) { if(m_tXplatUIX11 == null) { CheckState cs = CheckState.Indeterminate; // In System.Windows.Forms string strTypeCS = cs.GetType().AssemblyQualifiedName; string strTypeX11 = strTypeCS.Replace("CheckState", "XplatUIX11"); m_tXplatUIX11 = Type.GetType(strTypeX11, bThrowOnError, true); } return m_tXplatUIX11; } private static Type m_tHwnd = null; private static Type GetHwndType(bool bThrowOnError) { if(m_tHwnd == null) { CheckState cs = CheckState.Indeterminate; // In System.Windows.Forms string strTypeCS = cs.GetType().AssemblyQualifiedName; string strTypeHwnd = strTypeCS.Replace("CheckState", "Hwnd"); m_tHwnd = Type.GetType(strTypeHwnd, bThrowOnError, true); } return m_tHwnd; } 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); FieldInfo fiDisplayHandle = tXplatUIX11.GetField("DisplayHandle", BindingFlags.NonPublic | BindingFlags.Static); IntPtr hDisplay = (IntPtr)fiDisplayHandle.GetValue(null); Type tHwnd = GetHwndType(true); MethodInfo miObjectFromHandle = tHwnd.GetMethod("ObjectFromHandle", BindingFlags.Public | BindingFlags.Static); object oHwnd = miObjectFromHandle.Invoke(null, new object[] { f.Handle }); FieldInfo fiWholeWindow = tHwnd.GetField("whole_window", BindingFlags.NonPublic | BindingFlags.Instance); IntPtr hWindow = (IntPtr)fiWholeWindow.GetValue(oHwnd); XClassHint xch = new XClassHint(); xch.res_name = Marshal.StringToCoTaskMemAnsi(strName ?? string.Empty); xch.res_class = Marshal.StringToCoTaskMemAnsi(strClass ?? string.Empty); IntPtr pXch = Marshal.AllocCoTaskMem(Marshal.SizeOf(xch)); Marshal.StructureToPtr(xch, pXch, false); XSetClassHint(hDisplay, hWindow, pXch); Marshal.FreeCoTaskMem(pXch); Marshal.FreeCoTaskMem(xch.res_name); Marshal.FreeCoTaskMem(xch.res_class); } catch(Exception) { Debug.Assert(false); } } /* private static Dictionary m_dAsms = null; internal static Assembly LoadAssembly(string strAsmName, string strFileName) { if(m_dAsms == null) m_dAsms = new Dictionary(); Assembly asm; if(m_dAsms.TryGetValue(strAsmName, out asm)) return asm; try { asm = Assembly.Load(strAsmName); if(asm != null) { m_dAsms[strAsmName] = asm; return asm; } } catch(Exception) { } try { asm = Assembly.LoadFrom(strFileName); if(asm != null) { m_dAsms[strAsmName] = asm; return asm; } } catch(Exception) { } for(int d = 0; d < 4; ++d) { string strDir; switch(d) { case 0: strDir = "/usr/lib/mono/gac"; break; case 1: strDir = "/usr/lib/cli"; break; case 2: strDir = "/usr/lib/mono"; break; case 3: strDir = "/lib/mono"; break; default: strDir = null; break; } if(string.IsNullOrEmpty(strDir)) { Debug.Assert(false); continue; } try { string[] vFiles = Directory.GetFiles(strDir, strFileName, SearchOption.AllDirectories); if(vFiles == null) continue; for(int i = vFiles.Length - 1; i >= 0; --i) { string strFoundName = UrlUtil.GetFileName(vFiles[i]); if(!strFileName.Equals(strFoundName, StrUtil.CaseIgnoreCmp)) continue; try { asm = Assembly.LoadFrom(vFiles[i]); if(asm != null) { m_dAsms[strAsmName] = asm; return asm; } } catch(Exception) { } } } catch(Exception) { } } m_dAsms[strAsmName] = null; return null; } private static bool m_bGtkInitialized = false; internal static bool GtkEnsureInit() { if(m_bGtkInitialized) return true; try { Assembly asm = LoadAssembly("gtk-sharp", "gtk-sharp.dll"); if(asm == null) return false; Type tApp = asm.GetType("Gtk.Application", true); MethodInfo miInitCheck = tApp.GetMethod("InitCheck", BindingFlags.Public | BindingFlags.Static); if(miInitCheck == null) { Debug.Assert(false); return false; } string[] vArgs = new string[0]; bool bResult = (bool)miInitCheck.Invoke(null, new object[] { PwDefs.ShortProductName, vArgs }); if(!bResult) return false; m_bGtkInitialized = true; return true; } catch(Exception) { Debug.Assert(false); } return false; } */ } } keepass2-2.25/KeePass/Native/NativeMethods.New.cs0000664000175000017500000004017412265455304021541 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Text; using System.Security; using System.Runtime.InteropServices; using System.Windows.Forms; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.IO; using System.Diagnostics; using KeePass.UI; using KeePass.Util; using KeePassLib.Utility; namespace KeePass.Native { internal static partial class NativeMethods { internal static string GetWindowText(IntPtr hWnd, bool bTrim) { int nLength = GetWindowTextLength(hWnd); if(nLength <= 0) return string.Empty; StringBuilder sb = new StringBuilder(nLength + 1); GetWindowText(hWnd, sb, sb.Capacity); string strWindow = sb.ToString(); return (bTrim ? strWindow.Trim() : strWindow); } /* internal static string GetWindowClassName(IntPtr hWnd) { try { StringBuilder sb = new StringBuilder(260); if(GetClassName(hWnd, sb, 258) > 0) return sb.ToString(); else { Debug.Assert(false); } return string.Empty; } catch(Exception) { Debug.Assert(false); } return null; } */ internal static IntPtr GetForegroundWindowHandle() { if(!KeePassLib.Native.NativeLib.IsUnix()) return GetForegroundWindow(); // Windows API try { return new IntPtr(int.Parse(RunXDoTool("getactivewindow"))); } catch(Exception) { Debug.Assert(false); } return IntPtr.Zero; } private static readonly char[] m_vWindowTrim = { '\r', '\n' }; internal static void GetForegroundWindowInfo(out IntPtr hWnd, out string strWindowText, bool bTrimWindow) { hWnd = GetForegroundWindowHandle(); if(!KeePassLib.Native.NativeLib.IsUnix()) // Windows strWindowText = GetWindowText(hWnd, bTrimWindow); else // Unix { strWindowText = RunXDoTool("getactivewindow getwindowname"); if(!string.IsNullOrEmpty(strWindowText)) { if(bTrimWindow) strWindowText = strWindowText.Trim(); else strWindowText = strWindowText.Trim(m_vWindowTrim); } } } internal static bool IsWindowEx(IntPtr hWnd) { if(!KeePassLib.Native.NativeLib.IsUnix()) // Windows return IsWindow(hWnd); return true; } internal static int GetWindowStyle(IntPtr hWnd) { return GetWindowLong(hWnd, GWL_STYLE); } internal static IntPtr GetClassLongPtr(IntPtr hWnd, int nIndex) { if(IntPtr.Size > 4) return GetClassLongPtr64(hWnd, nIndex); return GetClassLongPtr32(hWnd, nIndex); } internal static bool SetForegroundWindowEx(IntPtr hWnd) { if(!KeePassLib.Native.NativeLib.IsUnix()) return SetForegroundWindow(hWnd); return (RunXDoTool("windowactivate " + hWnd.ToInt64().ToString()).Trim().Length == 0); } internal static bool EnsureForegroundWindow(IntPtr hWnd) { if(IsWindowEx(hWnd) == false) return false; if(SetForegroundWindowEx(hWnd) == false) { Debug.Assert(false); return false; } int nStartMS = Environment.TickCount; while((Environment.TickCount - nStartMS) < 1000) { IntPtr h = GetForegroundWindowHandle(); if(h == hWnd) return true; Application.DoEvents(); } return false; } internal static bool LoseFocus(Form fCurrent) { if(KeePassLib.Native.NativeLib.IsUnix()) return LoseFocusUnix(fCurrent); try { IntPtr hCurrentWnd = ((fCurrent != null) ? fCurrent.Handle : IntPtr.Zero); IntPtr hWnd = GetWindow(hCurrentWnd, GW_HWNDNEXT); while(true) { if(hWnd != hCurrentWnd) { int nStyle = GetWindowStyle(hWnd); if(((nStyle & WS_VISIBLE) != 0) && (GetWindowTextLength(hWnd) > 0)) { // Skip the taskbar window (required for Windows 7, // when the target window is the only other window // in the taskbar) if(!IsTaskBar(hWnd)) break; } } hWnd = GetWindow(hWnd, GW_HWNDNEXT); if(hWnd == IntPtr.Zero) break; } if(hWnd == IntPtr.Zero) return false; Debug.Assert(GetWindowText(hWnd, true) != "Start"); return EnsureForegroundWindow(hWnd); } catch(Exception) { Debug.Assert(false); } return false; } internal static bool IsTaskBar(IntPtr hWnd) { Process p = null; try { string strText = GetWindowText(hWnd, true); if(strText == null) return false; if(!strText.Equals("Start", StrUtil.CaseIgnoreCmp)) return false; uint uProcessId; NativeMethods.GetWindowThreadProcessId(hWnd, out uProcessId); p = Process.GetProcessById((int)uProcessId); string strExe = UrlUtil.GetFileName(p.MainModule.FileName).Trim(); return strExe.Equals("Explorer.exe", StrUtil.CaseIgnoreCmp); } catch(Exception) { Debug.Assert(false); } finally { try { if(p != null) p.Dispose(); } catch(Exception) { Debug.Assert(false); } } return false; } /* internal static bool IsMetroWindow(IntPtr hWnd) { if(hWnd == IntPtr.Zero) { Debug.Assert(false); return false; } if(KeePassLib.Native.NativeLib.IsUnix() || !WinUtil.IsAtLeastWindows8) return false; try { uint uProcessId; NativeMethods.GetWindowThreadProcessId(hWnd, out uProcessId); if(uProcessId == 0) { Debug.Assert(false); return false; } IntPtr h = NativeMethods.OpenProcess(NativeMethods.PROCESS_QUERY_INFORMATION, false, uProcessId); if(h == IntPtr.Zero) return false; // No assert bool bRet = NativeMethods.IsImmersiveProcess(h); NativeMethods.CloseHandle(h); return bRet; } catch(Exception) { Debug.Assert(false); } return false; } */ public static bool IsInvalidHandleValue(IntPtr p) { long h = p.ToInt64(); if(h == -1) return true; if(h == 0xFFFFFFFF) return true; return false; } // Workaround for only partially visible list view items /* public static void EnsureVisible(ListView lv, int nIndex, bool bPartialOK) { Debug.Assert(lv != null); if(lv == null) return; Debug.Assert(nIndex >= 0); if(nIndex < 0) return; Debug.Assert(nIndex < lv.Items.Count); if(nIndex >= lv.Items.Count) return; int nPartialOK = (bPartialOK ? 1 : 0); try { NativeMethods.SendMessage(lv.Handle, LVM_ENSUREVISIBLE, new IntPtr(nIndex), new IntPtr(nPartialOK)); } catch(Exception) { Debug.Assert(false); } } */ public static int GetScrollPosY(IntPtr hWnd) { try { SCROLLINFO si = new SCROLLINFO(); si.cbSize = (uint)Marshal.SizeOf(si); si.fMask = (uint)ScrollInfoMask.SIF_POS; if(GetScrollInfo(hWnd, (int)ScrollBarDirection.SB_VERT, ref si)) return si.nPos; Debug.Assert(false); } catch(Exception) { Debug.Assert(false); } return 0; } public static void Scroll(ListView lv, int dx, int dy) { if(lv == null) throw new ArgumentNullException("lv"); try { SendMessage(lv.Handle, LVM_SCROLL, (IntPtr)dx, (IntPtr)dy); } catch(Exception) { Debug.Assert(false); } } /* public static void ScrollAbsY(IntPtr hWnd, int y) { try { SCROLLINFO si = new SCROLLINFO(); si.cbSize = (uint)Marshal.SizeOf(si); si.fMask = (uint)ScrollInfoMask.SIF_POS; si.nPos = y; SetScrollInfo(hWnd, (int)ScrollBarDirection.SB_VERT, ref si, true); } catch(Exception) { Debug.Assert(false); } } */ /* public static void Scroll(IntPtr h, int dx, int dy) { if(h == IntPtr.Zero) { Debug.Assert(false); return; } // No throw try { ScrollWindowEx(h, dx, dy, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, SW_INVALIDATE); } catch(Exception) { Debug.Assert(false); } } */ /* internal static void ClearIconicBitmaps(IntPtr hWnd) { // TaskbarList.SetThumbnailClip(hWnd, new Rectangle(0, 0, 1, 1)); // TaskbarList.SetThumbnailClip(hWnd, null); try { DwmInvalidateIconicBitmaps(hWnd); } catch(Exception) { Debug.Assert(!WinUtil.IsAtLeastWindows7); } } */ internal static uint? GetLastInputTime() { try { LASTINPUTINFO lii = new LASTINPUTINFO(); lii.cbSize = (uint)Marshal.SizeOf(typeof(LASTINPUTINFO)); if(!GetLastInputInfo(ref lii)) { Debug.Assert(false); return null; } return lii.dwTime; } catch(Exception) { Debug.Assert(KeePassLib.Native.NativeLib.IsUnix() || WinUtil.IsWindows9x); } return null; } internal static bool SHGetFileInfo(string strPath, int nPrefImgDim, out Image img, out string strDisplayName) { img = null; strDisplayName = null; try { SHFILEINFO fi = new SHFILEINFO(); IntPtr p = SHGetFileInfo(strPath, 0, ref fi, (uint)Marshal.SizeOf(typeof( SHFILEINFO)), SHGFI_ICON | SHGFI_SMALLICON | SHGFI_DISPLAYNAME); if(p == IntPtr.Zero) return false; if(fi.hIcon != IntPtr.Zero) { using(Icon ico = Icon.FromHandle(fi.hIcon)) // Doesn't take ownership { img = new Bitmap(nPrefImgDim, nPrefImgDim); using(Graphics g = Graphics.FromImage(img)) { g.Clear(Color.Transparent); g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.SmoothingMode = SmoothingMode.HighQuality; g.DrawIcon(ico, new Rectangle(0, 0, nPrefImgDim, nPrefImgDim)); } } if(!DestroyIcon(fi.hIcon)) { Debug.Assert(false); } } strDisplayName = fi.szDisplayName; return true; } catch(Exception) { Debug.Assert(false); } return false; } /// /// Method for testing whether a file exists or not. Also /// supports NTFS alternate data streams. /// /// Path of the file or stream. /// true if the file exists. public static bool FileExists(string strFilePath) { if(strFilePath == null) throw new ArgumentNullException("strFilePath"); try { return (GetFileAttributes(strFilePath) != INVALID_FILE_ATTRIBUTES); } catch(Exception) { Debug.Assert(KeePassLib.Native.NativeLib.IsUnix()); } // Fallback to .NET method for Unix-like systems try { return File.Exists(strFilePath); } catch(Exception) { Debug.Assert(false); } // Invalid path return false; } /* internal static LVGROUP GetGroupInfoByIndex(ListView lv, uint uIndex) { if(lv == null) throw new ArgumentNullException("lv"); if(uIndex >= (uint)lv.Groups.Count) throw new ArgumentOutOfRangeException("uIndex"); const int nStrLen = 1024; LVGROUP g = new LVGROUP(); g.cbSize = (uint)Marshal.SizeOf(typeof(LVGROUP)); g.mask = ...; g.pszHeader = new StringBuilder(nStrLen); g.cchHeader = nStrLen - 1; g.pszFooter = new StringBuilder(nStrLen); g.cchFooter = nStrLen - 1; g.pszSubtitle = new StringBuilder(nStrLen); g.cchSubtitle = (uint)(nStrLen - 1); g.pszTask = new StringBuilder(nStrLen); g.cchTask = (uint)(nStrLen - 1); g.pszDescriptionTop = new StringBuilder(nStrLen); g.cchDescriptionTop = (uint)(nStrLen - 1); g.pszDescriptionBottom = new StringBuilder(nStrLen); g.cchDescriptionBottom = (uint)(nStrLen - 1); g.pszSubsetTitle = new StringBuilder(nStrLen); g.cchSubsetTitle = (uint)(nStrLen - 1); SendMessageLVGroup(lv.Handle, LVM_GETGROUPINFOBYINDEX, new IntPtr((int)uIndex), ref g); return g; } */ /* internal static uint GetGroupStateByIndex(ListView lv, uint uIndex, uint uStateMask, out int iGroupID) { if(lv == null) throw new ArgumentNullException("lv"); if(uIndex >= (uint)lv.Groups.Count) throw new ArgumentOutOfRangeException("uIndex"); LVGROUP g = new LVGROUP(); g.cbSize = (uint)Marshal.SizeOf(g); g.mask = (LVGF_STATE | LVGF_GROUPID); g.stateMask = uStateMask; SendMessageLVGroup(lv.Handle, LVM_GETGROUPINFOBYINDEX, new IntPtr((int)uIndex), ref g); iGroupID = g.iGroupId; return g.state; } internal static void SetGroupState(ListView lv, int iGroupID, uint uStateMask, uint uState) { if(lv == null) throw new ArgumentNullException("lv"); LVGROUP g = new LVGROUP(); g.cbSize = (uint)Marshal.SizeOf(g); g.mask = LVGF_STATE; g.stateMask = uStateMask; g.state = uState; SendMessageLVGroup(lv.Handle, LVM_SETGROUPINFO, new IntPtr(iGroupID), ref g); } */ /* internal static int GetGroupIDByIndex(ListView lv, uint uIndex) { if(lv == null) { Debug.Assert(false); return 0; } LVGROUP g = new LVGROUP(); g.cbSize = (uint)Marshal.SizeOf(g); g.AssertSize(); g.mask = NativeMethods.LVGF_GROUPID; if(SendMessageLVGroup(lv.Handle, LVM_GETGROUPINFOBYINDEX, new IntPtr((int)uIndex), ref g) == IntPtr.Zero) { Debug.Assert(false); } return g.iGroupId; } internal static void SetGroupTask(ListView lv, int iGroupID, string strTask) { if(lv == null) { Debug.Assert(false); return; } LVGROUP g = new LVGROUP(); g.cbSize = (uint)Marshal.SizeOf(g); g.AssertSize(); g.mask = LVGF_TASK; g.pszTask = strTask; g.cchTask = (uint)((strTask != null) ? strTask.Length : 0); if(SendMessageLVGroup(lv.Handle, LVM_SETGROUPINFO, new IntPtr(iGroupID), ref g) == (new IntPtr(-1))) { Debug.Assert(false); } } */ private static bool GetDesktopName(IntPtr hDesk, out string strAnsi, out string strUni) { strAnsi = null; strUni = null; const uint cbZ = 12; // Minimal number of terminating zeros const uint uBufSize = 64 + cbZ; IntPtr pBuf = Marshal.AllocCoTaskMem((int)uBufSize); byte[] pbZero = new byte[uBufSize]; Marshal.Copy(pbZero, 0, pBuf, pbZero.Length); try { uint uReqSize = uBufSize - cbZ; bool bSuccess = GetUserObjectInformation(hDesk, 2, pBuf, uBufSize - cbZ, ref uReqSize); if(uReqSize > (uBufSize - cbZ)) { Marshal.FreeCoTaskMem(pBuf); pBuf = Marshal.AllocCoTaskMem((int)(uReqSize + cbZ)); pbZero = new byte[uReqSize + cbZ]; Marshal.Copy(pbZero, 0, pBuf, pbZero.Length); bSuccess = GetUserObjectInformation(hDesk, 2, pBuf, uReqSize, ref uReqSize); Debug.Assert((uReqSize + cbZ) == (uint)pbZero.Length); } if(bSuccess) { try { strAnsi = Marshal.PtrToStringAnsi(pBuf).Trim(); } catch(Exception) { } try { strUni = Marshal.PtrToStringUni(pBuf).Trim(); } catch(Exception) { } return true; } } finally { Marshal.FreeCoTaskMem(pBuf); } Debug.Assert(false); return false; } // The GetUserObjectInformation function apparently returns the // desktop name using ANSI encoding even on Windows 7 systems. // As the encoding is not documented, we test both ANSI and // Unicode versions of the name. internal static bool? DesktopNameContains(IntPtr hDesk, string strName) { if(string.IsNullOrEmpty(strName)) { Debug.Assert(false); return false; } string strAnsi, strUni; if(!GetDesktopName(hDesk, out strAnsi, out strUni)) return null; if((strAnsi == null) && (strUni == null)) return null; try { if((strAnsi != null) && (strAnsi.IndexOf(strName, StringComparison.OrdinalIgnoreCase) >= 0)) return true; } catch(Exception) { Debug.Assert(false); } try { if((strUni != null) && (strUni.IndexOf(strName, StringComparison.OrdinalIgnoreCase) >= 0)) return true; } catch(Exception) { Debug.Assert(false); } return false; } } } keepass2-2.25/KeePass/DataExchange/0000775000175000017500000000000012271000176016756 5ustar jtaylorjtaylorkeepass2-2.25/KeePass/DataExchange/Json.cs0000664000175000017500000001577712261553106020244 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Globalization; using System.Diagnostics; using KeePassLib.Utility; using KeePassLib.Resources; namespace KeePass.DataExchange { public sealed class JsonFormatException : Exception { public override string Message { get { return KLRes.InvalidDataWhileDecoding; } } public JsonFormatException() { Debug.Assert(false); } } public sealed class JsonObject { private Dictionary m_dict = new Dictionary(); public Dictionary Items { get { return m_dict; } } public JsonObject(CharStream csDataSource) { if(csDataSource == null) throw new ArgumentNullException("csDataSource"); char chInit = csDataSource.ReadChar(true); if(chInit != '{') throw new JsonFormatException(); while(true) { string strName = (new JsonString(csDataSource)).Value; char chSeparator = csDataSource.ReadChar(true); if(chSeparator != ':') throw new JsonFormatException(); JsonValue jValue = new JsonValue(csDataSource); m_dict[strName] = jValue; char chNext = csDataSource.PeekChar(true); if(chNext == '}') break; else if(chNext == ',') csDataSource.ReadChar(true); else throw new JsonFormatException(); } char chTerminator = csDataSource.ReadChar(true); if(chTerminator != '}') throw new JsonFormatException(); } } public sealed class JsonArray { private JsonValue[] m_values; public JsonValue[] Values { get { return m_values; } } public JsonArray(JsonValue[] vValues) { if(vValues == null) throw new ArgumentNullException("vValues"); m_values = vValues; } public JsonArray(CharStream csDataSource) { if(csDataSource == null) throw new ArgumentNullException("csDataSource"); char chInit = csDataSource.ReadChar(true); if(chInit != '[') throw new JsonFormatException(); List lValues = new List(); while(true) { char chNext = csDataSource.PeekChar(true); if(chNext == ']') break; lValues.Add(new JsonValue(csDataSource)); chNext = csDataSource.PeekChar(true); if(chNext == ',') csDataSource.ReadChar(true); } char chTerminator = csDataSource.ReadChar(true); if(chTerminator != ']') throw new JsonFormatException(); m_values = lValues.ToArray(); } } public sealed class JsonValue { private object m_value; public object Value { get { return m_value; } } public JsonValue(CharStream csDataSource) { if(csDataSource == null) throw new ArgumentNullException("csDataSource"); char chNext = csDataSource.PeekChar(true); if(chNext == '\"') m_value = (new JsonString(csDataSource)).Value; else if(chNext == '{') m_value = new JsonObject(csDataSource); else if(chNext == '[') m_value = new JsonArray(csDataSource); else if(chNext == 't') { for(int i = 0; i < 4; ++i) csDataSource.ReadChar(true); m_value = true; } else if(chNext == 'f') { for(int i = 0; i < 5; ++i) csDataSource.ReadChar(true); m_value = false; } else if(chNext == 'n') { for(int i = 0; i < 4; ++i) csDataSource.ReadChar(true); m_value = null; } else m_value = new JsonNumber(csDataSource); } public override string ToString() { if(m_value != null) return m_value.ToString(); return string.Empty; } } public sealed class JsonString { private string m_str; public string Value { get { return m_str; } } public JsonString(string strValue) { if(strValue == null) throw new ArgumentNullException("strValue"); m_str = strValue; } public JsonString(CharStream csDataSource) { if(csDataSource == null) throw new ArgumentNullException("csDataSource"); char chInit = csDataSource.ReadChar(true); if(chInit != '\"') throw new JsonFormatException(); StringBuilder sb = new StringBuilder(); while(true) { char ch = csDataSource.ReadChar(); if(ch == char.MinValue) throw new JsonFormatException(); if(ch == '\"') break; // End of string else if(ch == '\\') { char chNext = csDataSource.ReadChar(); if(chNext == char.MinValue) throw new JsonFormatException(); if((chNext == 'b') || (chNext == 'f')) { } // Ignore else if(chNext == 'r') sb.Append('\r'); else if(chNext == 'n') sb.Append('\n'); else if(chNext == 't') sb.Append('\t'); else if(chNext == 'u') { char ch1 = csDataSource.ReadChar(); char ch2 = csDataSource.ReadChar(); char ch3 = csDataSource.ReadChar(); char ch4 = csDataSource.ReadChar(); if(ch4 == char.MinValue) throw new JsonFormatException(); byte[] pbUni = MemUtil.HexStringToByteArray(new string( new char[] { ch1, ch2, ch3, ch4 })); if((pbUni != null) && (pbUni.Length == 2)) sb.Append((char)(((ushort)pbUni[0] << 8) | (ushort)pbUni[1])); else throw new JsonFormatException(); } else sb.Append(chNext); } else sb.Append(ch); } m_str = sb.ToString(); } public override string ToString() { return m_str; } } public sealed class JsonNumber { private double m_value; public double Value { get { return m_value; } } public JsonNumber(CharStream csDataSource) { if(csDataSource == null) throw new ArgumentNullException("csDataSource"); StringBuilder sb = new StringBuilder(); while(true) { char ch = csDataSource.PeekChar(true); if(((ch >= '0') && (ch <= '9')) || (ch == 'e') || (ch == 'E') || (ch == '+') || (ch == '-') || (ch == '.')) { csDataSource.ReadChar(true); sb.Append(ch); } else break; } const NumberStyles ns = (NumberStyles.Integer | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowExponent); if(!double.TryParse(sb.ToString(), ns, NumberFormatInfo.InvariantInfo, out m_value)) { Debug.Assert(false); } } public override string ToString() { return m_value.ToString(NumberFormatInfo.InvariantInfo); } } } keepass2-2.25/KeePass/DataExchange/FileFormatProvider.cs0000664000175000017500000001227012261553106023057 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using System.Drawing; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; namespace KeePass.DataExchange { public abstract class FileFormatProvider { public abstract bool SupportsImport { get; } public abstract bool SupportsExport { get; } public abstract string FormatName { get; } public virtual string DisplayName { get { return this.FormatName; } } /// /// Default file name extension, without leading dot. /// If there are multiple default/equivalent extensions /// (like e.g. "html" and "htm"), specify all of them /// separated by a '|' (e.g. "html|htm"). /// public virtual string DefaultExtension { get { return string.Empty; } } /// /// Type of the original application using this format (like /// password manager / KPRes.PasswordManagers, /// web site / KPRes.WebSites, /// browser / KPRes.Browser, etc. /// public virtual string ApplicationGroup { get { return KPRes.General; } } public virtual Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Folder_Inbox; } } public virtual bool RequiresFile { get { return true; } } public virtual bool SupportsUuids { get { return false; } } public virtual bool RequiresKey { get { return false; } } /// /// This property specifies if entries are only appended to the /// end of the root group. This is true for example if the /// file format doesn't support groups (i.e. no hierarchy). /// public virtual bool ImportAppendsToRootGroupOnly { get { return false; } } /// /// If the importer is implemented as a profile for the generic /// XML importer, return the profile using this property (in /// this case the Import method must not be overridden!). /// internal virtual GxiProfile XmlProfile { get { return null; } } /// /// Called before the Import method is invoked. /// /// Returns true, if the Import method /// can be invoked. If it returns false, something has /// failed and the import process should be aborted. public virtual bool TryBeginImport() { return true; } /// /// Called before the Export method is invoked. /// /// Returns true, if the Export method /// can be invoked. If it returns false, something has /// failed and the export process should be aborted. public virtual bool TryBeginExport() { return true; } /// /// Import a stream into a database. Throws an exception if an error /// occurs. Do not call the base class method when overriding it. /// /// Data storage into which the data will be imported. /// Input stream to read the data from. /// Status logger. May be null. public virtual void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { GxiProfile p = this.XmlProfile; if(p != null) { if(pwStorage == null) throw new ArgumentNullException("pwStorage"); GxiImporter.Import(pwStorage.RootGroup, sInput, p, pwStorage, slLogger); return; } throw new NotSupportedException(); } /// /// Export data into a stream. Throws an exception if an error /// occurs (like writing to stream fails, etc.). Returns true, /// if the export was successful. /// /// Contains the data source and detailed /// information about which entries should be exported. /// Output stream to write the data to. /// Status logger. May be null. /// Returns false, if the user has aborted the export /// process (like clicking Cancel in an additional export settings /// dialog). public virtual bool Export(PwExportInfo pwExportInfo, Stream sOutput, IStatusLogger slLogger) { throw new NotSupportedException(); } } } keepass2-2.25/KeePass/DataExchange/PwExportInfo.cs0000664000175000017500000000447212261553106021725 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePassLib; namespace KeePass.DataExchange { public sealed class PwExportInfo { private PwGroup m_pg; /// /// This group contains all entries and subgroups that should /// be exported. Is never null. /// public PwGroup DataGroup { get { return m_pg; } } private PwDatabase m_pd; /// /// Optional context database reference. May be null. /// public PwDatabase ContextDatabase { get { return m_pd; } } private bool m_bExpDel = true; /// /// Indicates whether deleted objects should be exported, if /// the data format supports it. /// public bool ExportDeletedObjects { get { return m_bExpDel; } } public PwExportInfo(PwGroup pgDataSource, PwDatabase pwContextInfo) { ConstructEx(pgDataSource, pwContextInfo, null); } public PwExportInfo(PwGroup pgDataSource, PwDatabase pwContextInfo, bool bExportDeleted) { ConstructEx(pgDataSource, pwContextInfo, bExportDeleted); } private void ConstructEx(PwGroup pgDataSource, PwDatabase pwContextInfo, bool? bExportDeleted) { if(pgDataSource == null) throw new ArgumentNullException("pgDataSource"); // pwContextInfo may be null. m_pg = pgDataSource; m_pd = pwContextInfo; if(bExportDeleted.HasValue) m_bExpDel = bExportDeleted.Value; } } } keepass2-2.25/KeePass/DataExchange/ExportUtil.cs0000664000175000017500000001050012261553106021425 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Windows.Forms; using System.Diagnostics; using System.IO; using KeePass.App; using KeePass.Forms; using KeePass.UI; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Serialization; using KeePassLib.Utility; namespace KeePass.DataExchange { public static class ExportUtil { public static bool Export(PwExportInfo pwExportInfo, IStatusLogger slLogger) { if(pwExportInfo == null) throw new ArgumentNullException("pwExportInfo"); if(pwExportInfo.DataGroup == null) throw new ArgumentException(); if(!AppPolicy.Try(AppPolicyId.Export)) return false; ExchangeDataForm dlg = new ExchangeDataForm(); dlg.InitEx(true, pwExportInfo.ContextDatabase, pwExportInfo.DataGroup); bool bResult = false; if(dlg.ShowDialog() == DialogResult.OK) { FileFormatProvider ffp = dlg.ResultFormat; if(ffp == null) { Debug.Assert(false); goto ExpZRet; } if(ffp.RequiresFile) { if(dlg.ResultFiles.Length != 1) { Debug.Assert(false); goto ExpZRet; } if(dlg.ResultFiles[0] == null) { Debug.Assert(false); goto ExpZRet; } if(dlg.ResultFiles[0].Length == 0) { Debug.Assert(false); goto ExpZRet; } } Application.DoEvents(); // Redraw parent window IOConnectionInfo iocOutput = (ffp.RequiresFile ? IOConnectionInfo.FromPath( dlg.ResultFiles[0]) : null); try { bResult = Export(pwExportInfo, dlg.ResultFormat, iocOutput, slLogger); } catch(Exception ex) { MessageService.ShowWarning(ex); } } ExpZRet: UIUtil.DestroyForm(dlg); return bResult; } public static bool Export(PwExportInfo pwExportInfo, string strFormatName, IOConnectionInfo iocOutput) { if(strFormatName == null) throw new ArgumentNullException("strFormatName"); // iocOutput may be null FileFormatProvider prov = Program.FileFormatPool.Find(strFormatName); if(prov == null) return false; NullStatusLogger slLogger = new NullStatusLogger(); return Export(pwExportInfo, prov, iocOutput, slLogger); } public static bool Export(PwExportInfo pwExportInfo, FileFormatProvider fileFormat, IOConnectionInfo iocOutput, IStatusLogger slLogger) { if(pwExportInfo == null) throw new ArgumentNullException("pwExportInfo"); if(pwExportInfo.DataGroup == null) throw new ArgumentException(); if(fileFormat == null) throw new ArgumentNullException("fileFormat"); if(fileFormat.RequiresFile && (iocOutput == null)) throw new ArgumentNullException("iocOutput"); if(!AppPolicy.Try(AppPolicyId.Export)) return false; if(!fileFormat.SupportsExport) return false; if(!fileFormat.TryBeginExport()) return false; // bool bExistedAlready = File.Exists(strOutputFile); bool bExistedAlready = (fileFormat.RequiresFile ? IOConnection.FileExists( iocOutput) : false); // FileStream fsOut = new FileStream(strOutputFile, FileMode.Create, // FileAccess.Write, FileShare.None); Stream sOut = (fileFormat.RequiresFile ? IOConnection.OpenWrite( iocOutput) : null); bool bResult = false; try { bResult = fileFormat.Export(pwExportInfo, sOut, slLogger); } catch(Exception ex) { MessageService.ShowWarning(ex); } if(sOut != null) sOut.Close(); if(fileFormat.RequiresFile && (bResult == false) && (bExistedAlready == false)) { try { IOConnection.DeleteFile(iocOutput); } catch(Exception) { } } return bResult; } } } keepass2-2.25/KeePass/DataExchange/CsvStreamReaderEx.cs0000664000175000017500000001224112261553106022641 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using KeePassLib.Utility; namespace KeePass.DataExchange { public sealed class CsvOptions { private char m_chFieldSep = ','; public char FieldSeparator { get { return m_chFieldSep; } set { m_chFieldSep = value; } } private char m_chRecSep = '\n'; public char RecordSeparator { get { return m_chRecSep; } set { m_chRecSep = value; } } private char m_chTextQual = '\"'; public char TextQualifier { get { return m_chTextQual; } set { m_chTextQual = value; } } private bool m_bBackEscape = true; public bool BackslashIsEscape { get { return m_bBackEscape; } set { m_bBackEscape = value; } } private bool m_bTrimFields = true; public bool TrimFields { get { return m_bTrimFields; } set { m_bTrimFields = value; } } private string m_strNewLineSeq = "\r\n"; public string NewLineSequence { get { return m_strNewLineSeq; } set { if(value == null) throw new ArgumentNullException("value"); m_strNewLineSeq = value; } } } public sealed class CsvStreamReaderEx { private CharStream m_sChars; private CsvOptions m_opt; public CsvStreamReaderEx(string strData) { Init(strData, null); } public CsvStreamReaderEx(string strData, CsvOptions opt) { Init(strData, opt); } private void Init(string strData, CsvOptions opt) { if(strData == null) throw new ArgumentNullException("strData"); m_opt = (opt ?? new CsvOptions()); string strInput = strData; // Normalize to Unix "\n" right now; the new lines are // converted back in the AddField method strInput = StrUtil.NormalizeNewLines(strInput, false); strInput = strInput.Trim(new char[] { (char)0 }); m_sChars = new CharStream(strInput); } public string[] ReadLine() { char chFirst = m_sChars.PeekChar(); if(chFirst == char.MinValue) return null; List v = new List(); StringBuilder sb = new StringBuilder(); bool bInText = false; char chFS = m_opt.FieldSeparator, chRS = m_opt.RecordSeparator; char chTQ = m_opt.TextQualifier; while(true) { char ch = m_sChars.ReadChar(); if(ch == char.MinValue) break; Debug.Assert(ch != '\r'); // Was normalized to Unix "\n" if((ch == '\\') && m_opt.BackslashIsEscape) { char chEsc = m_sChars.ReadChar(); if(chEsc == char.MinValue) break; if(chEsc == 'n') sb.Append('\n'); else if(chEsc == 'r') sb.Append('\r'); else if(chEsc == 't') sb.Append('\t'); else if(chEsc == 'u') { char chNum1 = m_sChars.ReadChar(); char chNum2 = m_sChars.ReadChar(); char chNum3 = m_sChars.ReadChar(); char chNum4 = m_sChars.ReadChar(); if(chNum4 != char.MinValue) // Implies the others { StringBuilder sbNum = new StringBuilder(); sbNum.Append(chNum3); sbNum.Append(chNum4); // Little sbNum.Append(chNum1); sbNum.Append(chNum2); // Endian byte[] pbNum = MemUtil.HexStringToByteArray(sbNum.ToString()); ushort usNum = MemUtil.BytesToUInt16(pbNum); sb.Append((char)usNum); } } else sb.Append(chEsc); } else if(ch == chTQ) { if(!bInText) bInText = true; else // bInText { char chNext = m_sChars.PeekChar(); if(chNext == chTQ) { m_sChars.ReadChar(); sb.Append(chTQ); } else bInText = false; } } else if((ch == chRS) && !bInText) break; else if(bInText) sb.Append(ch); else if(ch == chFS) { AddField(v, sb.ToString()); if(sb.Length > 0) sb.Remove(0, sb.Length); } else sb.Append(ch); } // Debug.Assert(!bInText); AddField(v, sb.ToString()); return v.ToArray(); } private void AddField(List v, string strField) { // Escape characters might have been used to insert // new lines that might not conform to Unix "\n" strField = StrUtil.NormalizeNewLines(strField, false); // Transform to final form of new lines strField = strField.Replace("\n", m_opt.NewLineSequence); if(m_opt.TrimFields) strField = strField.Trim(); v.Add(strField); } } } keepass2-2.25/KeePass/DataExchange/ImportUtil.cs0000664000175000017500000004561012261553106021430 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Windows.Forms; using System.Diagnostics; using System.Xml; using System.Threading; using KeePass.App; using KeePass.DataExchange.Formats; using KeePass.Forms; using KeePass.Native; using KeePass.Resources; using KeePass.UI; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Keys; using KeePassLib.Resources; using KeePassLib.Security; using KeePassLib.Serialization; using KeePassLib.Utility; namespace KeePass.DataExchange { public static class ImportUtil { public static bool? Import(PwDatabase pwStorage, out bool bAppendedToRootOnly, Form fParent) { bAppendedToRootOnly = false; if(pwStorage == null) throw new ArgumentNullException("pwStorage"); if(!pwStorage.IsOpen) return null; if(!AppPolicy.Try(AppPolicyId.Import)) return null; ExchangeDataForm dlgFmt = new ExchangeDataForm(); dlgFmt.InitEx(false, pwStorage, pwStorage.RootGroup); if(UIUtil.ShowDialogNotValue(dlgFmt, DialogResult.OK)) return null; Debug.Assert(dlgFmt.ResultFormat != null); if(dlgFmt.ResultFormat == null) { MessageService.ShowWarning(KPRes.ImportFailed); UIUtil.DestroyForm(dlgFmt); return false; } bAppendedToRootOnly = dlgFmt.ResultFormat.ImportAppendsToRootGroupOnly; FileFormatProvider ffp = dlgFmt.ResultFormat; List lConnections = new List(); foreach(string strSelFile in dlgFmt.ResultFiles) lConnections.Add(IOConnectionInfo.FromPath(strSelFile)); UIUtil.DestroyForm(dlgFmt); return Import(pwStorage, ffp, lConnections.ToArray(), false, null, false, fParent); } public static bool? Import(PwDatabase pwDatabase, FileFormatProvider fmtImp, IOConnectionInfo[] vConnections, bool bSynchronize, IUIOperations uiOps, bool bForceSave, Form fParent) { if(pwDatabase == null) throw new ArgumentNullException("pwDatabase"); if(!pwDatabase.IsOpen) return null; if(fmtImp == null) throw new ArgumentNullException("fmtImp"); if(vConnections == null) throw new ArgumentNullException("vConnections"); if(!AppPolicy.Try(AppPolicyId.Import)) return false; if(!fmtImp.TryBeginImport()) return false; bool bUseTempDb = (fmtImp.SupportsUuids || fmtImp.RequiresKey); bool bAllSuccess = true; // if(bSynchronize) { Debug.Assert(vFiles.Length == 1); } IStatusLogger dlgStatus; if(Program.Config.UI.ShowImportStatusDialog) dlgStatus = new OnDemandStatusDialog(false, fParent); else dlgStatus = new UIBlockerStatusLogger(fParent); dlgStatus.StartLogging(PwDefs.ShortProductName + " - " + (bSynchronize ? KPRes.Synchronizing : KPRes.ImportingStatusMsg), false); dlgStatus.SetText(bSynchronize ? KPRes.Synchronizing : KPRes.ImportingStatusMsg, LogStatusType.Info); if(vConnections.Length == 0) { try { fmtImp.Import(pwDatabase, null, dlgStatus); } catch(Exception exSingular) { if((exSingular.Message != null) && (exSingular.Message.Length > 0)) { // slf.SetText(exSingular.Message, LogStatusType.Warning); MessageService.ShowWarning(exSingular); } } dlgStatus.EndLogging(); return true; } foreach(IOConnectionInfo iocIn in vConnections) { Stream s = null; try { s = IOConnection.OpenRead(iocIn); } catch(Exception exFile) { MessageService.ShowWarning(iocIn.GetDisplayName(), exFile); bAllSuccess = false; continue; } if(s == null) { Debug.Assert(false); bAllSuccess = false; continue; } PwDatabase pwImp; if(bUseTempDb) { pwImp = new PwDatabase(); pwImp.New(new IOConnectionInfo(), pwDatabase.MasterKey); pwImp.MemoryProtection = pwDatabase.MemoryProtection.CloneDeep(); } else pwImp = pwDatabase; if(fmtImp.RequiresKey && !bSynchronize) { KeyPromptForm kpf = new KeyPromptForm(); kpf.InitEx(iocIn, false, true); if(UIUtil.ShowDialogNotValue(kpf, DialogResult.OK)) { s.Close(); continue; } pwImp.MasterKey = kpf.CompositeKey; UIUtil.DestroyForm(kpf); } else if(bSynchronize) pwImp.MasterKey = pwDatabase.MasterKey; dlgStatus.SetText((bSynchronize ? KPRes.Synchronizing : KPRes.ImportingStatusMsg) + " (" + iocIn.GetDisplayName() + ")", LogStatusType.Info); try { fmtImp.Import(pwImp, s, dlgStatus); } catch(Exception excpFmt) { string strMsgEx = excpFmt.Message; if(bSynchronize && (excpFmt is InvalidCompositeKeyException)) strMsgEx = KLRes.InvalidCompositeKey + MessageService.NewParagraph + KPRes.SynchronizingHint; MessageService.ShowWarning(strMsgEx); s.Close(); bAllSuccess = false; continue; } s.Close(); if(bUseTempDb) { PwMergeMethod mm; if(!fmtImp.SupportsUuids) mm = PwMergeMethod.CreateNewUuids; else if(bSynchronize) mm = PwMergeMethod.Synchronize; else { ImportMethodForm imf = new ImportMethodForm(); if(UIUtil.ShowDialogNotValue(imf, DialogResult.OK)) continue; mm = imf.MergeMethod; UIUtil.DestroyForm(imf); } try { pwDatabase.MergeIn(pwImp, mm, dlgStatus); } catch(Exception exMerge) { MessageService.ShowWarning(iocIn.GetDisplayName(), KPRes.ImportFailed, exMerge); bAllSuccess = false; continue; } } } if(bSynchronize && bAllSuccess) { Debug.Assert(uiOps != null); if(uiOps == null) throw new ArgumentNullException("uiOps"); dlgStatus.SetText(KPRes.Synchronizing + " (" + KPRes.SavingDatabase + ")", LogStatusType.Info); if(uiOps.UIFileSave(bForceSave)) { foreach(IOConnectionInfo ioc in vConnections) { try { // dlgStatus.SetText(KPRes.Synchronizing + " (" + // KPRes.SavingDatabase + " " + ioc.GetDisplayName() + // ")", LogStatusType.Info); if(ioc.Path != pwDatabase.IOConnectionInfo.Path) { if(pwDatabase.IOConnectionInfo.IsLocalFile() && ioc.IsLocalFile()) { File.Copy(pwDatabase.IOConnectionInfo.Path, ioc.Path, true); } else pwDatabase.SaveAs(ioc, false, null); } else { } // No assert (sync on save) if(Program.MainForm != null) // Null for KPScript Program.MainForm.FileMruList.AddItem( ioc.GetDisplayName(), ioc.CloneDeep(), true); } catch(Exception exSync) { MessageService.ShowWarning(KPRes.SyncFailed, pwDatabase.IOConnectionInfo.GetDisplayName() + MessageService.NewLine + ioc.GetDisplayName(), exSync); bAllSuccess = false; continue; } } } else { MessageService.ShowWarning(KPRes.SyncFailed, pwDatabase.IOConnectionInfo.GetDisplayName()); bAllSuccess = false; } } dlgStatus.EndLogging(); return bAllSuccess; } public static bool? Import(PwDatabase pd, FileFormatProvider fmtImp, IOConnectionInfo iocImp, PwMergeMethod mm, CompositeKey cmpKey) { if(pd == null) { Debug.Assert(false); return false; } if(fmtImp == null) { Debug.Assert(false); return false; } if(iocImp == null) { Debug.Assert(false); return false; } if(cmpKey == null) cmpKey = new CompositeKey(); if(!AppPolicy.Try(AppPolicyId.Import)) return false; if(!fmtImp.TryBeginImport()) return false; PwDatabase pdImp = new PwDatabase(); pdImp.New(new IOConnectionInfo(), cmpKey); pdImp.MemoryProtection = pd.MemoryProtection.CloneDeep(); Stream s = IOConnection.OpenRead(iocImp); if(s == null) throw new FileNotFoundException(iocImp.GetDisplayName() + MessageService.NewLine + KPRes.FileNotFoundError); try { fmtImp.Import(pdImp, s, null); } finally { s.Close(); } pd.MergeIn(pdImp, mm); return true; } public static bool? Synchronize(PwDatabase pwStorage, IUIOperations uiOps, bool bOpenFromUrl, Form fParent) { if(pwStorage == null) throw new ArgumentNullException("pwStorage"); if(!pwStorage.IsOpen) return null; if(!AppPolicy.Try(AppPolicyId.Import)) return null; List vConnections = new List(); if(bOpenFromUrl == false) { OpenFileDialogEx ofd = UIUtil.CreateOpenFileDialog(KPRes.Synchronize, UIUtil.CreateFileTypeFilter(null, null, true), 1, null, true, AppDefs.FileDialogContext.Sync); if(ofd.ShowDialog() != DialogResult.OK) return null; foreach(string strSelFile in ofd.FileNames) vConnections.Add(IOConnectionInfo.FromPath(strSelFile)); } else // Open URL { IOConnectionForm iocf = new IOConnectionForm(); iocf.InitEx(false, new IOConnectionInfo(), true, true); if(UIUtil.ShowDialogNotValue(iocf, DialogResult.OK)) return null; vConnections.Add(iocf.IOConnectionInfo); UIUtil.DestroyForm(iocf); } return Import(pwStorage, new KeePassKdb2x(), vConnections.ToArray(), true, uiOps, false, fParent); } public static bool? Synchronize(PwDatabase pwStorage, IUIOperations uiOps, IOConnectionInfo iocSyncWith, bool bForceSave, Form fParent) { if(pwStorage == null) throw new ArgumentNullException("pwStorage"); if(!pwStorage.IsOpen) return null; // No assert or throw if(iocSyncWith == null) throw new ArgumentNullException("iocSyncWith"); if(!AppPolicy.Try(AppPolicyId.Import)) return null; List vConnections = new List(); vConnections.Add(iocSyncWith); return Import(pwStorage, new KeePassKdb2x(), vConnections.ToArray(), true, uiOps, bForceSave, fParent); } public static int CountQuotes(string str, int posMax) { int i = 0, n = 0; while(true) { i = str.IndexOf('\"', i); if(i < 0) return n; ++i; if(i > posMax) return n; ++n; } } public static List SplitCsvLine(string strLine, string strDelimiter) { List list = new List(); int nOffset = 0; while(true) { int i = strLine.IndexOf(strDelimiter, nOffset); if(i < 0) break; int nQuotes = CountQuotes(strLine, i); if((nQuotes & 1) == 0) { list.Add(strLine.Substring(0, i)); strLine = strLine.Remove(0, i + strDelimiter.Length); nOffset = 0; } else { nOffset = i + strDelimiter.Length; if(nOffset >= strLine.Length) break; } } list.Add(strLine); return list; } public static bool SetStatus(IStatusLogger slLogger, uint uPercent) { if(slLogger != null) return slLogger.SetProgress(uPercent); return true; } private static readonly string[] m_vTitles = { "title", "system", "account", "entry", "item", "itemname", "item name", "subject", "service", "servicename", "service name", "head", "heading", "card", "product", "provider", "bank", "type", // Non-English names "seite" }; private static readonly string[] m_vUserNames = { "user", "name", "user name", "username", "login name", "email", "e-mail", "id", "userid", "user id", "login", "form_loginname", "wpname", "mail", "loginid", "login id", "log", "first name", "last name", "card#", "account #", "member", "member #", // Non-English names "nom" }; private static readonly string[] m_vPasswords = { "password", "pass word", "passphrase", "pass phrase", "pass", "code", "code word", "codeword", "secret", "secret word", "key", "keyword", "key word", "keyphrase", "key phrase", "form_pw", "wppassword", "pin", "pwd", "pw", "pword", "p", "serial", "serial#", "license key", "reg #" }; private static readonly string[] m_vUrls = { "url", "hyper link", "hyperlink", "link", "host", "hostname", "host name", "server", "address", "hyper ref", "href", "web", "website", "web site", "site", "web-site", // Non-English names "ort" }; private static readonly string[] m_vNotes = { "note", "notes", "comment", "comments", "memo", "description", "free form", "freeform", "free text", "freetext", "free" }; private static readonly string[] m_vSubstrTitles = { "title", "system", "account", "entry", "item", "subject", "service", "head" }; private static readonly string[] m_vSubstrUserNames = { "user", "name", "id", "login", "mail" }; private static readonly string[] m_vSubstrPasswords = { "pass", "code", "secret", "key", "pw", "pin" }; private static readonly string[] m_vSubstrUrls = { "url", "link", "host", "address", "hyper ref", "href", "web", "site" }; private static readonly string[] m_vSubstrNotes = { "note", "comment", "memo", "description", "free" }; public static string MapNameToStandardField(string strName, bool bAllowFuzzy) { Debug.Assert(strName != null); if(strName == null) throw new ArgumentNullException("strName"); string strFind = strName.ToLower(); if(Array.IndexOf(m_vTitles, strFind) >= 0) return PwDefs.TitleField; if(Array.IndexOf(m_vUserNames, strFind) >= 0) return PwDefs.UserNameField; if(Array.IndexOf(m_vPasswords, strFind) >= 0) return PwDefs.PasswordField; if(Array.IndexOf(m_vUrls, strFind) >= 0) return PwDefs.UrlField; if(Array.IndexOf(m_vNotes, strFind) >= 0) return PwDefs.NotesField; return (bAllowFuzzy ? MapNameSubstringToStandardField(strName) : string.Empty); } private static string MapNameSubstringToStandardField(string strName) { Debug.Assert(strName != null); if(strName == null) throw new ArgumentNullException("strName"); string strFind = strName.ToLower(); // Check for passwords first, then user names ('vb_login_password') foreach(string strPassword in m_vSubstrPasswords) { if(strFind.Contains(strPassword)) return PwDefs.PasswordField; } foreach(string strUserName in m_vSubstrUserNames) { if(strFind.Contains(strUserName)) return PwDefs.UserNameField; } foreach(string strTitle in m_vSubstrTitles) { if(strFind.Contains(strTitle)) return PwDefs.TitleField; } foreach(string strUrl in m_vSubstrUrls) { if(strFind.Contains(strUrl)) return PwDefs.UrlField; } foreach(string strNotes in m_vSubstrNotes) { if(strFind.Contains(strNotes)) return PwDefs.NotesField; } return string.Empty; } public static void AppendToField(PwEntry pe, string strName, string strValue, PwDatabase pdContext) { AppendToField(pe, strName, strValue, pdContext, null, false); } public static void AppendToField(PwEntry pe, string strName, string strValue, PwDatabase pdContext, string strSeparator, bool bOnlyIfNotDup) { // Default separator must be single-line compatible if(strSeparator == null) strSeparator = ", "; bool bProtect = ((pdContext == null) ? false : pdContext.MemoryProtection.GetProtection(strName)); ProtectedString ps = pe.Strings.Get(strName); string strPrev = ((ps != null) ? ps.ReadString() : null); if(ps != null) bProtect = ps.IsProtected; strValue = (strValue ?? string.Empty); if(string.IsNullOrEmpty(strPrev)) pe.Strings.Set(strName, new ProtectedString(bProtect, strValue)); else if(strValue.Length > 0) { bool bAppend = true; if(bOnlyIfNotDup) bAppend &= (strPrev != strValue); if(bAppend) pe.Strings.Set(strName, new ProtectedString(bProtect, strPrev + strSeparator + strValue)); } } public static bool EntryEquals(PwEntry pe1, PwEntry pe2) { if(pe1.ParentGroup == null) return false; if(pe2.ParentGroup == null) return false; if(pe1.ParentGroup.Name != pe2.ParentGroup.Name) return false; if(pe1.Strings.ReadSafe(PwDefs.TitleField) != pe2.Strings.ReadSafe(PwDefs.TitleField)) { return false; } if(pe1.Strings.ReadSafe(PwDefs.UserNameField) != pe2.Strings.ReadSafe(PwDefs.UserNameField)) { return false; } if(pe1.Strings.ReadSafe(PwDefs.PasswordField) != pe2.Strings.ReadSafe(PwDefs.PasswordField)) { return false; } if(pe1.Strings.ReadSafe(PwDefs.UrlField) != pe2.Strings.ReadSafe(PwDefs.UrlField)) { return false; } if(pe1.Strings.ReadSafe(PwDefs.NotesField) != pe2.Strings.ReadSafe(PwDefs.NotesField)) { return false; } return true; } internal static string GuiSendRetrieve(string strSendPrefix) { if(strSendPrefix.Length > 0) GuiSendKeysPrc(strSendPrefix); return GuiRetrieveDataField(); } private static string GuiRetrieveDataField() { ClipboardUtil.Clear(); Application.DoEvents(); GuiSendKeysPrc(@"^c"); try { if(ClipboardUtil.ContainsText()) return ClipboardUtil.GetText(); } catch(Exception) { Debug.Assert(false); } // Opened by other process return string.Empty; } internal static void GuiSendKeysPrc(string strSend) { if(strSend.Length > 0) SendInputEx.SendKeysWait(strSend, false); Application.DoEvents(); Thread.Sleep(100); Application.DoEvents(); } internal static void GuiSendWaitWindowChange(string strSend) { IntPtr ptrCur = NativeMethods.GetForegroundWindowHandle(); ImportUtil.GuiSendKeysPrc(strSend); int nRound = 0; while(true) { Application.DoEvents(); IntPtr ptr = NativeMethods.GetForegroundWindowHandle(); if(ptr != ptrCur) break; ++nRound; if(nRound > 1000) throw new InvalidOperationException(); Thread.Sleep(50); } Thread.Sleep(100); Application.DoEvents(); } internal static string FixUrl(string strUrl) { strUrl = strUrl.Trim(); if((strUrl.Length > 0) && (strUrl.IndexOf(':') < 0) && (strUrl.IndexOf('@') < 0)) { string strNew = ("http://" + strUrl.ToLower()); if(strUrl.IndexOf('/') < 0) strNew += "/"; return strNew; } return strUrl; } } } keepass2-2.25/KeePass/DataExchange/FileFormatPool.cs0000664000175000017500000001240012261553106022171 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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; using System.Collections.Generic; using System.Text; using System.Diagnostics; using KeePass.DataExchange.Formats; namespace KeePass.DataExchange { public sealed class FileFormatPool : IEnumerable { private List m_vFormats = null; public IEnumerable Importers { get { EnsurePoolInitialized(); List v = new List(); foreach(FileFormatProvider prov in m_vFormats) { if(prov.SupportsImport) v.Add(prov); } return v; } } public IEnumerable Exporters { get { EnsurePoolInitialized(); List v = new List(); foreach(FileFormatProvider prov in m_vFormats) { if(prov.SupportsExport) v.Add(prov); } return v; } } public int Count { get { EnsurePoolInitialized(); return m_vFormats.Count; } } public FileFormatPool() { } IEnumerator IEnumerable.GetEnumerator() { EnsurePoolInitialized(); return m_vFormats.GetEnumerator(); } public IEnumerator GetEnumerator() { EnsurePoolInitialized(); return m_vFormats.GetEnumerator(); } private void EnsurePoolInitialized() { if(m_vFormats != null) return; InitializePool(); } private void InitializePool() { Debug.Assert(m_vFormats == null); m_vFormats = new List(); m_vFormats.Add(new KeePassCsv1x()); m_vFormats.Add(new KeePassKdb1x()); m_vFormats.Add(new KeePassKdb2x()); m_vFormats.Add(new KeePassKdb2xRepair()); m_vFormats.Add(new KeePassXml1x()); m_vFormats.Add(new KeePassXml2x()); m_vFormats.Add(new GenericCsv()); m_vFormats.Add(new OnePwProCsv599()); m_vFormats.Add(new AmpXml250()); m_vFormats.Add(new AnyPwCsv144()); m_vFormats.Add(new CodeWalletTxt605()); m_vFormats.Add(new DashlaneCsv2()); m_vFormats.Add(new DataVaultCsv47()); m_vFormats.Add(new DesktopKnox32()); m_vFormats.Add(new FlexWalletXml17()); m_vFormats.Add(new HandySafeTxt512()); m_vFormats.Add(new HandySafeProXml12()); m_vFormats.Add(new KasperskyPwMgrXml50()); m_vFormats.Add(new KeePassXXml041()); m_vFormats.Add(new LastPassCsv2()); m_vFormats.Add(new NetworkPwMgrCsv4()); m_vFormats.Add(new NortonIdSafeCsv2013()); m_vFormats.Add(new PassKeeper12()); m_vFormats.Add(new PpKeeperHtml270()); m_vFormats.Add(new PwAgentXml234()); m_vFormats.Add(new PwDepotXml26()); m_vFormats.Add(new PwKeeperCsv70()); m_vFormats.Add(new PwMemory2008Xml104()); m_vFormats.Add(new PwPrompterDat12()); m_vFormats.Add(new PwSafeXml302()); m_vFormats.Add(new PwsPlusCsv1007()); m_vFormats.Add(new PwTresorXml100()); m_vFormats.Add(new PVaultTxt14()); m_vFormats.Add(new PinsTxt450()); m_vFormats.Add(new RevelationXml04()); m_vFormats.Add(new RoboFormHtml69()); m_vFormats.Add(new SafeWalletXml3()); m_vFormats.Add(new SecurityTxt12()); m_vFormats.Add(new SplashIdCsv402()); m_vFormats.Add(new SteganosPwManager2007()); m_vFormats.Add(new StickyPwXml50()); m_vFormats.Add(new TurboPwsCsv5()); m_vFormats.Add(new Whisper32Csv116()); m_vFormats.Add(new ZdnPwProTxt314()); m_vFormats.Add(new MozillaBookmarksHtml100()); m_vFormats.Add(new MozillaBookmarksJson100()); m_vFormats.Add(new PwExporterXml105()); m_vFormats.Add(new Spamex20070328()); m_vFormats.Add(new KeePassHtml2x()); m_vFormats.Add(new XslTransform2x()); m_vFormats.Add(new WinFavorites10(false)); m_vFormats.Add(new WinFavorites10(true)); } public void Add(FileFormatProvider prov) { Debug.Assert(prov != null); if(prov == null) throw new ArgumentNullException("prov"); EnsurePoolInitialized(); m_vFormats.Add(prov); } public bool Remove(FileFormatProvider prov) { Debug.Assert(prov != null); if(prov == null) throw new ArgumentNullException("prov"); EnsurePoolInitialized(); return m_vFormats.Remove(prov); } public FileFormatProvider Find(string strFormatName) { if(strFormatName == null) return null; EnsurePoolInitialized(); foreach(FileFormatProvider f in m_vFormats) { if(f.FormatName == strFormatName) return f; } return null; } } } keepass2-2.25/KeePass/DataExchange/CsvStreamReader.cs0000664000175000017500000000667312261553106022360 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using KeePassLib.Utility; namespace KeePass.DataExchange { public sealed class CsvStreamReader { private CharStream m_sChars; private readonly bool m_bAllowUnquoted; [Obsolete] public CsvStreamReader(string strData) { m_sChars = new CharStream(strData); m_bAllowUnquoted = false; } public CsvStreamReader(string strData, bool bAllowUnquoted) { m_sChars = new CharStream(strData); m_bAllowUnquoted = bAllowUnquoted; } public string[] ReadLine() { return (m_bAllowUnquoted ? ReadLineUnquoted() : ReadLineQuoted()); } private string[] ReadLineQuoted() { if(m_sChars.PeekChar() == char.MinValue) return null; List v = new List(); StringBuilder sb = new StringBuilder(); bool bInField = false; while(true) { char ch = m_sChars.ReadChar(); if(ch == char.MinValue) break; if((ch == '\"') && !bInField) bInField = true; else if((ch == '\"') && bInField) { if(m_sChars.PeekChar() == '\"') { m_sChars.ReadChar(); sb.Append('\"'); } else { v.Add(sb.ToString()); if(sb.Length > 0) sb.Remove(0, sb.Length); bInField = false; } } else if(((ch == '\r') || (ch == '\n')) && !bInField) break; else if(bInField) sb.Append(ch); } Debug.Assert(!bInField); Debug.Assert(sb.Length == 0); if(sb.Length > 0) v.Add(sb.ToString()); return v.ToArray(); } private string[] ReadLineUnquoted() { char chFirst = m_sChars.PeekChar(); if(chFirst == char.MinValue) return null; if((chFirst == '\r') || (chFirst == '\n')) { m_sChars.ReadChar(); // Advance return new string[0]; } List v = new List(); StringBuilder sb = new StringBuilder(); bool bInField = false; while(true) { char ch = m_sChars.ReadChar(); if(ch == char.MinValue) break; if((ch == '\"') && !bInField) bInField = true; else if((ch == '\"') && bInField) { if(m_sChars.PeekChar() == '\"') { m_sChars.ReadChar(); sb.Append('\"'); } else bInField = false; } else if(((ch == '\r') || (ch == '\n')) && !bInField) break; else if(bInField) sb.Append(ch); else if(ch == ',') { v.Add(sb.ToString()); if(sb.Length > 0) sb.Remove(0, sb.Length); } else sb.Append(ch); } Debug.Assert(!bInField); v.Add(sb.ToString()); return v.ToArray(); } } } keepass2-2.25/KeePass/DataExchange/GxiImporter.cs0000664000175000017500000002731612261553106021574 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml; using System.Xml.XPath; using System.IO; using System.Diagnostics; using KeePass.Resources; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange { public static class GxiImporter { private sealed class GxiContext // Immutable { private PwDatabase m_pd; public PwDatabase Database { get { return m_pd; } } private PwGroup m_pg; public PwGroup Group { get { return m_pg; } } private PwEntry m_pe; public PwEntry Entry { get { return m_pe; } } private Dictionary m_dStringKeyRepl; public Dictionary StringKeyRepl { get { return m_dStringKeyRepl; } } private Dictionary m_dStringValueRepl; public Dictionary StringValueRepl { get { return m_dStringValueRepl; } } private Dictionary m_dStringKeyRepl2; public Dictionary StringKeyRepl2 { get { return m_dStringKeyRepl2; } } private Dictionary m_dStringValueRepl2; public Dictionary StringValueRepl2 { get { return m_dStringValueRepl2; } } private Dictionary m_dBinaryKeyRepl; public Dictionary BinaryKeyRepl { get { return m_dBinaryKeyRepl; } } public GxiContext(GxiProfile p, PwDatabase pd, PwGroup pg, PwEntry pe) { m_pd = pd; m_pg = pg; m_pe = pe; m_dStringKeyRepl = GxiImporter.ParseRepl(p.StringKeyRepl); m_dStringValueRepl = GxiImporter.ParseRepl(p.StringValueRepl); m_dStringKeyRepl2 = GxiImporter.ParseRepl(p.StringKeyRepl2); m_dStringValueRepl2 = GxiImporter.ParseRepl(p.StringValueRepl2); m_dBinaryKeyRepl = GxiImporter.ParseRepl(p.BinaryKeyRepl); } public GxiContext ModifyWith(PwGroup pg) { GxiContext c = (GxiContext)MemberwiseClone(); Debug.Assert(object.ReferenceEquals(c.m_dStringKeyRepl, m_dStringKeyRepl)); c.m_pg = pg; return c; } public GxiContext ModifyWith(PwEntry pe) { GxiContext c = (GxiContext)MemberwiseClone(); Debug.Assert(object.ReferenceEquals(c.m_dStringKeyRepl, m_dStringKeyRepl)); c.m_pe = pe; return c; } } private delegate void ImportObjectDelegate(XPathNavigator xpRoot, GxiProfile p, GxiContext c); public static void Import(PwGroup pgStorage, Stream s, GxiProfile p, PwDatabase pdContext, IStatusLogger sl) { if(pgStorage == null) throw new ArgumentNullException("pgStorage"); if(s == null) throw new ArgumentNullException("s"); if(p == null) throw new ArgumentNullException("p"); if(pdContext == null) throw new ArgumentNullException("pdContext"); // sl may be null // Import into virtual group first, in order to realize // an all-or-nothing import PwGroup pgVirt = new PwGroup(true, true); try { ImportPriv(pgVirt, s, p, pdContext, sl); } finally { s.Close(); } foreach(PwGroup pg in pgVirt.Groups) pgStorage.AddGroup(pg, true); foreach(PwEntry pe in pgVirt.Entries) pgStorage.AddEntry(pe, true); } private static void ImportPriv(PwGroup pgStorage, Stream s, GxiProfile p, PwDatabase pdContext, IStatusLogger sl) { StrEncodingInfo sei = StrUtil.GetEncoding(p.Encoding); StreamReader srRaw; if((sei != null) && (sei.Encoding != null)) srRaw = new StreamReader(s, sei.Encoding, true); else srRaw = new StreamReader(s, true); string strDoc = srRaw.ReadToEnd(); srRaw.Close(); strDoc = Preprocess(strDoc, p); StringReader srDoc = new StringReader(strDoc); XPathDocument xd = new XPathDocument(srDoc); GxiContext c = new GxiContext(p, pdContext, pgStorage, null); XPathNavigator xpDoc = xd.CreateNavigator(); ImportObject(xpDoc, p, p.RootXPath, "/*", GxiImporter.ImportRoot, c); srDoc.Close(); } private static string Preprocess(string strDoc, GxiProfile p) { string str = strDoc; if(str == null) { Debug.Assert(false); return string.Empty; } if(p.RemoveInvalidChars) str = StrUtil.SafeXmlString(str); if(p.DecodeHtmlEntities) str = XmlUtil.DecodeHtmlEntities(str); return str; } private static XPathNodeIterator QueryNodes(XPathNavigator xpBase, string strXPath, string strAltXPath) { if(xpBase == null) { Debug.Assert(false); return null; } string strX = (string.IsNullOrEmpty(strXPath) ? strAltXPath : strXPath); if(string.IsNullOrEmpty(strX)) return null; return xpBase.Select(strX); } private static string QueryValue(XPathNavigator xpBase, string strXPath, bool bQueryName) { if(xpBase == null) { Debug.Assert(false); return null; } if(string.IsNullOrEmpty(strXPath)) return null; XPathNavigator xp = xpBase.SelectSingleNode(strXPath); if(xp == null) return null; return (bQueryName ? xp.Name : xp.Value); } private static string QueryValueSafe(XPathNavigator xpBase, string strXPath) { return (QueryValue(xpBase, strXPath, false) ?? string.Empty); } // private static string QueryValueSafe(XPathNavigator xpBase, string strXPath, // bool bQueryName) // { // return (QueryValue(xpBase, strXPath, bQueryName) ?? string.Empty); // } private static void ImportObject(XPathNavigator xpBase, GxiProfile p, string strXPath, string strAltXPath, ImportObjectDelegate f, GxiContext c) { if(f == null) { Debug.Assert(false); return; } XPathNodeIterator xi = QueryNodes(xpBase, strXPath, strAltXPath); if(xi == null) return; // No assert foreach(XPathNavigator xp in xi) { f(xp, p, c); } } private static void ImportRoot(XPathNavigator xpBase, GxiProfile p, GxiContext c) { ImportObject(xpBase, p, p.GroupXPath, null, GxiImporter.ImportGroup, c); if(p.EntriesInRoot) ImportObject(xpBase, p, p.EntryXPath, null, GxiImporter.ImportEntry, c); } private static void ImportGroup(XPathNavigator xpBase, GxiProfile p, GxiContext c) { PwGroup pg = new PwGroup(true, true); c.Group.AddGroup(pg, true); GxiContext cSub = c.ModifyWith(pg); pg.Name = QueryValueSafe(xpBase, p.GroupNameXPath); if(pg.Name.Length == 0) pg.Name = KPRes.Group; if(p.GroupsInGroup) ImportObject(xpBase, p, p.GroupXPath, null, GxiImporter.ImportGroup, cSub); if(p.EntriesInGroup) ImportObject(xpBase, p, p.EntryXPath, null, GxiImporter.ImportEntry, cSub); } private static void ImportEntry(XPathNavigator xpBase, GxiProfile p, GxiContext c) { PwEntry pe = new PwEntry(true, true); PwGroup pg = c.Group; // Not the database root group string strGroupPath = QueryValueSafe(xpBase, p.EntryGroupXPath); string strGroupPath2 = QueryValueSafe(xpBase, p.EntryGroupXPath2); if((strGroupPath.Length > 0) && (strGroupPath2.Length > 0)) { Debug.Assert(p.EntryGroupSep.Length > 0); strGroupPath = strGroupPath + p.EntryGroupSep + strGroupPath2; } if(strGroupPath.Length > 0) { if(p.EntryGroupSep.Length == 0) pg = pg.FindCreateGroup(strGroupPath, true); else pg = pg.FindCreateSubTree(strGroupPath, new string[1]{ p.EntryGroupSep }, true); } pg.AddEntry(pe, true); GxiContext cSub = c.ModifyWith(pe); ImportObject(xpBase, p, p.StringKvpXPath, null, GxiImporter.ImportStringKvp, cSub); ImportObject(xpBase, p, p.StringKvpXPath2, null, GxiImporter.ImportStringKvp2, cSub); ImportObject(xpBase, p, p.BinaryKvpXPath, null, GxiImporter.ImportBinaryKvp, cSub); } private static void ImportStringKvp(XPathNavigator xpBase, GxiProfile p, GxiContext c) { ImportStringKvpEx(xpBase, p, c, true); } private static void ImportStringKvp2(XPathNavigator xpBase, GxiProfile p, GxiContext c) { ImportStringKvpEx(xpBase, p, c, false); } private static void ImportStringKvpEx(XPathNavigator xpBase, GxiProfile p, GxiContext c, bool bFirst) { string strKey = QueryValue(xpBase, (bFirst ? p.StringKeyXPath : p.StringKeyXPath2), (bFirst ? p.StringKeyUseName : p.StringKeyUseName2)); if(string.IsNullOrEmpty(strKey)) return; strKey = ApplyRepl(strKey, (bFirst ? c.StringKeyRepl : c.StringKeyRepl2)); if(strKey.Length == 0) return; if(p.StringKeyToStd) { string strMapped = ImportUtil.MapNameToStandardField(strKey, p.StringKeyToStdFuzzy); if(!string.IsNullOrEmpty(strMapped)) strKey = strMapped; } string strValue = QueryValueSafe(xpBase, (bFirst ? p.StringValueXPath : p.StringValueXPath2)); strValue = ApplyRepl(strValue, (bFirst ? c.StringValueRepl : c.StringValueRepl2)); ImportUtil.AppendToField(c.Entry, strKey, strValue, c.Database); } private static void ImportBinaryKvp(XPathNavigator xpBase, GxiProfile p, GxiContext c) { string strKey = QueryValue(xpBase, p.BinaryKeyXPath, p.BinaryKeyUseName); if(string.IsNullOrEmpty(strKey)) return; strKey = ApplyRepl(strKey, c.BinaryKeyRepl); if(strKey.Length == 0) return; string strValue = QueryValueSafe(xpBase, p.BinaryValueXPath); byte[] pbValue = null; if(p.BinaryValueEncoding == GxiBinaryEncoding.Base64) pbValue = Convert.FromBase64String(strValue); else if(p.BinaryValueEncoding == GxiBinaryEncoding.Hex) pbValue = MemUtil.HexStringToByteArray(strValue); else { Debug.Assert(false); } if(pbValue == null) return; c.Entry.Binaries.Set(strKey, new ProtectedBinary(false, pbValue)); } internal static Dictionary ParseRepl(string str) { Dictionary d = new Dictionary(); if(str == null) { Debug.Assert(false); return d; } CharStream cs = new CharStream(str + ",,"); StringBuilder sb = new StringBuilder(); string strKey = string.Empty; bool bValue = false; while(true) { char ch = cs.ReadChar(); if(ch == char.MinValue) break; if(ch == ',') { if(!bValue) { strKey = sb.ToString(); sb.Remove(0, sb.Length); } if(strKey.Length > 0) d[strKey] = sb.ToString(); sb.Remove(0, sb.Length); bValue = false; } else if(ch == '>') { strKey = sb.ToString(); sb.Remove(0, sb.Length); bValue = true; } else if(ch == '\\') { char chSub = cs.ReadChar(); if(chSub == 'n') sb.Append('\n'); else if(chSub == 'r') sb.Append('\r'); else if(chSub == 't') sb.Append('\t'); else sb.Append(chSub); } else sb.Append(ch); } return d; } private static string ApplyRepl(string str, Dictionary dRepl) { if(str == null) { Debug.Assert(false); return string.Empty; } if(dRepl == null) { Debug.Assert(false); return str; } string strOut; if(dRepl.TryGetValue(str, out strOut)) return strOut; return str; } } } keepass2-2.25/KeePass/DataExchange/KdbManager.cs0000664000175000017500000011355312261553106021315 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 PocketPC || Smartphone || WindowsCE #undef KDB_ANSI #else // If compiling for the ANSI version of KeePassLibC, define KDB_ANSI. // If compiling for the Unicode version of KeePassLibC, do not define KDB_ANSI. #define KDB_ANSI #endif using System; using System.Text; using System.Runtime.InteropServices; using System.Diagnostics; namespace KeePass.DataExchange { /// /// Structure containing information about a password group. This structure /// doesn't contain any information about the entries stored in this group. /// #if PocketPC || Smartphone || WindowsCE [StructLayout(LayoutKind.Sequential)] #else [StructLayout(LayoutKind.Sequential, Pack = 1)] #endif public struct KdbGroup { /// /// The GroupID of the group. /// [MarshalAs(UnmanagedType.U4)] public UInt32 GroupId; /// /// The ImageID of the group. /// [MarshalAs(UnmanagedType.U4)] public UInt32 ImageId; /// /// The Name of the group. /// #if KDB_ANSI [MarshalAs(UnmanagedType.LPStr)] public string Name; #else [MarshalAs(UnmanagedType.LPWStr)] public string Name; #endif /// /// The creation time of the group. /// public KdbTime CreationTime; /// /// The last modification time of the group. /// public KdbTime LastModificationTime; /// /// The last access time of the group. /// public KdbTime LastAccessTime; /// /// The expiry time of the group. /// public KdbTime ExpirationTime; /// /// Indentation level of the group. /// [MarshalAs(UnmanagedType.U2)] public UInt16 Level; #if VPF_ALIGN /// /// Dummy entry for alignment purposes. /// [MarshalAs(UnmanagedType.U2)] public UInt16 Dummy; #endif /// /// Flags of the group (see KdbGroupFlags). /// [MarshalAs(UnmanagedType.U4)] public UInt32 Flags; } /// /// Password group flags. /// [Flags] public enum KdbGroupFlags { /// /// No special flags. /// None = 0, /// /// The group is expanded. /// Expanded = 1 } /// /// Structure containing information about a password entry. /// #if PocketPC || Smartphone || WindowsCE [StructLayout(LayoutKind.Sequential)] #else [StructLayout(LayoutKind.Sequential, Pack = 1)] #endif public struct KdbEntry { /// /// The UUID of the entry. /// public KdbUuid Uuid; /// /// The group ID of the enty. /// [MarshalAs(UnmanagedType.U4)] public UInt32 GroupId; /// /// The image ID of the entry. /// [MarshalAs(UnmanagedType.U4)] public UInt32 ImageId; #if KDB_ANSI /// /// The title of the entry. /// [MarshalAs(UnmanagedType.LPStr)] public string Title; /// /// The URL of the entry. /// [MarshalAs(UnmanagedType.LPStr)] public string Url; /// /// The user name of the entry. /// [MarshalAs(UnmanagedType.LPStr)] public string UserName; /// /// The password length of the entry. /// [MarshalAs(UnmanagedType.U4)] public UInt32 PasswordLength; /// /// The password of the entry. /// [MarshalAs(UnmanagedType.LPStr)] public string Password; /// /// The notes field of the entry. /// [MarshalAs(UnmanagedType.LPStr)] public string Additional; #else /// /// The title of the entry. /// [MarshalAs(UnmanagedType.LPWStr)] public string Title; /// /// The URL of the entry. /// [MarshalAs(UnmanagedType.LPWStr)] public string Url; /// /// The user name of the entry. /// [MarshalAs(UnmanagedType.LPWStr)] public string UserName; /// /// The password length of the entry. /// [MarshalAs(UnmanagedType.U4)] public UInt32 PasswordLength; /// /// The password of the entry. /// [MarshalAs(UnmanagedType.LPWStr)] public string Password; /// /// The notes field of the entry. /// [MarshalAs(UnmanagedType.LPWStr)] public string Additional; #endif /// /// The creation time of the entry. /// public KdbTime CreationTime; /// /// The last modification time of the entry. /// public KdbTime LastModificationTime; /// /// The last access time of the entry. /// public KdbTime LastAccessTime; /// /// The expiration time of the entry. /// public KdbTime ExpirationTime; /// /// The description of the binary attachment. /// #if KDB_ANSI [MarshalAs(UnmanagedType.LPStr)] public string BinaryDescription; #else [MarshalAs(UnmanagedType.LPWStr)] public string BinaryDescription; #endif /// /// The attachment of the entry. /// public IntPtr BinaryData; /// /// The length of the attachment. /// [MarshalAs(UnmanagedType.U4)] public UInt32 BinaryDataLength; } /// /// Structure containing UUID bytes (16 bytes). /// #if PocketPC || Smartphone || WindowsCE [StructLayout(LayoutKind.Sequential)] #else [StructLayout(LayoutKind.Sequential, Pack = 1)] #endif public struct KdbUuid { #pragma warning disable 1591 // Missing XML comments warning public Byte V0; public Byte V1; public Byte V2; public Byte V3; public Byte V4; public Byte V5; public Byte V6; public Byte V7; public Byte V8; public Byte V9; public Byte VA; public Byte VB; public Byte VC; public Byte VD; public Byte VE; public Byte VF; #pragma warning restore 1591 // Missing XML comments warning /// /// Convert UUID to a byte array of length 16. /// /// Byte array (16 bytes). public byte[] ToByteArray() { return new byte[]{ this.V0, this.V1, this.V2, this.V3, this.V4, this.V5, this.V6, this.V7, this.V8, this.V9, this.VA, this.VB, this.VC, this.VD, this.VE, this.VF }; } /// /// Set the UUID using an array of 16 bytes. /// /// Bytes to set the UUID to. public void Set(byte[] pb) { Debug.Assert((pb != null) && (pb.Length == 16)); if(pb == null) throw new ArgumentNullException("pb"); if(pb.Length != 16) throw new ArgumentException(); this.V0 = pb[0]; this.V1 = pb[1]; this.V2 = pb[2]; this.V3 = pb[3]; this.V4 = pb[4]; this.V5 = pb[5]; this.V6 = pb[6]; this.V7 = pb[7]; this.V8 = pb[8]; this.V9 = pb[9]; this.VA = pb[10]; this.VB = pb[11]; this.VC = pb[12]; this.VD = pb[13]; this.VE = pb[14]; this.VF = pb[15]; } } /// /// Structure containing time information in a compact, but still easily /// accessible form. /// #if PocketPC || Smartphone || WindowsCE [StructLayout(LayoutKind.Sequential)] #else [StructLayout(LayoutKind.Sequential, Pack = 1)] #endif public struct KdbTime { #pragma warning disable 1591 // Missing XML comments warning [MarshalAs(UnmanagedType.U2)] public UInt16 Year; [MarshalAs(UnmanagedType.U1)] public Byte Month; [MarshalAs(UnmanagedType.U1)] public Byte Day; [MarshalAs(UnmanagedType.U1)] public Byte Hour; [MarshalAs(UnmanagedType.U1)] public Byte Minute; [MarshalAs(UnmanagedType.U1)] public Byte Second; #pragma warning restore 1591 // Missing XML comments warning #if VPF_ALIGN /// /// Dummy entry for alignment purposes. /// [MarshalAs(UnmanagedType.U1)] public Byte Dummy; #endif /// /// Construct a KdbTime with initial values. /// /// Year. /// Month. /// Day. /// Hour. /// Minute. /// Second. public KdbTime(UInt16 uYear, Byte uMonth, Byte uDay, Byte uHour, Byte uMinute, Byte uSecond) { this.Year = uYear; this.Month = uMonth; this.Day = uDay; this.Hour = uHour; this.Minute = uMinute; this.Second = uSecond; #if VPF_ALIGN this.Dummy = 0; #endif } /// /// Convert the current KdbTime object to a DateTime object. /// /// public DateTime ToDateTime() { if((this.Year == 0) || (this.Month == 0) || (this.Day == 0)) return DateTime.Now; return new DateTime((int)this.Year, (int)this.Month, (int)this.Day, (int)this.Hour, (int)this.Minute, (int)this.Second); } /// /// Copy data from a DateTime object to the current KdbTime object. /// /// Data source. public void Set(DateTime dt) { this.Year = (UInt16)dt.Year; this.Month = (Byte)dt.Month; this.Day = (Byte)dt.Day; this.Hour = (Byte)dt.Hour; this.Minute = (Byte)dt.Minute; this.Second = (Byte)dt.Second; } /// /// A KdbTime element that is used to indicate the never expire time. /// public static readonly KdbTime NeverExpireTime = new KdbTime(2999, 12, 28, 23, 59, 59); } /// /// Error codes for various functions (OpenDatabase, etc.). /// public enum KdbErrorCode { /// /// Unknown error occurred. /// Unknown = 0, /// /// Successfull function call. /// Success, /// /// Invalid parameters were given. /// InvalidParam, /// /// Not enough memory to perform requested operation. /// NotEnoughMemory, /// /// Invalid key was supplied. /// InvalidKey, /// /// The file could not be read. /// NoFileAccessRead, /// /// The file could not be written. /// NoFileAccessWrite, /// /// A file read error occurred. /// FileErrorRead, /// /// A file write error occurred. /// FileErrorWrite, /// /// Invalid random source was given. /// InvalidRandomSource, /// /// Invalid file structure was detected. /// InvalidFileStructure, /// /// Cryptographic error occurred. /// CryptoError, /// /// Invalid file size was given/detected. /// InvalidFileSize, /// /// Invalid file signature was detected. /// InvalidFileSignature, /// /// Invalid file header was detected. /// InvalidFileHeader, /// /// The keyfile could not be read. /// NoFileAccessReadKey } /// /// Manager class for KDB files. It can load/save databases, add/change/delete /// groups and entries, check for KeePassLibC library existence and version, etc. /// public sealed class KdbManager { private const string DllFile32 = "KeePassLibC32.dll"; private const string DllFile64 = "KeePassLibC64.dll"; private static readonly bool m_bX64 = (Marshal.SizeOf(typeof(IntPtr)) == 8); #if KDB_ANSI private const CharSet DllCharSet = CharSet.Ansi; #else private const CharSet DllCharSet = CharSet.Unicode; #endif private static bool m_bFirstInstance = true; private IntPtr m_pManager = IntPtr.Zero; [DllImport(DllFile32, EntryPoint = "GetKeePassVersion")] private static extern UInt32 GetKeePassVersion32(); [DllImport(DllFile64, EntryPoint = "GetKeePassVersion")] private static extern UInt32 GetKeePassVersion64(); /// /// Get the KeePass version, which the KeePassLibC library supports. /// public static UInt32 KeePassVersion { get { if(m_bX64) return GetKeePassVersion64(); else return GetKeePassVersion32(); } } [DllImport(DllFile32, CharSet = DllCharSet, EntryPoint = "GetKeePassVersionString")] private static extern IntPtr GetKeePassVersionString32(); [DllImport(DllFile64, CharSet = DllCharSet, EntryPoint = "GetKeePassVersionString")] private static extern IntPtr GetKeePassVersionString64(); /// /// Get the KeePass version, which the KeePassLibC library supports /// (the version is returned as a displayable string, if you need to /// compare versions: use the KeePassVersion property). /// public static string KeePassVersionString { #if KDB_ANSI get { if(m_bX64) return Marshal.PtrToStringAnsi(GetKeePassVersionString64()); else return Marshal.PtrToStringAnsi(GetKeePassVersionString32()); } #else get { if(m_bX64) return Marshal.PtrToStringUni(GetKeePassVersionString64()); else return Marshal.PtrToStringUni(GetKeePassVersionString32()); } #endif } [DllImport(DllFile32, EntryPoint = "GetLibraryBuild")] private static extern UInt32 GetLibraryBuild32(); [DllImport(DllFile64, EntryPoint = "GetLibraryBuild")] private static extern UInt32 GetLibraryBuild64(); /// /// Get the library build version. This version has nothing to do with /// the supported KeePass version (see KeePassVersion property). /// public static UInt32 LibraryBuild { get { if(m_bX64) return GetLibraryBuild64(); else return GetLibraryBuild32(); } } [DllImport(DllFile32, EntryPoint = "GetNumberOfEntries")] private static extern UInt32 GetNumberOfEntries32(IntPtr pMgr); [DllImport(DllFile64, EntryPoint = "GetNumberOfEntries")] private static extern UInt32 GetNumberOfEntries64(IntPtr pMgr); /// /// Get the number of entries in this manager instance. /// public UInt32 EntryCount { get { if(m_bX64) return GetNumberOfEntries64(m_pManager); else return GetNumberOfEntries32(m_pManager); } } [DllImport(DllFile32, EntryPoint = "GetNumberOfGroups")] private static extern UInt32 GetNumberOfGroups32(IntPtr pMgr); [DllImport(DllFile64, EntryPoint = "GetNumberOfGroups")] private static extern UInt32 GetNumberOfGroups64(IntPtr pMgr); /// /// Get the number of groups in this manager instance. /// public UInt32 GroupCount { get { if(m_bX64) return GetNumberOfGroups64(m_pManager); else return GetNumberOfGroups32(m_pManager); } } [DllImport(DllFile32, EntryPoint = "GetKeyEncRounds")] private static extern UInt32 GetKeyEncRounds32(IntPtr pMgr); [DllImport(DllFile64, EntryPoint = "GetKeyEncRounds")] private static extern UInt32 GetKeyEncRounds64(IntPtr pMgr); [DllImport(DllFile32, EntryPoint = "SetKeyEncRounds")] private static extern void SetKeyEncRounds32(IntPtr pMgr, UInt32 dwRounds); [DllImport(DllFile64, EntryPoint = "SetKeyEncRounds")] private static extern void SetKeyEncRounds64(IntPtr pMgr, UInt32 dwRounds); /// /// Get or set the number of key transformation rounds (in order to /// make key-searching attacks harder). /// public UInt32 KeyTransformationRounds { get { if(m_bX64) return GetKeyEncRounds64(m_pManager); else return GetKeyEncRounds32(m_pManager); } set { if(m_bX64) SetKeyEncRounds64(m_pManager, value); else SetKeyEncRounds32(m_pManager, value); } } [DllImport(DllFile32, EntryPoint = "InitManager")] private static extern void InitManager32(out IntPtr ppMgr, [MarshalAs(UnmanagedType.Bool)] bool bFirstInstance); [DllImport(DllFile64, EntryPoint = "InitManager")] private static extern void InitManager64(out IntPtr ppMgr, [MarshalAs(UnmanagedType.Bool)] bool bFirstInstance); [DllImport(DllFile32, EntryPoint = "NewDatabase")] private static extern void NewDatabase32(IntPtr pMgr); [DllImport(DllFile64, EntryPoint = "NewDatabase")] private static extern void NewDatabase64(IntPtr pMgr); /// /// Construct a new KDB manager instance. /// public KdbManager() { if(m_bX64 == false) // Only check 32-bit structures { #if VPF_ALIGN bool bAligned = true; #else bool bAligned = false; #endif // Static structure layout assertions int nExpectedSize = (bAligned ? 52 : 46); KdbGroup g = new KdbGroup(); Debug.Assert(Marshal.SizeOf(g) == nExpectedSize); if(Marshal.SizeOf(g) != nExpectedSize) throw new FormatException("SizeOf(KdbGroup) invalid!"); nExpectedSize = (bAligned ? 92 : 88); KdbEntry e = new KdbEntry(); Debug.Assert(Marshal.SizeOf(e) == nExpectedSize); if(Marshal.SizeOf(e) != nExpectedSize) throw new FormatException("SizeOf(KdbEntry) invalid!"); KdbUuid u = new KdbUuid(); Debug.Assert(Marshal.SizeOf(u) == 16); if(Marshal.SizeOf(u) != 16) throw new FormatException("SizeOf(KdbUuid) invalid!"); nExpectedSize = (bAligned ? 8 : 7); KdbTime t = new KdbTime(); Debug.Assert(Marshal.SizeOf(t) == nExpectedSize); if(Marshal.SizeOf(t) != nExpectedSize) throw new FormatException("SizeOf(KdbTime) invalid!"); } if(m_bX64) KdbManager.InitManager64(out m_pManager, m_bFirstInstance); else KdbManager.InitManager32(out m_pManager, m_bFirstInstance); m_bFirstInstance = false; if(m_pManager == IntPtr.Zero) throw new InvalidOperationException("Failed to initialize manager! DLL installed?"); if(m_bX64) KdbManager.NewDatabase64(m_pManager); else KdbManager.NewDatabase32(m_pManager); } /// /// Destructor for KdbManager instance. /// ~KdbManager() { this.Unload(); } [DllImport(DllFile32, EntryPoint = "DeleteManager")] private static extern void DeleteManager32(IntPtr pMgr); [DllImport(DllFile64, EntryPoint = "DeleteManager")] private static extern void DeleteManager64(IntPtr pMgr); /// /// This function clears up all memory associated with the current /// manager instance. You should call this function shortly before /// the object is destroyed (i.e. when you finished working with it). /// public void Unload() { if(m_pManager != IntPtr.Zero) { if(m_bX64) KdbManager.DeleteManager64(m_pManager); else KdbManager.DeleteManager32(m_pManager); m_pManager = IntPtr.Zero; } } [DllImport(DllFile32, CharSet = DllCharSet, EntryPoint = "SetMasterKey")] private static extern Int32 SetMasterKey32(IntPtr pMgr, string pszMasterKey, [MarshalAs(UnmanagedType.Bool)] bool bDiskDrive, string pszSecondKey, IntPtr pARI, [MarshalAs(UnmanagedType.Bool)] bool bOverwrite); [DllImport(DllFile64, CharSet = DllCharSet, EntryPoint = "SetMasterKey")] private static extern Int32 SetMasterKey64(IntPtr pMgr, string pszMasterKey, [MarshalAs(UnmanagedType.Bool)] bool bDiskDrive, string pszSecondKey, IntPtr pARI, [MarshalAs(UnmanagedType.Bool)] bool bOverwrite); /// /// Set the master key, which will be used when you call the /// OpenDatabase or SaveDatabase functions. /// /// Master password or path to key file. Must not be null. /// Indicates if a key file is used. /// Path to the key file when both master password /// and key file are used. /// Random source interface. Set this to IntPtr.Zero /// if you want to open a KDB file normally. If you want to create a key file, /// pARI must point to a CNewRandomInterface (see KeePass 1.x /// source code). /// Indicates if the target file should be overwritten when /// creating a new key file. /// Error code (see KdbErrorCode). public KdbErrorCode SetMasterKey(string strMasterKey, bool bDiskDrive, string strSecondKey, IntPtr pARI, bool bOverwrite) { Debug.Assert(strMasterKey != null); if(strMasterKey == null) throw new ArgumentNullException("strMasterKey"); if(m_bX64) return (KdbErrorCode)KdbManager.SetMasterKey64(m_pManager, strMasterKey, bDiskDrive, strSecondKey, pARI, bOverwrite); else return (KdbErrorCode)KdbManager.SetMasterKey32(m_pManager, strMasterKey, bDiskDrive, strSecondKey, pARI, bOverwrite); } [DllImport(DllFile32, CharSet = DllCharSet, EntryPoint = "GetNumberOfItemsInGroup")] private static extern UInt32 GetNumberOfItemsInGroup32(IntPtr pMgr, string pszGroup); [DllImport(DllFile64, CharSet = DllCharSet, EntryPoint = "GetNumberOfItemsInGroup")] private static extern UInt32 GetNumberOfItemsInGroup64(IntPtr pMgr, string pszGroup); /// /// Get the number of entries in a group. /// /// Group name, which identifies the group. Note /// that multiple groups can have the same name, in this case you'll need to /// use the other counting function which uses group IDs. /// Number of entries in the specified group. public UInt32 GetNumberOfEntriesInGroup(string strGroupName) { Debug.Assert(strGroupName != null); if(strGroupName == null) throw new ArgumentNullException("strGroupName"); if(m_bX64) return KdbManager.GetNumberOfItemsInGroup64(m_pManager, strGroupName); else return KdbManager.GetNumberOfItemsInGroup32(m_pManager, strGroupName); } [DllImport(DllFile32, EntryPoint = "GetNumberOfItemsInGroupN")] private static extern UInt32 GetNumberOfItemsInGroupN32(IntPtr pMgr, UInt32 idGroup); [DllImport(DllFile64, EntryPoint = "GetNumberOfItemsInGroupN")] private static extern UInt32 GetNumberOfItemsInGroupN64(IntPtr pMgr, UInt32 idGroup); /// /// Get the number of entries in a group. /// /// Group ID. /// Number of entries in the specified group. public UInt32 GetNumberOfEntriesInGroup(UInt32 uGroupId) { Debug.Assert((uGroupId != 0) && (uGroupId != UInt32.MaxValue)); if((uGroupId == 0) || (uGroupId == UInt32.MaxValue)) throw new ArgumentException("Invalid group ID!"); if(m_bX64) return KdbManager.GetNumberOfItemsInGroupN64(m_pManager, uGroupId); else return KdbManager.GetNumberOfItemsInGroupN32(m_pManager, uGroupId); } [DllImport(DllFile32, EntryPoint = "LockEntryPassword")] private static extern IntPtr LockEntryPassword32(IntPtr pMgr, IntPtr pEntry); [DllImport(DllFile64, EntryPoint = "LockEntryPassword")] private static extern IntPtr LockEntryPassword64(IntPtr pMgr, IntPtr pEntry); [DllImport(DllFile32, EntryPoint = "UnlockEntryPassword")] private static extern IntPtr UnlockEntryPassword32(IntPtr pMgr, IntPtr pEntry); [DllImport(DllFile64, EntryPoint = "UnlockEntryPassword")] private static extern IntPtr UnlockEntryPassword64(IntPtr pMgr, IntPtr pEntry); [DllImport(DllFile32, EntryPoint = "GetEntry")] private static extern IntPtr GetEntry32(IntPtr pMgr, UInt32 dwIndex); [DllImport(DllFile64, EntryPoint = "GetEntry")] private static extern IntPtr GetEntry64(IntPtr pMgr, UInt32 dwIndex); /// /// Get an entry. /// /// Index of the entry. This index must be valid, otherwise /// an ArgumentOutOfRangeException is thrown. /// The requested entry. Note that any modifications to this /// structure won't affect the internal data structures of the manager. public KdbEntry GetEntry(uint uIndex) { Debug.Assert(uIndex < this.EntryCount); IntPtr p; if(m_bX64) p = KdbManager.GetEntry64(m_pManager, uIndex); else p = KdbManager.GetEntry32(m_pManager, uIndex); if(p == IntPtr.Zero) throw new ArgumentOutOfRangeException("uIndex"); if(m_bX64) KdbManager.UnlockEntryPassword64(m_pManager, p); else KdbManager.UnlockEntryPassword32(m_pManager, p); KdbEntry kdbEntry = (KdbEntry)Marshal.PtrToStructure(p, typeof(KdbEntry)); if(m_bX64) KdbManager.LockEntryPassword64(m_pManager, p); else KdbManager.LockEntryPassword32(m_pManager, p); return kdbEntry; } [DllImport(DllFile32, EntryPoint = "GetEntryByGroup")] private static extern IntPtr GetEntryByGroup32(IntPtr pMgr, UInt32 idGroup, UInt32 dwIndex); [DllImport(DllFile64, EntryPoint = "GetEntryByGroup")] private static extern IntPtr GetEntryByGroup64(IntPtr pMgr, UInt32 idGroup, UInt32 dwIndex); /// /// Get an entry in a specific group. /// /// Index of the entry in the group. This index must /// be valid, otherwise an ArgumentOutOfRangeException is thrown. /// ID of the group containing the entry. /// The requested entry. Note that any modifications to this /// structure won't affect the internal data structures of the manager. public KdbEntry GetEntryByGroup(UInt32 uGroupId, UInt32 uIndex) { Debug.Assert((uGroupId != 0) && (uGroupId != UInt32.MaxValue)); if((uGroupId == 0) || (uGroupId == UInt32.MaxValue)) throw new ArgumentException("Invalid group ID!"); Debug.Assert(uIndex < this.EntryCount); IntPtr p; if(m_bX64) p = GetEntryByGroup64(m_pManager, uGroupId, uIndex); else p = GetEntryByGroup32(m_pManager, uGroupId, uIndex); if(p == IntPtr.Zero) throw new ArgumentOutOfRangeException(); if(m_bX64) KdbManager.UnlockEntryPassword64(m_pManager, p); else KdbManager.UnlockEntryPassword32(m_pManager, p); KdbEntry kdbEntry = (KdbEntry)Marshal.PtrToStructure(p, typeof(KdbEntry)); if(m_bX64) KdbManager.LockEntryPassword64(m_pManager, p); else KdbManager.LockEntryPassword32(m_pManager, p); return kdbEntry; } [DllImport(DllFile32, EntryPoint = "GetGroup")] private static extern IntPtr GetGroup32(IntPtr pMgr, UInt32 dwIndex); [DllImport(DllFile64, EntryPoint = "GetGroup")] private static extern IntPtr GetGroup64(IntPtr pMgr, UInt32 dwIndex); /// /// Get a group. /// /// Index of the group. Must be valid, otherwise an /// ArgumentOutOfRangeException is thrown. /// Group structure. public KdbGroup GetGroup(UInt32 uIndex) { Debug.Assert(uIndex < this.GroupCount); IntPtr p; if(m_bX64) p = KdbManager.GetGroup64(m_pManager, uIndex); else p = KdbManager.GetGroup32(m_pManager, uIndex); if(p == IntPtr.Zero) throw new ArgumentOutOfRangeException("uIndex"); return (KdbGroup)Marshal.PtrToStructure(p, typeof(KdbGroup)); } [DllImport(DllFile32, EntryPoint = "GetGroupById")] private static extern IntPtr GetGroupById32(IntPtr pMgr, UInt32 idGroup); [DllImport(DllFile64, EntryPoint = "GetGroupById")] private static extern IntPtr GetGroupById64(IntPtr pMgr, UInt32 idGroup); /// /// Get a group via the GroupID. /// /// ID of the group. /// Group structure. public KdbGroup GetGroupById(UInt32 uGroupId) { Debug.Assert((uGroupId != 0) && (uGroupId != UInt32.MaxValue)); if((uGroupId == 0) || (uGroupId == UInt32.MaxValue)) throw new ArgumentException("Invalid group ID!"); IntPtr p; if(m_bX64) p = KdbManager.GetGroupById64(m_pManager, uGroupId); else p = KdbManager.GetGroupById32(m_pManager, uGroupId); if(p == IntPtr.Zero) throw new ArgumentOutOfRangeException("uGroupId"); return (KdbGroup)Marshal.PtrToStructure(p, typeof(KdbGroup)); } [DllImport(DllFile32, EntryPoint = "GetGroupByIdN")] private static extern UInt32 GetGroupByIdN32(IntPtr pMgr, UInt32 idGroup); [DllImport(DllFile64, EntryPoint = "GetGroupByIdN")] private static extern UInt32 GetGroupByIdN64(IntPtr pMgr, UInt32 idGroup); /// /// Get the group index via the GroupID. /// /// ID of the group. /// Group index. public UInt32 GetGroupByIdN(UInt32 uGroupId) { Debug.Assert((uGroupId != 0) && (uGroupId != UInt32.MaxValue)); if((uGroupId == 0) || (uGroupId == UInt32.MaxValue)) throw new ArgumentException("Invalid group ID!"); if(m_bX64) return KdbManager.GetGroupByIdN64(m_pManager, uGroupId); else return KdbManager.GetGroupByIdN32(m_pManager, uGroupId); } [DllImport(DllFile32, CharSet = DllCharSet, EntryPoint = "OpenDatabase")] private static extern Int32 OpenDatabase32(IntPtr pMgr, string pszFile, IntPtr pRepair); [DllImport(DllFile64, CharSet = DllCharSet, EntryPoint = "OpenDatabase")] private static extern Int32 OpenDatabase64(IntPtr pMgr, string pszFile, IntPtr pRepair); /// /// Open a KDB database. /// /// File path of the database. /// Pointer to a repair information structure. If /// you want to open a Kdb file normally, set this parameter to /// IntPtr.Zero. /// Error code (see KdbErrorCode). public KdbErrorCode OpenDatabase(string strFile, IntPtr pRepairInfo) { Debug.Assert(strFile != null); if(strFile == null) throw new ArgumentNullException("strFile"); if(m_bX64) return (KdbErrorCode)KdbManager.OpenDatabase64(m_pManager, strFile, pRepairInfo); else return (KdbErrorCode)KdbManager.OpenDatabase32(m_pManager, strFile, pRepairInfo); } [DllImport(DllFile32, CharSet = DllCharSet, EntryPoint = "SaveDatabase")] private static extern Int32 SaveDatabase32(IntPtr pMgr, string pszFile); [DllImport(DllFile64, CharSet = DllCharSet, EntryPoint = "SaveDatabase")] private static extern Int32 SaveDatabase64(IntPtr pMgr, string pszFile); /// /// Save the current contents of the manager to a KDB file on disk. /// /// File to create. /// Error code (see KdbErrorCode). public KdbErrorCode SaveDatabase(string strFile) { Debug.Assert(strFile != null); if(strFile == null) throw new ArgumentNullException("strFile"); if(m_bX64) return (KdbErrorCode)KdbManager.SaveDatabase64(m_pManager, strFile); else return (KdbErrorCode)KdbManager.SaveDatabase32(m_pManager, strFile); } /// /// Close current database and create a new and empty one. /// public void NewDatabase() { if(m_bX64) KdbManager.NewDatabase64(m_pManager); else KdbManager.NewDatabase32(m_pManager); } /// /// Get the date/time object representing the 'Never Expires' status. /// /// DateTime object. public static DateTime GetNeverExpireTime() { return KdbTime.NeverExpireTime.ToDateTime(); } [DllImport(DllFile32, CharSet = DllCharSet, EntryPoint = "AddGroup")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool AddGroup32(IntPtr pMgr, ref KdbGroup pTemplate); [DllImport(DllFile64, CharSet = DllCharSet, EntryPoint = "AddGroup")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool AddGroup64(IntPtr pMgr, ref KdbGroup pTemplate); /// /// Add a new password group. /// /// Template containing new group information. /// Returns true if the group was created successfully. public bool AddGroup(ref KdbGroup pNewGroup) { if(m_bX64) return KdbManager.AddGroup64(m_pManager, ref pNewGroup); else return KdbManager.AddGroup32(m_pManager, ref pNewGroup); } [DllImport(DllFile32, CharSet = DllCharSet, EntryPoint = "SetGroup")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool SetGroup32(IntPtr pMgr, UInt32 dwIndex, ref KdbGroup pTemplate); [DllImport(DllFile64, CharSet = DllCharSet, EntryPoint = "SetGroup")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool SetGroup64(IntPtr pMgr, UInt32 dwIndex, ref KdbGroup pTemplate); /// /// Set/change a password group. /// /// Index of the group to be changed. /// Template containing new group information. /// Returns true if the group was created successfully. public bool SetGroup(UInt32 uIndex, ref KdbGroup pNewGroup) { Debug.Assert(uIndex < this.GroupCount); if(m_bX64) return KdbManager.SetGroup64(m_pManager, uIndex, ref pNewGroup); else return KdbManager.SetGroup32(m_pManager, uIndex, ref pNewGroup); } [DllImport(DllFile32, EntryPoint = "DeleteGroupById")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool DeleteGroupById32(IntPtr pMgr, UInt32 uGroupId); [DllImport(DllFile64, EntryPoint = "DeleteGroupById")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool DeleteGroupById64(IntPtr pMgr, UInt32 uGroupId); /// /// Delete a password group. /// /// ID of the group to be deleted. /// If the group has been deleted, the return value is true. public bool DeleteGroupByID(UInt32 uGroupID) { Debug.Assert((uGroupID != 0) && (uGroupID != UInt32.MaxValue)); if((uGroupID == 0) || (uGroupID == UInt32.MaxValue)) throw new ArgumentException("Invalid group ID!"); if(m_bX64) return KdbManager.DeleteGroupById64(m_pManager, uGroupID); else return KdbManager.DeleteGroupById32(m_pManager, uGroupID); } [DllImport(DllFile32, CharSet = DllCharSet, EntryPoint = "AddEntry")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool AddEntry32(IntPtr pMgr, ref KdbEntry pTemplate); [DllImport(DllFile64, CharSet = DllCharSet, EntryPoint = "AddEntry")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool AddEntry64(IntPtr pMgr, ref KdbEntry pTemplate); /// /// Add a new password entry. /// /// Template containing new entry information. /// Returns true if the entry was created successfully. public bool AddEntry(ref KdbEntry peNew) { if(m_bX64) return KdbManager.AddEntry64(m_pManager, ref peNew); else return KdbManager.AddEntry32(m_pManager, ref peNew); } [DllImport(DllFile32, CharSet = DllCharSet, EntryPoint = "SetEntry")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool SetEntry32(IntPtr pMgr, UInt32 dwIndex, ref KdbEntry pTemplate); [DllImport(DllFile64, CharSet = DllCharSet, EntryPoint = "SetEntry")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool SetEntry64(IntPtr pMgr, UInt32 dwIndex, ref KdbEntry pTemplate); /// /// Set/change a password entry. /// /// Index of the entry to be changed. /// Template containing new entry information. /// Returns true if the entry was created successfully. public bool SetEntry(UInt32 uIndex, ref KdbEntry peNew) { Debug.Assert(uIndex < this.EntryCount); if(m_bX64) return KdbManager.SetEntry64(m_pManager, uIndex, ref peNew); else return KdbManager.SetEntry32(m_pManager, uIndex, ref peNew); } [DllImport(DllFile32, EntryPoint = "DeleteEntry")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool DeleteEntry32(IntPtr pMgr, UInt32 dwIndex); [DllImport(DllFile64, EntryPoint = "DeleteEntry")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool DeleteEntry64(IntPtr pMgr, UInt32 dwIndex); /// /// Delete a password entry. /// /// Index of the entry. /// If the entry has been deleted, the return value is true. public bool DeleteEntry(UInt32 uIndex) { Debug.Assert(uIndex < this.EntryCount); if(m_bX64) return KdbManager.DeleteEntry64(m_pManager, uIndex); else return KdbManager.DeleteEntry32(m_pManager, uIndex); } /// /// Helper function to extract file attachments. /// /// Native memory pointer (as stored in the /// BinaryData member of KdbEntry. /// Size in bytes of the memory block. /// Managed byte array. public static byte[] ReadBinary(IntPtr pMemory, uint uSize) { Debug.Assert(pMemory != IntPtr.Zero); if(pMemory == IntPtr.Zero) throw new ArgumentNullException("pMemory"); byte[] pb = new byte[uSize]; if(uSize == 0) return pb; Marshal.Copy(pMemory, pb, 0, (int)uSize); return pb; } } } keepass2-2.25/KeePass/DataExchange/KdbFile.cs0000664000175000017500000006066612271000176020623 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Runtime.InteropServices; using System.Globalization; using System.Diagnostics; using KeePass.Resources; using KeePassLib; using KeePassLib.Security; using KeePassLib.Collections; using KeePassLib.Delegates; using KeePassLib.Interfaces; using KeePassLib.Keys; using KeePassLib.Utility; using KeePassLib.Resources; namespace KeePass.DataExchange { /// /// Serialization to KeePass KDB files. /// public sealed class KdbFile { private PwDatabase m_pwDatabase = null; private IStatusLogger m_slLogger = null; private const string KdbPrefix = "KDB: "; private const string AutoTypePrefix = "Auto-Type"; private const string AutoTypeWindowPrefix = "Auto-Type-Window"; private const string UrlOverridePrefix = "Url-Override:"; public static bool IsLibraryInstalled() { Exception ex; return IsLibraryInstalled(out ex); } public static bool IsLibraryInstalled(out Exception ex) { try { KdbManager mgr = new KdbManager(); mgr.Unload(); } catch(Exception exMgr) { ex = exMgr; return false; } ex = null; return true; } /// /// Default constructor. /// /// The PwDatabase instance that the class /// will load file data into or use to create a KDB file. Must not be null. /// Thrown if the database /// reference is null. public KdbFile(PwDatabase pwDataStore, IStatusLogger slLogger) { Debug.Assert(pwDataStore != null); if(pwDataStore == null) throw new ArgumentNullException("pwDataStore"); m_pwDatabase = pwDataStore; m_slLogger = slLogger; } private static KdbErrorCode SetDatabaseKey(KdbManager mgr, CompositeKey pwKey) { KdbErrorCode e; bool bPassword = pwKey.ContainsType(typeof(KcpPassword)); bool bKeyFile = pwKey.ContainsType(typeof(KcpKeyFile)); string strPassword = (bPassword ? (pwKey.GetUserKey( typeof(KcpPassword)) as KcpPassword).Password.ReadString() : string.Empty); string strKeyFile = (bKeyFile ? (pwKey.GetUserKey( typeof(KcpKeyFile)) as KcpKeyFile).Path : string.Empty); if(bPassword && bKeyFile) e = mgr.SetMasterKey(strKeyFile, true, strPassword, IntPtr.Zero, false); else if(bPassword && !bKeyFile) e = mgr.SetMasterKey(strPassword, false, null, IntPtr.Zero, false); else if(!bPassword && bKeyFile) e = mgr.SetMasterKey(strKeyFile, true, null, IntPtr.Zero, false); else { Debug.Assert(false); throw new Exception(KLRes.InvalidCompositeKey); } return e; } /// /// Loads a KDB file and stores all loaded entries in the current /// PwDatabase instance. /// /// Relative or absolute path to the file to open. public void Load(string strFilePath) { Debug.Assert(strFilePath != null); if(strFilePath == null) throw new ArgumentNullException("strFilePath"); KdbManager mgr = new KdbManager(); KdbErrorCode e; e = KdbFile.SetDatabaseKey(mgr, m_pwDatabase.MasterKey); if(e != KdbErrorCode.Success) throw new Exception(KLRes.InvalidCompositeKey); e = mgr.OpenDatabase(strFilePath, IntPtr.Zero); if(e != KdbErrorCode.Success) { mgr.Unload(); throw new Exception(KLRes.FileLoadFailed); } // Copy properties m_pwDatabase.KeyEncryptionRounds = mgr.KeyTransformationRounds; // Read groups and entries Dictionary dictGroups = ReadGroups(mgr); ReadEntries(mgr, dictGroups); mgr.Unload(); } private Dictionary ReadGroups(KdbManager mgr) { uint uGroupCount = mgr.GroupCount; Dictionary dictGroups = new Dictionary(); Stack vGroupStack = new Stack(); vGroupStack.Push(m_pwDatabase.RootGroup); DateTime dtNeverExpire = KdbManager.GetNeverExpireTime(); for(uint uGroup = 0; uGroup < uGroupCount; ++uGroup) { KdbGroup g = mgr.GetGroup(uGroup); PwGroup pg = new PwGroup(true, false); pg.Name = g.Name; pg.IconId = (g.ImageId < (uint)PwIcon.Count) ? (PwIcon)g.ImageId : PwIcon.Folder; pg.CreationTime = g.CreationTime.ToDateTime(); pg.LastModificationTime = g.LastModificationTime.ToDateTime(); pg.LastAccessTime = g.LastAccessTime.ToDateTime(); pg.ExpiryTime = g.ExpirationTime.ToDateTime(); pg.Expires = (pg.ExpiryTime != dtNeverExpire); pg.IsExpanded = ((g.Flags & (uint)KdbGroupFlags.Expanded) != 0); while(g.Level < (vGroupStack.Count - 1)) vGroupStack.Pop(); vGroupStack.Peek().AddGroup(pg, true); dictGroups[g.GroupId] = pg; if(g.Level == (uint)(vGroupStack.Count - 1)) vGroupStack.Push(pg); } return dictGroups; } private void ReadEntries(KdbManager mgr, Dictionary dictGroups) { DateTime dtNeverExpire = KdbManager.GetNeverExpireTime(); uint uEntryCount = mgr.EntryCount; for(uint uEntry = 0; uEntry < uEntryCount; ++uEntry) { KdbEntry e = mgr.GetEntry(uEntry); PwGroup pgContainer; if(!dictGroups.TryGetValue(e.GroupId, out pgContainer)) { Debug.Assert(false); continue; } PwEntry pe = new PwEntry(false, false); pe.SetUuid(new PwUuid(e.Uuid.ToByteArray()), false); pgContainer.AddEntry(pe, true, true); pe.IconId = (e.ImageId < (uint)PwIcon.Count) ? (PwIcon)e.ImageId : PwIcon.Key; pe.Strings.Set(PwDefs.TitleField, new ProtectedString( m_pwDatabase.MemoryProtection.ProtectTitle, e.Title)); pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( m_pwDatabase.MemoryProtection.ProtectUserName, e.UserName)); pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( m_pwDatabase.MemoryProtection.ProtectPassword, e.Password)); pe.Strings.Set(PwDefs.UrlField, new ProtectedString( m_pwDatabase.MemoryProtection.ProtectUrl, e.Url)); string strNotes = e.Additional; ImportAutoType(ref strNotes, pe); ImportUrlOverride(ref strNotes, pe); pe.Strings.Set(PwDefs.NotesField, new ProtectedString( m_pwDatabase.MemoryProtection.ProtectNotes, strNotes)); pe.CreationTime = e.CreationTime.ToDateTime(); pe.LastModificationTime = e.LastModificationTime.ToDateTime(); pe.LastAccessTime = e.LastAccessTime.ToDateTime(); pe.ExpiryTime = e.ExpirationTime.ToDateTime(); pe.Expires = (pe.ExpiryTime != dtNeverExpire); if((e.BinaryDataLength > 0) && (e.BinaryData != IntPtr.Zero)) { byte[] pbData = KdbManager.ReadBinary(e.BinaryData, e.BinaryDataLength); Debug.Assert(pbData.Length == e.BinaryDataLength); string strDesc = e.BinaryDescription; if(string.IsNullOrEmpty(strDesc)) strDesc = "Attachment"; pe.Binaries.Set(strDesc, new ProtectedBinary(false, pbData)); } if(m_slLogger != null) { if(!m_slLogger.SetProgress((100 * uEntry) / uEntryCount)) throw new Exception(KPRes.Cancel); } } } /// /// Save the contents of the current PwDatabase to a KDB file. /// /// Location to save the KDB file to. public void Save(string strSaveToFile, PwGroup pgDataSource) { Debug.Assert(strSaveToFile != null); if(strSaveToFile == null) throw new ArgumentNullException("strSaveToFile"); KdbManager mgr = new KdbManager(); KdbErrorCode e = KdbFile.SetDatabaseKey(mgr, m_pwDatabase.MasterKey); if(e != KdbErrorCode.Success) { Debug.Assert(false); throw new Exception(KLRes.InvalidCompositeKey); } if(m_slLogger != null) { if(m_pwDatabase.Name.Length != 0) m_slLogger.SetText(KdbPrefix + KPRes.FormatNoDatabaseName, LogStatusType.Warning); if(m_pwDatabase.Description.Length != 0) m_slLogger.SetText(KdbPrefix + KPRes.FormatNoDatabaseDesc, LogStatusType.Warning); } // Set properties if(m_pwDatabase.KeyEncryptionRounds >= (ulong)UInt32.MaxValue) mgr.KeyTransformationRounds = unchecked(uint.MaxValue - 1); else mgr.KeyTransformationRounds = (uint)m_pwDatabase.KeyEncryptionRounds; PwGroup pgRoot = (pgDataSource ?? m_pwDatabase.RootGroup); // Write groups and entries Dictionary dictGroups = WriteGroups(mgr, pgRoot); WriteEntries(mgr, dictGroups, pgRoot); e = mgr.SaveDatabase(strSaveToFile); if(e != KdbErrorCode.Success) throw new Exception(KLRes.FileSaveFailed); mgr.Unload(); } private static Dictionary WriteGroups(KdbManager mgr, PwGroup pgRoot) { Dictionary dictGroups = new Dictionary(); uint uGroupIndex = 1; DateTime dtNeverExpire = KdbManager.GetNeverExpireTime(); GroupHandler gh = delegate(PwGroup pg) { WriteGroup(pg, pgRoot, ref uGroupIndex, dictGroups, dtNeverExpire, mgr, false); return true; }; pgRoot.TraverseTree(TraversalMethod.PreOrder, gh, null); Debug.Assert(dictGroups.Count == (int)(uGroupIndex - 1)); EnsureParentGroupsExported(pgRoot, ref uGroupIndex, dictGroups, dtNeverExpire, mgr); return dictGroups; } private static void WriteGroup(PwGroup pg, PwGroup pgRoot, ref uint uGroupIndex, Dictionary dictGroups, DateTime dtNeverExpire, KdbManager mgr, bool bForceLevel0) { if(pg == pgRoot) return; KdbGroup grp = new KdbGroup(); grp.GroupId = uGroupIndex; dictGroups[pg] = grp.GroupId; grp.ImageId = (uint)pg.IconId; grp.Name = pg.Name; grp.CreationTime.Set(pg.CreationTime); grp.LastModificationTime.Set(pg.LastModificationTime); grp.LastAccessTime.Set(pg.LastAccessTime); if(pg.Expires) grp.ExpirationTime.Set(pg.ExpiryTime); else grp.ExpirationTime.Set(dtNeverExpire); grp.Level = (bForceLevel0 ? (ushort)0 : (ushort)(pg.GetLevel() - 1)); if(pg.IsExpanded) grp.Flags |= (uint)KdbGroupFlags.Expanded; if(!mgr.AddGroup(ref grp)) { Debug.Assert(false); throw new InvalidOperationException(); } ++uGroupIndex; } private static void EnsureParentGroupsExported(PwGroup pgRoot, ref uint uGroupIndex, Dictionary dictGroups, DateTime dtNeverExpires, KdbManager mgr) { bool bHasAtLeastOneGroup = (dictGroups.Count > 0); uint uLocalIndex = uGroupIndex; // Local copy, can't use ref in delegate EntryHandler eh = delegate(PwEntry pe) { PwGroup pg = pe.ParentGroup; if(pg == null) { Debug.Assert(false); return true; } if(bHasAtLeastOneGroup && (pg == pgRoot)) return true; if(dictGroups.ContainsKey(pg)) return true; WriteGroup(pg, pgRoot, ref uLocalIndex, dictGroups, dtNeverExpires, mgr, true); return true; }; pgRoot.TraverseTree(TraversalMethod.PreOrder, null, eh); uGroupIndex = uLocalIndex; } private void WriteEntries(KdbManager mgr, Dictionary dictGroups, PwGroup pgRoot) { bool bWarnedOnce = false; uint uGroupCount, uEntryCount, uEntriesSaved = 0; pgRoot.GetCounts(true, out uGroupCount, out uEntryCount); DateTime dtNeverExpire = KdbManager.GetNeverExpireTime(); EntryHandler eh = delegate(PwEntry pe) { KdbEntry e = new KdbEntry(); e.Uuid.Set(pe.Uuid.UuidBytes); if(pe.ParentGroup != pgRoot) e.GroupId = dictGroups[pe.ParentGroup]; else { e.GroupId = 1; if((m_slLogger != null) && !bWarnedOnce) { m_slLogger.SetText(KdbPrefix + KPRes.FormatNoRootEntries, LogStatusType.Warning); bWarnedOnce = true; } if(dictGroups.Count == 0) throw new Exception(KPRes.FormatNoSubGroupsInRoot); } e.ImageId = (uint)pe.IconId; e.Title = pe.Strings.ReadSafe(PwDefs.TitleField); e.UserName = pe.Strings.ReadSafe(PwDefs.UserNameField); e.Password = pe.Strings.ReadSafe(PwDefs.PasswordField); e.Url = pe.Strings.ReadSafe(PwDefs.UrlField); string strNotes = pe.Strings.ReadSafe(PwDefs.NotesField); ExportCustomStrings(pe, ref strNotes); ExportAutoType(pe, ref strNotes); ExportUrlOverride(pe, ref strNotes); e.Additional = strNotes; e.PasswordLength = (uint)e.Password.Length; Debug.Assert(TimeUtil.PwTimeLength == 7); e.CreationTime.Set(pe.CreationTime); e.LastModificationTime.Set(pe.LastModificationTime); e.LastAccessTime.Set(pe.LastAccessTime); if(pe.Expires) e.ExpirationTime.Set(pe.ExpiryTime); else e.ExpirationTime.Set(dtNeverExpire); IntPtr hBinaryData = IntPtr.Zero; if(pe.Binaries.UCount >= 1) { foreach(KeyValuePair kvp in pe.Binaries) { e.BinaryDescription = kvp.Key; byte[] pbAttached = kvp.Value.ReadData(); e.BinaryDataLength = (uint)pbAttached.Length; if(e.BinaryDataLength > 0) { hBinaryData = Marshal.AllocHGlobal((int)e.BinaryDataLength); Marshal.Copy(pbAttached, 0, hBinaryData, (int)e.BinaryDataLength); e.BinaryData = hBinaryData; } break; } if((pe.Binaries.UCount > 1) && (m_slLogger != null)) m_slLogger.SetText(KdbPrefix + KPRes.FormatOnlyOneAttachment + "\r\n\r\n" + KPRes.Entry + ":\r\n" + KPRes.Title + ": " + e.Title + "\r\n" + KPRes.UserName + ": " + e.UserName, LogStatusType.Warning); } bool bResult = mgr.AddEntry(ref e); Marshal.FreeHGlobal(hBinaryData); hBinaryData = IntPtr.Zero; if(!bResult) { Debug.Assert(false); throw new InvalidOperationException(); } ++uEntriesSaved; if(m_slLogger != null) if(!m_slLogger.SetProgress((100 * uEntriesSaved) / uEntryCount)) return false; return true; }; if(!pgRoot.TraverseTree(TraversalMethod.PreOrder, null, eh)) throw new InvalidOperationException(); } /* private static void ImportAutoType(ref string strNotes, PwEntry peStorage) { string str = strNotes; char[] vTrim = new char[]{ '\r', '\n', '\t', ' ' }; int nFirstAutoType = str.IndexOf(AutoTypePrefix, StringComparison.OrdinalIgnoreCase); if(nFirstAutoType < 0) nFirstAutoType = int.MaxValue; int nFirstAutoTypeWindow = str.IndexOf(AutoTypeWindowPrefix, StringComparison.OrdinalIgnoreCase); if((nFirstAutoTypeWindow >= 0) && (nFirstAutoTypeWindow < nFirstAutoType)) { int nWindowEnd = str.IndexOf('\n', nFirstAutoTypeWindow); if(nWindowEnd < 0) nWindowEnd = str.Length - 1; string strWindow = str.Substring(nFirstAutoTypeWindow + AutoTypeWindowPrefix.Length, nWindowEnd - nFirstAutoTypeWindow - AutoTypeWindowPrefix.Length + 1); strWindow = strWindow.Trim(vTrim); str = str.Remove(nFirstAutoTypeWindow, nWindowEnd - nFirstAutoTypeWindow + 1); peStorage.AutoType.Set(strWindow, string.Empty); } while(true) { int nAutoTypeStart = str.IndexOf(AutoTypePrefix, 0, StringComparison.OrdinalIgnoreCase); if(nAutoTypeStart < 0) break; int nAutoTypeEnd = str.IndexOf('\n', nAutoTypeStart); if(nAutoTypeEnd < 0) nAutoTypeEnd = str.Length - 1; string strAutoType = str.Substring(nAutoTypeStart + AutoTypePrefix.Length, nAutoTypeEnd - nAutoTypeStart - AutoTypePrefix.Length + 1); strAutoType = strAutoType.Trim(vTrim); str = str.Remove(nAutoTypeStart, nAutoTypeEnd - nAutoTypeStart + 1); int nWindowStart = str.IndexOf(AutoTypeWindowPrefix, 0, StringComparison.OrdinalIgnoreCase); if((nWindowStart < 0) || (nWindowStart >= nAutoTypeStart)) { peStorage.AutoType.DefaultSequence = strAutoType; continue; } int nWindowEnd = str.IndexOf('\n', nWindowStart); if(nWindowEnd < 0) nWindowEnd = str.Length - 1; string strWindow = str.Substring(nWindowStart + AutoTypeWindowPrefix.Length, nWindowEnd - nWindowStart - AutoTypeWindowPrefix.Length + 1); strWindow = strWindow.Trim(vTrim); str = str.Remove(nWindowStart, nWindowEnd - nWindowStart + 1); peStorage.AutoType.Set(strWindow, strAutoType); } strNotes = str; } */ private static void ImportAutoType(ref string strNotes, PwEntry peStorage) { if(string.IsNullOrEmpty(strNotes)) return; string str = strNotes.Replace("\r", string.Empty); string[] vLines = str.Split('\n'); string strOvr = FindPrefixedLine(vLines, AutoTypePrefix + ":"); if((strOvr != null) && (strOvr.Length > (AutoTypePrefix.Length + 1))) { strOvr = strOvr.Substring(AutoTypePrefix.Length + 1).Trim(); peStorage.AutoType.DefaultSequence = ConvertAutoTypeSequence( strOvr, true); } StringBuilder sb = new StringBuilder(); foreach(string strLine in vLines) { bool bProcessed = false; for(int iIdx = 0; iIdx < 32; ++iIdx) { string s = ((iIdx == 0) ? string.Empty : ("-" + iIdx.ToString(NumberFormatInfo.InvariantInfo))); string strWndPrefix = (AutoTypeWindowPrefix + s + ":"); string strSeqPrefix = (AutoTypePrefix + s + ":"); if(strLine.StartsWith(strWndPrefix, StrUtil.CaseIgnoreCmp) && (strLine.Length > strWndPrefix.Length)) { string strWindow = strLine.Substring(strWndPrefix.Length).Trim(); string strSeq = FindPrefixedLine(vLines, strSeqPrefix); if((strSeq != null) && (strSeq.Length > strSeqPrefix.Length)) peStorage.AutoType.Add(new AutoTypeAssociation( strWindow, ConvertAutoTypeSequence(strSeq.Substring( strSeqPrefix.Length), true))); else // Window, but no sequence peStorage.AutoType.Add(new AutoTypeAssociation( strWindow, string.Empty)); bProcessed = true; break; } else if(strLine.StartsWith(strSeqPrefix, StrUtil.CaseIgnoreCmp)) { bProcessed = true; break; } } if(bProcessed == false) { sb.Append(strLine); sb.Append(MessageService.NewLine); } } strNotes = sb.ToString(); } private static string FindPrefixedLine(string[] vLines, string strPrefix) { foreach(string str in vLines) { if(str.StartsWith(strPrefix, StrUtil.CaseIgnoreCmp)) return str; } return null; } private static Dictionary m_dSeq1xTo2x = null; private static Dictionary m_dSeq1xTo2xBiDir = null; private static string ConvertAutoTypeSequence(string strSeq, bool b1xTo2x) { if(string.IsNullOrEmpty(strSeq)) return string.Empty; if(m_dSeq1xTo2x == null) { m_dSeq1xTo2x = new Dictionary(); m_dSeq1xTo2xBiDir = new Dictionary(); // m_dSeq1xTo2x[@"{SPACE}"] = " "; // m_dSeq1xTo2x[@"{CLEARFIELD}"] = @"{HOME}+({END}){DEL}"; m_dSeq1xTo2xBiDir[@"{AT}"] = @"@"; m_dSeq1xTo2xBiDir[@"{PLUS}"] = @"{+}"; m_dSeq1xTo2xBiDir[@"{PERCENT}"] = @"{%}"; m_dSeq1xTo2xBiDir[@"{CARET}"] = @"{^}"; m_dSeq1xTo2xBiDir[@"{TILDE}"] = @"{~}"; m_dSeq1xTo2xBiDir[@"{LEFTBRACE}"] = @"{{}"; m_dSeq1xTo2xBiDir[@"{RIGHTBRACE}"] = @"{}}"; m_dSeq1xTo2xBiDir[@"{LEFTPAREN}"] = @"{(}"; m_dSeq1xTo2xBiDir[@"{RIGHTPAREN}"] = @"{)}"; m_dSeq1xTo2xBiDir[@"(+{END})"] = @"+({END})"; } string str = strSeq.Trim(); if(b1xTo2x) { foreach(KeyValuePair kvp in m_dSeq1xTo2x) str = StrUtil.ReplaceCaseInsensitive(str, kvp.Key, kvp.Value); } foreach(KeyValuePair kvp in m_dSeq1xTo2xBiDir) { if(b1xTo2x) str = StrUtil.ReplaceCaseInsensitive(str, kvp.Key, kvp.Value); else str = StrUtil.ReplaceCaseInsensitive(str, kvp.Value, kvp.Key); } if(!b1xTo2x) str = CapitalizePlaceholders(str); return str; } private static string CapitalizePlaceholders(string strSeq) { string str = strSeq; int iOffset = 0; while(true) { int iStart = str.IndexOf('{', iOffset); if(iStart < 0) break; int iEnd = str.IndexOf('}', iStart); if(iEnd < 0) { Debug.Assert(false); break; } string strPlaceholder = str.Substring(iStart, iEnd - iStart + 1); if(!strPlaceholder.StartsWith("{S:", StrUtil.CaseIgnoreCmp)) str = str.Replace(strPlaceholder, strPlaceholder.ToUpper()); iOffset = iStart + 1; } return str; } private static void ExportCustomStrings(PwEntry peSource, ref string strNotes) { bool bSep = false; foreach(KeyValuePair kvp in peSource.Strings) { if(PwDefs.IsStandardField(kvp.Key)) continue; if(!bSep) { if(strNotes.Length > 0) strNotes += MessageService.NewParagraph; bSep = true; } strNotes += kvp.Key + ": " + kvp.Value.ReadString() + MessageService.NewLine; } } private static void ExportAutoType(PwEntry peSource, ref string strNotes) { StringBuilder sbAppend = new StringBuilder(); bool bSeparator = false; uint uIndex = 0; if((peSource.AutoType.DefaultSequence.Length > 0) && (peSource.AutoType.AssociationsCount == 0)) // Avoid broken indices { if(strNotes.Length > 0) sbAppend.Append(MessageService.NewParagraph); sbAppend.Append(AutoTypePrefix); sbAppend.Append(@": "); sbAppend.Append(ConvertAutoTypeSeqExp(peSource.AutoType.DefaultSequence, peSource)); sbAppend.Append(MessageService.NewLine); bSeparator = true; ++uIndex; } foreach(AutoTypeAssociation a in peSource.AutoType.Associations) { if(bSeparator == false) { if(strNotes.Length > 0) sbAppend.Append(MessageService.NewParagraph); bSeparator = true; } string strSuffix = ((uIndex > 0) ? ("-" + uIndex.ToString( NumberFormatInfo.InvariantInfo)) : string.Empty); sbAppend.Append(AutoTypePrefix + strSuffix); sbAppend.Append(@": "); sbAppend.Append(ConvertAutoTypeSeqExp(a.Sequence, peSource)); sbAppend.Append(MessageService.NewLine); sbAppend.Append(AutoTypeWindowPrefix + strSuffix); sbAppend.Append(@": "); sbAppend.Append(a.WindowName); sbAppend.Append(MessageService.NewLine); ++uIndex; } strNotes = strNotes.TrimEnd(new char[]{ '\r', '\n', '\t', ' ' }); strNotes += sbAppend.ToString(); } private static string ConvertAutoTypeSeqExp(string strSeq, PwEntry pe) { string strExp = strSeq; if(string.IsNullOrEmpty(strExp)) strExp = pe.GetAutoTypeSequence(); return ConvertAutoTypeSequence(strExp, false); } private static void ImportUrlOverride(ref string strNotes, PwEntry peStorage) { string str = strNotes; char[] vTrim = new char[] { '\r', '\n', '\t', ' ' }; int nUrlStart = str.IndexOf(UrlOverridePrefix, 0, StringComparison.OrdinalIgnoreCase); if(nUrlStart < 0) return; int nUrlEnd = str.IndexOf('\n', nUrlStart); if(nUrlEnd < 0) nUrlEnd = str.Length - 1; string strUrl = str.Substring(nUrlStart + UrlOverridePrefix.Length, nUrlEnd - nUrlStart - UrlOverridePrefix.Length + 1); strUrl = strUrl.Trim(vTrim); peStorage.OverrideUrl = strUrl; str = str.Remove(nUrlStart, nUrlEnd - nUrlStart + 1); strNotes = str; } private static void ExportUrlOverride(PwEntry peSource, ref string strNotes) { if(peSource.OverrideUrl.Length > 0) { StringBuilder sbAppend = new StringBuilder(); sbAppend.Append(MessageService.NewParagraph); sbAppend.Append(UrlOverridePrefix); sbAppend.Append(@" "); sbAppend.Append(peSource.OverrideUrl); sbAppend.Append(MessageService.NewLine); strNotes = strNotes.TrimEnd(new char[] { '\r', '\n', '\t', ' ' }); strNotes += sbAppend.ToString(); } } } } keepass2-2.25/KeePass/DataExchange/GxiProfile.cs0000664000175000017500000002216312261553106021366 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml.Serialization; using System.ComponentModel; using System.Diagnostics; using KeePassLib.Utility; namespace KeePass.DataExchange { public enum GxiBinaryEncoding { Base64 = 0, Hex, Count // Virtual } public sealed class GxiProfile { private StrEncodingType m_tEnc = StrEncodingType.Unknown; public StrEncodingType Encoding { get { return m_tEnc; } set { m_tEnc = value; } } private bool m_bRemoveInvChars = true; [DefaultValue(true)] public bool RemoveInvalidChars { get { return m_bRemoveInvChars; } set { m_bRemoveInvChars = value; } } private bool m_bDecodeHtmlEnt = true; [DefaultValue(true)] public bool DecodeHtmlEntities { get { return m_bDecodeHtmlEnt; } set { m_bDecodeHtmlEnt = value; } } private string m_strRootXPath = string.Empty; [DefaultValue("")] public string RootXPath { get { return m_strRootXPath; } set { if(value == null) throw new ArgumentNullException("value"); m_strRootXPath = value; } } private string m_strGroupXPath = string.Empty; [DefaultValue("")] public string GroupXPath { get { return m_strGroupXPath; } set { if(value == null) throw new ArgumentNullException("value"); m_strGroupXPath = value; } } private string m_strGroupNameXPath = string.Empty; [DefaultValue("")] public string GroupNameXPath { get { return m_strGroupNameXPath; } set { if(value == null) throw new ArgumentNullException("value"); m_strGroupNameXPath = value; } } private string m_strEntryXPath = string.Empty; [DefaultValue("")] public string EntryXPath { get { return m_strEntryXPath; } set { if(value == null) throw new ArgumentNullException("value"); m_strEntryXPath = value; } } private string m_strStringKvpXPath = string.Empty; [DefaultValue("")] public string StringKvpXPath { get { return m_strStringKvpXPath; } set { if(value == null) throw new ArgumentNullException("value"); m_strStringKvpXPath = value; } } private string m_strStringKeyXPath = string.Empty; [DefaultValue("")] public string StringKeyXPath { get { return m_strStringKeyXPath; } set { if(value == null) throw new ArgumentNullException("value"); m_strStringKeyXPath = value; } } private bool m_bStringKeyUseName = false; [DefaultValue(false)] public bool StringKeyUseName { get { return m_bStringKeyUseName; } set { m_bStringKeyUseName = value; } } private string m_strStringKeyRepl = string.Empty; [DefaultValue("")] public string StringKeyRepl { get { return m_strStringKeyRepl; } set { if(value == null) throw new ArgumentNullException("value"); m_strStringKeyRepl = value; } } private string m_strStringValueXPath = string.Empty; [DefaultValue("")] public string StringValueXPath { get { return m_strStringValueXPath; } set { if(value == null) throw new ArgumentNullException("value"); m_strStringValueXPath = value; } } private string m_strStringValueRepl = string.Empty; [DefaultValue("")] public string StringValueRepl { get { return m_strStringValueRepl; } set { if(value == null) throw new ArgumentNullException("value"); m_strStringValueRepl = value; } } private string m_strStringKvpXPath2 = string.Empty; [DefaultValue("")] public string StringKvpXPath2 { get { return m_strStringKvpXPath2; } set { if(value == null) throw new ArgumentNullException("value"); m_strStringKvpXPath2 = value; } } private string m_strStringKeyXPath2 = string.Empty; [DefaultValue("")] public string StringKeyXPath2 { get { return m_strStringKeyXPath2; } set { if(value == null) throw new ArgumentNullException("value"); m_strStringKeyXPath2 = value; } } private bool m_bStringKeyUseName2 = false; [DefaultValue(false)] public bool StringKeyUseName2 { get { return m_bStringKeyUseName2; } set { m_bStringKeyUseName2 = value; } } private string m_strStringKeyRepl2 = string.Empty; [DefaultValue("")] public string StringKeyRepl2 { get { return m_strStringKeyRepl2; } set { if(value == null) throw new ArgumentNullException("value"); m_strStringKeyRepl2 = value; } } private string m_strStringValueXPath2 = string.Empty; [DefaultValue("")] public string StringValueXPath2 { get { return m_strStringValueXPath2; } set { if(value == null) throw new ArgumentNullException("value"); m_strStringValueXPath2 = value; } } private string m_strStringValueRepl2 = string.Empty; [DefaultValue("")] public string StringValueRepl2 { get { return m_strStringValueRepl2; } set { if(value == null) throw new ArgumentNullException("value"); m_strStringValueRepl2 = value; } } private string m_strBinaryKvpXPath = string.Empty; [DefaultValue("")] public string BinaryKvpXPath { get { return m_strBinaryKvpXPath; } set { if(value == null) throw new ArgumentNullException("value"); m_strBinaryKvpXPath = value; } } private string m_strBinaryKeyXPath = string.Empty; [DefaultValue("")] public string BinaryKeyXPath { get { return m_strBinaryKeyXPath; } set { if(value == null) throw new ArgumentNullException("value"); m_strBinaryKeyXPath = value; } } private bool m_bBinaryKeyUseName = false; [DefaultValue(false)] public bool BinaryKeyUseName { get { return m_bBinaryKeyUseName; } set { m_bBinaryKeyUseName = value; } } private string m_strBinaryKeyRepl = string.Empty; [DefaultValue("")] public string BinaryKeyRepl { get { return m_strBinaryKeyRepl; } set { if(value == null) throw new ArgumentNullException("value"); m_strBinaryKeyRepl = value; } } private string m_strBinaryValueXPath = string.Empty; [DefaultValue("")] public string BinaryValueXPath { get { return m_strBinaryValueXPath; } set { if(value == null) throw new ArgumentNullException("value"); m_strBinaryValueXPath = value; } } private GxiBinaryEncoding m_beBinValue = GxiBinaryEncoding.Base64; public GxiBinaryEncoding BinaryValueEncoding { get { return m_beBinValue; } set { m_beBinValue = value; } } private string m_strEntryGroupXPath = string.Empty; [DefaultValue("")] public string EntryGroupXPath { get { return m_strEntryGroupXPath; } set { if(value == null) throw new ArgumentNullException("value"); m_strEntryGroupXPath = value; } } private string m_strEntryGroupXPath2 = string.Empty; [DefaultValue("")] public string EntryGroupXPath2 { get { return m_strEntryGroupXPath2; } set { if(value == null) throw new ArgumentNullException("value"); m_strEntryGroupXPath2 = value; } } private string m_strEntryGroupSep = string.Empty; [DefaultValue("")] public string EntryGroupSep { get { return m_strEntryGroupSep; } set { if(value == null) throw new ArgumentNullException("value"); m_strEntryGroupSep = value; } } private bool m_bEntriesInRoot = true; [DefaultValue(true)] public bool EntriesInRoot { get { return m_bEntriesInRoot; } set { m_bEntriesInRoot = value; } } private bool m_bEntriesInGroup = true; [DefaultValue(true)] public bool EntriesInGroup { get { return m_bEntriesInGroup; } set { m_bEntriesInGroup = value; } } private bool m_bGroupsInGroup = true; [DefaultValue(true)] public bool GroupsInGroup { get { return m_bGroupsInGroup; } set { m_bGroupsInGroup = value; } } private bool m_bStringKeyToStd = true; [DefaultValue(true)] public bool StringKeyToStd { get { return m_bStringKeyToStd; } set { m_bStringKeyToStd = value; } } private bool m_bStringKeyToStdFuzzy = false; [DefaultValue(false)] public bool StringKeyToStdFuzzy { get { return m_bStringKeyToStdFuzzy; } set { m_bStringKeyToStdFuzzy = value; } } } } keepass2-2.25/KeePass/DataExchange/Formats/0000775000175000017500000000000012261553106020376 5ustar jtaylorjtaylorkeepass2-2.25/KeePass/DataExchange/Formats/WinFavorites10.cs0000664000175000017500000001756512261553106023524 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Drawing; using System.Threading; using System.Diagnostics; using KeePass.Resources; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { internal sealed class WinFavorites10 : FileFormatProvider { private readonly bool m_bInRoot; private const string IniTypeKey = "Type"; private const string IniTypeValue = "WinFav-Export 1.0"; public override bool SupportsImport { get { return false; } } public override bool SupportsExport { get { return true; } } public override string FormatName { get { return (KPRes.WindowsFavorites + " (" + (m_bInRoot ? KPRes.RootDirectory : (KPRes.Folder + @" '" + GetFolderName(true, null, null) + @"'")) + ")"); } } public override bool RequiresFile { get { return false; } } public override string ApplicationGroup { get { return KPRes.General; } } public override Image SmallIcon { get { return Properties.Resources.B16x16_WinFavs; } } public WinFavorites10(bool bInRoot) : base() { m_bInRoot = bInRoot; } private static string GetFolderName(bool bForceRoot, PwExportInfo pwExportInfo, PwGroup pg) { string strBaseName = UrlUtil.FilterFileName(string.IsNullOrEmpty( Program.Config.Defaults.WinFavsBaseFolderName) ? PwDefs.ShortProductName : Program.Config.Defaults.WinFavsBaseFolderName); if(bForceRoot || (pwExportInfo == null) || (pg == null)) return strBaseName; string strGroup = UrlUtil.FilterFileName(pg.Name); string strRootName = strBaseName; if(strGroup.Length > 0) strRootName += (" - " + strGroup); if(pwExportInfo.ContextDatabase != null) { if(pg == pwExportInfo.ContextDatabase.RootGroup) strRootName = strBaseName; } return strRootName; } public override bool Export(PwExportInfo pwExportInfo, Stream sOutput, IStatusLogger slLogger) { PwGroup pg = pwExportInfo.DataGroup; if(pg == null) { Debug.Assert(false); return true; } string strFavsRoot = Environment.GetFolderPath( Environment.SpecialFolder.Favorites); if(string.IsNullOrEmpty(strFavsRoot)) return false; uint uTotalGroups, uTotalEntries, uEntriesProcessed = 0; pwExportInfo.DataGroup.GetCounts(true, out uTotalGroups, out uTotalEntries); if(!m_bInRoot) // In folder { string strRootName = GetFolderName(false, pwExportInfo, pg); string strFavsSub = UrlUtil.EnsureTerminatingSeparator( strFavsRoot, false) + strRootName; if(Directory.Exists(strFavsSub)) { Directory.Delete(strFavsSub, true); WaitForDirCommit(strFavsSub, false); } ExportGroup(pwExportInfo.DataGroup, strFavsSub, slLogger, uTotalEntries, ref uEntriesProcessed); } else // In root { DeletePreviousExport(strFavsRoot, slLogger); ExportGroup(pwExportInfo.DataGroup, strFavsRoot, slLogger, uTotalEntries, ref uEntriesProcessed); } Debug.Assert(uEntriesProcessed == uTotalEntries); return true; } private static void ExportGroup(PwGroup pg, string strDir, IStatusLogger slLogger, uint uTotalEntries, ref uint uEntriesProcessed) { foreach(PwEntry pe in pg.Entries) { ExportEntry(pe, strDir); ++uEntriesProcessed; if(slLogger != null) slLogger.SetProgress(((uEntriesProcessed * 50U) / uTotalEntries) + 50U); } foreach(PwGroup pgSub in pg.Groups) { string strGroup = UrlUtil.FilterFileName(pgSub.Name); string strSub = (UrlUtil.EnsureTerminatingSeparator(strDir, false) + (!string.IsNullOrEmpty(strGroup) ? strGroup : KPRes.Group)); ExportGroup(pgSub, strSub, slLogger, uTotalEntries, ref uEntriesProcessed); } } private static void ExportEntry(PwEntry pe, string strDir) { string strUrl = pe.Strings.ReadSafe(PwDefs.UrlField); if(string.IsNullOrEmpty(strUrl)) return; string strTitle = pe.Strings.ReadSafe(PwDefs.TitleField); if(string.IsNullOrEmpty(strTitle)) strTitle = KPRes.Entry; strTitle = Program.Config.Defaults.WinFavsFileNamePrefix + strTitle; string strSuffix = Program.Config.Defaults.WinFavsFileNameSuffix + ".url"; strSuffix = UrlUtil.FilterFileName(strSuffix); string strFileBase = (UrlUtil.EnsureTerminatingSeparator(strDir, false) + UrlUtil.FilterFileName(strTitle)); string strFile = strFileBase + strSuffix; int iFind = 2; while(File.Exists(strFile)) { strFile = strFileBase + " (" + iFind.ToString() + ")" + strSuffix; ++iFind; } StringBuilder sb = new StringBuilder(); sb.AppendLine(@"[InternetShortcut]"); sb.AppendLine(@"URL=" + strUrl); // No additional line break sb.AppendLine(@"[" + PwDefs.ShortProductName + @"]"); sb.AppendLine(IniTypeKey + @"=" + IniTypeValue); // Terminating line break is important if(!Directory.Exists(strDir)) { try { Directory.CreateDirectory(strDir); } catch(Exception exDir) { throw new Exception(strDir + MessageService.NewParagraph + exDir.Message); } WaitForDirCommit(strDir, true); } try { File.WriteAllText(strFile, sb.ToString(), Encoding.Default); } catch(Exception exWrite) { throw new Exception(strFile + MessageService.NewParagraph + exWrite.Message); } } private static void WaitForDirCommit(string strDir, bool bRequireExists) { for(int i = 0; i < 20; ++i) { bool bExists = Directory.Exists(strDir); if(bExists && bRequireExists) return; if(!bExists && !bRequireExists) return; Thread.Sleep(50); } } private static void DeletePreviousExport(string strDir, IStatusLogger slLogger) { List vDirsToDelete = new List(); try { string[] vFiles = UrlUtil.GetFilePaths(strDir, "*.url", SearchOption.AllDirectories).ToArray(); for(int iFile = 0; iFile < vFiles.Length; ++iFile) { string strFile = vFiles[iFile]; try { IniFile ini = IniFile.Read(strFile, Encoding.Default); string strType = ini.Get(PwDefs.ShortProductName, IniTypeKey); if((strType != null) && (strType == IniTypeValue)) { File.Delete(strFile); string strCont = UrlUtil.GetFileDirectory(strFile, false, true); if(vDirsToDelete.IndexOf(strCont) < 0) vDirsToDelete.Add(strCont); } } catch(Exception) { Debug.Assert(false); } if(slLogger != null) slLogger.SetProgress(((uint)iFile * 50U) / (uint)vFiles.Length); } bool bDeleted = true; while(bDeleted) { bDeleted = false; for(int i = (vDirsToDelete.Count - 1); i >= 0; --i) { try { Directory.Delete(vDirsToDelete[i]); WaitForDirCommit(vDirsToDelete[i], false); vDirsToDelete.RemoveAt(i); bDeleted = true; } catch(Exception) { } // E.g. not empty } } } catch(Exception) { Debug.Assert(false); } } } } keepass2-2.25/KeePass/DataExchange/Formats/AmpXml250.cs0000664000175000017500000001523412261553106022357 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml; using System.IO; using System.Drawing; using System.Diagnostics; using KeePass.Resources; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; namespace KeePass.DataExchange.Formats { // 2.50-3.21+ internal sealed class AmpXml250 : FileFormatProvider { private const string ElemRoot = "AmP_FILE"; private const string ElemInfo = "INFO"; private const string ElemData = "DATA"; private const string ElemCategory = "Kategorie"; private const string ElemTitle = "Bezeichnung"; private const string ElemUserName = "Benutzername"; private const string ElemPassword1 = "Passwort1"; private const string ElemPassword2 = "Passwort2"; private const string ElemExpiry = "Ablaufdatum"; private const string ElemUrl = "URL_Programm"; private const string ElemNotes = "Kommentar"; private const string ElemCustom = "Benutzerdefinierte_Felder"; private const string ElemCustomName = "name"; private const string ElemCustomValue = "wert"; private const string ValueNoData = "n/a"; private const string ValueNone = "keins"; private const string ValueNever = "nie"; public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Alle meine Passworte XML"; } } public override string DefaultExtension { get { return "xml"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return Properties.Resources.B16x16_Imp_AmP; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); string strDoc = sr.ReadToEnd(); sr.Close(); strDoc = XmlUtil.DecodeHtmlEntities(strDoc); ImportFileString(strDoc, pwStorage, slLogger); } private static void ImportFileString(string strXmlDoc, PwDatabase pwStorage, IStatusLogger slLogger) { XmlDocument doc = new XmlDocument(); doc.LoadXml(strXmlDoc); XmlElement xmlRoot = doc.DocumentElement; Debug.Assert(xmlRoot.Name == ElemRoot); foreach(XmlNode xmlChild in xmlRoot.ChildNodes) { if(xmlChild.Name == ElemData) LoadDataNode(xmlChild, pwStorage, slLogger); else if(xmlChild.Name == ElemInfo) { } else { Debug.Assert(false); } } } private static void LoadDataNode(XmlNode xmlNode, PwDatabase pwStorage, IStatusLogger slLogger) { uint uCat = 0, uCount = (uint)xmlNode.ChildNodes.Count; foreach(XmlNode xmlCategory in xmlNode.ChildNodes) { LoadCategoryNode(xmlCategory, pwStorage); ++uCat; ImportUtil.SetStatus(slLogger, (uCat * 100) / uCount); } } private static void LoadCategoryNode(XmlNode xmlNode, PwDatabase pwStorage) { PwGroup pg = new PwGroup(true, true, xmlNode.Name, PwIcon.Folder); pwStorage.RootGroup.AddGroup(pg, true); PwEntry pe = new PwEntry(true, true); foreach(XmlNode xmlChild in xmlNode) { string strInner = XmlUtil.SafeInnerText(xmlChild); if(strInner == ValueNoData) strInner = string.Empty; if(xmlChild.Name == ElemCategory) { // strInner may contain special characters, thus // update the group name now pg.Name = strInner; } else if(xmlChild.Name == ElemTitle) { AddEntryIfValid(pg, ref pe); Debug.Assert(strInner.Length > 0); pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, strInner)); } else if(xmlChild.Name == ElemUserName) pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwStorage.MemoryProtection.ProtectUserName, strInner)); else if(xmlChild.Name == ElemPassword1) pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, strInner)); else if(xmlChild.Name == ElemPassword2) { if((strInner.Length > 0) && (strInner != ValueNone)) pe.Strings.Set(PwDefs.PasswordField + @" 2", new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, strInner)); } else if(xmlChild.Name == ElemExpiry) { if((strInner.Length > 0) && (strInner != ValueNever)) { try { DateTime dt = DateTime.Parse(strInner); pe.ExpiryTime = dt; pe.Expires = true; } catch(Exception) { Debug.Assert(false); } } } else if(xmlChild.Name == ElemUrl) pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pwStorage.MemoryProtection.ProtectUrl, strInner)); else if(xmlChild.Name == ElemNotes) pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, strInner)); else if(xmlChild.Name == ElemCustom) LoadCustomFields(xmlChild, pe, pwStorage); else { Debug.Assert(false); } } AddEntryIfValid(pg, ref pe); } private static void AddEntryIfValid(PwGroup pgContainer, ref PwEntry pe) { try { if(pe == null) return; if(pe.Strings.ReadSafe(PwDefs.TitleField).Length == 0) return; pgContainer.AddEntry(pe, true); } finally { pe = new PwEntry(true, true); } } private static void LoadCustomFields(XmlNode xmlNode, PwEntry pe, PwDatabase pwStorage) { string strKey = string.Empty; foreach(XmlNode xn in xmlNode.ChildNodes) { if(xn.Name == ElemCustomName) strKey = XmlUtil.SafeInnerText(xn); else if(xn.Name == ElemCustomValue) { if(strKey.Length == 0) { Debug.Assert(false); continue; } ImportUtil.AppendToField(pe, strKey, XmlUtil.SafeInnerText(xn), pwStorage); } } } } } keepass2-2.25/KeePass/DataExchange/Formats/PwExporterXml105.cs0000664000175000017500000001271212261553106023756 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using System.Xml; using System.Xml.Serialization; using System.Drawing; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 1.0.5 internal sealed class PwExporterXml105 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Password Exporter XML"; } } public override string DefaultExtension { get { return "xml"; } } public override string ApplicationGroup { get { return KPRes.Browser; } } public override bool ImportAppendsToRootGroupOnly { get { return true; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_HTML; } } private const string ElemRoot = "xml"; private const string ElemEntries = "entries"; private const string ElemEntry = "entry"; private const string AttrUser = "user"; private const string AttrPassword = "password"; private const string AttrURL = "host"; private const string AttrUserFieldName = "userFieldName"; private const string AttrPasswordFieldName = "passFieldName"; private const string DbUserFieldName = "FieldID_UserName"; private const string DbPasswordFieldName = "FieldID_Password"; public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); string strDoc = sr.ReadToEnd(); sr.Close(); int nIndex = strDoc.IndexOf('<'); while(nIndex >= 0) { int nAttrib = strDoc.LastIndexOf("=\"", nIndex); int nElem = strDoc.LastIndexOf('>', nIndex); if(nAttrib > nElem) { strDoc = strDoc.Remove(nIndex, 1); strDoc = strDoc.Insert(nIndex, @"<"); } nIndex = strDoc.IndexOf('<', nIndex + 1); } nIndex = strDoc.IndexOf('>'); while(nIndex >= 0) { if(nIndex <= 3) throw new FormatException("Invalid header!"); char chPrev = strDoc[nIndex - 1]; string strPrev4 = strDoc.Substring(nIndex - 3, 4); if((chPrev != '/') && (chPrev != '\"') && (strPrev4 != @"xml>") && (strPrev4 != @"ies>")) { strDoc = strDoc.Remove(nIndex, 1); strDoc = strDoc.Insert(nIndex, @">"); } nIndex = strDoc.IndexOf('>', nIndex + 1); } MemoryStream msXml = new MemoryStream(StrUtil.Utf8.GetBytes(strDoc), false); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(msXml); msXml.Close(); XmlNode xmlRoot = xmlDoc.DocumentElement; if(xmlRoot.Name != ElemRoot) throw new FormatException("Invalid root element!"); foreach(XmlNode xmlChild in xmlRoot.ChildNodes) { if(xmlChild.Name == ElemEntries) ImportEntries(xmlChild, pwStorage); else { Debug.Assert(false); } } } private static void ImportEntries(XmlNode xmlNode, PwDatabase pwStorage) { foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name == ElemEntry) ImportEntry(xmlChild, pwStorage); else { Debug.Assert(false); } } } private static void ImportEntry(XmlNode xmlNode, PwDatabase pwStorage) { PwEntry pe = new PwEntry(true, true); pwStorage.RootGroup.AddEntry(pe, true); XmlAttributeCollection col = xmlNode.Attributes; if(col == null) return; XmlNode xmlAttrib; xmlAttrib = col.GetNamedItem(AttrUser); if(xmlAttrib != null) pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwStorage.MemoryProtection.ProtectUserName, xmlAttrib.Value)); else { Debug.Assert(false); } xmlAttrib = col.GetNamedItem(AttrPassword); if(xmlAttrib != null) pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, xmlAttrib.Value)); else { Debug.Assert(false); } xmlAttrib = col.GetNamedItem(AttrURL); if(xmlAttrib != null) pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pwStorage.MemoryProtection.ProtectUrl, xmlAttrib.Value)); else { Debug.Assert(false); } xmlAttrib = col.GetNamedItem(AttrUserFieldName); if(xmlAttrib != null) pe.Strings.Set(DbUserFieldName, new ProtectedString( false, xmlAttrib.Value)); else { Debug.Assert(false); } xmlAttrib = col.GetNamedItem(AttrPasswordFieldName); if(xmlAttrib != null) pe.Strings.Set(DbPasswordFieldName, new ProtectedString( false, xmlAttrib.Value)); else { Debug.Assert(false); } } } } keepass2-2.25/KeePass/DataExchange/Formats/PwSafeXml302.cs0000664000175000017500000002757212261553106023035 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml; using System.Diagnostics; using System.Drawing; using KeePass.Resources; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 3.02-3.30+ internal sealed class PwSafeXml302 : FileFormatProvider { private const string AttribLineBreak = "delimiter"; private const string ElemEntry = "entry"; private const string ElemGroup = "group"; private const string ElemTitle = "title"; private const string ElemUserName = "username"; private const string ElemPassword = "password"; private const string ElemURL = "url"; private const string ElemNotes = "notes"; private const string ElemEMail = "email"; private const string ElemAutoType = "autotype"; private const string ElemRunCommand = "runcommand"; private const string ElemCreationTime = "ctime"; private const string ElemLastAccessTime = "atime"; private const string ElemExpireTime = "ltime"; private const string ElemLastModTime = "pmtime"; private const string ElemRecordModTime = "rmtime"; private const string ElemCreationTimeX = "ctimex"; private const string ElemLastAccessTimeX = "atimex"; private const string ElemExpireTimeX = "xtimex"; // Yes, inconsistent private const string ElemLastModTimeX = "pmtimex"; private const string ElemRecordModTimeX = "rmtimex"; private const string ElemEntryHistory = "pwhistory"; private const string ElemEntryHistoryContainer = "history_entries"; private const string ElemEntryHistoryItem = "history_entry"; private const string ElemEntryHistoryItemTime = "changed"; private const string ElemEntryHistoryItemTimeX = "changedx"; private const string ElemEntryHistoryItemPassword = "oldpassword"; private const string ElemTimePartDate = "date"; private const string ElemTimePartTime = "time"; private const string XPathUseDefaultUser = "Preferences/UseDefaultUser"; private const string XPathDefaultUser = "Preferences/DefaultUsername"; public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Password Safe XML"; } } public override string DefaultExtension { get { return "xml"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_PwSafe; } } private sealed class DatePasswordPair { public DateTime Time = DateTime.Now; public string Password = string.Empty; } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { MemoryStream ms = new MemoryStream(); MemUtil.CopyStream(sInput, ms); byte[] pbData = ms.ToArray(); ms.Close(); try { string strData = StrUtil.Utf8.GetString(pbData); if(strData.StartsWith("", StrUtil.CaseIgnoreCmp) && (strData.IndexOf( "WhatSaved=\"Password Safe V3.29\"", StrUtil.CaseIgnoreCmp) >= 0)) { // Fix broken XML exported by Password Safe 3.29; // this has been fixed in 3.30 strData = strData.Replace(" 0) pwStorage.DefaultUserNameChanged = DateTime.Now; } } } ms.Close(); } private static void ImportEntry(XmlNode xmlNode, PwDatabase pwStorage, string strLineBreak) { Debug.Assert(xmlNode != null); if(xmlNode == null) return; PwEntry pe = new PwEntry(true, true); string strGroupName = string.Empty; List listHistory = null; foreach(XmlNode xmlChild in xmlNode.ChildNodes) { if(xmlChild.Name == ElemGroup) strGroupName = XmlUtil.SafeInnerText(xmlChild); else if(xmlChild.Name == ElemTitle) pe.Strings.Set(PwDefs.TitleField, new ProtectedString(pwStorage.MemoryProtection.ProtectTitle, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemUserName) pe.Strings.Set(PwDefs.UserNameField, new ProtectedString(pwStorage.MemoryProtection.ProtectUserName, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemPassword) pe.Strings.Set(PwDefs.PasswordField, new ProtectedString(pwStorage.MemoryProtection.ProtectPassword, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemURL) pe.Strings.Set(PwDefs.UrlField, new ProtectedString(pwStorage.MemoryProtection.ProtectUrl, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemNotes) pe.Strings.Set(PwDefs.NotesField, new ProtectedString(pwStorage.MemoryProtection.ProtectNotes, XmlUtil.SafeInnerText(xmlChild, strLineBreak))); else if(xmlChild.Name == ElemEMail) pe.Strings.Set("E-Mail", new ProtectedString(false, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemCreationTime) pe.CreationTime = ReadDateTime(xmlChild); else if(xmlChild.Name == ElemLastAccessTime) pe.LastAccessTime = ReadDateTime(xmlChild); else if(xmlChild.Name == ElemExpireTime) { pe.ExpiryTime = ReadDateTime(xmlChild); pe.Expires = true; } else if(xmlChild.Name == ElemLastModTime) // = last mod pe.LastModificationTime = ReadDateTime(xmlChild); else if(xmlChild.Name == ElemRecordModTime) // = last mod pe.LastModificationTime = ReadDateTime(xmlChild); else if(xmlChild.Name == ElemCreationTimeX) pe.CreationTime = ReadDateTimeX(xmlChild); else if(xmlChild.Name == ElemLastAccessTimeX) pe.LastAccessTime = ReadDateTimeX(xmlChild); else if(xmlChild.Name == ElemExpireTimeX) { pe.ExpiryTime = ReadDateTimeX(xmlChild); pe.Expires = true; } else if(xmlChild.Name == ElemLastModTimeX) // = last mod pe.LastModificationTime = ReadDateTimeX(xmlChild); else if(xmlChild.Name == ElemRecordModTimeX) // = last mod pe.LastModificationTime = ReadDateTimeX(xmlChild); else if(xmlChild.Name == ElemAutoType) pe.AutoType.DefaultSequence = XmlUtil.SafeInnerText(xmlChild); else if(xmlChild.Name == ElemRunCommand) pe.OverrideUrl = XmlUtil.SafeInnerText(xmlChild); else if(xmlChild.Name == ElemEntryHistory) listHistory = ReadEntryHistory(xmlChild); } if(listHistory != null) { string strPassword = pe.Strings.ReadSafe(PwDefs.PasswordField); DateTime dtLastMod = pe.LastModificationTime; foreach(DatePasswordPair dpp in listHistory) { pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, dpp.Password)); pe.LastModificationTime = dpp.Time; pe.CreateBackup(null); } // Maintain backups manually now (backups from the imported file // might have been out of order) pe.MaintainBackups(pwStorage); pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, strPassword)); pe.LastModificationTime = dtLastMod; } PwGroup pgContainer = pwStorage.RootGroup; if(strGroupName.Length != 0) pgContainer = pwStorage.RootGroup.FindCreateSubTree(strGroupName, new string[1]{ "." }, true); pgContainer.AddEntry(pe, true); pgContainer.IsExpanded = true; } private static DateTime ReadDateTime(XmlNode xmlNode) { Debug.Assert(xmlNode != null); if(xmlNode == null) return DateTime.Now; int[] vTimeParts = new int[6]; DateTime dtTemp; foreach(XmlNode xmlChild in xmlNode.ChildNodes) { if(xmlChild.Name == ElemTimePartDate) { if(DateTime.TryParse(XmlUtil.SafeInnerText(xmlChild), out dtTemp)) { vTimeParts[0] = dtTemp.Year; vTimeParts[1] = dtTemp.Month; vTimeParts[2] = dtTemp.Day; } } else if(xmlChild.Name == ElemTimePartTime) { if(DateTime.TryParse(XmlUtil.SafeInnerText(xmlChild), out dtTemp)) { vTimeParts[3] = dtTemp.Hour; vTimeParts[4] = dtTemp.Minute; vTimeParts[5] = dtTemp.Second; } } else { Debug.Assert(false); } } return new DateTime(vTimeParts[0], vTimeParts[1], vTimeParts[2], vTimeParts[3], vTimeParts[4], vTimeParts[5]); } private static DateTime ReadDateTimeX(XmlNode xmlNode) { string strDate = XmlUtil.SafeInnerText(xmlNode); DateTime dt; if(StrUtil.TryParseDateTime(strDate, out dt)) return dt; Debug.Assert(false); return DateTime.Now; } private static List ReadEntryHistory(XmlNode xmlNode) { List list = null; foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name == ElemEntryHistoryContainer) list = ReadEntryHistoryContainer(xmlChild); } return list; } private static List ReadEntryHistoryContainer(XmlNode xmlNode) { List list = new List(); foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name == ElemEntryHistoryItem) list.Add(ReadEntryHistoryItem(xmlChild)); } return list; } private static DatePasswordPair ReadEntryHistoryItem(XmlNode xmlNode) { DatePasswordPair dpp = new DatePasswordPair(); foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name == ElemEntryHistoryItemTime) dpp.Time = ReadDateTime(xmlChild); else if(xmlChild.Name == ElemEntryHistoryItemTimeX) dpp.Time = ReadDateTimeX(xmlChild); else if(xmlChild.Name == ElemEntryHistoryItemPassword) dpp.Password = XmlUtil.SafeInnerText(xmlChild); } return dpp; } } } keepass2-2.25/KeePass/DataExchange/Formats/Spamex20070328.cs0000664000175000017500000002204012261553106023006 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Windows.Forms; using System.Drawing; using System.Net; using System.Net.Security; using System.Security.Cryptography.X509Certificates; using KeePass.Forms; using KeePass.Resources; using KeePass.UI; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Resources; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // Originally written on 2007-03-28, updated on 2012-04-15 internal sealed class Spamex20070328 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Spamex.com"; } } public override string ApplicationGroup { get { return KPRes.WebSites; } } public override bool ImportAppendsToRootGroupOnly { get { return true; } } public override bool RequiresFile { get { return false; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_WWW; } } private const string UrlDomain = "www.spamex.com"; private const string UrlBase = "https://www.spamex.com"; private const string UrlLoginPage = "https://www.spamex.com/tool/"; private const string UrlIndexPage = "https://www.spamex.com/tool/listaliases.cfm"; private const string UrlIndexAliasLink = ""; private const string StrTabLinkUrl = "/tool/listaliases.cfm"; public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { slLogger.SetText("> Spamex.com...", LogStatusType.Info); SingleLineEditForm dlgUser = new SingleLineEditForm(); dlgUser.InitEx("Spamex.com", KPRes.WebSiteLogin + " - " + KPRes.UserName, KPRes.UserNamePrompt, KeePass.Properties.Resources.B48x48_WWW, string.Empty, null); if(UIUtil.ShowDialogNotValue(dlgUser, DialogResult.OK)) return; string strUser = dlgUser.ResultString; UIUtil.DestroyForm(dlgUser); SingleLineEditForm dlgPassword = new SingleLineEditForm(); dlgPassword.InitEx("Spamex.com", KPRes.WebSiteLogin + " - " + KPRes.Password, KPRes.PasswordPrompt, KeePass.Properties.Resources.B48x48_WWW, string.Empty, null); if(UIUtil.ShowDialogNotValue(dlgPassword, DialogResult.OK)) return; string strPassword = dlgPassword.ResultString; UIUtil.DestroyForm(dlgPassword); RemoteCertificateValidationCallback pPrevCertCb = ServicePointManager.ServerCertificateValidationCallback; ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; }; try { slLogger.SetText(KPRes.ImportingStatusMsg, LogStatusType.Info); string strPostData = @"toollogin=&MetaDomain=&LoginEmail=" + strUser + @"&LoginPassword=" + strPassword + @"&Remember=1"; List> vCookies; string strMain = NetUtil.WebPageLogin(new Uri(UrlLoginPage), strPostData, out vCookies); if(strMain.IndexOf("Welcome " + strUser + "") < 0) { MessageService.ShowWarning(KPRes.InvalidUserPassword); return; } string strIndexPage = NetUtil.WebPageGetWithCookies(new Uri(UrlIndexPage), vCookies, UrlDomain); ImportIndex(pwStorage, strIndexPage, vCookies, slLogger); int nOffset = 0; List vSubPages = new List(); while(true) { string strLink = StrUtil.GetStringBetween(strIndexPage, nOffset, StrTabLinksStart, StrTabLinksEnd, out nOffset); ++nOffset; if(strLink.Length == 0) break; if(!strLink.StartsWith(StrTabLinkUrl)) continue; if(vSubPages.IndexOf(strLink) >= 0) continue; vSubPages.Add(strLink); string strSubPage = NetUtil.WebPageGetWithCookies(new Uri( UrlBase + strLink), vCookies, UrlDomain); ImportIndex(pwStorage, strSubPage, vCookies, slLogger); } } finally { ServicePointManager.ServerCertificateValidationCallback = pPrevCertCb; } } private static void ImportIndex(PwDatabase pwStorage, string strIndexPage, List> vCookies, IStatusLogger slf) { int nOffset = 0; while(true) { int nStart = strIndexPage.IndexOf(UrlIndexAliasLink, nOffset); if(nStart < 0) break; nStart += UrlIndexAliasLink.Length; StringBuilder sbCode = new StringBuilder(); while(true) { if(strIndexPage[nStart] == '\"') break; sbCode.Append(strIndexPage[nStart]); ++nStart; } ImportAccount(pwStorage, sbCode.ToString(), vCookies, slf); nOffset = nStart + 1; } } private static void ImportAccount(PwDatabase pwStorage, string strID, List> vCookies, IStatusLogger slf) { string strPage = NetUtil.WebPageGetWithCookies(new Uri( UrlAccountPage + strID), vCookies, UrlDomain); PwEntry pe = new PwEntry(true, true); pwStorage.RootGroup.AddEntry(pe, true); string str; string strTitle = StrUtil.GetStringBetween(strPage, 0, "Subject : ", ""); if(strTitle.StartsWith("")) strTitle = strTitle.Substring(3, strTitle.Length - 3); pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, strTitle)); string strUser = StrUtil.GetStringBetween(strPage, 0, "Site Username : ", ""); if(strUser.StartsWith("")) strUser = strUser.Substring(3, strUser.Length - 3); pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwStorage.MemoryProtection.ProtectUserName, strUser)); str = StrUtil.GetStringBetween(strPage, 0, "Site Password : ", ""); if(str.StartsWith("")) str = str.Substring(3, str.Length - 3); pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, str)); str = StrUtil.GetStringBetween(strPage, 0, "Site Domain : ", ""); if(str.StartsWith("")) str = str.Substring(3, str.Length - 3); pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pwStorage.MemoryProtection.ProtectUrl, str)); str = StrUtil.GetStringBetween(strPage, 0, "Notes : ", ""); if(str.StartsWith("")) str = str.Substring(3, str.Length - 3); pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, str)); str = StrUtil.GetStringBetween(strPage, 0, "Address: ", ""); if(str.StartsWith("")) str = str.Substring(3, str.Length - 3); pe.Strings.Set("Address", new ProtectedString(false, str)); str = StrUtil.GetStringBetween(strPage, 0, "Forwards to: ", ""); if(str.StartsWith("")) str = str.Substring(3, str.Length - 3); pe.Strings.Set("Forward To", new ProtectedString(false, str)); str = StrUtil.GetStringBetween(strPage, 0, "Reply-To Messages: ", ""); if(str.StartsWith("")) str = str.Substring(3, str.Length - 3); pe.Strings.Set("Reply-To Messages", new ProtectedString(false, str)); str = StrUtil.GetStringBetween(strPage, 0, "Allow Reply From: ", ""); if(str.StartsWith("")) str = str.Substring(3, str.Length - 3); pe.Strings.Set("Allow Reply From", new ProtectedString(false, str)); str = StrUtil.GetStringBetween(strPage, 0, "Filter Mode: ", ""); if(str.StartsWith("")) str = str.Substring(3, str.Length - 3); pe.Strings.Set("Filter Mode", new ProtectedString(false, str)); str = StrUtil.GetStringBetween(strPage, 0, "Created: ", ""); if(str.StartsWith("")) str = str.Substring(3, str.Length - 3); pe.Strings.Set("Created", new ProtectedString(false, str)); slf.SetText(strTitle + " - " + strUser + " (" + strID + ")", LogStatusType.Info); if(!slf.ContinueWork()) throw new InvalidOperationException(string.Empty); } } } keepass2-2.25/KeePass/DataExchange/Formats/KasperskyPwMgrXml50.cs0000664000175000017500000000304212261553106024503 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Drawing; using System.Diagnostics; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; namespace KeePass.DataExchange.Formats { // Sticky Password is basically the same password manager as // Kaspersky Password Manager, and the exported XML files // are exactly the same. // 5.0.0.148 internal sealed class KasperskyPwMgrXml50 : StickyPwXml50 { public override string FormatName { get { return "Kaspersky Password Manager XML"; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_KasperskyPwMgr; } } } } keepass2-2.25/KeePass/DataExchange/Formats/XslTransform2x.cs0000664000175000017500000000662012261553106023645 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml; using System.Xml.Xsl; using System.Windows.Forms; using System.Diagnostics; using System.Drawing; using KeePass.App; using KeePass.Resources; using KeePass.UI; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Serialization; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { internal sealed class XslTransform2x : FileFormatProvider { public override bool SupportsImport { get { return false; } } public override bool SupportsExport { get { return true; } } public override string FormatName { get { return KPRes.XslExporter; } } public override string ApplicationGroup { get { return KPRes.General; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_CompFile; } } public override bool Export(PwExportInfo pwExportInfo, Stream sOutput, IStatusLogger slLogger) { string strFilter = UIUtil.CreateFileTypeFilter("xsl", KPRes.XslFileType, true); OpenFileDialogEx dlgXsl = UIUtil.CreateOpenFileDialog(KPRes.XslSelectFile, strFilter, 1, "xsl", false, AppDefs.FileDialogContext.Xsl); if(dlgXsl.ShowDialog() != DialogResult.OK) return false; string strXslFile = dlgXsl.FileName; XslCompiledTransform xsl = new XslCompiledTransform(); try { xsl.Load(strXslFile); } catch(Exception exXsl) { throw new NotSupportedException(strXslFile + MessageService.NewParagraph + KPRes.NoXslFile + MessageService.NewParagraph + exXsl.Message); } MemoryStream msDataXml = new MemoryStream(); PwDatabase pd = (pwExportInfo.ContextDatabase ?? new PwDatabase()); KdbxFile kdb = new KdbxFile(pd); kdb.Save(msDataXml, pwExportInfo.DataGroup, KdbxFormat.PlainXml, slLogger); byte[] pbData = msDataXml.ToArray(); msDataXml.Close(); MemoryStream msDataRead = new MemoryStream(pbData, false); XmlReader xmlDataReader = XmlReader.Create(msDataRead); XmlWriterSettings xws = new XmlWriterSettings(); xws.CheckCharacters = false; xws.Encoding = new UTF8Encoding(false); xws.NewLineChars = MessageService.NewLine; xws.NewLineHandling = NewLineHandling.None; xws.OmitXmlDeclaration = true; xws.ConformanceLevel = ConformanceLevel.Auto; XmlWriter xmlWriter = XmlWriter.Create(sOutput, xws); xsl.Transform(xmlDataReader, xmlWriter); xmlWriter.Close(); xmlDataReader.Close(); msDataRead.Close(); Array.Clear(pbData, 0, pbData.Length); return true; } } } keepass2-2.25/KeePass/DataExchange/Formats/PwDepotXml26.cs0000664000175000017500000002616312261553106023150 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml; using System.IO; using System.Drawing; using System.Globalization; using System.Diagnostics; using KeePass.Resources; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 2.6 - 5.3.0+ internal sealed class PwDepotXml26 : FileFormatProvider { private const string ElemHeader = "HEADER"; private const string ElemContainer = "PASSWORDS"; private const string ElemGroup = "GROUP"; private const string AttribGroupName = "NAME"; private const string ElemEntry = "ITEM"; private const string ElemEntryName = "DESCRIPTION"; private const string ElemEntryUser = "USERNAME"; private const string ElemEntryPassword = "PASSWORD"; private const string ElemEntryURL = "URL"; private const string ElemEntryNotes = "COMMENT"; private const string ElemEntryLastModTime = "LASTMODIFIED"; private const string ElemEntryExpireTime = "EXPIRYDATE"; private const string ElemEntryCreatedTime = "CREATED"; private const string ElemEntryLastAccTime = "LASTACCESSED"; private const string ElemEntryUsageCount = "USAGECOUNT"; private const string ElemEntryAutoType = "TEMPLATE"; private const string ElemEntryCustom = "CUSTOMFIELDS"; private static readonly string[] ElemEntryUnsupportedItems = new string[]{ "TYPE", "IMPORTANCE", "IMAGECUSTOM", "PARAMSTR", "CATEGORY", "CUSTOMBROWSER", "AUTOCOMPLETEMETHOD", "WEBFORMDATA", "TANS", "FINGERPRINT" }; private const string ElemImageIndex = "IMAGEINDEX"; private const string ElemCustomField = "FIELD"; private const string ElemCustomFieldName = "NAME"; private const string ElemCustomFieldValue = "VALUE"; private const string AttribFormat = "FMT"; private const string FieldInfoText = "IDS_InformationText"; public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Password Depot XML"; } } public override string DefaultExtension { get { return "xml"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_PwDepot; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, StrUtil.Utf8); string strData = sr.ReadToEnd(); sr.Close(); // Remove vertical tabulators strData = strData.Replace("\u000B", string.Empty); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(strData); XmlNode xmlRoot = xmlDoc.DocumentElement; foreach(XmlNode xmlChild in xmlRoot.ChildNodes) { if(xmlChild.Name == ElemHeader) { } // Unsupported else if(xmlChild.Name == ElemContainer) ReadContainer(xmlChild, pwStorage); else { Debug.Assert(false); } } } private static void ReadContainer(XmlNode xmlNode, PwDatabase pwStorage) { foreach(XmlNode xmlChild in xmlNode.ChildNodes) { if(xmlChild.Name == ElemGroup) ReadGroup(xmlChild, pwStorage.RootGroup, pwStorage); else { Debug.Assert(false); } } } private static void ReadGroup(XmlNode xmlNode, PwGroup pgParent, PwDatabase pwStorage) { PwGroup pg = new PwGroup(true, true); pgParent.AddGroup(pg, true); try { XmlAttributeCollection xac = xmlNode.Attributes; pg.Name = xac.GetNamedItem(AttribGroupName).Value; } catch(Exception) { } foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name == ElemGroup) ReadGroup(xmlChild, pg, pwStorage); else if(xmlChild.Name == ElemEntry) ReadEntry(xmlChild, pg, pwStorage); else { Debug.Assert(false); } } } private static void ReadEntry(XmlNode xmlNode, PwGroup pgParent, PwDatabase pwStorage) { PwEntry pe = new PwEntry(true, true); pgParent.AddEntry(pe, true); DateTime? ndt; foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name == ElemEntryName) pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemEntryUser) pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwStorage.MemoryProtection.ProtectUserName, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemEntryPassword) pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemEntryURL) pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pwStorage.MemoryProtection.ProtectUrl, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemEntryNotes) pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemEntryLastModTime) { ndt = ReadTime(xmlChild); if(ndt.HasValue) pe.LastModificationTime = ndt.Value; } else if(xmlChild.Name == ElemEntryExpireTime) { ndt = ReadTime(xmlChild); if(ndt.HasValue) { pe.ExpiryTime = ndt.Value; pe.Expires = true; } } else if(xmlChild.Name == ElemEntryCreatedTime) { ndt = ReadTime(xmlChild); if(ndt.HasValue) pe.CreationTime = ndt.Value; } else if(xmlChild.Name == ElemEntryLastAccTime) { ndt = ReadTime(xmlChild); if(ndt.HasValue) pe.LastAccessTime = ndt.Value; } else if(xmlChild.Name == ElemEntryUsageCount) { ulong uUsageCount; if(ulong.TryParse(XmlUtil.SafeInnerText(xmlChild), out uUsageCount)) pe.UsageCount = uUsageCount; } else if(xmlChild.Name == ElemEntryAutoType) pe.AutoType.DefaultSequence = MapAutoType( XmlUtil.SafeInnerText(xmlChild)); else if(xmlChild.Name == ElemEntryCustom) ReadCustomContainer(xmlChild, pe); else if(xmlChild.Name == ElemImageIndex) pe.IconId = MapIcon(XmlUtil.SafeInnerText(xmlChild), true); else if(Array.IndexOf(ElemEntryUnsupportedItems, xmlChild.Name) >= 0) { } else { Debug.Assert(false, xmlChild.Name); } } string strInfoText = pe.Strings.ReadSafe(FieldInfoText); if((pe.Strings.ReadSafe(PwDefs.NotesField).Length == 0) && (strInfoText.Length > 0)) { pe.Strings.Remove(FieldInfoText); pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, strInfoText)); } } private static void ReadCustomContainer(XmlNode xmlNode, PwEntry pe) { foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name == ElemCustomField) ReadCustomField(xmlChild, pe); else { Debug.Assert(false); } } } private static void ReadCustomField(XmlNode xmlNode, PwEntry pe) { string strName = string.Empty, strValue = string.Empty; foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name == ElemCustomFieldName) strName = XmlUtil.SafeInnerText(xmlChild); else if(xmlChild.Name == ElemCustomFieldValue) strValue = XmlUtil.SafeInnerText(xmlChild); // else { } // Field 'VISIBLE' } if((strName.Length == 0) || PwDefs.IsStandardField(strName)) pe.Strings.Set(Guid.NewGuid().ToString(), new ProtectedString(false, strValue)); else pe.Strings.Set(strName, new ProtectedString(false, strValue)); } private static PwIcon MapIcon(string strIconId, bool bEntryIcon) { PwIcon ico = (bEntryIcon ? PwIcon.Key : PwIcon.Folder); int idIcon; if(!int.TryParse(strIconId, out idIcon)) return ico; ++idIcon; // In the icon picker dialog, all indices are + 1 switch(idIcon) { case 1: ico = PwIcon.Key; break; case 4: ico = PwIcon.Folder; break; case 5: ico = PwIcon.LockOpen; break; case 15: ico = PwIcon.EMail; break; case 16: ico = PwIcon.EMail; break; case 17: ico = PwIcon.ProgramIcons; break; case 18: ico = PwIcon.ProgramIcons; break; case 21: ico = PwIcon.World; break; case 22: ico = PwIcon.World; break; case 25: ico = PwIcon.Money; break; case 26: ico = PwIcon.Money; break; case 27: ico = PwIcon.Star; break; case 28: ico = PwIcon.Star; break; case 47: ico = PwIcon.FolderOpen; break; case 48: ico = PwIcon.TrashBin; break; case 49: ico = PwIcon.TrashBin; break; default: break; }; return ico; } private static string MapAutoType(string str) { str = str.Replace('<', '{'); str = str.Replace('>', '}'); str = StrUtil.ReplaceCaseInsensitive(str, @"{USER}", @"{" + PwDefs.UserNameField.ToUpper() + @"}"); str = StrUtil.ReplaceCaseInsensitive(str, @"{PASS}", @"{" + PwDefs.PasswordField.ToUpper() + @"}"); str = StrUtil.ReplaceCaseInsensitive(str, @"{CLEAR}", @"{HOME}+({END}){DEL}"); str = StrUtil.ReplaceCaseInsensitive(str, @"{ARROW_LEFT}", @"{LEFT}"); str = StrUtil.ReplaceCaseInsensitive(str, @"{ARROW_UP}", @"{UP}"); str = StrUtil.ReplaceCaseInsensitive(str, @"{ARROW_RIGHT}", @"{RIGHT}"); str = StrUtil.ReplaceCaseInsensitive(str, @"{ARROW_DOWN}", @"{DOWN}"); if(str.Equals(PwDefs.DefaultAutoTypeSequence, StrUtil.CaseIgnoreCmp)) return string.Empty; return str; } private static DateTime? ReadTime(XmlNode xmlNode) { DateTime? ndt = ReadTimeRaw(xmlNode); if(!ndt.HasValue) return null; if(ndt.Value.Year < 1950) return null; return ndt.Value; } private static DateTime? ReadTimeRaw(XmlNode xmlNode) { string strTime = XmlUtil.SafeInnerText(xmlNode); string strFormat = null; try { XmlAttributeCollection xac = xmlNode.Attributes; strFormat = xac.GetNamedItem(AttribFormat).Value; } catch(Exception) { } DateTime dt; if(!string.IsNullOrEmpty(strFormat)) { strFormat = strFormat.Replace("mm", "MM"); if(DateTime.TryParseExact(strTime, strFormat, null, DateTimeStyles.AssumeLocal, out dt)) return dt; } if(DateTime.TryParse(strTime, out dt)) return dt; return null; } } } keepass2-2.25/KeePass/DataExchange/Formats/DesktopKnox32.cs0000664000175000017500000000715512261553106023353 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Drawing; using System.Xml; using System.Diagnostics; using KeePass.Resources; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 3.2+ internal sealed class DesktopKnox32 : FileFormatProvider { private const string ElemRoot = "SafeCatalog"; private const string ElemEntry = "SafeElement"; private const string ElemCategory = "Category"; private const string ElemTitle = "Title"; private const string ElemNotes = "Content"; public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "DesktopKnox XML"; } } public override string DefaultExtension { get { return "xml"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_DesktopKnox; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, StrUtil.Utf8); string strDoc = sr.ReadToEnd(); sr.Close(); XmlDocument doc = new XmlDocument(); doc.LoadXml(strDoc); XmlElement xmlRoot = doc.DocumentElement; Debug.Assert(xmlRoot.Name == ElemRoot); Dictionary dictGroups = new Dictionary(); dictGroups[string.Empty] = pwStorage.RootGroup; foreach(XmlNode xmlChild in xmlRoot.ChildNodes) { if(xmlChild.Name == ElemEntry) ImportEntry(xmlChild, pwStorage, dictGroups); else { Debug.Assert(false); } } } private static void ImportEntry(XmlNode xmlNode, PwDatabase pwStorage, Dictionary dGroups) { PwEntry pe = new PwEntry(true, true); string strGroup = string.Empty; foreach(XmlNode xmlChild in xmlNode) { string strInner = XmlUtil.SafeInnerText(xmlChild); if(xmlChild.Name == ElemCategory) strGroup = strInner; else if(xmlChild.Name == ElemTitle) pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, strInner)); else if(xmlChild.Name == ElemNotes) pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, strInner)); } PwGroup pg; dGroups.TryGetValue(strGroup, out pg); if(pg == null) { pg = new PwGroup(true, true); pg.Name = strGroup; dGroups[string.Empty].AddGroup(pg, true); dGroups[strGroup] = pg; } pg.AddEntry(pe, true); } } } keepass2-2.25/KeePass/DataExchange/Formats/PVaultTxt14.cs0000664000175000017500000001065212261553106023011 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Drawing; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; namespace KeePass.DataExchange.Formats { // 1.4 internal sealed class PVaultTxt14 : FileFormatProvider { private const string InitGroup = "************"; private const string InitNewEntry = "----------------------"; private const string InitTitle = "Account: "; private const string InitUser = "User Name: "; private const string InitPassword = "Password: "; private const string InitURL = "Hyperlink: "; private const string InitEMail = "Email: "; private const string InitNotes = "Comments: "; private const string ContinueNotes = " "; public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Personal Vault TXT"; } } public override string DefaultExtension { get { return "txt"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_PVault; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); string strData = sr.ReadToEnd(); sr.Close(); string[] vLines = strData.Split(new char[]{ '\r', '\n' }); PwGroup pg = pwStorage.RootGroup; PwEntry pe = new PwEntry(true, true); foreach(string strLine in vLines) { if(strLine.StartsWith(InitGroup)) { string strGroup = strLine.Remove(0, InitGroup.Length); if(strGroup.Length > InitGroup.Length) strGroup = strGroup.Substring(0, strGroup.Length - InitGroup.Length); pg = pwStorage.RootGroup.FindCreateGroup(strGroup, true); pe = new PwEntry(true, true); pg.AddEntry(pe, true); } else if(strLine.StartsWith(InitNewEntry)) { pe = new PwEntry(true, true); pg.AddEntry(pe, true); } else if(strLine.StartsWith(InitTitle)) pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, strLine.Remove(0, InitTitle.Length))); else if(strLine.StartsWith(InitUser)) pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwStorage.MemoryProtection.ProtectUserName, strLine.Remove(0, InitUser.Length))); else if(strLine.StartsWith(InitPassword)) pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, strLine.Remove(0, InitPassword.Length))); else if(strLine.StartsWith(InitURL)) pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pwStorage.MemoryProtection.ProtectUrl, strLine.Remove(0, InitURL.Length))); else if(strLine.StartsWith(InitEMail)) pe.Strings.Set("E-Mail", new ProtectedString( false, strLine.Remove(0, InitEMail.Length))); else if(strLine.StartsWith(InitNotes)) pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, strLine.Remove(0, InitNotes.Length))); else if(strLine.StartsWith(ContinueNotes)) pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, pe.Strings.ReadSafe(PwDefs.NotesField) + "\r\n" + strLine.Remove(0, ContinueNotes.Length))); } } } } keepass2-2.25/KeePass/DataExchange/Formats/KeePassCsv1x.cs0000664000175000017500000001343312261553106023211 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 false; } } 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, StrUtil.Utf8); 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; if(!string.IsNullOrEmpty(str)) { str = str.Replace("\\", "\\\\"); str = str.Replace("\"", "\\\""); sw.Write(str); } if(!string.IsNullOrEmpty(strAppend)) sw.Write(strAppend); } } } keepass2-2.25/KeePass/DataExchange/Formats/PwPrompterDat12.cs0000664000175000017500000001207212261553106023642 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Windows.Forms; using System.Drawing; using System.Diagnostics; using KeePass.Forms; using KeePass.Resources; using KeePass.UI; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Resources; using KeePassLib.Security; namespace KeePass.DataExchange.Formats { internal sealed class PwPrompterDat12 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Password Prompter DAT"; } } public override string DefaultExtension { get { return "dat"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override bool ImportAppendsToRootGroupOnly { get { return true; } } public override Image SmallIcon { get { return Properties.Resources.B16x16_Imp_PwPrompter; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { SingleLineEditForm dlg = new SingleLineEditForm(); dlg.InitEx(KPRes.Password, KPRes.Import + ": " + this.FormatName, KPRes.PasswordPrompt, Properties.Resources.B48x48_KGPG_Key2, string.Empty, null); if(UIUtil.ShowDialogNotValue(dlg, DialogResult.OK)) return; string strPassword = dlg.ResultString; UIUtil.DestroyForm(dlg); byte[] pbPassword = Encoding.Default.GetBytes(strPassword); BinaryReader br = new BinaryReader(sInput, Encoding.Default); ushort usFileVersion = br.ReadUInt16(); if(usFileVersion != 0x0100) throw new Exception(KLRes.FileVersionUnsupported); uint uEntries = br.ReadUInt32(); uint uKeySize = br.ReadUInt32(); Debug.Assert(uKeySize == 50); // It's a constant byte btKeyArrayLen = br.ReadByte(); byte[] pbKey = br.ReadBytes(btKeyArrayLen); byte btValidArrayLen = br.ReadByte(); byte[] pbValid = br.ReadBytes(btValidArrayLen); if(pbPassword.Length > 0) { MangleSetKey(pbPassword); MangleDecode(pbKey); } MangleSetKey(pbKey); MangleDecode(pbValid); string strValid = Encoding.Default.GetString(pbValid); if(strValid != "aacaaaadaaeabaacyuioqaqqaaaaaertaaajkadaadaaxywqea") throw new Exception(KLRes.InvalidCompositeKey); for(uint uEntry = 0; uEntry < uEntries; ++uEntry) { PwEntry pe = new PwEntry(true, true); pwStorage.RootGroup.AddEntry(pe, true); pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, ReadString(br))); pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwStorage.MemoryProtection.ProtectUserName, ReadString(br))); pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, ReadString(br))); pe.Strings.Set("Hint", new ProtectedString(false, ReadString(br))); pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, ReadString(br))); pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pwStorage.MemoryProtection.ProtectUrl, ReadString(br))); } br.Close(); sInput.Close(); } private string ReadString(BinaryReader br) { byte btLen = br.ReadByte(); byte[] pbData = br.ReadBytes(btLen); MangleDecode(pbData); return Encoding.Default.GetString(pbData); } byte[] m_pbMangleKey = null; private void MangleSetKey(byte[] pbKey) { if(pbKey == null) { Debug.Assert(false); return; } m_pbMangleKey = new byte[pbKey.Length]; Array.Copy(pbKey, m_pbMangleKey, pbKey.Length); } private void MangleDecode(byte[] pbData) { if(m_pbMangleKey == null) { Debug.Assert(false); return; } int nKeyIndex = 0, nIndex = 0, nRemLen = pbData.Length; bool bUp = true; while(nRemLen > 0) { if(nKeyIndex > (m_pbMangleKey.Length - 1)) { nKeyIndex = m_pbMangleKey.Length - 1; bUp = false; } else if(nKeyIndex < 0) { nKeyIndex = 0; bUp = true; } pbData[nIndex] ^= m_pbMangleKey[nKeyIndex]; nKeyIndex += (bUp ? 1 : -1); ++nIndex; --nRemLen; } } } } keepass2-2.25/KeePass/DataExchange/Formats/KeePassXml1x.cs0000664000175000017500000001625112261553106023217 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using System.Xml; using System.Xml.Serialization; using System.Diagnostics; using KeePass.Resources; using KeePass.Util; using KeePassLib; using KeePassLib.Collections; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Serialization; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { internal sealed class KeePassXml1x : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "KeePass XML (1.x)"; } } public override string DefaultExtension { get { return "xml"; } } public override string ApplicationGroup { get { return PwDefs.ShortProductName; } } public override bool SupportsUuids { get { return true; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Binary; } } private const string ElemRoot = "pwlist"; private const string ElemEntry = "pwentry"; private const string ElemGroup = "group"; private const string ElemTitle = "title"; private const string ElemUserName = "username"; private const string ElemUrl = "url"; private const string ElemPassword = "password"; private const string ElemNotes = "notes"; private const string ElemUuid = "uuid"; private const string ElemImage = "image"; private const string ElemCreationTime = "creationtime"; private const string ElemLastModTime = "lastmodtime"; private const string ElemLastAccessTime = "lastaccesstime"; private const string ElemExpiryTime = "expiretime"; private const string ElemAttachDesc = "attachdesc"; private const string ElemAttachment = "attachment"; private const string AttribGroupTree = "tree"; private const string AttribExpires = "expires"; public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(sInput); XmlNode xmlRoot = xmlDoc.DocumentElement; Debug.Assert(xmlRoot.Name == ElemRoot); int nNodeCount = xmlRoot.ChildNodes.Count; for(int i = 0; i < nNodeCount; ++i) { XmlNode xmlChild = xmlRoot.ChildNodes[i]; if(xmlChild.Name == ElemEntry) ReadEntry(xmlChild, pwStorage); else { Debug.Assert(false); } if(slLogger != null) slLogger.SetProgress((uint)(((i + 1) * 100) / nNodeCount)); } } private static void ReadEntry(XmlNode xmlNode, PwDatabase pwStorage) { PwEntry pe = new PwEntry(true, true); PwGroup pg = pwStorage.RootGroup; string strAttachDesc = null, strAttachment = null; foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name == ElemGroup) { string strPreTree = null; try { XmlNode xmlTree = xmlChild.Attributes.GetNamedItem(AttribGroupTree); strPreTree = xmlTree.Value; } catch(Exception) { } string strLast = XmlUtil.SafeInnerText(xmlChild); string strGroup = ((!string.IsNullOrEmpty(strPreTree)) ? strPreTree + "\\" + strLast : strLast); pg = pwStorage.RootGroup.FindCreateSubTree(strGroup, new string[1]{ "\\" }, true); } else if(xmlChild.Name == ElemTitle) pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemUserName) pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwStorage.MemoryProtection.ProtectUserName, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemUrl) pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pwStorage.MemoryProtection.ProtectUrl, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemPassword) pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemNotes) pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemUuid) pe.SetUuid(new PwUuid(MemUtil.HexStringToByteArray( XmlUtil.SafeInnerText(xmlChild))), false); else if(xmlChild.Name == ElemImage) { int nImage; if(int.TryParse(XmlUtil.SafeInnerText(xmlChild), out nImage)) { if((nImage >= 0) && (nImage < (int)PwIcon.Count)) pe.IconId = (PwIcon)nImage; else { Debug.Assert(false); } } else { Debug.Assert(false); } } else if(xmlChild.Name == ElemCreationTime) pe.CreationTime = ParseTime(XmlUtil.SafeInnerText(xmlChild)); else if(xmlChild.Name == ElemLastModTime) pe.LastModificationTime = ParseTime(XmlUtil.SafeInnerText(xmlChild)); else if(xmlChild.Name == ElemLastAccessTime) pe.LastAccessTime = ParseTime(XmlUtil.SafeInnerText(xmlChild)); else if(xmlChild.Name == ElemExpiryTime) { try { XmlNode xmlExpires = xmlChild.Attributes.GetNamedItem(AttribExpires); if(StrUtil.StringToBool(xmlExpires.Value)) { pe.Expires = true; pe.ExpiryTime = ParseTime(XmlUtil.SafeInnerText(xmlChild)); } else { Debug.Assert(ParseTime(XmlUtil.SafeInnerText(xmlChild)).Year == 2999); } } catch(Exception) { Debug.Assert(false); } } else if(xmlChild.Name == ElemAttachDesc) strAttachDesc = XmlUtil.SafeInnerText(xmlChild); else if(xmlChild.Name == ElemAttachment) strAttachment = XmlUtil.SafeInnerText(xmlChild); else { Debug.Assert(false); } } if(!string.IsNullOrEmpty(strAttachDesc) && (strAttachment != null)) { byte[] pbData = Convert.FromBase64String(strAttachment); ProtectedBinary pb = new ProtectedBinary(false, pbData); pe.Binaries.Set(strAttachDesc, pb); } pg.AddEntry(pe, true); } private static DateTime ParseTime(string str) { if(string.IsNullOrEmpty(str)) { Debug.Assert(false); return DateTime.Now; } if(str == "0000-00-00T00:00:00") return DateTime.Now; DateTime dt; if(DateTime.TryParse(str, out dt)) return dt; Debug.Assert(false); return DateTime.Now; } } } keepass2-2.25/KeePass/DataExchange/Formats/PpKeeperHtml270.cs0000664000175000017500000001536012261553106023523 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Text.RegularExpressions; using System.Drawing; using System.IO; using System.Diagnostics; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 2.50 and 2.70 internal sealed class PpKeeperHtml270 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Passphrase Keeper HTML"; } } public override string DefaultExtension { get { return @"html|htm"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override bool ImportAppendsToRootGroupOnly { get { return true; } } public override Image SmallIcon { // Passphrase Keeper uses the same standard XP keys icon // as Whisper 32 get { return KeePass.Properties.Resources.B16x16_Imp_Whisper32; } } private const string m_strStartTd = ""; private const string m_strEndTd = @""; private const string m_strModifiedField = @"{0530D298-F983-454C-B5A3-BFB0775844D1}"; private const string m_strModifiedHdrStart = "Modified"; public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); string strData = sr.ReadToEnd(); sr.Close(); // Normalize 2.70 files strData = strData.Replace("", m_strStartTd); strData = strData.Replace("", m_strStartTd); strData = strData.Replace("", m_strStartTd); strData = strData.Replace("", m_strStartTd); strData = strData.Replace("", m_strStartTd); strData = strData.Replace("", m_strStartTd); // Additionally support the old version 2.50 string[] vRepl = new string[4]{ @"", @"", @"", @"" }; MatchCollection mc = Regex.Matches(strData, vRepl[2]); if((mc != null) && (mc.Count > 0)) { foreach(string strRepl in vRepl) strData = Regex.Replace(strData, strRepl, m_strStartTd); strData = strData.Replace("\r\n", m_strEndTd + "\r\n"); } int nOffset = 0; PwEntry peHeader; if(!ReadEntry(out peHeader, strData, ref nOffset, pwStorage)) { Debug.Assert(false); return; } while((nOffset >= 0) && (nOffset < strData.Length)) { PwEntry pe; if(!ReadEntry(out pe, strData, ref nOffset, pwStorage)) { Debug.Assert(false); break; } if(pe == null) break; pwStorage.RootGroup.AddEntry(pe, true); } } private static bool ReadEntry(out PwEntry pe, string strData, ref int nOffset, PwDatabase pd) { pe = new PwEntry(true, true); if(!ReadString(strData, ref nOffset, m_strStartTd, m_strEndTd, pe, null, false)) { pe = null; return true; } if(!ReadString(strData, ref nOffset, m_strStartTd, m_strEndTd, pe, PwDefs.TitleField, pd.MemoryProtection.ProtectTitle)) return false; if(!ReadString(strData, ref nOffset, m_strStartTd, m_strEndTd, pe, PwDefs.UserNameField, pd.MemoryProtection.ProtectUserName)) return false; if(!ReadString(strData, ref nOffset, m_strStartTd, m_strEndTd, pe, PwDefs.PasswordField, pd.MemoryProtection.ProtectPassword)) return false; if(!ReadString(strData, ref nOffset, m_strStartTd, m_strEndTd, pe, PwDefs.UrlField, pd.MemoryProtection.ProtectUrl)) return false; if(!ReadString(strData, ref nOffset, m_strStartTd, m_strEndTd, pe, PwDefs.NotesField, pd.MemoryProtection.ProtectNotes)) return false; if(!ReadString(strData, ref nOffset, m_strStartTd, m_strEndTd, pe, m_strModifiedField, false)) return false; return true; } private static bool ReadString(string strData, ref int nOffset, string strStart, string strEnd, PwEntry pe, string strFieldName, bool bProtect) { nOffset = strData.IndexOf(strStart, nOffset); if(nOffset < 0) return false; string strRawValue = StrUtil.GetStringBetween(strData, nOffset, strStart, strEnd); string strValue = strRawValue.Trim(); if(strValue == @"
") strValue = string.Empty; strValue = strValue.Replace("\r", string.Empty); strValue = strValue.Replace("\n", string.Empty); strValue = strValue.Replace(@"
", MessageService.NewLine); if((strFieldName != null) && (strFieldName == m_strModifiedField)) { DateTime dt = ReadModified(strValue); pe.CreationTime = dt; pe.LastModificationTime = dt; } else if(strFieldName != null) pe.Strings.Set(strFieldName, new ProtectedString(bProtect, strValue)); nOffset += strStart.Length + strRawValue.Length + strEnd.Length; return true; } private static DateTime ReadModified(string strValue) { if(strValue == null) { Debug.Assert(false); return DateTime.Now; } if(strValue.StartsWith(m_strModifiedHdrStart)) return DateTime.Now; string[] vParts = strValue.Split(new char[]{ ' ', ':', '/' }, StringSplitOptions.RemoveEmptyEntries); if(vParts.Length != 6) { Debug.Assert(false); return DateTime.Now; } try { return new DateTime(int.Parse(vParts[2]), int.Parse(vParts[0]), int.Parse(vParts[1]), int.Parse(vParts[3]), int.Parse(vParts[4]), int.Parse(vParts[5])); } catch(Exception) { Debug.Assert(false); } return DateTime.Now; } } } keepass2-2.25/KeePass/DataExchange/Formats/LastPassCsv2.cs0000664000175000017500000001155412261553106023223 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Drawing; using System.Diagnostics; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 2.0.2-2.0.20+ internal sealed class LastPassCsv2 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "LastPass CSV"; } } public override string DefaultExtension { get { return "csv"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override bool ImportAppendsToRootGroupOnly { get { return false; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_LastPass; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, StrUtil.Utf8, true); string strData = sr.ReadToEnd(); sr.Close(); CsvOptions opt = new CsvOptions(); opt.BackslashIsEscape = false; CsvStreamReaderEx csr = new CsvStreamReaderEx(strData, opt); while(true) { string[] vLine = csr.ReadLine(); if(vLine == null) break; AddEntry(vLine, pwStorage); } } private static void AddEntry(string[] vLine, PwDatabase pd) { Debug.Assert((vLine.Length == 0) || (vLine.Length == 7)); if(vLine.Length < 5) return; // Skip header line if((vLine[1] == "username") && (vLine[2] == "password") && (vLine[3] == "extra") && (vLine[4] == "name")) return; PwEntry pe = new PwEntry(true, true); PwGroup pg = pd.RootGroup; if(vLine.Length >= 6) { string strGroup = vLine[5]; if(strGroup.Length > 0) pg = pg.FindCreateSubTree(strGroup, new string[1]{ "\\" }, true); } pg.AddEntry(pe, true); ImportUtil.AppendToField(pe, PwDefs.TitleField, vLine[4], pd); ImportUtil.AppendToField(pe, PwDefs.UserNameField, vLine[1], pd); ImportUtil.AppendToField(pe, PwDefs.PasswordField, vLine[2], pd); string strNotes = vLine[3]; bool bIsSecNote = vLine[0].Equals("http://sn", StrUtil.CaseIgnoreCmp); if(bIsSecNote) { if(strNotes.StartsWith("NoteType:", StrUtil.CaseIgnoreCmp)) AddNoteFields(pe, strNotes, pd); else ImportUtil.AppendToField(pe, PwDefs.NotesField, strNotes, pd); } else // Standard entry, no secure note { ImportUtil.AppendToField(pe, PwDefs.UrlField, vLine[0], pd); Debug.Assert(!strNotes.StartsWith("NoteType:")); ImportUtil.AppendToField(pe, PwDefs.NotesField, strNotes, pd); } if(vLine.Length >= 7) { if(StrUtil.StringToBool(vLine[6])) pe.AddTag("Favorite"); } } private static void AddNoteFields(PwEntry pe, string strNotes, PwDatabase pd) { string strData = StrUtil.NormalizeNewLines(strNotes, false); string[] vLines = strData.Split('\n'); string strFieldName = PwDefs.NotesField; bool bNotesFound = false; foreach(string strLine in vLines) { int iFieldLen = strLine.IndexOf(':'); int iDataOffset = 0; if((iFieldLen > 0) && !bNotesFound) { string strRaw = strLine.Substring(0, iFieldLen).Trim(); string strField = ImportUtil.MapNameToStandardField(strRaw, false); if(string.IsNullOrEmpty(strField)) strField = strRaw; if(strField.Length > 0) { strFieldName = strField; iDataOffset = iFieldLen + 1; bNotesFound |= (strRaw == "Notes"); // Not PwDefs.NotesField } } bool bSingle = ((strFieldName == PwDefs.TitleField) || (strFieldName == PwDefs.UserNameField) || (strFieldName == PwDefs.PasswordField) || (strFieldName == PwDefs.UrlField)); string strSep = (bSingle ? ", " : "\r\n"); ImportUtil.AppendToField(pe, strFieldName, strLine.Substring( iDataOffset), pd, strSep, bSingle); } } } } keepass2-2.25/KeePass/DataExchange/Formats/OnePwProCsv599.cs0000664000175000017500000001505312261553106023365 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using System.Globalization; using System.Drawing; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 1Password Pro 5.99 and 1PW 6.15-7.05+ internal sealed class OnePwProCsv599 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return @"1PW & 1Password Pro CSV"; } } public override string DefaultExtension { get { return "csv"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override bool ImportAppendsToRootGroupOnly { get { return false; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_OnePwPro; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default, true); string strData = sr.ReadToEnd(); sr.Close(); string[] vLines = strData.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); Dictionary dictGroups = new Dictionary(); foreach(string strLine in vLines) { ProcessCsvLine(strLine, pwStorage, dictGroups); } } private static void ProcessCsvLine(string strLine, PwDatabase pwStorage, Dictionary dictGroups) { if(strLine == "\"Bezeichnung\"\t\"User/ID\"\t\"1.Passwort\"\t\"Url/Programm\"\t\"Geändert am\"\t\"Bemerkung\"\t\"2.Passwort\"\t\"Läuft ab\"\t\"Kategorie\"\t\"Eigene Felder\"") return; string str = strLine; if(str.StartsWith("\"") && str.EndsWith("\"")) str = str.Substring(1, str.Length - 2); else { Debug.Assert(false); } string[] list = str.Split(new string[]{ "\"\t\"" }, StringSplitOptions.None); int iOffset; if(list.Length == 11) iOffset = 0; // 1Password Pro 5.99 else if(list.Length == 10) iOffset = -1; // 1PW 6.15 else if(list.Length > 11) iOffset = 0; // Unknown extension else return; string strGroup = list[9 + iOffset]; PwGroup pg; if(dictGroups.ContainsKey(strGroup)) pg = dictGroups[strGroup]; else { pg = new PwGroup(true, true, strGroup, PwIcon.Folder); pwStorage.RootGroup.AddGroup(pg, true); dictGroups[strGroup] = pg; } PwEntry pe = new PwEntry(true, true); pg.AddEntry(pe, true); pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, ParseCsvWord(list[1 + iOffset]))); pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwStorage.MemoryProtection.ProtectUserName, ParseCsvWord(list[2 + iOffset]))); pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, ParseCsvWord(list[3 + iOffset]))); pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pwStorage.MemoryProtection.ProtectUrl, ParseCsvWord(list[4 + iOffset]))); pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, ParseCsvWord(list[6 + iOffset]))); pe.Strings.Set(PwDefs.PasswordField + " 2", new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, ParseCsvWord(list[7 + iOffset]))); // 1Password Pro only: // Debug.Assert(list[9] == list[0]); // Very mysterious format... DateTime dt; if(ParseDateTime(list[5 + iOffset], out dt)) { pe.CreationTime = pe.LastAccessTime = pe.LastModificationTime = dt; } else { Debug.Assert(false); } if(ParseDateTime(list[8 + iOffset], out dt)) { pe.Expires = true; pe.ExpiryTime = dt; } AddCustomFields(pe, list[10 + iOffset]); } private static string ParseCsvWord(string strWord) { string str = strWord; str = str.Replace("\\r", string.Empty); str = str.Replace("\\n", "\r\n"); return str; } private static bool ParseDateTime(string str, out DateTime dt) { dt = DateTime.MinValue; if(string.IsNullOrEmpty(str)) return false; if(str.Trim().Equals("nie", StrUtil.CaseIgnoreCmp)) return false; if(str.Trim().Equals("never", StrUtil.CaseIgnoreCmp)) return false; if(str.Trim().Equals("morgen", StrUtil.CaseIgnoreCmp)) { dt = DateTime.Now.AddDays(1.0); return true; } string[] list = str.Split(new char[]{ '.', '\r', '\n', ' ', '\t', '-', ':' }, StringSplitOptions.RemoveEmptyEntries); try { if(list.Length == 6) dt = new DateTime(int.Parse(list[2]), int.Parse(list[1]), int.Parse(list[0]), int.Parse(list[3]), int.Parse(list[4]), int.Parse(list[5])); else if(list.Length == 3) dt = new DateTime(int.Parse(list[2]), int.Parse(list[1]), int.Parse(list[0])); else { Debug.Assert(false); return false; } } catch(Exception) { Debug.Assert(false); return false; } return true; } private static void AddCustomFields(PwEntry pe, string strCustom) { string[] vItems = strCustom.Split(new string[] { @"|~#~|" }, StringSplitOptions.RemoveEmptyEntries); foreach(string strItem in vItems) { string[] vData = strItem.Split(new char[] { '|' }, StringSplitOptions.None); if(vData.Length >= 3) { string strValue = vData[2]; for(int i = 3; i < vData.Length; ++i) strValue += @"|" + vData[i]; pe.Strings.Set(vData[1], new ProtectedString(false, strValue)); } else { Debug.Assert(false); } } } } } keepass2-2.25/KeePass/DataExchange/Formats/KeePassXXml041.cs0000664000175000017500000001656212261553106023330 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using System.Xml; using System.Xml.Serialization; using System.Diagnostics; using KeePass.Resources; using KeePass.Util; using KeePassLib; using KeePassLib.Collections; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Serialization; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 0.4.1 internal sealed class KeePassXXml041 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "KeePassX XML"; } } public override string DefaultExtension { get { return "xml"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override bool SupportsUuids { get { return false; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_KeePassX; } } private const string ElemRoot = "database"; private const string ElemGroup = "group"; private const string ElemTitle = "title"; private const string ElemIcon = "icon"; private const string ElemEntry = "entry"; private const string ElemUserName = "username"; private const string ElemUrl = "url"; private const string ElemPassword = "password"; private const string ElemNotes = "comment"; private const string ElemCreationTime = "creation"; private const string ElemLastModTime = "lastmod"; private const string ElemLastAccessTime = "lastaccess"; private const string ElemExpiryTime = "expire"; private const string ElemAttachDesc = "bindesc"; private const string ElemAttachment = "bin"; private const string ValueNever = "Never"; public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(sInput); XmlNode xmlRoot = xmlDoc.DocumentElement; Debug.Assert(xmlRoot.Name == ElemRoot); Stack vGroups = new Stack(); vGroups.Push(pwStorage.RootGroup); int nNodeCount = xmlRoot.ChildNodes.Count; for(int i = 0; i < nNodeCount; ++i) { XmlNode xmlChild = xmlRoot.ChildNodes[i]; if(xmlChild.Name == ElemGroup) ReadGroup(xmlChild, vGroups, pwStorage); else { Debug.Assert(false); } if(slLogger != null) slLogger.SetProgress((uint)(((i + 1) * 100) / nNodeCount)); } } private static PwIcon ReadIcon(XmlNode xmlChild, PwIcon pwDefault) { int nIcon; if(StrUtil.TryParseInt(XmlUtil.SafeInnerText(xmlChild), out nIcon)) { if((nIcon >= 0) && (nIcon < (int)PwIcon.Count)) return (PwIcon)nIcon; } else { Debug.Assert(false); } return pwDefault; } private static void ReadGroup(XmlNode xmlNode, Stack vGroups, PwDatabase pwStorage) { if(vGroups.Count == 0) { Debug.Assert(false); return; } PwGroup pgParent = vGroups.Peek(); PwGroup pg = new PwGroup(true, true); pgParent.AddGroup(pg, true); vGroups.Push(pg); foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name == ElemTitle) pg.Name = XmlUtil.SafeInnerText(xmlChild); else if(xmlChild.Name == ElemIcon) pg.IconId = ReadIcon(xmlChild, pg.IconId); else if(xmlChild.Name == ElemGroup) ReadGroup(xmlChild, vGroups, pwStorage); else if(xmlChild.Name == ElemEntry) ReadEntry(xmlChild, pg, pwStorage); else { Debug.Assert(false); } } vGroups.Pop(); } private static void ReadEntry(XmlNode xmlNode, PwGroup pgParent, PwDatabase pwStorage) { PwEntry pe = new PwEntry(true, true); pgParent.AddEntry(pe, true); string strAttachDesc = null, strAttachment = null; foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name == ElemTitle) pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemUserName) pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwStorage.MemoryProtection.ProtectUserName, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemUrl) pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pwStorage.MemoryProtection.ProtectUrl, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemPassword) pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemNotes) pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, FilterSpecial(XmlUtil.SafeInnerXml(xmlChild)))); else if(xmlChild.Name == ElemIcon) pe.IconId = ReadIcon(xmlChild, pe.IconId); else if(xmlChild.Name == ElemCreationTime) pe.CreationTime = ParseTime(XmlUtil.SafeInnerText(xmlChild)); else if(xmlChild.Name == ElemLastModTime) pe.LastModificationTime = ParseTime(XmlUtil.SafeInnerText(xmlChild)); else if(xmlChild.Name == ElemLastAccessTime) pe.LastAccessTime = ParseTime(XmlUtil.SafeInnerText(xmlChild)); else if(xmlChild.Name == ElemExpiryTime) { string strDate = XmlUtil.SafeInnerText(xmlChild); pe.Expires = (strDate != ValueNever); if(pe.Expires) pe.ExpiryTime = ParseTime(strDate); } else if(xmlChild.Name == ElemAttachDesc) strAttachDesc = XmlUtil.SafeInnerText(xmlChild); else if(xmlChild.Name == ElemAttachment) strAttachment = XmlUtil.SafeInnerText(xmlChild); else { Debug.Assert(false); } } if(!string.IsNullOrEmpty(strAttachDesc) && (strAttachment != null)) { byte[] pbData = Convert.FromBase64String(strAttachment); ProtectedBinary pb = new ProtectedBinary(false, pbData); pe.Binaries.Set(strAttachDesc, pb); } } private static DateTime ParseTime(string str) { if(string.IsNullOrEmpty(str)) { Debug.Assert(false); return DateTime.Now; } if(str == "0000-00-00T00:00:00") return DateTime.Now; DateTime dt; if(DateTime.TryParse(str, out dt)) return dt; Debug.Assert(false); return DateTime.Now; } private static string FilterSpecial(string strData) { string str = strData; str = str.Replace(@"
", MessageService.NewLine); str = str.Replace(@"
", MessageService.NewLine); str = StrUtil.XmlToString(str); return str; } } } keepass2-2.25/KeePass/DataExchange/Formats/RoboFormHtml69.cs0000664000175000017500000001521612261553106023463 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using System.Windows.Forms; using System.Diagnostics; using KeePass.Resources; using KeePass.UI; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 6.9.82-7.9.2.5+ internal sealed class RoboFormHtml69 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "RoboForm HTML (Logins/PassCards)"; } } public override string DefaultExtension { get { return @"html|htm"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_RoboForm; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Unicode); string strData = sr.ReadToEnd(); sr.Close(); strData = strData.Replace(@"", string.Empty); strData = strData.Replace(@"­", string.Empty); WebBrowser wb = new WebBrowser(); try { wb.Visible = false; wb.ScriptErrorsSuppressed = true; UIUtil.SetWebBrowserDocument(wb, strData); ImportPriv(pwStorage, wb.Document.Body); } finally { wb.Dispose(); } } private static string ParseTitle(string strTitle, PwDatabase pd, out PwGroup pg) { pg = pd.RootGroup; if(strTitle.IndexOf('\\') >= 0) { int nLast = strTitle.LastIndexOf('\\'); string strTree = strTitle.Substring(0, nLast); pg = pd.RootGroup.FindCreateSubTree(strTree, new string[1] { "\\" }, true); return strTitle.Substring(nLast + 1); } return strTitle; } private static string MapKey(string strKey) { string s = ImportUtil.MapNameToStandardField(strKey, true); if(string.IsNullOrEmpty(s)) return strKey; if((s == PwDefs.TitleField) || (s == PwDefs.UrlField)) return strKey; return s; } private static List GetElements(HtmlElement hRoot, string strTagName, string strAttribName, string strAttribValue) { List l = new List(); if(hRoot == null) { Debug.Assert(false); return l; } if(string.IsNullOrEmpty(strTagName)) { Debug.Assert(false); return l; } foreach(HtmlElement hEl in hRoot.GetElementsByTagName(strTagName)) { if(!string.IsNullOrEmpty(strAttribName) && (strAttribValue != null)) { string strValue = XmlUtil.SafeAttribute(hEl, strAttribName); if(!strValue.Equals(strAttribValue, StrUtil.CaseIgnoreCmp)) continue; } l.Add(hEl); } return l; } private static void ImportPriv(PwDatabase pd, HtmlElement hBody) { #if DEBUG bool bHasSpanCaptions = (GetElements(hBody, "SPAN", "class", "caption").Count > 0); #endif foreach(HtmlElement hTable in hBody.GetElementsByTagName("TABLE")) { Debug.Assert(XmlUtil.SafeAttribute(hTable, "width") == "100%"); string strRules = XmlUtil.SafeAttribute(hTable, "rules"); string strFrame = XmlUtil.SafeAttribute(hTable, "frame"); if(strRules.Equals("cols", StrUtil.CaseIgnoreCmp) && strFrame.Equals("void", StrUtil.CaseIgnoreCmp)) continue; PwEntry pe = new PwEntry(true, true); PwGroup pg = null; bool bNotesHeaderFound = false; foreach(HtmlElement hTr in hTable.GetElementsByTagName("TR")) { // 7.9.1.1+ List lCaption = GetElements(hTr, "SPAN", "class", "caption"); if(lCaption.Count == 0) lCaption = GetElements(hTr, "DIV", "class", "caption"); if(lCaption.Count > 0) { string strTitle = ParseTitle(XmlUtil.SafeInnerText( lCaption[0]), pd, out pg); ImportUtil.AppendToField(pe, PwDefs.TitleField, strTitle, pd); continue; // Data is in next TR } // 7.9.1.1+ if(hTr.GetElementsByTagName("TABLE").Count > 0) continue; HtmlElementCollection lTd = hTr.GetElementsByTagName("TD"); if(lTd.Count == 1) { HtmlElement e = lTd[0]; string strText = XmlUtil.SafeInnerText(e); string strClass = XmlUtil.SafeAttribute(e, "class"); if(strClass.Equals("caption", StrUtil.CaseIgnoreCmp)) { Debug.Assert(pg == null); strText = ParseTitle(strText, pd, out pg); ImportUtil.AppendToField(pe, PwDefs.TitleField, strText, pd); } else if(strClass.Equals("subcaption", StrUtil.CaseIgnoreCmp)) ImportUtil.AppendToField(pe, PwDefs.UrlField, ImportUtil.FixUrl(strText), pd); else if(strClass.Equals("field", StrUtil.CaseIgnoreCmp)) { // 7.9.2.5+ if(strText.EndsWith(":") && !bNotesHeaderFound) bNotesHeaderFound = true; else ImportUtil.AppendToField(pe, PwDefs.NotesField, strText.Trim(), pd, MessageService.NewLine, false); } else { Debug.Assert(false); } } else if((lTd.Count == 2) || (lTd.Count == 3)) { string strKey = XmlUtil.SafeInnerText(lTd[0]); string strValue = XmlUtil.SafeInnerText(lTd[lTd.Count - 1]); if(lTd.Count == 3) { Debug.Assert(string.IsNullOrEmpty(lTd[1].InnerText)); } if(strKey.EndsWith(":")) // 7.9.1.1+ strKey = strKey.Substring(0, strKey.Length - 1); if(strKey.Length > 0) ImportUtil.AppendToField(pe, MapKey(strKey), strValue, pd); else { Debug.Assert(false); } } else { Debug.Assert(false); } } if(pg != null) pg.AddEntry(pe, true); #if DEBUG else { Debug.Assert(bHasSpanCaptions); } #endif } } } } keepass2-2.25/KeePass/DataExchange/Formats/PwTresorXml100.cs0000664000175000017500000001051412261553106023415 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml; using System.Drawing; using System.IO; using System.Diagnostics; using KeePass.Resources; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; namespace KeePass.DataExchange.Formats { // 1.0.2001.157 internal sealed class PwTresorXml100 : FileFormatProvider { private const string ElemGroup = "Group"; private const string ElemGroupName = "groupname"; private const string ElemEntry = "PassItem"; private const string ElemEntryName = "itemname"; private const string ElemEntryUser = "username"; private const string ElemEntryPassword = "password"; private const string ElemEntryURL = "url"; private const string ElemEntryNotes = "description"; public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Passwort.Tresor XML"; } } public override string DefaultExtension { get { return "xml"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_PwTresor; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(sr); XmlNode xmlRoot = xmlDoc.DocumentElement; foreach(XmlNode xmlChild in xmlRoot.ChildNodes) { if(xmlChild.Name == ElemGroup) ReadGroup(xmlChild, pwStorage.RootGroup, pwStorage); else { Debug.Assert(false); } } } private static void ReadGroup(XmlNode xmlNode, PwGroup pgParent, PwDatabase pwStorage) { PwGroup pg = new PwGroup(true, true); pgParent.AddGroup(pg, true); foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name == ElemGroupName) pg.Name = XmlUtil.SafeInnerText(xmlChild); else if(xmlChild.Name == ElemGroup) ReadGroup(xmlChild, pg, pwStorage); else if(xmlChild.Name == ElemEntry) ReadEntry(xmlChild, pg, pwStorage); else { Debug.Assert(false); } } } private static void ReadEntry(XmlNode xmlNode, PwGroup pgParent, PwDatabase pwStorage) { PwEntry pe = new PwEntry(true, true); pgParent.AddEntry(pe, true); foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name == ElemEntryName) pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemEntryUser) pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwStorage.MemoryProtection.ProtectUserName, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemEntryPassword) pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemEntryURL) pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pwStorage.MemoryProtection.ProtectUrl, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemEntryNotes) pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, XmlUtil.SafeInnerText(xmlChild))); else { Debug.Assert(false); } } } } } keepass2-2.25/KeePass/DataExchange/Formats/HandySafeTxt512.cs0000664000175000017500000001070512261553106023522 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using System.Diagnostics; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 5.12 internal sealed class HandySafeTxt512 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Handy Safe TXT"; } } public override string DefaultExtension { get { return "txt"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_HandySafe; } } private const string StrGroupStart = "[Category: "; private const string StrGroupEnd = "]"; private const string StrEntryStart = "[Card, "; private const string StrEntryEnd = "]"; private const string StrNotesBegin = "Note:"; private const string StrFieldSplit = ": "; public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); string strData = sr.ReadToEnd(); sr.Close(); strData = strData.Replace("\r", string.Empty); string[] vLines = strData.Split(new char[] { '\n' }); PwGroup pg = pwStorage.RootGroup; Dictionary dItems = new Dictionary(); bool bInNotes = false; foreach(string strLine in vLines) { if(strLine.StartsWith(StrGroupStart) && strLine.EndsWith(StrGroupEnd)) { AddEntry(pg, dItems, ref bInNotes); dItems.Clear(); pg = new PwGroup(true, true); pg.Name = strLine.Substring(StrGroupStart.Length, strLine.Length - StrGroupStart.Length - StrGroupEnd.Length); pwStorage.RootGroup.AddGroup(pg, true); } else if(strLine.StartsWith(StrEntryStart) && strLine.EndsWith(StrEntryEnd)) { AddEntry(pg, dItems, ref bInNotes); dItems.Clear(); } else if(strLine == StrNotesBegin) bInNotes = true; else if(bInNotes) { if(dItems.ContainsKey(PwDefs.NotesField)) dItems[PwDefs.NotesField] += MessageService.NewLine + strLine; else dItems[PwDefs.NotesField] = strLine; } else { int nSplitPos = strLine.IndexOf(StrFieldSplit); if(nSplitPos < 0) { Debug.Assert(false); } else { AddField(dItems, strLine.Substring(0, nSplitPos), strLine.Substring(nSplitPos + StrFieldSplit.Length)); } } } AddEntry(pg, dItems, ref bInNotes); } private static void AddField(Dictionary dItems, string strKey, string strValue) { string strKeyTrl = ImportUtil.MapNameToStandardField(strKey, true); if(string.IsNullOrEmpty(strKeyTrl)) strKeyTrl = strKey; if(!dItems.ContainsKey(strKeyTrl)) { dItems[strKeyTrl] = strValue; return; } string strPreValue = dItems[strKeyTrl]; if((strPreValue.Length > 0) && (strValue.Length > 0)) strPreValue += ", "; dItems[strKeyTrl] = strPreValue + strValue; } private static void AddEntry(PwGroup pg, Dictionary dItems, ref bool bInNotes) { if(dItems.Count == 0) return; PwEntry pe = new PwEntry(true, true); pg.AddEntry(pe, true); foreach(KeyValuePair kvp in dItems) pe.Strings.Set(kvp.Key, new ProtectedString(false, kvp.Value)); bInNotes = false; } } } keepass2-2.25/KeePass/DataExchange/Formats/SafeWalletXml3.cs0000664000175000017500000001465712261553106023535 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml; using System.IO; using System.Drawing; using System.Diagnostics; using KeePass.Resources; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; namespace KeePass.DataExchange.Formats { // 2.4.1.2-3.0.7.2022+ internal sealed class SafeWalletXml3 : FileFormatProvider { private static readonly string[] ElemsVault = new string[] { "T37" // 3.0.5 }; private static readonly string[] ElemsGroup = new string[] { "Folder", // 2.4.1.2 "T3", // 3.0.5 "T21" // 3.0.7, special group for web entries }; private static readonly string[] ElemsEntry = new string[] { "Card", // 3.0.4 "T4" // 3.0.5 }; private static readonly string[] ElemsProps = new string[] { "Property", // 3.0.4 "T257", "T258", "T259", "T263", "T264", "T265", // 3.0.5 "T266", "T267" // 3.0.5 }; private static readonly string[] ElemsWebEntry = new string[] { "T22" // 3.0.7 }; private const string AttribCaption = "Caption"; private const string AttribWebUrl = "URL"; private const string AttribWebUserName = "Username"; private const string AttribWebPassword = "Password"; public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "SafeWallet XML"; } } public override string DefaultExtension { get { return "xml"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override bool ImportAppendsToRootGroupOnly { get { return false; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_SafeWallet; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Unicode); string strDoc = sr.ReadToEnd(); sr.Close(); XmlDocument xd = new XmlDocument(); xd.LoadXml(strDoc); XmlNode xnRoot = xd.DocumentElement; Debug.Assert(xnRoot.Name == "SafeWallet"); foreach(XmlNode xn in xnRoot.ChildNodes) { if(Array.IndexOf(ElemsGroup, xn.Name) >= 0) AddGroup(xn, pwStorage.RootGroup, pwStorage); // 2.4.1.2 else if(Array.IndexOf(ElemsEntry, xn.Name) >= 0) AddEntry(xn, pwStorage.RootGroup, pwStorage); // 3.0.4 else if(Array.IndexOf(ElemsVault, xn.Name) >= 0) ImportVault(xn, pwStorage); // 3.0.5 } } private static void AddEntry(XmlNode xnEntry, PwGroup pg, PwDatabase pd) { PwEntry pe = new PwEntry(true, true); pg.AddEntry(pe, true); XmlNode xnTitle = xnEntry.Attributes.GetNamedItem(AttribCaption); string strTitle = ((xnTitle != null) ? xnTitle.Value : string.Empty); ImportUtil.AppendToField(pe, PwDefs.TitleField, strTitle ?? string.Empty, pd); foreach(XmlNode xn in xnEntry.ChildNodes) { if(Array.IndexOf(ElemsProps, xn.Name) >= 0) { XmlNode xnField = xn.Attributes.GetNamedItem(AttribCaption); string strField = ((xnField != null) ? xnField.Value : null); if(string.IsNullOrEmpty(strField)) { Debug.Assert(false); } else { string strMap = ImportUtil.MapNameToStandardField(strField, false); if(string.IsNullOrEmpty(strMap)) strMap = strField; ImportUtil.AppendToField(pe, strMap, XmlUtil.SafeInnerText(xn), pd); } } else { Debug.Assert(false); } // Unknown node } } private static void AddWebEntry(XmlNode xnEntry, PwGroup pg, PwDatabase pd) { PwEntry pe = new PwEntry(true, true); pg.AddEntry(pe, true); XmlNode xn = xnEntry.Attributes.GetNamedItem(AttribCaption); string str = ((xn != null) ? xn.Value : string.Empty); ImportUtil.AppendToField(pe, PwDefs.TitleField, str ?? string.Empty, pd); xn = xnEntry.Attributes.GetNamedItem(AttribWebUrl); str = ((xn != null) ? xn.Value : string.Empty); ImportUtil.AppendToField(pe, PwDefs.UrlField, str ?? string.Empty, pd); xn = xnEntry.Attributes.GetNamedItem(AttribWebUserName); str = ((xn != null) ? xn.Value : string.Empty); ImportUtil.AppendToField(pe, PwDefs.UserNameField, str ?? string.Empty, pd); xn = xnEntry.Attributes.GetNamedItem(AttribWebPassword); str = ((xn != null) ? xn.Value : string.Empty); ImportUtil.AppendToField(pe, PwDefs.PasswordField, str ?? string.Empty, pd); } private static void ImportVault(XmlNode xnVault, PwDatabase pd) { foreach(XmlNode xn in xnVault.ChildNodes) { if(Array.IndexOf(ElemsGroup, xn.Name) >= 0) AddGroup(xn, pd.RootGroup, pd); else if(Array.IndexOf(ElemsEntry, xn.Name) >= 0) AddEntry(xn, pd.RootGroup, pd); else { Debug.Assert(false); } // Unknown node } } private static void AddGroup(XmlNode xnGrp, PwGroup pgParent, PwDatabase pd) { XmlNode xnName = xnGrp.Attributes.GetNamedItem(AttribCaption); string strName = ((xnName != null) ? xnName.Value : null); if(string.IsNullOrEmpty(strName)) { Debug.Assert(false); strName = KPRes.Group; } PwGroup pg = new PwGroup(true, true); pg.Name = strName; pgParent.AddGroup(pg, true); foreach(XmlNode xn in xnGrp) { if(Array.IndexOf(ElemsGroup, xn.Name) >= 0) AddGroup(xn, pg, pd); else if(Array.IndexOf(ElemsEntry, xn.Name) >= 0) AddEntry(xn, pg, pd); else if(Array.IndexOf(ElemsWebEntry, xn.Name) >= 0) AddWebEntry(xn, pg, pd); else { Debug.Assert(false); } // Unknown node } } } } keepass2-2.25/KeePass/DataExchange/Formats/DashlaneCsv2.cs0000664000175000017500000001304512261553106023205 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Text.RegularExpressions; using System.IO; using System.Drawing; using System.Diagnostics; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Native; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 2.3.2+ internal sealed class DashlaneCsv2 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Dashlane CSV"; } } public override string DefaultExtension { get { return "csv"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override bool ImportAppendsToRootGroupOnly { get { return true; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_Dashlane; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, StrUtil.Utf8, true); string str = sr.ReadToEnd(); sr.Close(); // All fields are enclosed in '"', however '"' in data is // not encoded (broken format) str = str.Trim(); str = StrUtil.NormalizeNewLines(str, false); // To Unix char chFieldSep = StrUtil.GetUnusedChar(str); str = str.Replace("\",\"", new string(chFieldSep, 1)); char chRecSep = StrUtil.GetUnusedChar(str); str = str.Replace("\"\n\"", new string(chRecSep, 1)); if(str.StartsWith("\"") && str.EndsWith("\"") && (str.Length >= 2)) str = str.Substring(1, str.Length - 2); else { Debug.Assert(false); } if(!NativeLib.IsUnix()) str = StrUtil.NormalizeNewLines(str, true); CsvOptions opt = new CsvOptions(); opt.BackslashIsEscape = false; opt.FieldSeparator = chFieldSep; opt.RecordSeparator = chRecSep; opt.TextQualifier = char.MinValue; CsvStreamReaderEx csr = new CsvStreamReaderEx(str, opt); while(true) { string[] vLine = csr.ReadLine(); if(vLine == null) break; AddEntry(vLine, pwStorage); } } private static Regex m_rxIsDate = null; private static Regex m_rxIsGuid = null; private static void AddEntry(string[] vLine, PwDatabase pd) { int n = vLine.Length; if(n == 0) return; PwEntry pe = new PwEntry(true, true); pd.RootGroup.AddEntry(pe, true); string[] vFields = null; if(n == 2) vFields = new string[2] { PwDefs.TitleField, PwDefs.UrlField }; else if(n == 3) vFields = new string[3] { PwDefs.TitleField, PwDefs.UrlField, PwDefs.UserNameField }; else if(n == 4) { if((vLine[2].Length == 0) && (vLine[3].Length == 0)) vFields = new string[4] { PwDefs.TitleField, PwDefs.UserNameField, PwDefs.NotesField, PwDefs.NotesField }; else vFields = new string[4] { PwDefs.TitleField, PwDefs.NotesField, PwDefs.UserNameField, PwDefs.NotesField }; } else if(n == 5) vFields = new string[5] { PwDefs.TitleField, PwDefs.UrlField, PwDefs.UserNameField, PwDefs.PasswordField, PwDefs.NotesField }; else if(n == 6) vFields = new string[6] { PwDefs.TitleField, PwDefs.UrlField, PwDefs.UserNameField, PwDefs.UserNameField, PwDefs.PasswordField, PwDefs.NotesField }; else if(n == 7) vFields = new string[7] { PwDefs.TitleField, PwDefs.UserNameField, PwDefs.NotesField, PwDefs.NotesField, PwDefs.NotesField, PwDefs.NotesField, PwDefs.NotesField }; if(m_rxIsDate == null) { m_rxIsDate = new Regex(@"^\d{4}-\d+-\d+$"); m_rxIsGuid = new Regex( @"^\{[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\}$"); } if((vLine[0].Length == 0) && (n >= 2) && m_rxIsDate.IsMatch(vLine[1])) { vFields = null; vLine[0] = KPRes.Id; for(int i = 1; i < n; ++i) { string strPart = vLine[i]; if(strPart.Equals("NO_TYPE", StrUtil.CaseIgnoreCmp) || m_rxIsGuid.IsMatch(strPart)) vLine[i] = string.Empty; } } for(int i = 0; i < n; ++i) { string str = vLine[i]; if(str.Length == 0) continue; if(str.Equals("dashlaneappcredential", StrUtil.CaseIgnoreCmp)) continue; string strField = ((vFields != null) ? vFields[i] : null); if(strField == null) { if(i == 0) strField = PwDefs.TitleField; else strField = PwDefs.NotesField; } if((strField == PwDefs.UrlField) && (str.IndexOf('.') >= 0)) str = ImportUtil.FixUrl(str); ImportUtil.AppendToField(pe, strField, str, pd, ((strField == PwDefs.NotesField) ? MessageService.NewLine : ", "), false); } } } } keepass2-2.25/KeePass/DataExchange/Formats/AnyPwCsv144.cs0000664000175000017500000001003312261553106022665 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using System.Globalization; using System.Drawing; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; namespace KeePass.DataExchange.Formats { // 1.44 & Pro 1.07 internal sealed class AnyPwCsv144 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Any Password CSV"; } } public override string DefaultExtension { get { return "csv"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override bool ImportAppendsToRootGroupOnly { get { return true; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_AnyPw; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); string strData = sr.ReadToEnd(); sr.Close(); string[] vLines = strData.Split(new char[]{ '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach(string strLine in vLines) { if(strLine.Length > 5) ProcessCsvLine(strLine, pwStorage); } } private static void ProcessCsvLine(string strLine, PwDatabase pwStorage) { List list = ImportUtil.SplitCsvLine(strLine, ","); Debug.Assert((list.Count == 6) || (list.Count == 7)); if(list.Count < 6) return; bool bIsPro = (list.Count >= 7); // Std exports 6 fields only PwEntry pe = new PwEntry(true, true); pwStorage.RootGroup.AddEntry(pe, true); pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, ParseCsvWord(list[0], false))); pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwStorage.MemoryProtection.ProtectUserName, ParseCsvWord(list[1], false))); pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, ParseCsvWord(list[2], false))); pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pwStorage.MemoryProtection.ProtectUrl, ParseCsvWord(list[3], false))); int p = 3; if(bIsPro) pe.Strings.Set(KPRes.Custom, new ProtectedString(false, ParseCsvWord(list[++p], false))); pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, ParseCsvWord(list[++p], true))); DateTime dt; if(DateTime.TryParse(ParseCsvWord(list[++p], false), out dt)) pe.CreationTime = pe.LastAccessTime = pe.LastModificationTime = dt; else { Debug.Assert(false); } } private static string ParseCsvWord(string strWord, bool bFixCodes) { string str = strWord.Trim(); if((str.Length >= 2) && str.StartsWith("\"") && str.EndsWith("\"")) str = str.Substring(1, str.Length - 2); str = str.Replace("\"\"", "\""); if(bFixCodes) { str = str.Replace("<13>", string.Empty); str = str.Replace("<10>", "\r\n"); } return str; } } } keepass2-2.25/KeePass/DataExchange/Formats/CodeWalletTxt605.cs0000664000175000017500000000710212261553106023703 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Windows.Forms; using System.Diagnostics; using System.Drawing; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 6.05-6.62+ internal sealed class CodeWalletTxt605 : FileFormatProvider { private const string FieldSeparator = "*---------------------------------------------------"; public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "CodeWallet TXT"; } } public override string DefaultExtension { get { return "txt"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override bool ImportAppendsToRootGroupOnly { get { return true; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_CWallet; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Unicode); string strData = sr.ReadToEnd(); sr.Close(); string[] vLines = strData.Split(new char[]{ '\r', '\n' }); bool bDoImport = false; PwEntry pe = new PwEntry(true, true); bool bInnerSep = false; bool bEmptyEntry = true; string strLastIndexedItem = string.Empty; string strLastLine = string.Empty; foreach(string strLine in vLines) { if(strLine.Length == 0) continue; if(strLine == FieldSeparator) { bInnerSep = !bInnerSep; if(bInnerSep && !bEmptyEntry) { pwStorage.RootGroup.AddEntry(pe, true); pe = new PwEntry(true, true); bEmptyEntry = true; } else if(!bInnerSep) pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, strLastLine)); bDoImport = true; } else if(bDoImport) { int nIDLen = strLine.IndexOf(": "); if(nIDLen > 0) { string strIndex = strLine.Substring(0, nIDLen); if(PwDefs.IsStandardField(strIndex)) strIndex = Guid.NewGuid().ToString(); pe.Strings.Set(strIndex, new ProtectedString( false, strLine.Remove(0, nIDLen + 2))); strLastIndexedItem = strIndex; } else if(!bEmptyEntry) { pe.Strings.Set(strLastIndexedItem, new ProtectedString( false, pe.Strings.ReadSafe(strLastIndexedItem) + MessageService.NewParagraph + strLine)); } bEmptyEntry = false; } strLastLine = strLine; } } } } keepass2-2.25/KeePass/DataExchange/Formats/PwAgentXml234.cs0000664000175000017500000001302612261553106023206 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml; using System.IO; using System.Diagnostics; using System.Drawing; using KeePass.Resources; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 2.3.4-2.6.2+ internal sealed class PwAgentXml234 : FileFormatProvider { private const string ElemGroup = "group"; private const string ElemGroupName = "name"; private const string ElemEntry = "entry"; private const string ElemEntryName = "name"; private const string ElemEntryType = "type"; private const string ElemEntryUser = "account"; private const string ElemEntryPassword = "password"; private const string ElemEntryURL = "link"; private const string ElemEntryNotes = "note"; private const string ElemEntryCreationTime = "date_added"; private const string ElemEntryLastModTime = "date_modified"; private const string ElemEntryExpireTime = "date_expire"; public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Password Agent XML"; } } public override string DefaultExtension { get { return "xml"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_PwAgent; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(sr); sr.Close(); sInput.Close(); XmlNode xmlRoot = xmlDoc.DocumentElement; foreach(XmlNode xmlChild in xmlRoot.ChildNodes) { if(xmlChild.Name == ElemGroup) ReadGroup(xmlChild, pwStorage.RootGroup, pwStorage); else { Debug.Assert(false); } } } private static void ReadGroup(XmlNode xmlNode, PwGroup pgParent, PwDatabase pwStorage) { PwGroup pg = new PwGroup(true, true); pgParent.AddGroup(pg, true); foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name == ElemGroupName) pg.Name = XmlUtil.SafeInnerText(xmlChild); else if(xmlChild.Name == ElemGroup) ReadGroup(xmlChild, pg, pwStorage); else if(xmlChild.Name == ElemEntry) ReadEntry(xmlChild, pg, pwStorage); else { Debug.Assert(false); } } } private static void ReadEntry(XmlNode xmlNode, PwGroup pgParent, PwDatabase pwStorage) { PwEntry pe = new PwEntry(true, true); pgParent.AddEntry(pe, true); DateTime dt; foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name == ElemEntryName) pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemEntryType) pe.IconId = ((XmlUtil.SafeInnerText(xmlChild) != "1") ? PwIcon.Key : PwIcon.PaperNew); else if(xmlChild.Name == ElemEntryUser) pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwStorage.MemoryProtection.ProtectUserName, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemEntryPassword) pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemEntryURL) pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pwStorage.MemoryProtection.ProtectUrl, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemEntryNotes) pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == ElemEntryCreationTime) { if(ParseDate(xmlChild, out dt)) pe.CreationTime = dt; } else if(xmlChild.Name == ElemEntryLastModTime) { if(ParseDate(xmlChild, out dt)) pe.LastModificationTime = dt; } else if(xmlChild.Name == ElemEntryExpireTime) { if(ParseDate(xmlChild, out dt)) { pe.ExpiryTime = dt; pe.Expires = true; } } else { Debug.Assert(false); } } } private static bool ParseDate(XmlNode xn, out DateTime dtOut) { string strDate = XmlUtil.SafeInnerText(xn); if(strDate.Length == 0) { dtOut = DateTime.Now; return false; } if(DateTime.TryParse(strDate, out dtOut)) return true; Debug.Assert(false); dtOut = DateTime.Now; return false; } } } keepass2-2.25/KeePass/DataExchange/Formats/ZdnPwProTxt314.cs0000664000175000017500000001254712261553106023411 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using System.Diagnostics; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 3.1.4 internal sealed class ZdnPwProTxt314 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "ZDNet's Password Pro TXT"; } } public override string DefaultExtension { get { return "txt"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override bool ImportAppendsToRootGroupOnly { get { return true; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_ZdnPwPro; } } private const string StrFieldUser = "User Name: "; private const string StrFieldPw = "Password: "; private const string StrFieldUrl = "Shortcut: "; private const string StrFieldExpires = "Expires: "; private const string StrFieldType = "Type: "; private const string StrFieldNotes = "Comments: "; public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); string strData = sr.ReadToEnd(); sr.Close(); strData = strData.Replace("\r", string.Empty); string[] vLines = strData.Split(new char[] { '\n' }); if(vLines.Length >= 1) { Debug.Assert(vLines[0].StartsWith("Contents of: ")); vLines[0] = string.Empty; // Trigger 'new entry' below } Dictionary dItems = new Dictionary(); bool bInNotes = false; DateTime? dtExpire = null; for(int i = 0; i < vLines.Length; ++i) { string strLine = vLines[i]; if((i + 2) < vLines.Length) { string strSep = new string('-', vLines[i + 1].Length); if((strLine.Length == 0) && (vLines[i + 2] == strSep) && (strSep.Length > 0)) { AddEntry(pwStorage.RootGroup, dItems, ref bInNotes, ref dtExpire); dItems.Clear(); dItems[PwDefs.TitleField] = vLines[i + 1]; i += 2; continue; } } if(bInNotes) { if(dItems.ContainsKey(PwDefs.NotesField)) dItems[PwDefs.NotesField] += MessageService.NewLine + strLine; else dItems[PwDefs.NotesField] = strLine; } else if(strLine.StartsWith(StrFieldUser)) AddField(dItems, PwDefs.UserNameField, strLine.Substring( StrFieldUser.Length)); else if(strLine.StartsWith(StrFieldPw)) AddField(dItems, PwDefs.PasswordField, strLine.Substring( StrFieldPw.Length)); else if(strLine.StartsWith(StrFieldUrl)) AddField(dItems, PwDefs.UrlField, strLine.Substring( StrFieldUrl.Length)); else if(strLine.StartsWith(StrFieldType)) AddField(dItems, "Type", strLine.Substring(StrFieldType.Length)); else if(strLine.StartsWith(StrFieldExpires)) { string strExp = strLine.Substring(StrFieldExpires.Length); DateTime dtExp; if(DateTime.TryParse(strExp, out dtExp)) dtExpire = dtExp; else { Debug.Assert(false); } } else if(strLine.StartsWith(StrFieldNotes)) { AddField(dItems, PwDefs.NotesField, strLine.Substring( StrFieldNotes.Length)); bInNotes = true; } else { Debug.Assert(false); } } AddEntry(pwStorage.RootGroup, dItems, ref bInNotes, ref dtExpire); Debug.Assert(!dtExpire.HasValue); } private static void AddField(Dictionary dItems, string strKey, string strValue) { if(!dItems.ContainsKey(strKey)) { dItems[strKey] = strValue; return; } string strPreValue = dItems[strKey]; if((strPreValue.Length > 0) && (strValue.Length > 0)) strPreValue += ", "; dItems[strKey] = strPreValue + strValue; } private static void AddEntry(PwGroup pg, Dictionary dItems, ref bool bInNotes, ref DateTime? dtExpire) { if(dItems.Count > 0) { PwEntry pe = new PwEntry(true, true); pg.AddEntry(pe, true); foreach(KeyValuePair kvp in dItems) pe.Strings.Set(kvp.Key, new ProtectedString(false, kvp.Value)); if(dtExpire.HasValue) { pe.Expires = true; pe.ExpiryTime = dtExpire.Value; } } bInNotes = false; dtExpire = null; } } } keepass2-2.25/KeePass/DataExchange/Formats/SteganosPwManager2007.cs0000664000175000017500000001076212261553106024631 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Windows.Forms; using System.IO; using System.Drawing; using System.Threading; using KeePass.App; using KeePass.Native; using KeePass.Resources; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { internal sealed class SteganosPwManager2007 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Steganos Password Manager 2007"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override bool RequiresFile { get { return false; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_Steganos; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { if(MessageService.AskYesNo(KPRes.ImportMustRead + MessageService.NewParagraph + KPRes.ImportMustReadQuestion) == false) { AppHelp.ShowHelp(AppDefs.HelpTopics.ImportExport, AppDefs.HelpTopics.ImportExportSteganos); return; } PwEntry pePrev = new PwEntry(true, true); for(int i = 0; i < 20; ++i) { Thread.Sleep(500); Application.DoEvents(); } try { while(true) { PwEntry pe = ImportEntry(pwStorage); if(ImportUtil.EntryEquals(pe, pePrev)) { if(pe.ParentGroup != null) // Remove duplicate pe.ParentGroup.Entries.Remove(pe); break; } ImportUtil.GuiSendKeysPrc(@"{DOWN}"); pePrev = pe; } MessageService.ShowInfo(KPRes.ImportFinished); } catch(Exception exImp) { MessageService.ShowWarning(exImp); } } private static PwEntry ImportEntry(PwDatabase pwDb) { ImportUtil.GuiSendWaitWindowChange(@"{ENTER}"); Thread.Sleep(1000); ImportUtil.GuiSendKeysPrc(string.Empty); // Process messages string strTitle = ImportUtil.GuiSendRetrieve(string.Empty); string strGroup = ImportUtil.GuiSendRetrieve(@"{TAB}"); string strUserName = ImportUtil.GuiSendRetrieve(@"{TAB}"); ImportUtil.GuiSendKeysPrc(@"{TAB}{TAB}"); ImportUtil.GuiSendKeysPrc(@" "); ImportUtil.GuiSendKeysPrc(@"+({TAB})"); string strPassword = ImportUtil.GuiSendRetrieve(string.Empty); ImportUtil.GuiSendKeysPrc(@"{TAB} "); string strNotes = ImportUtil.GuiSendRetrieve(@"{TAB}{TAB}"); string strUrl = ImportUtil.GuiSendRetrieve(@"{TAB}"); string strUrl2 = ImportUtil.GuiSendRetrieve(@"{TAB}"); ImportUtil.GuiSendWaitWindowChange(@"{ESC}"); if(strGroup.Length == 0) strGroup = "Steganos"; PwGroup pg = pwDb.RootGroup.FindCreateGroup(strGroup, true); PwEntry pe = new PwEntry(true, true); pg.AddEntry(pe, true); pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwDb.MemoryProtection.ProtectTitle, strTitle)); pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwDb.MemoryProtection.ProtectUserName, strUserName)); pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwDb.MemoryProtection.ProtectPassword, strPassword)); pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwDb.MemoryProtection.ProtectNotes, strNotes)); if(strUrl.Length > 0) pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pwDb.MemoryProtection.ProtectUrl, strUrl)); else pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pwDb.MemoryProtection.ProtectUrl, strUrl2)); return pe; } } } keepass2-2.25/KeePass/DataExchange/Formats/KeePassKdb1x.cs0000664000175000017500000000675612261553106023170 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Native; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { internal sealed class KeePassKdb1x : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return true; } } public override string FormatName { get { return "KeePass KDB (1.x)"; } } public override string DefaultExtension { get { return "kdb"; } } public override string ApplicationGroup { get { return PwDefs.ShortProductName; } } public override bool SupportsUuids { get { return true; } } public override bool RequiresKey { get { return true; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_KeePass; } } public override bool TryBeginImport() { if(NativeLib.IsUnix()) { MessageService.ShowWarning(KPRes.KeePassLibCNotWindows, KPRes.KeePassLibCNotWindowsHint); return false; } Exception exLib; if(!KdbFile.IsLibraryInstalled(out exLib)) { MessageService.ShowWarning(KPRes.KeePassLibCNotFound, KPRes.KdbKeePassLibC, exLib); return false; } return true; } public override bool TryBeginExport() { return this.TryBeginImport(); } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { string strTempFile = Program.TempFilesPool.GetTempFileName(); BinaryReader br = new BinaryReader(sInput); byte[] pb = br.ReadBytes((int)sInput.Length); br.Close(); File.WriteAllBytes(strTempFile, pb); KdbFile kdb = new KdbFile(pwStorage, slLogger); kdb.Load(strTempFile); Program.TempFilesPool.Delete(strTempFile); } public override bool Export(PwExportInfo pwExportInfo, Stream sOutput, IStatusLogger slLogger) { PwDatabase pd = (pwExportInfo.ContextDatabase ?? new PwDatabase()); string strTempFile = Program.TempFilesPool.GetTempFileName(false); try { KdbFile kdb = new KdbFile(pd, slLogger); kdb.Save(strTempFile, pwExportInfo.DataGroup); byte[] pbKdb = File.ReadAllBytes(strTempFile); sOutput.Write(pbKdb, 0, pbKdb.Length); Array.Clear(pbKdb, 0, pbKdb.Length); } catch(Exception exKdb) { if(slLogger != null) slLogger.SetText(exKdb.Message, LogStatusType.Error); return false; } finally { Program.TempFilesPool.Delete(strTempFile); } return true; } } } keepass2-2.25/KeePass/DataExchange/Formats/StickyPwXml50.cs0000664000175000017500000001213412261553106023331 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml; using System.Xml.XPath; using System.IO; using System.Drawing; using System.Diagnostics; using KeePass.Resources; using KeePass.UI; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // KasperskyPwMgrXml50 derives from this // 5.0.4.232 internal class StickyPwXml50 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Sticky Password XML"; } } public override string DefaultExtension { get { return "xml"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override bool ImportAppendsToRootGroupOnly { get { return true; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_StickyPw; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { XPathDocument xpDoc = new XPathDocument(sInput); XPathNavigator xpNav = xpDoc.CreateNavigator(); ImportLogins(xpNav, pwStorage); ImportMemos(xpNav, pwStorage); } private static void ImportLogins(XPathNavigator xpNav, PwDatabase pd) { XPathNodeIterator it = xpNav.Select("/root/Database/Logins/Login"); while(it.MoveNext()) { PwEntry pe = new PwEntry(true, true); pd.RootGroup.AddEntry(pe, true); XPathNavigator xpLogin = it.Current; pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pd.MemoryProtection.ProtectUserName, xpLogin.GetAttribute("Name", string.Empty))); pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pd.MemoryProtection.ProtectPassword, xpLogin.GetAttribute("Password", string.Empty))); SetTimes(pe, xpLogin); string strID = xpLogin.GetAttribute("ID", string.Empty); if(string.IsNullOrEmpty(strID)) continue; XPathNavigator xpAccLogin = xpNav.SelectSingleNode( @"/root/Database/Accounts/Account/LoginLinks/Login[@SourceLoginID='" + strID + @"']/../.."); if(xpAccLogin == null) { Debug.Assert(false); } else { Debug.Assert(xpAccLogin.Name == "Account"); pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pd.MemoryProtection.ProtectTitle, xpAccLogin.GetAttribute("Name", string.Empty))); pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pd.MemoryProtection.ProtectUrl, xpAccLogin.GetAttribute("Link", string.Empty))); string strNotes = xpAccLogin.GetAttribute("Comments", string.Empty); strNotes = strNotes.Replace("/n", Environment.NewLine); pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pd.MemoryProtection.ProtectNotes, strNotes)); } } } private static void ImportMemos(XPathNavigator xpNav, PwDatabase pd) { XPathNodeIterator it = xpNav.Select("/root/Database/SecureMemos/SecureMemo"); while(it.MoveNext()) { PwEntry pe = new PwEntry(true, true); pd.RootGroup.AddEntry(pe, true); pe.IconId = PwIcon.PaperNew; XPathNavigator xpMemo = it.Current; pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pd.MemoryProtection.ProtectTitle, xpMemo.GetAttribute("Name", string.Empty))); SetTimes(pe, xpMemo); try { string strMemoHex = xpMemo.Value; byte[] pbMemo = MemUtil.HexStringToByteArray(strMemoHex); string strMemoRtf = Encoding.Unicode.GetString(pbMemo); pe.Binaries.Set(KPRes.Notes + ".rtf", new ProtectedBinary( false, StrUtil.Utf8.GetBytes(strMemoRtf))); } catch(Exception) { Debug.Assert(false); } } } private static void SetTimes(PwEntry pe, XPathNavigator xpNode) { DateTime dt; string strTime = (xpNode.GetAttribute("CreatedDate", string.Empty)); if(DateTime.TryParse(strTime, out dt)) pe.CreationTime = dt; else { Debug.Assert(false); } strTime = (xpNode.GetAttribute("ModifiedDate", string.Empty)); if(DateTime.TryParse(strTime, out dt)) pe.LastModificationTime = dt; else { Debug.Assert(false); } } } } keepass2-2.25/KeePass/DataExchange/Formats/PwMemory2008Xml104.cs0000664000175000017500000001017012261553106023723 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using System.Xml; using System.Xml.Serialization; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 1.0.4 internal sealed class PwMemory2008Xml104 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Password Memory 2008 XML"; } } public override string DefaultExtension { get { return "xml"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_PwMem2008; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { string str = PwMemory2008Xml104.Preprocess(sInput); MemoryStream ms = new MemoryStream(StrUtil.Utf8.GetBytes(str), false); XmlSerializer xs = new XmlSerializer(typeof(Priv_PwMem2008XmlFile)); Priv_PwMem2008XmlFile f = (Priv_PwMem2008XmlFile)xs.Deserialize(ms); ms.Close(); if((f == null) || (f.Cells == null)) return; Dictionary vGroups = new Dictionary(); for(int iLine = 2; iLine < f.Cells.Length; ++iLine) { string[] vCells = f.Cells[iLine]; if((vCells == null) || (vCells.Length != 6)) continue; if((vCells[1] == null) || (vCells[2] == null) || (vCells[3] == null) || (vCells[4] == null)) continue; string strGroup = vCells[4]; PwGroup pg; if(strGroup == ".") pg = pwStorage.RootGroup; else if(vGroups.ContainsKey(strGroup)) pg = vGroups[strGroup]; else { pg = new PwGroup(true, true); pg.Name = strGroup; pwStorage.RootGroup.AddGroup(pg, true); vGroups[strGroup] = pg; } PwEntry pe = new PwEntry(true, true); pg.AddEntry(pe, true); if(vCells[1] != ".") pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, vCells[1])); if(vCells[2] != ".") pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwStorage.MemoryProtection.ProtectUserName, vCells[2])); if(vCells[3] != ".") pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, vCells[3])); } } private static string Preprocess(Stream sInput) { StreamReader sr = new StreamReader(sInput, Encoding.UTF8); string str = sr.ReadToEnd(); const string strStartTag = " 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.Drawing; using System.Diagnostics; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; namespace KeePass.DataExchange.Formats { // 4.0+ internal sealed class NetworkPwMgrCsv4 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Network Password Manager CSV"; } } public override string DefaultExtension { get { return "csv"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_NetworkPwMgr; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); string strData = sr.ReadToEnd(); sr.Close(); CsvOptions opt = new CsvOptions(); opt.BackslashIsEscape = false; opt.TextQualifier = char.MaxValue; // No text qualifier CsvStreamReaderEx csv = new CsvStreamReaderEx(strData, opt); PwGroup pg = pwStorage.RootGroup; char[] vGroupSplit = new char[] { '\\' }; while(true) { string[] v = csv.ReadLine(); if(v == null) break; if(v.Length < 1) continue; for(int i = 0; i < v.Length; ++i) v[i] = ParseString(v[i]); if(v[0].StartsWith("\\")) // Group { string strGroup = v[0].Trim(vGroupSplit); // Also from end if(strGroup.Length > 0) { pg = pwStorage.RootGroup.FindCreateSubTree(strGroup, vGroupSplit); if(v.Length >= 6) pg.Notes = v[5].Trim(); if((v.Length >= 5) && (v[4].Trim().Length > 0)) { if(pg.Notes.Length > 0) pg.Notes += Environment.NewLine + Environment.NewLine; pg.Notes += v[4].Trim(); } } } else // Entry { PwEntry pe = new PwEntry(true, true); pg.AddEntry(pe, true); List l = new List(v); while(l.Count < 8) { Debug.Assert(false); l.Add(string.Empty); } ImportUtil.AppendToField(pe, PwDefs.TitleField, l[0], pwStorage); ImportUtil.AppendToField(pe, PwDefs.UserNameField, l[1], pwStorage); ImportUtil.AppendToField(pe, PwDefs.PasswordField, l[2], pwStorage); ImportUtil.AppendToField(pe, PwDefs.UrlField, l[3], pwStorage); ImportUtil.AppendToField(pe, PwDefs.NotesField, l[4], pwStorage); if(l[5].Length > 0) ImportUtil.AppendToField(pe, "Custom 1", l[5], pwStorage); if(l[6].Length > 0) ImportUtil.AppendToField(pe, "Custom 2", l[6], pwStorage); if(l[7].Length > 0) ImportUtil.AppendToField(pe, "Custom 3", l[7], pwStorage); } } } private static string ParseString(string str) { if(str == null) { Debug.Assert(false); return string.Empty; } str = str.Replace(@"#44", ","); str = str.Replace(@"#13", Environment.NewLine); return str; } } } keepass2-2.25/KeePass/DataExchange/Formats/PwsPlusCsv1007.cs0000664000175000017500000000773712261553106023344 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using System.Diagnostics; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { internal sealed class PwsPlusCsv1007 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Passwords Plus CSV"; } } public override string DefaultExtension { get { return "csv"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_PwsPlus; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); string strData = sr.ReadToEnd(); sr.Close(); CsvStreamReader csv = new CsvStreamReader(strData, true); Dictionary dictGroups = new Dictionary(); while(true) { string[] vLine = csv.ReadLine(); if(vLine == null) break; if(vLine.Length == 0) continue; // Skip empty line if(vLine.Length == 5) continue; // Skip header line if(vLine.Length != 34) { Debug.Assert(false); continue; } string strType = vLine[0].Trim(); if(strType.Equals("Is Template", StrUtil.CaseIgnoreCmp)) continue; if(strType.Equals("1")) continue; // Skip template string strGroup = vLine[2].Trim(); PwGroup pg; if(strGroup.Length == 0) pg = pwStorage.RootGroup; else { if(dictGroups.ContainsKey(strGroup)) pg = dictGroups[strGroup]; else { pg = new PwGroup(true, true, strGroup, PwIcon.Folder); pwStorage.RootGroup.AddGroup(pg, true); dictGroups[strGroup] = pg; } } PwEntry pe = new PwEntry(true, true); pg.AddEntry(pe, true); string strTitle = vLine[1].Trim(); if(strTitle.Length > 0) ImportUtil.AppendToField(pe, PwDefs.TitleField, strTitle, pwStorage); for(int i = 0; i < 10; ++i) { string strKey = vLine[(i * 3) + 3].Trim(); string strValue = vLine[(i * 3) + 4].Trim(); if((strKey.Length == 0) || (strValue.Length == 0)) continue; string strMapped = ImportUtil.MapNameToStandardField(strKey, true); if(string.IsNullOrEmpty(strMapped)) strMapped = strKey; ImportUtil.AppendToField(pe, strMapped, strValue, pwStorage); } string strNotesPre = pe.Strings.ReadSafe(PwDefs.NotesField); string strNotes = vLine[33].Trim(); if(strNotes.Length > 0) { if(strNotesPre.Length == 0) ImportUtil.AppendToField(pe, PwDefs.NotesField, strNotes, pwStorage); else pe.Strings.Set(PwDefs.NotesField, new ProtectedString( ((pwStorage == null) ? false : pwStorage.MemoryProtection.ProtectNotes), strNotesPre + Environment.NewLine + Environment.NewLine + strNotes)); } } } } } keepass2-2.25/KeePass/DataExchange/Formats/FlexWalletXml17.cs0000664000175000017500000001403712261553106023632 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml; using System.IO; using System.Diagnostics; using System.Drawing; using KeePass.Resources; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 1.7 internal sealed class FlexWalletXml17 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "FlexWallet XML"; } } public override string DefaultExtension { get { return "xml"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_FlexWallet; } } private const string ElemRoot = "FlexWallet"; // In 1.7 the node names are Pascal-cased and in 2006 they are // lower-cased. Therefore, compare them case-insensitively. private const string ElemCategory = "Category"; private const string ElemEntry = "Card"; private const string ElemField = "Field"; private const string ElemNotes = "Notes"; private const string AttribData = "Description"; // 1.7 private const string AttribName = "name"; // 2006 public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); string strDoc = sr.ReadToEnd(); sr.Close(); ImportFileString(strDoc, pwStorage); } private static void ImportFileString(string strXmlDoc, PwDatabase pwStorage) { XmlDocument doc = new XmlDocument(); doc.LoadXml(strXmlDoc); XmlElement xmlRoot = doc.DocumentElement; Debug.Assert(xmlRoot.Name == ElemRoot); foreach(XmlNode xmlChild in xmlRoot.ChildNodes) { if(xmlChild.Name.Equals(ElemCategory, StrUtil.CaseIgnoreCmp)) ImportCategory(xmlChild, pwStorage.RootGroup, pwStorage); else { Debug.Assert(false); } } } private static void ImportCategory(XmlNode xmlNode, PwGroup pgContainer, PwDatabase pwStorage) { string strName = ReadNameAttrib(xmlNode); if(string.IsNullOrEmpty(strName)) strName = KPRes.Group; PwGroup pg = new PwGroup(true, true, strName, PwIcon.Folder); pgContainer.AddGroup(pg, true); foreach(XmlNode xmlChild in xmlNode.ChildNodes) { if(xmlChild.Name.Equals(ElemEntry, StrUtil.CaseIgnoreCmp)) ImportEntry(xmlChild, pg, pwStorage); else if(xmlChild.Name.Equals(ElemCategory, StrUtil.CaseIgnoreCmp)) ImportCategory(xmlChild, pg, pwStorage); else { Debug.Assert(false); } } } private static void ImportEntry(XmlNode xmlNode, PwGroup pg, PwDatabase pwStorage) { PwEntry pe = new PwEntry(true, true); string strTitle = ReadNameAttrib(xmlNode); if(!string.IsNullOrEmpty(strTitle)) pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, strTitle)); foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name.Equals(ElemField, StrUtil.CaseIgnoreCmp)) { string strName = ReadNameAttrib(xmlChild); if(string.IsNullOrEmpty(strName)) continue; string strValue = XmlUtil.SafeInnerText(xmlChild); string strKpName = ImportUtil.MapNameToStandardField(strName, true); if(string.IsNullOrEmpty(strKpName)) strKpName = strName; ImportUtil.AppendToField(pe, strKpName, strValue, pwStorage); } else if(xmlChild.Name.Equals(ElemNotes, StrUtil.CaseIgnoreCmp)) ImportUtil.AppendToField(pe, PwDefs.NotesField, XmlUtil.SafeInnerText(xmlChild), pwStorage); else { Debug.Assert(false); } } // RenameFields(pe); pg.AddEntry(pe, true); } private static string ReadNameAttrib(XmlNode xmlNode) { if(xmlNode == null) { Debug.Assert(false); return string.Empty; } try { if(xmlNode.Attributes.GetNamedItem(AttribData) != null) // 1.7 return (xmlNode.Attributes[AttribData].Value ?? string.Empty); if(xmlNode.Attributes.GetNamedItem(AttribName) != null) // 2006 return (xmlNode.Attributes[AttribName].Value ?? string.Empty); Debug.Assert(false); } catch(Exception) { Debug.Assert(false); } return string.Empty; } /* private static void RenameFields(PwEntry pe) { string[] vMap = new string[] { "Acct #", PwDefs.UserNameField, "Subject", PwDefs.UserNameField, "Location", PwDefs.UserNameField, "Combination", PwDefs.PasswordField, "Username", PwDefs.UserNameField, "Website", PwDefs.UrlField, "Serial #", PwDefs.PasswordField, "Product ID", PwDefs.UserNameField }; Debug.Assert((vMap.Length % 2) == 0); for(int i = 0; i < vMap.Length; i += 2) { string strFrom = vMap[i], strTo = vMap[i + 1]; if(pe.Strings.ReadSafe(strTo).Length > 0) continue; string strData = pe.Strings.ReadSafe(strFrom); if(strData.Length > 0) { pe.Strings.Set(strTo, new ProtectedString(false, strData)); if(pe.Strings.Remove(strFrom) == false) { Debug.Assert(false); } } } } */ } } keepass2-2.25/KeePass/DataExchange/Formats/KeePassKdb2xRepair.cs0000664000175000017500000001042112261553106024314 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using System.Windows.Forms; using KeePass.App; using KeePass.Native; using KeePass.Resources; using KeePass.UI; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Serialization; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { internal sealed class KeePassKdb2xRepair : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "KeePass KDBX (2.x) (" + KPRes.RepairMode + ")"; } } public override string DefaultExtension { get { return AppDefs.FileExtension.FileExt; } } public override string ApplicationGroup { get { return PwDefs.ShortProductName; } } public override bool SupportsUuids { get { return true; } } public override bool RequiresKey { get { return true; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_KeePass; } } public override bool TryBeginImport() { string strTitle = KPRes.Warning + "!"; string strMsg = KPRes.RepairModeInt + MessageService.NewParagraph + KPRes.RepairModeUse + MessageService.NewParagraph + KPRes.RepairModeQ; int iYes = (int)DialogResult.Yes; int iNo = (int)DialogResult.No; int r = VistaTaskDialog.ShowMessageBoxEx(strMsg, strTitle, PwDefs.ShortProductName, VtdIcon.Warning, null, KPRes.Yes, iYes, KPRes.No, iNo); if(r < 0) r = (MessageService.AskYesNo(strTitle + MessageService.NewParagraph + strMsg, PwDefs.ShortProductName, false, MessageBoxIcon.Warning) ? iYes : iNo); return ((r == iYes) || (r == (int)DialogResult.OK)); } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { KdbxFile kdbx = new KdbxFile(pwStorage); // CappedByteStream s = new CappedByteStream(sInput, 64); kdbx.RepairMode = true; try { kdbx.Load(sInput, KdbxFormat.Default, slLogger); } catch(Exception) { } } /* private sealed class CappedByteStream : Stream { private Stream m_sBase; private int m_nMaxRead; public override bool CanRead { get { return m_sBase.CanRead; } } public override bool CanSeek { get { return m_sBase.CanSeek; } } public override bool CanWrite { get { return m_sBase.CanWrite; } } public override long Length { get { return m_sBase.Length; } } public override long Position { get { return m_sBase.Position; } set { m_sBase.Position = value; } } public CappedByteStream(Stream sBase, int nMaxRead) { if(sBase == null) throw new ArgumentNullException("sBase"); if(nMaxRead <= 0) throw new ArgumentException(); m_sBase = sBase; m_nMaxRead = nMaxRead; } public override void Flush() { m_sBase.Flush(); } public override int Read(byte[] buffer, int offset, int count) { if(count > m_nMaxRead) count = m_nMaxRead; return m_sBase.Read(buffer, offset, count); } public override long Seek(long offset, SeekOrigin origin) { return m_sBase.Seek(offset, origin); } public override void SetLength(long value) { m_sBase.SetLength(value); } public override void Write(byte[] buffer, int offset, int count) { m_sBase.Write(buffer, offset, count); } } */ } } keepass2-2.25/KeePass/DataExchange/Formats/MozillaBookmarksJson100.cs0000664000175000017500000001675612261553106025277 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using System.Drawing; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 1.00 internal sealed class MozillaBookmarksJson100 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Mozilla Bookmarks JSON"; } } public override string DefaultExtension { get { return "json"; } } public override string ApplicationGroup { get { return KPRes.Browser; } } private const string m_strGroup = "children"; public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_ASCII; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, StrUtil.Utf8); string strContent = sr.ReadToEnd(); sr.Close(); if(string.IsNullOrEmpty(strContent)) return; CharStream cs = new CharStream(strContent); Dictionary> dTags = new Dictionary>(); List lCreatedEntries = new List(); JsonObject jRoot = new JsonObject(cs); AddObject(pwStorage.RootGroup, jRoot, pwStorage, false, dTags, lCreatedEntries); Debug.Assert(cs.PeekChar(true) == char.MinValue); // Assign tags foreach(PwEntry pe in lCreatedEntries) { string strUri = pe.Strings.ReadSafe(PwDefs.UrlField); if(strUri.Length == 0) continue; foreach(KeyValuePair> kvp in dTags) { foreach(string strTagUri in kvp.Value) { if(strUri.Equals(strTagUri, StrUtil.CaseIgnoreCmp)) pe.AddTag(kvp.Key); } } } } private static void AddObject(PwGroup pgStorage, JsonObject jObject, PwDatabase pwContext, bool bCreateSubGroups, Dictionary> dTags, List lCreatedEntries) { JsonValue jvRoot; jObject.Items.TryGetValue("root", out jvRoot); string strRoot = (((jvRoot != null) ? jvRoot.ToString() : null) ?? string.Empty); if(strRoot.Equals("tagsFolder", StrUtil.CaseIgnoreCmp)) { ImportTags(jObject, dTags); return; } if(jObject.Items.ContainsKey(m_strGroup)) { JsonArray jArray = (jObject.Items[m_strGroup].Value as JsonArray); if(jArray == null) { Debug.Assert(false); return; } PwGroup pgNew; if(bCreateSubGroups) { pgNew = new PwGroup(true, true); pgStorage.AddGroup(pgNew, true); if(jObject.Items.ContainsKey("title")) pgNew.Name = ((jObject.Items["title"].Value != null) ? jObject.Items["title"].Value.ToString() : string.Empty); } else pgNew = pgStorage; foreach(JsonValue jValue in jArray.Values) { JsonObject objSub = (jValue.Value as JsonObject); if(objSub != null) AddObject(pgNew, objSub, pwContext, true, dTags, lCreatedEntries); else { Debug.Assert(false); } } return; } PwEntry pe = new PwEntry(true, true); SetString(pe, "Index", false, jObject, "index"); SetString(pe, PwDefs.TitleField, pwContext.MemoryProtection.ProtectTitle, jObject, "title"); SetString(pe, "ID", false, jObject, "id"); SetString(pe, PwDefs.UrlField, pwContext.MemoryProtection.ProtectUrl, jObject, "uri"); SetString(pe, "CharSet", false, jObject, "charset"); if(jObject.Items.ContainsKey("annos")) { JsonArray vAnnos = (jObject.Items["annos"].Value as JsonArray); if(vAnnos != null) { foreach(JsonValue jv in vAnnos.Values) { if(jv == null) { Debug.Assert(false); continue; } JsonObject jo = (jv.Value as JsonObject); if(jo == null) { Debug.Assert(false); continue; } JsonValue jvAnnoName, jvAnnoValue; jo.Items.TryGetValue("name", out jvAnnoName); jo.Items.TryGetValue("value", out jvAnnoValue); if((jvAnnoName == null) || (jvAnnoValue == null)) continue; string strAnnoName = jvAnnoName.ToString(); string strAnnoValue = jvAnnoValue.ToString(); if((strAnnoName == null) || (strAnnoValue == null)) continue; if(strAnnoName == "bookmarkProperties/description") pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwContext.MemoryProtection.ProtectNotes, strAnnoValue)); } } } if((pe.Strings.ReadSafe(PwDefs.TitleField).Length > 0) || (pe.Strings.ReadSafe(PwDefs.UrlField).Length > 0)) { pgStorage.AddEntry(pe, true); lCreatedEntries.Add(pe); } } private static void SetString(PwEntry pe, string strEntryKey, bool bProtect, JsonObject jObject, string strObjectKey) { if(!jObject.Items.ContainsKey(strObjectKey)) return; object obj = jObject.Items[strObjectKey].Value; if(obj == null) return; pe.Strings.Set(strEntryKey, new ProtectedString(bProtect, obj.ToString())); } private static void ImportTags(JsonObject jTagsRoot, Dictionary> dTags) { try { JsonValue jTags = jTagsRoot.Items["children"]; if(jTags == null) { Debug.Assert(false); return; } JsonArray arTags = (jTags.Value as JsonArray); if(arTags == null) { Debug.Assert(false); return; } foreach(JsonValue jvTag in arTags.Values) { JsonObject jTag = (jvTag.Value as JsonObject); if(jTag == null) { Debug.Assert(false); continue; } JsonValue jvName = jTag.Items["title"]; if(jvName == null) { Debug.Assert(false); continue; } string strName = jvName.ToString(); if(string.IsNullOrEmpty(strName)) { Debug.Assert(false); continue; } List lUris; dTags.TryGetValue(strName, out lUris); if(lUris == null) { lUris = new List(); dTags[strName] = lUris; } JsonValue jvUrls = jTag.Items["children"]; if(jvUrls == null) { Debug.Assert(false); continue; } JsonArray arUrls = (jvUrls.Value as JsonArray); if(arUrls == null) { Debug.Assert(false); continue; } foreach(JsonValue jvPlace in arUrls.Values) { JsonObject jUrl = (jvPlace.Value as JsonObject); if(jUrl == null) { Debug.Assert(false); continue; } JsonValue jvUri = jUrl.Items["uri"]; if(jvUri == null) { Debug.Assert(false); continue; } string strUri = jvUri.ToString(); if(!string.IsNullOrEmpty(strUri)) lUris.Add(strUri); } } } catch(Exception) { Debug.Assert(false); } } } } keepass2-2.25/KeePass/DataExchange/Formats/DataVaultCsv47.cs0000664000175000017500000000640612261553106023447 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using System.Globalization; using System.Drawing; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; namespace KeePass.DataExchange.Formats { // 4.7.35 internal sealed class DataVaultCsv47 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "DataVault CSV"; } } public override string DefaultExtension { get { return "csv"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override bool ImportAppendsToRootGroupOnly { get { return true; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_DataVault; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); string strData = sr.ReadToEnd(); sr.Close(); // Fix broken newlines strData = strData.Replace("\r\r\n", "\r\n"); CsvStreamReader csv = new CsvStreamReader(strData, false); while(true) { string[] v = csv.ReadLine(); if(v == null) break; if(v.Length == 0) continue; PwEntry pe = new PwEntry(true, true); pwStorage.RootGroup.AddEntry(pe, true); pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, v[0])); int p = 1; while((p + 1) < v.Length) { string strMapped = ImportUtil.MapNameToStandardField(v[p], true); string strKey = (string.IsNullOrEmpty(strMapped) ? v[p] : strMapped); string strValue = v[p + 1]; p += 2; if((strKey.Length == 0) && (strValue.Length == 0)) continue; AppendToString(pe, strKey, strValue); } if((p < v.Length) && !string.IsNullOrEmpty(v[p])) AppendToString(pe, PwDefs.NotesField, v[p]); } } private static void AppendToString(PwEntry pe, string strKey, string strValue) { if(pe.Strings.ReadSafe(strKey).Length > 0) { pe.Strings.Set(strKey, new ProtectedString(false, pe.Strings.ReadSafe(strKey) + ", " + strValue)); } else pe.Strings.Set(strKey, new ProtectedString(false, strValue)); } } } keepass2-2.25/KeePass/DataExchange/Formats/Whisper32Csv116.cs0000664000175000017500000001147712261553106023431 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Drawing; using System.Diagnostics; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 1.16 internal sealed class Whisper32Csv116 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Whisper 32 CSV"; } } public override string DefaultExtension { get { return "csv"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override bool ImportAppendsToRootGroupOnly { get { return true; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_Whisper32; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); string strDocument = sr.ReadToEnd(); sr.Close(); PwGroup pg = pwStorage.RootGroup; CharStream cs = new CharStream(strDocument); string[] vFields = new string[7]; char[] vDateFieldSplitter = new char[]{ '/' }; char[] vDateZeroTrim = new char[]{ '0' }; bool bFirst = true; while(true) { bool bSubZero = false; for(int iField = 0; iField < vFields.Length; ++iField) { vFields[iField] = ReadCsvField(cs); if((iField > 0) && (vFields[iField] == null)) bSubZero = true; } if(vFields[0] == null) break; // Import successful else if(bSubZero) throw new FormatException(); if(bFirst) { bFirst = false; // Check first line once only if((vFields[0] != "ServiceName") || (vFields[1] != "UserName") || (vFields[2] != "Password") || (vFields[3] != "Memo") || (vFields[4] != "Expire") || (vFields[5] != "StartDate") || (vFields[6] != "DaysToLive")) { Debug.Assert(false); throw new FormatException(); } else continue; } PwEntry pe = new PwEntry(true, true); pg.AddEntry(pe, true); pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, vFields[0])); pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwStorage.MemoryProtection.ProtectUserName, vFields[1])); pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, vFields[2])); pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, vFields[3])); pe.Expires = (vFields[4] == "true"); try { string[] vDateParts = vFields[5].Split(vDateFieldSplitter); DateTime dt = new DateTime( int.Parse(vDateParts[2].TrimStart(vDateZeroTrim)), int.Parse(vDateParts[0].TrimStart(vDateZeroTrim)), int.Parse(vDateParts[1].TrimStart(vDateZeroTrim))); pe.LastModificationTime = dt; pe.LastAccessTime = dt; pe.ExpiryTime = dt.AddDays(double.Parse(vFields[6])); } catch(Exception) { Debug.Assert(false); } pe.Strings.Set("Days To Live", new ProtectedString(false, vFields[6])); } } private static string ReadCsvField(CharStream cs) { StringBuilder sbValue = new StringBuilder(); char ch; while(true) { ch = cs.ReadChar(); if(ch == char.MinValue) return null; else if(ch == '\"') break; } while(true) { ch = cs.ReadChar(); if(ch == char.MinValue) return null; else if(ch == '\r') continue; else if(ch == '\"') { char chSucc = cs.ReadChar(); if(chSucc == '\"') sbValue.Append('\"'); else break; } else if(ch == '\n') sbValue.Append(MessageService.NewLine); else sbValue.Append(ch); } return sbValue.ToString(); } } } keepass2-2.25/KeePass/DataExchange/Formats/PinsTxt450.cs0000664000175000017500000001011212261553106022562 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Windows.Forms; using System.IO; using System.Diagnostics; using System.Drawing; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; namespace KeePass.DataExchange.Formats { // 4.50 internal sealed class PinsTxt450 : FileFormatProvider { private const string FirstLine = "\"Category\"\t\"System\"\t\"User\"\t" + "\"Password\"\t\"URL/Comments\"\t\"Custom\"\t\"Start date\"\t\"Expires\"\t" + "\"More info\""; private const string FieldSeparator = "\"\t\""; public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "PINs TXT"; } } public override string DefaultExtension { get { return "txt"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_PINs; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); string strData = sr.ReadToEnd(); sr.Close(); string[] vLines = strData.Split(new char[]{ '\r', '\n' }); bool bFirst = true; foreach(string strLine in vLines) { if(bFirst) { if(strLine != FirstLine) throw new FormatException("Format error. First line is invalid. Read the documentation."); bFirst = false; } else if(strLine.Length > 5) ImportLine(strLine, pwStorage); } } private static void ImportLine(string strLine, PwDatabase pwStorage) { string[] vParts = strLine.Split(new string[] { FieldSeparator }, StringSplitOptions.None); Debug.Assert(vParts.Length == 9); if(vParts.Length != 9) throw new FormatException("Line:\r\n" + strLine); vParts[0] = vParts[0].Remove(0, 1); vParts[8] = vParts[8].Substring(0, vParts[8].Length - 1); vParts[8] = vParts[8].Replace("||", "\r\n"); PwGroup pg = pwStorage.RootGroup.FindCreateGroup(vParts[0], true); PwEntry pe = new PwEntry(true, true); pg.AddEntry(pe, true); pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, vParts[1])); pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwStorage.MemoryProtection.ProtectUserName, vParts[2])); pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, vParts[3])); pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pwStorage.MemoryProtection.ProtectUrl, vParts[4])); if(vParts[5].Length > 0) pe.Strings.Set("Custom", new ProtectedString(false, vParts[5])); DateTime dt; if((vParts[6].Length > 0) && DateTime.TryParse(vParts[6], out dt)) pe.CreationTime = pe.LastModificationTime = pe.LastAccessTime = dt; if((vParts[7].Length > 0) && DateTime.TryParse(vParts[7], out dt)) { pe.ExpiryTime = dt; pe.Expires = true; } pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, vParts[8])); } } } keepass2-2.25/KeePass/DataExchange/Formats/KeePassHtml2x.cs0000664000175000017500000000424212261553106023361 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using System.Windows.Forms; using KeePass.Forms; using KeePass.Resources; using KeePass.UI; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { internal sealed class KeePassHtml2x : FileFormatProvider { public override bool SupportsImport { get { return false; } } public override bool SupportsExport { get { return true; } } public override string FormatName { get { return KPRes.CustomizableHtml; } } public override string DefaultExtension { get { return @"html|htm"; } } public override string ApplicationGroup { get { return KPRes.General; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_HTML; } } public override bool Export(PwExportInfo pwExportInfo, Stream sOutput, IStatusLogger slLogger) { PrintForm dlg = new PrintForm(); dlg.InitEx(pwExportInfo.DataGroup, false, -1); bool bResult = false; if(dlg.ShowDialog() == DialogResult.OK) { byte[] pb = StrUtil.Utf8.GetBytes(dlg.GeneratedHtml); sOutput.Write(pb, 0, pb.Length); sOutput.Close(); bResult = true; } UIUtil.DestroyForm(dlg); return bResult; } } } keepass2-2.25/KeePass/DataExchange/Formats/GenericCsv.cs0000664000175000017500000000426112261553106022760 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Drawing; using KeePass.Forms; using KeePass.Resources; using KeePass.UI; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { internal sealed class GenericCsv : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return KPRes.CsvTextFile; } } public override string DisplayName { get { return KPRes.GenericCsvImporter; } } public override string DefaultExtension { get { return @"*"; } } public override string ApplicationGroup { get { return KPRes.General; } } public override bool ImportAppendsToRootGroupOnly { get { return false; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_ASCII; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { MemoryStream ms = new MemoryStream(); MemUtil.CopyStream(sInput, ms); byte[] pbData = ms.ToArray(); ms.Close(); sInput.Close(); CsvImportForm dlg = new CsvImportForm(); dlg.InitEx(pwStorage, pbData); UIUtil.ShowDialogAndDestroy(dlg); } } } keepass2-2.25/KeePass/DataExchange/Formats/KeePassKdb2x.cs0000664000175000017500000000441412261553106023156 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using KeePass.App; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Serialization; namespace KeePass.DataExchange.Formats { internal sealed class KeePassKdb2x : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return true; } } public override string FormatName { get { return "KeePass KDBX (2.x)"; } } public override string DefaultExtension { get { return AppDefs.FileExtension.FileExt; } } public override string ApplicationGroup { get { return PwDefs.ShortProductName; } } public override bool SupportsUuids { get { return true; } } public override bool RequiresKey { get { return true; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_KeePass; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { KdbxFile kdbx = new KdbxFile(pwStorage); kdbx.Load(sInput, KdbxFormat.Default, slLogger); } public override bool Export(PwExportInfo pwExportInfo, Stream sOutput, IStatusLogger slLogger) { KdbxFile kdbx = new KdbxFile(pwExportInfo.ContextDatabase); kdbx.Save(sOutput, pwExportInfo.DataGroup, KdbxFormat.Default, slLogger); return true; } } } keepass2-2.25/KeePass/DataExchange/Formats/SecurityTxt12.cs0000664000175000017500000000716012261553106023403 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using System.Drawing; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; namespace KeePass.DataExchange.Formats { // 1.2 internal sealed class SecurityTxt12 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Security TXT"; } } public override string DefaultExtension { get { return "txt"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_Security; } } internal sealed class SecLine { public string Text = string.Empty; public List SubLines = new List(); } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); Stack vGroups = new Stack(); SecLine secRoot = new SecLine(); vGroups.Push(secRoot); char[] vTrim = new char[]{ '\t', '\n', '\r', ' ' }; while(true) { string str = sr.ReadLine(); if(str == null) break; if(str.Length == 0) continue; SecLine line = new SecLine(); line.Text = str.Trim(vTrim); int nTabs = CountTabs(str); if(nTabs == vGroups.Count) { vGroups.Peek().SubLines.Add(line); vGroups.Push(line); } else { while(nTabs < (vGroups.Count - 1)) vGroups.Pop(); vGroups.Peek().SubLines.Add(line); vGroups.Push(line); } } AddSecLine(pwStorage.RootGroup, secRoot, true, pwStorage); sr.Close(); } private static int CountTabs(string str) { Debug.Assert(str != null); if(str == null) return 0; int nTabs = 0; for(int i = 0; i < str.Length; ++i) { if(str[i] != '\t') break; ++nTabs; } return nTabs; } private void AddSecLine(PwGroup pgContainer, SecLine line, bool bIsContainer, PwDatabase pwParent) { if(!bIsContainer) { if(line.SubLines.Count > 0) { PwGroup pg = new PwGroup(true, true); pg.Name = line.Text; pgContainer.AddGroup(pg, true); pgContainer = pg; } else { PwEntry pe = new PwEntry(true, true); pgContainer.AddEntry(pe, true); pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwParent.MemoryProtection.ProtectTitle, line.Text)); } } foreach(SecLine subLine in line.SubLines) AddSecLine(pgContainer, subLine, false, pwParent); } } } keepass2-2.25/KeePass/DataExchange/Formats/PassKeeper12.cs0000664000175000017500000000757112261553106023144 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Windows.Forms; using System.IO; using System.Drawing; using System.Threading; using KeePass.App; using KeePass.Native; using KeePass.Resources; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 1.2 internal sealed class PassKeeper12 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "PassKeeper"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override bool RequiresFile { get { return false; } } public override bool ImportAppendsToRootGroupOnly { get { return true; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_PassKeeper; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { if(MessageService.AskYesNo(KPRes.ImportMustRead + MessageService.NewParagraph + KPRes.ImportMustReadQuestion) == false) { AppHelp.ShowHelp(AppDefs.HelpTopics.ImportExport, AppDefs.HelpTopics.ImportExportPassKeeper); return; } PwEntry pePrev = new PwEntry(true, true); for(int i = 0; i < 20; ++i) { Thread.Sleep(500); Application.DoEvents(); } try { while(true) { PwEntry pe = ImportEntry(pwStorage); if(ImportUtil.EntryEquals(pe, pePrev)) { if(pe.ParentGroup != null) // Remove duplicate pe.ParentGroup.Entries.Remove(pe); break; } ImportUtil.GuiSendKeysPrc(@"{DOWN}"); pePrev = pe; } MessageService.ShowInfo(KPRes.ImportFinished); } catch(Exception exImp) { MessageService.ShowWarning(exImp); } } private static PwEntry ImportEntry(PwDatabase pwDb) { ImportUtil.GuiSendWaitWindowChange(@"{ENTER}"); Thread.Sleep(250); ImportUtil.GuiSendKeysPrc(string.Empty); // Process messages string strTitle = ImportUtil.GuiSendRetrieve(string.Empty); string strUserName = ImportUtil.GuiSendRetrieve(@"{TAB}"); string strPassword = ImportUtil.GuiSendRetrieve(@"{TAB}"); string strNotes = ImportUtil.GuiSendRetrieve(@"{TAB}"); ImportUtil.GuiSendWaitWindowChange(@"{ESC}"); PwGroup pg = pwDb.RootGroup; PwEntry pe = new PwEntry(true, true); pg.AddEntry(pe, true); pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwDb.MemoryProtection.ProtectTitle, strTitle)); pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwDb.MemoryProtection.ProtectUserName, strUserName)); pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwDb.MemoryProtection.ProtectPassword, strPassword)); pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwDb.MemoryProtection.ProtectNotes, strNotes)); return pe; } } } keepass2-2.25/KeePass/DataExchange/Formats/HandySafeProXml12.cs0000664000175000017500000001037612261553106024103 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using System.Diagnostics; using System.Xml.Serialization; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { [XmlRoot("HandySafe")] public sealed class HspFolder { [XmlAttribute("name")] public string Name { get; set; } [XmlElement("Folder")] public HspFolder[] Folders { get; set; } [XmlElement("Card")] public HspCard[] Cards { get; set; } } public sealed class HspCard { [XmlAttribute("name")] public string Name { get; set; } [XmlElement("Field")] public HspField[] Fields { get; set; } public string Note { get; set; } } public sealed class HspField { [XmlAttribute("name")] public string Name { get; set; } [XmlText] public string Value { get; set; } } // 1.2 internal sealed class HandySafeProXml12 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Handy Safe Pro XML"; } } public override string DefaultExtension { get { return "xml"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_HandySafePro; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { XmlSerializer xs = new XmlSerializer(typeof(HspFolder)); HspFolder hspRoot = (HspFolder)xs.Deserialize(sInput); AddFolder(pwStorage.RootGroup, hspRoot, false); } private static void AddFolder(PwGroup pgParent, HspFolder hspFolder, bool bNewGroup) { if(hspFolder == null) { Debug.Assert(false); return; } PwGroup pg; if(bNewGroup) { pg = new PwGroup(true, true); pgParent.AddGroup(pg, true); if(!string.IsNullOrEmpty(hspFolder.Name)) pg.Name = hspFolder.Name; } else pg = pgParent; if(hspFolder.Folders != null) { foreach(HspFolder fld in hspFolder.Folders) AddFolder(pg, fld, true); } if(hspFolder.Cards != null) { foreach(HspCard crd in hspFolder.Cards) AddCard(pg, crd); } } private static void AddCard(PwGroup pgParent, HspCard hspCard) { if(hspCard == null) { Debug.Assert(false); return; } PwEntry pe = new PwEntry(true, true); pgParent.AddEntry(pe, true); if(!string.IsNullOrEmpty(hspCard.Name)) pe.Strings.Set(PwDefs.TitleField, new ProtectedString(false, hspCard.Name)); if(!string.IsNullOrEmpty(hspCard.Note)) pe.Strings.Set(PwDefs.NotesField, new ProtectedString(false, hspCard.Note)); if(hspCard.Fields == null) return; foreach(HspField fld in hspCard.Fields) { if(fld == null) { Debug.Assert(false); continue; } if(string.IsNullOrEmpty(fld.Name) || string.IsNullOrEmpty(fld.Value)) continue; string strKey = ImportUtil.MapNameToStandardField(fld.Name, true); if(string.IsNullOrEmpty(strKey)) strKey = fld.Name; string strValue = pe.Strings.ReadSafe(strKey); if(strValue.Length > 0) strValue += ", "; strValue += fld.Value; pe.Strings.Set(strKey, new ProtectedString(false, strValue)); } } } } keepass2-2.25/KeePass/DataExchange/Formats/NortonIdSafeCsv2013.cs0000664000175000017500000000566512261553106024256 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using System.Globalization; using System.Drawing; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 2013.4.0.10 internal sealed class NortonIdSafeCsv2013 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Norton Identity Safe CSV"; } } public override string DefaultExtension { get { return "csv"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_NortonIdSafe; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Unicode, true); string strData = sr.ReadToEnd(); sr.Close(); CsvOptions opt = new CsvOptions(); opt.BackslashIsEscape = false; CsvStreamReaderEx csv = new CsvStreamReaderEx(strData, opt); while(true) { string[] v = csv.ReadLine(); if(v == null) break; if(v.Length < 5) continue; if(v[0].Equals("url", StrUtil.CaseIgnoreCmp) && v[1].Equals("username", StrUtil.CaseIgnoreCmp) && v[2].Equals("password", StrUtil.CaseIgnoreCmp)) continue; // Header PwGroup pg = pwStorage.RootGroup; string strGroup = v[4]; if(!string.IsNullOrEmpty(strGroup)) pg = pg.FindCreateGroup(strGroup, true); PwEntry pe = new PwEntry(true, true); pg.AddEntry(pe, true); ImportUtil.AppendToField(pe, PwDefs.UrlField, v[0], pwStorage); ImportUtil.AppendToField(pe, PwDefs.UserNameField, v[1], pwStorage); ImportUtil.AppendToField(pe, PwDefs.PasswordField, v[2], pwStorage); ImportUtil.AppendToField(pe, PwDefs.TitleField, v[3], pwStorage); } } } } keepass2-2.25/KeePass/DataExchange/Formats/KeePassXml2x.cs0000664000175000017500000000501012261553106023207 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using KeePass.Resources; using KeePassLib; using KeePassLib.Collections; using KeePassLib.Interfaces; using KeePassLib.Serialization; namespace KeePass.DataExchange.Formats { internal sealed class KeePassXml2x : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return true; } } public override string FormatName { get { return "KeePass XML (2.x)"; } } public override string DefaultExtension { get { return "xml"; } } public override string ApplicationGroup { get { return PwDefs.ShortProductName; } } public override bool SupportsUuids { get { return true; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Binary; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { KdbxFile kdbx = new KdbxFile(pwStorage); kdbx.Load(sInput, KdbxFormat.PlainXml, slLogger); } public override bool Export(PwExportInfo pwExportInfo, Stream sOutput, IStatusLogger slLogger) { PwDatabase pd = (pwExportInfo.ContextDatabase ?? new PwDatabase()); PwObjectList vDel = null; if(pwExportInfo.ExportDeletedObjects == false) { vDel = pd.DeletedObjects.CloneShallow(); pd.DeletedObjects.Clear(); } KdbxFile kdb = new KdbxFile(pd); kdb.Save(sOutput, pwExportInfo.DataGroup, KdbxFormat.PlainXml, slLogger); // Restore deleted objects list if(vDel != null) pd.DeletedObjects.Add(vDel); return true; } } } keepass2-2.25/KeePass/DataExchange/Formats/TurboPwsCsv5.cs0000664000175000017500000000772512261553106023266 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using System.Globalization; using System.Drawing; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; namespace KeePass.DataExchange.Formats { // 5.0.1+ internal sealed class TurboPwsCsv5 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "TurboPasswords CSV"; } } public override string DefaultExtension { get { return "csv"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return Properties.Resources.B16x16_Imp_TurboPws; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); string strData = sr.ReadToEnd(); sr.Close(); sInput.Close(); Dictionary dGroups = new Dictionary(); dGroups[string.Empty] = pwStorage.RootGroup; CsvOptions opt = new CsvOptions(); opt.BackslashIsEscape = false; CsvStreamReaderEx csv = new CsvStreamReaderEx(strData, opt); while(true) { string[] v = csv.ReadLine(); if(v == null) break; if(v.Length == 0) continue; if(v[0].StartsWith("TurboPasswords CSV Export File")) continue; if(v.Length < 24) { Debug.Assert(false); continue; } if((v[0] == "Category") && (v[1] == "Type")) continue; PwEntry pe = new PwEntry(true, true); PwGroup pg; string strGroup = v[0]; if(!dGroups.TryGetValue(strGroup, out pg)) { pg = new PwGroup(true, true, strGroup, PwIcon.Folder); dGroups[string.Empty].AddGroup(pg, true); dGroups[strGroup] = pg; } pg.AddEntry(pe, true); string strType = v[1]; for(int f = 0; f < 6; ++f) { string strKey = v[2 + (2 * f)]; string strValue = v[2 + (2 * f) + 1]; if(strKey.Length == 0) strKey = PwDefs.NotesField; if(strValue.Length == 0) continue; if(strKey == "Description") strKey = PwDefs.TitleField; else if(((strType == "Contact") || (strType == "Personal Info")) && (strKey == "Name")) strKey = PwDefs.TitleField; else if(((strType == "Membership") || (strType == "Insurance")) && (strKey == "Company")) strKey = PwDefs.TitleField; else if(strKey == "SSN") strKey = PwDefs.UserNameField; else { string strMapped = ImportUtil.MapNameToStandardField(strKey, false); if(!string.IsNullOrEmpty(strMapped)) strKey = strMapped; } ImportUtil.AppendToField(pe, strKey, strValue, pwStorage, ((strKey == PwDefs.NotesField) ? "\r\n" : ", "), false); } ImportUtil.AppendToField(pe, PwDefs.NotesField, v[20], pwStorage, "\r\n\r\n", false); if(v[21].Length > 0) ImportUtil.AppendToField(pe, "Login URL", v[21], pwStorage, null, true); } } } } keepass2-2.25/KeePass/DataExchange/Formats/MozillaBookmarksHtml100.cs0000664000175000017500000001775512261553106025272 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Xml; using System.IO; using System.Drawing; using System.Drawing.Imaging; using System.Diagnostics; using KeePass.Resources; using KeePass.UI; using KeePass.Util; using KeePassLib; using KeePassLib.Cryptography; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 1.00 internal sealed class MozillaBookmarksHtml100 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Mozilla Bookmarks HTML"; } } public override string DefaultExtension { get { return @"html|htm"; } } public override string ApplicationGroup { get { return KPRes.Browser; } } // public override bool ImportAppendsToRootGroupOnly { get { return false; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_ASCII; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.UTF8); string strContent = sr.ReadToEnd(); sr.Close(); if(strContent.IndexOf(@"") < 0) throw new FormatException("Invalid DOCTYPE!"); strContent = strContent.Replace(@"", string.Empty); strContent = strContent.Replace(@"
", string.Empty); strContent = strContent.Replace(@"

", string.Empty); // strContent = strContent.Replace(@"

", string.Empty); // strContent = strContent.Replace(@"
", string.Empty); // strContent = strContent.Replace(@"
", string.Empty); strContent = strContent.Replace(@"
", string.Empty); // int nOffset = strContent.IndexOf('&'); // while(nOffset >= 0) // { // string str4 = strContent.Substring(nOffset, 4); // string str5 = strContent.Substring(nOffset, 5); // string str6 = strContent.Substring(nOffset, 6); // if((str6 != @" ") && (str5 != @"&") && (str4 != @"<") && // (str4 != @">") && (str5 != @"'") && (str6 != @""")) // { // strContent = strContent.Remove(nOffset, 1); // strContent = strContent.Insert(nOffset, @"&"); // } // else nOffset = strContent.IndexOf('&', nOffset + 1); // } string[] vPreserve = new string[] { @" ", @"&", @"<", @">", @"'", @""" }; Dictionary dPreserve = new Dictionary(); CryptoRandom cr = CryptoRandom.Instance; foreach(string strPreserve in vPreserve) { string strCode = Convert.ToBase64String(cr.GetRandomBytes(16)); Debug.Assert(strCode.IndexOf('&') < 0); dPreserve[strPreserve] = strCode; strContent = strContent.Replace(strPreserve, strCode); } strContent = strContent.Replace(@"&", @"&"); foreach(KeyValuePair kvpPreserve in dPreserve) { strContent = strContent.Replace(kvpPreserve.Value, kvpPreserve.Key); } // Terminate
s int iDD = -1; while(true) { iDD = strContent.IndexOf(@"
", iDD + 1); if(iDD < 0) break; int iNextTag = strContent.IndexOf('<', iDD + 1); if(iNextTag <= 0) { Debug.Assert(false); break; } strContent = strContent.Insert(iNextTag, @"
"); } strContent = "" + strContent + ""; byte[] pbFixedData = StrUtil.Utf8.GetBytes(strContent); MemoryStream msFixed = new MemoryStream(pbFixedData, false); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(msFixed); msFixed.Close(); XmlNode xmlRoot = xmlDoc.DocumentElement; foreach(XmlNode xmlChild in xmlRoot) { if(xmlChild.Name == "META") ImportMeta(xmlChild, pwStorage); } } private static void ImportMeta(XmlNode xmlNode, PwDatabase pwStorage) { foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name == "DL") ImportGroup(xmlChild, pwStorage, pwStorage.RootGroup); else if(xmlChild.Name == "TITLE") { } else if(xmlChild.Name == "H1") { } else { Debug.Assert(false); } } } private static void ImportGroup(XmlNode xmlNode, PwDatabase pwStorage, PwGroup pg) { PwGroup pgSub = pg; PwEntry pe = null; foreach(XmlNode xmlChild in xmlNode) { if(xmlChild.Name == "A") { pe = new PwEntry(true, true); pg.AddEntry(pe, true); pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, XmlUtil.SafeInnerText(xmlChild))); XmlNode xnUrl = xmlChild.Attributes.GetNamedItem("HREF"); if((xnUrl != null) && (xnUrl.Value != null)) pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pwStorage.MemoryProtection.ProtectUrl, xnUrl.Value)); else { Debug.Assert(false); } // pe.Strings.Set("RDF_ID", new ProtectedString( // false, xmlChild.Attributes.GetNamedItem("ID").Value)); ImportIcon(xmlChild, pe, pwStorage); } else if(xmlChild.Name == "DD") { if(pe != null) ImportUtil.AppendToField(pe, PwDefs.NotesField, XmlUtil.SafeInnerText(xmlChild).Trim(), pwStorage, "\r\n", false); else { Debug.Assert(false); } } else if(xmlChild.Name == "H3") { string strGroup = XmlUtil.SafeInnerText(xmlChild); if(strGroup.Length == 0) { Debug.Assert(false); pgSub = pg; } else { pgSub = new PwGroup(true, true, strGroup, PwIcon.Folder); pg.AddGroup(pgSub, true); } } else if(xmlChild.Name == "DL") ImportGroup(xmlChild, pwStorage, pgSub); else { Debug.Assert(false); } } } private static void ImportIcon(XmlNode xn, PwEntry pe, PwDatabase pd) { XmlNode xnIcon = xn.Attributes.GetNamedItem("ICON"); if(xnIcon == null) return; string strIcon = xnIcon.Value; if(!StrUtil.IsDataUri(strIcon)) { Debug.Assert(false); return; } try { byte[] pbImage = StrUtil.DataUriToData(strIcon); if((pbImage == null) || (pbImage.Length == 0)) { Debug.Assert(false); return; } Image img = GfxUtil.LoadImage(pbImage); if(img == null) { Debug.Assert(false); return; } byte[] pbPng; if((img.Width == 16) && (img.Height == 16)) { MemoryStream msPng = new MemoryStream(); img.Save(msPng, ImageFormat.Png); pbPng = msPng.ToArray(); msPng.Close(); } else { Bitmap bmp = UIUtil.CreateScaledImage(img, 16, 16); MemoryStream msPng = new MemoryStream(); bmp.Save(msPng, ImageFormat.Png); pbPng = msPng.ToArray(); msPng.Close(); bmp.Dispose(); } img.Dispose(); PwUuid pwUuid = null; int iEx = pd.GetCustomIconIndex(pbPng); if(iEx >= 0) pwUuid = pd.CustomIcons[iEx].Uuid; else { pwUuid = new PwUuid(true); pd.CustomIcons.Add(new PwCustomIcon(pwUuid, pbPng)); pd.UINeedsIconUpdate = true; pd.Modified = true; } pe.CustomIconUuid = pwUuid; } catch(Exception) { Debug.Assert(false); } } } } keepass2-2.25/KeePass/DataExchange/Formats/RevelationXml04.cs0000664000175000017500000001432112261553106023663 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 System.Xml; using KeePass.Resources; using KeePass.Util; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Utility; using KeePassLib.Security; namespace KeePass.DataExchange.Formats { internal sealed class RevelationXml04 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Revelation XML"; } } public override string DefaultExtension { get { return "xml"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_Revelation; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.UTF8); string strDoc = sr.ReadToEnd(); sr.Close(); XmlDocument doc = new XmlDocument(); doc.LoadXml(strDoc); ProcessEntries(pwStorage, pwStorage.RootGroup, doc.DocumentElement.ChildNodes); } private static void ProcessEntries(PwDatabase pd, PwGroup pgParent, XmlNodeList xlNodes) { foreach(XmlNode xmlChild in xlNodes) { if(xmlChild.Name == "entry") { XmlNode xnType = xmlChild.Attributes.GetNamedItem("type"); if(xnType == null) { Debug.Assert(false); } else { if(xnType.Value == "folder") ImportGroup(pd, pgParent, xmlChild); else ImportEntry(pd, pgParent, xmlChild); } } } } private static void ImportGroup(PwDatabase pd, PwGroup pgParent, XmlNode xmlNode) { PwGroup pg = new PwGroup(true, true); foreach(XmlNode xmlChild in xmlNode.ChildNodes) { if(xmlChild.Name == "name") pg.Name = XmlUtil.SafeInnerText(xmlChild); else if(xmlChild.Name == "description") pg.Notes = XmlUtil.SafeInnerText(xmlChild); else if(xmlChild.Name == "entry") { } else if(xmlChild.Name == "updated") pg.LastModificationTime = ImportTime(xmlChild); else { Debug.Assert(false); } } pgParent.AddGroup(pg, true); ProcessEntries(pd, pg, xmlNode.ChildNodes); } private static void ImportEntry(PwDatabase pd, PwGroup pgParent, XmlNode xmlNode) { PwEntry pe = new PwEntry(true, true); pgParent.AddEntry(pe, true); foreach(XmlNode xmlChild in xmlNode.ChildNodes) { if(xmlChild.Name == "name") pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pd.MemoryProtection.ProtectTitle, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == "description") pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pd.MemoryProtection.ProtectNotes, XmlUtil.SafeInnerText(xmlChild))); else if(xmlChild.Name == "updated") pe.LastModificationTime = ImportTime(xmlChild); else if(xmlChild.Name == "field") { XmlNode xnName = xmlChild.Attributes.GetNamedItem("id"); if(xnName == null) { Debug.Assert(false); } else { KeyValuePair kvp = MapFieldName(xnName.Value, pd); pe.Strings.Set(kvp.Key, new ProtectedString(kvp.Value, XmlUtil.SafeInnerText(xmlChild))); } } else { Debug.Assert(false); } } } private static KeyValuePair MapFieldName(string strFieldName, PwDatabase pdContext) { switch(strFieldName) { case "creditcard-cardnumber": case "generic-username": case "generic-location": case "phone-phonenumber": return new KeyValuePair(PwDefs.UserNameField, pdContext.MemoryProtection.ProtectUserName); case "generic-code": case "generic-password": case "generic-pin": return new KeyValuePair(PwDefs.PasswordField, pdContext.MemoryProtection.ProtectPassword); case "generic-hostname": case "generic-url": return new KeyValuePair(PwDefs.UrlField, pdContext.MemoryProtection.ProtectUrl); case "creditcard-cardtype": return new KeyValuePair("Card Type", false); case "creditcard-expirydate": return new KeyValuePair(KPRes.ExpiryTime, false); case "creditcard-ccv": return new KeyValuePair("CCV Number", false); case "generic-certificate": return new KeyValuePair("Certificate", false); case "generic-keyfile": return new KeyValuePair("Key File", false); case "generic-database": return new KeyValuePair(KPRes.Database, false); case "generic-email": return new KeyValuePair(KPRes.EMail, false); case "generic-port": return new KeyValuePair("Port", false); case "generic-domain": return new KeyValuePair("Domain", false); default: Debug.Assert(false); break; } return new KeyValuePair(strFieldName, false); } private static DateTime ImportTime(XmlNode xn) { string str = XmlUtil.SafeInnerText(xn); double dtUnix; if(!double.TryParse(str, out dtUnix)) { Debug.Assert(false); } else return TimeUtil.ConvertUnixTime(dtUnix); return DateTime.Now; } } } keepass2-2.25/KeePass/DataExchange/Formats/SplashIdCsv402.cs0000664000175000017500000002072012261553106023337 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using System.Diagnostics; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.DataExchange.Formats { // 4.02-5.3+ internal sealed class SplashIdCsv402 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "SplashID CSV"; } } public override string DefaultExtension { get { return "csv"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override bool ImportAppendsToRootGroupOnly { get { return false; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_SplashID; } } private const string StrHeader = "SplashID Export File"; private static SplashIdMapping[] m_vMappings = null; private static SplashIdMapping[] SplashIdMappings { get { if(m_vMappings != null) return m_vMappings; m_vMappings = new SplashIdMapping[]{ new SplashIdMapping("Bank Accts", PwIcon.Homebanking, new string[]{ PwDefs.TitleField, "Account #", PwDefs.PasswordField, PwDefs.UserNameField, "Branch", "Phone #" }), new SplashIdMapping("Birthdays", PwIcon.UserCommunication, new string[]{ PwDefs.TitleField, "Date" }), new SplashIdMapping("Calling Cards", PwIcon.EMail, new string[]{ PwDefs.TitleField, PwDefs.UserNameField, PwDefs.PasswordField }), new SplashIdMapping("Clothes Size", PwIcon.UserCommunication, new string[]{ PwDefs.TitleField, "Shirt Size", "Pant Size", "Shoe Size", "Dress Size" }), new SplashIdMapping("Combinations", PwIcon.Key, new string[]{ PwDefs.TitleField, PwDefs.PasswordField }), new SplashIdMapping("Credit Cards", PwIcon.UserKey, new string[]{ PwDefs.TitleField, "Card #", "Expiration Date", PwDefs.UserNameField, PwDefs.PasswordField, "Bank" }), new SplashIdMapping("Email Accts", PwIcon.EMail, new string[]{ PwDefs.TitleField, PwDefs.UserNameField, PwDefs.PasswordField, "POP3 Host", "SMTP Host" }), new SplashIdMapping("Emergency Info", PwIcon.UserCommunication, new string[]{ PwDefs.TitleField, PwDefs.UserNameField }), new SplashIdMapping("Frequent Flyer", PwIcon.PaperQ, new string[]{ PwDefs.TitleField, "Number", PwDefs.UserNameField, "Date" }), new SplashIdMapping("Identification", PwIcon.UserKey, new string[]{ PwDefs.TitleField, PwDefs.PasswordField, PwDefs.UserNameField, "Date" }), new SplashIdMapping("Insurance", PwIcon.ClipboardReady, new string[]{ PwDefs.TitleField, PwDefs.PasswordField, PwDefs.UserNameField, "Insured", "Date" }), new SplashIdMapping("Memberships", PwIcon.UserKey, new string[]{ PwDefs.TitleField, PwDefs.PasswordField, PwDefs.UserNameField, "Date" }), new SplashIdMapping("Phone Numbers", PwIcon.UserCommunication, new string[]{ PwDefs.TitleField, PwDefs.UserNameField }), new SplashIdMapping("Prescriptions", PwIcon.ClipboardReady, new string[]{ PwDefs.TitleField, PwDefs.PasswordField, PwDefs.UserNameField, "Doctor", "Pharmacy", "Phone #" }), new SplashIdMapping("Serial Numbers", PwIcon.Key, new string[]{ PwDefs.TitleField, PwDefs.PasswordField, "Purchase Date", "Reseller" }), new SplashIdMapping("Vehicle Info", PwIcon.PaperReady, new string[]{ PwDefs.TitleField, PwDefs.UserNameField, PwDefs.PasswordField }), new SplashIdMapping("Voice Mail", PwIcon.IRCommunication, new string[]{ PwDefs.TitleField, PwDefs.UserNameField, PwDefs.PasswordField }), new SplashIdMapping("Web Logins", PwIcon.UserKey, new string[]{ PwDefs.TitleField, PwDefs.UserNameField, PwDefs.PasswordField, PwDefs.UrlField }) }; return m_vMappings; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); string strData = sr.ReadToEnd(); sr.Close(); string[] vLines = strData.Split(new char[]{ '\r', '\n' }); SortedDictionary dictGroups = new SortedDictionary(); foreach(string strLine in vLines) { if(strLine.Length > 0) ProcessCsvLine(strLine, pwStorage, dictGroups); } } private static void ProcessCsvLine(string strLine, PwDatabase pwStorage, SortedDictionary dictGroups) { if(strLine == StrHeader) return; // Skip header List list = ImportUtil.SplitCsvLine(strLine, ","); Debug.Assert(list.Count == 13); if(list.Count != 13) return; string strType = ParseCsvWord(list[0]); string strGroupName = ParseCsvWord(list[12]) + " - " + strType; SplashIdMapping mp = null; foreach(SplashIdMapping mpFind in SplashIdCsv402.SplashIdMappings) { if(mpFind.TypeName == strType) { mp = mpFind; break; } } PwIcon pwIcon = ((mp != null) ? mp.Icon : PwIcon.Key); PwGroup pg = null; if(dictGroups.ContainsKey(strGroupName)) pg = dictGroups[strGroupName]; else { PwIcon pwGroupIcon = ((pwIcon == PwIcon.Key) ? PwIcon.FolderOpen : pwIcon); pg = new PwGroup(true, true, strGroupName, pwGroupIcon); pwStorage.RootGroup.AddGroup(pg, true); dictGroups.Add(strGroupName, pg); } PwEntry pe = new PwEntry(true, true); pg.AddEntry(pe, true); pe.IconId = pwIcon; for(int iField = 0; iField < 9; ++iField) { string strData = ParseCsvWord(list[iField + 1]); if(strData.Length == 0) continue; string strLookup = ((mp != null) ? mp.FieldNames[iField] : null); string strField = (strLookup ?? ("Field " + (iField + 1).ToString())); pe.Strings.Set(strField, new ProtectedString(false, strData)); } pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, ParseCsvWord(list[11]))); DateTime? dt = TimeUtil.ParseUSTextDate(ParseCsvWord(list[10])); if(dt.HasValue) { pe.LastAccessTime = dt.Value; pe.LastModificationTime = dt.Value; } } private static string ParseCsvWord(string strWord) { string str = strWord.Trim(new char[]{ '\"' }); str = str.Replace("\"\"", "\""); // Unescape quotes str = str.Replace((char)0x0B, '\n'); // 0x0B = new line str = str.Replace("\r", string.Empty); str = str.Replace("\n", "\r\n"); // To Windows new lines return str; } private sealed class SplashIdMapping { private string m_strTypeName; public string TypeName { get { return m_strTypeName; } } private PwIcon m_pwIcon; public PwIcon Icon { get { return m_pwIcon; } } private string[] m_vFieldNames = new string[9]; public string[] FieldNames { get { return m_vFieldNames; } } public SplashIdMapping(string strTypeName, PwIcon pwIcon, string[] vFieldNames) { Debug.Assert(strTypeName != null); if(strTypeName == null) throw new ArgumentNullException("strTypeName"); Debug.Assert(vFieldNames != null); if(vFieldNames == null) throw new ArgumentNullException("vFieldNames"); m_strTypeName = strTypeName; m_pwIcon = pwIcon; for(int i = 0; i < Math.Min(m_vFieldNames.Length, vFieldNames.Length); ++i) m_vFieldNames[i] = vFieldNames[i]; } } } } keepass2-2.25/KeePass/DataExchange/Formats/PwKeeperCsv70.cs0000664000175000017500000000702012261553106023271 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Diagnostics; using System.Globalization; using System.Drawing; using KeePass.Resources; using KeePassLib; using KeePassLib.Interfaces; using KeePassLib.Security; namespace KeePass.DataExchange.Formats { // 7.0 internal sealed class PwKeeperCsv70 : FileFormatProvider { public override bool SupportsImport { get { return true; } } public override bool SupportsExport { get { return false; } } public override string FormatName { get { return "Password Keeper CSV"; } } public override string DefaultExtension { get { return "csv"; } } public override string ApplicationGroup { get { return KPRes.PasswordManagers; } } public override bool ImportAppendsToRootGroupOnly { get { return true; } } public override Image SmallIcon { get { return KeePass.Properties.Resources.B16x16_Imp_Whisper32; } } public override void Import(PwDatabase pwStorage, Stream sInput, IStatusLogger slLogger) { StreamReader sr = new StreamReader(sInput, Encoding.Default); string strData = sr.ReadToEnd(); sr.Close(); string[] vLines = strData.Split(new char[] { '\r', '\n' }); foreach(string strLine in vLines) { if(strLine.Length > 5) ProcessCsvLine(strLine, pwStorage); } } private static void ProcessCsvLine(string strLine, PwDatabase pwStorage) { List list = ImportUtil.SplitCsvLine(strLine, ","); Debug.Assert(list.Count == 5); PwEntry pe = new PwEntry(true, true); pwStorage.RootGroup.AddEntry(pe, true); if(list.Count == 5) { pe.Strings.Set(PwDefs.TitleField, new ProtectedString( pwStorage.MemoryProtection.ProtectTitle, ProcessCsvWord(list[0]))); pe.Strings.Set(PwDefs.UserNameField, new ProtectedString( pwStorage.MemoryProtection.ProtectUserName, ProcessCsvWord(list[1]))); pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( pwStorage.MemoryProtection.ProtectPassword, ProcessCsvWord(list[2]))); pe.Strings.Set(PwDefs.UrlField, new ProtectedString( pwStorage.MemoryProtection.ProtectUrl, ProcessCsvWord(list[3]))); pe.Strings.Set(PwDefs.NotesField, new ProtectedString( pwStorage.MemoryProtection.ProtectNotes, ProcessCsvWord(list[4]))); } else throw new FormatException("Invalid field count!"); } private static string ProcessCsvWord(string strWord) { if(strWord == null) return string.Empty; if(strWord.Length < 2) return strWord; if(strWord.StartsWith("\"") && strWord.EndsWith("\"")) return strWord.Substring(1, strWord.Length - 2); return strWord; } } } keepass2-2.25/KeePass/KeePass.pfx0000664000175000017500000000333410576764760016545 0ustar jtaylorjtaylor00 *H 0}0 *H 00 *H  00 *H  05D?*dI& |i&fKG;#!΀%R[m)ZwQoT>ybv[O$Rd3OWo7c4;תBvft87 5SG LLP4AiF2L[+ )$as(Q+Oݷ+hț[#~)[jgriL8V(C3=JpzĺV 3:|<`N8+؃8, tjؚyD5֙,X2ut_."h/^+ɳ)oAL̒*Yv3V윎,J3kgLp/s(AqPԼH^˪Ͳ;6L$ 8̒/Ya\J7zl0+/eϬ!!v,(7w&ٝ|mQZmI];8FVW.";> r'E gӟ.4{j<(C ҉v9&g>+9= 9}z7Dݗ]2>y%o,^9߸E69Rd_yYaļI6h>'3s=7haT<$t\1BOJuHsw3dMBjW"F~aؒz>um+yj8S!X*ZР#D!;*q^1-28=p'>[ɠ> !\8CY5qM~}dWBx~I`߃m@%wz'mBqlCd |~E~Q4nvwm0d΢pJ4\Z46`W|Uc Ut10;00+&cr{ 5FL~!4Sqn.Ckeepass2-2.25/KeePass/Forms/0000775000175000017500000000000012273660422015540 5ustar jtaylorjtaylorkeepass2-2.25/KeePass/Forms/DatabaseOperationsForm.cs0000664000175000017500000001012712261553106022461 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePass.UI; using KeePass.Resources; using KeePassLib; using KeePassLib.Delegates; namespace KeePass.Forms { public partial class DatabaseOperationsForm : Form, IGwmWindow { private PwDatabase m_pwDatabase = null; private bool m_bModified = false; public bool CanCloseWithoutDataLoss { get { return true; } } public bool HasModifiedDatabase { get { return m_bModified; } } public void InitEx(PwDatabase pwDatabase) { m_pwDatabase = pwDatabase; } public DatabaseOperationsForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_pwDatabase != null); if(m_pwDatabase == null) throw new InvalidOperationException(); GlobalWindowManager.AddWindow(this, this); BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_Package_Settings, KPRes.DatabaseMaintenance, KPRes.DatabaseMaintenanceDesc); this.Icon = Properties.Resources.KeePass; this.Text = KPRes.DatabaseMaintenance; m_numHistoryDays.Value = m_pwDatabase.MaintenanceHistoryDays; m_pbStatus.Visible = false; } private void OnBtnClose(object sender, EventArgs e) { m_pwDatabase.MaintenanceHistoryDays = (uint)m_numHistoryDays.Value; } private void EnableStatusMsgEx(bool bEnable) { if(bEnable) { m_btnClose.Enabled = m_btnHistoryEntriesDelete.Enabled = m_btnRemoveDelObjInfo.Enabled = false; if(!m_pbStatus.Visible) m_pbStatus.Visible = true; m_pbStatus.Value = 0; } else { m_btnClose.Enabled = m_btnHistoryEntriesDelete.Enabled = m_btnRemoveDelObjInfo.Enabled = true; m_pbStatus.Value = m_pbStatus.Maximum; } } private void OnBtnDelete(object sender, EventArgs e) { EnableStatusMsgEx(true); DateTime dtNow = DateTime.Now; TimeSpan tsSpan = new TimeSpan((int)m_numHistoryDays.Value, 0, 0, 0); uint uNumGroups, uNumEntries; m_pwDatabase.RootGroup.GetCounts(true, out uNumGroups, out uNumEntries); uint uCurEntryNumber = 1; EntryHandler eh = delegate(PwEntry pe) { for(uint u = 0; u < pe.History.UCount; ++u) { PwEntry peHist = pe.History.GetAt(u); if((dtNow - peHist.LastModificationTime) >= tsSpan) { pe.History.Remove(peHist); --u; m_bModified = true; } } m_pbStatus.Value = (int)((uCurEntryNumber * 100) / uNumEntries); ++uCurEntryNumber; return true; }; m_pwDatabase.RootGroup.TraverseTree(TraversalMethod.PreOrder, null, eh); EnableStatusMsgEx(false); // Database is set modified by parent } private void OnFormClosed(object sender, FormClosedEventArgs e) { GlobalWindowManager.RemoveWindow(this); } private void OnBtnRemoveDelObjInfo(object sender, EventArgs e) { EnableStatusMsgEx(true); if(m_pwDatabase.DeletedObjects.UCount > 0) { m_pwDatabase.DeletedObjects.Clear(); m_bModified = true; } EnableStatusMsgEx(false); // Database is set modified by parent } } } keepass2-2.25/KeePass/Forms/FileBrowserForm.resx0000664000175000017500000001326611536411230021512 0ustar jtaylorjtaylor 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 keepass2-2.25/KeePass/Forms/IOConnectionForm.resx0000664000175000017500000001326611676655724021645 0ustar jtaylorjtaylor 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 keepass2-2.25/KeePass/Forms/OptionsForm.cs0000664000175000017500000010254012261553106020345 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePass.App; using KeePass.App.Configuration; using KeePass.UI; using KeePass.Resources; using KeePass.Util; using KeePassLib; using KeePassLib.Serialization; using KeePassLib.Utility; using NativeLib = KeePassLib.Native.NativeLib; namespace KeePass.Forms { /// /// Options dialog. In this dialog, global program options can be configured. /// public partial class OptionsForm : Form { private ImageList m_ilIcons; private BannerStyle m_curBannerStyle = BannerStyle.KeePassWin32; private bool m_bBlockUIUpdate = false; private bool m_bLoadingSettings = false; private CheckedLVItemDXList m_cdxSecurityOptions = null; private CheckedLVItemDXList m_cdxPolicy = null; private CheckedLVItemDXList m_cdxGuiOptions = null; private CheckedLVItemDXList m_cdxAdvanced = null; private HotKeyControlEx m_hkGlobalAutoType = null; private HotKeyControlEx m_hkSelectedAutoType = null; private HotKeyControlEx m_hkShowWindow = null; private Keys m_kPrevATHKKey = Keys.None; private Keys m_kPrevATSHKKey = Keys.None; private Keys m_kPrevSWHKKey = Keys.None; private AceUrlSchemeOverrides m_aceUrlSchemeOverrides = null; private bool m_bInitialTsRenderer = true; public bool RequiresUIReinitialize { get { return Program.Config.UI.UseCustomToolStripRenderer != m_bInitialTsRenderer; } } public OptionsForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } public void InitEx(ImageList ilIcons) { InitEx(ilIcons, false); } public void InitEx(ImageList ilIcons, bool bForceInTaskbar) { Debug.Assert(ilIcons != null); m_ilIcons = ilIcons; // Set ShowInTaskbar immediately, not later, otherwise the form // can disappear: // https://sourceforge.net/p/keepass/discussion/329220/thread/c95b5644/ if(bForceInTaskbar) this.ShowInTaskbar = true; } private void CreateDialogBanner(BannerStyle bsStyle) { if(bsStyle == m_curBannerStyle) return; m_curBannerStyle = bsStyle; m_bannerImage.Image = BannerFactory.CreateBanner(m_bannerImage.Width, m_bannerImage.Height, bsStyle, Properties.Resources.B48x48_KCMSystem, KPRes.Options, KPRes.OptionsDesc); } private void OnFormLoad(object sender, EventArgs e) { // Can be invoked by tray command; don't use CenterParent Debug.Assert(this.StartPosition == FormStartPosition.CenterScreen); GlobalWindowManager.AddWindow(this); this.Icon = Properties.Resources.KeePass; Debug.Assert(m_ilIcons != null); if(m_ilIcons != null) { m_tabMain.ImageList = m_ilIcons; m_tabSecurity.ImageIndex = (int)PwIcon.TerminalEncrypted; m_tabPolicy.ImageIndex = (int)PwIcon.List; m_tabGui.ImageIndex = (int)PwIcon.Screen; m_tabIntegration.ImageIndex = (int)PwIcon.Console; m_tabAdvanced.ImageIndex = (int)PwIcon.ClipboardReady; } uint uTab = Program.Config.Defaults.OptionsTabIndex; if(uTab < (uint)m_tabMain.TabPages.Count) m_tabMain.SelectedTab = m_tabMain.TabPages[(int)uTab]; m_aceUrlSchemeOverrides = Program.Config.Integration.UrlSchemeOverrides.CloneDeep(); m_cmbBannerStyle.Items.Add("(" + KPRes.CurrentStyle + ")"); m_cmbBannerStyle.Items.Add("WinXP Login"); m_cmbBannerStyle.Items.Add("WinVista Black"); m_cmbBannerStyle.Items.Add("KeePass Win32"); m_cmbBannerStyle.Items.Add("Blue Carbon"); CreateDialogBanner(BannerStyle.Default); // Default forces generation m_cmbBannerStyle.SelectedIndex = (int)BannerStyle.Default; if((BannerFactory.CustomGenerator != null) || AppConfigEx.IsOptionEnforced(Program.Config.UI, "BannerStyle")) { m_lblBannerStyle.Enabled = false; m_cmbBannerStyle.Enabled = false; } int nWidth = m_lvPolicy.ClientRectangle.Width - UIUtil.GetVScrollBarWidth() - 1; m_lvPolicy.Columns.Add(KPRes.Feature, (nWidth * 10) / 29); m_lvPolicy.Columns.Add(KPRes.Description, (nWidth * 19) / 29); m_hkGlobalAutoType = HotKeyControlEx.ReplaceTextBox(m_grpHotKeys, m_tbGlobalAutoType, false); m_hkSelectedAutoType = HotKeyControlEx.ReplaceTextBox(m_grpHotKeys, m_tbSelAutoTypeHotKey, false); m_hkShowWindow = HotKeyControlEx.ReplaceTextBox(m_grpHotKeys, m_tbShowWindowHotKey, false); if(!NativeLib.IsUnix()) { UIUtil.SetShield(m_btnFileExtCreate, true); UIUtil.SetShield(m_btnFileExtRemove, true); m_linkHotKeyHelp.Visible = false; } else // Unix { Program.Config.Integration.HotKeyGlobalAutoType = (ulong)Keys.None; Program.Config.Integration.HotKeySelectedAutoType = (ulong)Keys.None; Program.Config.Integration.HotKeyShowWindow = (ulong)Keys.None; m_hkGlobalAutoType.Enabled = m_hkSelectedAutoType.Enabled = m_hkShowWindow.Enabled = false; m_btnFileExtCreate.Enabled = m_btnFileExtRemove.Enabled = false; m_cbAutoRun.Enabled = false; } UIUtil.SetExplorerTheme(m_lvSecurityOptions, false); UIUtil.SetExplorerTheme(m_lvPolicy, false); UIUtil.SetExplorerTheme(m_lvGuiOptions, false); UIUtil.SetExplorerTheme(m_lvAdvanced, false); AppConfigEx.ClearXmlPathCache(); LoadOptions(); // if(Program.Config.Meta.IsEnforcedConfiguration) // m_lvPolicy.Enabled = false; UpdateUIState(); } private void LoadOptions() { m_bLoadingSettings = true; LoadSecurityOptions(); LoadPolicyOptions(); LoadGuiOptions(); LoadIntegrationOptions(); LoadAdvancedOptions(); m_bLoadingSettings = false; } private void LoadSecurityOptions() { AceWorkspaceLocking aceWL = Program.Config.Security.WorkspaceLocking; uint uLockTime = aceWL.LockAfterTime; bool bLockTime = (uLockTime > 0); m_numLockAfterTime.Value = (bLockTime ? uLockTime : 300); m_cbLockAfterTime.Checked = bLockTime; if(AppConfigEx.IsOptionEnforced(aceWL, "LockAfterTime")) m_cbLockAfterTime.Enabled = false; uLockTime = aceWL.LockAfterGlobalTime; bLockTime = (uLockTime > 0); m_numLockAfterGlobalTime.Value = (bLockTime ? uLockTime : 240); m_cbLockAfterGlobalTime.Checked = bLockTime; if(AppConfigEx.IsOptionEnforced(aceWL, "LockAfterGlobalTime")) m_cbLockAfterGlobalTime.Enabled = false; int nDefaultExpireDays = Program.Config.Defaults.NewEntryExpiresInDays; if(nDefaultExpireDays < 0) m_cbDefaultExpireDays.Checked = false; else { m_cbDefaultExpireDays.Checked = true; try { m_numDefaultExpireDays.Value = nDefaultExpireDays; } catch(Exception) { Debug.Assert(false); } } if(AppConfigEx.IsOptionEnforced(Program.Config.Defaults, "NewEntryExpiresInDays")) m_cbDefaultExpireDays.Enabled = false; int nClipClear = Program.Config.Security.ClipboardClearAfterSeconds; if(nClipClear >= 0) { m_cbClipClearTime.Checked = true; m_numClipClearTime.Value = nClipClear; } else m_cbClipClearTime.Checked = false; if(AppConfigEx.IsOptionEnforced(Program.Config.Security, "ClipboardClearAfterSeconds")) m_cbClipClearTime.Enabled = false; m_lvSecurityOptions.Columns.Add(string.Empty, 200); // Resize below ListViewGroup lvg = new ListViewGroup(KPRes.Options); m_lvSecurityOptions.Groups.Add(lvg); Debug.Assert(lvg.ListView == m_lvSecurityOptions); m_cdxSecurityOptions = new CheckedLVItemDXList(m_lvSecurityOptions, true); m_cdxSecurityOptions.CreateItem(aceWL, "LockOnWindowMinimize", lvg, KPRes.LockOnMinimize); m_cdxSecurityOptions.CreateItem(aceWL, "LockOnSessionSwitch", lvg, KPRes.LockOnSessionSwitch); m_cdxSecurityOptions.CreateItem(aceWL, "LockOnSuspend", lvg, KPRes.LockOnSuspend); m_cdxSecurityOptions.CreateItem(aceWL, "LockOnRemoteControlChange", lvg, KPRes.LockOnRemoteControlChange); m_cdxSecurityOptions.CreateItem(aceWL, "ExitInsteadOfLockingAfterTime", lvg, KPRes.ExitInsteadOfLockingAfterTime); m_cdxSecurityOptions.CreateItem(aceWL, "AlwaysExitInsteadOfLocking", lvg, KPRes.ExitInsteadOfLockingAlways); m_cdxSecurityOptions.CreateItem(Program.Config.Security, "ClipboardClearOnExit", lvg, KPRes.ClipboardClearOnExit); m_cdxSecurityOptions.CreateItem(Program.Config.Security, "UseClipboardViewerIgnoreFormat", lvg, KPRes.ClipboardViewerIgnoreFormat + " " + KPRes.NotRecommended); if(NativeLib.IsLibraryInstalled()) m_cdxSecurityOptions.CreateItem(Program.Config.Native, "NativeKeyTransformations", lvg, KPRes.NativeLibUse); m_cdxSecurityOptions.CreateItem(Program.Config.Security, "MasterKeyOnSecureDesktop", lvg, KPRes.MasterKeyOnSecureDesktop); m_cdxSecurityOptions.CreateItem(Program.Config.Security, "ClearKeyCommandLineParams", lvg, KPRes.ClearKeyCmdLineParams); m_cdxSecurityOptions.UpdateData(false); m_lvSecurityOptions.Columns[0].Width = m_lvSecurityOptions.ClientRectangle.Width - UIUtil.GetVScrollBarWidth() - 1; } private void LoadPolicyOption(string strPropertyName, string strDisplayName, string strDisplayDesc) { ListViewItem lvi = m_cdxPolicy.CreateItem(Program.Config.Security.Policy, strPropertyName, null, strDisplayName + "*"); lvi.SubItems.Add(strDisplayDesc); } private void LoadPolicyOptions() { m_cdxPolicy = new CheckedLVItemDXList(m_lvPolicy, true); LoadPolicyOption("Plugins", KPRes.Plugins, KPRes.PolicyPluginsDesc); LoadPolicyOption("Export", KPRes.Export, KPRes.PolicyExportDesc); LoadPolicyOption("ExportNoKey", KPRes.Export + " - " + KPRes.NoKeyRepeat, KPRes.PolicyExportNoKeyDesc); LoadPolicyOption("Import", KPRes.Import, KPRes.PolicyImportDesc); LoadPolicyOption("Print", KPRes.Print, KPRes.PolicyPrintDesc); LoadPolicyOption("PrintNoKey", KPRes.Print + " - " + KPRes.NoKeyRepeat, KPRes.PolicyPrintNoKeyDesc); LoadPolicyOption("NewFile", KPRes.NewDatabase, KPRes.PolicyNewDatabaseDesc); LoadPolicyOption("SaveFile", KPRes.SaveDatabase, KPRes.PolicySaveDatabaseDesc); LoadPolicyOption("AutoType", KPRes.AutoType, KPRes.PolicyAutoTypeDesc); LoadPolicyOption("AutoTypeWithoutContext", KPRes.AutoType + " - " + KPRes.WithoutContext, KPRes.PolicyAutoTypeWithoutContextDesc); LoadPolicyOption("CopyToClipboard", KPRes.Copy, KPRes.PolicyClipboardDesc); LoadPolicyOption("CopyWholeEntries", KPRes.CopyWholeEntries, KPRes.PolicyCopyWholeEntriesDesc); LoadPolicyOption("DragDrop", KPRes.DragDrop, KPRes.PolicyDragDropDesc); LoadPolicyOption("UnhidePasswords", KPRes.UnhidePasswords, KPRes.UnhidePasswordsDesc); LoadPolicyOption("ChangeMasterKey", KPRes.ChangeMasterKey, KPRes.PolicyChangeMasterKey); LoadPolicyOption("ChangeMasterKeyNoKey", KPRes.ChangeMasterKey + " - " + KPRes.NoKeyRepeat, KPRes.PolicyChangeMasterKeyNoKeyDesc); LoadPolicyOption("EditTriggers", KPRes.TriggersEdit, KPRes.PolicyTriggersEditDesc); m_cdxPolicy.UpdateData(false); } private void LoadGuiOptions() { m_bInitialTsRenderer = Program.Config.UI.UseCustomToolStripRenderer; m_lvGuiOptions.Columns.Add(KPRes.Options, 200); // Resize below ListViewGroup lvg = new ListViewGroup(KPRes.MainWindow); m_lvGuiOptions.Groups.Add(lvg); Debug.Assert(lvg.ListView == m_lvGuiOptions); m_cdxGuiOptions = new CheckedLVItemDXList(m_lvGuiOptions, true); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "CloseButtonMinimizesWindow", lvg, KPRes.CloseButtonMinimizes); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "MinimizeToTray", lvg, KPRes.MinimizeToTray); m_cdxGuiOptions.CreateItem(Program.Config.UI.TrayIcon, "ShowOnlyIfTrayed", lvg, KPRes.ShowTrayOnlyIfTrayed); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "ShowFullPathInTitle", lvg, KPRes.ShowFullPathInTitleBar); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "DropToBackAfterClipboardCopy", lvg, KPRes.DropToBackOnCopy); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "MinimizeAfterClipboardCopy", lvg, KPRes.MinimizeAfterCopy); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "MinimizeAfterLocking", lvg, KPRes.MinimizeAfterLocking); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "MinimizeAfterOpeningDatabase", lvg, KPRes.MinimizeAfterOpeningDatabase); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "DisableSaveIfNotModified", lvg, KPRes.DisableSaveIfNotModified); lvg = new ListViewGroup(KPRes.EntryList); m_lvGuiOptions.Groups.Add(lvg); // m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "ShowGridLines", // m_lvGuiOptions, lvg, KPRes.ShowGridLines); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "EntryListAutoResizeColumns", lvg, KPRes.EntryListAutoResizeColumns); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "EntryListAlternatingBgColors", lvg, KPRes.AlternatingBgColors); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "CopyUrlsInsteadOfOpening", lvg, KPRes.CopyUrlsInsteadOfOpening); if(!Program.Config.MainWindow.EntryListShowDerefData) { Debug.Assert(!Program.Config.MainWindow.EntryListShowDerefDataAsync); Program.Config.MainWindow.EntryListShowDerefDataAsync = false; } ListViewItem lviDeref = m_cdxGuiOptions.CreateItem( Program.Config.MainWindow, "EntryListShowDerefData", lvg, KPRes.ShowDerefData + " (" + KPRes.Slow + ")"); ListViewItem lviDerefAsync = m_cdxGuiOptions.CreateItem( Program.Config.MainWindow, "EntryListShowDerefDataAsync", lvg, KPRes.ShowDerefDataAsync + " (" + KPRes.IncompatibleWithSorting + ")"); m_cdxGuiOptions.AddLink(lviDeref, lviDerefAsync, CheckItemLinkType.UncheckedUnchecked); m_cdxGuiOptions.AddLink(lviDerefAsync, lviDeref, CheckItemLinkType.CheckedChecked); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "EntryListShowDerefDataAndRefs", lvg, KPRes.ShowDerefDataAndRefs); // lvg = new ListViewGroup(KPRes.EntryView); // m_lvGuiOptions.Groups.Add(lvg); // m_cdxGuiOptions.CreateItem(Program.Config.MainWindow.EntryView, "HideProtectedCustomStrings", // lvg, KPRes.EntryViewHideProtectedCustomStrings); lvg = new ListViewGroup(KPRes.QuickSearchTb); m_lvGuiOptions.Groups.Add(lvg); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "QuickFindSearchInPasswords", lvg, KPRes.QuickSearchInPwFields); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "QuickFindExcludeExpired", lvg, KPRes.QuickSearchExclExpired); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "QuickFindDerefData", lvg, KPRes.QuickSearchDerefData + " (" + KPRes.Slow + ")"); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "FocusResultsAfterQuickFind", lvg, KPRes.FocusResultsAfterQuickSearch); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "FocusQuickFindOnRestore", lvg, KPRes.FocusQuickFindOnRestore); m_cdxGuiOptions.CreateItem(Program.Config.MainWindow, "FocusQuickFindOnUntray", lvg, KPRes.FocusQuickFindOnUntray); lvg = new ListViewGroup(KPRes.Advanced); m_lvGuiOptions.Groups.Add(lvg); m_cdxGuiOptions.CreateItem(Program.Config.UI, "RepeatPasswordOnlyWhenHidden", lvg, KPRes.RepeatOnlyWhenHidden); m_cdxGuiOptions.CreateItem(Program.Config.UI, "UseCustomToolStripRenderer", lvg, KPRes.UseCustomToolStripRenderer); m_cdxGuiOptions.CreateItem(Program.Config.UI, "ForceSystemFontUnix", lvg, KPRes.ForceSystemFontUnix); m_cdxGuiOptions.CreateItem(Program.Config.UI, "ShowDbMntncResultsDialog", lvg, KPRes.DbMntncResults); m_cdxGuiOptions.UpdateData(false); m_lvGuiOptions.Columns[0].Width = m_lvGuiOptions.ClientRectangle.Width - UIUtil.GetVScrollBarWidth() - 1; try { m_numMruCount.Value = Program.Config.Application.MostRecentlyUsed.MaxItemCount; } catch(Exception) { Debug.Assert(false); m_numMruCount.Value = AceMru.DefaultMaxItemCount; } if(AppConfigEx.IsOptionEnforced(Program.Config.Application.MostRecentlyUsed, "MaxItemCount")) { m_lblMruCount.Enabled = false; m_numMruCount.Enabled = false; } if(AppConfigEx.IsOptionEnforced(Program.Config.UI, "StandardFont")) m_btnSelFont.Enabled = false; if(AppConfigEx.IsOptionEnforced(Program.Config.UI, "PasswordFont")) m_btnSelPwFont.Enabled = false; } private void LoadIntegrationOptions() { Keys kAT = (Keys)Program.Config.Integration.HotKeyGlobalAutoType; m_hkGlobalAutoType.HotKey = (kAT & Keys.KeyCode); m_hkGlobalAutoType.HotKeyModifiers = (kAT & Keys.Modifiers); m_hkGlobalAutoType.RenderHotKey(); m_kPrevATHKKey = (m_hkGlobalAutoType.HotKey | m_hkGlobalAutoType.HotKeyModifiers); if(AppConfigEx.IsOptionEnforced(Program.Config.Integration, "HotKeyGlobalAutoType")) m_hkGlobalAutoType.Enabled = false; Keys kATS = (Keys)Program.Config.Integration.HotKeySelectedAutoType; m_hkSelectedAutoType.HotKey = (kATS & Keys.KeyCode); m_hkSelectedAutoType.HotKeyModifiers = (kATS & Keys.Modifiers); m_hkSelectedAutoType.RenderHotKey(); m_kPrevATSHKKey = (m_hkSelectedAutoType.HotKey | m_hkSelectedAutoType.HotKeyModifiers); if(AppConfigEx.IsOptionEnforced(Program.Config.Integration, "HotKeySelectedAutoType")) m_hkSelectedAutoType.Enabled = false; Keys kSW = (Keys)Program.Config.Integration.HotKeyShowWindow; m_hkShowWindow.HotKey = (kSW & Keys.KeyCode); m_hkShowWindow.HotKeyModifiers = (kSW & Keys.Modifiers); m_hkShowWindow.RenderHotKey(); m_kPrevSWHKKey = (m_hkShowWindow.HotKey | m_hkShowWindow.HotKeyModifiers); if(AppConfigEx.IsOptionEnforced(Program.Config.Integration, "HotKeyShowWindow")) m_hkShowWindow.Enabled = false; m_cbAutoRun.Checked = ShellUtil.GetStartWithWindows(AppDefs.AutoRunName); m_cbSingleClickTrayAction.Checked = Program.Config.UI.TrayIcon.SingleClickDefault; if(AppConfigEx.IsOptionEnforced(Program.Config.UI.TrayIcon, "SingleClickDefault")) m_cbSingleClickTrayAction.Enabled = false; string strOverride = Program.Config.Integration.UrlOverride; m_cbUrlOverride.Checked = (strOverride.Length > 0); m_tbUrlOverride.Text = strOverride; if(AppConfigEx.IsOptionEnforced(Program.Config.Integration, "UrlOverride")) m_cbUrlOverride.Enabled = false; if(AppConfigEx.IsOptionEnforced(Program.Config.Integration, "UrlSchemeOverrides")) m_btnSchemeOverrides.Enabled = false; } private void LoadAdvancedOptions() { m_lvAdvanced.Columns.Add(string.Empty, 200); // Resize below m_cdxAdvanced = new CheckedLVItemDXList(m_lvAdvanced, true); ListViewGroup lvg = new ListViewGroup(KPRes.StartAndExit); m_lvAdvanced.Groups.Add(lvg); m_cdxAdvanced.CreateItem(Program.Config.Application.Start, "OpenLastFile", lvg, KPRes.AutoRememberOpenLastFile); m_cdxAdvanced.CreateItem(Program.Config.Integration, "LimitToSingleInstance", lvg, KPRes.LimitSingleInstance); m_cdxAdvanced.CreateItem(Program.Config.Application.Start, "CheckForUpdate", lvg, KPRes.CheckForUpdAtStart); m_cdxAdvanced.CreateItem(Program.Config.Application.Start, "MinimizedAndLocked", lvg, KPRes.StartMinimizedAndLocked); m_cdxAdvanced.CreateItem(Program.Config.Application.FileClosing, "AutoSave", lvg, KPRes.AutoSaveAtExit); lvg = new ListViewGroup(KPRes.AfterDatabaseOpen); m_lvAdvanced.Groups.Add(lvg); m_cdxAdvanced.CreateItem(Program.Config.Application.FileOpening, "ShowExpiredEntries", lvg, KPRes.AutoShowExpiredEntries); m_cdxAdvanced.CreateItem(Program.Config.Application.FileOpening, "ShowSoonToExpireEntries", lvg, KPRes.AutoShowSoonToExpireEntries); lvg = new ListViewGroup(KPRes.AutoType); m_lvAdvanced.Groups.Add(lvg); m_cdxAdvanced.CreateItem(Program.Config.Integration, "AutoTypeMatchByTitle", lvg, KPRes.AutoTypeMatchByTitle); m_cdxAdvanced.CreateItem(Program.Config.Integration, "AutoTypeMatchByUrlInTitle", lvg, KPRes.AutoTypeMatchByUrlInTitle); m_cdxAdvanced.CreateItem(Program.Config.Integration, "AutoTypeMatchByUrlHostInTitle", lvg, KPRes.AutoTypeMatchByUrlHostInTitle); m_cdxAdvanced.CreateItem(Program.Config.Integration, "AutoTypeMatchByTagInTitle", lvg, KPRes.AutoTypeMatchByTagInTitle); m_cdxAdvanced.CreateItem(Program.Config.Integration, "AutoTypePrependInitSequenceForIE", lvg, KPRes.AutoTypePrependInitSeqForIE); m_cdxAdvanced.CreateItem(Program.Config.Integration, "AutoTypeReleaseAltWithKeyPress", lvg, KPRes.AutoTypeReleaseAltWithKeyPress); m_cdxAdvanced.CreateItem(Program.Config.Integration, "AutoTypeAdjustKeyboardLayout", lvg, KPRes.SameKeybLayout); m_cdxAdvanced.CreateItem(Program.Config.Integration, "AutoTypeAllowInterleaved", lvg, KPRes.InterleavedKeySending); m_cdxAdvanced.CreateItem(Program.Config.Integration, "AutoTypeCancelOnWindowChange", lvg, KPRes.AutoTypeCancelOnWindowChange); m_cdxAdvanced.CreateItem(Program.Config.Integration, "AutoTypeCancelOnTitleChange", lvg, KPRes.AutoTypeCancelOnTitleChange); lvg = new ListViewGroup(KPRes.IOConnectionLong); m_lvAdvanced.Groups.Add(lvg); m_cdxAdvanced.CreateItem(Program.Config.Application, "VerifyWrittenFileAfterSaving", lvg, KPRes.VerifyWrittenFileAfterSave); m_cdxAdvanced.CreateItem(Program.Config.Application, "UseTransactedFileWrites", lvg, KPRes.UseTransactedDatabaseWrites); m_cdxAdvanced.CreateItem(Program.Config.Application, "UseFileLocks", lvg, KPRes.UseFileLocks + " " + KPRes.NotRecommended); m_cdxAdvanced.CreateItem(Program.Config.Security, "SslCertsAcceptInvalid", lvg, KPRes.SslCertsAcceptInvalid); lvg = new ListViewGroup(KPRes.Advanced); m_lvAdvanced.Groups.Add(lvg); if(!Program.Config.Integration.SearchKeyFiles) Program.Config.Integration.SearchKeyFilesOnRemovableMedia = false; ListViewItem lviSearch = m_cdxAdvanced.CreateItem( Program.Config.Integration, "SearchKeyFiles", lvg, KPRes.SearchKeyFiles); ListViewItem lviSearchRmv = m_cdxAdvanced.CreateItem( Program.Config.Integration, "SearchKeyFilesOnRemovableMedia", lvg, KPRes.SearchKeyFilesAlsoOnRemovable); m_cdxAdvanced.AddLink(lviSearch, lviSearchRmv, CheckItemLinkType.UncheckedUnchecked); m_cdxAdvanced.AddLink(lviSearchRmv, lviSearch, CheckItemLinkType.CheckedChecked); m_cdxAdvanced.CreateItem(Program.Config.Defaults, "RememberKeySources", lvg, KPRes.RememberKeySources); m_cdxAdvanced.CreateItem(Program.Config.Application, "RememberWorkingDirectories", lvg, KPRes.RememberWorkingDirectories); m_cdxAdvanced.CreateItem(Program.Config.UI.Hiding, "SeparateHidingSettings", lvg, KPRes.RememberHidingSettings); m_cdxAdvanced.CreateItem(Program.Config.UI.Hiding, "UnhideButtonAlsoUnhidesSource", lvg, KPRes.UnhideSourceCharactersToo); m_cdxAdvanced.CreateItem(Program.Config.Defaults, "TanExpiresOnUse", lvg, KPRes.TanExpiresOnUse); m_cdxAdvanced.CreateItem(Program.Config.Defaults, "RecycleBinCollapse", lvg, KPRes.RecycleBinCollapse); m_cdxAdvanced.CreateItem(Program.Config.UI, "SecureDesktopPlaySound", lvg, KPRes.SecDeskPlaySound); m_cdxAdvanced.CreateItem(Program.Config.UI, "OptimizeForScreenReader", lvg, KPRes.OptimizeForScreenReader); m_cdxAdvanced.UpdateData(false); m_lvAdvanced.Columns[0].Width = m_lvAdvanced.ClientRectangle.Width - UIUtil.GetVScrollBarWidth() - 1; if(AppConfigEx.IsOptionEnforced(Program.Config.Integration, "ProxyType") || AppConfigEx.IsOptionEnforced(Program.Config.Integration, "ProxyAddress")) m_btnProxy.Enabled = false; } private bool ValidateOptions() { m_hkGlobalAutoType.ResetIfModifierOnly(); m_hkSelectedAutoType.ResetIfModifierOnly(); m_hkShowWindow.ResetIfModifierOnly(); bool bAltMod = false; bAltMod |= ((m_hkGlobalAutoType.HotKeyModifiers == Keys.Alt) || (m_hkGlobalAutoType.HotKeyModifiers == (Keys.Alt | Keys.Shift))); bAltMod |= ((m_hkSelectedAutoType.HotKeyModifiers == Keys.Alt) || (m_hkSelectedAutoType.HotKeyModifiers == (Keys.Alt | Keys.Shift))); bAltMod |= ((m_hkShowWindow.HotKeyModifiers == Keys.Alt) || (m_hkShowWindow.HotKeyModifiers == (Keys.Alt | Keys.Shift))); if(bAltMod) { if(!MessageService.AskYesNo(KPRes.HotKeyAltOnly + MessageService.NewParagraph + KPRes.HotKeyAltOnlyHint + MessageService.NewParagraph + KPRes.HotKeyAltOnlyQuestion, null, false)) return false; } return true; } private void SaveOptions() { if(!m_cbLockAfterTime.Checked) Program.Config.Security.WorkspaceLocking.LockAfterTime = 0; else Program.Config.Security.WorkspaceLocking.LockAfterTime = (uint)m_numLockAfterTime.Value; if(!m_cbLockAfterGlobalTime.Checked) Program.Config.Security.WorkspaceLocking.LockAfterGlobalTime = 0; else Program.Config.Security.WorkspaceLocking.LockAfterGlobalTime = (uint)m_numLockAfterGlobalTime.Value; if(m_cbDefaultExpireDays.Checked) Program.Config.Defaults.NewEntryExpiresInDays = (int)m_numDefaultExpireDays.Value; else Program.Config.Defaults.NewEntryExpiresInDays = -1; if(m_cbClipClearTime.Checked) Program.Config.Security.ClipboardClearAfterSeconds = (int)m_numClipClearTime.Value; else Program.Config.Security.ClipboardClearAfterSeconds = -1; m_cdxSecurityOptions.UpdateData(true); NativeLib.AllowNative = Program.Config.Native.NativeKeyTransformations; m_cdxPolicy.UpdateData(true); m_cdxGuiOptions.UpdateData(true); if(m_cmbBannerStyle.SelectedIndex != (int)BannerStyle.Default) Program.Config.UI.BannerStyle = (BannerStyle) m_cmbBannerStyle.SelectedIndex; Program.Config.Application.MostRecentlyUsed.MaxItemCount = (uint)m_numMruCount.Value; ChangeHotKey(ref m_kPrevATHKKey, m_hkGlobalAutoType, AppDefs.GlobalHotKeyId.AutoType); ChangeHotKey(ref m_kPrevATSHKKey, m_hkSelectedAutoType, AppDefs.GlobalHotKeyId.AutoTypeSelected); ChangeHotKey(ref m_kPrevSWHKKey, m_hkShowWindow, AppDefs.GlobalHotKeyId.ShowWindow); Program.Config.UI.TrayIcon.SingleClickDefault = m_cbSingleClickTrayAction.Checked; if(m_cbUrlOverride.Checked) Program.Config.Integration.UrlOverride = m_tbUrlOverride.Text; else Program.Config.Integration.UrlOverride = string.Empty; m_cdxAdvanced.UpdateData(true); Program.Config.Integration.UrlSchemeOverrides = m_aceUrlSchemeOverrides; Program.Config.Apply(AceApplyFlags.All); } private void CleanUpEx() { int nTab = m_tabMain.SelectedIndex; if((nTab >= 0) && (nTab < m_tabMain.TabPages.Count)) Program.Config.Defaults.OptionsTabIndex = (uint)nTab; m_tabMain.ImageList = null; // Detach event handlers m_cdxSecurityOptions.Release(); m_cdxPolicy.Release(); m_cdxGuiOptions.Release(); m_cdxAdvanced.Release(); AppConfigEx.ClearXmlPathCache(); } private static void ChangeHotKey(ref Keys kPrevHK, HotKeyControlEx hkControl, int nHotKeyID) { Keys kNew = (hkControl.HotKey | hkControl.HotKeyModifiers); if(kPrevHK != kNew) { kPrevHK = kNew; if(nHotKeyID == AppDefs.GlobalHotKeyId.AutoType) Program.Config.Integration.HotKeyGlobalAutoType = (ulong)kNew; else if(nHotKeyID == AppDefs.GlobalHotKeyId.AutoTypeSelected) Program.Config.Integration.HotKeySelectedAutoType = (ulong)kNew; else if(nHotKeyID == AppDefs.GlobalHotKeyId.ShowWindow) Program.Config.Integration.HotKeyShowWindow = (ulong)kNew; HotKeyManager.UnregisterHotKey(nHotKeyID); if(kPrevHK != Keys.None) HotKeyManager.RegisterHotKey(nHotKeyID, kPrevHK); } } private void UpdateUIState() { if(m_bBlockUIUpdate) return; m_bBlockUIUpdate = true; m_numLockAfterTime.Enabled = (m_cbLockAfterTime.Checked && m_cbLockAfterTime.Enabled); if(WinUtil.IsWindows9x || NativeLib.IsUnix()) { m_cbLockAfterGlobalTime.Checked = false; m_cbLockAfterGlobalTime.Enabled = false; m_numLockAfterGlobalTime.Enabled = false; } else m_numLockAfterGlobalTime.Enabled = (m_cbLockAfterGlobalTime.Checked && m_cbLockAfterGlobalTime.Enabled); m_numDefaultExpireDays.Enabled = (m_cbDefaultExpireDays.Checked && m_cbDefaultExpireDays.Enabled); m_numClipClearTime.Enabled = (m_cbClipClearTime.Checked && m_cbClipClearTime.Enabled); m_tbUrlOverride.Enabled = (m_cbUrlOverride.Checked && m_cbUrlOverride.Enabled); m_bBlockUIUpdate = false; } private void OnBtnOK(object sender, EventArgs e) { if(!ValidateOptions()) { this.DialogResult = DialogResult.None; return; } SaveOptions(); } private void OnBtnCancel(object sender, EventArgs e) { } private void OnBannerStyleSelectedChanged(object sender, EventArgs e) { int nIndex = m_cmbBannerStyle.SelectedIndex; BannerStyle bs = (BannerStyle)nIndex; CreateDialogBanner(bs); } private void OnLockAfterTimeCheckedChanged(object sender, EventArgs e) { UpdateUIState(); } private void OnBtnSelListFont(object sender, EventArgs e) { FontDialog dlg = UIUtil.CreateFontDialog(false); AceFont fOld = Program.Config.UI.StandardFont; if(fOld.OverrideUIDefault) dlg.Font = fOld.ToFont(); else { try { dlg.Font = m_tbUrlOverride.Font; } catch(Exception) { Debug.Assert(false); } } if(dlg.ShowDialog() == DialogResult.OK) { Program.Config.UI.StandardFont = new AceFont(dlg.Font); Program.Config.UI.StandardFont.OverrideUIDefault = true; } dlg.Dispose(); } private void OnBtnSelPwFont(object sender, EventArgs e) { FontDialog dlg = UIUtil.CreateFontDialog(false); AceFont fOld = Program.Config.UI.PasswordFont; if(fOld.OverrideUIDefault) dlg.Font = fOld.ToFont(); else if(FontUtil.MonoFont != null) dlg.Font = FontUtil.MonoFont; else { try { dlg.Font = new Font(FontFamily.GenericMonospace, m_tbUrlOverride.Font.SizeInPoints); } catch(Exception) { Debug.Assert(false); } } if(dlg.ShowDialog() == DialogResult.OK) { Program.Config.UI.PasswordFont = new AceFont(dlg.Font); Program.Config.UI.PasswordFont.OverrideUIDefault = true; } dlg.Dispose(); } private void OnDefaultExpireDaysCheckedChanged(object sender, EventArgs e) { UpdateUIState(); } private void OnBtnFileExtCreate(object sender, EventArgs e) { // ShellUtil.RegisterExtension(AppDefs.FileExtension.FileExt, AppDefs.FileExtension.ExtId, // KPRes.FileExtName, WinUtil.GetExecutable(), PwDefs.ShortProductName, true); WinUtil.RunElevated(WinUtil.GetExecutable(), "/" + AppDefs.CommandLineOptions.FileExtRegister, false); } private void OnBtnFileExtRemove(object sender, EventArgs e) { // ShellUtil.UnregisterExtension(AppDefs.FileExtension.FileExt, // AppDefs.FileExtension.ExtId); WinUtil.RunElevated(WinUtil.GetExecutable(), "/" + AppDefs.CommandLineOptions.FileExtUnregister, false); } private void OnCheckedChangedAutoRun(object sender, EventArgs e) { if(m_bLoadingSettings) return; bool bRequested = m_cbAutoRun.Checked; bool bCurrent = ShellUtil.GetStartWithWindows(AppDefs.AutoRunName); if(bRequested != bCurrent) { string strPath = WinUtil.GetExecutable().Trim(); if(strPath.StartsWith("\"") == false) strPath = "\"" + strPath + "\""; ShellUtil.SetStartWithWindows(AppDefs.AutoRunName, strPath, bRequested); bool bNew = ShellUtil.GetStartWithWindows(AppDefs.AutoRunName); if(bNew != bRequested) m_cbAutoRun.Checked = bNew; } } private void OnOverrideURLsCheckedChanged(object sender, EventArgs e) { UpdateUIState(); } private void OnFormClosed(object sender, FormClosedEventArgs e) { CleanUpEx(); GlobalWindowManager.RemoveWindow(this); } private void OnPolicyInfoLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { AppHelp.ShowHelp(AppDefs.HelpTopics.AppPolicy, null); } private void OnClipboardClearTimeCheckedChanged(object sender, EventArgs e) { UpdateUIState(); } private void OnBtnUrlSchemeOverrides(object sender, EventArgs e) { UrlSchemesForm dlg = new UrlSchemesForm(); dlg.InitEx(m_aceUrlSchemeOverrides); UIUtil.ShowDialogAndDestroy(dlg); } private void OnHotKeyHelpLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { AppHelp.ShowHelp(AppDefs.HelpTopics.Setup, AppDefs.HelpTopics.SetupMono); } private void OnLockAfterGlobalTimeCheckedChanged(object sender, EventArgs e) { UpdateUIState(); } private void OnBtnProxy(object sender, EventArgs e) { ProxyForm dlg = new ProxyForm(); UIUtil.ShowDialogAndDestroy(dlg); } } } keepass2-2.25/KeePass/Forms/ExchangeDataForm.Designer.cs0000664000175000017500000001733112000510734022757 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class ExchangeDataForm { /// /// 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_bannerImage = new System.Windows.Forms.PictureBox(); this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_grpFormat = new System.Windows.Forms.GroupBox(); this.m_lvFormats = new KeePass.UI.CustomListViewEx(); this.m_grpFile = new System.Windows.Forms.GroupBox(); this.m_lnkFileFormats = new System.Windows.Forms.LinkLabel(); this.m_btnSelFile = new System.Windows.Forms.Button(); this.m_tbFile = new System.Windows.Forms.TextBox(); this.m_lblFile = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).BeginInit(); this.m_grpFormat.SuspendLayout(); this.m_grpFile.SuspendLayout(); this.SuspendLayout(); // // m_bannerImage // this.m_bannerImage.Dock = System.Windows.Forms.DockStyle.Top; this.m_bannerImage.Location = new System.Drawing.Point(0, 0); this.m_bannerImage.Name = "m_bannerImage"; this.m_bannerImage.Size = new System.Drawing.Size(378, 60); this.m_bannerImage.TabIndex = 0; this.m_bannerImage.TabStop = false; // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(210, 449); 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 = "&OK"; 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(291, 449); 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_grpFormat // this.m_grpFormat.Controls.Add(this.m_lvFormats); this.m_grpFormat.Location = new System.Drawing.Point(12, 72); this.m_grpFormat.Name = "m_grpFormat"; this.m_grpFormat.Size = new System.Drawing.Size(354, 297); this.m_grpFormat.TabIndex = 2; this.m_grpFormat.TabStop = false; this.m_grpFormat.Text = "Format"; // // m_lvFormats // this.m_lvFormats.FullRowSelect = true; this.m_lvFormats.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; this.m_lvFormats.HideSelection = false; this.m_lvFormats.Location = new System.Drawing.Point(9, 19); this.m_lvFormats.MultiSelect = false; this.m_lvFormats.Name = "m_lvFormats"; this.m_lvFormats.Size = new System.Drawing.Size(336, 268); this.m_lvFormats.TabIndex = 0; this.m_lvFormats.UseCompatibleStateImageBehavior = false; this.m_lvFormats.View = System.Windows.Forms.View.Details; this.m_lvFormats.ItemActivate += new System.EventHandler(this.OnFormatsItemActivate); this.m_lvFormats.SelectedIndexChanged += new System.EventHandler(this.OnFormatsSelectedIndexChanged); // // m_grpFile // this.m_grpFile.Controls.Add(this.m_lnkFileFormats); this.m_grpFile.Controls.Add(this.m_btnSelFile); this.m_grpFile.Controls.Add(this.m_tbFile); this.m_grpFile.Controls.Add(this.m_lblFile); this.m_grpFile.Location = new System.Drawing.Point(12, 375); this.m_grpFile.Name = "m_grpFile"; this.m_grpFile.Size = new System.Drawing.Size(354, 68); this.m_grpFile.TabIndex = 3; this.m_grpFile.TabStop = false; this.m_grpFile.Text = "File"; // // m_lnkFileFormats // this.m_lnkFileFormats.AutoSize = true; this.m_lnkFileFormats.Location = new System.Drawing.Point(110, 45); this.m_lnkFileFormats.Name = "m_lnkFileFormats"; this.m_lnkFileFormats.Size = new System.Drawing.Size(182, 13); this.m_lnkFileFormats.TabIndex = 3; this.m_lnkFileFormats.TabStop = true; this.m_lnkFileFormats.Text = "Help: Configuring source applications"; this.m_lnkFileFormats.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.OnLinkFileFormats); // // m_btnSelFile // this.m_btnSelFile.Location = new System.Drawing.Point(316, 17); this.m_btnSelFile.Name = "m_btnSelFile"; this.m_btnSelFile.Size = new System.Drawing.Size(32, 23); this.m_btnSelFile.TabIndex = 2; this.m_btnSelFile.UseVisualStyleBackColor = true; this.m_btnSelFile.Click += new System.EventHandler(this.OnBtnSelFile); // // m_tbFile // this.m_tbFile.Location = new System.Drawing.Point(113, 19); this.m_tbFile.Name = "m_tbFile"; this.m_tbFile.Size = new System.Drawing.Size(197, 20); this.m_tbFile.TabIndex = 1; this.m_tbFile.TextChanged += new System.EventHandler(this.OnImportFileTextChanged); // // m_lblFile // this.m_lblFile.AutoSize = true; this.m_lblFile.Location = new System.Drawing.Point(6, 22); this.m_lblFile.Name = "m_lblFile"; this.m_lblFile.Size = new System.Drawing.Size(19, 13); this.m_lblFile.TabIndex = 0; this.m_lblFile.Text = "<>"; // // ExchangeDataForm // 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(378, 484); this.Controls.Add(this.m_grpFile); this.Controls.Add(this.m_grpFormat); this.Controls.Add(this.m_btnCancel); this.Controls.Add(this.m_btnOK); this.Controls.Add(this.m_bannerImage); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "ExchangeDataForm"; this.ShowInTaskbar = false; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = ""; this.Load += new System.EventHandler(this.OnFormLoad); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).EndInit(); this.m_grpFormat.ResumeLayout(false); this.m_grpFile.ResumeLayout(false); this.m_grpFile.PerformLayout(); this.ResumeLayout(false); } #endregion private System.Windows.Forms.PictureBox m_bannerImage; private System.Windows.Forms.Button m_btnOK; private System.Windows.Forms.Button m_btnCancel; private System.Windows.Forms.GroupBox m_grpFormat; private KeePass.UI.CustomListViewEx m_lvFormats; private System.Windows.Forms.GroupBox m_grpFile; private System.Windows.Forms.Button m_btnSelFile; private System.Windows.Forms.TextBox m_tbFile; private System.Windows.Forms.Label m_lblFile; private System.Windows.Forms.LinkLabel m_lnkFileFormats; } }keepass2-2.25/KeePass/Forms/ImportMethodForm.cs0000664000175000017500000000616312261553106021331 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePass.UI; using KeePass.Resources; using KeePassLib; namespace KeePass.Forms { public partial class ImportMethodForm : Form { PwMergeMethod m_mmSelected = PwMergeMethod.CreateNewUuids; public PwMergeMethod MergeMethod { get { return m_mmSelected; } } public ImportMethodForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } private void OnFormLoad(object sender, EventArgs e) { GlobalWindowManager.AddWindow(this); try { if(this.Owner == null) this.Owner = Program.MainForm; } catch(Exception) { Debug.Assert(false); } BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_Folder_Download, KPRes.ImportBehavior, KPRes.ImportBehaviorDesc); this.Icon = Properties.Resources.KeePass; this.Text = KPRes.ImportBehavior; m_radioCreateNew.Text = KPRes.CreateNewIDs; m_radioKeepExisting.Text = KPRes.KeepExisting; m_radioOverwrite.Text = KPRes.OverwriteExisting; m_radioOverwriteIfNewer.Text = KPRes.OverwriteIfNewer; m_radioSynchronize.Text = KPRes.OverwriteIfNewerAndApplyDel; FontUtil.AssignDefaultBold(m_radioCreateNew); FontUtil.AssignDefaultBold(m_radioKeepExisting); FontUtil.AssignDefaultBold(m_radioOverwrite); FontUtil.AssignDefaultBold(m_radioOverwriteIfNewer); FontUtil.AssignDefaultBold(m_radioSynchronize); m_radioCreateNew.Checked = true; } private void OnBtnOK(object sender, EventArgs e) { if(m_radioCreateNew.Checked) m_mmSelected = PwMergeMethod.CreateNewUuids; else if(m_radioKeepExisting.Checked) m_mmSelected = PwMergeMethod.KeepExisting; else if(m_radioOverwrite.Checked) m_mmSelected = PwMergeMethod.OverwriteExisting; else if(m_radioOverwriteIfNewer.Checked) m_mmSelected = PwMergeMethod.OverwriteIfNewer; else if(m_radioSynchronize.Checked) m_mmSelected = PwMergeMethod.Synchronize; } private void OnBtnCancel(object sender, EventArgs e) { } private void OnFormClosed(object sender, FormClosedEventArgs e) { GlobalWindowManager.RemoveWindow(this); } } }keepass2-2.25/KeePass/Forms/PwEntryForm.cs0000664000175000017500000016544112267250346020341 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Globalization; using System.IO; using System.Threading; using System.Diagnostics; using KeePass.App; using KeePass.App.Configuration; using KeePass.Native; using KeePass.Resources; using KeePass.UI; using KeePass.Util; using KeePassLib; using KeePassLib.Collections; using KeePassLib.Cryptography; using KeePassLib.Cryptography.PasswordGenerator; using KeePassLib.Delegates; using KeePassLib.Security; using KeePassLib.Utility; namespace KeePass.Forms { public enum PwEditMode { Invalid = 0, AddNewEntry, EditExistingEntry, ViewReadOnlyEntry } public partial class PwEntryForm : Form { private PwEditMode m_pwEditMode = PwEditMode.Invalid; private PwDatabase m_pwDatabase = null; private bool m_bShowAdvancedByDefault = false; private bool m_bSelectFullTitle = false; private PwEntry m_pwEntry = null; private PwEntry m_pwInitialEntry = null; private ProtectedStringDictionary m_vStrings = null; private ProtectedBinaryDictionary m_vBinaries = null; private AutoTypeConfig m_atConfig = null; private PwObjectList m_vHistory = null; private Color m_clrForeground = Color.Empty; private Color m_clrBackground = Color.Empty; private PwIcon m_pwEntryIcon = PwIcon.Key; private PwUuid m_pwCustomIconID = PwUuid.Zero; private ImageList m_ilIcons = null; private bool m_bLockEnabledState = false; private bool m_bTouchedOnce = false; private bool m_bInitializing = false; private bool m_bForceClosing = false; private PwInputControlGroup m_icgPassword = new PwInputControlGroup(); private ExpiryControlGroup m_cgExpiry = new ExpiryControlGroup(); private RichTextBoxContextMenu m_ctxNotes = new RichTextBoxContextMenu(); private Image m_imgPwGen = null; private Image m_imgStdExpire = null; private List m_lOverrideUrlIcons = new List(); private ContextMenuStrip m_ctxBinOpen = null; private DynamicMenu m_dynBinOpen = null; private readonly string DeriveFromPrevious = "(" + KPRes.GenPwBasedOnPrevious + ")"; private readonly string AutoGenProfile = "(" + KPRes.AutoGeneratedPasswordSettings + ")"; private DynamicMenu m_dynGenProfiles; private const PwIcon m_pwObjectProtected = PwIcon.PaperLocked; private const PwIcon m_pwObjectPlainText = PwIcon.PaperNew; public event EventHandler EntrySaving; public event EventHandler EntrySaved; private const PwCompareOptions m_cmpOpt = (PwCompareOptions.NullEmptyEquivStd | PwCompareOptions.IgnoreTimes); public bool HasModifiedEntry { get { if((m_pwEntry == null) || (m_pwInitialEntry == null)) { Debug.Assert(false); return true; } return !m_pwEntry.EqualsEntry(m_pwInitialEntry, m_cmpOpt, MemProtCmpMode.CustomOnly); } } public PwEntry EntryRef { get { return m_pwEntry; } } public ProtectedStringDictionary EntryStrings { get { return m_vStrings; } } public ProtectedBinaryDictionary EntryBinaries { get { return m_vBinaries; } } public ContextMenuStrip ToolsContextMenu { get { return m_ctxTools; } } public ContextMenuStrip DefaultTimesContextMenu { get { return m_ctxDefaultTimes; } } public ContextMenuStrip ListOperationsContextMenu { get { return m_ctxListOperations; } } public ContextMenuStrip PasswordGeneratorContextMenu { get { return m_ctxPwGen; } } public ContextMenuStrip StandardStringMovementContextMenu { get { return m_ctxStrMoveToStandard; } } public ContextMenuStrip AttachmentsContextMenu { get { return m_ctxBinAttach; } } private bool m_bInitSwitchToHistory = false; internal bool InitSwitchToHistoryTab { // get { return m_bInitSwitchToHistory; } // Internal, uncalled set { m_bInitSwitchToHistory = value; } } public PwEntryForm() { InitializeComponent(); Program.Translation.ApplyTo(this); Program.Translation.ApplyTo("KeePass.Forms.PwEntryForm.m_ctxTools", m_ctxTools.Items); Program.Translation.ApplyTo("KeePass.Forms.PwEntryForm.m_ctxDefaultTimes", m_ctxDefaultTimes.Items); Program.Translation.ApplyTo("KeePass.Forms.PwEntryForm.m_ctxListOperations", m_ctxListOperations.Items); Program.Translation.ApplyTo("KeePass.Forms.PwEntryForm.m_ctxPwGen", m_ctxPwGen.Items); Program.Translation.ApplyTo("KeePass.Forms.PwEntryForm.m_ctxStrMoveToStandard", m_ctxStrMoveToStandard.Items); Program.Translation.ApplyTo("KeePass.Forms.PwEntryForm.m_ctxBinAttach", m_ctxBinAttach.Items); } public void InitEx(PwEntry pwEntry, PwEditMode pwMode, PwDatabase pwDatabase, ImageList ilIcons, bool bShowAdvancedByDefault, bool bSelectFullTitle) { Debug.Assert(pwEntry != null); if(pwEntry == null) throw new ArgumentNullException("pwEntry"); Debug.Assert(pwMode != PwEditMode.Invalid); if(pwMode == PwEditMode.Invalid) throw new ArgumentException(); Debug.Assert(ilIcons != null); if(ilIcons == null) throw new ArgumentNullException("ilIcons"); m_pwEntry = pwEntry; m_pwEditMode = pwMode; m_pwDatabase = pwDatabase; m_ilIcons = ilIcons; m_bShowAdvancedByDefault = bShowAdvancedByDefault; m_bSelectFullTitle = bSelectFullTitle; m_vStrings = m_pwEntry.Strings.CloneDeep(); m_vBinaries = m_pwEntry.Binaries.CloneDeep(); m_atConfig = m_pwEntry.AutoType.CloneDeep(); m_vHistory = m_pwEntry.History.CloneDeep(); } private void InitEntryTab() { m_pwEntryIcon = m_pwEntry.IconId; m_pwCustomIconID = m_pwEntry.CustomIconUuid; if(!m_pwCustomIconID.Equals(PwUuid.Zero)) { // int nInx = (int)PwIcon.Count + m_pwDatabase.GetCustomIconIndex(m_pwCustomIconID); // if((nInx > -1) && (nInx < m_ilIcons.Images.Count)) // m_btnIcon.Image = m_ilIcons.Images[nInx]; // else m_btnIcon.Image = m_ilIcons.Images[(int)m_pwEntryIcon]; Image imgCustom = m_pwDatabase.GetCustomIcon(m_pwCustomIconID); // m_btnIcon.Image = (imgCustom ?? m_ilIcons.Images[(int)m_pwEntryIcon]); UIUtil.SetButtonImage(m_btnIcon, (imgCustom ?? m_ilIcons.Images[ (int)m_pwEntryIcon]), true); } else { // m_btnIcon.Image = m_ilIcons.Images[(int)m_pwEntryIcon]; UIUtil.SetButtonImage(m_btnIcon, m_ilIcons.Images[ (int)m_pwEntryIcon], true); } bool bHideInitial = m_cbHidePassword.Checked; m_icgPassword.Attach(m_tbPassword, m_cbHidePassword, m_lblPasswordRepeat, m_tbRepeatPassword, m_lblQuality, m_pbQuality, m_lblQualityBitsText, this, bHideInitial, false); if(m_pwEntry.Expires) { m_dtExpireDateTime.Value = m_pwEntry.ExpiryTime; m_cbExpires.Checked = true; } else // Does not expire { m_dtExpireDateTime.Value = DateTime.Now.Date; m_cbExpires.Checked = false; } m_cgExpiry.Attach(m_cbExpires, m_dtExpireDateTime); if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) { m_tbTitle.ReadOnly = m_tbUserName.ReadOnly = m_tbPassword.ReadOnly = m_tbRepeatPassword.ReadOnly = m_tbUrl.ReadOnly = m_rtNotes.ReadOnly = true; m_btnIcon.Enabled = m_btnGenPw.Enabled = m_cbExpires.Enabled = m_dtExpireDateTime.Enabled = m_btnStandardExpires.Enabled = false; m_rtNotes.SelectAll(); m_rtNotes.BackColor = m_rtNotes.SelectionBackColor = AppDefs.ColorControlDisabled; m_rtNotes.DeselectAll(); m_ctxToolsUrlSelApp.Enabled = m_ctxToolsUrlSelDoc.Enabled = false; m_ctxToolsFieldRefsInTitle.Enabled = m_ctxToolsFieldRefsInUserName.Enabled = m_ctxToolsFieldRefsInPassword.Enabled = m_ctxToolsFieldRefsInUrl.Enabled = m_ctxToolsFieldRefsInNotes.Enabled = false; m_ctxToolsFieldRefs.Enabled = false; m_btnOK.Enabled = false; } // Show URL in blue, if it's black in the current visual theme if(m_tbUrl.ForeColor.ToArgb() == Color.Black.ToArgb()) m_tbUrl.ForeColor = Color.Blue; } private void InitAdvancedTab() { m_lvStrings.SmallImageList = m_ilIcons; m_lvBinaries.SmallImageList = m_ilIcons; int nWidth = m_lvStrings.ClientRectangle.Width / 2; m_lvStrings.Columns.Add(KPRes.FieldName, nWidth); m_lvStrings.Columns.Add(KPRes.FieldValue, nWidth); nWidth = m_lvBinaries.ClientRectangle.Width / 2; m_lvBinaries.Columns.Add(KPRes.Attachments, nWidth); m_lvBinaries.Columns.Add(KPRes.Size, nWidth, HorizontalAlignment.Right); if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) { m_btnStrAdd.Enabled = m_btnStrEdit.Enabled = m_btnStrDelete.Enabled = m_btnStrMove.Enabled = m_btnBinAdd.Enabled = m_btnBinDelete.Enabled = false; // Always available: // m_btnBinOpen.Enabled = m_btnBinSave.Enabled = false; m_lvBinaries.LabelEdit = false; } } // Public for plugins public void UpdateEntryStrings(bool bGuiToInternal, bool bSetRepeatPw) { if(bGuiToInternal) { m_vStrings.Set(PwDefs.TitleField, new ProtectedString(m_pwDatabase.MemoryProtection.ProtectTitle, m_tbTitle.Text)); m_vStrings.Set(PwDefs.UserNameField, new ProtectedString(m_pwDatabase.MemoryProtection.ProtectUserName, m_tbUserName.Text)); byte[] pb = m_icgPassword.GetPasswordUtf8(); m_vStrings.Set(PwDefs.PasswordField, new ProtectedString(m_pwDatabase.MemoryProtection.ProtectPassword, pb)); MemUtil.ZeroByteArray(pb); m_vStrings.Set(PwDefs.UrlField, new ProtectedString(m_pwDatabase.MemoryProtection.ProtectUrl, m_tbUrl.Text)); m_vStrings.Set(PwDefs.NotesField, new ProtectedString(m_pwDatabase.MemoryProtection.ProtectNotes, m_rtNotes.Text)); } else // Internal to GUI { m_tbTitle.Text = m_vStrings.ReadSafe(PwDefs.TitleField); m_tbUserName.Text = m_vStrings.ReadSafe(PwDefs.UserNameField); byte[] pb = m_vStrings.GetSafe(PwDefs.PasswordField).ReadUtf8(); m_icgPassword.SetPassword(pb, bSetRepeatPw); MemUtil.ZeroByteArray(pb); m_tbUrl.Text = m_vStrings.ReadSafe(PwDefs.UrlField); m_rtNotes.Text = m_vStrings.ReadSafe(PwDefs.NotesField); int iTopVisible = UIUtil.GetTopVisibleItem(m_lvStrings); m_lvStrings.Items.Clear(); foreach(KeyValuePair kvpStr in m_vStrings) { if(!PwDefs.IsStandardField(kvpStr.Key)) { PwIcon pwIcon = (kvpStr.Value.IsProtected ? m_pwObjectProtected : m_pwObjectPlainText); ListViewItem lvi = m_lvStrings.Items.Add(kvpStr.Key, (int)pwIcon); if(kvpStr.Value.IsProtected) lvi.SubItems.Add(PwDefs.HiddenPassword); else { string strValue = StrUtil.MultiToSingleLine( kvpStr.Value.ReadString()); lvi.SubItems.Add(strValue); } } } UIUtil.SetTopVisibleItem(m_lvStrings, iTopVisible); } } // Public for plugins public void UpdateEntryBinaries(bool bGuiToInternal) { UpdateEntryBinaries(bGuiToInternal, false, null); } public void UpdateEntryBinaries(bool bGuiToInternal, bool bUpdateState) { UpdateEntryBinaries(bGuiToInternal, bUpdateState, null); } public void UpdateEntryBinaries(bool bGuiToInternal, bool bUpdateState, string strFocusItem) { if(bGuiToInternal) { } else // Internal to GUI { int iTopVisible = UIUtil.GetTopVisibleItem(m_lvBinaries); m_lvBinaries.Items.Clear(); foreach(KeyValuePair kvpBin in m_vBinaries) { PwIcon pwIcon = (kvpBin.Value.IsProtected ? m_pwObjectProtected : m_pwObjectPlainText); ListViewItem lvi = m_lvBinaries.Items.Add(kvpBin.Key, (int)pwIcon); lvi.SubItems.Add(StrUtil.FormatDataSizeKB(kvpBin.Value.Length)); } UIUtil.SetTopVisibleItem(m_lvBinaries, iTopVisible); if(strFocusItem != null) { ListViewItem lvi = m_lvBinaries.FindItemWithText(strFocusItem, false, 0, false); if(lvi != null) { m_lvBinaries.EnsureVisible(lvi.Index); UIUtil.SetFocusedItem(m_lvBinaries, lvi, true); } else { Debug.Assert(false); } } } if(bUpdateState) EnableControlsEx(); } internal static Image CreateColorButtonImage(Button btn, Color clr) { return UIUtil.CreateColorBitmap24(btn.ClientRectangle.Width - 8, btn.ClientRectangle.Height - 8, clr); } private void InitPropertiesTab() { m_clrForeground = m_pwEntry.ForegroundColor; m_clrBackground = m_pwEntry.BackgroundColor; if(m_clrForeground != Color.Empty) UIUtil.SetButtonImage(m_btnPickFgColor, CreateColorButtonImage( m_btnPickFgColor, m_clrForeground), false); if(m_clrBackground != Color.Empty) UIUtil.SetButtonImage(m_btnPickBgColor, CreateColorButtonImage( m_btnPickBgColor, m_clrBackground), false); m_cbCustomForegroundColor.Checked = (m_clrForeground != Color.Empty); m_cbCustomBackgroundColor.Checked = (m_clrBackground != Color.Empty); m_cmbOverrideUrl.Text = m_pwEntry.OverrideUrl; m_tbTags.Text = StrUtil.TagsToString(m_pwEntry.Tags, true); if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) { m_cbCustomForegroundColor.Enabled = false; m_cbCustomBackgroundColor.Enabled = false; m_btnPickFgColor.Enabled = false; m_btnPickBgColor.Enabled = false; m_cmbOverrideUrl.Enabled = false; m_tbTags.ReadOnly = true; } m_tbUuid.Text = m_pwEntry.Uuid.ToHexString(); } private void InitAutoTypeTab() { m_lvAutoType.SmallImageList = m_ilIcons; m_cbAutoTypeEnabled.Checked = m_atConfig.Enabled; m_cbAutoTypeObfuscation.Checked = !(m_atConfig.ObfuscationOptions == AutoTypeObfuscationOptions.None); string strDefaultSeq = m_atConfig.DefaultSequence; if(strDefaultSeq.Length > 0) m_rbAutoTypeOverride.Checked = true; else m_rbAutoTypeSeqInherit.Checked = true; if(strDefaultSeq.Length == 0) { PwGroup pg = m_pwEntry.ParentGroup; if(pg != null) { strDefaultSeq = pg.GetAutoTypeSequenceInherited(); if(strDefaultSeq.Length == 0) { if(PwDefs.IsTanEntry(m_pwEntry)) strDefaultSeq = PwDefs.DefaultAutoTypeSequenceTan; else strDefaultSeq = PwDefs.DefaultAutoTypeSequence; } } } m_tbDefaultAutoTypeSeq.Text = strDefaultSeq; int nWidth = m_lvAutoType.ClientRectangle.Width / 2; m_lvAutoType.Columns.Add(KPRes.TargetWindow, nWidth); m_lvAutoType.Columns.Add(KPRes.Sequence, nWidth); UpdateAutoTypeList(); if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) { m_cbAutoTypeEnabled.Enabled = m_cbAutoTypeObfuscation.Enabled = m_rbAutoTypeSeqInherit.Enabled = m_rbAutoTypeOverride.Enabled = m_btnAutoTypeAdd.Enabled = m_btnAutoTypeDelete.Enabled = m_btnAutoTypeEdit.Enabled = false; m_tbDefaultAutoTypeSeq.Enabled = m_btnAutoTypeEditDefault.Enabled = false; } } private void UpdateAutoTypeList() { m_lvAutoType.Items.Clear(); string strDefault = "(" + KPRes.Default + ")"; foreach(AutoTypeAssociation a in m_atConfig.Associations) { ListViewItem lvi = m_lvAutoType.Items.Add(a.WindowName, (int)PwIcon.List); lvi.SubItems.Add((a.Sequence.Length > 0) ? a.Sequence : strDefault); } } private void InitHistoryTab() { m_lvHistory.SmallImageList = m_ilIcons; m_lvHistory.Columns.Add(KPRes.Version); m_lvHistory.Columns.Add(KPRes.Title); m_lvHistory.Columns.Add(KPRes.UserName); m_lvHistory.Columns.Add(KPRes.Size, 72, HorizontalAlignment.Right); UpdateHistoryList(); if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) { m_btnHistoryDelete.Enabled = m_btnHistoryRestore.Enabled = m_btnHistoryView.Enabled = false; } } private void UpdateHistoryList() { m_lvHistory.Items.Clear(); foreach(PwEntry pe in m_vHistory) { ListViewItem lvi = m_lvHistory.Items.Add(TimeUtil.ToDisplayString( pe.LastModificationTime), (int)pe.IconId); lvi.SubItems.Add(pe.Strings.ReadSafe(PwDefs.TitleField)); lvi.SubItems.Add(pe.Strings.ReadSafe(PwDefs.UserNameField)); lvi.SubItems.Add(StrUtil.FormatDataSizeKB(pe.GetSize())); } } private void ResizeColumnHeaders() { Debug.Assert(m_lvStrings.Columns.Count == 2); int dx = m_lvStrings.ClientRectangle.Width; m_lvStrings.Columns[0].Width = dx / 2; m_lvStrings.Columns[1].Width = dx / 2; Debug.Assert(m_lvBinaries.Columns.Count == 2); dx = m_lvBinaries.ClientRectangle.Width; m_lvBinaries.Columns[0].Width = (dx * 4) / 5; m_lvBinaries.Columns[1].Width = dx / 5; Debug.Assert(m_lvAutoType.Columns.Count == 2); dx = m_lvAutoType.ClientRectangle.Width; m_lvAutoType.Columns[0].Width = m_lvAutoType.Columns[1].Width = dx / 2; Debug.Assert(m_lvHistory.Columns.Count == 4); dx = m_lvHistory.ClientRectangle.Width; int dt = dx / 85; m_lvHistory.Columns[0].Width = (dx * 2) / 7 + dt; m_lvHistory.Columns[1].Width = (dx * 2) / 7; m_lvHistory.Columns[2].Width = ((dx * 2) / 7) - (dt * 2); m_lvHistory.Columns[3].Width = (dx / 7) + dt; } private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_pwEntry != null); if(m_pwEntry == null) throw new InvalidOperationException(); Debug.Assert(m_pwEditMode != PwEditMode.Invalid); if(m_pwEditMode == PwEditMode.Invalid) throw new ArgumentException(); Debug.Assert(m_pwDatabase != null); if(m_pwDatabase == null) throw new InvalidOperationException(); Debug.Assert(m_ilIcons != null); if(m_ilIcons == null) throw new InvalidOperationException(); GlobalWindowManager.AddWindow(this); GlobalWindowManager.CustomizeControl(m_ctxTools); GlobalWindowManager.CustomizeControl(m_ctxPwGen); GlobalWindowManager.CustomizeControl(m_ctxStrMoveToStandard); m_pwInitialEntry = m_pwEntry.CloneDeep(); StrUtil.NormalizeNewLines(m_pwInitialEntry.Strings, true); m_ttRect.SetToolTip(m_btnIcon, KPRes.SelectIcon); m_ttRect.SetToolTip(m_cbHidePassword, KPRes.TogglePasswordAsterisks); m_ttRect.SetToolTip(m_btnGenPw, KPRes.GeneratePassword); m_ttRect.SetToolTip(m_btnStandardExpires, KPRes.StandardExpireSelect); m_ttBalloon.SetToolTip(m_tbRepeatPassword, KPRes.PasswordRepeatHint); m_dynGenProfiles = new DynamicMenu(m_ctxPwGen.Items); m_dynGenProfiles.MenuClick += this.OnProfilesDynamicMenuClick; m_ctxNotes.Attach(m_rtNotes, this); m_ctxBinOpen = new ContextMenuStrip(); m_ctxBinOpen.Opening += this.OnCtxBinOpenOpening; m_dynBinOpen = new DynamicMenu(m_ctxBinOpen.Items); m_dynBinOpen.MenuClick += this.OnDynBinOpen; m_btnBinOpen.SplitDropDownMenu = m_ctxBinOpen; string strTitle = string.Empty, strDesc = string.Empty; if(m_pwEditMode == PwEditMode.AddNewEntry) { strTitle = KPRes.AddEntry; strDesc = KPRes.AddEntryDesc; } else if(m_pwEditMode == PwEditMode.EditExistingEntry) { strTitle = KPRes.EditEntry; strDesc = KPRes.EditEntryDesc; } else if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) { strTitle = KPRes.ViewEntry; strDesc = KPRes.ViewEntryDesc; } else { Debug.Assert(false); } BannerFactory.CreateBannerEx(this, m_bannerImage, KeePass.Properties.Resources.B48x48_KGPG_Sign, strTitle, strDesc); this.Icon = Properties.Resources.KeePass; this.Text = strTitle; m_imgPwGen = UIUtil.CreateDropDownImage(Properties.Resources.B16x16_Key_New); m_imgStdExpire = UIUtil.CreateDropDownImage(Properties.Resources.B16x16_History); UIUtil.SetButtonImage(m_btnTools, Properties.Resources.B16x16_Package_Settings, true); UIUtil.SetButtonImage(m_btnGenPw, m_imgPwGen, true); UIUtil.SetButtonImage(m_btnStandardExpires, m_imgStdExpire, true); if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) m_bLockEnabledState = true; // UIUtil.SetExplorerTheme(m_lvStrings, true); // UIUtil.SetExplorerTheme(m_lvBinaries, true); // UIUtil.SetExplorerTheme(m_lvAutoType, true); // UIUtil.SetExplorerTheme(m_lvHistory, true); UIUtil.PrepareStandardMultilineControl(m_rtNotes, true, true); m_bInitializing = true; bool bForceHide = !AppPolicy.Current.UnhidePasswords; if(Program.Config.UI.Hiding.SeparateHidingSettings) m_cbHidePassword.Checked = (Program.Config.UI.Hiding.HideInEntryWindow || bForceHide); else { AceColumn colPw = Program.Config.MainWindow.FindColumn(AceColumnType.Password); m_cbHidePassword.Checked = (((colPw != null) ? colPw.HideWithAsterisks : true) || bForceHide); } InitEntryTab(); InitAdvancedTab(); InitPropertiesTab(); InitAutoTypeTab(); InitHistoryTab(); UpdateEntryStrings(false, true); UpdateEntryBinaries(false, false); if(PwDefs.IsTanEntry(m_pwEntry)) m_btnTools.Enabled = false; CustomizeForScreenReader(); m_bInitializing = false; if(m_bInitSwitchToHistory) // Before 'Advanced' tab switch m_tabMain.SelectedTab = m_tabHistory; else if(m_bShowAdvancedByDefault) m_tabMain.SelectedTab = m_tabAdvanced; ResizeColumnHeaders(); EnableControlsEx(); ThreadPool.QueueUserWorkItem(delegate(object state) { try { InitOverridesBox(); } catch(Exception) { Debug.Assert(false); } }); if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) m_btnCancel.Select(); else { if(m_bSelectFullTitle) m_tbTitle.Select(0, m_tbTitle.TextLength); else m_tbTitle.Select(0, 0); m_tbTitle.Select(); } } private void CustomizeForScreenReader() { if(!Program.Config.UI.OptimizeForScreenReader) return; m_btnIcon.Text = KPRes.PickIcon; m_cbHidePassword.Text = KPRes.HideUsingAsterisks; m_btnGenPw.Text = m_ttRect.GetToolTip(m_btnGenPw); m_btnStandardExpires.Text = m_ttRect.GetToolTip(m_btnStandardExpires); m_btnPickFgColor.Text = KPRes.SelectColor; m_btnPickBgColor.Text = KPRes.SelectColor; } private void EnableControlsEx() { if(m_bInitializing) return; int nStringsSel = m_lvStrings.SelectedItems.Count; int nBinSel = m_lvBinaries.SelectedItems.Count; m_btnBinOpen.Enabled = (nBinSel == 1); m_btnBinSave.Enabled = (nBinSel >= 1); if(m_bLockEnabledState) return; m_btnStrEdit.Enabled = (nStringsSel == 1); m_btnStrDelete.Enabled = (nStringsSel >= 1); m_btnBinDelete.Enabled = (nBinSel >= 1); m_btnPickFgColor.Enabled = m_cbCustomForegroundColor.Checked; m_btnPickBgColor.Enabled = m_cbCustomBackgroundColor.Checked; bool bATEnabled = m_cbAutoTypeEnabled.Checked; m_lvAutoType.Enabled = m_btnAutoTypeAdd.Enabled = m_rbAutoTypeSeqInherit.Enabled = m_rbAutoTypeOverride.Enabled = m_cbAutoTypeObfuscation.Enabled = bATEnabled; if(!m_rbAutoTypeOverride.Checked) m_tbDefaultAutoTypeSeq.Enabled = m_btnAutoTypeEditDefault.Enabled = false; else m_tbDefaultAutoTypeSeq.Enabled = m_btnAutoTypeEditDefault.Enabled = bATEnabled; int nAutoTypeSel = m_lvAutoType.SelectedItems.Count; if(m_pwEditMode != PwEditMode.ViewReadOnlyEntry) { m_btnAutoTypeEdit.Enabled = (bATEnabled && (nAutoTypeSel == 1)); m_btnAutoTypeDelete.Enabled = (bATEnabled && (nAutoTypeSel >= 1)); } int nAccumSel = nStringsSel + nBinSel + nAutoTypeSel; m_menuListCtxCopyFieldValue.Enabled = (nAccumSel != 0); int nHistorySel = m_lvHistory.SelectedIndices.Count; m_btnHistoryRestore.Enabled = (nHistorySel == 1); m_btnHistoryDelete.Enabled = m_btnHistoryView.Enabled = (nHistorySel >= 1); m_menuListCtxMoveStandardTitle.Enabled = m_menuListCtxMoveStandardUser.Enabled = m_menuListCtxMoveStandardPassword.Enabled = m_menuListCtxMoveStandardURL.Enabled = m_menuListCtxMoveStandardNotes.Enabled = m_btnStrMove.Enabled = (nStringsSel == 1); } private bool SaveEntry(PwEntry peTarget, bool bValidate) { if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) return true; if(bValidate && !m_icgPassword.ValidateData(true)) return false; if(this.EntrySaving != null) { CancellableOperationEventArgs eaCancel = new CancellableOperationEventArgs(); this.EntrySaving(this, eaCancel); if(eaCancel.Cancel) return false; } peTarget.History = m_vHistory; // Must be called before CreateBackup() bool bCreateBackup = (m_pwEditMode != PwEditMode.AddNewEntry); if(bCreateBackup) peTarget.CreateBackup(null); peTarget.IconId = m_pwEntryIcon; peTarget.CustomIconUuid = m_pwCustomIconID; if(m_cbCustomForegroundColor.Checked) peTarget.ForegroundColor = m_clrForeground; else peTarget.ForegroundColor = Color.Empty; if(m_cbCustomBackgroundColor.Checked) peTarget.BackgroundColor = m_clrBackground; else peTarget.BackgroundColor = Color.Empty; peTarget.OverrideUrl = m_cmbOverrideUrl.Text; List vNewTags = StrUtil.StringToTags(m_tbTags.Text); peTarget.Tags.Clear(); foreach(string strTag in vNewTags) peTarget.AddTag(strTag); peTarget.Expires = m_cgExpiry.Checked; if(peTarget.Expires) peTarget.ExpiryTime = m_cgExpiry.Value; UpdateEntryStrings(true, false); peTarget.Strings = m_vStrings; peTarget.Binaries = m_vBinaries; m_atConfig.Enabled = m_cbAutoTypeEnabled.Checked; m_atConfig.ObfuscationOptions = (m_cbAutoTypeObfuscation.Checked ? AutoTypeObfuscationOptions.UseClipboard : AutoTypeObfuscationOptions.None); SaveDefaultSeq(); peTarget.AutoType = m_atConfig; peTarget.Touch(true, false); // Touch *after* backup if(object.ReferenceEquals(peTarget, m_pwEntry)) m_bTouchedOnce = true; StrUtil.NormalizeNewLines(peTarget.Strings, true); bool bUndoBackup = false; PwCompareOptions cmpOpt = m_cmpOpt; if(bCreateBackup) cmpOpt |= PwCompareOptions.IgnoreLastBackup; if(peTarget.EqualsEntry(m_pwInitialEntry, cmpOpt, MemProtCmpMode.CustomOnly)) { // No modifications at all => restore last mod time and undo backup peTarget.LastModificationTime = m_pwInitialEntry.LastModificationTime; bUndoBackup = bCreateBackup; } else if(bCreateBackup) { // If only history items have been modified (deleted) => undo // backup, but without restoring the last mod time PwCompareOptions cmpOptNH = (m_cmpOpt | PwCompareOptions.IgnoreHistory); if(peTarget.EqualsEntry(m_pwInitialEntry, cmpOptNH, MemProtCmpMode.CustomOnly)) bUndoBackup = true; } if(bUndoBackup) peTarget.History.RemoveAt(peTarget.History.UCount - 1); peTarget.MaintainBackups(m_pwDatabase); if(this.EntrySaved != null) this.EntrySaved(this, EventArgs.Empty); return true; } private void SaveDefaultSeq() { if(m_rbAutoTypeSeqInherit.Checked) m_atConfig.DefaultSequence = string.Empty; else if(m_rbAutoTypeOverride.Checked) m_atConfig.DefaultSequence = m_tbDefaultAutoTypeSeq.Text; else { Debug.Assert(false); } } private void OnBtnOK(object sender, EventArgs e) { if(SaveEntry(m_pwEntry, true)) m_bForceClosing = true; else this.DialogResult = DialogResult.None; } private void OnBtnCancel(object sender, EventArgs e) { m_bForceClosing = true; try { ushort usEsc = NativeMethods.GetAsyncKeyState((int)Keys.Escape); if((usEsc & 0x8000) != 0) m_bForceClosing = false; } catch(Exception) { Debug.Assert(KeePassLib.Native.NativeLib.IsUnix()); } } private void CleanUpEx() { m_dynGenProfiles.MenuClick -= this.OnProfilesDynamicMenuClick; m_dynGenProfiles.Clear(); m_btnBinOpen.SplitDropDownMenu = null; m_dynBinOpen.MenuClick -= this.OnDynBinOpen; m_dynBinOpen.Clear(); m_ctxBinOpen.Opening -= this.OnCtxBinOpenOpening; m_ctxBinOpen.Dispose(); if(m_pwEditMode != PwEditMode.ViewReadOnlyEntry) Program.Config.UI.Hiding.HideInEntryWindow = m_cbHidePassword.Checked; m_ctxNotes.Detach(); m_icgPassword.Release(); m_cgExpiry.Release(); m_cmbOverrideUrl.OrderedImageList = null; foreach(Image img in m_lOverrideUrlIcons) { if(img != null) img.Dispose(); } m_lOverrideUrlIcons.Clear(); // Detach event handlers m_lvStrings.SmallImageList = null; m_lvBinaries.SmallImageList = null; m_lvAutoType.SmallImageList = null; m_lvHistory.SmallImageList = null; m_btnGenPw.Image = null; m_imgPwGen.Dispose(); m_imgPwGen = null; m_btnStandardExpires.Image = null; m_imgStdExpire.Dispose(); m_imgStdExpire = null; } private void OnBtnStrAdd(object sender, EventArgs e) { if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) return; UpdateEntryStrings(true, false); EditStringForm esf = new EditStringForm(); esf.InitEx(m_vStrings, null, null, m_pwDatabase); if(UIUtil.ShowDialogAndDestroy(esf) == DialogResult.OK) { UpdateEntryStrings(false, false); ResizeColumnHeaders(); } } private void OnBtnStrEdit(object sender, EventArgs e) { if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) return; ListView.SelectedListViewItemCollection vSel = m_lvStrings.SelectedItems; if(vSel.Count <= 0) return; UpdateEntryStrings(true, false); string strName = vSel[0].Text; ProtectedString psValue = m_vStrings.Get(strName); Debug.Assert(psValue != null); EditStringForm esf = new EditStringForm(); esf.InitEx(m_vStrings, strName, psValue, m_pwDatabase); if(UIUtil.ShowDialogAndDestroy(esf) == DialogResult.OK) UpdateEntryStrings(false, false); } private void OnBtnStrDelete(object sender, EventArgs e) { if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) return; UpdateEntryStrings(true, false); ListView.SelectedListViewItemCollection lvsicSel = m_lvStrings.SelectedItems; for(int i = 0; i < lvsicSel.Count; ++i) { if(!m_vStrings.Remove(lvsicSel[i].Text)) { Debug.Assert(false); } } if(lvsicSel.Count > 0) { UpdateEntryStrings(false, false); ResizeColumnHeaders(); } } private void OnBtnBinAdd(object sender, EventArgs e) { m_ctxBinAttach.Show(m_btnBinAdd, new Point(0, m_btnBinAdd.Height)); } private void OnBtnBinDelete(object sender, EventArgs e) { if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) return; UpdateEntryBinaries(true, false); ListView.SelectedListViewItemCollection lvsc = m_lvBinaries.SelectedItems; int nSelCount = lvsc.Count; if(nSelCount == 0) { Debug.Assert(false); return; } for(int i = 0; i < nSelCount; ++i) m_vBinaries.Remove(lvsc[nSelCount - i - 1].Text); UpdateEntryBinaries(false, true); ResizeColumnHeaders(); } private void OnBtnBinSave(object sender, EventArgs e) { ListView.SelectedListViewItemCollection lvsc = m_lvBinaries.SelectedItems; int nSelCount = lvsc.Count; if(nSelCount == 0) { Debug.Assert(false); return; } if(nSelCount == 1) { SaveFileDialogEx sfd = UIUtil.CreateSaveFileDialog(KPRes.AttachmentSave, lvsc[0].Text, UIUtil.CreateFileTypeFilter(null, null, true), 1, null, AppDefs.FileDialogContext.Attachments); if(sfd.ShowDialog() == DialogResult.OK) SaveAttachmentTo(lvsc[0], sfd.FileName, false); } else // nSelCount > 1 { FolderBrowserDialog fbd = UIUtil.CreateFolderBrowserDialog(KPRes.AttachmentsSave); if(fbd.ShowDialog() == DialogResult.OK) { string strRootPath = UrlUtil.EnsureTerminatingSeparator(fbd.SelectedPath, false); foreach(ListViewItem lvi in lvsc) SaveAttachmentTo(lvi, strRootPath + lvi.Text, true); } fbd.Dispose(); } } private void SaveAttachmentTo(ListViewItem lvi, string strFileName, bool bConfirmOverwrite) { Debug.Assert(lvi != null); if(lvi == null) throw new ArgumentNullException("lvi"); Debug.Assert(strFileName != null); if(strFileName == null) throw new ArgumentNullException("strFileName"); if(bConfirmOverwrite && File.Exists(strFileName)) { string strMsg = KPRes.FileExistsAlready + MessageService.NewLine + strFileName + MessageService.NewParagraph + KPRes.OverwriteExistingFileQuestion; if(MessageService.AskYesNo(strMsg) == false) return; } ProtectedBinary pb = m_vBinaries.Get(lvi.Text); Debug.Assert(pb != null); if(pb == null) throw new ArgumentException(); byte[] pbData = pb.ReadData(); try { File.WriteAllBytes(strFileName, pbData); } catch(Exception exWrite) { MessageService.ShowWarning(strFileName, exWrite); } MemUtil.ZeroByteArray(pbData); } private void OnBtnAutoTypeAdd(object sender, EventArgs e) { if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) return; EditAutoTypeItemForm dlg = new EditAutoTypeItemForm(); dlg.InitEx(m_atConfig, -1, false, m_tbDefaultAutoTypeSeq.Text, m_vStrings); if(UIUtil.ShowDialogAndDestroy(dlg) == DialogResult.OK) { UpdateAutoTypeList(); ResizeColumnHeaders(); } } private void OnBtnAutoTypeEdit(object sender, EventArgs e) { if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) return; ListView.SelectedIndexCollection lvSel = m_lvAutoType.SelectedIndices; Debug.Assert(lvSel.Count == 1); if(lvSel.Count != 1) return; EditAutoTypeItemForm dlg = new EditAutoTypeItemForm(); dlg.InitEx(m_atConfig, lvSel[0], false, m_tbDefaultAutoTypeSeq.Text, m_vStrings); if(UIUtil.ShowDialogAndDestroy(dlg) == DialogResult.OK) UpdateAutoTypeList(); } private void OnBtnAutoTypeDelete(object sender, EventArgs e) { if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) return; int j, nItemCount = m_lvAutoType.Items.Count; for(int i = 0; i < nItemCount; ++i) { j = nItemCount - i - 1; if(m_lvAutoType.Items[j].Selected) m_atConfig.RemoveAt(j); } UpdateAutoTypeList(); ResizeColumnHeaders(); } private void OnBtnHistoryView(object sender, EventArgs e) { Debug.Assert(m_vHistory.UCount == m_lvHistory.Items.Count); ListView.SelectedIndexCollection lvsi = m_lvHistory.SelectedIndices; if(lvsi.Count != 1) { Debug.Assert(false); return; } PwEntry pe = m_vHistory.GetAt((uint)lvsi[0]); if(pe == null) { Debug.Assert(false); return; } PwEntryForm pwf = new PwEntryForm(); pwf.InitEx(pe, PwEditMode.ViewReadOnlyEntry, m_pwDatabase, m_ilIcons, false, false); UIUtil.ShowDialogAndDestroy(pwf); } private void OnBtnHistoryDelete(object sender, EventArgs e) { if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) return; Debug.Assert(m_vHistory.UCount == m_lvHistory.Items.Count); ListView.SelectedIndexCollection lvsi = m_lvHistory.SelectedIndices; int nSelCount = lvsi.Count; if(nSelCount == 0) return; for(int i = 0; i < lvsi.Count; ++i) m_vHistory.Remove(m_vHistory.GetAt((uint)lvsi[nSelCount - i - 1])); UpdateHistoryList(); ResizeColumnHeaders(); } private void OnBtnHistoryRestore(object sender, EventArgs e) { if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) return; Debug.Assert(m_vHistory.UCount == m_lvHistory.Items.Count); ListView.SelectedIndexCollection lvsi = m_lvHistory.SelectedIndices; if(lvsi.Count != 1) { Debug.Assert(false); return; } m_pwEntry.RestoreFromBackup((uint)lvsi[0], m_pwDatabase); m_pwEntry.Touch(true, false); m_bTouchedOnce = true; this.DialogResult = DialogResult.OK; // Doesn't invoke OnBtnOK } private void OnHistorySelectedIndexChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnStringsSelectedIndexChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnBinariesSelectedIndexChanged(object sender, EventArgs e) { EnableControlsEx(); } private void SetExpireIn(int nYears, int nMonths, int nDays) { if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) return; DateTime dt = DateTime.Now.Date; dt = dt.AddYears(nYears); dt = dt.AddMonths(nMonths); dt = dt.AddDays(nDays); DateTime dtPrevTime = m_cgExpiry.Value; dt = dt.AddHours(dtPrevTime.Hour); dt = dt.AddMinutes(dtPrevTime.Minute); dt = dt.AddSeconds(dtPrevTime.Second); m_cgExpiry.Checked = true; m_cgExpiry.Value = dt; EnableControlsEx(); } private void OnMenuExpireNow(object sender, EventArgs e) { SetExpireIn(0, 0, 0); } private void OnMenuExpire1Week(object sender, EventArgs e) { SetExpireIn(0, 0, 7); } private void OnMenuExpire2Weeks(object sender, EventArgs e) { SetExpireIn(0, 0, 14); } private void OnMenuExpire1Month(object sender, EventArgs e) { SetExpireIn(0, 1, 0); } private void OnMenuExpire3Months(object sender, EventArgs e) { SetExpireIn(0, 3, 0); } private void OnMenuExpire6Months(object sender, EventArgs e) { SetExpireIn(0, 6, 0); } private void OnMenuExpire1Year(object sender, EventArgs e) { SetExpireIn(1, 0, 0); } private void OnBtnStandardExpiresClick(object sender, EventArgs e) { m_ctxDefaultTimes.Show(m_btnStandardExpires, 0, m_btnStandardExpires.Height); } private void OnCtxCopyFieldValue(object sender, EventArgs e) { ListView.SelectedListViewItemCollection lvsc; if(m_lvStrings.Focused) { lvsc = m_lvStrings.SelectedItems; if((lvsc != null) && (lvsc.Count > 0)) { string strName = lvsc[0].Text; ClipboardUtil.Copy(m_vStrings.ReadSafe(strName), true, true, null, m_pwDatabase, this.Handle); } } else if(m_lvAutoType.Focused) { lvsc = m_lvAutoType.SelectedItems; if((lvsc != null) && (lvsc.Count > 0)) ClipboardUtil.Copy(lvsc[0].SubItems[1].Text, true, true, null, m_pwDatabase, this.Handle); } else { Debug.Assert(false); } } private void OnBtnPickIcon(object sender, EventArgs e) { if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) return; IconPickerForm ipf = new IconPickerForm(); ipf.InitEx(m_ilIcons, (uint)PwIcon.Count, m_pwDatabase, (uint)m_pwEntryIcon, m_pwCustomIconID); if(ipf.ShowDialog() == DialogResult.OK) { if(!ipf.ChosenCustomIconUuid.Equals(PwUuid.Zero)) // Custom icon { m_pwCustomIconID = ipf.ChosenCustomIconUuid; UIUtil.SetButtonImage(m_btnIcon, m_pwDatabase.GetCustomIcon( m_pwCustomIconID), true); } else // Standard icon { m_pwEntryIcon = (PwIcon)ipf.ChosenIconId; m_pwCustomIconID = PwUuid.Zero; UIUtil.SetButtonImage(m_btnIcon, m_ilIcons.Images[ (int)m_pwEntryIcon], true); } } UIUtil.DestroyForm(ipf); } private void OnAutoTypeSeqInheritCheckedChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnAutoTypeEnableCheckedChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnBtnAutoTypeEditDefault(object sender, EventArgs e) { if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) return; SaveDefaultSeq(); EditAutoTypeItemForm ef = new EditAutoTypeItemForm(); ef.InitEx(m_atConfig, -1, true, m_tbDefaultAutoTypeSeq.Text, m_vStrings); if(UIUtil.ShowDialogAndDestroy(ef) == DialogResult.OK) m_tbDefaultAutoTypeSeq.Text = m_atConfig.DefaultSequence; } private void OnCtxMoveToTitle(object sender, EventArgs e) { MoveSelectedStringTo(PwDefs.TitleField); } private void OnCtxMoveToUserName(object sender, EventArgs e) { MoveSelectedStringTo(PwDefs.UserNameField); } private void OnCtxMoveToPassword(object sender, EventArgs e) { MoveSelectedStringTo(PwDefs.PasswordField); } private void OnCtxMoveToURL(object sender, EventArgs e) { MoveSelectedStringTo(PwDefs.UrlField); } private void OnCtxMoveToNotes(object sender, EventArgs e) { MoveSelectedStringTo(PwDefs.NotesField); } private void MoveSelectedStringTo(string strStandardField) { ListView.SelectedListViewItemCollection lvsic = m_lvStrings.SelectedItems; Debug.Assert(lvsic.Count == 1); if(lvsic.Count != 1) return; ListViewItem lvi = lvsic[0]; string strText = m_vStrings.ReadSafe(lvi.Text); if(strStandardField == PwDefs.TitleField) { if((m_tbTitle.TextLength > 0) && (strText.Length > 0)) m_tbTitle.Text += ", "; m_tbTitle.Text += strText; } else if(strStandardField == PwDefs.UserNameField) { if((m_tbUserName.TextLength > 0) && (strText.Length > 0)) m_tbUserName.Text += ", "; m_tbUserName.Text += strText; } else if(strStandardField == PwDefs.PasswordField) { string strPw = m_icgPassword.GetPassword(); if((strPw.Length > 0) && (strText.Length > 0)) strPw += ", "; strPw += strText; string strRep = m_icgPassword.GetRepeat(); if((strRep.Length > 0) && (strText.Length > 0)) strRep += ", "; strRep += strText; m_icgPassword.SetPasswords(strPw, strRep); } else if(strStandardField == PwDefs.UrlField) { if((m_tbUrl.TextLength > 0) && (strText.Length > 0)) m_tbUrl.Text += ", "; m_tbUrl.Text += strText; } else if(strStandardField == PwDefs.NotesField) { if((m_rtNotes.TextLength > 0) && (strText.Length > 0)) m_rtNotes.Text += MessageService.NewParagraph; m_rtNotes.Text += strText; } else { Debug.Assert(false); } UpdateEntryStrings(true, false); m_vStrings.Remove(lvi.Text); UpdateEntryStrings(false, false); EnableControlsEx(); } private void OnBtnStrMove(object sender, EventArgs e) { m_ctxStrMoveToStandard.Show(m_btnStrMove, 0, m_btnStrMove.Height); } private void OnNotesLinkClicked(object sender, LinkClickedEventArgs e) { WinUtil.OpenUrl(e.LinkText, m_pwEntry); } private void OnAutoTypeSelectedIndexChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnAutoTypeItemActivate(object sender, EventArgs e) { OnBtnAutoTypeEdit(sender, e); } private void OnStringsItemActivate(object sender, EventArgs e) { OnBtnStrEdit(sender, e); } private void OnPwGenOpen(object sender, EventArgs e) { PwGeneratorForm pgf = new PwGeneratorForm(); byte[] pbCurPassword = m_icgPassword.GetPasswordUtf8(); bool bAtLeastOneChar = (pbCurPassword.Length > 0); ProtectedString ps = new ProtectedString(true, pbCurPassword); Array.Clear(pbCurPassword, 0, pbCurPassword.Length); PwProfile opt = PwProfile.DeriveFromPassword(ps); pgf.InitEx((bAtLeastOneChar ? opt : null), true, false); // pgf.InitEx(null, true, false); if(pgf.ShowDialog() == DialogResult.OK) { byte[] pbEntropy = EntropyForm.CollectEntropyIfEnabled(pgf.SelectedProfile); ProtectedString psNew; PwGenerator.Generate(out psNew, pgf.SelectedProfile, pbEntropy, Program.PwGeneratorPool); byte[] pbNew = psNew.ReadUtf8(); m_icgPassword.SetPassword(pbNew, true); MemUtil.ZeroByteArray(pbNew); } UIUtil.DestroyForm(pgf); EnableControlsEx(); } private void OnProfilesDynamicMenuClick(object sender, DynamicMenuEventArgs e) { PwProfile pwp = null; if(e.ItemName == DeriveFromPrevious) { byte[] pbCur = m_icgPassword.GetPasswordUtf8(); ProtectedString psCur = new ProtectedString(true, pbCur); MemUtil.ZeroByteArray(pbCur); pwp = PwProfile.DeriveFromPassword(psCur); } else if(e.ItemName == AutoGenProfile) pwp = Program.Config.PasswordGenerator.AutoGeneratedPasswordsProfile; else { foreach(PwProfile pwgo in PwGeneratorUtil.GetAllProfiles(false)) { if(pwgo.Name == e.ItemName) { pwp = pwgo; break; } } } if(pwp != null) { ProtectedString psNew; PwGenerator.Generate(out psNew, pwp, null, Program.PwGeneratorPool); byte[] pbNew = psNew.ReadUtf8(); m_icgPassword.SetPassword(pbNew, true); MemUtil.ZeroByteArray(pbNew); } else { Debug.Assert(false); } } private void OnPwGenClick(object sender, EventArgs e) { m_dynGenProfiles.Clear(); m_dynGenProfiles.AddSeparator(); m_dynGenProfiles.AddItem(DeriveFromPrevious, Properties.Resources.B16x16_CompFile); m_dynGenProfiles.AddItem(AutoGenProfile, Properties.Resources.B16x16_FileNew); bool bHideBuiltIn = ((Program.Config.UI.UIFlags & (ulong)AceUIFlags.HideBuiltInPwGenPrfInEntryDlg) != 0); List> l = new List>(); foreach(PwProfile pwgo in PwGeneratorUtil.GetAllProfiles(true)) { if((pwgo.Name != DeriveFromPrevious) && (pwgo.Name != AutoGenProfile)) { if(bHideBuiltIn && PwGeneratorUtil.IsBuiltInProfile(pwgo.Name)) continue; l.Add(new KeyValuePair(pwgo.Name, Properties.Resources.B16x16_KOrganizer)); } } if(l.Count > 0) m_dynGenProfiles.AddSeparator(); foreach(KeyValuePair kvp in l) m_dynGenProfiles.AddItem(kvp.Key, kvp.Value); m_ctxPwGen.Show(m_btnGenPw, new Point(0, m_btnGenPw.Height)); } private void OnPickForegroundColor(object sender, EventArgs e) { Color? clr = UIUtil.ShowColorDialog(m_clrForeground); if(clr.HasValue) { m_clrForeground = clr.Value; UIUtil.SetButtonImage(m_btnPickFgColor, CreateColorButtonImage( m_btnPickFgColor, m_clrForeground), false); } } private void OnPickBackgroundColor(object sender, EventArgs e) { Color? clr = UIUtil.ShowColorDialog(m_clrBackground); if(clr.HasValue) { m_clrBackground = clr.Value; UIUtil.SetButtonImage(m_btnPickBgColor, CreateColorButtonImage( m_btnPickBgColor, m_clrBackground), false); } } private void OnCustomForegroundColorCheckedChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnCustomBackgroundColorCheckedChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnFormClosed(object sender, FormClosedEventArgs e) { GlobalWindowManager.RemoveWindow(this); } private void OnAutoTypeObfuscationLink(object sender, LinkLabelLinkClickedEventArgs e) { if(e.Button == MouseButtons.Left) AppHelp.ShowHelp(AppDefs.HelpTopics.AutoTypeObfuscation, null); } private void OnAutoTypeObfuscationCheckedChanged(object sender, EventArgs e) { if(m_bInitializing) return; if(m_cbAutoTypeObfuscation.Checked == false) return; MessageService.ShowInfo(KPRes.AutoTypeObfuscationHint, KPRes.DocumentationHint); } private bool GetSelBin(out string strDataItem, out ProtectedBinary pb) { strDataItem = null; pb = null; ListView.SelectedListViewItemCollection lvsic = m_lvBinaries.SelectedItems; if((lvsic == null) || (lvsic.Count != 1)) return false; // No assert strDataItem = lvsic[0].Text; pb = m_vBinaries.Get(strDataItem); if(pb == null) { Debug.Assert(false); return false; } return true; } private void OpenSelBin(BinaryDataOpenOptions optBase) { string strDataItem; ProtectedBinary pb; if(!GetSelBin(out strDataItem, out pb)) return; BinaryDataOpenOptions opt = ((optBase != null) ? optBase.CloneDeep() : new BinaryDataOpenOptions()); if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) { if(optBase == null) opt.Handler = BinaryDataHandler.InternalViewer; opt.ReadOnly = true; } ProtectedBinary pbMod = BinaryDataUtil.Open(strDataItem, pb, opt); if(pbMod != null) { m_vBinaries.Set(strDataItem, pbMod); UpdateEntryBinaries(false, true, strDataItem); // Update size } } private void OnBtnBinOpen(object sender, EventArgs e) { OpenSelBin(null); } private void OnDynBinOpen(object sender, DynamicMenuEventArgs e) { if(e == null) { Debug.Assert(false); return; } BinaryDataOpenOptions opt = (e.Tag as BinaryDataOpenOptions); if(opt == null) { Debug.Assert(false); return; } OpenSelBin(opt); } private void OnCtxBinOpenOpening(object sender, CancelEventArgs e) { string strDataItem; ProtectedBinary pb; if(!GetSelBin(out strDataItem, out pb)) { e.Cancel = true; return; } BinaryDataUtil.BuildOpenWithMenu(m_dynBinOpen, strDataItem, pb, (m_pwEditMode == PwEditMode.ViewReadOnlyEntry)); } private void OnBtnTools(object sender, EventArgs e) { m_ctxTools.Show(m_btnTools, 0, m_btnTools.Height); } private void OnCtxToolsHelp(object sender, EventArgs e) { if(m_tabMain.SelectedTab == m_tabAdvanced) AppHelp.ShowHelp(AppDefs.HelpTopics.Entry, AppDefs.HelpTopics.EntryStrings); else if(m_tabMain.SelectedTab == m_tabAutoType) AppHelp.ShowHelp(AppDefs.HelpTopics.Entry, AppDefs.HelpTopics.EntryAutoType); else if(m_tabMain.SelectedTab == m_tabHistory) AppHelp.ShowHelp(AppDefs.HelpTopics.Entry, AppDefs.HelpTopics.EntryHistory); else AppHelp.ShowHelp(AppDefs.HelpTopics.Entry, null); } private void OnCtxUrlHelp(object sender, EventArgs e) { AppHelp.ShowHelp(AppDefs.HelpTopics.UrlField, null); } private void SelectFileAsUrl(string strFilter) { string strFlt = string.Empty; if(strFilter != null) strFlt += strFilter; strFlt += KPRes.AllFiles + @" (*.*)|*.*"; OpenFileDialogEx dlg = UIUtil.CreateOpenFileDialog(null, strFlt, 1, null, false, AppDefs.FileDialogContext.Attachments); if(dlg.ShowDialog() == DialogResult.OK) m_tbUrl.Text = "cmd://\"" + dlg.FileName + "\""; } private void OnCtxUrlSelApp(object sender, EventArgs e) { SelectFileAsUrl(KPRes.Application + @" (*.exe, *.com, *.bat, *.cmd)|" + @"*.exe;*.com;*.bat;*.cmd|"); } private void OnCtxUrlSelDoc(object sender, EventArgs e) { SelectFileAsUrl(null); } private string CreateFieldReference() { FieldRefForm dlg = new FieldRefForm(); dlg.InitEx(m_pwDatabase.RootGroup, m_ilIcons); string strResult = string.Empty; if(dlg.ShowDialog() == DialogResult.OK) strResult = dlg.ResultReference; UIUtil.DestroyForm(dlg); return strResult; } private void OnFieldRefInTitle(object sender, EventArgs e) { m_tbTitle.Text += CreateFieldReference(); } private void OnFieldRefInUserName(object sender, EventArgs e) { m_tbUserName.Text += CreateFieldReference(); } private void OnFieldRefInPassword(object sender, EventArgs e) { string strRef = CreateFieldReference(); if(strRef.Length == 0) return; string strPw = m_icgPassword.GetPassword(); string strRep = m_icgPassword.GetRepeat(); m_icgPassword.SetPasswords(strPw + strRef, strRep + strRef); } private void OnFieldRefInUrl(object sender, EventArgs e) { m_tbUrl.Text += CreateFieldReference(); } private void OnFieldRefInNotes(object sender, EventArgs e) { string strRef = CreateFieldReference(); if(m_rtNotes.Text.Length == 0) m_rtNotes.Text = strRef; else m_rtNotes.Text += "\r\n" + strRef; } protected override bool ProcessDialogKey(Keys keyData) { if(((keyData == Keys.Return) || (keyData == Keys.Enter)) && m_rtNotes.Focused) return false; // Forward to RichTextBox return base.ProcessDialogKey(keyData); } private bool m_bClosing = false; // Mono bug workaround private void OnFormClosing(object sender, FormClosingEventArgs e) { if(m_bClosing) return; m_bClosing = true; HandleFormClosing(e); m_bClosing = false; } private void HandleFormClosing(FormClosingEventArgs e) { bool bCancel = false; if(!m_bForceClosing && (m_pwEditMode != PwEditMode.ViewReadOnlyEntry)) { PwEntry pe = m_pwInitialEntry.CloneDeep(); SaveEntry(pe, false); bool bModified = !pe.EqualsEntry(m_pwInitialEntry, m_cmpOpt, MemProtCmpMode.CustomOnly); bModified |= !m_icgPassword.ValidateData(false); if(bModified) { DialogResult dr = MessageService.Ask(KPRes.SaveBeforeCloseQuestion, PwDefs.ShortProductName, MessageBoxButtons.YesNoCancel); if((dr == DialogResult.Yes) || (dr == DialogResult.OK)) { bCancel = !SaveEntry(m_pwEntry, true); if(!bCancel) this.DialogResult = DialogResult.OK; } else if(dr == DialogResult.Cancel) bCancel = true; } } if(bCancel) { this.DialogResult = DialogResult.None; e.Cancel = true; return; } if(!m_bTouchedOnce) m_pwEntry.Touch(false, false); CleanUpEx(); } private void OnBinariesItemActivate(object sender, EventArgs e) { OnBtnBinOpen(sender, e); } private void OnHistoryItemActivate(object sender, EventArgs e) { OnBtnHistoryView(sender, e); } private void OnCtxBinImport(object sender, EventArgs e) { if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) return; OpenFileDialogEx ofd = UIUtil.CreateOpenFileDialog(KPRes.AttachFiles, UIUtil.CreateFileTypeFilter(null, null, true), 1, null, true, AppDefs.FileDialogContext.Attachments); if(ofd.ShowDialog() == DialogResult.OK) BinImportFiles(ofd.FileNames); } private void BinImportFiles(string[] vPaths) { if(vPaths == null) { Debug.Assert(false); return; } UpdateEntryBinaries(true, false); foreach(string strFile in vPaths) { if(string.IsNullOrEmpty(strFile)) { Debug.Assert(false); continue; } byte[] vBytes = null; string strMsg, strItem = UrlUtil.GetFileName(strFile); if(m_vBinaries.Get(strItem) != null) { strMsg = KPRes.AttachedExistsAlready + MessageService.NewLine + strItem + MessageService.NewParagraph + KPRes.AttachNewRename + MessageService.NewParagraph + KPRes.AttachNewRenameRemarks0 + MessageService.NewLine + KPRes.AttachNewRenameRemarks1 + MessageService.NewLine + KPRes.AttachNewRenameRemarks2; DialogResult dr = MessageService.Ask(strMsg, null, MessageBoxButtons.YesNoCancel); if(dr == DialogResult.Cancel) continue; else if(dr == DialogResult.Yes) { string strFileName = UrlUtil.StripExtension(strItem); string strExtension = "." + UrlUtil.GetExtension(strItem); int nTry = 0; while(true) { string strNewName = strFileName + nTry.ToString() + strExtension; if(m_vBinaries.Get(strNewName) == null) { strItem = strNewName; break; } ++nTry; } } } try { vBytes = File.ReadAllBytes(strFile); vBytes = DataEditorForm.ConvertAttachment(strItem, vBytes); if(vBytes != null) { ProtectedBinary pb = new ProtectedBinary(false, vBytes); m_vBinaries.Set(strItem, pb); } } catch(Exception exAttach) { MessageService.ShowWarning(KPRes.AttachFailed, strFile, exAttach); } } UpdateEntryBinaries(false, true); ResizeColumnHeaders(); } private void OnCtxBinNew(object sender, EventArgs e) { if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) return; string strName; for(int i = 0; ; ++i) { strName = KPRes.New; if(i >= 1) strName += " (" + i.ToString() + ")"; strName += ".rtf"; if(m_vBinaries.Get(strName) == null) break; } ProtectedBinary pb = new ProtectedBinary(); m_vBinaries.Set(strName, pb); UpdateEntryBinaries(false, true, strName); ResizeColumnHeaders(); ListViewItem lviNew = m_lvBinaries.FindItemWithText(strName, false, 0, false); if(lviNew != null) lviNew.BeginEdit(); } private void OnBinAfterLabelEdit(object sender, LabelEditEventArgs e) { string strNew = e.Label; e.CancelEdit = true; // In the case of success, we update it on our own if(string.IsNullOrEmpty(strNew)) return; if(m_pwEditMode == PwEditMode.ViewReadOnlyEntry) return; int iItem = e.Item; if((iItem < 0) || (iItem >= m_lvBinaries.Items.Count)) return; string strOld = m_lvBinaries.Items[iItem].Text; if(strNew == strOld) return; if(m_vBinaries.Get(strNew) != null) { MessageService.ShowWarning(KPRes.FieldNameExistsAlready); return; } ProtectedBinary pb = m_vBinaries.Get(strOld); if(pb == null) { Debug.Assert(false); return; } m_vBinaries.Remove(strOld); m_vBinaries.Set(strNew, pb); UpdateEntryBinaries(false, true, strNew); } private static void BinDragAccept(DragEventArgs e) { if(e == null) { Debug.Assert(false); return; } IDataObject ido = e.Data; if((ido == null) || !ido.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.None; else e.Effect = DragDropEffects.Copy; } private void OnBinDragEnter(object sender, DragEventArgs e) { BinDragAccept(e); } private void OnBinDragOver(object sender, DragEventArgs e) { BinDragAccept(e); } private void OnBinDragDrop(object sender, DragEventArgs e) { try { BinImportFiles(e.Data.GetData(DataFormats.FileDrop) as string[]); } catch(Exception) { Debug.Assert(false); } } private void InitOverridesBox() { List> l = new List>(); AddOverrideUrlItem(l, "cmd://{INTERNETEXPLORER} \"{URL}\"", AppLocator.InternetExplorerPath); AddOverrideUrlItem(l, "cmd://{FIREFOX} \"{URL}\"", AppLocator.FirefoxPath); AddOverrideUrlItem(l, "cmd://{OPERA} \"{URL}\"", AppLocator.OperaPath); AddOverrideUrlItem(l, "cmd://{GOOGLECHROME} \"{URL}\"", AppLocator.ChromePath); AddOverrideUrlItem(l, "cmd://{SAFARI} \"{URL}\"", AppLocator.SafariPath); Debug.Assert(m_cmbOverrideUrl.InvokeRequired); VoidDelegate f = delegate() { try { Debug.Assert(!m_cmbOverrideUrl.InvokeRequired); foreach(KeyValuePair kvp in l) { m_cmbOverrideUrl.Items.Add(kvp.Key); m_lOverrideUrlIcons.Add(kvp.Value); } m_cmbOverrideUrl.OrderedImageList = m_lOverrideUrlIcons; } catch(Exception) { Debug.Assert(false); } }; m_cmbOverrideUrl.Invoke(f); } private void AddOverrideUrlItem(List> l, string strOverride, string strIconPath) { if(string.IsNullOrEmpty(strOverride)) { Debug.Assert(false); return; } const int qSize = 16; Image img = null; string str = UrlUtil.GetQuotedAppPath(strIconPath ?? string.Empty); str = str.Trim(); if(str.Length > 0) img = UIUtil.GetFileIcon(str, qSize, qSize); if(img == null) img = UIUtil.CreateScaledImage(m_ilIcons.Images[ (int)PwIcon.Console], qSize, qSize); l.Add(new KeyValuePair(strOverride, img)); } } } keepass2-2.25/KeePass/Forms/DataViewerForm.Designer.cs0000664000175000017500000002070412267251736022517 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class DataViewerForm { /// /// 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_picBox = new System.Windows.Forms.PictureBox(); this.m_webBrowser = new System.Windows.Forms.WebBrowser(); this.m_pnlImageViewer = new System.Windows.Forms.Panel(); this.m_statusMain = new System.Windows.Forms.StatusStrip(); this.m_tssStatusMain = new System.Windows.Forms.ToolStripStatusLabel(); this.m_rtbText = new KeePass.UI.CustomRichTextBoxEx(); this.m_toolMain = new KeePass.UI.CustomToolStripEx(); this.m_tslViewer = new System.Windows.Forms.ToolStripLabel(); this.m_tscViewers = new System.Windows.Forms.ToolStripComboBox(); this.m_tssSeparator0 = new System.Windows.Forms.ToolStripSeparator(); this.m_tslEncoding = new System.Windows.Forms.ToolStripLabel(); this.m_tscEncoding = new System.Windows.Forms.ToolStripComboBox(); this.m_tslZoom = new System.Windows.Forms.ToolStripLabel(); this.m_tscZoom = new System.Windows.Forms.ToolStripComboBox(); ((System.ComponentModel.ISupportInitialize)(this.m_picBox)).BeginInit(); this.m_pnlImageViewer.SuspendLayout(); this.m_statusMain.SuspendLayout(); this.m_toolMain.SuspendLayout(); this.SuspendLayout(); // // m_picBox // this.m_picBox.Location = new System.Drawing.Point(31, 26); this.m_picBox.Name = "m_picBox"; this.m_picBox.Size = new System.Drawing.Size(174, 130); this.m_picBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; this.m_picBox.TabIndex = 1; this.m_picBox.TabStop = false; // // m_webBrowser // this.m_webBrowser.AllowWebBrowserDrop = false; this.m_webBrowser.Location = new System.Drawing.Point(23, 160); this.m_webBrowser.MinimumSize = new System.Drawing.Size(20, 20); this.m_webBrowser.Name = "m_webBrowser"; this.m_webBrowser.ScriptErrorsSuppressed = true; this.m_webBrowser.Size = new System.Drawing.Size(193, 158); this.m_webBrowser.TabIndex = 2; // // m_pnlImageViewer // this.m_pnlImageViewer.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.m_pnlImageViewer.Controls.Add(this.m_picBox); this.m_pnlImageViewer.Location = new System.Drawing.Point(234, 70); this.m_pnlImageViewer.Name = "m_pnlImageViewer"; this.m_pnlImageViewer.Size = new System.Drawing.Size(264, 212); this.m_pnlImageViewer.TabIndex = 1; // // m_statusMain // this.m_statusMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_tssStatusMain}); this.m_statusMain.Location = new System.Drawing.Point(0, 366); this.m_statusMain.Name = "m_statusMain"; this.m_statusMain.Size = new System.Drawing.Size(524, 22); this.m_statusMain.TabIndex = 4; // // m_tssStatusMain // this.m_tssStatusMain.Name = "m_tssStatusMain"; this.m_tssStatusMain.Size = new System.Drawing.Size(509, 17); this.m_tssStatusMain.Spring = true; this.m_tssStatusMain.Text = "<>"; this.m_tssStatusMain.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // m_rtbText // this.m_rtbText.Location = new System.Drawing.Point(23, 40); this.m_rtbText.Name = "m_rtbText"; this.m_rtbText.ReadOnly = true; this.m_rtbText.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedBoth; this.m_rtbText.Size = new System.Drawing.Size(190, 114); this.m_rtbText.TabIndex = 0; this.m_rtbText.Text = ""; this.m_rtbText.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.OnRichTextBoxLinkClicked); // // m_toolMain // this.m_toolMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_tslViewer, this.m_tscViewers, this.m_tssSeparator0, this.m_tslEncoding, this.m_tscEncoding, this.m_tslZoom, this.m_tscZoom}); this.m_toolMain.Location = new System.Drawing.Point(0, 0); this.m_toolMain.Name = "m_toolMain"; this.m_toolMain.Size = new System.Drawing.Size(524, 25); this.m_toolMain.TabIndex = 3; this.m_toolMain.TabStop = true; // // m_tslViewer // this.m_tslViewer.Name = "m_tslViewer"; this.m_tslViewer.Size = new System.Drawing.Size(21, 22); this.m_tslViewer.Text = "<>"; // // m_tscViewers // this.m_tscViewers.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.m_tscViewers.Name = "m_tscViewers"; this.m_tscViewers.Size = new System.Drawing.Size(140, 25); this.m_tscViewers.SelectedIndexChanged += new System.EventHandler(this.OnViewersSelectedIndexChanged); // // m_tssSeparator0 // this.m_tssSeparator0.Name = "m_tssSeparator0"; this.m_tssSeparator0.Size = new System.Drawing.Size(6, 25); // // m_tslEncoding // this.m_tslEncoding.Name = "m_tslEncoding"; this.m_tslEncoding.Size = new System.Drawing.Size(21, 22); this.m_tslEncoding.Text = "<>"; // // m_tscEncoding // this.m_tscEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.m_tscEncoding.Name = "m_tscEncoding"; this.m_tscEncoding.Size = new System.Drawing.Size(200, 25); this.m_tscEncoding.SelectedIndexChanged += new System.EventHandler(this.OnEncodingSelectedIndexChanged); // // m_tslZoom // this.m_tslZoom.Name = "m_tslZoom"; this.m_tslZoom.Size = new System.Drawing.Size(21, 22); this.m_tslZoom.Text = "<>"; // // m_tscZoom // this.m_tscZoom.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.m_tscZoom.Name = "m_tscZoom"; this.m_tscZoom.Size = new System.Drawing.Size(75, 25); this.m_tscZoom.SelectedIndexChanged += new System.EventHandler(this.OnZoomSelectedIndexChanged); // // DataViewerForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(524, 388); this.Controls.Add(this.m_webBrowser); this.Controls.Add(this.m_pnlImageViewer); this.Controls.Add(this.m_rtbText); this.Controls.Add(this.m_toolMain); this.Controls.Add(this.m_statusMain); this.MinimizeBox = false; this.Name = "DataViewerForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "<>"; this.Load += new System.EventHandler(this.OnFormLoad); this.SizeChanged += new System.EventHandler(this.OnFormSizeChanged); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing); ((System.ComponentModel.ISupportInitialize)(this.m_picBox)).EndInit(); this.m_pnlImageViewer.ResumeLayout(false); this.m_statusMain.ResumeLayout(false); this.m_statusMain.PerformLayout(); this.m_toolMain.ResumeLayout(false); this.m_toolMain.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private KeePass.UI.CustomRichTextBoxEx m_rtbText; private System.Windows.Forms.PictureBox m_picBox; private System.Windows.Forms.WebBrowser m_webBrowser; private KeePass.UI.CustomToolStripEx m_toolMain; private System.Windows.Forms.ToolStripLabel m_tslViewer; private System.Windows.Forms.ToolStripComboBox m_tscViewers; private System.Windows.Forms.ToolStripSeparator m_tssSeparator0; private System.Windows.Forms.ToolStripLabel m_tslEncoding; private System.Windows.Forms.ToolStripComboBox m_tscEncoding; private System.Windows.Forms.Panel m_pnlImageViewer; private System.Windows.Forms.StatusStrip m_statusMain; private System.Windows.Forms.ToolStripStatusLabel m_tssStatusMain; private System.Windows.Forms.ToolStripLabel m_tslZoom; private System.Windows.Forms.ToolStripComboBox m_tscZoom; } }keepass2-2.25/KeePass/Forms/TanWizardForm.Designer.cs0000664000175000017500000002004211246246244022354 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class TanWizardForm { /// /// 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() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TanWizardForm)); this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_bannerImage = new System.Windows.Forms.PictureBox(); this.m_lblIntro = new System.Windows.Forms.Label(); this.m_tbTANs = new System.Windows.Forms.TextBox(); this.m_cbNumberTans = new System.Windows.Forms.CheckBox(); this.m_lblSeparator = new System.Windows.Forms.Label(); this.m_numTANsIndex = new System.Windows.Forms.NumericUpDown(); this.m_lblTanChars = new System.Windows.Forms.Label(); this.m_tbTanChars = new System.Windows.Forms.TextBox(); this.m_lblToGroup = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.m_numTANsIndex)).BeginInit(); this.SuspendLayout(); // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(403, 423); this.m_btnOK.Name = "m_btnOK"; this.m_btnOK.Size = new System.Drawing.Size(75, 23); this.m_btnOK.TabIndex = 3; this.m_btnOK.Text = "&OK"; 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(484, 423); this.m_btnCancel.Name = "m_btnCancel"; this.m_btnCancel.Size = new System.Drawing.Size(75, 23); this.m_btnCancel.TabIndex = 4; this.m_btnCancel.Text = "&Cancel"; this.m_btnCancel.UseVisualStyleBackColor = true; this.m_btnCancel.Click += new System.EventHandler(this.OnBtnCancel); // // m_bannerImage // this.m_bannerImage.Dock = System.Windows.Forms.DockStyle.Top; this.m_bannerImage.Location = new System.Drawing.Point(0, 0); this.m_bannerImage.Name = "m_bannerImage"; this.m_bannerImage.Size = new System.Drawing.Size(571, 60); this.m_bannerImage.TabIndex = 2; this.m_bannerImage.TabStop = false; // // m_lblIntro // this.m_lblIntro.Location = new System.Drawing.Point(9, 91); this.m_lblIntro.Name = "m_lblIntro"; this.m_lblIntro.Size = new System.Drawing.Size(550, 29); this.m_lblIntro.TabIndex = 5; this.m_lblIntro.Text = resources.GetString("m_lblIntro.Text"); // // m_tbTANs // this.m_tbTANs.AcceptsReturn = true; this.m_tbTANs.Location = new System.Drawing.Point(12, 124); this.m_tbTANs.Multiline = true; this.m_tbTANs.Name = "m_tbTANs"; this.m_tbTANs.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.m_tbTANs.Size = new System.Drawing.Size(547, 208); this.m_tbTANs.TabIndex = 0; // // m_cbNumberTans // this.m_cbNumberTans.AutoSize = true; this.m_cbNumberTans.Location = new System.Drawing.Point(12, 344); this.m_cbNumberTans.Name = "m_cbNumberTans"; this.m_cbNumberTans.Size = new System.Drawing.Size(275, 17); this.m_cbNumberTans.TabIndex = 1; this.m_cbNumberTans.Text = "Number TANs consecutively, starting from this value:"; this.m_cbNumberTans.UseVisualStyleBackColor = true; this.m_cbNumberTans.CheckedChanged += new System.EventHandler(this.OnNumberTANsCheckedChanged); // // m_lblSeparator // this.m_lblSeparator.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.m_lblSeparator.Location = new System.Drawing.Point(0, 416); this.m_lblSeparator.Name = "m_lblSeparator"; this.m_lblSeparator.Size = new System.Drawing.Size(571, 2); this.m_lblSeparator.TabIndex = 6; // // m_numTANsIndex // this.m_numTANsIndex.Location = new System.Drawing.Point(293, 343); this.m_numTANsIndex.Maximum = new decimal(new int[] { 65535, 0, 0, 0}); this.m_numTANsIndex.Name = "m_numTANsIndex"; this.m_numTANsIndex.Size = new System.Drawing.Size(72, 20); this.m_numTANsIndex.TabIndex = 2; this.m_numTANsIndex.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // m_lblTanChars // this.m_lblTanChars.AutoSize = true; this.m_lblTanChars.Location = new System.Drawing.Point(9, 368); this.m_lblTanChars.Name = "m_lblTanChars"; this.m_lblTanChars.Size = new System.Drawing.Size(200, 13); this.m_lblTanChars.TabIndex = 7; this.m_lblTanChars.Text = "TANs consist of the following characters:"; // // m_tbTanChars // this.m_tbTanChars.Location = new System.Drawing.Point(12, 384); this.m_tbTanChars.Name = "m_tbTanChars"; this.m_tbTanChars.Size = new System.Drawing.Size(547, 20); this.m_tbTanChars.TabIndex = 8; // // m_lblToGroup // this.m_lblToGroup.Location = new System.Drawing.Point(9, 71); this.m_lblToGroup.Name = "m_lblToGroup"; this.m_lblToGroup.Size = new System.Drawing.Size(550, 15); this.m_lblToGroup.TabIndex = 9; this.m_lblToGroup.Text = "TANs are imported into the currently selected group"; // // TanWizardForm // 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(571, 458); this.Controls.Add(this.m_lblToGroup); this.Controls.Add(this.m_tbTanChars); this.Controls.Add(this.m_lblTanChars); this.Controls.Add(this.m_numTANsIndex); this.Controls.Add(this.m_lblSeparator); this.Controls.Add(this.m_cbNumberTans); this.Controls.Add(this.m_tbTANs); this.Controls.Add(this.m_lblIntro); this.Controls.Add(this.m_bannerImage); 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 = "TanWizardForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "<>"; this.Load += new System.EventHandler(this.OnFormLoad); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.m_numTANsIndex)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.Button m_btnOK; private System.Windows.Forms.Button m_btnCancel; private System.Windows.Forms.PictureBox m_bannerImage; private System.Windows.Forms.Label m_lblIntro; private System.Windows.Forms.TextBox m_tbTANs; private System.Windows.Forms.CheckBox m_cbNumberTans; private System.Windows.Forms.Label m_lblSeparator; private System.Windows.Forms.NumericUpDown m_numTANsIndex; private System.Windows.Forms.Label m_lblTanChars; private System.Windows.Forms.TextBox m_tbTanChars; private System.Windows.Forms.Label m_lblToGroup; } }keepass2-2.25/KeePass/Forms/OptionsForm.Designer.cs0000664000175000017500000010326012074503566022113 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class OptionsForm { /// /// 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_bannerImage = new System.Windows.Forms.PictureBox(); this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_tabMain = new System.Windows.Forms.TabControl(); this.m_tabSecurity = new System.Windows.Forms.TabPage(); this.m_numLockAfterGlobalTime = new System.Windows.Forms.NumericUpDown(); this.m_cbLockAfterGlobalTime = new System.Windows.Forms.CheckBox(); this.m_lvSecurityOptions = new KeePass.UI.CustomListViewEx(); this.m_numClipClearTime = new System.Windows.Forms.NumericUpDown(); this.m_cbClipClearTime = new System.Windows.Forms.CheckBox(); this.m_numDefaultExpireDays = new System.Windows.Forms.NumericUpDown(); this.m_cbDefaultExpireDays = new System.Windows.Forms.CheckBox(); this.m_cbLockAfterTime = new System.Windows.Forms.CheckBox(); this.m_numLockAfterTime = new System.Windows.Forms.NumericUpDown(); this.m_tabPolicy = new System.Windows.Forms.TabPage(); this.m_lvPolicy = new KeePass.UI.CustomListViewEx(); this.m_linkPolicyInfo = new System.Windows.Forms.LinkLabel(); this.m_lblPolicyMore = new System.Windows.Forms.Label(); this.m_lblPolicyRestart = new System.Windows.Forms.Label(); this.m_lblPolicyIntro = new System.Windows.Forms.Label(); this.m_tabGui = new System.Windows.Forms.TabPage(); this.m_btnSelPwFont = new System.Windows.Forms.Button(); this.m_numMruCount = new System.Windows.Forms.NumericUpDown(); this.m_lblMruCount = new System.Windows.Forms.Label(); this.m_btnSelFont = new System.Windows.Forms.Button(); this.m_lvGuiOptions = new KeePass.UI.CustomListViewEx(); this.m_lblBannerStyle = new System.Windows.Forms.Label(); this.m_cmbBannerStyle = new System.Windows.Forms.ComboBox(); this.m_tabIntegration = new System.Windows.Forms.TabPage(); this.m_btnSchemeOverrides = new System.Windows.Forms.Button(); this.m_tbUrlOverride = new System.Windows.Forms.TextBox(); this.m_cbUrlOverride = new System.Windows.Forms.CheckBox(); this.m_cbSingleClickTrayAction = new System.Windows.Forms.CheckBox(); this.m_cbAutoRun = new System.Windows.Forms.CheckBox(); this.m_grpFileExt = new System.Windows.Forms.GroupBox(); this.m_btnFileExtRemove = new System.Windows.Forms.Button(); this.m_btnFileExtCreate = new System.Windows.Forms.Button(); this.m_lblFileExtHint = new System.Windows.Forms.Label(); this.m_grpHotKeys = new System.Windows.Forms.GroupBox(); this.m_linkHotKeyHelp = new System.Windows.Forms.LinkLabel(); this.m_lblSelAutoTypeHotKey = new System.Windows.Forms.Label(); this.m_tbSelAutoTypeHotKey = new System.Windows.Forms.TextBox(); this.m_tbShowWindowHotKey = new System.Windows.Forms.TextBox(); this.m_lblGlobalAutoTypeHotKey = new System.Windows.Forms.Label(); this.m_lblRestoreHotKey = new System.Windows.Forms.Label(); this.m_tbGlobalAutoType = new System.Windows.Forms.TextBox(); this.m_tabAdvanced = new System.Windows.Forms.TabPage(); this.m_btnProxy = new System.Windows.Forms.Button(); this.m_lvAdvanced = new KeePass.UI.CustomListViewEx(); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).BeginInit(); this.m_tabMain.SuspendLayout(); this.m_tabSecurity.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.m_numLockAfterGlobalTime)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.m_numClipClearTime)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.m_numDefaultExpireDays)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.m_numLockAfterTime)).BeginInit(); this.m_tabPolicy.SuspendLayout(); this.m_tabGui.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.m_numMruCount)).BeginInit(); this.m_tabIntegration.SuspendLayout(); this.m_grpFileExt.SuspendLayout(); this.m_grpHotKeys.SuspendLayout(); this.m_tabAdvanced.SuspendLayout(); this.SuspendLayout(); // // m_bannerImage // this.m_bannerImage.Dock = System.Windows.Forms.DockStyle.Top; this.m_bannerImage.Location = new System.Drawing.Point(0, 0); this.m_bannerImage.Name = "m_bannerImage"; this.m_bannerImage.Size = new System.Drawing.Size(586, 60); this.m_bannerImage.TabIndex = 0; this.m_bannerImage.TabStop = false; // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(418, 409); 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 = "&OK"; 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(499, 409); 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_tabMain // this.m_tabMain.Controls.Add(this.m_tabSecurity); this.m_tabMain.Controls.Add(this.m_tabPolicy); this.m_tabMain.Controls.Add(this.m_tabGui); this.m_tabMain.Controls.Add(this.m_tabIntegration); this.m_tabMain.Controls.Add(this.m_tabAdvanced); this.m_tabMain.Location = new System.Drawing.Point(12, 66); this.m_tabMain.Multiline = true; this.m_tabMain.Name = "m_tabMain"; this.m_tabMain.SelectedIndex = 0; this.m_tabMain.Size = new System.Drawing.Size(562, 337); this.m_tabMain.TabIndex = 2; // // m_tabSecurity // this.m_tabSecurity.Controls.Add(this.m_numLockAfterGlobalTime); this.m_tabSecurity.Controls.Add(this.m_cbLockAfterGlobalTime); this.m_tabSecurity.Controls.Add(this.m_lvSecurityOptions); this.m_tabSecurity.Controls.Add(this.m_numClipClearTime); this.m_tabSecurity.Controls.Add(this.m_cbClipClearTime); this.m_tabSecurity.Controls.Add(this.m_numDefaultExpireDays); this.m_tabSecurity.Controls.Add(this.m_cbDefaultExpireDays); this.m_tabSecurity.Controls.Add(this.m_cbLockAfterTime); this.m_tabSecurity.Controls.Add(this.m_numLockAfterTime); this.m_tabSecurity.Location = new System.Drawing.Point(4, 22); this.m_tabSecurity.Name = "m_tabSecurity"; this.m_tabSecurity.Padding = new System.Windows.Forms.Padding(3); this.m_tabSecurity.Size = new System.Drawing.Size(554, 311); this.m_tabSecurity.TabIndex = 0; this.m_tabSecurity.Text = "Security"; this.m_tabSecurity.UseVisualStyleBackColor = true; // // m_numLockAfterGlobalTime // this.m_numLockAfterGlobalTime.Location = new System.Drawing.Point(327, 37); this.m_numLockAfterGlobalTime.Maximum = new decimal(new int[] { 1209600, 0, 0, 0}); this.m_numLockAfterGlobalTime.Name = "m_numLockAfterGlobalTime"; this.m_numLockAfterGlobalTime.Size = new System.Drawing.Size(66, 20); this.m_numLockAfterGlobalTime.TabIndex = 3; // // m_cbLockAfterGlobalTime // this.m_cbLockAfterGlobalTime.AutoSize = true; this.m_cbLockAfterGlobalTime.Location = new System.Drawing.Point(6, 38); this.m_cbLockAfterGlobalTime.Name = "m_cbLockAfterGlobalTime"; this.m_cbLockAfterGlobalTime.Size = new System.Drawing.Size(279, 17); this.m_cbLockAfterGlobalTime.TabIndex = 2; this.m_cbLockAfterGlobalTime.Text = "Lock workspace after global user inactivity (seconds):"; this.m_cbLockAfterGlobalTime.UseVisualStyleBackColor = true; this.m_cbLockAfterGlobalTime.CheckedChanged += new System.EventHandler(this.OnLockAfterGlobalTimeCheckedChanged); // // m_lvSecurityOptions // this.m_lvSecurityOptions.CheckBoxes = true; this.m_lvSecurityOptions.FullRowSelect = true; this.m_lvSecurityOptions.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; this.m_lvSecurityOptions.Location = new System.Drawing.Point(6, 115); this.m_lvSecurityOptions.Name = "m_lvSecurityOptions"; this.m_lvSecurityOptions.ShowItemToolTips = true; this.m_lvSecurityOptions.Size = new System.Drawing.Size(540, 188); this.m_lvSecurityOptions.TabIndex = 8; this.m_lvSecurityOptions.UseCompatibleStateImageBehavior = false; this.m_lvSecurityOptions.View = System.Windows.Forms.View.Details; // // m_numClipClearTime // this.m_numClipClearTime.Location = new System.Drawing.Point(327, 63); this.m_numClipClearTime.Maximum = new decimal(new int[] { 1209600, 0, 0, 0}); this.m_numClipClearTime.Name = "m_numClipClearTime"; this.m_numClipClearTime.Size = new System.Drawing.Size(66, 20); this.m_numClipClearTime.TabIndex = 5; // // m_cbClipClearTime // this.m_cbClipClearTime.AutoSize = true; this.m_cbClipClearTime.Location = new System.Drawing.Point(6, 64); this.m_cbClipClearTime.Name = "m_cbClipClearTime"; this.m_cbClipClearTime.Size = new System.Drawing.Size(194, 17); this.m_cbClipClearTime.TabIndex = 4; this.m_cbClipClearTime.Text = "Clipboard auto-clear time (seconds):"; this.m_cbClipClearTime.UseVisualStyleBackColor = true; this.m_cbClipClearTime.CheckedChanged += new System.EventHandler(this.OnClipboardClearTimeCheckedChanged); // // m_numDefaultExpireDays // this.m_numDefaultExpireDays.Location = new System.Drawing.Point(327, 89); this.m_numDefaultExpireDays.Maximum = new decimal(new int[] { 2920, 0, 0, 0}); this.m_numDefaultExpireDays.Name = "m_numDefaultExpireDays"; this.m_numDefaultExpireDays.Size = new System.Drawing.Size(66, 20); this.m_numDefaultExpireDays.TabIndex = 7; // // m_cbDefaultExpireDays // this.m_cbDefaultExpireDays.AutoSize = true; this.m_cbDefaultExpireDays.Location = new System.Drawing.Point(6, 90); this.m_cbDefaultExpireDays.Name = "m_cbDefaultExpireDays"; this.m_cbDefaultExpireDays.Size = new System.Drawing.Size(315, 17); this.m_cbDefaultExpireDays.TabIndex = 6; this.m_cbDefaultExpireDays.Text = "By default, new entries expire in the following number of days:"; this.m_cbDefaultExpireDays.UseVisualStyleBackColor = true; this.m_cbDefaultExpireDays.CheckedChanged += new System.EventHandler(this.OnDefaultExpireDaysCheckedChanged); // // m_cbLockAfterTime // this.m_cbLockAfterTime.AutoSize = true; this.m_cbLockAfterTime.Location = new System.Drawing.Point(6, 12); this.m_cbLockAfterTime.Name = "m_cbLockAfterTime"; this.m_cbLockAfterTime.Size = new System.Drawing.Size(270, 17); this.m_cbLockAfterTime.TabIndex = 0; this.m_cbLockAfterTime.Text = "Lock workspace after KeePass inactivity (seconds):"; this.m_cbLockAfterTime.UseVisualStyleBackColor = true; this.m_cbLockAfterTime.CheckedChanged += new System.EventHandler(this.OnLockAfterTimeCheckedChanged); // // m_numLockAfterTime // this.m_numLockAfterTime.Location = new System.Drawing.Point(327, 11); this.m_numLockAfterTime.Maximum = new decimal(new int[] { 1209600, 0, 0, 0}); this.m_numLockAfterTime.Name = "m_numLockAfterTime"; this.m_numLockAfterTime.Size = new System.Drawing.Size(66, 20); this.m_numLockAfterTime.TabIndex = 1; // // m_tabPolicy // this.m_tabPolicy.Controls.Add(this.m_lvPolicy); this.m_tabPolicy.Controls.Add(this.m_linkPolicyInfo); this.m_tabPolicy.Controls.Add(this.m_lblPolicyMore); this.m_tabPolicy.Controls.Add(this.m_lblPolicyRestart); this.m_tabPolicy.Controls.Add(this.m_lblPolicyIntro); this.m_tabPolicy.Location = new System.Drawing.Point(4, 22); this.m_tabPolicy.Name = "m_tabPolicy"; this.m_tabPolicy.Size = new System.Drawing.Size(554, 311); this.m_tabPolicy.TabIndex = 3; this.m_tabPolicy.Text = "Policy"; this.m_tabPolicy.UseVisualStyleBackColor = true; // // m_lvPolicy // this.m_lvPolicy.CheckBoxes = true; this.m_lvPolicy.FullRowSelect = true; this.m_lvPolicy.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; this.m_lvPolicy.Location = new System.Drawing.Point(6, 46); this.m_lvPolicy.Name = "m_lvPolicy"; this.m_lvPolicy.ShowItemToolTips = true; this.m_lvPolicy.Size = new System.Drawing.Size(540, 240); this.m_lvPolicy.TabIndex = 3; this.m_lvPolicy.UseCompatibleStateImageBehavior = false; this.m_lvPolicy.View = System.Windows.Forms.View.Details; // // m_linkPolicyInfo // this.m_linkPolicyInfo.AutoSize = true; this.m_linkPolicyInfo.Location = new System.Drawing.Point(134, 26); this.m_linkPolicyInfo.Name = "m_linkPolicyInfo"; this.m_linkPolicyInfo.Size = new System.Drawing.Size(115, 13); this.m_linkPolicyInfo.TabIndex = 2; this.m_linkPolicyInfo.TabStop = true; this.m_linkPolicyInfo.Text = "Application Policy Help"; this.m_linkPolicyInfo.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.OnPolicyInfoLinkClicked); // // m_lblPolicyMore // this.m_lblPolicyMore.AutoSize = true; this.m_lblPolicyMore.Location = new System.Drawing.Point(3, 26); this.m_lblPolicyMore.Name = "m_lblPolicyMore"; this.m_lblPolicyMore.Size = new System.Drawing.Size(125, 13); this.m_lblPolicyMore.TabIndex = 1; this.m_lblPolicyMore.Text = "For more information see:"; // // m_lblPolicyRestart // this.m_lblPolicyRestart.AutoSize = true; this.m_lblPolicyRestart.Location = new System.Drawing.Point(3, 289); this.m_lblPolicyRestart.Name = "m_lblPolicyRestart"; this.m_lblPolicyRestart.Size = new System.Drawing.Size(238, 13); this.m_lblPolicyRestart.TabIndex = 4; this.m_lblPolicyRestart.Text = "*Changing the policy requires restarting KeePass."; // // m_lblPolicyIntro // this.m_lblPolicyIntro.Location = new System.Drawing.Point(3, 9); this.m_lblPolicyIntro.Name = "m_lblPolicyIntro"; this.m_lblPolicyIntro.Size = new System.Drawing.Size(548, 14); this.m_lblPolicyIntro.TabIndex = 0; this.m_lblPolicyIntro.Text = "The application policy defines which security-critical operations are allowed and" + " which aren\'t."; // // m_tabGui // this.m_tabGui.Controls.Add(this.m_btnSelPwFont); this.m_tabGui.Controls.Add(this.m_numMruCount); this.m_tabGui.Controls.Add(this.m_lblMruCount); this.m_tabGui.Controls.Add(this.m_btnSelFont); this.m_tabGui.Controls.Add(this.m_lvGuiOptions); this.m_tabGui.Controls.Add(this.m_lblBannerStyle); this.m_tabGui.Controls.Add(this.m_cmbBannerStyle); this.m_tabGui.Location = new System.Drawing.Point(4, 22); this.m_tabGui.Name = "m_tabGui"; this.m_tabGui.Size = new System.Drawing.Size(554, 311); this.m_tabGui.TabIndex = 2; this.m_tabGui.Text = "Interface"; this.m_tabGui.UseVisualStyleBackColor = true; // // m_btnSelPwFont // this.m_btnSelPwFont.Location = new System.Drawing.Point(414, 279); this.m_btnSelPwFont.Name = "m_btnSelPwFont"; this.m_btnSelPwFont.Size = new System.Drawing.Size(133, 23); this.m_btnSelPwFont.TabIndex = 6; this.m_btnSelPwFont.Text = "Select Password Font"; this.m_btnSelPwFont.UseVisualStyleBackColor = true; this.m_btnSelPwFont.Click += new System.EventHandler(this.OnBtnSelPwFont); // // m_numMruCount // this.m_numMruCount.Location = new System.Drawing.Point(157, 280); this.m_numMruCount.Maximum = new decimal(new int[] { 120, 0, 0, 0}); this.m_numMruCount.Name = "m_numMruCount"; this.m_numMruCount.Size = new System.Drawing.Size(53, 20); this.m_numMruCount.TabIndex = 5; this.m_numMruCount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // m_lblMruCount // this.m_lblMruCount.AutoSize = true; this.m_lblMruCount.Location = new System.Drawing.Point(3, 282); this.m_lblMruCount.Name = "m_lblMruCount"; this.m_lblMruCount.Size = new System.Drawing.Size(148, 13); this.m_lblMruCount.TabIndex = 4; this.m_lblMruCount.Text = "Remember recently used files:"; // // m_btnSelFont // this.m_btnSelFont.Location = new System.Drawing.Point(414, 252); this.m_btnSelFont.Name = "m_btnSelFont"; this.m_btnSelFont.Size = new System.Drawing.Size(133, 23); this.m_btnSelFont.TabIndex = 3; this.m_btnSelFont.Text = "Select List Font"; this.m_btnSelFont.UseVisualStyleBackColor = true; this.m_btnSelFont.Click += new System.EventHandler(this.OnBtnSelListFont); // // m_lvGuiOptions // this.m_lvGuiOptions.CheckBoxes = true; this.m_lvGuiOptions.FullRowSelect = true; this.m_lvGuiOptions.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; this.m_lvGuiOptions.Location = new System.Drawing.Point(6, 12); this.m_lvGuiOptions.Name = "m_lvGuiOptions"; this.m_lvGuiOptions.ShowItemToolTips = true; this.m_lvGuiOptions.Size = new System.Drawing.Size(540, 230); this.m_lvGuiOptions.TabIndex = 0; this.m_lvGuiOptions.UseCompatibleStateImageBehavior = false; this.m_lvGuiOptions.View = System.Windows.Forms.View.Details; // // m_lblBannerStyle // this.m_lblBannerStyle.AutoSize = true; this.m_lblBannerStyle.Location = new System.Drawing.Point(3, 256); this.m_lblBannerStyle.Name = "m_lblBannerStyle"; this.m_lblBannerStyle.Size = new System.Drawing.Size(100, 13); this.m_lblBannerStyle.TabIndex = 1; this.m_lblBannerStyle.Text = "Dialog banner style:"; // // m_cmbBannerStyle // this.m_cmbBannerStyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.m_cmbBannerStyle.FormattingEnabled = true; this.m_cmbBannerStyle.Location = new System.Drawing.Point(157, 253); this.m_cmbBannerStyle.Name = "m_cmbBannerStyle"; this.m_cmbBannerStyle.Size = new System.Drawing.Size(193, 21); this.m_cmbBannerStyle.TabIndex = 2; this.m_cmbBannerStyle.SelectedValueChanged += new System.EventHandler(this.OnBannerStyleSelectedChanged); // // m_tabIntegration // this.m_tabIntegration.Controls.Add(this.m_btnSchemeOverrides); this.m_tabIntegration.Controls.Add(this.m_tbUrlOverride); this.m_tabIntegration.Controls.Add(this.m_cbUrlOverride); this.m_tabIntegration.Controls.Add(this.m_cbSingleClickTrayAction); this.m_tabIntegration.Controls.Add(this.m_cbAutoRun); this.m_tabIntegration.Controls.Add(this.m_grpFileExt); this.m_tabIntegration.Controls.Add(this.m_grpHotKeys); this.m_tabIntegration.Location = new System.Drawing.Point(4, 22); this.m_tabIntegration.Name = "m_tabIntegration"; this.m_tabIntegration.Size = new System.Drawing.Size(554, 311); this.m_tabIntegration.TabIndex = 4; this.m_tabIntegration.Text = "Integration"; this.m_tabIntegration.UseVisualStyleBackColor = true; // // m_btnSchemeOverrides // this.m_btnSchemeOverrides.Location = new System.Drawing.Point(402, 265); this.m_btnSchemeOverrides.Name = "m_btnSchemeOverrides"; this.m_btnSchemeOverrides.Size = new System.Drawing.Size(145, 23); this.m_btnSchemeOverrides.TabIndex = 6; this.m_btnSchemeOverrides.Text = "URL Scheme Overrides..."; this.m_btnSchemeOverrides.UseVisualStyleBackColor = true; this.m_btnSchemeOverrides.Click += new System.EventHandler(this.OnBtnUrlSchemeOverrides); // // m_tbUrlOverride // this.m_tbUrlOverride.Location = new System.Drawing.Point(124, 239); this.m_tbUrlOverride.Name = "m_tbUrlOverride"; this.m_tbUrlOverride.Size = new System.Drawing.Size(422, 20); this.m_tbUrlOverride.TabIndex = 5; // // m_cbUrlOverride // this.m_cbUrlOverride.AutoSize = true; this.m_cbUrlOverride.Location = new System.Drawing.Point(6, 241); this.m_cbUrlOverride.Name = "m_cbUrlOverride"; this.m_cbUrlOverride.Size = new System.Drawing.Size(112, 17); this.m_cbUrlOverride.TabIndex = 4; this.m_cbUrlOverride.Text = "Override all URLs:"; this.m_cbUrlOverride.UseVisualStyleBackColor = true; this.m_cbUrlOverride.CheckedChanged += new System.EventHandler(this.OnOverrideURLsCheckedChanged); // // m_cbSingleClickTrayAction // this.m_cbSingleClickTrayAction.AutoSize = true; this.m_cbSingleClickTrayAction.Location = new System.Drawing.Point(6, 218); this.m_cbSingleClickTrayAction.Name = "m_cbSingleClickTrayAction"; this.m_cbSingleClickTrayAction.Size = new System.Drawing.Size(314, 17); this.m_cbSingleClickTrayAction.TabIndex = 3; this.m_cbSingleClickTrayAction.Text = "Single click instead of double click for default tray icon action"; this.m_cbSingleClickTrayAction.UseVisualStyleBackColor = true; // // m_cbAutoRun // this.m_cbAutoRun.AutoSize = true; this.m_cbAutoRun.Location = new System.Drawing.Point(6, 195); this.m_cbAutoRun.Name = "m_cbAutoRun"; this.m_cbAutoRun.Size = new System.Drawing.Size(250, 17); this.m_cbAutoRun.TabIndex = 2; this.m_cbAutoRun.Text = "Run KeePass at Windows startup (current user)"; this.m_cbAutoRun.UseVisualStyleBackColor = true; this.m_cbAutoRun.CheckedChanged += new System.EventHandler(this.OnCheckedChangedAutoRun); // // m_grpFileExt // this.m_grpFileExt.Controls.Add(this.m_btnFileExtRemove); this.m_grpFileExt.Controls.Add(this.m_btnFileExtCreate); this.m_grpFileExt.Controls.Add(this.m_lblFileExtHint); this.m_grpFileExt.Location = new System.Drawing.Point(6, 97); this.m_grpFileExt.Name = "m_grpFileExt"; this.m_grpFileExt.Size = new System.Drawing.Size(540, 85); this.m_grpFileExt.TabIndex = 1; this.m_grpFileExt.TabStop = false; this.m_grpFileExt.Text = "KDBX file association"; // // m_btnFileExtRemove // this.m_btnFileExtRemove.FlatStyle = System.Windows.Forms.FlatStyle.System; this.m_btnFileExtRemove.Location = new System.Drawing.Point(146, 52); this.m_btnFileExtRemove.Name = "m_btnFileExtRemove"; this.m_btnFileExtRemove.Size = new System.Drawing.Size(135, 23); this.m_btnFileExtRemove.TabIndex = 2; this.m_btnFileExtRemove.Text = "&Remove Association"; this.m_btnFileExtRemove.UseVisualStyleBackColor = true; this.m_btnFileExtRemove.Click += new System.EventHandler(this.OnBtnFileExtRemove); // // m_btnFileExtCreate // this.m_btnFileExtCreate.FlatStyle = System.Windows.Forms.FlatStyle.System; this.m_btnFileExtCreate.Location = new System.Drawing.Point(9, 52); this.m_btnFileExtCreate.Name = "m_btnFileExtCreate"; this.m_btnFileExtCreate.Size = new System.Drawing.Size(131, 23); this.m_btnFileExtCreate.TabIndex = 1; this.m_btnFileExtCreate.Text = "Create &Association"; this.m_btnFileExtCreate.UseVisualStyleBackColor = true; this.m_btnFileExtCreate.Click += new System.EventHandler(this.OnBtnFileExtCreate); // // m_lblFileExtHint // this.m_lblFileExtHint.Location = new System.Drawing.Point(6, 21); this.m_lblFileExtHint.Name = "m_lblFileExtHint"; this.m_lblFileExtHint.Size = new System.Drawing.Size(525, 28); this.m_lblFileExtHint.TabIndex = 0; this.m_lblFileExtHint.Text = "KDBX files can be associated with KeePass. When you double-click a KDBX file in W" + "indows Explorer, they will automatically be opened by KeePass."; // // m_grpHotKeys // this.m_grpHotKeys.Controls.Add(this.m_linkHotKeyHelp); this.m_grpHotKeys.Controls.Add(this.m_lblSelAutoTypeHotKey); this.m_grpHotKeys.Controls.Add(this.m_tbSelAutoTypeHotKey); this.m_grpHotKeys.Controls.Add(this.m_tbShowWindowHotKey); this.m_grpHotKeys.Controls.Add(this.m_lblGlobalAutoTypeHotKey); this.m_grpHotKeys.Controls.Add(this.m_lblRestoreHotKey); this.m_grpHotKeys.Controls.Add(this.m_tbGlobalAutoType); this.m_grpHotKeys.Location = new System.Drawing.Point(6, 12); this.m_grpHotKeys.Name = "m_grpHotKeys"; this.m_grpHotKeys.Size = new System.Drawing.Size(540, 77); this.m_grpHotKeys.TabIndex = 0; this.m_grpHotKeys.TabStop = false; this.m_grpHotKeys.Text = "System-wide hot keys"; // // m_linkHotKeyHelp // this.m_linkHotKeyHelp.AutoSize = true; this.m_linkHotKeyHelp.Location = new System.Drawing.Point(278, 47); this.m_linkHotKeyHelp.Name = "m_linkHotKeyHelp"; this.m_linkHotKeyHelp.Size = new System.Drawing.Size(177, 13); this.m_linkHotKeyHelp.TabIndex = 6; this.m_linkHotKeyHelp.TabStop = true; this.m_linkHotKeyHelp.Text = "Help: Creating system-wide hot keys"; this.m_linkHotKeyHelp.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.OnHotKeyHelpLinkClicked); // // m_lblSelAutoTypeHotKey // this.m_lblSelAutoTypeHotKey.AutoSize = true; this.m_lblSelAutoTypeHotKey.Location = new System.Drawing.Point(278, 21); this.m_lblSelAutoTypeHotKey.Name = "m_lblSelAutoTypeHotKey"; this.m_lblSelAutoTypeHotKey.Size = new System.Drawing.Size(124, 13); this.m_lblSelAutoTypeHotKey.TabIndex = 2; this.m_lblSelAutoTypeHotKey.Text = "Auto-type selected entry:"; // // m_tbSelAutoTypeHotKey // this.m_tbSelAutoTypeHotKey.Location = new System.Drawing.Point(408, 18); this.m_tbSelAutoTypeHotKey.Name = "m_tbSelAutoTypeHotKey"; this.m_tbSelAutoTypeHotKey.Size = new System.Drawing.Size(123, 20); this.m_tbSelAutoTypeHotKey.TabIndex = 3; // // m_tbShowWindowHotKey // this.m_tbShowWindowHotKey.Location = new System.Drawing.Point(133, 44); this.m_tbShowWindowHotKey.Name = "m_tbShowWindowHotKey"; this.m_tbShowWindowHotKey.Size = new System.Drawing.Size(123, 20); this.m_tbShowWindowHotKey.TabIndex = 5; // // m_lblGlobalAutoTypeHotKey // this.m_lblGlobalAutoTypeHotKey.AutoSize = true; this.m_lblGlobalAutoTypeHotKey.Location = new System.Drawing.Point(6, 21); this.m_lblGlobalAutoTypeHotKey.Name = "m_lblGlobalAutoTypeHotKey"; this.m_lblGlobalAutoTypeHotKey.Size = new System.Drawing.Size(87, 13); this.m_lblGlobalAutoTypeHotKey.TabIndex = 0; this.m_lblGlobalAutoTypeHotKey.Text = "Global auto-type:"; // // m_lblRestoreHotKey // this.m_lblRestoreHotKey.AutoSize = true; this.m_lblRestoreHotKey.Location = new System.Drawing.Point(6, 47); this.m_lblRestoreHotKey.Name = "m_lblRestoreHotKey"; this.m_lblRestoreHotKey.Size = new System.Drawing.Size(121, 13); this.m_lblRestoreHotKey.TabIndex = 4; this.m_lblRestoreHotKey.Text = "Show KeePass window:"; // // m_tbGlobalAutoType // this.m_tbGlobalAutoType.Location = new System.Drawing.Point(133, 18); this.m_tbGlobalAutoType.Name = "m_tbGlobalAutoType"; this.m_tbGlobalAutoType.Size = new System.Drawing.Size(123, 20); this.m_tbGlobalAutoType.TabIndex = 1; // // m_tabAdvanced // this.m_tabAdvanced.Controls.Add(this.m_btnProxy); this.m_tabAdvanced.Controls.Add(this.m_lvAdvanced); this.m_tabAdvanced.Location = new System.Drawing.Point(4, 22); this.m_tabAdvanced.Name = "m_tabAdvanced"; this.m_tabAdvanced.Padding = new System.Windows.Forms.Padding(3); this.m_tabAdvanced.Size = new System.Drawing.Size(554, 311); this.m_tabAdvanced.TabIndex = 1; this.m_tabAdvanced.Text = "Advanced"; this.m_tabAdvanced.UseVisualStyleBackColor = true; // // m_btnProxy // this.m_btnProxy.Location = new System.Drawing.Point(472, 279); this.m_btnProxy.Name = "m_btnProxy"; this.m_btnProxy.Size = new System.Drawing.Size(75, 23); this.m_btnProxy.TabIndex = 1; this.m_btnProxy.Text = "Proxy..."; this.m_btnProxy.UseVisualStyleBackColor = true; this.m_btnProxy.Click += new System.EventHandler(this.OnBtnProxy); // // m_lvAdvanced // this.m_lvAdvanced.CheckBoxes = true; this.m_lvAdvanced.FullRowSelect = true; this.m_lvAdvanced.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; this.m_lvAdvanced.Location = new System.Drawing.Point(6, 12); this.m_lvAdvanced.Name = "m_lvAdvanced"; this.m_lvAdvanced.ShowItemToolTips = true; this.m_lvAdvanced.Size = new System.Drawing.Size(540, 261); this.m_lvAdvanced.TabIndex = 0; this.m_lvAdvanced.UseCompatibleStateImageBehavior = false; this.m_lvAdvanced.View = System.Windows.Forms.View.Details; // // OptionsForm // 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(586, 444); this.Controls.Add(this.m_tabMain); this.Controls.Add(this.m_btnCancel); this.Controls.Add(this.m_btnOK); this.Controls.Add(this.m_bannerImage); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "OptionsForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Options"; this.Load += new System.EventHandler(this.OnFormLoad); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).EndInit(); this.m_tabMain.ResumeLayout(false); this.m_tabSecurity.ResumeLayout(false); this.m_tabSecurity.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.m_numLockAfterGlobalTime)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.m_numClipClearTime)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.m_numDefaultExpireDays)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.m_numLockAfterTime)).EndInit(); this.m_tabPolicy.ResumeLayout(false); this.m_tabPolicy.PerformLayout(); this.m_tabGui.ResumeLayout(false); this.m_tabGui.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.m_numMruCount)).EndInit(); this.m_tabIntegration.ResumeLayout(false); this.m_tabIntegration.PerformLayout(); this.m_grpFileExt.ResumeLayout(false); this.m_grpHotKeys.ResumeLayout(false); this.m_grpHotKeys.PerformLayout(); this.m_tabAdvanced.ResumeLayout(false); this.ResumeLayout(false); } #endregion private System.Windows.Forms.PictureBox m_bannerImage; private System.Windows.Forms.Button m_btnOK; private System.Windows.Forms.Button m_btnCancel; private System.Windows.Forms.TabControl m_tabMain; private System.Windows.Forms.TabPage m_tabSecurity; private System.Windows.Forms.TabPage m_tabAdvanced; private System.Windows.Forms.TabPage m_tabGui; private System.Windows.Forms.ComboBox m_cmbBannerStyle; private System.Windows.Forms.Label m_lblBannerStyle; private System.Windows.Forms.CheckBox m_cbLockAfterTime; private System.Windows.Forms.NumericUpDown m_numLockAfterTime; private System.Windows.Forms.TabPage m_tabPolicy; private System.Windows.Forms.LinkLabel m_linkPolicyInfo; private System.Windows.Forms.Label m_lblPolicyMore; private System.Windows.Forms.Label m_lblPolicyRestart; private System.Windows.Forms.Label m_lblPolicyIntro; private KeePass.UI.CustomListViewEx m_lvPolicy; private KeePass.UI.CustomListViewEx m_lvGuiOptions; private System.Windows.Forms.Button m_btnSelFont; private System.Windows.Forms.TabPage m_tabIntegration; private System.Windows.Forms.TextBox m_tbGlobalAutoType; private System.Windows.Forms.Label m_lblGlobalAutoTypeHotKey; private System.Windows.Forms.GroupBox m_grpHotKeys; private System.Windows.Forms.TextBox m_tbShowWindowHotKey; private System.Windows.Forms.Label m_lblRestoreHotKey; private System.Windows.Forms.CheckBox m_cbDefaultExpireDays; private System.Windows.Forms.NumericUpDown m_numDefaultExpireDays; private System.Windows.Forms.NumericUpDown m_numClipClearTime; private System.Windows.Forms.CheckBox m_cbClipClearTime; private System.Windows.Forms.Button m_btnFileExtRemove; private System.Windows.Forms.GroupBox m_grpFileExt; private System.Windows.Forms.Button m_btnFileExtCreate; private System.Windows.Forms.Label m_lblFileExtHint; private System.Windows.Forms.CheckBox m_cbAutoRun; private System.Windows.Forms.CheckBox m_cbSingleClickTrayAction; private KeePass.UI.CustomListViewEx m_lvAdvanced; private System.Windows.Forms.TextBox m_tbUrlOverride; private System.Windows.Forms.CheckBox m_cbUrlOverride; private KeePass.UI.CustomListViewEx m_lvSecurityOptions; private System.Windows.Forms.NumericUpDown m_numMruCount; private System.Windows.Forms.Label m_lblMruCount; private System.Windows.Forms.Button m_btnSchemeOverrides; private System.Windows.Forms.Label m_lblSelAutoTypeHotKey; private System.Windows.Forms.TextBox m_tbSelAutoTypeHotKey; private System.Windows.Forms.Button m_btnSelPwFont; private System.Windows.Forms.LinkLabel m_linkHotKeyHelp; private System.Windows.Forms.CheckBox m_cbLockAfterGlobalTime; private System.Windows.Forms.NumericUpDown m_numLockAfterGlobalTime; private System.Windows.Forms.Button m_btnProxy; } }keepass2-2.25/KeePass/Forms/SingleLineEditForm.Designer.cs0000664000175000017500000001151710666755434023332 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class SingleLineEditForm { /// /// 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_bannerImage = new System.Windows.Forms.PictureBox(); this.m_tbEdit = new System.Windows.Forms.TextBox(); this.m_lblLongDesc = new System.Windows.Forms.Label(); this.m_cmbEdit = new System.Windows.Forms.ComboBox(); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).BeginInit(); this.SuspendLayout(); // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(263, 139); this.m_btnOK.Name = "m_btnOK"; this.m_btnOK.Size = new System.Drawing.Size(75, 23); this.m_btnOK.TabIndex = 1; this.m_btnOK.Text = "&OK"; 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(344, 139); this.m_btnCancel.Name = "m_btnCancel"; this.m_btnCancel.Size = new System.Drawing.Size(75, 23); this.m_btnCancel.TabIndex = 2; this.m_btnCancel.Text = "&Cancel"; this.m_btnCancel.UseVisualStyleBackColor = true; this.m_btnCancel.Click += new System.EventHandler(this.OnBtnCancel); // // m_bannerImage // this.m_bannerImage.Dock = System.Windows.Forms.DockStyle.Top; this.m_bannerImage.Location = new System.Drawing.Point(0, 0); this.m_bannerImage.Name = "m_bannerImage"; this.m_bannerImage.Size = new System.Drawing.Size(431, 60); this.m_bannerImage.TabIndex = 2; this.m_bannerImage.TabStop = false; // // m_tbEdit // this.m_tbEdit.Location = new System.Drawing.Point(12, 106); this.m_tbEdit.Name = "m_tbEdit"; this.m_tbEdit.Size = new System.Drawing.Size(407, 20); this.m_tbEdit.TabIndex = 0; // // m_lblLongDesc // this.m_lblLongDesc.Location = new System.Drawing.Point(9, 72); this.m_lblLongDesc.Name = "m_lblLongDesc"; this.m_lblLongDesc.Size = new System.Drawing.Size(410, 28); this.m_lblLongDesc.TabIndex = 3; this.m_lblLongDesc.Text = "<>"; // // m_cmbEdit // this.m_cmbEdit.DropDownHeight = 400; this.m_cmbEdit.FormattingEnabled = true; this.m_cmbEdit.IntegralHeight = false; this.m_cmbEdit.Location = new System.Drawing.Point(12, 106); this.m_cmbEdit.Name = "m_cmbEdit"; this.m_cmbEdit.Size = new System.Drawing.Size(407, 21); this.m_cmbEdit.TabIndex = 4; // // SingleLineEditForm // 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(431, 174); this.Controls.Add(this.m_cmbEdit); this.Controls.Add(this.m_lblLongDesc); this.Controls.Add(this.m_tbEdit); this.Controls.Add(this.m_bannerImage); 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 = "SingleLineEditForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = ""; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); this.Load += new System.EventHandler(this.OnFormLoad); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.Button m_btnOK; private System.Windows.Forms.Button m_btnCancel; private System.Windows.Forms.PictureBox m_bannerImage; private System.Windows.Forms.TextBox m_tbEdit; private System.Windows.Forms.Label m_lblLongDesc; private System.Windows.Forms.ComboBox m_cmbEdit; } }keepass2-2.25/KeePass/Forms/KeyCreationForm.cs0000664000175000017500000002566612261553106021144 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Text; using System.IO; using System.Windows.Forms; using System.Diagnostics; using KeePass.App; using KeePass.App.Configuration; using KeePass.Resources; using KeePass.UI; using KeePass.Util; using KeePassLib; using KeePassLib.Cryptography; using KeePassLib.Keys; using KeePassLib.Native; using KeePassLib.Security; using KeePassLib.Serialization; using KeePassLib.Utility; namespace KeePass.Forms { public partial class KeyCreationForm : Form { private CompositeKey m_pKey = null; private bool m_bCreatingNew = false; private IOConnectionInfo m_ioInfo = new IOConnectionInfo(); private PwInputControlGroup m_icgPassword = new PwInputControlGroup(); private Image m_imgAccWarning = null; public CompositeKey CompositeKey { get { Debug.Assert(m_pKey != null); return m_pKey; } } public KeyCreationForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } public void InitEx(IOConnectionInfo ioInfo, bool bCreatingNew) { if(ioInfo != null) m_ioInfo = ioInfo; m_bCreatingNew = bCreatingNew; } private void OnFormLoad(object sender, EventArgs e) { GlobalWindowManager.AddWindow(this); BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_KGPG_Sign, KPRes.CreateMasterKey, m_ioInfo.GetDisplayName()); this.Icon = Properties.Resources.KeePass; this.Text = KPRes.CreateMasterKey; FontUtil.SetDefaultFont(m_cbPassword); FontUtil.AssignDefaultBold(m_cbPassword); FontUtil.AssignDefaultBold(m_cbKeyFile); FontUtil.AssignDefaultBold(m_cbUserAccount); Bitmap bmpBig = SystemIcons.Warning.ToBitmap(); m_imgAccWarning = UIUtil.CreateScaledImage(bmpBig, 16, 16); bmpBig.Dispose(); m_picAccWarning.Image = m_imgAccWarning; m_ttRect.SetToolTip(m_cbHidePassword, KPRes.TogglePasswordAsterisks); m_ttRect.SetToolTip(m_btnSaveKeyFile, KPRes.KeyFileCreate); m_ttRect.SetToolTip(m_btnOpenKeyFile, KPRes.KeyFileUseExisting); m_ttRect.SetToolTip(m_tbRepeatPassword, KPRes.PasswordRepeatHint); if(!m_bCreatingNew) m_lblIntro.Text = KPRes.ChangeMasterKeyIntroShort; m_icgPassword.Attach(m_tbPassword, m_cbHidePassword, m_lblRepeatPassword, m_tbRepeatPassword, m_lblEstimatedQuality, m_pbPasswordQuality, m_lblQualityBits, this, true, false); m_cmbKeyFile.Items.Add(KPRes.NoKeyFileSpecifiedMeta); foreach(KeyProvider prov in Program.KeyProviderPool) m_cmbKeyFile.Items.Add(prov.Name); m_cmbKeyFile.SelectedIndex = 0; m_cbPassword.Checked = true; UIUtil.ApplyKeyUIFlags(Program.Config.UI.KeyCreationFlags, m_cbPassword, m_cbKeyFile, m_cbUserAccount, m_cbHidePassword); if(WinUtil.IsWindows9x || NativeLib.IsUnix()) { UIUtil.SetChecked(m_cbUserAccount, false); UIUtil.SetEnabled(m_cbUserAccount, false); UIUtil.SetEnabled(m_lblWindowsAccDesc, false); UIUtil.SetEnabled(m_lblWindowsAccDesc2, false); } CustomizeForScreenReader(); EnableUserControls(); // UIUtil.SetFocus(m_tbPassword, this); // See OnFormShown } private void OnFormShown(object sender, EventArgs e) { // Focusing doesn't always work in OnFormLoad; // https://sourceforge.net/p/keepass/feature-requests/1735/ if(m_tbPassword.CanFocus) UIUtil.SetFocus(m_tbPassword, this); else if(m_cmbKeyFile.CanFocus) UIUtil.SetFocus(m_cmbKeyFile, this); else if(m_btnCreate.CanFocus) UIUtil.SetFocus(m_btnCreate, this); else { Debug.Assert(false); } } private void CustomizeForScreenReader() { if(!Program.Config.UI.OptimizeForScreenReader) return; m_cbHidePassword.Text = KPRes.HideUsingAsterisks; } private void CleanUpEx() { if(m_imgAccWarning != null) { m_picAccWarning.Image = null; m_imgAccWarning.Dispose(); m_imgAccWarning = null; } m_icgPassword.Release(); } private bool CreateCompositeKey() { m_pKey = new CompositeKey(); if(m_cbPassword.Checked) // Use a password { if(!m_icgPassword.ValidateData(true)) return false; uint uPwLen = m_icgPassword.PasswordLength; if(uPwLen == 0) { if(!MessageService.AskYesNo(KPRes.EmptyMasterPw + MessageService.NewParagraph + KPRes.EmptyMasterPwHint + MessageService.NewParagraph + KPRes.EmptyMasterPwQuestion, null, false)) { return false; } } uint uMinLen = Program.Config.Security.MasterPassword.MinimumLength; if(uPwLen < uMinLen) { string strML = KPRes.MasterPasswordMinLengthFailed; strML = strML.Replace(@"{PARAM}", uMinLen.ToString()); MessageService.ShowWarning(strML); return false; } byte[] pb = m_icgPassword.GetPasswordUtf8(); uint uMinQual = Program.Config.Security.MasterPassword.MinimumQuality; if(QualityEstimation.EstimatePasswordBits(pb) < uMinQual) { string strMQ = KPRes.MasterPasswordMinQualityFailed; strMQ = strMQ.Replace(@"{PARAM}", uMinQual.ToString()); MessageService.ShowWarning(strMQ); Array.Clear(pb, 0, pb.Length); return false; } string strValRes = Program.KeyValidatorPool.Validate(pb, KeyValidationType.MasterPassword); if(strValRes != null) { MessageService.ShowWarning(strValRes); Array.Clear(pb, 0, pb.Length); return false; } m_pKey.AddUserKey(new KcpPassword(pb)); Array.Clear(pb, 0, pb.Length); } string strKeyFile = m_cmbKeyFile.Text; bool bIsKeyProv = Program.KeyProviderPool.IsKeyProvider(strKeyFile); if(m_cbKeyFile.Checked && (!strKeyFile.Equals(KPRes.NoKeyFileSpecifiedMeta)) && !bIsKeyProv) { try { m_pKey.AddUserKey(new KcpKeyFile(strKeyFile, true)); } catch(InvalidDataException exID) // Selected database file { MessageService.ShowWarning(strKeyFile, exID); return false; } catch(Exception exKF) { MessageService.ShowWarning(strKeyFile, KPRes.KeyFileError, exKF); return false; } } else if(m_cbKeyFile.Checked && (!strKeyFile.Equals(KPRes.NoKeyFileSpecifiedMeta)) && bIsKeyProv) { KeyProviderQueryContext ctxKP = new KeyProviderQueryContext( m_ioInfo, true, false); bool bPerformHash; byte[] pbCustomKey = Program.KeyProviderPool.GetKey(strKeyFile, ctxKP, out bPerformHash); if((pbCustomKey != null) && (pbCustomKey.Length > 0)) { try { m_pKey.AddUserKey(new KcpCustomKey(strKeyFile, pbCustomKey, bPerformHash)); } catch(Exception exCKP) { MessageService.ShowWarning(exCKP); return false; } Array.Clear(pbCustomKey, 0, pbCustomKey.Length); } else return false; // Provider has shown error message } if(m_cbUserAccount.Checked) { try { m_pKey.AddUserKey(new KcpUserAccount()); } catch(Exception exUA) { MessageService.ShowWarning(exUA); return false; } } return true; } private void EnableUserControls() { m_icgPassword.Enabled = m_cbPassword.Checked; m_btnOpenKeyFile.Enabled = m_btnSaveKeyFile.Enabled = m_cmbKeyFile.Enabled = m_cbKeyFile.Checked; string strKeyFile = m_cmbKeyFile.Text; if(!m_cbPassword.Checked && !m_cbKeyFile.Checked && !m_cbUserAccount.Checked) m_btnCreate.Enabled = false; else if(m_cbKeyFile.Checked && strKeyFile.Equals(KPRes.NoKeyFileSpecifiedMeta)) m_btnCreate.Enabled = false; else m_btnCreate.Enabled = true; m_ttRect.SetToolTip(m_cmbKeyFile, strKeyFile); } private void OnCheckedPassword(object sender, EventArgs e) { EnableUserControls(); if(m_cbPassword.Checked) UIUtil.SetFocus(m_tbPassword, this); } private void OnCheckedKeyFile(object sender, EventArgs e) { EnableUserControls(); } private void OnBtnOK(object sender, EventArgs e) { if(!CreateCompositeKey()) this.DialogResult = DialogResult.None; } private void OnBtnCancel(object sender, EventArgs e) { m_pKey = null; } private void OnClickKeyFileCreate(object sender, EventArgs e) { SaveFileDialogEx sfd = UIUtil.CreateSaveFileDialog(KPRes.KeyFileCreate, UrlUtil.StripExtension(UrlUtil.GetFileName(m_ioInfo.Path)) + "." + AppDefs.FileExtension.KeyFile, UIUtil.CreateFileTypeFilter("key", KPRes.KeyFiles, true), 1, "key", AppDefs.FileDialogContext.KeyFile); if(sfd.ShowDialog() == DialogResult.OK) { EntropyForm dlg = new EntropyForm(); if(dlg.ShowDialog() == DialogResult.OK) { byte[] pbAdditionalEntropy = dlg.GeneratedEntropy; try { KcpKeyFile.Create(sfd.FileName, pbAdditionalEntropy); string str = sfd.FileName; m_cmbKeyFile.Items.Add(str); m_cmbKeyFile.SelectedIndex = m_cmbKeyFile.Items.Count - 1; } catch(Exception exKC) { MessageService.ShowWarning(exKC); } } UIUtil.DestroyForm(dlg); } EnableUserControls(); } private void OnClickKeyFileBrowse(object sender, EventArgs e) { OpenFileDialogEx ofd = UIUtil.CreateOpenFileDialog(KPRes.KeyFileUseExisting, UIUtil.CreateFileTypeFilter("key", KPRes.KeyFiles, true), 2, null, false, AppDefs.FileDialogContext.KeyFile); if(ofd.ShowDialog() == DialogResult.OK) { string str = ofd.FileName; m_cmbKeyFile.Items.Add(str); m_cmbKeyFile.SelectedIndex = m_cmbKeyFile.Items.Count - 1; } EnableUserControls(); } private void OnWinUserCheckedChanged(object sender, EventArgs e) { EnableUserControls(); } private void OnFormClosed(object sender, FormClosedEventArgs e) { GlobalWindowManager.RemoveWindow(this); } private void OnBtnHelp(object sender, EventArgs e) { AppHelp.ShowHelp(AppDefs.HelpTopics.KeySources, null); } private void OnKeyFileSelectedIndexChanged(object sender, EventArgs e) { EnableUserControls(); } private void OnFormClosing(object sender, FormClosingEventArgs e) { CleanUpEx(); } } } keepass2-2.25/KeePass/Forms/EditAutoTypeItemForm.Designer.cs0000664000175000017500000002604711744606124023663 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class EditAutoTypeItemForm { /// /// 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_bannerImage = new System.Windows.Forms.PictureBox(); this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_btnHelp = new System.Windows.Forms.Button(); this.m_lblTargetWindow = new System.Windows.Forms.Label(); this.m_lblKeySeqInsertInfo = new System.Windows.Forms.Label(); this.m_lblSeparator = new System.Windows.Forms.Label(); this.m_rbKeySeq = new KeePass.UI.CustomRichTextBoxEx(); this.m_rtbPlaceholders = new KeePass.UI.CustomRichTextBoxEx(); this.m_cmbWindow = new KeePass.UI.ImageComboBoxEx(); this.m_lblOpenHint = new System.Windows.Forms.Label(); this.m_lnkWildcardRegexHint = new System.Windows.Forms.LinkLabel(); this.m_rbSeqDefault = new System.Windows.Forms.RadioButton(); this.m_rbSeqCustom = new System.Windows.Forms.RadioButton(); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).BeginInit(); this.SuspendLayout(); // // m_bannerImage // this.m_bannerImage.Dock = System.Windows.Forms.DockStyle.Top; this.m_bannerImage.Location = new System.Drawing.Point(0, 0); this.m_bannerImage.Name = "m_bannerImage"; this.m_bannerImage.Size = new System.Drawing.Size(511, 60); this.m_bannerImage.TabIndex = 0; this.m_bannerImage.TabStop = false; // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(343, 388); this.m_btnOK.Name = "m_btnOK"; this.m_btnOK.Size = new System.Drawing.Size(75, 23); this.m_btnOK.TabIndex = 8; this.m_btnOK.Text = "&OK"; 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(424, 388); this.m_btnCancel.Name = "m_btnCancel"; this.m_btnCancel.Size = new System.Drawing.Size(75, 23); this.m_btnCancel.TabIndex = 9; this.m_btnCancel.Text = "&Cancel"; this.m_btnCancel.UseVisualStyleBackColor = true; this.m_btnCancel.Click += new System.EventHandler(this.OnBtnCancel); // // m_btnHelp // this.m_btnHelp.Location = new System.Drawing.Point(12, 388); this.m_btnHelp.Name = "m_btnHelp"; this.m_btnHelp.Size = new System.Drawing.Size(75, 23); this.m_btnHelp.TabIndex = 10; this.m_btnHelp.Text = "&Help"; this.m_btnHelp.UseVisualStyleBackColor = true; this.m_btnHelp.Click += new System.EventHandler(this.OnBtnHelp); // // m_lblTargetWindow // this.m_lblTargetWindow.AutoSize = true; this.m_lblTargetWindow.Location = new System.Drawing.Point(9, 75); this.m_lblTargetWindow.Name = "m_lblTargetWindow"; this.m_lblTargetWindow.Size = new System.Drawing.Size(80, 13); this.m_lblTargetWindow.TabIndex = 12; this.m_lblTargetWindow.Text = "Target window:"; // // m_lblKeySeqInsertInfo // this.m_lblKeySeqInsertInfo.AutoSize = true; this.m_lblKeySeqInsertInfo.Location = new System.Drawing.Point(29, 213); this.m_lblKeySeqInsertInfo.Name = "m_lblKeySeqInsertInfo"; this.m_lblKeySeqInsertInfo.Size = new System.Drawing.Size(94, 13); this.m_lblKeySeqInsertInfo.TabIndex = 6; this.m_lblKeySeqInsertInfo.Text = "Insert placeholder:"; // // m_lblSeparator // this.m_lblSeparator.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.m_lblSeparator.Location = new System.Drawing.Point(0, 379); this.m_lblSeparator.Name = "m_lblSeparator"; this.m_lblSeparator.Size = new System.Drawing.Size(511, 2); this.m_lblSeparator.TabIndex = 11; // // m_rbKeySeq // this.m_rbKeySeq.DetectUrls = false; this.m_rbKeySeq.Font = new System.Drawing.Font("Courier New", 8.25F); this.m_rbKeySeq.HideSelection = false; this.m_rbKeySeq.Location = new System.Drawing.Point(32, 187); this.m_rbKeySeq.Multiline = false; this.m_rbKeySeq.Name = "m_rbKeySeq"; this.m_rbKeySeq.Size = new System.Drawing.Size(467, 20); this.m_rbKeySeq.TabIndex = 5; this.m_rbKeySeq.Text = ""; this.m_rbKeySeq.TextChanged += new System.EventHandler(this.OnTextChangedKeySeq); // // m_rtbPlaceholders // this.m_rtbPlaceholders.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.m_rtbPlaceholders.Location = new System.Drawing.Point(32, 229); this.m_rtbPlaceholders.Name = "m_rtbPlaceholders"; this.m_rtbPlaceholders.ReadOnly = true; this.m_rtbPlaceholders.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedVertical; this.m_rtbPlaceholders.Size = new System.Drawing.Size(467, 136); this.m_rtbPlaceholders.TabIndex = 7; this.m_rtbPlaceholders.Text = ""; this.m_rtbPlaceholders.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.OnPlaceholdersLinkClicked); // // m_cmbWindow // this.m_cmbWindow.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable; this.m_cmbWindow.DropDownHeight = 218; this.m_cmbWindow.FormattingEnabled = true; this.m_cmbWindow.IntegralHeight = false; this.m_cmbWindow.Location = new System.Drawing.Point(95, 72); this.m_cmbWindow.MaxDropDownItems = 12; this.m_cmbWindow.Name = "m_cmbWindow"; this.m_cmbWindow.OrderedImageList = null; this.m_cmbWindow.Size = new System.Drawing.Size(404, 21); this.m_cmbWindow.TabIndex = 0; this.m_cmbWindow.SelectedIndexChanged += new System.EventHandler(this.OnWindowSelectedIndexChanged); this.m_cmbWindow.TextUpdate += new System.EventHandler(this.OnWindowTextUpdate); // // m_lblOpenHint // this.m_lblOpenHint.AutoSize = true; this.m_lblOpenHint.Location = new System.Drawing.Point(92, 99); this.m_lblOpenHint.Name = "m_lblOpenHint"; this.m_lblOpenHint.Size = new System.Drawing.Size(351, 13); this.m_lblOpenHint.TabIndex = 1; this.m_lblOpenHint.Text = "Click the drop-down button on the right to see currently opened windows."; // // m_lnkWildcardRegexHint // this.m_lnkWildcardRegexHint.AutoSize = true; this.m_lnkWildcardRegexHint.Location = new System.Drawing.Point(92, 116); this.m_lnkWildcardRegexHint.Name = "m_lnkWildcardRegexHint"; this.m_lnkWildcardRegexHint.Size = new System.Drawing.Size(270, 13); this.m_lnkWildcardRegexHint.TabIndex = 2; this.m_lnkWildcardRegexHint.TabStop = true; this.m_lnkWildcardRegexHint.Text = "Simple wildcards and regular expressions are supported."; this.m_lnkWildcardRegexHint.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.OnWildcardRegexLinkClicked); // // m_rbSeqDefault // this.m_rbSeqDefault.AutoSize = true; this.m_rbSeqDefault.Location = new System.Drawing.Point(12, 142); this.m_rbSeqDefault.Name = "m_rbSeqDefault"; this.m_rbSeqDefault.Size = new System.Drawing.Size(234, 17); this.m_rbSeqDefault.TabIndex = 3; this.m_rbSeqDefault.TabStop = true; this.m_rbSeqDefault.Text = "Use default keystroke sequence of the entry"; this.m_rbSeqDefault.UseVisualStyleBackColor = true; this.m_rbSeqDefault.CheckedChanged += new System.EventHandler(this.OnSeqDefaultCheckedChanged); // // m_rbSeqCustom // this.m_rbSeqCustom.AutoSize = true; this.m_rbSeqCustom.Location = new System.Drawing.Point(12, 164); this.m_rbSeqCustom.Name = "m_rbSeqCustom"; this.m_rbSeqCustom.Size = new System.Drawing.Size(183, 17); this.m_rbSeqCustom.TabIndex = 4; this.m_rbSeqCustom.TabStop = true; this.m_rbSeqCustom.Text = "Use custom keystroke sequence:"; this.m_rbSeqCustom.UseVisualStyleBackColor = true; this.m_rbSeqCustom.CheckedChanged += new System.EventHandler(this.OnSeqCustomCheckedChanged); // // EditAutoTypeItemForm // 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(511, 423); this.Controls.Add(this.m_rbSeqCustom); this.Controls.Add(this.m_rbSeqDefault); this.Controls.Add(this.m_lnkWildcardRegexHint); this.Controls.Add(this.m_lblOpenHint); this.Controls.Add(this.m_cmbWindow); this.Controls.Add(this.m_rtbPlaceholders); this.Controls.Add(this.m_rbKeySeq); this.Controls.Add(this.m_lblSeparator); this.Controls.Add(this.m_lblKeySeqInsertInfo); this.Controls.Add(this.m_lblTargetWindow); this.Controls.Add(this.m_btnHelp); this.Controls.Add(this.m_btnCancel); this.Controls.Add(this.m_btnOK); this.Controls.Add(this.m_bannerImage); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "EditAutoTypeItemForm"; this.ShowInTaskbar = false; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Edit Auto-Type Item"; this.Load += new System.EventHandler(this.OnFormLoad); this.Shown += new System.EventHandler(this.OnFormShown); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.PictureBox m_bannerImage; private System.Windows.Forms.Button m_btnOK; private System.Windows.Forms.Button m_btnCancel; private System.Windows.Forms.Button m_btnHelp; private System.Windows.Forms.Label m_lblTargetWindow; private System.Windows.Forms.Label m_lblKeySeqInsertInfo; private System.Windows.Forms.Label m_lblSeparator; private KeePass.UI.CustomRichTextBoxEx m_rbKeySeq; private KeePass.UI.CustomRichTextBoxEx m_rtbPlaceholders; private KeePass.UI.ImageComboBoxEx m_cmbWindow; private System.Windows.Forms.Label m_lblOpenHint; private System.Windows.Forms.LinkLabel m_lnkWildcardRegexHint; private System.Windows.Forms.RadioButton m_rbSeqDefault; private System.Windows.Forms.RadioButton m_rbSeqCustom; } }keepass2-2.25/KeePass/Forms/UrlSchemeForm.resx0000664000175000017500000001326611230125006021150 0ustar jtaylorjtaylor 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 keepass2-2.25/KeePass/Forms/FieldRefForm.Designer.cs0000664000175000017500000003243611572445304022143 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class FieldRefForm { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if(disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.m_lvEntries = new KeePass.UI.CustomListViewEx(); this.m_grpIdentify = new System.Windows.Forms.GroupBox(); this.m_radioIdUuid = new System.Windows.Forms.RadioButton(); this.m_radioIdNotes = new System.Windows.Forms.RadioButton(); this.m_radioIdUrl = new System.Windows.Forms.RadioButton(); this.m_radioIdPassword = new System.Windows.Forms.RadioButton(); this.m_radioIdUserName = new System.Windows.Forms.RadioButton(); this.m_radioIdTitle = new System.Windows.Forms.RadioButton(); this.m_grpRefField = new System.Windows.Forms.GroupBox(); this.m_radioRefNotes = new System.Windows.Forms.RadioButton(); this.m_radioRefUrl = new System.Windows.Forms.RadioButton(); this.m_radioRefPassword = new System.Windows.Forms.RadioButton(); this.m_radioRefUserName = new System.Windows.Forms.RadioButton(); this.m_radioRefTitle = new System.Windows.Forms.RadioButton(); this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_btnHelp = new System.Windows.Forms.Button(); this.m_lblFilter = new System.Windows.Forms.Label(); this.m_tbFilter = new System.Windows.Forms.TextBox(); this.m_grpIdentify.SuspendLayout(); this.m_grpRefField.SuspendLayout(); this.SuspendLayout(); // // m_lvEntries // this.m_lvEntries.FullRowSelect = true; this.m_lvEntries.GridLines = true; this.m_lvEntries.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; this.m_lvEntries.HideSelection = false; this.m_lvEntries.Location = new System.Drawing.Point(12, 38); this.m_lvEntries.MultiSelect = false; this.m_lvEntries.Name = "m_lvEntries"; this.m_lvEntries.Size = new System.Drawing.Size(608, 280); this.m_lvEntries.TabIndex = 0; this.m_lvEntries.UseCompatibleStateImageBehavior = false; this.m_lvEntries.View = System.Windows.Forms.View.Details; this.m_lvEntries.SelectedIndexChanged += new System.EventHandler(this.OnEntriesSelectedIndexChanged); // // m_grpIdentify // this.m_grpIdentify.Controls.Add(this.m_radioIdUuid); this.m_grpIdentify.Controls.Add(this.m_radioIdNotes); this.m_grpIdentify.Controls.Add(this.m_radioIdUrl); this.m_grpIdentify.Controls.Add(this.m_radioIdPassword); this.m_grpIdentify.Controls.Add(this.m_radioIdUserName); this.m_grpIdentify.Controls.Add(this.m_radioIdTitle); this.m_grpIdentify.Location = new System.Drawing.Point(12, 326); this.m_grpIdentify.Name = "m_grpIdentify"; this.m_grpIdentify.Size = new System.Drawing.Size(301, 69); this.m_grpIdentify.TabIndex = 1; this.m_grpIdentify.TabStop = false; this.m_grpIdentify.Text = "Identify source entry by"; // // m_radioIdUuid // this.m_radioIdUuid.AutoSize = true; this.m_radioIdUuid.Location = new System.Drawing.Point(202, 42); this.m_radioIdUuid.Name = "m_radioIdUuid"; this.m_radioIdUuid.Size = new System.Drawing.Size(52, 17); this.m_radioIdUuid.TabIndex = 5; this.m_radioIdUuid.TabStop = true; this.m_radioIdUuid.Text = "UUID"; this.m_radioIdUuid.UseVisualStyleBackColor = true; // // m_radioIdNotes // this.m_radioIdNotes.AutoSize = true; this.m_radioIdNotes.Location = new System.Drawing.Point(202, 19); this.m_radioIdNotes.Name = "m_radioIdNotes"; this.m_radioIdNotes.Size = new System.Drawing.Size(53, 17); this.m_radioIdNotes.TabIndex = 4; this.m_radioIdNotes.TabStop = true; this.m_radioIdNotes.Text = "Notes"; this.m_radioIdNotes.UseVisualStyleBackColor = true; // // m_radioIdUrl // this.m_radioIdUrl.AutoSize = true; this.m_radioIdUrl.Location = new System.Drawing.Point(106, 42); this.m_radioIdUrl.Name = "m_radioIdUrl"; this.m_radioIdUrl.Size = new System.Drawing.Size(47, 17); this.m_radioIdUrl.TabIndex = 3; this.m_radioIdUrl.TabStop = true; this.m_radioIdUrl.Text = "URL"; this.m_radioIdUrl.UseVisualStyleBackColor = true; // // m_radioIdPassword // this.m_radioIdPassword.AutoSize = true; this.m_radioIdPassword.Location = new System.Drawing.Point(106, 19); this.m_radioIdPassword.Name = "m_radioIdPassword"; this.m_radioIdPassword.Size = new System.Drawing.Size(71, 17); this.m_radioIdPassword.TabIndex = 2; this.m_radioIdPassword.TabStop = true; this.m_radioIdPassword.Text = "Password"; this.m_radioIdPassword.UseVisualStyleBackColor = true; // // m_radioIdUserName // this.m_radioIdUserName.AutoSize = true; this.m_radioIdUserName.Location = new System.Drawing.Point(10, 42); this.m_radioIdUserName.Name = "m_radioIdUserName"; this.m_radioIdUserName.Size = new System.Drawing.Size(76, 17); this.m_radioIdUserName.TabIndex = 1; this.m_radioIdUserName.TabStop = true; this.m_radioIdUserName.Text = "User name"; this.m_radioIdUserName.UseVisualStyleBackColor = true; // // m_radioIdTitle // this.m_radioIdTitle.AutoSize = true; this.m_radioIdTitle.Location = new System.Drawing.Point(10, 19); this.m_radioIdTitle.Name = "m_radioIdTitle"; this.m_radioIdTitle.Size = new System.Drawing.Size(45, 17); this.m_radioIdTitle.TabIndex = 0; this.m_radioIdTitle.TabStop = true; this.m_radioIdTitle.Text = "Title"; this.m_radioIdTitle.UseVisualStyleBackColor = true; // // m_grpRefField // this.m_grpRefField.Controls.Add(this.m_radioRefNotes); this.m_grpRefField.Controls.Add(this.m_radioRefUrl); this.m_grpRefField.Controls.Add(this.m_radioRefPassword); this.m_grpRefField.Controls.Add(this.m_radioRefUserName); this.m_grpRefField.Controls.Add(this.m_radioRefTitle); this.m_grpRefField.Location = new System.Drawing.Point(319, 326); this.m_grpRefField.Name = "m_grpRefField"; this.m_grpRefField.Size = new System.Drawing.Size(301, 69); this.m_grpRefField.TabIndex = 2; this.m_grpRefField.TabStop = false; this.m_grpRefField.Text = "Source field to reference"; // // m_radioRefNotes // this.m_radioRefNotes.AutoSize = true; this.m_radioRefNotes.Location = new System.Drawing.Point(203, 19); this.m_radioRefNotes.Name = "m_radioRefNotes"; this.m_radioRefNotes.Size = new System.Drawing.Size(53, 17); this.m_radioRefNotes.TabIndex = 4; this.m_radioRefNotes.TabStop = true; this.m_radioRefNotes.Text = "Notes"; this.m_radioRefNotes.UseVisualStyleBackColor = true; // // m_radioRefUrl // this.m_radioRefUrl.AutoSize = true; this.m_radioRefUrl.Location = new System.Drawing.Point(107, 42); this.m_radioRefUrl.Name = "m_radioRefUrl"; this.m_radioRefUrl.Size = new System.Drawing.Size(47, 17); this.m_radioRefUrl.TabIndex = 3; this.m_radioRefUrl.TabStop = true; this.m_radioRefUrl.Text = "URL"; this.m_radioRefUrl.UseVisualStyleBackColor = true; // // m_radioRefPassword // this.m_radioRefPassword.AutoSize = true; this.m_radioRefPassword.Location = new System.Drawing.Point(107, 19); this.m_radioRefPassword.Name = "m_radioRefPassword"; this.m_radioRefPassword.Size = new System.Drawing.Size(71, 17); this.m_radioRefPassword.TabIndex = 2; this.m_radioRefPassword.TabStop = true; this.m_radioRefPassword.Text = "Password"; this.m_radioRefPassword.UseVisualStyleBackColor = true; // // m_radioRefUserName // this.m_radioRefUserName.AutoSize = true; this.m_radioRefUserName.Location = new System.Drawing.Point(11, 42); this.m_radioRefUserName.Name = "m_radioRefUserName"; this.m_radioRefUserName.Size = new System.Drawing.Size(76, 17); this.m_radioRefUserName.TabIndex = 1; this.m_radioRefUserName.TabStop = true; this.m_radioRefUserName.Text = "User name"; this.m_radioRefUserName.UseVisualStyleBackColor = true; // // m_radioRefTitle // this.m_radioRefTitle.AutoSize = true; this.m_radioRefTitle.Location = new System.Drawing.Point(11, 19); this.m_radioRefTitle.Name = "m_radioRefTitle"; this.m_radioRefTitle.Size = new System.Drawing.Size(45, 17); this.m_radioRefTitle.TabIndex = 0; this.m_radioRefTitle.TabStop = true; this.m_radioRefTitle.Text = "Title"; this.m_radioRefTitle.UseVisualStyleBackColor = true; // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(464, 405); this.m_btnOK.Name = "m_btnOK"; this.m_btnOK.Size = new System.Drawing.Size(75, 23); this.m_btnOK.TabIndex = 3; this.m_btnOK.Text = "&OK"; 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(545, 405); this.m_btnCancel.Name = "m_btnCancel"; this.m_btnCancel.Size = new System.Drawing.Size(75, 23); this.m_btnCancel.TabIndex = 4; this.m_btnCancel.Text = "&Cancel"; this.m_btnCancel.UseVisualStyleBackColor = true; this.m_btnCancel.Click += new System.EventHandler(this.OnBtnCancel); // // m_btnHelp // this.m_btnHelp.Location = new System.Drawing.Point(12, 405); this.m_btnHelp.Name = "m_btnHelp"; this.m_btnHelp.Size = new System.Drawing.Size(75, 23); this.m_btnHelp.TabIndex = 5; this.m_btnHelp.Text = "&Help"; this.m_btnHelp.UseVisualStyleBackColor = true; this.m_btnHelp.Click += new System.EventHandler(this.OnBtnHelp); // // m_lblFilter // this.m_lblFilter.AutoSize = true; this.m_lblFilter.Location = new System.Drawing.Point(396, 15); this.m_lblFilter.Name = "m_lblFilter"; this.m_lblFilter.Size = new System.Drawing.Size(32, 13); this.m_lblFilter.TabIndex = 6; this.m_lblFilter.Text = "Filter:"; // // m_tbFilter // this.m_tbFilter.Location = new System.Drawing.Point(434, 12); this.m_tbFilter.Name = "m_tbFilter"; this.m_tbFilter.Size = new System.Drawing.Size(186, 20); this.m_tbFilter.TabIndex = 7; this.m_tbFilter.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnFilterKeyDown); this.m_tbFilter.KeyUp += new System.Windows.Forms.KeyEventHandler(this.OnFilterKeyUp); // // FieldRefForm // 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(632, 440); this.Controls.Add(this.m_tbFilter); this.Controls.Add(this.m_lblFilter); this.Controls.Add(this.m_btnHelp); this.Controls.Add(this.m_btnCancel); this.Controls.Add(this.m_btnOK); this.Controls.Add(this.m_grpRefField); this.Controls.Add(this.m_grpIdentify); this.Controls.Add(this.m_lvEntries); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "FieldRefForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Insert Field Reference"; this.Load += new System.EventHandler(this.OnFormLoad); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); this.m_grpIdentify.ResumeLayout(false); this.m_grpIdentify.PerformLayout(); this.m_grpRefField.ResumeLayout(false); this.m_grpRefField.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private KeePass.UI.CustomListViewEx m_lvEntries; private System.Windows.Forms.GroupBox m_grpIdentify; private System.Windows.Forms.GroupBox m_grpRefField; private System.Windows.Forms.Button m_btnOK; private System.Windows.Forms.Button m_btnCancel; private System.Windows.Forms.Button m_btnHelp; private System.Windows.Forms.RadioButton m_radioIdNotes; private System.Windows.Forms.RadioButton m_radioIdUrl; private System.Windows.Forms.RadioButton m_radioIdPassword; private System.Windows.Forms.RadioButton m_radioIdUserName; private System.Windows.Forms.RadioButton m_radioIdTitle; private System.Windows.Forms.RadioButton m_radioIdUuid; private System.Windows.Forms.RadioButton m_radioRefNotes; private System.Windows.Forms.RadioButton m_radioRefUrl; private System.Windows.Forms.RadioButton m_radioRefPassword; private System.Windows.Forms.RadioButton m_radioRefUserName; private System.Windows.Forms.RadioButton m_radioRefTitle; private System.Windows.Forms.Label m_lblFilter; private System.Windows.Forms.TextBox m_tbFilter; } }keepass2-2.25/KeePass/Forms/ProxyForm.Designer.cs0000664000175000017500000002301111576140524021571 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class ProxyForm { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if(disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_grpServer = new System.Windows.Forms.GroupBox(); this.m_tbPort = new System.Windows.Forms.TextBox(); this.m_lblPort = new System.Windows.Forms.Label(); this.m_tbAddress = new System.Windows.Forms.TextBox(); this.m_lblAddress = new System.Windows.Forms.Label(); this.m_rbManualProxy = new System.Windows.Forms.RadioButton(); this.m_rbSystemProxy = new System.Windows.Forms.RadioButton(); this.m_rbNoProxy = new System.Windows.Forms.RadioButton(); this.m_grpAuth = new System.Windows.Forms.GroupBox(); this.m_tbPassword = new System.Windows.Forms.TextBox(); this.m_lblPassword = new System.Windows.Forms.Label(); this.m_tbUser = new System.Windows.Forms.TextBox(); this.m_lblUser = new System.Windows.Forms.Label(); this.m_grpServer.SuspendLayout(); this.m_grpAuth.SuspendLayout(); this.SuspendLayout(); // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(183, 227); 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 = "&OK"; 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(264, 227); 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; // // m_grpServer // this.m_grpServer.Controls.Add(this.m_tbPort); this.m_grpServer.Controls.Add(this.m_lblPort); this.m_grpServer.Controls.Add(this.m_tbAddress); this.m_grpServer.Controls.Add(this.m_lblAddress); this.m_grpServer.Controls.Add(this.m_rbManualProxy); this.m_grpServer.Controls.Add(this.m_rbSystemProxy); this.m_grpServer.Controls.Add(this.m_rbNoProxy); this.m_grpServer.Location = new System.Drawing.Point(12, 12); this.m_grpServer.Name = "m_grpServer"; this.m_grpServer.Size = new System.Drawing.Size(327, 120); this.m_grpServer.TabIndex = 2; this.m_grpServer.TabStop = false; this.m_grpServer.Text = "Server"; // // m_tbPort // this.m_tbPort.Location = new System.Drawing.Point(266, 88); this.m_tbPort.Name = "m_tbPort"; this.m_tbPort.Size = new System.Drawing.Size(50, 20); this.m_tbPort.TabIndex = 6; // // m_lblPort // this.m_lblPort.AutoSize = true; this.m_lblPort.Location = new System.Drawing.Point(231, 91); this.m_lblPort.Name = "m_lblPort"; this.m_lblPort.Size = new System.Drawing.Size(29, 13); this.m_lblPort.TabIndex = 5; this.m_lblPort.Text = "Port:"; // // m_tbAddress // this.m_tbAddress.Location = new System.Drawing.Point(80, 88); this.m_tbAddress.Name = "m_tbAddress"; this.m_tbAddress.Size = new System.Drawing.Size(144, 20); this.m_tbAddress.TabIndex = 4; this.m_tbAddress.TextChanged += new System.EventHandler(this.OnAddressTextChanged); // // m_lblAddress // this.m_lblAddress.AutoSize = true; this.m_lblAddress.Location = new System.Drawing.Point(26, 91); this.m_lblAddress.Name = "m_lblAddress"; this.m_lblAddress.Size = new System.Drawing.Size(48, 13); this.m_lblAddress.TabIndex = 3; this.m_lblAddress.Text = "Address:"; // // m_rbManualProxy // this.m_rbManualProxy.AutoSize = true; this.m_rbManualProxy.Location = new System.Drawing.Point(9, 65); this.m_rbManualProxy.Name = "m_rbManualProxy"; this.m_rbManualProxy.Size = new System.Drawing.Size(155, 17); this.m_rbManualProxy.TabIndex = 2; this.m_rbManualProxy.TabStop = true; this.m_rbManualProxy.Text = "&Manual proxy configuration:"; this.m_rbManualProxy.UseVisualStyleBackColor = true; this.m_rbManualProxy.CheckedChanged += new System.EventHandler(this.OnManualProxyCheckedChanged); // // m_rbSystemProxy // this.m_rbSystemProxy.AutoSize = true; this.m_rbSystemProxy.Location = new System.Drawing.Point(9, 42); this.m_rbSystemProxy.Name = "m_rbSystemProxy"; this.m_rbSystemProxy.Size = new System.Drawing.Size(146, 17); this.m_rbSystemProxy.TabIndex = 1; this.m_rbSystemProxy.TabStop = true; this.m_rbSystemProxy.Text = "Use &system proxy settings"; this.m_rbSystemProxy.UseVisualStyleBackColor = true; this.m_rbSystemProxy.CheckedChanged += new System.EventHandler(this.OnSystemProxyCheckedChanged); // // m_rbNoProxy // this.m_rbNoProxy.AutoSize = true; this.m_rbNoProxy.Location = new System.Drawing.Point(9, 19); this.m_rbNoProxy.Name = "m_rbNoProxy"; this.m_rbNoProxy.Size = new System.Drawing.Size(67, 17); this.m_rbNoProxy.TabIndex = 0; this.m_rbNoProxy.TabStop = true; this.m_rbNoProxy.Text = "&No proxy"; this.m_rbNoProxy.UseVisualStyleBackColor = true; this.m_rbNoProxy.CheckedChanged += new System.EventHandler(this.OnNoProxyCheckedChanged); // // m_grpAuth // this.m_grpAuth.Controls.Add(this.m_tbPassword); this.m_grpAuth.Controls.Add(this.m_lblPassword); this.m_grpAuth.Controls.Add(this.m_tbUser); this.m_grpAuth.Controls.Add(this.m_lblUser); this.m_grpAuth.Location = new System.Drawing.Point(12, 138); this.m_grpAuth.Name = "m_grpAuth"; this.m_grpAuth.Size = new System.Drawing.Size(327, 77); this.m_grpAuth.TabIndex = 3; this.m_grpAuth.TabStop = false; this.m_grpAuth.Text = "Authentication"; // // m_tbPassword // this.m_tbPassword.Location = new System.Drawing.Point(80, 45); this.m_tbPassword.Name = "m_tbPassword"; this.m_tbPassword.Size = new System.Drawing.Size(236, 20); this.m_tbPassword.TabIndex = 3; this.m_tbPassword.UseSystemPasswordChar = true; // // m_lblPassword // this.m_lblPassword.AutoSize = true; this.m_lblPassword.Location = new System.Drawing.Point(6, 48); this.m_lblPassword.Name = "m_lblPassword"; this.m_lblPassword.Size = new System.Drawing.Size(56, 13); this.m_lblPassword.TabIndex = 2; this.m_lblPassword.Text = "Password:"; // // m_tbUser // this.m_tbUser.Location = new System.Drawing.Point(80, 19); this.m_tbUser.Name = "m_tbUser"; this.m_tbUser.Size = new System.Drawing.Size(236, 20); this.m_tbUser.TabIndex = 1; // // m_lblUser // this.m_lblUser.AutoSize = true; this.m_lblUser.Location = new System.Drawing.Point(6, 22); this.m_lblUser.Name = "m_lblUser"; this.m_lblUser.Size = new System.Drawing.Size(61, 13); this.m_lblUser.TabIndex = 0; this.m_lblUser.Text = "User name:"; // // ProxyForm // 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(351, 262); this.Controls.Add(this.m_grpAuth); this.Controls.Add(this.m_grpServer); 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 = "ProxyForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Proxy Settings"; this.Load += new System.EventHandler(this.OnFormLoad); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); this.m_grpServer.ResumeLayout(false); this.m_grpServer.PerformLayout(); this.m_grpAuth.ResumeLayout(false); this.m_grpAuth.PerformLayout(); this.ResumeLayout(false); } #endregion private System.Windows.Forms.Button m_btnOK; private System.Windows.Forms.Button m_btnCancel; private System.Windows.Forms.GroupBox m_grpServer; private System.Windows.Forms.RadioButton m_rbSystemProxy; private System.Windows.Forms.RadioButton m_rbNoProxy; private System.Windows.Forms.GroupBox m_grpAuth; private System.Windows.Forms.TextBox m_tbPassword; private System.Windows.Forms.Label m_lblPassword; private System.Windows.Forms.TextBox m_tbUser; private System.Windows.Forms.Label m_lblUser; private System.Windows.Forms.TextBox m_tbPort; private System.Windows.Forms.Label m_lblPort; private System.Windows.Forms.TextBox m_tbAddress; private System.Windows.Forms.Label m_lblAddress; private System.Windows.Forms.RadioButton m_rbManualProxy; } }keepass2-2.25/KeePass/Forms/EcasActionForm.Designer.cs0000664000175000017500000001420112113701650022451 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class EcasActionForm { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if(disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.m_cmbActions = new System.Windows.Forms.ComboBox(); this.m_lblAction = new System.Windows.Forms.Label(); this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_dgvParams = new System.Windows.Forms.DataGridView(); this.m_lblParamHint = new System.Windows.Forms.Label(); this.m_lblSep = new System.Windows.Forms.Label(); this.m_btnHelp = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.m_dgvParams)).BeginInit(); this.SuspendLayout(); // // m_cmbActions // this.m_cmbActions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.m_cmbActions.FormattingEnabled = true; this.m_cmbActions.Location = new System.Drawing.Point(12, 30); this.m_cmbActions.Name = "m_cmbActions"; this.m_cmbActions.Size = new System.Drawing.Size(510, 21); this.m_cmbActions.TabIndex = 0; this.m_cmbActions.SelectedIndexChanged += new System.EventHandler(this.OnActionsSelectedIndexChanged); // // m_lblAction // this.m_lblAction.AutoSize = true; this.m_lblAction.Location = new System.Drawing.Point(9, 14); this.m_lblAction.Name = "m_lblAction"; this.m_lblAction.Size = new System.Drawing.Size(40, 13); this.m_lblAction.TabIndex = 7; this.m_lblAction.Text = "Action:"; // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(366, 289); this.m_btnOK.Name = "m_btnOK"; this.m_btnOK.Size = new System.Drawing.Size(75, 23); this.m_btnOK.TabIndex = 5; this.m_btnOK.Text = "&OK"; 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(447, 289); this.m_btnCancel.Name = "m_btnCancel"; this.m_btnCancel.Size = new System.Drawing.Size(75, 23); this.m_btnCancel.TabIndex = 6; this.m_btnCancel.Text = "&Cancel"; this.m_btnCancel.UseVisualStyleBackColor = true; this.m_btnCancel.Click += new System.EventHandler(this.OnBtnCancel); // // m_dgvParams // this.m_dgvParams.AllowUserToAddRows = false; this.m_dgvParams.AllowUserToDeleteRows = false; this.m_dgvParams.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.m_dgvParams.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.m_dgvParams.Location = new System.Drawing.Point(12, 57); this.m_dgvParams.Name = "m_dgvParams"; this.m_dgvParams.Size = new System.Drawing.Size(510, 180); this.m_dgvParams.TabIndex = 1; // // m_lblParamHint // this.m_lblParamHint.Location = new System.Drawing.Point(9, 249); this.m_lblParamHint.Name = "m_lblParamHint"; this.m_lblParamHint.Size = new System.Drawing.Size(513, 15); this.m_lblParamHint.TabIndex = 2; this.m_lblParamHint.Text = "<>"; // // m_lblSep // this.m_lblSep.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.m_lblSep.Location = new System.Drawing.Point(0, 280); this.m_lblSep.Name = "m_lblSep"; this.m_lblSep.Size = new System.Drawing.Size(535, 2); this.m_lblSep.TabIndex = 3; // // m_btnHelp // this.m_btnHelp.Location = new System.Drawing.Point(12, 289); this.m_btnHelp.Name = "m_btnHelp"; this.m_btnHelp.Size = new System.Drawing.Size(75, 23); this.m_btnHelp.TabIndex = 4; this.m_btnHelp.Text = "&Help"; this.m_btnHelp.UseVisualStyleBackColor = true; this.m_btnHelp.Click += new System.EventHandler(this.OnBtnHelp); // // EcasActionForm // 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(534, 324); this.Controls.Add(this.m_btnHelp); this.Controls.Add(this.m_lblSep); this.Controls.Add(this.m_lblParamHint); this.Controls.Add(this.m_dgvParams); this.Controls.Add(this.m_btnCancel); this.Controls.Add(this.m_btnOK); this.Controls.Add(this.m_lblAction); this.Controls.Add(this.m_cmbActions); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "EcasActionForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "<>"; this.Load += new System.EventHandler(this.OnFormLoad); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); ((System.ComponentModel.ISupportInitialize)(this.m_dgvParams)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.ComboBox m_cmbActions; private System.Windows.Forms.Label m_lblAction; private System.Windows.Forms.Button m_btnOK; private System.Windows.Forms.Button m_btnCancel; private System.Windows.Forms.DataGridView m_dgvParams; private System.Windows.Forms.Label m_lblParamHint; private System.Windows.Forms.Label m_lblSep; private System.Windows.Forms.Button m_btnHelp; } }keepass2-2.25/KeePass/Forms/MainForm.Designer.cs0000664000175000017500000033703512237465010021345 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class MainForm { /// /// 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.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.m_ctxGroupList = new System.Windows.Forms.ContextMenuStrip(this.components); this.m_ctxGroupAdd = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxGroupSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_ctxGroupEdit = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxGroupDuplicate = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxGroupDelete = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxGroupEmpty = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxGroupSep1 = new System.Windows.Forms.ToolStripSeparator(); this.m_ctxGroupFind = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxGroupSep2 = new System.Windows.Forms.ToolStripSeparator(); this.m_ctxGroupPrint = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxGroupExport = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxGroupSep3 = new System.Windows.Forms.ToolStripSeparator(); this.m_ctxGroupRearrange = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxGroupMoveToTop = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxGroupMoveOneUp = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxGroupMoveOneDown = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxGroupMoveToBottom = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxGroupRearrSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_ctxGroupSort = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxGroupSortRec = new System.Windows.Forms.ToolStripMenuItem(); this.m_ilClientIcons = new System.Windows.Forms.ImageList(this.components); this.m_ctxPwList = new System.Windows.Forms.ContextMenuStrip(this.components); this.m_ctxEntryCopyUserName = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryCopyPassword = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryUrl = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryOpenUrl = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryCopyUrl = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryUrlSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_ctxEntryUrlOpenInInternal = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryCopyCustomString = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryAttachments = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntrySaveAttachedFiles = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntrySep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_ctxEntryPerformAutoType = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntrySep1 = new System.Windows.Forms.ToolStripSeparator(); this.m_ctxEntryAdd = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryEdit = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryDuplicate = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryDelete = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryMassModify = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntrySetColor = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryColorStandard = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryColorSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_ctxEntryColorLightRed = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryColorLightGreen = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryColorLightBlue = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryColorLightYellow = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryColorSep1 = new System.Windows.Forms.ToolStripSeparator(); this.m_ctxEntryColorCustom = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryMassSetIcon = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntrySelectedSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_ctxEntrySelectedAddTag = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntrySelectedNewTag = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntrySelectedRemoveTag = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntrySelectedSep1 = new System.Windows.Forms.ToolStripSeparator(); this.m_ctxEntrySelectedPrint = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntrySelectedExport = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntrySelectAll = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntrySep2 = new System.Windows.Forms.ToolStripSeparator(); this.m_ctxEntryClipboard = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryClipCopy = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryClipPaste = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryRearrangePopup = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryMoveToTop = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryMoveOneUp = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryMoveOneDown = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxEntryMoveToBottom = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuMain = new KeePass.UI.CustomMenuStripEx(); this.m_menuFile = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileNew = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileOpen = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileOpenLocal = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileOpenUrl = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileRecent = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileClose = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuFileSave = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSaveAs = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSaveAsLocal = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSaveAsUrl = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSaveAsSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuFileSaveAsCopy = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSep1 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuFileDbSettings = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileChangeMasterKey = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSep2 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuFilePrint = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSep3 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuFileImport = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileExport = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSync = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSyncFile = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSyncUrl = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSyncSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuFileSyncRecent = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSep4 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuFileLock = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileExit = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuEdit = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuEditShowAllEntries = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuEditShowExpired = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuEditShowByTag = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuEditSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuEditFind = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuView = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuChangeLanguage = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuViewSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuViewShowToolBar = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuViewShowEntryView = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuViewWindowLayout = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuViewWindowsStacked = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuViewWindowsSideBySide = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuViewSep1 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuViewAlwaysOnTop = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuViewSep2 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuViewConfigColumns = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuViewSortBy = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuViewTanOptions = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuViewTanSimpleList = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuViewTanIndices = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuViewEntryListGrouping = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuViewSep3 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuViewShowEntriesOfSubGroups = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuTools = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuToolsPwGenerator = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuToolsGeneratePwList = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuToolsSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuToolsTanWizard = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuToolsDb = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuToolsDbMaintenance = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuToolsDbSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuToolsDbDelDupEntries = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuToolsDbDelEmptyGroups = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuToolsDbDelUnusedIcons = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuToolsSep1 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuToolsTriggers = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuToolsPlugins = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuToolsSep2 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuToolsOptions = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuHelp = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuHelpContents = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuHelpSelectSource = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuHelpSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuHelpWebsite = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuHelpDonate = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuHelpSep1 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuHelpCheckForUpdate = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuHelpSep2 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuHelpAbout = new System.Windows.Forms.ToolStripMenuItem(); this.m_toolMain = new KeePass.UI.CustomToolStripEx(); this.m_tbNewDatabase = new System.Windows.Forms.ToolStripButton(); this.m_tbOpenDatabase = new System.Windows.Forms.ToolStripButton(); this.m_tbSaveDatabase = new System.Windows.Forms.ToolStripButton(); this.m_tbSaveAll = new System.Windows.Forms.ToolStripButton(); this.m_tbSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_tbAddEntry = new System.Windows.Forms.ToolStripSplitButton(); this.m_tbAddEntryDefault = new System.Windows.Forms.ToolStripMenuItem(); this.m_tbSep1 = new System.Windows.Forms.ToolStripSeparator(); this.m_tbCopyUserName = new System.Windows.Forms.ToolStripButton(); this.m_tbCopyPassword = new System.Windows.Forms.ToolStripButton(); this.m_tbOpenUrl = new System.Windows.Forms.ToolStripSplitButton(); this.m_tbOpenUrlDefault = new System.Windows.Forms.ToolStripMenuItem(); this.m_tbCopyUrl = new System.Windows.Forms.ToolStripButton(); this.m_tbAutoType = new System.Windows.Forms.ToolStripButton(); this.m_tbSep4 = new System.Windows.Forms.ToolStripSeparator(); this.m_tbFind = new System.Windows.Forms.ToolStripButton(); this.m_tbEntryViewsDropDown = new System.Windows.Forms.ToolStripDropDownButton(); this.m_tbViewsShowAll = new System.Windows.Forms.ToolStripMenuItem(); this.m_tbViewsShowExpired = new System.Windows.Forms.ToolStripMenuItem(); this.m_tbSep2 = new System.Windows.Forms.ToolStripSeparator(); this.m_tbLockWorkspace = new System.Windows.Forms.ToolStripButton(); this.m_tbSep3 = new System.Windows.Forms.ToolStripSeparator(); this.m_tbQuickFind = new System.Windows.Forms.ToolStripComboBox(); this.m_tbCloseTab = new System.Windows.Forms.ToolStripButton(); this.m_statusMain = new System.Windows.Forms.StatusStrip(); this.m_statusPartSelected = new System.Windows.Forms.ToolStripStatusLabel(); this.m_statusPartInfo = new System.Windows.Forms.ToolStripStatusLabel(); this.m_statusPartProgress = new System.Windows.Forms.ToolStripProgressBar(); this.m_statusClipboard = new System.Windows.Forms.ToolStripProgressBar(); this.m_ctxTray = new System.Windows.Forms.ContextMenuStrip(this.components); this.m_ctxTrayTray = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxTraySep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_ctxTrayGenPw = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxTraySep1 = new System.Windows.Forms.ToolStripSeparator(); this.m_ctxTrayOptions = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxTraySep2 = new System.Windows.Forms.ToolStripSeparator(); this.m_ctxTrayLock = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxTrayFileExit = new System.Windows.Forms.ToolStripMenuItem(); this.m_timerMain = new System.Windows.Forms.Timer(this.components); this.m_tabMain = new System.Windows.Forms.TabControl(); this.m_splitHorizontal = new KeePass.UI.CustomSplitContainerEx(); this.m_splitVertical = new KeePass.UI.CustomSplitContainerEx(); this.m_tvGroups = new KeePass.UI.CustomTreeViewEx(); this.m_lvEntries = new KeePass.UI.CustomListViewEx(); this.m_richEntryView = new KeePass.UI.CustomRichTextBoxEx(); this.m_menuToolsDbSep1 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuToolsDbXmlRep = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxGroupList.SuspendLayout(); this.m_ctxPwList.SuspendLayout(); this.m_menuMain.SuspendLayout(); this.m_toolMain.SuspendLayout(); this.m_statusMain.SuspendLayout(); this.m_ctxTray.SuspendLayout(); this.m_splitHorizontal.Panel1.SuspendLayout(); this.m_splitHorizontal.Panel2.SuspendLayout(); this.m_splitHorizontal.SuspendLayout(); this.m_splitVertical.Panel1.SuspendLayout(); this.m_splitVertical.Panel2.SuspendLayout(); this.m_splitVertical.SuspendLayout(); this.SuspendLayout(); // // m_ctxGroupList // this.m_ctxGroupList.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_ctxGroupAdd, this.m_ctxGroupSep0, this.m_ctxGroupEdit, this.m_ctxGroupDuplicate, this.m_ctxGroupDelete, this.m_ctxGroupEmpty, this.m_ctxGroupSep1, this.m_ctxGroupFind, this.m_ctxGroupSep2, this.m_ctxGroupPrint, this.m_ctxGroupExport, this.m_ctxGroupSep3, this.m_ctxGroupRearrange}); this.m_ctxGroupList.Name = "m_ctxGroupList"; this.m_ctxGroupList.Size = new System.Drawing.Size(180, 226); this.m_ctxGroupList.Opening += new System.ComponentModel.CancelEventHandler(this.OnCtxGroupListOpening); // // m_ctxGroupAdd // this.m_ctxGroupAdd.Image = global::KeePass.Properties.Resources.B16x16_Folder_Sent_Mail; this.m_ctxGroupAdd.Name = "m_ctxGroupAdd"; this.m_ctxGroupAdd.Size = new System.Drawing.Size(179, 22); this.m_ctxGroupAdd.Text = "Add &Group"; this.m_ctxGroupAdd.Click += new System.EventHandler(this.OnGroupsAdd); // // m_ctxGroupSep0 // this.m_ctxGroupSep0.Name = "m_ctxGroupSep0"; this.m_ctxGroupSep0.Size = new System.Drawing.Size(176, 6); // // m_ctxGroupEdit // this.m_ctxGroupEdit.Image = global::KeePass.Properties.Resources.B16x16_Folder_Txt; this.m_ctxGroupEdit.Name = "m_ctxGroupEdit"; this.m_ctxGroupEdit.Size = new System.Drawing.Size(179, 22); this.m_ctxGroupEdit.Text = "Ed&it Group"; this.m_ctxGroupEdit.Click += new System.EventHandler(this.OnGroupsEdit); // // m_ctxGroupDuplicate // this.m_ctxGroupDuplicate.Image = global::KeePass.Properties.Resources.B16x16_Folder_2; this.m_ctxGroupDuplicate.Name = "m_ctxGroupDuplicate"; this.m_ctxGroupDuplicate.Size = new System.Drawing.Size(179, 22); this.m_ctxGroupDuplicate.Text = "Dupli&cate Group"; this.m_ctxGroupDuplicate.Click += new System.EventHandler(this.OnGroupsDuplicate); // // m_ctxGroupDelete // this.m_ctxGroupDelete.Image = global::KeePass.Properties.Resources.B16x16_Folder_Locked; this.m_ctxGroupDelete.Name = "m_ctxGroupDelete"; this.m_ctxGroupDelete.Size = new System.Drawing.Size(179, 22); this.m_ctxGroupDelete.Text = "Dele&te Group"; this.m_ctxGroupDelete.Click += new System.EventHandler(this.OnGroupsDelete); // // m_ctxGroupEmpty // this.m_ctxGroupEmpty.Image = global::KeePass.Properties.Resources.B16x16_Trashcan_Full; this.m_ctxGroupEmpty.Name = "m_ctxGroupEmpty"; this.m_ctxGroupEmpty.Size = new System.Drawing.Size(179, 22); this.m_ctxGroupEmpty.Text = "Empty Recycle &Bin"; this.m_ctxGroupEmpty.Click += new System.EventHandler(this.OnGroupsEmpty); // // m_ctxGroupSep1 // this.m_ctxGroupSep1.Name = "m_ctxGroupSep1"; this.m_ctxGroupSep1.Size = new System.Drawing.Size(176, 6); // // m_ctxGroupFind // this.m_ctxGroupFind.Image = global::KeePass.Properties.Resources.B16x16_XMag; this.m_ctxGroupFind.Name = "m_ctxGroupFind"; this.m_ctxGroupFind.Size = new System.Drawing.Size(179, 22); this.m_ctxGroupFind.Text = "&Find in this Group..."; this.m_ctxGroupFind.Click += new System.EventHandler(this.OnGroupsFind); // // m_ctxGroupSep2 // this.m_ctxGroupSep2.Name = "m_ctxGroupSep2"; this.m_ctxGroupSep2.Size = new System.Drawing.Size(176, 6); // // m_ctxGroupPrint // this.m_ctxGroupPrint.Image = global::KeePass.Properties.Resources.B16x16_FilePrint; this.m_ctxGroupPrint.Name = "m_ctxGroupPrint"; this.m_ctxGroupPrint.Size = new System.Drawing.Size(179, 22); this.m_ctxGroupPrint.Text = "&Print Group..."; this.m_ctxGroupPrint.Click += new System.EventHandler(this.OnGroupsPrint); // // m_ctxGroupExport // this.m_ctxGroupExport.Image = global::KeePass.Properties.Resources.B16x16_Folder_Outbox; this.m_ctxGroupExport.Name = "m_ctxGroupExport"; this.m_ctxGroupExport.Size = new System.Drawing.Size(179, 22); this.m_ctxGroupExport.Text = "&Export..."; this.m_ctxGroupExport.Click += new System.EventHandler(this.OnGroupsExport); // // m_ctxGroupSep3 // this.m_ctxGroupSep3.Name = "m_ctxGroupSep3"; this.m_ctxGroupSep3.Size = new System.Drawing.Size(176, 6); // // m_ctxGroupRearrange // this.m_ctxGroupRearrange.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_ctxGroupMoveToTop, this.m_ctxGroupMoveOneUp, this.m_ctxGroupMoveOneDown, this.m_ctxGroupMoveToBottom, this.m_ctxGroupRearrSep0, this.m_ctxGroupSort, this.m_ctxGroupSortRec}); this.m_ctxGroupRearrange.Name = "m_ctxGroupRearrange"; this.m_ctxGroupRearrange.Size = new System.Drawing.Size(179, 22); this.m_ctxGroupRearrange.Text = "&Rearrange"; // // m_ctxGroupMoveToTop // this.m_ctxGroupMoveToTop.Image = global::KeePass.Properties.Resources.B16x16_2UpArrow; this.m_ctxGroupMoveToTop.Name = "m_ctxGroupMoveToTop"; this.m_ctxGroupMoveToTop.Size = new System.Drawing.Size(202, 22); this.m_ctxGroupMoveToTop.Text = "Move Group to &Top"; this.m_ctxGroupMoveToTop.Click += new System.EventHandler(this.OnGroupsMoveToTop); // // m_ctxGroupMoveOneUp // this.m_ctxGroupMoveOneUp.Image = global::KeePass.Properties.Resources.B16x16_1UpArrow; this.m_ctxGroupMoveOneUp.Name = "m_ctxGroupMoveOneUp"; this.m_ctxGroupMoveOneUp.Size = new System.Drawing.Size(202, 22); this.m_ctxGroupMoveOneUp.Text = "Move Group &One Up"; this.m_ctxGroupMoveOneUp.Click += new System.EventHandler(this.OnGroupsMoveOneUp); // // m_ctxGroupMoveOneDown // this.m_ctxGroupMoveOneDown.Image = global::KeePass.Properties.Resources.B16x16_1DownArrow; this.m_ctxGroupMoveOneDown.Name = "m_ctxGroupMoveOneDown"; this.m_ctxGroupMoveOneDown.Size = new System.Drawing.Size(202, 22); this.m_ctxGroupMoveOneDown.Text = "Mo&ve Group One Down"; this.m_ctxGroupMoveOneDown.Click += new System.EventHandler(this.OnGroupsMoveOneDown); // // m_ctxGroupMoveToBottom // this.m_ctxGroupMoveToBottom.Image = global::KeePass.Properties.Resources.B16x16_2DownArrow; this.m_ctxGroupMoveToBottom.Name = "m_ctxGroupMoveToBottom"; this.m_ctxGroupMoveToBottom.Size = new System.Drawing.Size(202, 22); this.m_ctxGroupMoveToBottom.Text = "Move Group to &Bottom"; this.m_ctxGroupMoveToBottom.Click += new System.EventHandler(this.OnGroupsMoveToBottom); // // m_ctxGroupRearrSep0 // this.m_ctxGroupRearrSep0.Name = "m_ctxGroupRearrSep0"; this.m_ctxGroupRearrSep0.Size = new System.Drawing.Size(199, 6); // // m_ctxGroupSort // this.m_ctxGroupSort.Image = global::KeePass.Properties.Resources.B16x16_KaboodleLoop; this.m_ctxGroupSort.Name = "m_ctxGroupSort"; this.m_ctxGroupSort.Size = new System.Drawing.Size(202, 22); this.m_ctxGroupSort.Text = "&Sort Direct Subgroups"; this.m_ctxGroupSort.Click += new System.EventHandler(this.OnGroupsSort); // // m_ctxGroupSortRec // this.m_ctxGroupSortRec.Image = global::KeePass.Properties.Resources.B16x16_KaboodleLoop; this.m_ctxGroupSortRec.Name = "m_ctxGroupSortRec"; this.m_ctxGroupSortRec.Size = new System.Drawing.Size(202, 22); this.m_ctxGroupSortRec.Text = "So&rt Subgroup Tree"; this.m_ctxGroupSortRec.Click += new System.EventHandler(this.OnGroupsSortRec); // // m_ilClientIcons // this.m_ilClientIcons.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("m_ilClientIcons.ImageStream"))); this.m_ilClientIcons.TransparentColor = System.Drawing.Color.Transparent; this.m_ilClientIcons.Images.SetKeyName(0, "C00_Password.png"); this.m_ilClientIcons.Images.SetKeyName(1, "C01_Package_Network.png"); this.m_ilClientIcons.Images.SetKeyName(2, "C02_MessageBox_Warning.png"); this.m_ilClientIcons.Images.SetKeyName(3, "C03_Server.png"); this.m_ilClientIcons.Images.SetKeyName(4, "C04_Klipper.png"); this.m_ilClientIcons.Images.SetKeyName(5, "C05_Edu_Languages.png"); this.m_ilClientIcons.Images.SetKeyName(6, "C06_KCMDF.png"); this.m_ilClientIcons.Images.SetKeyName(7, "C07_Kate.png"); this.m_ilClientIcons.Images.SetKeyName(8, "C08_Socket.png"); this.m_ilClientIcons.Images.SetKeyName(9, "C09_Identity.png"); this.m_ilClientIcons.Images.SetKeyName(10, "C10_Kontact.png"); this.m_ilClientIcons.Images.SetKeyName(11, "C11_Camera.png"); this.m_ilClientIcons.Images.SetKeyName(12, "C12_IRKickFlash.png"); this.m_ilClientIcons.Images.SetKeyName(13, "C13_KGPG_Key3.png"); this.m_ilClientIcons.Images.SetKeyName(14, "C14_Laptop_Power.png"); this.m_ilClientIcons.Images.SetKeyName(15, "C15_Scanner.png"); this.m_ilClientIcons.Images.SetKeyName(16, "C16_Mozilla_Firebird.png"); this.m_ilClientIcons.Images.SetKeyName(17, "C17_CDROM_Unmount.png"); this.m_ilClientIcons.Images.SetKeyName(18, "C18_Display.png"); this.m_ilClientIcons.Images.SetKeyName(19, "C19_Mail_Generic.png"); this.m_ilClientIcons.Images.SetKeyName(20, "C20_Misc.png"); this.m_ilClientIcons.Images.SetKeyName(21, "C21_KOrganizer.png"); this.m_ilClientIcons.Images.SetKeyName(22, "C22_ASCII.png"); this.m_ilClientIcons.Images.SetKeyName(23, "C23_Icons.png"); this.m_ilClientIcons.Images.SetKeyName(24, "C24_Connect_Established.png"); this.m_ilClientIcons.Images.SetKeyName(25, "C25_Folder_Mail.png"); this.m_ilClientIcons.Images.SetKeyName(26, "C26_FileSave.png"); this.m_ilClientIcons.Images.SetKeyName(27, "C27_NFS_Unmount.png"); this.m_ilClientIcons.Images.SetKeyName(28, "C28_QuickTime.png"); this.m_ilClientIcons.Images.SetKeyName(29, "C29_KGPG_Term.png"); this.m_ilClientIcons.Images.SetKeyName(30, "C30_Konsole.png"); this.m_ilClientIcons.Images.SetKeyName(31, "C31_FilePrint.png"); this.m_ilClientIcons.Images.SetKeyName(32, "C32_FSView.png"); this.m_ilClientIcons.Images.SetKeyName(33, "C33_Run.png"); this.m_ilClientIcons.Images.SetKeyName(34, "C34_Configure.png"); this.m_ilClientIcons.Images.SetKeyName(35, "C35_KRFB.png"); this.m_ilClientIcons.Images.SetKeyName(36, "C36_Ark.png"); this.m_ilClientIcons.Images.SetKeyName(37, "C37_KPercentage.png"); this.m_ilClientIcons.Images.SetKeyName(38, "C38_Samba_Unmount.png"); this.m_ilClientIcons.Images.SetKeyName(39, "C39_History.png"); this.m_ilClientIcons.Images.SetKeyName(40, "C40_Mail_Find.png"); this.m_ilClientIcons.Images.SetKeyName(41, "C41_VectorGfx.png"); this.m_ilClientIcons.Images.SetKeyName(42, "C42_KCMMemory.png"); this.m_ilClientIcons.Images.SetKeyName(43, "C43_EditTrash.png"); this.m_ilClientIcons.Images.SetKeyName(44, "C44_KNotes.png"); this.m_ilClientIcons.Images.SetKeyName(45, "C45_Cancel.png"); this.m_ilClientIcons.Images.SetKeyName(46, "C46_Help.png"); this.m_ilClientIcons.Images.SetKeyName(47, "C47_KPackage.png"); this.m_ilClientIcons.Images.SetKeyName(48, "C48_Folder.png"); this.m_ilClientIcons.Images.SetKeyName(49, "C49_Folder_Blue_Open.png"); this.m_ilClientIcons.Images.SetKeyName(50, "C50_Folder_Tar.png"); this.m_ilClientIcons.Images.SetKeyName(51, "C51_Decrypted.png"); this.m_ilClientIcons.Images.SetKeyName(52, "C52_Encrypted.png"); this.m_ilClientIcons.Images.SetKeyName(53, "C53_Apply.png"); this.m_ilClientIcons.Images.SetKeyName(54, "C54_Signature.png"); this.m_ilClientIcons.Images.SetKeyName(55, "C55_Thumbnail.png"); this.m_ilClientIcons.Images.SetKeyName(56, "C56_KAddressBook.png"); this.m_ilClientIcons.Images.SetKeyName(57, "C57_View_Text.png"); this.m_ilClientIcons.Images.SetKeyName(58, "C58_KGPG.png"); this.m_ilClientIcons.Images.SetKeyName(59, "C59_Package_Development.png"); this.m_ilClientIcons.Images.SetKeyName(60, "C60_KFM_Home.png"); this.m_ilClientIcons.Images.SetKeyName(61, "C61_Services.png"); this.m_ilClientIcons.Images.SetKeyName(62, "C62_Tux.png"); this.m_ilClientIcons.Images.SetKeyName(63, "C63_Feather.png"); this.m_ilClientIcons.Images.SetKeyName(64, "C64_Apple.png"); this.m_ilClientIcons.Images.SetKeyName(65, "C65_W.png"); this.m_ilClientIcons.Images.SetKeyName(66, "C66_Money.png"); this.m_ilClientIcons.Images.SetKeyName(67, "C67_Certificate.png"); this.m_ilClientIcons.Images.SetKeyName(68, "C68_BlackBerry.png"); // // m_ctxPwList // this.m_ctxPwList.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_ctxEntryCopyUserName, this.m_ctxEntryCopyPassword, this.m_ctxEntryUrl, this.m_ctxEntryCopyCustomString, this.m_ctxEntryAttachments, this.m_ctxEntrySaveAttachedFiles, this.m_ctxEntrySep0, this.m_ctxEntryPerformAutoType, this.m_ctxEntrySep1, this.m_ctxEntryAdd, this.m_ctxEntryEdit, this.m_ctxEntryDuplicate, this.m_ctxEntryDelete, this.m_ctxEntryMassModify, this.m_ctxEntrySelectAll, this.m_ctxEntrySep2, this.m_ctxEntryClipboard, this.m_ctxEntryRearrangePopup}); this.m_ctxPwList.Name = "m_ctxPwList"; this.m_ctxPwList.Size = new System.Drawing.Size(215, 352); this.m_ctxPwList.Opening += new System.ComponentModel.CancelEventHandler(this.OnCtxPwListOpening); // // m_ctxEntryCopyUserName // this.m_ctxEntryCopyUserName.Image = global::KeePass.Properties.Resources.B16x16_Personal; this.m_ctxEntryCopyUserName.Name = "m_ctxEntryCopyUserName"; this.m_ctxEntryCopyUserName.Size = new System.Drawing.Size(214, 22); this.m_ctxEntryCopyUserName.Text = "Copy User &Name"; this.m_ctxEntryCopyUserName.Click += new System.EventHandler(this.OnEntryCopyUserName); // // m_ctxEntryCopyPassword // this.m_ctxEntryCopyPassword.Image = global::KeePass.Properties.Resources.B16x16_KGPG_Info; this.m_ctxEntryCopyPassword.Name = "m_ctxEntryCopyPassword"; this.m_ctxEntryCopyPassword.Size = new System.Drawing.Size(214, 22); this.m_ctxEntryCopyPassword.Text = ""; this.m_ctxEntryCopyPassword.Click += new System.EventHandler(this.OnEntryCopyPassword); // // m_ctxEntryUrl // this.m_ctxEntryUrl.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_ctxEntryOpenUrl, this.m_ctxEntryCopyUrl, this.m_ctxEntryUrlSep0, this.m_ctxEntryUrlOpenInInternal}); this.m_ctxEntryUrl.Name = "m_ctxEntryUrl"; this.m_ctxEntryUrl.Size = new System.Drawing.Size(214, 22); this.m_ctxEntryUrl.Text = "&URL(s)"; // // m_ctxEntryOpenUrl // this.m_ctxEntryOpenUrl.Image = global::KeePass.Properties.Resources.B16x16_FTP; this.m_ctxEntryOpenUrl.Name = "m_ctxEntryOpenUrl"; this.m_ctxEntryOpenUrl.Size = new System.Drawing.Size(209, 22); this.m_ctxEntryOpenUrl.Text = "<>"; this.m_ctxEntryOpenUrl.Click += new System.EventHandler(this.OnEntryOpenUrl); // // m_ctxEntryCopyUrl // this.m_ctxEntryCopyUrl.Image = global::KeePass.Properties.Resources.B16x16_EditCopyUrl; this.m_ctxEntryCopyUrl.Name = "m_ctxEntryCopyUrl"; this.m_ctxEntryCopyUrl.Size = new System.Drawing.Size(209, 22); this.m_ctxEntryCopyUrl.Text = "&Copy to Clipboard"; this.m_ctxEntryCopyUrl.Click += new System.EventHandler(this.OnEntryCopyURL); // // m_ctxEntryUrlSep0 // this.m_ctxEntryUrlSep0.Name = "m_ctxEntryUrlSep0"; this.m_ctxEntryUrlSep0.Size = new System.Drawing.Size(206, 6); this.m_ctxEntryUrlSep0.Visible = false; // // m_ctxEntryUrlOpenInInternal // this.m_ctxEntryUrlOpenInInternal.Image = global::KeePass.Properties.Resources.B16x16_Browser; this.m_ctxEntryUrlOpenInInternal.Name = "m_ctxEntryUrlOpenInInternal"; this.m_ctxEntryUrlOpenInInternal.Size = new System.Drawing.Size(209, 22); this.m_ctxEntryUrlOpenInInternal.Text = "Open in Internal Browser"; this.m_ctxEntryUrlOpenInInternal.Visible = false; this.m_ctxEntryUrlOpenInInternal.Click += new System.EventHandler(this.OnEntryUrlOpenInInternal); // // m_ctxEntryCopyCustomString // this.m_ctxEntryCopyCustomString.Name = "m_ctxEntryCopyCustomString"; this.m_ctxEntryCopyCustomString.Size = new System.Drawing.Size(214, 22); this.m_ctxEntryCopyCustomString.Text = "Copy Custom &String"; // // m_ctxEntryAttachments // this.m_ctxEntryAttachments.Name = "m_ctxEntryAttachments"; this.m_ctxEntryAttachments.Size = new System.Drawing.Size(214, 22); this.m_ctxEntryAttachments.Text = "Attach&ments"; // // m_ctxEntrySaveAttachedFiles // this.m_ctxEntrySaveAttachedFiles.Image = global::KeePass.Properties.Resources.B16x16_Attach; this.m_ctxEntrySaveAttachedFiles.Name = "m_ctxEntrySaveAttachedFiles"; this.m_ctxEntrySaveAttachedFiles.Size = new System.Drawing.Size(214, 22); this.m_ctxEntrySaveAttachedFiles.Text = "Save Attached &File(s) To..."; this.m_ctxEntrySaveAttachedFiles.Click += new System.EventHandler(this.OnEntrySaveAttachments); // // m_ctxEntrySep0 // this.m_ctxEntrySep0.Name = "m_ctxEntrySep0"; this.m_ctxEntrySep0.Size = new System.Drawing.Size(211, 6); // // m_ctxEntryPerformAutoType // this.m_ctxEntryPerformAutoType.Image = global::KeePass.Properties.Resources.B16x16_KTouch; this.m_ctxEntryPerformAutoType.Name = "m_ctxEntryPerformAutoType"; this.m_ctxEntryPerformAutoType.Size = new System.Drawing.Size(214, 22); this.m_ctxEntryPerformAutoType.Text = "Perform Auto-&Type"; this.m_ctxEntryPerformAutoType.Click += new System.EventHandler(this.OnEntryPerformAutoType); // // m_ctxEntrySep1 // this.m_ctxEntrySep1.Name = "m_ctxEntrySep1"; this.m_ctxEntrySep1.Size = new System.Drawing.Size(211, 6); // // m_ctxEntryAdd // this.m_ctxEntryAdd.Image = global::KeePass.Properties.Resources.B16x16_KGPG_Import; this.m_ctxEntryAdd.Name = "m_ctxEntryAdd"; this.m_ctxEntryAdd.Size = new System.Drawing.Size(214, 22); this.m_ctxEntryAdd.Text = "&Add Entry..."; this.m_ctxEntryAdd.Click += new System.EventHandler(this.OnEntryAdd); // // m_ctxEntryEdit // this.m_ctxEntryEdit.Image = global::KeePass.Properties.Resources.B16x16_KGPG_Sign; this.m_ctxEntryEdit.Name = "m_ctxEntryEdit"; this.m_ctxEntryEdit.Size = new System.Drawing.Size(214, 22); this.m_ctxEntryEdit.Text = "&Edit/View Entry..."; this.m_ctxEntryEdit.Click += new System.EventHandler(this.OnEntryEdit); // // m_ctxEntryDuplicate // this.m_ctxEntryDuplicate.Image = global::KeePass.Properties.Resources.B16x16_KGPG_Key2; this.m_ctxEntryDuplicate.Name = "m_ctxEntryDuplicate"; this.m_ctxEntryDuplicate.Size = new System.Drawing.Size(214, 22); this.m_ctxEntryDuplicate.Text = "Dupli&cate Entry"; this.m_ctxEntryDuplicate.Click += new System.EventHandler(this.OnEntryDuplicate); // // m_ctxEntryDelete // this.m_ctxEntryDelete.Image = global::KeePass.Properties.Resources.B16x16_DeleteEntry; this.m_ctxEntryDelete.Name = "m_ctxEntryDelete"; this.m_ctxEntryDelete.Size = new System.Drawing.Size(214, 22); this.m_ctxEntryDelete.Text = "&Delete Entry"; this.m_ctxEntryDelete.Click += new System.EventHandler(this.OnEntryDelete); // // m_ctxEntryMassModify // this.m_ctxEntryMassModify.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_ctxEntrySetColor, this.m_ctxEntryMassSetIcon, this.m_ctxEntrySelectedSep0, this.m_ctxEntrySelectedAddTag, this.m_ctxEntrySelectedRemoveTag, this.m_ctxEntrySelectedSep1, this.m_ctxEntrySelectedPrint, this.m_ctxEntrySelectedExport}); this.m_ctxEntryMassModify.Name = "m_ctxEntryMassModify"; this.m_ctxEntryMassModify.Size = new System.Drawing.Size(214, 22); this.m_ctxEntryMassModify.Text = "Selected Entr&ies"; // // m_ctxEntrySetColor // this.m_ctxEntrySetColor.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_ctxEntryColorStandard, this.m_ctxEntryColorSep0, this.m_ctxEntryColorLightRed, this.m_ctxEntryColorLightGreen, this.m_ctxEntryColorLightBlue, this.m_ctxEntryColorLightYellow, this.m_ctxEntryColorSep1, this.m_ctxEntryColorCustom}); this.m_ctxEntrySetColor.Name = "m_ctxEntrySetColor"; this.m_ctxEntrySetColor.Size = new System.Drawing.Size(144, 22); this.m_ctxEntrySetColor.Text = "Set &Color"; // // m_ctxEntryColorStandard // this.m_ctxEntryColorStandard.Name = "m_ctxEntryColorStandard"; this.m_ctxEntryColorStandard.Size = new System.Drawing.Size(202, 22); this.m_ctxEntryColorStandard.Text = "&Standard"; this.m_ctxEntryColorStandard.Click += new System.EventHandler(this.OnEntryColorStandard); // // m_ctxEntryColorSep0 // this.m_ctxEntryColorSep0.Name = "m_ctxEntryColorSep0"; this.m_ctxEntryColorSep0.Size = new System.Drawing.Size(199, 6); // // m_ctxEntryColorLightRed // this.m_ctxEntryColorLightRed.Name = "m_ctxEntryColorLightRed"; this.m_ctxEntryColorLightRed.Size = new System.Drawing.Size(202, 22); this.m_ctxEntryColorLightRed.Text = "Light &Red"; this.m_ctxEntryColorLightRed.Click += new System.EventHandler(this.OnEntryColorLightRed); // // m_ctxEntryColorLightGreen // this.m_ctxEntryColorLightGreen.Name = "m_ctxEntryColorLightGreen"; this.m_ctxEntryColorLightGreen.Size = new System.Drawing.Size(202, 22); this.m_ctxEntryColorLightGreen.Text = "Light &Green"; this.m_ctxEntryColorLightGreen.Click += new System.EventHandler(this.OnEntryColorLightGreen); // // m_ctxEntryColorLightBlue // this.m_ctxEntryColorLightBlue.Name = "m_ctxEntryColorLightBlue"; this.m_ctxEntryColorLightBlue.Size = new System.Drawing.Size(202, 22); this.m_ctxEntryColorLightBlue.Text = "Light &Blue"; this.m_ctxEntryColorLightBlue.Click += new System.EventHandler(this.OnEntryColorLightBlue); // // m_ctxEntryColorLightYellow // this.m_ctxEntryColorLightYellow.Name = "m_ctxEntryColorLightYellow"; this.m_ctxEntryColorLightYellow.Size = new System.Drawing.Size(202, 22); this.m_ctxEntryColorLightYellow.Text = "Light &Yellow"; this.m_ctxEntryColorLightYellow.Click += new System.EventHandler(this.OnEntryColorLightYellow); // // m_ctxEntryColorSep1 // this.m_ctxEntryColorSep1.Name = "m_ctxEntryColorSep1"; this.m_ctxEntryColorSep1.Size = new System.Drawing.Size(199, 6); // // m_ctxEntryColorCustom // this.m_ctxEntryColorCustom.Name = "m_ctxEntryColorCustom"; this.m_ctxEntryColorCustom.Size = new System.Drawing.Size(202, 22); this.m_ctxEntryColorCustom.Text = "&Choose Custom Color..."; this.m_ctxEntryColorCustom.Click += new System.EventHandler(this.OnEntryColorCustom); // // m_ctxEntryMassSetIcon // this.m_ctxEntryMassSetIcon.Image = global::KeePass.Properties.Resources.B16x16_Spreadsheet; this.m_ctxEntryMassSetIcon.Name = "m_ctxEntryMassSetIcon"; this.m_ctxEntryMassSetIcon.Size = new System.Drawing.Size(144, 22); this.m_ctxEntryMassSetIcon.Text = "Set &Icons..."; this.m_ctxEntryMassSetIcon.Click += new System.EventHandler(this.OnEntryMassSetIcon); // // m_ctxEntrySelectedSep0 // this.m_ctxEntrySelectedSep0.Name = "m_ctxEntrySelectedSep0"; this.m_ctxEntrySelectedSep0.Size = new System.Drawing.Size(141, 6); // // m_ctxEntrySelectedAddTag // this.m_ctxEntrySelectedAddTag.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_ctxEntrySelectedNewTag}); this.m_ctxEntrySelectedAddTag.Name = "m_ctxEntrySelectedAddTag"; this.m_ctxEntrySelectedAddTag.Size = new System.Drawing.Size(144, 22); this.m_ctxEntrySelectedAddTag.Text = "Add &Tag"; this.m_ctxEntrySelectedAddTag.DropDownOpening += new System.EventHandler(this.OnEntrySelectedAddTagOpening); // // m_ctxEntrySelectedNewTag // this.m_ctxEntrySelectedNewTag.Image = global::KeePass.Properties.Resources.B16x16_KNotes; this.m_ctxEntrySelectedNewTag.Name = "m_ctxEntrySelectedNewTag"; this.m_ctxEntrySelectedNewTag.Size = new System.Drawing.Size(132, 22); this.m_ctxEntrySelectedNewTag.Text = "&New Tag..."; this.m_ctxEntrySelectedNewTag.Click += new System.EventHandler(this.OnEntrySelectedNewTag); // // m_ctxEntrySelectedRemoveTag // this.m_ctxEntrySelectedRemoveTag.Name = "m_ctxEntrySelectedRemoveTag"; this.m_ctxEntrySelectedRemoveTag.Size = new System.Drawing.Size(144, 22); this.m_ctxEntrySelectedRemoveTag.Text = "&Remove Tag"; this.m_ctxEntrySelectedRemoveTag.DropDownOpening += new System.EventHandler(this.OnEntrySelectedRemoveTagOpening); // // m_ctxEntrySelectedSep1 // this.m_ctxEntrySelectedSep1.Name = "m_ctxEntrySelectedSep1"; this.m_ctxEntrySelectedSep1.Size = new System.Drawing.Size(141, 6); // // m_ctxEntrySelectedPrint // this.m_ctxEntrySelectedPrint.Image = global::KeePass.Properties.Resources.B16x16_FilePrint; this.m_ctxEntrySelectedPrint.Name = "m_ctxEntrySelectedPrint"; this.m_ctxEntrySelectedPrint.Size = new System.Drawing.Size(144, 22); this.m_ctxEntrySelectedPrint.Text = "&Print..."; this.m_ctxEntrySelectedPrint.Click += new System.EventHandler(this.OnEntrySelectedPrint); // // m_ctxEntrySelectedExport // this.m_ctxEntrySelectedExport.Image = global::KeePass.Properties.Resources.B16x16_Folder_Outbox; this.m_ctxEntrySelectedExport.Name = "m_ctxEntrySelectedExport"; this.m_ctxEntrySelectedExport.Size = new System.Drawing.Size(144, 22); this.m_ctxEntrySelectedExport.Text = "&Export..."; this.m_ctxEntrySelectedExport.Click += new System.EventHandler(this.OnEntrySelectedExport); // // m_ctxEntrySelectAll // this.m_ctxEntrySelectAll.Name = "m_ctxEntrySelectAll"; this.m_ctxEntrySelectAll.Size = new System.Drawing.Size(214, 22); this.m_ctxEntrySelectAll.Text = "Se&lect All"; this.m_ctxEntrySelectAll.Click += new System.EventHandler(this.OnEntrySelectAll); // // m_ctxEntrySep2 // this.m_ctxEntrySep2.Name = "m_ctxEntrySep2"; this.m_ctxEntrySep2.Size = new System.Drawing.Size(211, 6); // // m_ctxEntryClipboard // this.m_ctxEntryClipboard.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_ctxEntryClipCopy, this.m_ctxEntryClipPaste}); this.m_ctxEntryClipboard.Name = "m_ctxEntryClipboard"; this.m_ctxEntryClipboard.Size = new System.Drawing.Size(214, 22); this.m_ctxEntryClipboard.Text = "Clip&board"; this.m_ctxEntryClipboard.DropDownOpening += new System.EventHandler(this.OnCtxEntryClipboardOpening); // // m_ctxEntryClipCopy // this.m_ctxEntryClipCopy.Image = global::KeePass.Properties.Resources.B16x16_EditCopy; this.m_ctxEntryClipCopy.Name = "m_ctxEntryClipCopy"; this.m_ctxEntryClipCopy.Size = new System.Drawing.Size(146, 22); this.m_ctxEntryClipCopy.Text = "&Copy Entries"; this.m_ctxEntryClipCopy.Click += new System.EventHandler(this.OnEntryClipCopy); // // m_ctxEntryClipPaste // this.m_ctxEntryClipPaste.Image = global::KeePass.Properties.Resources.B16x16_EditPaste; this.m_ctxEntryClipPaste.Name = "m_ctxEntryClipPaste"; this.m_ctxEntryClipPaste.Size = new System.Drawing.Size(146, 22); this.m_ctxEntryClipPaste.Text = "&Paste Entries"; this.m_ctxEntryClipPaste.Click += new System.EventHandler(this.OnEntryClipPaste); // // m_ctxEntryRearrangePopup // this.m_ctxEntryRearrangePopup.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_ctxEntryMoveToTop, this.m_ctxEntryMoveOneUp, this.m_ctxEntryMoveOneDown, this.m_ctxEntryMoveToBottom}); this.m_ctxEntryRearrangePopup.Name = "m_ctxEntryRearrangePopup"; this.m_ctxEntryRearrangePopup.Size = new System.Drawing.Size(214, 22); this.m_ctxEntryRearrangePopup.Text = "&Rearrange"; // // m_ctxEntryMoveToTop // this.m_ctxEntryMoveToTop.Image = global::KeePass.Properties.Resources.B16x16_2UpArrow; this.m_ctxEntryMoveToTop.Name = "m_ctxEntryMoveToTop"; this.m_ctxEntryMoveToTop.Size = new System.Drawing.Size(195, 22); this.m_ctxEntryMoveToTop.Text = "Move Entry to &Top"; this.m_ctxEntryMoveToTop.Click += new System.EventHandler(this.OnEntryMoveToTop); // // m_ctxEntryMoveOneUp // this.m_ctxEntryMoveOneUp.Image = global::KeePass.Properties.Resources.B16x16_1UpArrow; this.m_ctxEntryMoveOneUp.Name = "m_ctxEntryMoveOneUp"; this.m_ctxEntryMoveOneUp.Size = new System.Drawing.Size(195, 22); this.m_ctxEntryMoveOneUp.Text = "Move Entry &One Up"; this.m_ctxEntryMoveOneUp.Click += new System.EventHandler(this.OnEntryMoveOneUp); // // m_ctxEntryMoveOneDown // this.m_ctxEntryMoveOneDown.Image = global::KeePass.Properties.Resources.B16x16_1DownArrow; this.m_ctxEntryMoveOneDown.Name = "m_ctxEntryMoveOneDown"; this.m_ctxEntryMoveOneDown.Size = new System.Drawing.Size(195, 22); this.m_ctxEntryMoveOneDown.Text = "Mo&ve Entry One Down"; this.m_ctxEntryMoveOneDown.Click += new System.EventHandler(this.OnEntryMoveOneDown); // // m_ctxEntryMoveToBottom // this.m_ctxEntryMoveToBottom.Image = global::KeePass.Properties.Resources.B16x16_2DownArrow; this.m_ctxEntryMoveToBottom.Name = "m_ctxEntryMoveToBottom"; this.m_ctxEntryMoveToBottom.Size = new System.Drawing.Size(195, 22); this.m_ctxEntryMoveToBottom.Text = "Move Entry to &Bottom"; this.m_ctxEntryMoveToBottom.Click += new System.EventHandler(this.OnEntryMoveToBottom); // // m_menuMain // this.m_menuMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuFile, this.m_menuEdit, this.m_menuView, this.m_menuTools, this.m_menuHelp}); this.m_menuMain.Location = new System.Drawing.Point(0, 0); this.m_menuMain.Name = "m_menuMain"; this.m_menuMain.Size = new System.Drawing.Size(654, 24); this.m_menuMain.TabIndex = 0; // // m_menuFile // this.m_menuFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuFileNew, this.m_menuFileOpen, this.m_menuFileRecent, this.m_menuFileClose, this.m_menuFileSep0, this.m_menuFileSave, this.m_menuFileSaveAs, this.m_menuFileSep1, this.m_menuFileDbSettings, this.m_menuFileChangeMasterKey, this.m_menuFileSep2, this.m_menuFilePrint, this.m_menuFileSep3, this.m_menuFileImport, this.m_menuFileExport, this.m_menuFileSync, this.m_menuFileSep4, this.m_menuFileLock, this.m_menuFileExit}); this.m_menuFile.Name = "m_menuFile"; this.m_menuFile.Size = new System.Drawing.Size(39, 20); this.m_menuFile.Text = "&File"; // // m_menuFileNew // this.m_menuFileNew.Image = global::KeePass.Properties.Resources.B16x16_FileNew; this.m_menuFileNew.Name = "m_menuFileNew"; this.m_menuFileNew.Size = new System.Drawing.Size(190, 22); this.m_menuFileNew.Text = "&New..."; this.m_menuFileNew.Click += new System.EventHandler(this.OnFileNew); // // m_menuFileOpen // this.m_menuFileOpen.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuFileOpenLocal, this.m_menuFileOpenUrl}); this.m_menuFileOpen.Name = "m_menuFileOpen"; this.m_menuFileOpen.Size = new System.Drawing.Size(190, 22); this.m_menuFileOpen.Text = "&Open"; // // m_menuFileOpenLocal // this.m_menuFileOpenLocal.Image = global::KeePass.Properties.Resources.B16x16_Folder_Yellow_Open; this.m_menuFileOpenLocal.Name = "m_menuFileOpenLocal"; this.m_menuFileOpenLocal.Size = new System.Drawing.Size(141, 22); this.m_menuFileOpenLocal.Text = "Open &File..."; this.m_menuFileOpenLocal.Click += new System.EventHandler(this.OnFileOpen); // // m_menuFileOpenUrl // this.m_menuFileOpenUrl.Image = global::KeePass.Properties.Resources.B16x16_Browser; this.m_menuFileOpenUrl.Name = "m_menuFileOpenUrl"; this.m_menuFileOpenUrl.Size = new System.Drawing.Size(141, 22); this.m_menuFileOpenUrl.Text = "Open &URL..."; this.m_menuFileOpenUrl.Click += new System.EventHandler(this.OnFileOpenUrl); // // m_menuFileRecent // this.m_menuFileRecent.Name = "m_menuFileRecent"; this.m_menuFileRecent.Size = new System.Drawing.Size(190, 22); this.m_menuFileRecent.Text = "Open &Recent"; // // m_menuFileClose // this.m_menuFileClose.Image = global::KeePass.Properties.Resources.B16x16_File_Close; this.m_menuFileClose.Name = "m_menuFileClose"; this.m_menuFileClose.Size = new System.Drawing.Size(190, 22); this.m_menuFileClose.Text = "&Close"; this.m_menuFileClose.Click += new System.EventHandler(this.OnFileClose); // // m_menuFileSep0 // this.m_menuFileSep0.Name = "m_menuFileSep0"; this.m_menuFileSep0.Size = new System.Drawing.Size(187, 6); // // m_menuFileSave // this.m_menuFileSave.Image = global::KeePass.Properties.Resources.B16x16_FileSave; this.m_menuFileSave.Name = "m_menuFileSave"; this.m_menuFileSave.Size = new System.Drawing.Size(190, 22); this.m_menuFileSave.Text = "&Save"; this.m_menuFileSave.Click += new System.EventHandler(this.OnFileSave); // // m_menuFileSaveAs // this.m_menuFileSaveAs.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuFileSaveAsLocal, this.m_menuFileSaveAsUrl, this.m_menuFileSaveAsSep0, this.m_menuFileSaveAsCopy}); this.m_menuFileSaveAs.Name = "m_menuFileSaveAs"; this.m_menuFileSaveAs.Size = new System.Drawing.Size(190, 22); this.m_menuFileSaveAs.Text = "Save &As"; // // m_menuFileSaveAsLocal // this.m_menuFileSaveAsLocal.Image = global::KeePass.Properties.Resources.B16x16_FileSaveAs; this.m_menuFileSaveAsLocal.Name = "m_menuFileSaveAsLocal"; this.m_menuFileSaveAsLocal.Size = new System.Drawing.Size(176, 22); this.m_menuFileSaveAsLocal.Text = "Save to &File..."; this.m_menuFileSaveAsLocal.Click += new System.EventHandler(this.OnFileSaveAs); // // m_menuFileSaveAsUrl // this.m_menuFileSaveAsUrl.Image = global::KeePass.Properties.Resources.B16x16_Browser; this.m_menuFileSaveAsUrl.Name = "m_menuFileSaveAsUrl"; this.m_menuFileSaveAsUrl.Size = new System.Drawing.Size(176, 22); this.m_menuFileSaveAsUrl.Text = "Save to &URL..."; this.m_menuFileSaveAsUrl.Click += new System.EventHandler(this.OnFileSaveAsUrl); // // m_menuFileSaveAsSep0 // this.m_menuFileSaveAsSep0.Name = "m_menuFileSaveAsSep0"; this.m_menuFileSaveAsSep0.Size = new System.Drawing.Size(173, 6); // // m_menuFileSaveAsCopy // this.m_menuFileSaveAsCopy.Image = global::KeePass.Properties.Resources.B16x16_FileSaveAs; this.m_menuFileSaveAsCopy.Name = "m_menuFileSaveAsCopy"; this.m_menuFileSaveAsCopy.Size = new System.Drawing.Size(176, 22); this.m_menuFileSaveAsCopy.Text = "Save &Copy to File..."; this.m_menuFileSaveAsCopy.Click += new System.EventHandler(this.OnFileSaveAsCopy); // // m_menuFileSep1 // this.m_menuFileSep1.Name = "m_menuFileSep1"; this.m_menuFileSep1.Size = new System.Drawing.Size(187, 6); // // m_menuFileDbSettings // this.m_menuFileDbSettings.Image = global::KeePass.Properties.Resources.B16x16_Package_Development; this.m_menuFileDbSettings.Name = "m_menuFileDbSettings"; this.m_menuFileDbSettings.Size = new System.Drawing.Size(190, 22); this.m_menuFileDbSettings.Text = "&Database Settings..."; this.m_menuFileDbSettings.Click += new System.EventHandler(this.OnFileDbSettings); // // m_menuFileChangeMasterKey // this.m_menuFileChangeMasterKey.Image = global::KeePass.Properties.Resources.B16x16_File_Locked; this.m_menuFileChangeMasterKey.Name = "m_menuFileChangeMasterKey"; this.m_menuFileChangeMasterKey.Size = new System.Drawing.Size(190, 22); this.m_menuFileChangeMasterKey.Text = "Change &Master Key..."; this.m_menuFileChangeMasterKey.Click += new System.EventHandler(this.OnFileChangeMasterKey); // // m_menuFileSep2 // this.m_menuFileSep2.Name = "m_menuFileSep2"; this.m_menuFileSep2.Size = new System.Drawing.Size(187, 6); // // m_menuFilePrint // this.m_menuFilePrint.Image = global::KeePass.Properties.Resources.B16x16_FilePrint; this.m_menuFilePrint.Name = "m_menuFilePrint"; this.m_menuFilePrint.Size = new System.Drawing.Size(190, 22); this.m_menuFilePrint.Text = "&Print..."; this.m_menuFilePrint.Click += new System.EventHandler(this.OnFilePrint); // // m_menuFileSep3 // this.m_menuFileSep3.Name = "m_menuFileSep3"; this.m_menuFileSep3.Size = new System.Drawing.Size(187, 6); // // m_menuFileImport // this.m_menuFileImport.Image = global::KeePass.Properties.Resources.B16x16_Folder_Inbox; this.m_menuFileImport.Name = "m_menuFileImport"; this.m_menuFileImport.Size = new System.Drawing.Size(190, 22); this.m_menuFileImport.Text = "&Import..."; this.m_menuFileImport.Click += new System.EventHandler(this.OnFileImport); // // m_menuFileExport // this.m_menuFileExport.Image = global::KeePass.Properties.Resources.B16x16_Folder_Outbox; this.m_menuFileExport.Name = "m_menuFileExport"; this.m_menuFileExport.Size = new System.Drawing.Size(190, 22); this.m_menuFileExport.Text = "&Export..."; this.m_menuFileExport.Click += new System.EventHandler(this.OnFileExport); // // m_menuFileSync // this.m_menuFileSync.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuFileSyncFile, this.m_menuFileSyncUrl, this.m_menuFileSyncSep0, this.m_menuFileSyncRecent}); this.m_menuFileSync.Name = "m_menuFileSync"; this.m_menuFileSync.Size = new System.Drawing.Size(190, 22); this.m_menuFileSync.Text = "S&ynchronize"; // // m_menuFileSyncFile // this.m_menuFileSyncFile.Image = global::KeePass.Properties.Resources.B16x16_Reload_Page; this.m_menuFileSyncFile.Name = "m_menuFileSyncFile"; this.m_menuFileSyncFile.Size = new System.Drawing.Size(203, 22); this.m_menuFileSyncFile.Text = "Synchronize with &File..."; this.m_menuFileSyncFile.Click += new System.EventHandler(this.OnFileSynchronize); // // m_menuFileSyncUrl // this.m_menuFileSyncUrl.Image = global::KeePass.Properties.Resources.B16x16_Reload_Page; this.m_menuFileSyncUrl.Name = "m_menuFileSyncUrl"; this.m_menuFileSyncUrl.Size = new System.Drawing.Size(203, 22); this.m_menuFileSyncUrl.Text = "Synchronize with &URL..."; this.m_menuFileSyncUrl.Click += new System.EventHandler(this.OnFileSynchronizeUrl); // // m_menuFileSyncSep0 // this.m_menuFileSyncSep0.Name = "m_menuFileSyncSep0"; this.m_menuFileSyncSep0.Size = new System.Drawing.Size(200, 6); // // m_menuFileSyncRecent // this.m_menuFileSyncRecent.Name = "m_menuFileSyncRecent"; this.m_menuFileSyncRecent.Size = new System.Drawing.Size(203, 22); this.m_menuFileSyncRecent.Text = "&Recent Files"; // // m_menuFileSep4 // this.m_menuFileSep4.Name = "m_menuFileSep4"; this.m_menuFileSep4.Size = new System.Drawing.Size(187, 6); // // m_menuFileLock // this.m_menuFileLock.Image = global::KeePass.Properties.Resources.B16x16_LockWorkspace; this.m_menuFileLock.Name = "m_menuFileLock"; this.m_menuFileLock.Size = new System.Drawing.Size(190, 22); this.m_menuFileLock.Text = "&Lock Workspace"; this.m_menuFileLock.Click += new System.EventHandler(this.OnFileLock); // // m_menuFileExit // this.m_menuFileExit.Image = global::KeePass.Properties.Resources.B16x16_Exit; this.m_menuFileExit.Name = "m_menuFileExit"; this.m_menuFileExit.Size = new System.Drawing.Size(190, 22); this.m_menuFileExit.Text = "E&xit"; this.m_menuFileExit.Click += new System.EventHandler(this.OnFileExit); // // m_menuEdit // this.m_menuEdit.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuEditShowAllEntries, this.m_menuEditShowExpired, this.m_menuEditShowByTag, this.m_menuEditSep0, this.m_menuEditFind}); this.m_menuEdit.Name = "m_menuEdit"; this.m_menuEdit.Size = new System.Drawing.Size(40, 20); this.m_menuEdit.Text = "&Edit"; this.m_menuEdit.DropDownOpening += new System.EventHandler(this.OnMenuEditOpening); // // m_menuEditShowAllEntries // this.m_menuEditShowAllEntries.Image = global::KeePass.Properties.Resources.B16x16_KGPG_Key3; this.m_menuEditShowAllEntries.Name = "m_menuEditShowAllEntries"; this.m_menuEditShowAllEntries.Size = new System.Drawing.Size(207, 22); this.m_menuEditShowAllEntries.Text = "&Show All Entries"; this.m_menuEditShowAllEntries.Click += new System.EventHandler(this.OnShowAllEntries); // // m_menuEditShowExpired // this.m_menuEditShowExpired.Image = global::KeePass.Properties.Resources.B16x16_History_Clear; this.m_menuEditShowExpired.Name = "m_menuEditShowExpired"; this.m_menuEditShowExpired.Size = new System.Drawing.Size(207, 22); this.m_menuEditShowExpired.Text = "Show All E&xpired Entries"; this.m_menuEditShowExpired.Click += new System.EventHandler(this.OnToolsShowExpired); // // m_menuEditShowByTag // this.m_menuEditShowByTag.Name = "m_menuEditShowByTag"; this.m_menuEditShowByTag.Size = new System.Drawing.Size(207, 22); this.m_menuEditShowByTag.Text = "Show Entries &by Tag"; this.m_menuEditShowByTag.DropDownOpening += new System.EventHandler(this.OnEditShowByTagOpening); // // m_menuEditSep0 // this.m_menuEditSep0.Name = "m_menuEditSep0"; this.m_menuEditSep0.Size = new System.Drawing.Size(204, 6); // // m_menuEditFind // this.m_menuEditFind.Image = global::KeePass.Properties.Resources.B16x16_XMag; this.m_menuEditFind.Name = "m_menuEditFind"; this.m_menuEditFind.Size = new System.Drawing.Size(207, 22); this.m_menuEditFind.Text = "&Find..."; this.m_menuEditFind.Click += new System.EventHandler(this.OnPwListFind); // // m_menuView // this.m_menuView.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuChangeLanguage, this.m_menuViewSep0, this.m_menuViewShowToolBar, this.m_menuViewShowEntryView, this.m_menuViewWindowLayout, this.m_menuViewSep1, this.m_menuViewAlwaysOnTop, this.m_menuViewSep2, this.m_menuViewConfigColumns, this.m_menuViewSortBy, this.m_menuViewTanOptions, this.m_menuViewEntryListGrouping, this.m_menuViewSep3, this.m_menuViewShowEntriesOfSubGroups}); this.m_menuView.Name = "m_menuView"; this.m_menuView.Size = new System.Drawing.Size(45, 20); this.m_menuView.Text = "&View"; // // m_menuChangeLanguage // this.m_menuChangeLanguage.Image = global::KeePass.Properties.Resources.B16x16_Keyboard_Layout; this.m_menuChangeLanguage.Name = "m_menuChangeLanguage"; this.m_menuChangeLanguage.Size = new System.Drawing.Size(222, 22); this.m_menuChangeLanguage.Text = "Change &Language..."; this.m_menuChangeLanguage.Click += new System.EventHandler(this.OnMenuChangeLanguage); // // m_menuViewSep0 // this.m_menuViewSep0.Name = "m_menuViewSep0"; this.m_menuViewSep0.Size = new System.Drawing.Size(219, 6); // // m_menuViewShowToolBar // this.m_menuViewShowToolBar.CheckOnClick = true; this.m_menuViewShowToolBar.Name = "m_menuViewShowToolBar"; this.m_menuViewShowToolBar.Size = new System.Drawing.Size(222, 22); this.m_menuViewShowToolBar.Text = "Show &Toolbar"; this.m_menuViewShowToolBar.Click += new System.EventHandler(this.OnViewShowToolBar); // // m_menuViewShowEntryView // this.m_menuViewShowEntryView.CheckOnClick = true; this.m_menuViewShowEntryView.Name = "m_menuViewShowEntryView"; this.m_menuViewShowEntryView.Size = new System.Drawing.Size(222, 22); this.m_menuViewShowEntryView.Text = "Show &Entry View"; this.m_menuViewShowEntryView.Click += new System.EventHandler(this.OnViewShowEntryView); // // m_menuViewWindowLayout // this.m_menuViewWindowLayout.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuViewWindowsStacked, this.m_menuViewWindowsSideBySide}); this.m_menuViewWindowLayout.Name = "m_menuViewWindowLayout"; this.m_menuViewWindowLayout.Size = new System.Drawing.Size(222, 22); this.m_menuViewWindowLayout.Text = "&Window Layout"; // // m_menuViewWindowsStacked // this.m_menuViewWindowsStacked.Image = global::KeePass.Properties.Resources.B16x16_Window_2Horz1Vert; this.m_menuViewWindowsStacked.Name = "m_menuViewWindowsStacked"; this.m_menuViewWindowsStacked.Size = new System.Drawing.Size(142, 22); this.m_menuViewWindowsStacked.Text = "&Stacked"; this.m_menuViewWindowsStacked.Click += new System.EventHandler(this.OnViewWindowsStacked); // // m_menuViewWindowsSideBySide // this.m_menuViewWindowsSideBySide.Image = global::KeePass.Properties.Resources.B16x16_Window_3Horz; this.m_menuViewWindowsSideBySide.Name = "m_menuViewWindowsSideBySide"; this.m_menuViewWindowsSideBySide.Size = new System.Drawing.Size(142, 22); this.m_menuViewWindowsSideBySide.Text = "Side &by Side"; this.m_menuViewWindowsSideBySide.Click += new System.EventHandler(this.OnViewWindowsSideBySide); // // m_menuViewSep1 // this.m_menuViewSep1.Name = "m_menuViewSep1"; this.m_menuViewSep1.Size = new System.Drawing.Size(219, 6); // // m_menuViewAlwaysOnTop // this.m_menuViewAlwaysOnTop.CheckOnClick = true; this.m_menuViewAlwaysOnTop.Name = "m_menuViewAlwaysOnTop"; this.m_menuViewAlwaysOnTop.Size = new System.Drawing.Size(222, 22); this.m_menuViewAlwaysOnTop.Text = "&Always on Top"; this.m_menuViewAlwaysOnTop.Click += new System.EventHandler(this.OnViewAlwaysOnTop); // // m_menuViewSep2 // this.m_menuViewSep2.Name = "m_menuViewSep2"; this.m_menuViewSep2.Size = new System.Drawing.Size(219, 6); // // m_menuViewConfigColumns // this.m_menuViewConfigColumns.Image = global::KeePass.Properties.Resources.B16x16_View_Detailed; this.m_menuViewConfigColumns.Name = "m_menuViewConfigColumns"; this.m_menuViewConfigColumns.Size = new System.Drawing.Size(222, 22); this.m_menuViewConfigColumns.Text = "&Configure Columns..."; this.m_menuViewConfigColumns.Click += new System.EventHandler(this.OnViewConfigColumns); // // m_menuViewSortBy // this.m_menuViewSortBy.Name = "m_menuViewSortBy"; this.m_menuViewSortBy.Size = new System.Drawing.Size(222, 22); this.m_menuViewSortBy.Text = "&Sort By"; // // m_menuViewTanOptions // this.m_menuViewTanOptions.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuViewTanSimpleList, this.m_menuViewTanIndices}); this.m_menuViewTanOptions.Name = "m_menuViewTanOptions"; this.m_menuViewTanOptions.Size = new System.Drawing.Size(222, 22); this.m_menuViewTanOptions.Text = "TAN &View Options"; // // m_menuViewTanSimpleList // this.m_menuViewTanSimpleList.CheckOnClick = true; this.m_menuViewTanSimpleList.Name = "m_menuViewTanSimpleList"; this.m_menuViewTanSimpleList.Size = new System.Drawing.Size(303, 22); this.m_menuViewTanSimpleList.Text = "Use &Simple List View for TAN-Only Groups"; this.m_menuViewTanSimpleList.Click += new System.EventHandler(this.OnViewTanSimpleListClick); // // m_menuViewTanIndices // this.m_menuViewTanIndices.CheckOnClick = true; this.m_menuViewTanIndices.Name = "m_menuViewTanIndices"; this.m_menuViewTanIndices.Size = new System.Drawing.Size(303, 22); this.m_menuViewTanIndices.Text = "Show TAN &Indices in Entry Titles"; this.m_menuViewTanIndices.Click += new System.EventHandler(this.OnViewTanIndicesClick); // // m_menuViewEntryListGrouping // this.m_menuViewEntryListGrouping.Name = "m_menuViewEntryListGrouping"; this.m_menuViewEntryListGrouping.Size = new System.Drawing.Size(222, 22); this.m_menuViewEntryListGrouping.Text = "&Grouping in Entry List"; // // m_menuViewSep3 // this.m_menuViewSep3.Name = "m_menuViewSep3"; this.m_menuViewSep3.Size = new System.Drawing.Size(219, 6); // // m_menuViewShowEntriesOfSubGroups // this.m_menuViewShowEntriesOfSubGroups.CheckOnClick = true; this.m_menuViewShowEntriesOfSubGroups.Name = "m_menuViewShowEntriesOfSubGroups"; this.m_menuViewShowEntriesOfSubGroups.Size = new System.Drawing.Size(222, 22); this.m_menuViewShowEntriesOfSubGroups.Text = "Show Entries of Su&bgroups"; this.m_menuViewShowEntriesOfSubGroups.Click += new System.EventHandler(this.OnViewShowEntriesOfSubGroups); // // m_menuTools // this.m_menuTools.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuToolsPwGenerator, this.m_menuToolsGeneratePwList, this.m_menuToolsSep0, this.m_menuToolsTanWizard, this.m_menuToolsDb, this.m_menuToolsSep1, this.m_menuToolsTriggers, this.m_menuToolsPlugins, this.m_menuToolsSep2, this.m_menuToolsOptions}); this.m_menuTools.Name = "m_menuTools"; this.m_menuTools.Size = new System.Drawing.Size(49, 20); this.m_menuTools.Text = "&Tools"; // // m_menuToolsPwGenerator // this.m_menuToolsPwGenerator.Image = global::KeePass.Properties.Resources.B16x16_Key_New; this.m_menuToolsPwGenerator.Name = "m_menuToolsPwGenerator"; this.m_menuToolsPwGenerator.Size = new System.Drawing.Size(213, 22); this.m_menuToolsPwGenerator.Text = "&Generate Password..."; this.m_menuToolsPwGenerator.Click += new System.EventHandler(this.OnToolsPwGenerator); // // m_menuToolsGeneratePwList // this.m_menuToolsGeneratePwList.Image = global::KeePass.Properties.Resources.B16x16_KGPG_Gen; this.m_menuToolsGeneratePwList.Name = "m_menuToolsGeneratePwList"; this.m_menuToolsGeneratePwList.Size = new System.Drawing.Size(213, 22); this.m_menuToolsGeneratePwList.Text = "Generate Password &List..."; this.m_menuToolsGeneratePwList.Click += new System.EventHandler(this.OnToolsGeneratePasswordList); // // m_menuToolsSep0 // this.m_menuToolsSep0.Name = "m_menuToolsSep0"; this.m_menuToolsSep0.Size = new System.Drawing.Size(210, 6); // // m_menuToolsTanWizard // this.m_menuToolsTanWizard.Image = global::KeePass.Properties.Resources.B16x16_Wizard; this.m_menuToolsTanWizard.Name = "m_menuToolsTanWizard"; this.m_menuToolsTanWizard.Size = new System.Drawing.Size(213, 22); this.m_menuToolsTanWizard.Text = "&TAN Wizard..."; this.m_menuToolsTanWizard.Click += new System.EventHandler(this.OnToolsTanWizard); // // m_menuToolsDb // this.m_menuToolsDb.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuToolsDbMaintenance, this.m_menuToolsDbSep0, this.m_menuToolsDbDelDupEntries, this.m_menuToolsDbDelEmptyGroups, this.m_menuToolsDbDelUnusedIcons, this.m_menuToolsDbSep1, this.m_menuToolsDbXmlRep}); this.m_menuToolsDb.Name = "m_menuToolsDb"; this.m_menuToolsDb.Size = new System.Drawing.Size(213, 22); this.m_menuToolsDb.Text = "&Database Tools"; // // m_menuToolsDbMaintenance // this.m_menuToolsDbMaintenance.Image = global::KeePass.Properties.Resources.B16x16_Package_Settings; this.m_menuToolsDbMaintenance.Name = "m_menuToolsDbMaintenance"; this.m_menuToolsDbMaintenance.Size = new System.Drawing.Size(233, 22); this.m_menuToolsDbMaintenance.Text = "Database &Maintenance..."; this.m_menuToolsDbMaintenance.Click += new System.EventHandler(this.OnToolsDbMaintenance); // // m_menuToolsDbSep0 // this.m_menuToolsDbSep0.Name = "m_menuToolsDbSep0"; this.m_menuToolsDbSep0.Size = new System.Drawing.Size(230, 6); // // m_menuToolsDbDelDupEntries // this.m_menuToolsDbDelDupEntries.Image = global::KeePass.Properties.Resources.B16x16_DeleteEntry; this.m_menuToolsDbDelDupEntries.Name = "m_menuToolsDbDelDupEntries"; this.m_menuToolsDbDelDupEntries.Size = new System.Drawing.Size(233, 22); this.m_menuToolsDbDelDupEntries.Text = "Delete &Duplicate Entries"; this.m_menuToolsDbDelDupEntries.Click += new System.EventHandler(this.OnToolsDelDupEntries); // // m_menuToolsDbDelEmptyGroups // this.m_menuToolsDbDelEmptyGroups.Image = global::KeePass.Properties.Resources.B16x16_Folder_Locked; this.m_menuToolsDbDelEmptyGroups.Name = "m_menuToolsDbDelEmptyGroups"; this.m_menuToolsDbDelEmptyGroups.Size = new System.Drawing.Size(233, 22); this.m_menuToolsDbDelEmptyGroups.Text = "Delete Empty &Groups"; this.m_menuToolsDbDelEmptyGroups.Click += new System.EventHandler(this.OnToolsDelEmptyGroups); // // m_menuToolsDbDelUnusedIcons // this.m_menuToolsDbDelUnusedIcons.Image = global::KeePass.Properties.Resources.B16x16_Trashcan_Full; this.m_menuToolsDbDelUnusedIcons.Name = "m_menuToolsDbDelUnusedIcons"; this.m_menuToolsDbDelUnusedIcons.Size = new System.Drawing.Size(233, 22); this.m_menuToolsDbDelUnusedIcons.Text = "Delete Unused Custom &Icons"; this.m_menuToolsDbDelUnusedIcons.Click += new System.EventHandler(this.OnToolsDelUnusedIcons); // // m_menuToolsSep1 // this.m_menuToolsSep1.Name = "m_menuToolsSep1"; this.m_menuToolsSep1.Size = new System.Drawing.Size(210, 6); // // m_menuToolsTriggers // this.m_menuToolsTriggers.Image = global::KeePass.Properties.Resources.B16x16_Make_KDevelop; this.m_menuToolsTriggers.Name = "m_menuToolsTriggers"; this.m_menuToolsTriggers.Size = new System.Drawing.Size(213, 22); this.m_menuToolsTriggers.Text = "T&riggers..."; this.m_menuToolsTriggers.Click += new System.EventHandler(this.OnToolsTriggers); // // m_menuToolsPlugins // this.m_menuToolsPlugins.Image = global::KeePass.Properties.Resources.B16x16_BlockDevice; this.m_menuToolsPlugins.Name = "m_menuToolsPlugins"; this.m_menuToolsPlugins.Size = new System.Drawing.Size(213, 22); this.m_menuToolsPlugins.Text = "&Plugins..."; this.m_menuToolsPlugins.Click += new System.EventHandler(this.OnToolsPlugins); // // m_menuToolsSep2 // this.m_menuToolsSep2.Name = "m_menuToolsSep2"; this.m_menuToolsSep2.Size = new System.Drawing.Size(210, 6); // // m_menuToolsOptions // this.m_menuToolsOptions.Image = global::KeePass.Properties.Resources.B16x16_Misc; this.m_menuToolsOptions.Name = "m_menuToolsOptions"; this.m_menuToolsOptions.Size = new System.Drawing.Size(213, 22); this.m_menuToolsOptions.Text = "&Options..."; this.m_menuToolsOptions.Click += new System.EventHandler(this.OnToolsOptions); // // m_menuHelp // this.m_menuHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuHelpContents, this.m_menuHelpSelectSource, this.m_menuHelpSep0, this.m_menuHelpWebsite, this.m_menuHelpDonate, this.m_menuHelpSep1, this.m_menuHelpCheckForUpdate, this.m_menuHelpSep2, this.m_menuHelpAbout}); this.m_menuHelp.Name = "m_menuHelp"; this.m_menuHelp.Size = new System.Drawing.Size(45, 20); this.m_menuHelp.Text = "&Help"; // // m_menuHelpContents // this.m_menuHelpContents.Image = global::KeePass.Properties.Resources.B16x16_Toggle_Log; this.m_menuHelpContents.Name = "m_menuHelpContents"; this.m_menuHelpContents.Size = new System.Drawing.Size(170, 22); this.m_menuHelpContents.Text = "&Help Contents"; this.m_menuHelpContents.Click += new System.EventHandler(this.OnHelpContents); // // m_menuHelpSelectSource // this.m_menuHelpSelectSource.Image = global::KeePass.Properties.Resources.B16x16_KOrganizer; this.m_menuHelpSelectSource.Name = "m_menuHelpSelectSource"; this.m_menuHelpSelectSource.Size = new System.Drawing.Size(170, 22); this.m_menuHelpSelectSource.Text = "Help &Source..."; this.m_menuHelpSelectSource.Click += new System.EventHandler(this.OnHelpSelectSource); // // m_menuHelpSep0 // this.m_menuHelpSep0.Name = "m_menuHelpSep0"; this.m_menuHelpSep0.Size = new System.Drawing.Size(167, 6); // // m_menuHelpWebsite // this.m_menuHelpWebsite.Image = global::KeePass.Properties.Resources.B16x16_Folder_Home; this.m_menuHelpWebsite.Name = "m_menuHelpWebsite"; this.m_menuHelpWebsite.Size = new System.Drawing.Size(170, 22); this.m_menuHelpWebsite.Text = "KeePass &Website"; this.m_menuHelpWebsite.Click += new System.EventHandler(this.OnHelpHomepage); // // m_menuHelpDonate // this.m_menuHelpDonate.Image = global::KeePass.Properties.Resources.B16x16_Identity; this.m_menuHelpDonate.Name = "m_menuHelpDonate"; this.m_menuHelpDonate.Size = new System.Drawing.Size(170, 22); this.m_menuHelpDonate.Text = "&Donate..."; this.m_menuHelpDonate.Click += new System.EventHandler(this.OnHelpDonate); // // m_menuHelpSep1 // this.m_menuHelpSep1.Name = "m_menuHelpSep1"; this.m_menuHelpSep1.Size = new System.Drawing.Size(167, 6); // // m_menuHelpCheckForUpdate // this.m_menuHelpCheckForUpdate.Image = global::KeePass.Properties.Resources.B16x16_FTP; this.m_menuHelpCheckForUpdate.Name = "m_menuHelpCheckForUpdate"; this.m_menuHelpCheckForUpdate.Size = new System.Drawing.Size(170, 22); this.m_menuHelpCheckForUpdate.Text = "&Check for Update"; this.m_menuHelpCheckForUpdate.Click += new System.EventHandler(this.OnHelpCheckForUpdate); // // m_menuHelpSep2 // this.m_menuHelpSep2.Name = "m_menuHelpSep2"; this.m_menuHelpSep2.Size = new System.Drawing.Size(167, 6); // // m_menuHelpAbout // this.m_menuHelpAbout.Image = global::KeePass.Properties.Resources.B16x16_Help; this.m_menuHelpAbout.Name = "m_menuHelpAbout"; this.m_menuHelpAbout.Size = new System.Drawing.Size(170, 22); this.m_menuHelpAbout.Text = "&About KeePass..."; this.m_menuHelpAbout.Click += new System.EventHandler(this.OnHelpAbout); // // m_toolMain // this.m_toolMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_tbNewDatabase, this.m_tbOpenDatabase, this.m_tbSaveDatabase, this.m_tbSaveAll, this.m_tbSep0, this.m_tbAddEntry, this.m_tbSep1, this.m_tbCopyUserName, this.m_tbCopyPassword, this.m_tbOpenUrl, this.m_tbCopyUrl, this.m_tbAutoType, this.m_tbSep4, this.m_tbFind, this.m_tbEntryViewsDropDown, this.m_tbSep2, this.m_tbLockWorkspace, this.m_tbSep3, this.m_tbQuickFind, this.m_tbCloseTab}); this.m_toolMain.Location = new System.Drawing.Point(0, 24); this.m_toolMain.Name = "m_toolMain"; this.m_toolMain.Size = new System.Drawing.Size(654, 25); this.m_toolMain.TabIndex = 1; this.m_toolMain.TabStop = true; // // m_tbNewDatabase // this.m_tbNewDatabase.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbNewDatabase.Image = global::KeePass.Properties.Resources.B16x16_FileNew; this.m_tbNewDatabase.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbNewDatabase.Name = "m_tbNewDatabase"; this.m_tbNewDatabase.Size = new System.Drawing.Size(23, 22); this.m_tbNewDatabase.Click += new System.EventHandler(this.OnFileNew); // // m_tbOpenDatabase // this.m_tbOpenDatabase.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbOpenDatabase.Image = global::KeePass.Properties.Resources.B16x16_Folder_Yellow_Open; this.m_tbOpenDatabase.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbOpenDatabase.Name = "m_tbOpenDatabase"; this.m_tbOpenDatabase.Size = new System.Drawing.Size(23, 22); this.m_tbOpenDatabase.Click += new System.EventHandler(this.OnFileOpen); // // m_tbSaveDatabase // this.m_tbSaveDatabase.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbSaveDatabase.Image = global::KeePass.Properties.Resources.B16x16_FileSave; this.m_tbSaveDatabase.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbSaveDatabase.Name = "m_tbSaveDatabase"; this.m_tbSaveDatabase.Size = new System.Drawing.Size(23, 22); this.m_tbSaveDatabase.Click += new System.EventHandler(this.OnFileSave); // // m_tbSaveAll // this.m_tbSaveAll.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbSaveAll.Image = global::KeePass.Properties.Resources.B16x16_File_SaveAll; this.m_tbSaveAll.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbSaveAll.Name = "m_tbSaveAll"; this.m_tbSaveAll.Size = new System.Drawing.Size(23, 22); this.m_tbSaveAll.Click += new System.EventHandler(this.OnFileSaveAll); // // m_tbSep0 // this.m_tbSep0.Name = "m_tbSep0"; this.m_tbSep0.Size = new System.Drawing.Size(6, 25); // // m_tbAddEntry // this.m_tbAddEntry.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbAddEntry.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_tbAddEntryDefault}); this.m_tbAddEntry.Image = global::KeePass.Properties.Resources.B16x16_KGPG_Import; this.m_tbAddEntry.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbAddEntry.Name = "m_tbAddEntry"; this.m_tbAddEntry.Size = new System.Drawing.Size(32, 22); this.m_tbAddEntry.ButtonClick += new System.EventHandler(this.OnEntryAdd); // // m_tbAddEntryDefault // this.m_tbAddEntryDefault.Image = global::KeePass.Properties.Resources.B16x16_KGPG_Import; this.m_tbAddEntryDefault.Name = "m_tbAddEntryDefault"; this.m_tbAddEntryDefault.Size = new System.Drawing.Size(88, 22); this.m_tbAddEntryDefault.Text = "<>"; this.m_tbAddEntryDefault.Click += new System.EventHandler(this.OnEntryAdd); // // m_tbSep1 // this.m_tbSep1.Name = "m_tbSep1"; this.m_tbSep1.Size = new System.Drawing.Size(6, 25); // // m_tbCopyUserName // this.m_tbCopyUserName.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbCopyUserName.Image = global::KeePass.Properties.Resources.B16x16_Personal; this.m_tbCopyUserName.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbCopyUserName.Name = "m_tbCopyUserName"; this.m_tbCopyUserName.Size = new System.Drawing.Size(23, 22); this.m_tbCopyUserName.Click += new System.EventHandler(this.OnEntryCopyUserName); // // m_tbCopyPassword // this.m_tbCopyPassword.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbCopyPassword.Image = global::KeePass.Properties.Resources.B16x16_KGPG_Info; this.m_tbCopyPassword.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbCopyPassword.Name = "m_tbCopyPassword"; this.m_tbCopyPassword.Size = new System.Drawing.Size(23, 22); this.m_tbCopyPassword.Click += new System.EventHandler(this.OnEntryCopyPassword); // // m_tbOpenUrl // this.m_tbOpenUrl.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbOpenUrl.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_tbOpenUrlDefault}); this.m_tbOpenUrl.Image = global::KeePass.Properties.Resources.B16x16_FTP; this.m_tbOpenUrl.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbOpenUrl.Name = "m_tbOpenUrl"; this.m_tbOpenUrl.Size = new System.Drawing.Size(32, 22); this.m_tbOpenUrl.ButtonClick += new System.EventHandler(this.OnEntryOpenUrl); // // m_tbOpenUrlDefault // this.m_tbOpenUrlDefault.Image = global::KeePass.Properties.Resources.B16x16_FTP; this.m_tbOpenUrlDefault.Name = "m_tbOpenUrlDefault"; this.m_tbOpenUrlDefault.Size = new System.Drawing.Size(88, 22); this.m_tbOpenUrlDefault.Text = "<>"; this.m_tbOpenUrlDefault.Click += new System.EventHandler(this.OnEntryOpenUrl); // // m_tbCopyUrl // this.m_tbCopyUrl.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbCopyUrl.Image = global::KeePass.Properties.Resources.B16x16_EditCopyUrl; this.m_tbCopyUrl.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbCopyUrl.Name = "m_tbCopyUrl"; this.m_tbCopyUrl.Size = new System.Drawing.Size(23, 22); this.m_tbCopyUrl.Click += new System.EventHandler(this.OnEntryCopyURL); // // m_tbAutoType // this.m_tbAutoType.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbAutoType.Image = global::KeePass.Properties.Resources.B16x16_KTouch; this.m_tbAutoType.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbAutoType.Name = "m_tbAutoType"; this.m_tbAutoType.Size = new System.Drawing.Size(23, 22); this.m_tbAutoType.Click += new System.EventHandler(this.OnEntryPerformAutoType); // // m_tbSep4 // this.m_tbSep4.Name = "m_tbSep4"; this.m_tbSep4.Size = new System.Drawing.Size(6, 25); // // m_tbFind // this.m_tbFind.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbFind.Image = global::KeePass.Properties.Resources.B16x16_XMag; this.m_tbFind.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbFind.Name = "m_tbFind"; this.m_tbFind.Size = new System.Drawing.Size(23, 22); this.m_tbFind.Click += new System.EventHandler(this.OnPwListFind); // // m_tbEntryViewsDropDown // this.m_tbEntryViewsDropDown.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbEntryViewsDropDown.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_tbViewsShowAll, this.m_tbViewsShowExpired}); this.m_tbEntryViewsDropDown.Image = global::KeePass.Properties.Resources.B16x16_KGPG_Key3; this.m_tbEntryViewsDropDown.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbEntryViewsDropDown.Name = "m_tbEntryViewsDropDown"; this.m_tbEntryViewsDropDown.Size = new System.Drawing.Size(29, 22); this.m_tbEntryViewsDropDown.DropDownOpening += new System.EventHandler(this.OnEntryViewsByTagOpening); // // m_tbViewsShowAll // this.m_tbViewsShowAll.Image = global::KeePass.Properties.Resources.B16x16_KGPG_Key3; this.m_tbViewsShowAll.Name = "m_tbViewsShowAll"; this.m_tbViewsShowAll.Size = new System.Drawing.Size(67, 22); this.m_tbViewsShowAll.Click += new System.EventHandler(this.OnShowAllEntries); // // m_tbViewsShowExpired // this.m_tbViewsShowExpired.Image = global::KeePass.Properties.Resources.B16x16_History_Clear; this.m_tbViewsShowExpired.Name = "m_tbViewsShowExpired"; this.m_tbViewsShowExpired.Size = new System.Drawing.Size(67, 22); this.m_tbViewsShowExpired.Click += new System.EventHandler(this.OnToolsShowExpired); // // m_tbSep2 // this.m_tbSep2.Name = "m_tbSep2"; this.m_tbSep2.Size = new System.Drawing.Size(6, 25); // // m_tbLockWorkspace // this.m_tbLockWorkspace.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbLockWorkspace.Image = global::KeePass.Properties.Resources.B16x16_LockWorkspace; this.m_tbLockWorkspace.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbLockWorkspace.Name = "m_tbLockWorkspace"; this.m_tbLockWorkspace.Size = new System.Drawing.Size(23, 22); this.m_tbLockWorkspace.Click += new System.EventHandler(this.OnFileLock); // // m_tbSep3 // this.m_tbSep3.Name = "m_tbSep3"; this.m_tbSep3.Size = new System.Drawing.Size(6, 25); // // m_tbQuickFind // this.m_tbQuickFind.Name = "m_tbQuickFind"; this.m_tbQuickFind.Size = new System.Drawing.Size(121, 25); this.m_tbQuickFind.SelectedIndexChanged += new System.EventHandler(this.OnQuickFindSelectedIndexChanged); this.m_tbQuickFind.KeyUp += new System.Windows.Forms.KeyEventHandler(this.OnQuickFindKeyUp); this.m_tbQuickFind.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnQuickFindKeyDown); // // m_tbCloseTab // this.m_tbCloseTab.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; this.m_tbCloseTab.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbCloseTab.Image = ((System.Drawing.Image)(resources.GetObject("m_tbCloseTab.Image"))); this.m_tbCloseTab.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbCloseTab.Name = "m_tbCloseTab"; this.m_tbCloseTab.Size = new System.Drawing.Size(23, 22); this.m_tbCloseTab.Click += new System.EventHandler(this.OnFileClose); // // m_statusMain // this.m_statusMain.GripStyle = System.Windows.Forms.ToolStripGripStyle.Visible; this.m_statusMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_statusPartSelected, this.m_statusPartInfo, this.m_statusPartProgress, this.m_statusClipboard}); this.m_statusMain.Location = new System.Drawing.Point(0, 464); this.m_statusMain.Name = "m_statusMain"; this.m_statusMain.Size = new System.Drawing.Size(654, 22); this.m_statusMain.TabIndex = 3; // // m_statusPartSelected // this.m_statusPartSelected.AutoSize = false; this.m_statusPartSelected.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right; this.m_statusPartSelected.Name = "m_statusPartSelected"; this.m_statusPartSelected.Size = new System.Drawing.Size(140, 17); this.m_statusPartSelected.Text = ""; this.m_statusPartSelected.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // m_statusPartInfo // this.m_statusPartInfo.Name = "m_statusPartInfo"; this.m_statusPartInfo.Size = new System.Drawing.Size(245, 17); this.m_statusPartInfo.Spring = true; this.m_statusPartInfo.Text = ""; this.m_statusPartInfo.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // m_statusPartProgress // this.m_statusPartProgress.AutoSize = false; this.m_statusPartProgress.Name = "m_statusPartProgress"; this.m_statusPartProgress.Size = new System.Drawing.Size(150, 16); this.m_statusPartProgress.Style = System.Windows.Forms.ProgressBarStyle.Continuous; // // m_statusClipboard // this.m_statusClipboard.Name = "m_statusClipboard"; this.m_statusClipboard.Size = new System.Drawing.Size(100, 16); this.m_statusClipboard.Style = System.Windows.Forms.ProgressBarStyle.Continuous; // // m_ctxTray // this.m_ctxTray.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_ctxTrayTray, this.m_ctxTraySep0, this.m_ctxTrayGenPw, this.m_ctxTraySep1, this.m_ctxTrayOptions, this.m_ctxTraySep2, this.m_ctxTrayLock, this.m_ctxTrayFileExit}); this.m_ctxTray.Name = "m_ctxTray"; this.m_ctxTray.Size = new System.Drawing.Size(192, 132); this.m_ctxTray.Opening += new System.ComponentModel.CancelEventHandler(this.OnCtxTrayOpening); // // m_ctxTrayTray // this.m_ctxTrayTray.Image = global::KeePass.Properties.Resources.B16x16_View_Detailed; this.m_ctxTrayTray.Name = "m_ctxTrayTray"; this.m_ctxTrayTray.Size = new System.Drawing.Size(191, 22); this.m_ctxTrayTray.Text = "&Tray / Untray"; this.m_ctxTrayTray.Click += new System.EventHandler(this.OnTrayTray); // // m_ctxTraySep0 // this.m_ctxTraySep0.Name = "m_ctxTraySep0"; this.m_ctxTraySep0.Size = new System.Drawing.Size(188, 6); // // m_ctxTrayGenPw // this.m_ctxTrayGenPw.Image = global::KeePass.Properties.Resources.B16x16_Key_New; this.m_ctxTrayGenPw.Name = "m_ctxTrayGenPw"; this.m_ctxTrayGenPw.Size = new System.Drawing.Size(191, 22); this.m_ctxTrayGenPw.Text = "&Generate Password..."; this.m_ctxTrayGenPw.Click += new System.EventHandler(this.OnTrayGenPw); // // m_ctxTraySep1 // this.m_ctxTraySep1.Name = "m_ctxTraySep1"; this.m_ctxTraySep1.Size = new System.Drawing.Size(188, 6); // // m_ctxTrayOptions // this.m_ctxTrayOptions.Image = global::KeePass.Properties.Resources.B16x16_Misc; this.m_ctxTrayOptions.Name = "m_ctxTrayOptions"; this.m_ctxTrayOptions.Size = new System.Drawing.Size(191, 22); this.m_ctxTrayOptions.Text = "&Options..."; this.m_ctxTrayOptions.Click += new System.EventHandler(this.OnTrayOptions); // // m_ctxTraySep2 // this.m_ctxTraySep2.Name = "m_ctxTraySep2"; this.m_ctxTraySep2.Size = new System.Drawing.Size(188, 6); // // m_ctxTrayLock // this.m_ctxTrayLock.Image = global::KeePass.Properties.Resources.B16x16_LockWorkspace; this.m_ctxTrayLock.Name = "m_ctxTrayLock"; this.m_ctxTrayLock.Size = new System.Drawing.Size(191, 22); this.m_ctxTrayLock.Text = "<>"; this.m_ctxTrayLock.Click += new System.EventHandler(this.OnTrayLock); // // m_ctxTrayFileExit // this.m_ctxTrayFileExit.Image = global::KeePass.Properties.Resources.B16x16_Exit; this.m_ctxTrayFileExit.Name = "m_ctxTrayFileExit"; this.m_ctxTrayFileExit.Size = new System.Drawing.Size(191, 22); this.m_ctxTrayFileExit.Text = "E&xit"; this.m_ctxTrayFileExit.Click += new System.EventHandler(this.OnTrayExit); // // m_timerMain // this.m_timerMain.Enabled = true; this.m_timerMain.Interval = 1000; this.m_timerMain.Tick += new System.EventHandler(this.OnTimerMainTick); // // m_tabMain // this.m_tabMain.Dock = System.Windows.Forms.DockStyle.Top; this.m_tabMain.Location = new System.Drawing.Point(0, 49); this.m_tabMain.Name = "m_tabMain"; this.m_tabMain.SelectedIndex = 0; this.m_tabMain.ShowToolTips = true; this.m_tabMain.Size = new System.Drawing.Size(654, 22); this.m_tabMain.TabIndex = 2; this.m_tabMain.MouseClick += new System.Windows.Forms.MouseEventHandler(this.OnTabMainMouseClick); this.m_tabMain.SelectedIndexChanged += new System.EventHandler(this.OnTabMainSelectedIndexChanged); // // m_splitHorizontal // this.m_splitHorizontal.Dock = System.Windows.Forms.DockStyle.Fill; this.m_splitHorizontal.Location = new System.Drawing.Point(0, 71); this.m_splitHorizontal.Name = "m_splitHorizontal"; this.m_splitHorizontal.Orientation = System.Windows.Forms.Orientation.Horizontal; // // m_splitHorizontal.Panel1 // this.m_splitHorizontal.Panel1.Controls.Add(this.m_splitVertical); // // m_splitHorizontal.Panel2 // this.m_splitHorizontal.Panel2.Controls.Add(this.m_richEntryView); this.m_splitHorizontal.Size = new System.Drawing.Size(654, 393); this.m_splitHorizontal.SplitterDistance = 306; this.m_splitHorizontal.TabIndex = 2; this.m_splitHorizontal.TabStop = false; // // m_splitVertical // this.m_splitVertical.Dock = System.Windows.Forms.DockStyle.Fill; this.m_splitVertical.Location = new System.Drawing.Point(0, 0); this.m_splitVertical.Name = "m_splitVertical"; // // m_splitVertical.Panel1 // this.m_splitVertical.Panel1.Controls.Add(this.m_tvGroups); // // m_splitVertical.Panel2 // this.m_splitVertical.Panel2.Controls.Add(this.m_lvEntries); this.m_splitVertical.Size = new System.Drawing.Size(654, 306); this.m_splitVertical.SplitterDistance = 177; this.m_splitVertical.TabIndex = 0; this.m_splitVertical.TabStop = false; // // m_tvGroups // this.m_tvGroups.AllowDrop = true; this.m_tvGroups.ContextMenuStrip = this.m_ctxGroupList; this.m_tvGroups.Dock = System.Windows.Forms.DockStyle.Fill; this.m_tvGroups.HideSelection = false; this.m_tvGroups.HotTracking = true; this.m_tvGroups.Location = new System.Drawing.Point(0, 0); this.m_tvGroups.Name = "m_tvGroups"; this.m_tvGroups.ShowNodeToolTips = true; this.m_tvGroups.ShowRootLines = false; this.m_tvGroups.Size = new System.Drawing.Size(177, 306); this.m_tvGroups.TabIndex = 0; this.m_tvGroups.AfterCollapse += new System.Windows.Forms.TreeViewEventHandler(this.OnGroupsAfterCollapse); this.m_tvGroups.DragDrop += new System.Windows.Forms.DragEventHandler(this.OnGroupsListDragDrop); this.m_tvGroups.DragEnter += new System.Windows.Forms.DragEventHandler(this.OnGroupsListDragEnter); this.m_tvGroups.KeyUp += new System.Windows.Forms.KeyEventHandler(this.OnGroupsKeyUp); this.m_tvGroups.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.OnGroupsListClickNode); this.m_tvGroups.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnGroupsKeyDown); this.m_tvGroups.AfterExpand += new System.Windows.Forms.TreeViewEventHandler(this.OnGroupsAfterExpand); this.m_tvGroups.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.OnGroupsListItemDrag); this.m_tvGroups.DragOver += new System.Windows.Forms.DragEventHandler(this.OnGroupsListDragOver); // // m_lvEntries // this.m_lvEntries.AllowColumnReorder = true; this.m_lvEntries.ContextMenuStrip = this.m_ctxPwList; this.m_lvEntries.Dock = System.Windows.Forms.DockStyle.Fill; this.m_lvEntries.FullRowSelect = true; this.m_lvEntries.HideSelection = false; this.m_lvEntries.Location = new System.Drawing.Point(0, 0); this.m_lvEntries.Name = "m_lvEntries"; this.m_lvEntries.ShowItemToolTips = true; this.m_lvEntries.Size = new System.Drawing.Size(473, 306); this.m_lvEntries.TabIndex = 0; this.m_lvEntries.UseCompatibleStateImageBehavior = false; this.m_lvEntries.View = System.Windows.Forms.View.Details; this.m_lvEntries.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.OnPwListMouseDoubleClick); this.m_lvEntries.ColumnWidthChanged += new System.Windows.Forms.ColumnWidthChangedEventHandler(this.OnPwListColumnWidthChanged); this.m_lvEntries.SelectedIndexChanged += new System.EventHandler(this.OnPwListSelectedIndexChanged); this.m_lvEntries.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.OnPwListColumnClick); this.m_lvEntries.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnPwListMouseDown); this.m_lvEntries.KeyUp += new System.Windows.Forms.KeyEventHandler(this.OnPwListKeyUp); this.m_lvEntries.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnPwListKeyDown); this.m_lvEntries.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.OnPwListItemDrag); this.m_lvEntries.Click += new System.EventHandler(this.OnPwListClick); // // m_richEntryView // this.m_richEntryView.Dock = System.Windows.Forms.DockStyle.Fill; this.m_richEntryView.Location = new System.Drawing.Point(0, 0); this.m_richEntryView.Name = "m_richEntryView"; this.m_richEntryView.ReadOnly = true; this.m_richEntryView.Size = new System.Drawing.Size(654, 83); this.m_richEntryView.TabIndex = 0; this.m_richEntryView.Text = ""; this.m_richEntryView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnEntryViewKeyDown); this.m_richEntryView.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.OnEntryViewLinkClicked); this.m_richEntryView.KeyUp += new System.Windows.Forms.KeyEventHandler(this.OnEntryViewKeyUp); // // m_menuToolsDbSep1 // this.m_menuToolsDbSep1.Name = "m_menuToolsDbSep1"; this.m_menuToolsDbSep1.Size = new System.Drawing.Size(230, 6); // // m_menuToolsDbXmlRep // this.m_menuToolsDbXmlRep.Image = global::KeePass.Properties.Resources.B16x16_Binary; this.m_menuToolsDbXmlRep.Name = "m_menuToolsDbXmlRep"; this.m_menuToolsDbXmlRep.Size = new System.Drawing.Size(233, 22); this.m_menuToolsDbXmlRep.Text = "&XML Replace..."; this.m_menuToolsDbXmlRep.Click += new System.EventHandler(this.OnToolsXmlRep); // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(654, 486); this.Controls.Add(this.m_splitHorizontal); this.Controls.Add(this.m_statusMain); this.Controls.Add(this.m_tabMain); this.Controls.Add(this.m_toolMain); this.Controls.Add(this.m_menuMain); this.MainMenuStrip = this.m_menuMain; this.Name = "MainForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "<>"; this.Load += new System.EventHandler(this.OnFormLoad); this.Shown += new System.EventHandler(this.OnFormShown); this.Activated += new System.EventHandler(this.OnFormActivated); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing); this.Resize += new System.EventHandler(this.OnFormResize); this.m_ctxGroupList.ResumeLayout(false); this.m_ctxPwList.ResumeLayout(false); this.m_menuMain.ResumeLayout(false); this.m_menuMain.PerformLayout(); this.m_toolMain.ResumeLayout(false); this.m_toolMain.PerformLayout(); this.m_statusMain.ResumeLayout(false); this.m_statusMain.PerformLayout(); this.m_ctxTray.ResumeLayout(false); this.m_splitHorizontal.Panel1.ResumeLayout(false); this.m_splitHorizontal.Panel2.ResumeLayout(false); this.m_splitHorizontal.ResumeLayout(false); this.m_splitVertical.Panel1.ResumeLayout(false); this.m_splitVertical.Panel2.ResumeLayout(false); this.m_splitVertical.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); } #endregion private KeePass.UI.CustomMenuStripEx m_menuMain; private System.Windows.Forms.ToolStripMenuItem m_menuFile; private System.Windows.Forms.ToolStripMenuItem m_menuFileNew; private System.Windows.Forms.ToolStripMenuItem m_menuFileClose; private System.Windows.Forms.ToolStripSeparator m_menuFileSep0; private System.Windows.Forms.ToolStripMenuItem m_menuFileSave; private System.Windows.Forms.ToolStripSeparator m_menuFileSep1; private System.Windows.Forms.ToolStripMenuItem m_menuFileDbSettings; private System.Windows.Forms.ToolStripMenuItem m_menuFileChangeMasterKey; private System.Windows.Forms.ToolStripSeparator m_menuFileSep2; private System.Windows.Forms.ToolStripMenuItem m_menuFilePrint; private System.Windows.Forms.ToolStripSeparator m_menuFileSep3; private System.Windows.Forms.ToolStripMenuItem m_menuFileExport; private System.Windows.Forms.ToolStripSeparator m_menuFileSep4; private System.Windows.Forms.ToolStripMenuItem m_menuFileLock; private System.Windows.Forms.ToolStripMenuItem m_menuFileExit; private System.Windows.Forms.ToolStripMenuItem m_menuEdit; private System.Windows.Forms.ToolStripMenuItem m_menuView; private System.Windows.Forms.ToolStripMenuItem m_menuTools; private System.Windows.Forms.ToolStripMenuItem m_menuHelp; private System.Windows.Forms.ToolStripMenuItem m_menuHelpWebsite; private System.Windows.Forms.ToolStripMenuItem m_menuHelpDonate; private System.Windows.Forms.ToolStripSeparator m_menuHelpSep0; private System.Windows.Forms.ToolStripMenuItem m_menuHelpContents; private System.Windows.Forms.ToolStripSeparator m_menuHelpSep1; private System.Windows.Forms.ToolStripMenuItem m_menuHelpCheckForUpdate; private System.Windows.Forms.ToolStripSeparator m_menuHelpSep2; private System.Windows.Forms.ToolStripMenuItem m_menuHelpAbout; private KeePass.UI.CustomToolStripEx m_toolMain; private System.Windows.Forms.ToolStripButton m_tbNewDatabase; private System.Windows.Forms.ToolStripButton m_tbOpenDatabase; private KeePass.UI.CustomRichTextBoxEx m_richEntryView; private KeePass.UI.CustomSplitContainerEx m_splitHorizontal; private KeePass.UI.CustomSplitContainerEx m_splitVertical; private KeePass.UI.CustomTreeViewEx m_tvGroups; private System.Windows.Forms.StatusStrip m_statusMain; private System.Windows.Forms.ToolStripStatusLabel m_statusPartSelected; private System.Windows.Forms.ToolStripStatusLabel m_statusPartInfo; private KeePass.UI.CustomListViewEx m_lvEntries; private System.Windows.Forms.ToolStripButton m_tbSaveDatabase; private System.Windows.Forms.ContextMenuStrip m_ctxPwList; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryCopyUserName; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryCopyPassword; private System.Windows.Forms.ToolStripMenuItem m_ctxEntrySaveAttachedFiles; private System.Windows.Forms.ToolStripSeparator m_ctxEntrySep0; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryPerformAutoType; private System.Windows.Forms.ToolStripSeparator m_ctxEntrySep1; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryAdd; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryEdit; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryDuplicate; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryDelete; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryMassModify; private System.Windows.Forms.ToolStripMenuItem m_ctxEntrySelectAll; private System.Windows.Forms.ToolStripSeparator m_ctxEntrySep2; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryRearrangePopup; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryMoveToTop; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryMoveOneUp; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryMoveOneDown; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryMoveToBottom; private System.Windows.Forms.ImageList m_ilClientIcons; private System.Windows.Forms.ToolStripMenuItem m_menuChangeLanguage; private System.Windows.Forms.ToolStripSeparator m_tbSep0; private System.Windows.Forms.ToolStripMenuItem m_menuEditFind; private System.Windows.Forms.ToolStripSeparator m_menuViewSep0; private System.Windows.Forms.ToolStripMenuItem m_menuViewShowToolBar; private System.Windows.Forms.ToolStripMenuItem m_menuViewShowEntryView; private System.Windows.Forms.ToolStripSeparator m_tbSep1; private System.Windows.Forms.ToolStripButton m_tbFind; private System.Windows.Forms.ToolStripSeparator m_tbSep2; private System.Windows.Forms.ToolStripButton m_tbLockWorkspace; private System.Windows.Forms.ToolStripSeparator m_tbSep3; private System.Windows.Forms.ToolStripComboBox m_tbQuickFind; private System.Windows.Forms.ToolStripMenuItem m_menuToolsOptions; private System.Windows.Forms.ToolStripSeparator m_menuViewSep1; private System.Windows.Forms.ContextMenuStrip m_ctxGroupList; private System.Windows.Forms.ToolStripMenuItem m_ctxGroupAdd; private System.Windows.Forms.ToolStripSeparator m_ctxGroupSep0; private System.Windows.Forms.ToolStripMenuItem m_ctxGroupEdit; private System.Windows.Forms.ToolStripMenuItem m_ctxGroupDelete; private System.Windows.Forms.ToolStripProgressBar m_statusPartProgress; private System.Windows.Forms.ToolStripMenuItem m_menuViewAlwaysOnTop; private System.Windows.Forms.ToolStripSeparator m_menuViewSep2; private System.Windows.Forms.ToolStripSeparator m_ctxGroupSep1; private System.Windows.Forms.ToolStripMenuItem m_ctxGroupPrint; private System.Windows.Forms.ToolStripMenuItem m_menuViewConfigColumns; private System.Windows.Forms.ToolStripSeparator m_menuViewSep3; private System.Windows.Forms.ToolStripMenuItem m_menuFileRecent; private System.Windows.Forms.ContextMenuStrip m_ctxTray; private System.Windows.Forms.ToolStripMenuItem m_ctxTrayTray; private System.Windows.Forms.Timer m_timerMain; private System.Windows.Forms.ToolStripMenuItem m_menuToolsPlugins; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryUrl; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryOpenUrl; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryCopyUrl; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryMassSetIcon; private System.Windows.Forms.ToolStripMenuItem m_ctxGroupFind; private System.Windows.Forms.ToolStripSeparator m_ctxGroupSep2; private System.Windows.Forms.ToolStripMenuItem m_menuViewTanOptions; private System.Windows.Forms.ToolStripMenuItem m_menuViewTanSimpleList; private System.Windows.Forms.ToolStripMenuItem m_menuViewTanIndices; private System.Windows.Forms.ToolStripMenuItem m_menuToolsPwGenerator; private System.Windows.Forms.ToolStripSeparator m_menuToolsSep0; private System.Windows.Forms.ToolStripMenuItem m_menuToolsTanWizard; private System.Windows.Forms.ToolStripMenuItem m_menuEditShowAllEntries; private System.Windows.Forms.ToolStripMenuItem m_menuEditShowExpired; private System.Windows.Forms.ToolStripSeparator m_menuEditSep0; private System.Windows.Forms.ToolStripProgressBar m_statusClipboard; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryClipboard; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryClipCopy; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryClipPaste; private System.Windows.Forms.ToolStripMenuItem m_ctxEntrySetColor; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryColorStandard; private System.Windows.Forms.ToolStripSeparator m_ctxEntryColorSep0; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryColorLightRed; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryColorLightGreen; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryColorLightBlue; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryColorLightYellow; private System.Windows.Forms.ToolStripSeparator m_ctxEntryColorSep1; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryColorCustom; private System.Windows.Forms.ToolStripDropDownButton m_tbEntryViewsDropDown; private System.Windows.Forms.ToolStripMenuItem m_tbViewsShowAll; private System.Windows.Forms.ToolStripMenuItem m_tbViewsShowExpired; private System.Windows.Forms.ToolStripSplitButton m_tbAddEntry; private System.Windows.Forms.ToolStripMenuItem m_tbAddEntryDefault; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryCopyCustomString; private System.Windows.Forms.ToolStripMenuItem m_menuToolsGeneratePwList; private System.Windows.Forms.ToolStripSeparator m_menuToolsSep1; private System.Windows.Forms.ToolStripMenuItem m_menuViewWindowLayout; private System.Windows.Forms.ToolStripMenuItem m_menuViewWindowsStacked; private System.Windows.Forms.ToolStripMenuItem m_menuViewWindowsSideBySide; private System.Windows.Forms.ToolStripButton m_tbCopyUserName; private System.Windows.Forms.ToolStripButton m_tbCopyPassword; private System.Windows.Forms.ToolStripSeparator m_tbSep4; private System.Windows.Forms.ToolStripMenuItem m_menuHelpSelectSource; private System.Windows.Forms.ToolStripMenuItem m_menuFileOpen; private System.Windows.Forms.ToolStripMenuItem m_menuFileOpenLocal; private System.Windows.Forms.ToolStripMenuItem m_menuFileOpenUrl; private System.Windows.Forms.ToolStripMenuItem m_menuFileSaveAs; private System.Windows.Forms.ToolStripMenuItem m_menuFileSaveAsLocal; private System.Windows.Forms.ToolStripMenuItem m_menuFileSaveAsUrl; private System.Windows.Forms.ToolStripMenuItem m_menuFileImport; private System.Windows.Forms.ToolStripSeparator m_ctxGroupSep3; private System.Windows.Forms.ToolStripMenuItem m_ctxGroupRearrange; private System.Windows.Forms.ToolStripMenuItem m_ctxGroupMoveToTop; private System.Windows.Forms.ToolStripMenuItem m_ctxGroupMoveOneUp; private System.Windows.Forms.ToolStripMenuItem m_ctxGroupMoveOneDown; private System.Windows.Forms.ToolStripMenuItem m_ctxGroupMoveToBottom; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryAttachments; private System.Windows.Forms.ToolStripSeparator m_ctxEntryUrlSep0; private System.Windows.Forms.ToolStripMenuItem m_ctxEntryUrlOpenInInternal; private System.Windows.Forms.ToolStripSeparator m_ctxTraySep0; private System.Windows.Forms.ToolStripMenuItem m_ctxTrayFileExit; private System.Windows.Forms.TabControl m_tabMain; private System.Windows.Forms.ToolStripButton m_tbSaveAll; private System.Windows.Forms.ToolStripButton m_tbCloseTab; private System.Windows.Forms.ToolStripSeparator m_menuFileSaveAsSep0; private System.Windows.Forms.ToolStripMenuItem m_menuFileSaveAsCopy; private System.Windows.Forms.ToolStripSeparator m_ctxEntrySelectedSep0; private System.Windows.Forms.ToolStripMenuItem m_ctxEntrySelectedPrint; private System.Windows.Forms.ToolStripMenuItem m_menuViewShowEntriesOfSubGroups; private System.Windows.Forms.ToolStripMenuItem m_menuFileSync; private System.Windows.Forms.ToolStripMenuItem m_menuFileSyncFile; private System.Windows.Forms.ToolStripMenuItem m_menuFileSyncUrl; private System.Windows.Forms.ToolStripMenuItem m_ctxTrayLock; private System.Windows.Forms.ToolStripSeparator m_ctxTraySep1; private System.Windows.Forms.ToolStripMenuItem m_ctxGroupExport; private System.Windows.Forms.ToolStripMenuItem m_ctxEntrySelectedExport; private System.Windows.Forms.ToolStripSeparator m_menuFileSyncSep0; private System.Windows.Forms.ToolStripMenuItem m_menuFileSyncRecent; private System.Windows.Forms.ToolStripSeparator m_menuToolsSep2; private System.Windows.Forms.ToolStripMenuItem m_menuToolsTriggers; private System.Windows.Forms.ToolStripMenuItem m_menuEditShowByTag; private System.Windows.Forms.ToolStripMenuItem m_ctxEntrySelectedAddTag; private System.Windows.Forms.ToolStripMenuItem m_ctxEntrySelectedNewTag; private System.Windows.Forms.ToolStripSeparator m_ctxEntrySelectedSep1; private System.Windows.Forms.ToolStripMenuItem m_ctxEntrySelectedRemoveTag; private System.Windows.Forms.ToolStripMenuItem m_menuViewSortBy; private System.Windows.Forms.ToolStripSeparator m_ctxGroupRearrSep0; private System.Windows.Forms.ToolStripMenuItem m_ctxGroupSort; private System.Windows.Forms.ToolStripMenuItem m_ctxGroupSortRec; private System.Windows.Forms.ToolStripMenuItem m_ctxGroupEmpty; private System.Windows.Forms.ToolStripMenuItem m_menuToolsDb; private System.Windows.Forms.ToolStripMenuItem m_menuToolsDbMaintenance; private System.Windows.Forms.ToolStripMenuItem m_menuToolsDbDelDupEntries; private System.Windows.Forms.ToolStripSeparator m_menuToolsDbSep0; private System.Windows.Forms.ToolStripMenuItem m_menuToolsDbDelEmptyGroups; private System.Windows.Forms.ToolStripMenuItem m_menuToolsDbDelUnusedIcons; private System.Windows.Forms.ToolStripMenuItem m_ctxTrayOptions; private System.Windows.Forms.ToolStripMenuItem m_menuViewEntryListGrouping; private System.Windows.Forms.ToolStripSeparator m_ctxTraySep2; private System.Windows.Forms.ToolStripMenuItem m_ctxTrayGenPw; private System.Windows.Forms.ToolStripMenuItem m_ctxGroupDuplicate; private System.Windows.Forms.ToolStripSplitButton m_tbOpenUrl; private System.Windows.Forms.ToolStripMenuItem m_tbOpenUrlDefault; private System.Windows.Forms.ToolStripButton m_tbCopyUrl; private System.Windows.Forms.ToolStripButton m_tbAutoType; private System.Windows.Forms.ToolStripSeparator m_menuToolsDbSep1; private System.Windows.Forms.ToolStripMenuItem m_menuToolsDbXmlRep; } } keepass2-2.25/KeePass/Forms/EcasActionForm.resx0000664000175000017500000001326612113701650021300 0ustar jtaylorjtaylor 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 keepass2-2.25/KeePass/Forms/EntropyForm.cs0000664000175000017500000000736512261553106020363 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Security.Cryptography; using System.IO; using System.Diagnostics; using KeePass.UI; using KeePass.Resources; using KeePassLib.Cryptography; using KeePassLib.Cryptography.PasswordGenerator; using KeePassLib.Utility; namespace KeePass.Forms { public partial class EntropyForm : Form { private byte[] m_pbEntropy = null; private LinkedList m_llPool = new LinkedList(); public byte[] GeneratedEntropy { get { return m_pbEntropy; } } public static byte[] CollectEntropyIfEnabled(PwProfile pp) { if(!pp.CollectUserEntropy) return null; EntropyForm ef = new EntropyForm(); if(UIUtil.ShowDialogNotValue(ef, DialogResult.OK)) return null; byte[] pbGen = ef.GeneratedEntropy; UIUtil.DestroyForm(ef); return pbGen; } public EntropyForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } private void OnFormLoad(object sender, EventArgs e) { // Can be invoked by tray command; don't use CenterParent Debug.Assert(this.StartPosition == FormStartPosition.CenterScreen); GlobalWindowManager.AddWindow(this); BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_Binary, KPRes.EntropyTitle, KPRes.EntropyDesc); this.Icon = Properties.Resources.KeePass; this.Text = KPRes.EntropyTitle; UpdateUIState(); } private void UpdateUIState() { int nBits = m_llPool.Count / 8; m_lblStatus.Text = nBits.ToString() + " " + KPRes.Bits; if(nBits > 256) { Debug.Assert(false); m_pbGenerated.Value = 100; } else m_pbGenerated.Value = (nBits * 100) / 256; } private void OnRandomMouseMove(object sender, MouseEventArgs e) { if(m_llPool.Count >= 2048) return; uint ul = (uint)((e.X << 8) ^ e.Y); ul ^= (uint)(Environment.TickCount << 16); m_llPool.AddLast(ul); UpdateUIState(); } private void OnBtnOK(object sender, EventArgs e) { MemoryStream ms = new MemoryStream(); // Prevent empty / low entropy buffer byte[] pbGuid = Guid.NewGuid().ToByteArray(); ms.Write(pbGuid, 0, pbGuid.Length); foreach(uint ln in m_llPool) ms.Write(MemUtil.UInt32ToBytes(ln), 0, 4); if(m_tbEdit.Text.Length > 0) { byte[] pbUTF8 = StrUtil.Utf8.GetBytes(m_tbEdit.Text); ms.Write(pbUTF8, 0, pbUTF8.Length); } byte[] pbColl = ms.ToArray(); SHA256Managed sha256 = new SHA256Managed(); m_pbEntropy = sha256.ComputeHash(pbColl); CryptoRandom.Instance.AddEntropy(pbColl); // Will be hashed using SHA-512 ms.Close(); } private void OnBtnCancel(object sender, EventArgs e) { } private void OnFormClosed(object sender, FormClosedEventArgs e) { GlobalWindowManager.RemoveWindow(this); } } }keepass2-2.25/KeePass/Forms/XmlReplaceForm.cs0000664000175000017500000001012312273660422020744 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePass.App; using KeePass.Resources; using KeePass.UI; using KeePass.Util; using KeePassLib; using KeePassLib.Utility; namespace KeePass.Forms { public partial class XmlReplaceForm : Form { private PwDatabase m_pd = null; private Image m_imgWarning = null; public void InitEx(PwDatabase pd) { m_pd = pd; } public XmlReplaceForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } private void OnFormLoad(object sender, EventArgs e) { if(m_pd == null) { Debug.Assert(false); throw new InvalidOperationException(); } GlobalWindowManager.AddWindow(this); BannerFactory.CreateBannerEx(this, m_bannerImage, KeePass.Properties.Resources.B48x48_Binary, KPRes.XmlReplace, KPRes.XmlReplaceDesc); this.Icon = Properties.Resources.KeePass; this.Text = KPRes.XmlReplace; Bitmap bmpBig = SystemIcons.Warning.ToBitmap(); m_imgWarning = UIUtil.CreateScaledImage(bmpBig, 16, 16); bmpBig.Dispose(); m_picWarning.Image = m_imgWarning; FontUtil.AssignDefaultBold(m_rbRemove); FontUtil.AssignDefaultBold(m_rbReplace); m_rbReplace.Checked = true; m_rbInnerText.Checked = true; EnableControlsEx(); } private void CleanUpEx() { if(m_imgWarning != null) { m_picWarning.Image = null; m_imgWarning.Dispose(); m_imgWarning = null; } else { Debug.Assert(false); } } private void OnFormClosed(object sender, FormClosedEventArgs e) { CleanUpEx(); GlobalWindowManager.RemoveWindow(this); } private void EnableControlsEx() { m_pnlReplace.Enabled = m_rbReplace.Checked; } private void OnRemoveCheckedChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnBtnOK(object sender, EventArgs e) { this.Enabled = false; try { XmlReplaceOptions opt = new XmlReplaceOptions(); XmlReplaceFlags f = XmlReplaceFlags.StatusUI; opt.ParentForm = this; opt.SelectNodesXPath = m_tbSelNodes.Text; if(m_rbRemove.Checked) opt.Operation = XmlReplaceOp.RemoveNodes; else if(m_rbReplace.Checked) opt.Operation = XmlReplaceOp.ReplaceData; else { Debug.Assert(false); } if(m_rbInnerText.Checked) opt.Data = XmlReplaceData.InnerText; else if(m_rbInnerXml.Checked) opt.Data = XmlReplaceData.InnerXml; else if(m_rbOuterXml.Checked) opt.Data = XmlReplaceData.OuterXml; else { Debug.Assert(false); } if(m_cbCase.Checked) f |= XmlReplaceFlags.CaseSensitive; if(m_cbRegex.Checked) f |= XmlReplaceFlags.Regex; opt.FindText = m_tbMatch.Text; opt.ReplaceText = m_tbReplace.Text; opt.Flags = f; XmlUtil.Replace(m_pd, opt); this.Enabled = true; } catch(Exception ex) { this.Enabled = true; MessageService.ShowWarning(ex.Message); this.DialogResult = DialogResult.None; } } private void OnBtnCancel(object sender, EventArgs e) { } private void OnBtnHelp(object sender, EventArgs e) { AppHelp.ShowHelp(AppDefs.HelpTopics.XmlReplace, null); } } } keepass2-2.25/KeePass/Forms/KeyCreationForm.resx0000664000175000017500000001504112162576046021512 0ustar jtaylorjtaylor 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 A composite master key consists of one or more of the following key sources. All sources you specify will be required to open the database.  If you lose one source, you will not be able to open the database. 17, 17 If the Windows account is lost, it will not be enough to create a new account with the same user name and password. A complete backup of the user account is required. Creating and restoring such a backup is not a simple task. If you don't know how to do this, don't enable this option. keepass2-2.25/KeePass/Forms/EntropyForm.resx0000664000175000017500000001326612135466320020735 0ustar jtaylorjtaylor 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 keepass2-2.25/KeePass/Forms/InternalBrowserForm.Designer.cs0000664000175000017500000002321611352443100023563 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class InternalBrowserForm { /// /// 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_menuMain = new KeePass.UI.CustomMenuStripEx(); this.m_menuFile = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileExit = new System.Windows.Forms.ToolStripMenuItem(); this.m_statusMain = new System.Windows.Forms.StatusStrip(); this.m_lblStatus = new System.Windows.Forms.ToolStripStatusLabel(); this.m_webBrowser = new System.Windows.Forms.WebBrowser(); this.m_toolNav = new KeePass.UI.CustomToolStripEx(); this.m_btnBack = new System.Windows.Forms.ToolStripButton(); this.m_btnForward = new System.Windows.Forms.ToolStripButton(); this.m_btnReload = new System.Windows.Forms.ToolStripButton(); this.m_btnStop = new System.Windows.Forms.ToolStripButton(); this.m_tssSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_tbUrl = new System.Windows.Forms.ToolStripTextBox(); this.m_btnGo = new System.Windows.Forms.ToolStripButton(); this.m_menuMain.SuspendLayout(); this.m_statusMain.SuspendLayout(); this.m_toolNav.SuspendLayout(); this.SuspendLayout(); // // m_menuMain // this.m_menuMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuFile}); this.m_menuMain.Location = new System.Drawing.Point(0, 0); this.m_menuMain.Name = "m_menuMain"; this.m_menuMain.Size = new System.Drawing.Size(779, 24); this.m_menuMain.TabIndex = 0; this.m_menuMain.TabStop = true; // // m_menuFile // this.m_menuFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuFileExit}); this.m_menuFile.Name = "m_menuFile"; this.m_menuFile.Size = new System.Drawing.Size(35, 20); this.m_menuFile.Text = "&File"; // // m_menuFileExit // this.m_menuFileExit.Name = "m_menuFileExit"; this.m_menuFileExit.Size = new System.Drawing.Size(91, 22); this.m_menuFileExit.Text = "E&xit"; // // m_statusMain // this.m_statusMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_lblStatus}); this.m_statusMain.Location = new System.Drawing.Point(0, 506); this.m_statusMain.Name = "m_statusMain"; this.m_statusMain.Size = new System.Drawing.Size(779, 22); this.m_statusMain.TabIndex = 1; // // m_lblStatus // this.m_lblStatus.Name = "m_lblStatus"; this.m_lblStatus.Size = new System.Drawing.Size(764, 17); this.m_lblStatus.Spring = true; this.m_lblStatus.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // m_webBrowser // this.m_webBrowser.Dock = System.Windows.Forms.DockStyle.Fill; this.m_webBrowser.Location = new System.Drawing.Point(0, 49); this.m_webBrowser.MinimumSize = new System.Drawing.Size(20, 20); this.m_webBrowser.Name = "m_webBrowser"; this.m_webBrowser.ScriptErrorsSuppressed = true; this.m_webBrowser.Size = new System.Drawing.Size(779, 457); this.m_webBrowser.TabIndex = 2; this.m_webBrowser.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.OnWbDocumentCompleted); this.m_webBrowser.Navigated += new System.Windows.Forms.WebBrowserNavigatedEventHandler(this.OnWbNavigated); // // m_toolNav // this.m_toolNav.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_btnBack, this.m_btnForward, this.m_btnReload, this.m_btnStop, this.m_tssSep0, this.m_tbUrl, this.m_btnGo}); this.m_toolNav.Location = new System.Drawing.Point(0, 24); this.m_toolNav.Name = "m_toolNav"; this.m_toolNav.Size = new System.Drawing.Size(779, 25); this.m_toolNav.TabIndex = 3; this.m_toolNav.TabStop = true; // // m_btnBack // this.m_btnBack.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_btnBack.Image = global::KeePass.Properties.Resources.B16x16_1UpArrow; this.m_btnBack.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_btnBack.Name = "m_btnBack"; this.m_btnBack.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never; this.m_btnBack.Size = new System.Drawing.Size(23, 22); this.m_btnBack.Text = "&Back"; this.m_btnBack.Click += new System.EventHandler(this.OnBtnBack); // // m_btnForward // this.m_btnForward.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_btnForward.Image = global::KeePass.Properties.Resources.B16x16_1DownArrow; this.m_btnForward.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_btnForward.Name = "m_btnForward"; this.m_btnForward.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never; this.m_btnForward.Size = new System.Drawing.Size(23, 22); this.m_btnForward.Text = "&Forward"; this.m_btnForward.Click += new System.EventHandler(this.OnBtnForward); // // m_btnReload // this.m_btnReload.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_btnReload.Image = global::KeePass.Properties.Resources.B16x16_Reload_Page; this.m_btnReload.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_btnReload.Name = "m_btnReload"; this.m_btnReload.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never; this.m_btnReload.Size = new System.Drawing.Size(23, 22); this.m_btnReload.Text = "&Reload"; this.m_btnReload.Click += new System.EventHandler(this.OnBtnReload); // // m_btnStop // this.m_btnStop.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_btnStop.Image = global::KeePass.Properties.Resources.B16x16_Exit; this.m_btnStop.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_btnStop.Name = "m_btnStop"; this.m_btnStop.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never; this.m_btnStop.Size = new System.Drawing.Size(23, 22); this.m_btnStop.Text = "&Stop"; this.m_btnStop.Click += new System.EventHandler(this.OnBtnStop); // // m_tssSep0 // this.m_tssSep0.Name = "m_tssSep0"; this.m_tssSep0.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never; this.m_tssSep0.Size = new System.Drawing.Size(6, 25); // // m_tbUrl // this.m_tbUrl.Name = "m_tbUrl"; this.m_tbUrl.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never; this.m_tbUrl.Size = new System.Drawing.Size(200, 25); this.m_tbUrl.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnTbUrlKeyDown); // // m_btnGo // this.m_btnGo.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_btnGo.Image = global::KeePass.Properties.Resources.B16x16_FTP; this.m_btnGo.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_btnGo.Name = "m_btnGo"; this.m_btnGo.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never; this.m_btnGo.Size = new System.Drawing.Size(23, 22); this.m_btnGo.Text = "&Go"; this.m_btnGo.Click += new System.EventHandler(this.OnBtnGo); // // InternalBrowserForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(779, 528); this.Controls.Add(this.m_webBrowser); this.Controls.Add(this.m_toolNav); this.Controls.Add(this.m_statusMain); this.Controls.Add(this.m_menuMain); this.MainMenuStrip = this.m_menuMain; this.MinimizeBox = false; this.Name = "InternalBrowserForm"; this.ShowInTaskbar = false; this.Text = ""; this.Load += new System.EventHandler(this.OnFormLoad); this.SizeChanged += new System.EventHandler(this.OnFormSizeChanged); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing); this.m_menuMain.ResumeLayout(false); this.m_menuMain.PerformLayout(); this.m_statusMain.ResumeLayout(false); this.m_statusMain.PerformLayout(); this.m_toolNav.ResumeLayout(false); this.m_toolNav.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private KeePass.UI.CustomMenuStripEx m_menuMain; private System.Windows.Forms.ToolStripMenuItem m_menuFile; private System.Windows.Forms.ToolStripMenuItem m_menuFileExit; private System.Windows.Forms.StatusStrip m_statusMain; private System.Windows.Forms.ToolStripStatusLabel m_lblStatus; private System.Windows.Forms.WebBrowser m_webBrowser; private KeePass.UI.CustomToolStripEx m_toolNav; private System.Windows.Forms.ToolStripTextBox m_tbUrl; private System.Windows.Forms.ToolStripButton m_btnBack; private System.Windows.Forms.ToolStripButton m_btnForward; private System.Windows.Forms.ToolStripButton m_btnReload; private System.Windows.Forms.ToolStripButton m_btnStop; private System.Windows.Forms.ToolStripSeparator m_tssSep0; private System.Windows.Forms.ToolStripButton m_btnGo; } }keepass2-2.25/KeePass/Forms/AboutForm.resx0000664000175000017500000001326611503154044020342 0ustar jtaylorjtaylor 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 keepass2-2.25/KeePass/Forms/DuplicationForm.Designer.cs0000664000175000017500000001431012166534530022725 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class DuplicationForm { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if(disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DuplicationForm)); this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_cbAppendCopy = new System.Windows.Forms.CheckBox(); this.m_cbFieldRefs = new System.Windows.Forms.CheckBox(); this.m_lblFieldRefs = new System.Windows.Forms.Label(); this.m_lblSep = new System.Windows.Forms.Label(); this.m_lnkFieldRefs = new System.Windows.Forms.LinkLabel(); this.m_cbCopyHistory = new System.Windows.Forms.CheckBox(); this.SuspendLayout(); // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(205, 174); 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 = "&OK"; 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(286, 174); 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; // // m_cbAppendCopy // this.m_cbAppendCopy.AutoSize = true; this.m_cbAppendCopy.Location = new System.Drawing.Point(12, 12); this.m_cbAppendCopy.Name = "m_cbAppendCopy"; this.m_cbAppendCopy.Size = new System.Drawing.Size(168, 17); this.m_cbAppendCopy.TabIndex = 2; this.m_cbAppendCopy.Text = "&Append \"- Copy\" to entry titles"; this.m_cbAppendCopy.UseVisualStyleBackColor = true; // // m_cbFieldRefs // this.m_cbFieldRefs.AutoSize = true; this.m_cbFieldRefs.Location = new System.Drawing.Point(12, 35); this.m_cbFieldRefs.Name = "m_cbFieldRefs"; this.m_cbFieldRefs.Size = new System.Drawing.Size(264, 17); this.m_cbFieldRefs.TabIndex = 3; this.m_cbFieldRefs.Text = "&Replace user names and passwords by references"; this.m_cbFieldRefs.UseVisualStyleBackColor = true; // // m_lblFieldRefs // this.m_lblFieldRefs.Location = new System.Drawing.Point(28, 55); this.m_lblFieldRefs.Name = "m_lblFieldRefs"; this.m_lblFieldRefs.Size = new System.Drawing.Size(333, 54); this.m_lblFieldRefs.TabIndex = 4; this.m_lblFieldRefs.Text = resources.GetString("m_lblFieldRefs.Text"); // // m_lblSep // this.m_lblSep.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.m_lblSep.Location = new System.Drawing.Point(1, 163); this.m_lblSep.Name = "m_lblSep"; this.m_lblSep.Size = new System.Drawing.Size(372, 2); this.m_lblSep.TabIndex = 7; // // m_lnkFieldRefs // this.m_lnkFieldRefs.AutoSize = true; this.m_lnkFieldRefs.Location = new System.Drawing.Point(28, 112); this.m_lnkFieldRefs.Name = "m_lnkFieldRefs"; this.m_lnkFieldRefs.Size = new System.Drawing.Size(115, 13); this.m_lnkFieldRefs.TabIndex = 5; this.m_lnkFieldRefs.TabStop = true; this.m_lnkFieldRefs.Text = "Help: Field References"; this.m_lnkFieldRefs.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.OnFieldRefsLinkClicked); // // m_cbCopyHistory // this.m_cbCopyHistory.AutoSize = true; this.m_cbCopyHistory.Location = new System.Drawing.Point(12, 134); this.m_cbCopyHistory.Name = "m_cbCopyHistory"; this.m_cbCopyHistory.Size = new System.Drawing.Size(83, 17); this.m_cbCopyHistory.TabIndex = 6; this.m_cbCopyHistory.Text = "Copy &history"; this.m_cbCopyHistory.UseVisualStyleBackColor = true; // // DuplicationForm // 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(373, 209); this.Controls.Add(this.m_cbCopyHistory); this.Controls.Add(this.m_lnkFieldRefs); this.Controls.Add(this.m_lblSep); this.Controls.Add(this.m_lblFieldRefs); this.Controls.Add(this.m_cbFieldRefs); this.Controls.Add(this.m_cbAppendCopy); 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 = "DuplicationForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Duplication Options"; 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.CheckBox m_cbAppendCopy; private System.Windows.Forms.CheckBox m_cbFieldRefs; private System.Windows.Forms.Label m_lblFieldRefs; private System.Windows.Forms.Label m_lblSep; private System.Windows.Forms.LinkLabel m_lnkFieldRefs; private System.Windows.Forms.CheckBox m_cbCopyHistory; } }keepass2-2.25/KeePass/Forms/SingleLineEditForm.resx0000664000175000017500000001326610666755434022152 0ustar jtaylorjtaylor 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 keepass2-2.25/KeePass/Forms/EditAutoTypeItemForm.cs0000664000175000017500000004662512273460136022127 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Threading; using System.Diagnostics; using KeePass.App; using KeePass.Native; using KeePass.Resources; using KeePass.UI; using KeePass.Util; using KeePass.Util.Spr; using KeePassLib; using KeePassLib.Security; using KeePassLib.Collections; using KeePassLib.Utility; using NativeLib = KeePassLib.Native.NativeLib; namespace KeePass.Forms { public partial class EditAutoTypeItemForm : Form { private AutoTypeConfig m_atConfig = null; private int m_iAssocIndex = -1; private bool m_bEditSequenceOnly = false; private string m_strDefaultSeq = string.Empty; private ProtectedStringDictionary m_vStringDict = null; private object m_objDialogSync = new object(); private bool m_bDialogClosed = false; #if DEBUG private static Dictionary m_dWndTasks = new Dictionary(); #endif // private Color m_clrOriginalForeground = Color.Black; // private Color m_clrOriginalBackground = Color.White; private List m_vWndImages = new List(); private RichTextBoxContextMenu m_ctxKeySeq = new RichTextBoxContextMenu(); private RichTextBoxContextMenu m_ctxKeyCodes = new RichTextBoxContextMenu(); private bool m_bBlockUpdates = false; public EditAutoTypeItemForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } public void InitEx(AutoTypeConfig atConfig, int iAssocIndex, bool bEditSequenceOnly, string strDefaultSeq, ProtectedStringDictionary vStringDict) { Debug.Assert(atConfig != null); if(atConfig == null) throw new ArgumentNullException("atConfig"); m_atConfig = atConfig; m_iAssocIndex = iAssocIndex; m_bEditSequenceOnly = bEditSequenceOnly; m_strDefaultSeq = (strDefaultSeq ?? string.Empty); m_vStringDict = (vStringDict ?? new ProtectedStringDictionary()); } private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_atConfig != null); if(m_atConfig == null) throw new InvalidOperationException(); Debug.Assert(m_vStringDict != null); if(m_vStringDict == null) throw new InvalidOperationException(); GlobalWindowManager.AddWindow(this); m_ctxKeySeq.Attach(m_rbKeySeq, this); m_ctxKeyCodes.Attach(m_rtbPlaceholders, this); if(!m_bEditSequenceOnly) { BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_KCMSystem, KPRes.ConfigureAutoTypeItem, KPRes.ConfigureAutoTypeItemDesc); } else // Edit keystrokes only { BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_KCMSystem, KPRes.ConfigureKeystrokeSeq, KPRes.ConfigureKeystrokeSeqDesc); } this.Icon = Properties.Resources.KeePass; // FontUtil.AssignDefaultBold(m_lblTargetWindow); // FontUtil.AssignDefaultBold(m_rbSeqDefault); // FontUtil.AssignDefaultBold(m_rbSeqCustom); UIUtil.EnableAutoCompletion(m_cmbWindow, false); // m_clrOriginalForeground = m_lblOpenHint.ForeColor; // m_clrOriginalBackground = m_cmbWindow.BackColor; // m_strOriginalWindowHint = m_lblTargetWindowInfo.Text; InitPlaceholdersBox(); string strInitSeq = m_atConfig.DefaultSequence; if(m_iAssocIndex >= 0) { AutoTypeAssociation asInit = m_atConfig.GetAt(m_iAssocIndex); m_cmbWindow.Text = asInit.WindowName; if(!m_bEditSequenceOnly) strInitSeq = asInit.Sequence; } else if(m_bEditSequenceOnly) m_cmbWindow.Text = "(" + KPRes.Default + ")"; else strInitSeq = string.Empty; bool bSetDefault = false; m_bBlockUpdates = true; if(strInitSeq.Length > 0) m_rbSeqCustom.Checked = true; else { m_rbSeqDefault.Checked = true; bSetDefault = true; } m_bBlockUpdates = false; if(bSetDefault) m_rbKeySeq.Text = m_strDefaultSeq; else m_rbKeySeq.Text = strInitSeq; try { if(NativeLib.IsUnix()) PopulateWindowsListUnix(); else PopulateWindowsListWin(); } catch(Exception) { Debug.Assert(false); } EnableControlsEx(); } private void InitPlaceholdersBox() { const string VkcBreak = @""; string[] vSpecialKeyCodes = new string[] { "TAB", "ENTER", "UP", "DOWN", "LEFT", "RIGHT", "HOME", "END", "PGUP", "PGDN", "INSERT", "DELETE", "SPACE", VkcBreak, "BACKSPACE", "BREAK", "CAPSLOCK", "ESC", "WIN", "LWIN", "RWIN", "APPS", "HELP", "NUMLOCK", "PRTSC", "SCROLLLOCK", VkcBreak, "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", VkcBreak, "ADD", "SUBTRACT", "MULTIPLY", "DIVIDE", "NUMPAD0", "NUMPAD1", "NUMPAD2", "NUMPAD3", "NUMPAD4", "NUMPAD5", "NUMPAD6", "NUMPAD7", "NUMPAD8", "NUMPAD9" }; string[] vSpecialPlaceholders = new string[] { "GROUP", "GROUPPATH", "PASSWORD_ENC", "URL:RMVSCM", "URL:SCM", "URL:HOST", "URL:PORT", "URL:PATH", "URL:QUERY", "T-REPLACE-RX:/T/S/R/", "T-CONV:/T/C/", "C:Comment", VkcBreak, "DELAY 1000", "DELAY=200", "VKEY 13", "VKEY-NX 13", "VKEY-EX 13", "PICKCHARS", "PICKCHARS:Password:C=3", "NEWPASSWORD", "HMACOTP", "CLEARFIELD", VkcBreak, "APPDIR", "DB_PATH", "DB_DIR", "DB_NAME", "DB_BASENAME", "DB_EXT", "ENV_DIRSEP", "ENV_PROGRAMFILES_X86", VkcBreak, // "INTERNETEXPLORER", "FIREFOX", "OPERA", "GOOGLECHROME", // "SAFARI", VkcBreak, "DT_SIMPLE", "DT_YEAR", "DT_MONTH", "DT_DAY", "DT_HOUR", "DT_MINUTE", "DT_SECOND", "DT_UTC_SIMPLE", "DT_UTC_YEAR", "DT_UTC_MONTH", "DT_UTC_DAY", "DT_UTC_HOUR", "DT_UTC_MINUTE", "DT_UTC_SECOND" }; RichTextBuilder rb = new RichTextBuilder(); rb.AppendLine(KPRes.StandardFields, FontStyle.Bold, null, null, ":", null); rb.Append("{" + PwDefs.TitleField + "} "); rb.Append("{" + PwDefs.UserNameField + "} "); rb.Append("{" + PwDefs.PasswordField + "} "); rb.Append("{" + PwDefs.UrlField + "} "); rb.Append("{" + PwDefs.NotesField + "}"); bool bCustomInitialized = false, bFirst = true; foreach(KeyValuePair kvp in m_vStringDict) { if(!PwDefs.IsStandardField(kvp.Key)) { if(bCustomInitialized == false) { rb.AppendLine(); rb.AppendLine(); rb.AppendLine(KPRes.CustomFields, FontStyle.Bold, null, null, ":", null); bCustomInitialized = true; } if(!bFirst) rb.Append(" "); rb.Append("{" + PwDefs.AutoTypeStringPrefix + kvp.Key + "}"); bFirst = false; } } rb.AppendLine(); rb.AppendLine(); rb.AppendLine(KPRes.KeyboardKeyModifiers, FontStyle.Bold, null, null, ":", null); rb.Append(KPRes.KeyboardKeyShift + @": +, "); rb.Append(KPRes.KeyboardKeyCtrl + @": ^, "); rb.Append(KPRes.KeyboardKeyAlt + @": %"); rb.AppendLine(); rb.AppendLine(); rb.AppendLine(KPRes.SpecialKeys, FontStyle.Bold, null, null, ":", null); bFirst = true; foreach(string strNav in vSpecialKeyCodes) { if(strNav == VkcBreak) { rb.AppendLine(); rb.AppendLine(); bFirst = true; } else { if(!bFirst) rb.Append(" "); rb.Append("{" + strNav + "}"); bFirst = false; } } rb.AppendLine(); rb.AppendLine(); rb.AppendLine(KPRes.OtherPlaceholders, FontStyle.Bold, null, null, ":", null); bFirst = true; foreach(string strPH in vSpecialPlaceholders) { if(strPH == VkcBreak) { rb.AppendLine(); rb.AppendLine(); bFirst = true; } else { if(!bFirst) rb.Append(" "); rb.Append("{" + strPH + "}"); bFirst = false; } } if(SprEngine.FilterPlaceholderHints.Count > 0) { rb.AppendLine(); rb.AppendLine(); rb.AppendLine(KPRes.PluginProvided, FontStyle.Bold, null, null, ":", null); bFirst = true; foreach(string strP in SprEngine.FilterPlaceholderHints) { if(string.IsNullOrEmpty(strP)) continue; if(!bFirst) rb.Append(" "); rb.Append(strP); bFirst = false; } } rb.Build(m_rtbPlaceholders); LinkifyRtf(m_rtbPlaceholders); } private void OnFormShown(object sender, EventArgs e) { // Focusing doesn't work in OnFormLoad if(m_cmbWindow.Enabled) UIUtil.SetFocus(m_cmbWindow, this); else if(m_rbKeySeq.Enabled) UIUtil.SetFocus(m_rbKeySeq, this); else UIUtil.SetFocus(m_btnOK, this); } private void CleanUpEx() { lock(m_objDialogSync) { m_bDialogClosed = true; } m_cmbWindow.OrderedImageList = null; foreach(Image img in m_vWndImages) { if(img != null) img.Dispose(); } m_vWndImages.Clear(); m_ctxKeyCodes.Detach(); m_ctxKeySeq.Detach(); #if DEBUG lock(m_dWndTasks) { Debug.Assert(m_dWndTasks.Count == 0); } #endif } private void OnBtnOK(object sender, EventArgs e) { EnableControlsEx(); Debug.Assert(m_btnOK.Enabled); if(!m_btnOK.Enabled) return; string strNewSeq = (m_rbSeqCustom.Checked ? m_rbKeySeq.Text : string.Empty); if(!m_bEditSequenceOnly) { AutoTypeAssociation atAssoc; if(m_iAssocIndex >= 0) atAssoc = m_atConfig.GetAt(m_iAssocIndex); else { atAssoc = new AutoTypeAssociation(); m_atConfig.Add(atAssoc); } atAssoc.WindowName = m_cmbWindow.Text; atAssoc.Sequence = strNewSeq; } else m_atConfig.DefaultSequence = strNewSeq; } private void OnBtnCancel(object sender, EventArgs e) { } private void OnBtnHelp(object sender, EventArgs e) { AppHelp.ShowHelp(AppDefs.HelpTopics.AutoType, null); } private void EnableControlsEx() { if(m_bBlockUpdates) return; m_bBlockUpdates = true; // string strItemName = m_cmbWindow.Text; // bool bEnableOK = true; // // string strError = string.Empty; // if((m_atConfig.Get(strItemName) != null) && !m_bEditSequenceOnly) // { // if((m_strOriginalName == null) || !strItemName.Equals(m_strOriginalName)) // { // bEnableOK = false; // // strError = KPRes.FieldNameExistsAlready; // } // } // // if((strItemName.IndexOf('{') >= 0) || (strItemName.IndexOf('}') >= 0)) // // { // // bEnableOK = false; // // // strError = KPRes.FieldNameInvalid; // // } // if(bEnableOK) // { // // m_lblTargetWindowInfo.Text = m_strOriginalWindowHint; // // m_lblTargetWindowInfo.ForeColor = m_clrOriginalForeground; // m_cmbWindow.BackColor = m_clrOriginalBackground; // m_btnOK.Enabled = true; // } // else // { // // m_lblTargetWindowInfo.Text = strError; // // m_lblTargetWindowInfo.ForeColor = Color.Red; // m_cmbWindow.BackColor = AppDefs.ColorEditError; // m_btnOK.Enabled = false; // } m_lblTargetWindow.Enabled = !m_bEditSequenceOnly; m_cmbWindow.Enabled = !m_bEditSequenceOnly; m_lblOpenHint.Enabled = !m_bEditSequenceOnly; m_lnkWildcardRegexHint.Enabled = !m_bEditSequenceOnly; // Workaround for disabled link render bug (gray too dark) m_lnkWildcardRegexHint.Visible = !m_bEditSequenceOnly; bool bCustom = m_rbSeqCustom.Checked; m_rbKeySeq.Enabled = bCustom; m_lblKeySeqInsertInfo.Enabled = bCustom; m_rtbPlaceholders.Enabled = bCustom; m_bBlockUpdates = false; } private void ColorizeKeySeq() { string strText = m_rbKeySeq.Text; int iSelStart = m_rbKeySeq.SelectionStart, iSelLen = m_rbKeySeq.SelectionLength; m_rbKeySeq.SelectAll(); m_rbKeySeq.SelectionBackColor = SystemColors.Window; int iStart = 0; while(true) { int iPos = strText.IndexOf('{', iStart); if(iPos < 0) break; int iEnd = strText.IndexOf('}', iPos + 1); if(iEnd < 0) break; m_rbKeySeq.Select(iPos, iEnd - iPos + 1); m_rbKeySeq.SelectionBackColor = Color.FromArgb(212, 255, 212); iStart = iEnd; } m_rbKeySeq.SelectionStart = iSelStart; m_rbKeySeq.SelectionLength = iSelLen; } private void OnTextChangedKeySeq(object sender, EventArgs e) { ColorizeKeySeq(); } private static void LinkifyRtf(RichTextBox rtb) { Debug.Assert(rtb.HideSelection); // Flicker otherwise string str = rtb.Text; int iPos = str.IndexOf('{'); while(iPos >= 0) { int iEnd = str.IndexOf('}', iPos); if(iEnd >= 1) { rtb.Select(iPos, iEnd - iPos + 1); UIUtil.RtfSetSelectionLink(rtb); } iPos = str.IndexOf('{', iPos + 1); } rtb.Select(0, 0); } private void OnPlaceholdersLinkClicked(object sender, LinkClickedEventArgs e) { if(!m_rbSeqCustom.Checked) m_rbSeqCustom.Checked = true; int nSelStart = m_rbKeySeq.SelectionStart; int nSelLength = m_rbKeySeq.SelectionLength; string strText = m_rbKeySeq.Text; string strUrl = e.LinkText; if(nSelLength > 0) strText = strText.Remove(nSelStart, nSelLength); m_rbKeySeq.Text = strText.Insert(nSelStart, strUrl); m_rbKeySeq.Select(nSelStart + strUrl.Length, 0); UIUtil.SetFocus(m_rbKeySeq, this); } private void OnWindowTextUpdate(object sender, EventArgs e) { EnableControlsEx(); } private void OnWindowSelectedIndexChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnFormClosed(object sender, FormClosedEventArgs e) { GlobalWindowManager.RemoveWindow(this); } private void OnWildcardRegexLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { AppHelp.ShowHelp(AppDefs.HelpTopics.AutoType, AppDefs.HelpTopics.AutoTypeWindowFilters); } private void OnSeqDefaultCheckedChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnSeqCustomCheckedChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnFormClosing(object sender, FormClosingEventArgs e) { CleanUpEx(); } private sealed class PwlwInfo { public EditAutoTypeItemForm Form { get; private set; } public IntPtr WindowHandle { get; private set; } public PwlwInfo(EditAutoTypeItemForm f, IntPtr h) { this.Form = f; this.WindowHandle = h; } } private void PopulateWindowsListWin() { Dictionary dWnds = new Dictionary(); NativeMethods.EnumWindowsProc procEnum = delegate(IntPtr hWnd, IntPtr lParam) { try { if(hWnd != IntPtr.Zero) dWnds[hWnd] = true; } catch(Exception) { Debug.Assert(false); } return true; }; NativeMethods.EnumWindows(procEnum, IntPtr.Zero); // On Windows 8 and higher, EnumWindows does not return Metro // app windows, thus we try to discover these windows using // the FindWindowEx function; we do this in addition to EnumWindows, // because calling FindWindowEx in a loop is less reliable (and // by additionally using EnumWindows we at least get all desktop // windows for sure) if(WinUtil.IsAtLeastWindows8) { int nMax = (dWnds.Count * 2) + 2; IntPtr h = NativeMethods.FindWindowEx(IntPtr.Zero, IntPtr.Zero, null, null); for(int i = 0; i < nMax; ++i) { if(h == IntPtr.Zero) break; dWnds[h] = true; h = NativeMethods.FindWindowEx(IntPtr.Zero, h, null, null); } } foreach(KeyValuePair kvp in dWnds) ThreadPool.QueueUserWorkItem(new WaitCallback( EditAutoTypeItemForm.EvalWindowProc), new PwlwInfo(this, kvp.Key)); m_cmbWindow.OrderedImageList = m_vWndImages; } private static void EvalWindowProc(object objState) { #if DEBUG string strTaskID = Guid.NewGuid().ToString(); lock(m_dWndTasks) { m_dWndTasks[strTaskID] = @"<<>>"; } #endif try { PwlwInfo pInfo = (objState as PwlwInfo); IntPtr hWnd = pInfo.WindowHandle; if(hWnd == IntPtr.Zero) { Debug.Assert(false); return; } uint uSmtoFlags = (NativeMethods.SMTO_NORMAL | NativeMethods.SMTO_ABORTIFHUNG); IntPtr pLen = IntPtr.Zero; IntPtr pSmto = NativeMethods.SendMessageTimeout(hWnd, NativeMethods.WM_GETTEXTLENGTH, IntPtr.Zero, IntPtr.Zero, uSmtoFlags, 2000, ref pLen); if(pSmto == IntPtr.Zero) return; string strName = NativeMethods.GetWindowText(hWnd, true); if(string.IsNullOrEmpty(strName)) return; #if DEBUG Debug.Assert(strName.Length <= pLen.ToInt64()); lock(m_dWndTasks) { m_dWndTasks[strTaskID] = strName; } #endif if((NativeMethods.GetWindowStyle(hWnd) & NativeMethods.WS_VISIBLE) == 0) return; if(NativeMethods.IsTaskBar(hWnd)) return; Image img = UIUtil.GetWindowImage(hWnd, true); if(pInfo.Form.InvokeRequired) pInfo.Form.Invoke(new AddWindowProcDelegate( EditAutoTypeItemForm.AddWindowProc), new object[] { pInfo.Form, hWnd, strName, img }); else AddWindowProc(pInfo.Form, hWnd, strName, img); } catch(Exception) { Debug.Assert(false); } #if DEBUG finally { lock(m_dWndTasks) { m_dWndTasks.Remove(strTaskID); } } #endif } private delegate void AddWindowProcDelegate(EditAutoTypeItemForm f, IntPtr h, string strWndName, Image img); private static void AddWindowProc(EditAutoTypeItemForm f, IntPtr h, string strWndName, Image img) { if(f == null) { Debug.Assert(false); return; } if(h == IntPtr.Zero) { Debug.Assert(false); return; } try { if(!AutoType.IsValidAutoTypeWindow(h, false)) return; lock(f.m_objDialogSync) { if(!f.m_bDialogClosed) { f.m_vWndImages.Add(img); f.m_cmbWindow.Items.Add(strWndName); } } } catch(Exception) { Debug.Assert(false); } } private void PopulateWindowsListUnix() { string strWindows = NativeMethods.RunXDoTool( @"search --onlyvisible --name '.+' getwindowname %@"); if(string.IsNullOrEmpty(strWindows)) return; strWindows = StrUtil.NormalizeNewLines(strWindows, false); string[] vWindows = strWindows.Split(new char[]{ '\n' }); List vListed = new List(); for(int i = 0; i < vWindows.Length; ++i) { string str = vWindows[i].Trim(); bool bValid = true; foreach(Form f in Application.OpenForms) { if(IsOwnWindow(f, str)) { bValid = false; break; } } if(!bValid) continue; if((str.Length > 0) && (vListed.IndexOf(str) < 0)) { m_cmbWindow.Items.Add(str); vListed.Add(str); } } } private static bool IsOwnWindow(Control cRoot, string strText) { if(cRoot == null) { Debug.Assert(false); return false; } if(cRoot.Text.Trim() == strText) return true; foreach(Control cSub in cRoot.Controls) { if(cSub == cRoot) { Debug.Assert(false); continue; } if(IsOwnWindow(cSub, strText)) return true; } return false; } } } keepass2-2.25/KeePass/Forms/EntryListForm.resx0000664000175000017500000001326612074500442021226 0ustar jtaylorjtaylor 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 keepass2-2.25/KeePass/Forms/EntryReportForm.resx0000664000175000017500000001326611072634014021566 0ustar jtaylorjtaylor 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 keepass2-2.25/KeePass/Forms/EntryListForm.cs0000664000175000017500000001202612261553106020646 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePass.UI; using KeePass.Resources; using KeePass.Native; using KeePassLib; using KeePassLib.Collections; using KeePassLib.Utility; namespace KeePass.Forms { public partial class EntryListForm : Form { private string m_strTitle = string.Empty; private string m_strDescShort = string.Empty; private string m_strDescLong = string.Empty; private Image m_imgIcon = null; private ImageList m_ilIcons = null; private PwObjectList m_vEntries = null; private PwEntry m_peSelected = null; private bool m_bEnsureForeground = false; public PwEntry SelectedEntry { get { return m_peSelected; } } public bool EnsureForeground { get { return m_bEnsureForeground; } set { m_bEnsureForeground = value; } } public void InitEx(string strTitle, string strDescShort, string strDescLong, Image imgIcon, ImageList ilIcons, PwObjectList vEntries) { m_strTitle = strTitle; m_strDescShort = strDescShort; m_strDescLong = strDescLong; m_imgIcon = imgIcon; m_ilIcons = UIUtil.CloneImageList(ilIcons, true); m_vEntries = vEntries; } public EntryListForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_strTitle.Length > 0); Debug.Assert(m_imgIcon != null); Debug.Assert(m_ilIcons != null); GlobalWindowManager.AddWindow(this); BannerFactory.CreateBannerEx(this, m_bannerImage, m_imgIcon, m_strTitle, m_strDescShort); m_lblText.Text = m_strDescLong; this.Text = m_strTitle; this.Icon = Properties.Resources.KeePass; if(m_ilIcons != null) m_lvEntries.SmallImageList = m_ilIcons; else m_ilIcons = new ImageList(); List> vColumns = new List>(); vColumns.Add(new KeyValuePair(PwDefs.TitleField, KPRes.Title)); vColumns.Add(new KeyValuePair(PwDefs.UserNameField, KPRes.UserName)); vColumns.Add(new KeyValuePair(PwDefs.UrlField, KPRes.Url)); UIUtil.CreateEntryList(m_lvEntries, m_vEntries, vColumns, m_ilIcons); ProcessResize(); if(m_bEnsureForeground) { this.BringToFront(); this.Activate(); } EnableControlsEx(); } private void EnableControlsEx() { bool bCond = (m_lvEntries.SelectedIndices.Count > 0); bool bCur = m_btnOK.Enabled; if(bCond != bCur) m_btnOK.Enabled = bCond; } private void ProcessResize() { int nWidth = m_lvEntries.ClientRectangle.Width / m_lvEntries.Columns.Count; for(int i = 0; i < m_lvEntries.Columns.Count; ++i) m_lvEntries.Columns[i].Width = nWidth; } private bool GetSelectedEntry(bool bSetDialogResult) { ListView.SelectedListViewItemCollection slvic = m_lvEntries.SelectedItems; if(slvic.Count == 1) { m_peSelected = (slvic[0].Tag as PwEntry); if(bSetDialogResult) this.DialogResult = DialogResult.OK; return true; } return false; } private void OnBtnOK(object sender, EventArgs e) { if(GetSelectedEntry(false) == false) this.DialogResult = DialogResult.None; } private void OnBtnCancel(object sender, EventArgs e) { } private void CleanUpEx() { if(m_ilIcons != null) { m_lvEntries.SmallImageList = null; // Detach event handlers m_ilIcons.Dispose(); m_ilIcons = null; } } private void OnEntriesItemActivate(object sender, EventArgs e) { if(GetSelectedEntry(true)) m_lvEntries.Enabled = false; } private void OnEntriesSelectedIndexChanged(object sender, EventArgs e) { EnableControlsEx(); // ListView.SelectedIndexCollection lvsic = m_lvEntries.SelectedIndices; // if((lvsic != null) && (lvsic.Count == 1)) // NativeMethods.EnsureVisible(m_lvEntries, lvsic[0], false); } private void OnFormClosed(object sender, FormClosedEventArgs e) { CleanUpEx(); GlobalWindowManager.RemoveWindow(this); } } } keepass2-2.25/KeePass/Forms/AboutForm.cs0000664000175000017500000001066312261553106017770 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.IO; using System.Diagnostics; using KeePass.App; using KeePass.UI; using KeePass.Resources; using KeePass.Util; using KeePass.DataExchange; using KeePassLib; using KeePassLib.Utility; namespace KeePass.Forms { public partial class AboutForm : Form, IGwmWindow { public bool CanCloseWithoutDataLoss { get { return true; } } public AboutForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } private void OnFormLoad(object sender, EventArgs e) { GlobalWindowManager.AddWindow(this, this); m_lblCopyright.Text = PwDefs.Copyright + "."; string strTitle = PwDefs.ProductName; string strDesc = KPRes.Version + " " + PwDefs.VersionString; Icon icoNew = new Icon(Properties.Resources.KeePass, 48, 48); BannerFactory.CreateBannerEx(this, m_bannerImage, icoNew.ToBitmap(), strTitle, strDesc); this.Icon = Properties.Resources.KeePass; m_lvComponents.Columns.Add(KPRes.Component, 100, HorizontalAlignment.Left); m_lvComponents.Columns.Add(KPRes.Status + " / " + KPRes.Version, 100, HorizontalAlignment.Left); try { GetAppComponents(); } catch(Exception) { Debug.Assert(false); } int nWidth = m_lvComponents.ClientRectangle.Width / 2; int nMod = m_lvComponents.ClientRectangle.Width % 2; m_lvComponents.Columns[0].Width = nWidth; m_lvComponents.Columns[1].Width = nWidth + nMod; UIUtil.SetExplorerTheme(m_lvComponents, false); } private void OnFormClosed(object sender, FormClosedEventArgs e) { GlobalWindowManager.RemoveWindow(this); } private void GetAppComponents() { ListViewItem lvi = new ListViewItem(PwDefs.ShortProductName); lvi.SubItems.Add(PwDefs.VersionString); m_lvComponents.Items.Add(lvi); lvi = new ListViewItem(KPRes.XslStylesheetsKdbx); string strPath = WinUtil.GetExecutable(); strPath = UrlUtil.GetFileDirectory(strPath, true, false); strPath += AppDefs.XslFilesDir; strPath = UrlUtil.EnsureTerminatingSeparator(strPath, false); bool bInstalled = File.Exists(strPath + AppDefs.XslFileHtmlLite); bInstalled &= File.Exists(strPath + AppDefs.XslFileHtmlFull); bInstalled &= File.Exists(strPath + AppDefs.XslFileHtmlTabular); if(!bInstalled) lvi.SubItems.Add(KPRes.NotInstalled); else lvi.SubItems.Add(KPRes.Installed); m_lvComponents.Items.Add(lvi); lvi = new ListViewItem(KPRes.KeePassLibCLong); if(!KdbFile.IsLibraryInstalled()) lvi.SubItems.Add(KPRes.NotInstalled); else lvi.SubItems.Add(KdbManager.KeePassVersionString + " (0x" + KdbManager.LibraryBuild.ToString("X4") + ")"); m_lvComponents.Items.Add(lvi); } private void OnLinkHomepage(object sender, LinkLabelLinkClickedEventArgs e) { WinUtil.OpenUrl(PwDefs.HomepageUrl, null); this.Close(); } private void OnLinkHelpFile(object sender, LinkLabelLinkClickedEventArgs e) { AppHelp.ShowHelp(null, null); this.Close(); } private void OnLinkLicenseFile(object sender, LinkLabelLinkClickedEventArgs e) { AppHelp.ShowHelp(AppDefs.HelpTopics.License, null, true); this.Close(); } private void OnLinkAcknowledgements(object sender, LinkLabelLinkClickedEventArgs e) { AppHelp.ShowHelp(AppDefs.HelpTopics.Acknowledgements, null, true); this.Close(); } private void OnLinkDonate(object sender, LinkLabelLinkClickedEventArgs e) { WinUtil.OpenUrl(PwDefs.DonationsUrl, null); this.Close(); } } } keepass2-2.25/KeePass/Forms/StatusLoggerForm.cs0000664000175000017500000001054712261553106021342 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePass.Resources; using KeePass.UI; using KeePassLib; using KeePassLib.Interfaces; namespace KeePass.Forms { public partial class StatusLoggerForm : Form, IStatusLogger { private bool m_bIsModal = false; private bool m_bCancelled = false; private bool m_bCloseMode = false; private uint m_uLastPercent = 0; private uint uWarnings = 0; private uint uErrors = 0; public void InitEx(bool bIsModal) { m_bIsModal = bIsModal; } public void StartLogging(string strOperation, bool bWriteOperationToLog) { if(strOperation != null) { this.Text = PwDefs.ShortProductName + " - " + strOperation; if(bWriteOperationToLog) this.SetText(strOperation, LogStatusType.Info); } m_pbProgress.Value = 0; m_uLastPercent = 0; } public void EndLogging() { m_btnCancel.Text = KPRes.CloseButton; m_bCloseMode = true; this.SetText(string.Empty, LogStatusType.AdditionalInfo); string strFinish = KPRes.Ready + " " + uErrors.ToString() + " " + KPRes.Errors + ", " + uWarnings.ToString() + " " + KPRes.Warnings + "."; this.SetText(strFinish, LogStatusType.Info); m_pbProgress.Value = 100; m_uLastPercent = 100; Application.DoEvents(); } public bool SetProgress(uint uPercent) { if(uPercent != m_uLastPercent) { m_pbProgress.Value = (int)uPercent; m_uLastPercent = uPercent; Application.DoEvents(); } return !m_bCancelled; } public bool SetText(string strNewText, LogStatusType lsType) { if(strNewText != null) { m_lvMessages.Items.Add(strNewText, (int)lsType); m_lvMessages.EnsureVisible(m_lvMessages.Items.Count - 1); } if(lsType == LogStatusType.Warning) ++uWarnings; else if(lsType == LogStatusType.Error) ++uErrors; ProcessResize(); Application.DoEvents(); return !m_bCancelled; } public bool ContinueWork() { Application.DoEvents(); return !m_bCancelled; } public StatusLoggerForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } private void OnFormLoad(object sender, EventArgs e) { GlobalWindowManager.AddWindow(this); this.Icon = Properties.Resources.KeePass; this.Text = PwDefs.ShortProductName; m_pbProgress.Minimum = 0; m_pbProgress.Maximum = 100; int nWidth = m_lvMessages.ClientRectangle.Width - 1; m_lvMessages.Columns.Add("<>", nWidth); ProcessResize(); } private void ProcessResize() { if(m_lvMessages.Columns.Count > 0) { int nColumnWidth = m_lvMessages.ClientRectangle.Width - 2; m_lvMessages.Columns[0].Width = nColumnWidth; } } private void OnBtnCancel(object sender, EventArgs e) { if(m_bCloseMode) { if(m_bIsModal) this.DialogResult = DialogResult.Cancel; else Close(); } else { m_bCancelled = true; this.DialogResult = DialogResult.None; } } private void OnMessagesSelectedIndexChanged(object sender, EventArgs e) { ListView.SelectedListViewItemCollection slvic = m_lvMessages.SelectedItems; if(slvic.Count == 0) { m_tbDetails.Text = string.Empty; return; } UIUtil.SetMultilineText(m_tbDetails, slvic[0].Text); } private void OnFormClosed(object sender, FormClosedEventArgs e) { GlobalWindowManager.RemoveWindow(this); } } } keepass2-2.25/KeePass/Forms/DataViewerForm.cs0000664000175000017500000003635612270756504020767 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Text; using System.Windows.Forms; using System.Diagnostics; using System.IO; using KeePass.Native; using KeePass.Resources; using KeePass.UI; using KeePass.Util; using KeePassLib; using KeePassLib.Utility; namespace KeePass.Forms { public partial class DataViewerForm : Form { private string m_strDataDesc = string.Empty; private byte[] m_pbData = null; private bool m_bInitializing = false; private uint m_uStartOffset = 0; private BinaryDataClass m_bdc = BinaryDataClass.Unknown; private readonly string m_strViewerHex = KPRes.HexViewer; private readonly string m_strViewerText = KPRes.TextViewer; private readonly string m_strViewerImage = KPRes.ImageViewer; private readonly string m_strViewerWeb = KPRes.WebBrowser; private readonly string m_strDataExpand = "--- " + KPRes.More + " ---"; private bool m_bDataExpanded = false; private RichTextBoxContextMenu m_ctxText = new RichTextBoxContextMenu(); private Image m_img = null; private Image m_imgResized = null; public event EventHandler DvfInit; public event EventHandler DvfUpdating; public event EventHandler DvfRelease; public static bool SupportsDataType(BinaryDataClass bdc) { return ((bdc == BinaryDataClass.Text) || (bdc == BinaryDataClass.RichText) || (bdc == BinaryDataClass.Image) || (bdc == BinaryDataClass.WebDocument)); } public void InitEx(string strDataDesc, byte[] pbData) { if(strDataDesc != null) m_strDataDesc = strDataDesc; m_pbData = pbData; } public DataViewerForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_pbData != null); if(m_pbData == null) throw new InvalidOperationException(); GlobalWindowManager.AddWindow(this); this.Icon = Properties.Resources.KeePass; string strTitle = PwDefs.ShortProductName + " " + KPRes.DataViewer; if(m_strDataDesc.Length > 0) strTitle = m_strDataDesc + " - " + strTitle; this.Text = strTitle; this.DoubleBuffered = true; m_bInitializing = true; m_tssStatusMain.Text = KPRes.Ready; m_ctxText.Attach(m_rtbText, this); m_rtbText.Dock = DockStyle.Fill; m_webBrowser.Dock = DockStyle.Fill; m_pnlImageViewer.Dock = DockStyle.Fill; m_picBox.Dock = DockStyle.Fill; m_tslEncoding.Text = KPRes.Encoding + ":"; foreach(StrEncodingInfo seiEnum in StrUtil.Encodings) { m_tscEncoding.Items.Add(seiEnum.Name); } StrEncodingInfo seiGuess = BinaryDataClassifier.GetStringEncoding( m_pbData, out m_uStartOffset); int iSel = 0; if(seiGuess != null) iSel = Math.Max(m_tscEncoding.FindStringExact(seiGuess.Name), 0); m_tscEncoding.SelectedIndex = iSel; m_tslZoom.Text = KPRes.Zoom + ":"; m_tscZoom.Items.Add(KPRes.Auto); int[] vZooms = new int[] { 10, 25, 50, 75, 100, 125, 150, 200, 400 }; foreach(int iZoom in vZooms) m_tscZoom.Items.Add(iZoom.ToString() + @"%"); m_tscZoom.SelectedIndex = 0; m_tslViewer.Text = KPRes.ShowIn + ":"; m_tscViewers.Items.Add(m_strViewerHex); m_tscViewers.Items.Add(m_strViewerText); m_tscViewers.Items.Add(m_strViewerImage); m_tscViewers.Items.Add(m_strViewerWeb); m_bdc = BinaryDataClassifier.Classify(m_strDataDesc, m_pbData); if((m_bdc == BinaryDataClass.Text) || (m_bdc == BinaryDataClass.RichText)) m_tscViewers.SelectedIndex = 1; else if(m_bdc == BinaryDataClass.Image) m_tscViewers.SelectedIndex = 2; else if(m_bdc == BinaryDataClass.WebDocument) m_tscViewers.SelectedIndex = 3; else m_tscViewers.SelectedIndex = 0; if(this.DvfInit != null) this.DvfInit(this, new DvfContextEventArgs(this, m_pbData, m_strDataDesc, m_tscViewers)); m_bInitializing = false; UpdateDataView(); } private void OnRichTextBoxLinkClicked(object sender, LinkClickedEventArgs e) { string strLink = e.LinkText; if(string.IsNullOrEmpty(strLink)) { Debug.Assert(false); return; } try { if((strLink == m_strDataExpand) && (m_tscViewers.Text == m_strViewerHex)) { m_bDataExpanded = true; UpdateHexView(); m_rtbText.Select(m_rtbText.TextLength, 0); m_rtbText.ScrollToCaret(); } else WinUtil.OpenUrl(strLink, null); } catch(Exception) { } // ScrollToCaret might throw (but still works) } private string BinaryDataToString() { string strEnc = m_tscEncoding.Text; StrEncodingInfo sei = StrUtil.GetEncoding(strEnc); try { return (sei.Encoding.GetString(m_pbData, (int)m_uStartOffset, m_pbData.Length - (int)m_uStartOffset) ?? string.Empty); } catch(Exception) { } return string.Empty; } private void SetRtbData(string strData, bool bRtf, bool bFixedFont) { if(strData == null) { Debug.Assert(false); strData = string.Empty; } m_rtbText.Clear(); // Clear formatting (esp. induced by Unicode) if(bFixedFont) FontUtil.AssignDefaultMono(m_rtbText, false); else FontUtil.AssignDefault(m_rtbText); if(bRtf) m_rtbText.Rtf = strData; else { m_rtbText.Text = strData; Font f = (bFixedFont ? FontUtil.MonoFont : FontUtil.DefaultFont); if(f != null) { m_rtbText.SelectAll(); m_rtbText.SelectionFont = f; m_rtbText.Select(0, 0); } else { Debug.Assert(false); } } } private void UpdateHexView() { int cbData = (m_bDataExpanded ? m_pbData.Length : Math.Min(m_pbData.Length, 16 * 256)); const int cbGrp = 4; const int cbLine = 16; int iMaxAddrWidth = Convert.ToString(Math.Max(cbData - 1, 0), 16).Length; int cbDataUp = cbData; if((cbDataUp % cbLine) != 0) cbDataUp = cbDataUp + cbLine - (cbDataUp % cbLine); Debug.Assert(((cbDataUp % cbLine) == 0) && (cbDataUp >= cbData)); StringBuilder sb = new StringBuilder(); for(int i = 0; i < cbDataUp; ++i) { if((i % cbLine) == 0) { sb.Append(Convert.ToString(i, 16).ToUpper().PadLeft( iMaxAddrWidth, '0')); sb.Append(": "); } if(i < cbData) { byte bt = m_pbData[i]; byte btHigh = (byte)(bt >> 4); byte btLow = (byte)(bt & 0x0F); if(btHigh >= 10) sb.Append((char)('A' + btHigh - 10)); else sb.Append((char)('0' + btHigh)); if(btLow >= 10) sb.Append((char)('A' + btLow - 10)); else sb.Append((char)('0' + btLow)); } else sb.Append(" "); if(((i + 1) % cbGrp) == 0) sb.Append(' '); if(((i + 1) % cbLine) == 0) { sb.Append(' '); int iStart = i - cbLine + 1; int iEndExcl = Math.Min(iStart + cbLine, cbData); for(int j = iStart; j < iEndExcl; ++j) sb.Append(StrUtil.ByteToSafeChar(m_pbData[j])); sb.AppendLine(); } } if(cbData < m_pbData.Length) sb.AppendLine(m_strDataExpand); SetRtbData(sb.ToString(), false, true); if(cbData < m_pbData.Length) { int iLinkStart = m_rtbText.Text.LastIndexOf(m_strDataExpand); if(iLinkStart >= 0) { m_rtbText.Select(iLinkStart, m_strDataExpand.Length); UIUtil.RtfSetSelectionLink(m_rtbText); m_rtbText.Select(0, 0); } else { Debug.Assert(false); } } } private void UpdateVisibility(string strViewer, bool bMakeVisible) { if(string.IsNullOrEmpty(strViewer)) { Debug.Assert(false); return; } if(!bMakeVisible) // Hide all except strViewer { if((strViewer != m_strViewerHex) && (strViewer != m_strViewerText)) m_rtbText.Visible = false; if(strViewer != m_strViewerImage) { m_picBox.Visible = false; m_pnlImageViewer.Visible = false; } if(strViewer != m_strViewerWeb) m_webBrowser.Visible = false; } else // Show strViewer { if((strViewer == m_strViewerHex) || (strViewer == m_strViewerText)) m_rtbText.Visible = true; else if(strViewer == m_strViewerImage) { m_pnlImageViewer.Visible = true; m_picBox.Visible = true; } else if(strViewer == m_strViewerWeb) m_webBrowser.Visible = true; } } private void UpdateDataView() { if(m_bInitializing) return; string strViewer = m_tscViewers.Text; bool bText = ((strViewer == m_strViewerText) || (strViewer == m_strViewerWeb)); bool bImage = (strViewer == m_strViewerImage); UpdateVisibility(strViewer, false); m_tssSeparator0.Visible = (bText || bImage); m_tslEncoding.Visible = m_tscEncoding.Visible = bText; m_tslZoom.Visible = m_tscZoom.Visible = bImage; try { if(this.DvfUpdating != null) { DvfContextEventArgs args = new DvfContextEventArgs(this, m_pbData, m_strDataDesc, m_tscViewers); this.DvfUpdating(this, args); if(args.Cancel) return; } if(strViewer == m_strViewerHex) UpdateHexView(); else if(strViewer == m_strViewerText) { string strData = BinaryDataToString(); SetRtbData(strData, (m_bdc == BinaryDataClass.RichText), false); } else if(strViewer == m_strViewerImage) { if(m_img == null) m_img = GfxUtil.LoadImage(m_pbData); UpdateImageView(); } else if(strViewer == m_strViewerWeb) { string strData = BinaryDataToString(); UIUtil.SetWebBrowserDocument(m_webBrowser, strData); } } catch(Exception) { } UpdateVisibility(strViewer, true); } private void OnViewersSelectedIndexChanged(object sender, EventArgs e) { UpdateDataView(); } private void OnEncodingSelectedIndexChanged(object sender, EventArgs e) { UpdateDataView(); } private void OnFormSizeChanged(object sender, EventArgs e) { UpdateImageView(); } private void UpdateImageView() { if(m_img == null) return; string strZoom = m_tscZoom.Text; if(string.IsNullOrEmpty(strZoom) || (strZoom == KPRes.Auto)) { m_pnlImageViewer.AutoScroll = false; m_picBox.Dock = DockStyle.Fill; m_picBox.Image = m_img; if((m_img.Width > m_picBox.ClientSize.Width) || (m_img.Height > m_picBox.ClientSize.Height)) { m_picBox.SizeMode = PictureBoxSizeMode.Zoom; } else m_picBox.SizeMode = PictureBoxSizeMode.CenterImage; return; } if(!strZoom.EndsWith(@"%")) { Debug.Assert(false); return; } int iZoom; if(!int.TryParse(strZoom.Substring(0, strZoom.Length - 1), out iZoom)) { Debug.Assert(false); return; } int cliW = m_pnlImageViewer.ClientRectangle.Width; int cliH = m_pnlImageViewer.ClientRectangle.Height; int dx = (m_img.Width * iZoom) / 100; int dy = (m_img.Height * iZoom) / 100; float fScrollX = 0.5f, fScrollY = 0.5f; if(m_pnlImageViewer.AutoScroll) { Point ptOffset = m_pnlImageViewer.AutoScrollPosition; Size sz = m_picBox.ClientSize; if(sz.Width > cliW) { fScrollX = Math.Abs((float)ptOffset.X / (float)(sz.Width - cliW)); if(fScrollX < 0.0f) { Debug.Assert(false); fScrollX = 0.0f; } if(fScrollX > 1.0f) { Debug.Assert(false); fScrollX = 1.0f; } } if(sz.Height > cliH) { fScrollY = Math.Abs((float)ptOffset.Y / (float)(sz.Height - cliH)); if(fScrollY < 0.0f) { Debug.Assert(false); fScrollY = 0.0f; } if(fScrollY > 1.0f) { Debug.Assert(false); fScrollY = 1.0f; } } } m_pnlImageViewer.AutoScroll = false; m_picBox.Dock = DockStyle.None; m_picBox.SizeMode = PictureBoxSizeMode.AutoSize; int x = 0, y = 0; if(dx < cliW) x = (cliW - dx) / 2; if(dy < cliH) y = (cliH - dy) / 2; m_picBox.Location = new Point(x, y); if((dx == m_img.Width) && (dy == m_img.Height)) m_picBox.Image = m_img; else if((m_imgResized != null) && (m_imgResized.Width == dx) && (m_imgResized.Height == dy)) m_picBox.Image = m_imgResized; else { Image imgToDispose = m_imgResized; Image img = new Bitmap(dx, dy, PixelFormat.Format32bppArgb); using(Graphics g = Graphics.FromImage(img)) { g.InterpolationMode = InterpolationMode.High; g.SmoothingMode = SmoothingMode.HighQuality; g.DrawImage(m_img, 0, 0, img.Width, img.Height); } m_imgResized = img; m_picBox.Image = m_imgResized; if(imgToDispose != null) imgToDispose.Dispose(); } m_pnlImageViewer.AutoScroll = true; int sx = 0, sy = 0; if(dx > cliW) sx = (int)(fScrollX * (float)(dx - cliW)); if(dy > cliH) sy = (int)(fScrollY * (float)(dy - cliH)); try { m_pnlImageViewer.AutoScrollPosition = new Point(sx, sy); } catch(Exception) { Debug.Assert(false); } } private void OnFormClosing(object sender, FormClosingEventArgs e) { if(this.DvfRelease != null) { DvfContextEventArgs args = new DvfContextEventArgs(this, m_pbData, m_strDataDesc, m_tscViewers); this.DvfRelease(sender, args); if(args.Cancel) { e.Cancel = true; return; } } m_picBox.Image = null; if(m_img != null) { m_img.Dispose(); m_img = null; } if(m_imgResized != null) { m_imgResized.Dispose(); m_imgResized = null; } m_ctxText.Detach(); GlobalWindowManager.RemoveWindow(this); } protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if(keyData == Keys.Escape) { if(msg.Msg == NativeMethods.WM_KEYDOWN) { this.Close(); return true; } else if(msg.Msg == NativeMethods.WM_KEYUP) return true; } return base.ProcessCmdKey(ref msg, keyData); } private void OnZoomSelectedIndexChanged(object sender, EventArgs e) { UpdateImageView(); } } public sealed class DvfContextEventArgs : CancellableOperationEventArgs { private DataViewerForm m_form; public DataViewerForm Form { get { return m_form; } } private byte[] m_pbData; public byte[] Data { get { return m_pbData; } } private string m_strDataDesc; public string DataDescription { get { return m_strDataDesc; } } private ToolStripComboBox m_tscViewers; public ToolStripComboBox ViewersComboBox { get { return m_tscViewers; } } public DvfContextEventArgs(DataViewerForm form, byte[] pbData, string strDataDesc, ToolStripComboBox cbViewers) { m_form = form; m_pbData = pbData; m_strDataDesc = strDataDesc; m_tscViewers = cbViewers; } } } keepass2-2.25/KeePass/Forms/OptionsForm.resx0000664000175000017500000001326612074503566020736 0ustar jtaylorjtaylor 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 keepass2-2.25/KeePass/Forms/PwEntryForm.resx0000664000175000017500000001641312266514234020705 0ustar jtaylorjtaylor 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 372, 17 17, 17 113, 17 642, 17 487, 54 667, 54 17, 43 135, 46 keepass2-2.25/KeePass/Forms/SearchForm.Designer.cs0000664000175000017500000003106611632115526021663 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class SearchForm { /// /// 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_bannerImage = new System.Windows.Forms.PictureBox(); this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_tbSearch = new System.Windows.Forms.TextBox(); this.m_lblSearchFor = new System.Windows.Forms.Label(); this.m_grpSearchIn = new System.Windows.Forms.GroupBox(); this.m_cbTags = new System.Windows.Forms.CheckBox(); this.m_cbGroupName = new System.Windows.Forms.CheckBox(); this.m_cbUuid = new System.Windows.Forms.CheckBox(); this.m_cbOtherFields = new System.Windows.Forms.CheckBox(); this.m_cbNotes = new System.Windows.Forms.CheckBox(); this.m_cbURL = new System.Windows.Forms.CheckBox(); this.m_cbPassword = new System.Windows.Forms.CheckBox(); this.m_cbUserName = new System.Windows.Forms.CheckBox(); this.m_cbTitle = new System.Windows.Forms.CheckBox(); this.m_grpOptions = new System.Windows.Forms.GroupBox(); this.m_cbDerefData = new System.Windows.Forms.CheckBox(); this.m_cbExcludeExpired = new System.Windows.Forms.CheckBox(); this.m_cbCaseSensitive = new System.Windows.Forms.CheckBox(); this.m_cbRegEx = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).BeginInit(); this.m_grpSearchIn.SuspendLayout(); this.m_grpOptions.SuspendLayout(); this.SuspendLayout(); // // m_bannerImage // this.m_bannerImage.Dock = System.Windows.Forms.DockStyle.Top; this.m_bannerImage.Location = new System.Drawing.Point(0, 0); this.m_bannerImage.Name = "m_bannerImage"; this.m_bannerImage.Size = new System.Drawing.Size(351, 60); this.m_bannerImage.TabIndex = 0; this.m_bannerImage.TabStop = false; // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(183, 314); this.m_btnOK.Name = "m_btnOK"; this.m_btnOK.Size = new System.Drawing.Size(75, 23); this.m_btnOK.TabIndex = 5; this.m_btnOK.Text = "&Find"; 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(264, 314); this.m_btnCancel.Name = "m_btnCancel"; this.m_btnCancel.Size = new System.Drawing.Size(75, 23); this.m_btnCancel.TabIndex = 6; this.m_btnCancel.Text = "&Cancel"; this.m_btnCancel.UseVisualStyleBackColor = true; this.m_btnCancel.Click += new System.EventHandler(this.OnBtnCancel); // // m_tbSearch // this.m_tbSearch.Location = new System.Drawing.Point(74, 69); this.m_tbSearch.Name = "m_tbSearch"; this.m_tbSearch.Size = new System.Drawing.Size(265, 20); this.m_tbSearch.TabIndex = 0; // // m_lblSearchFor // this.m_lblSearchFor.AutoSize = true; this.m_lblSearchFor.Location = new System.Drawing.Point(12, 72); this.m_lblSearchFor.Name = "m_lblSearchFor"; this.m_lblSearchFor.Size = new System.Drawing.Size(56, 13); this.m_lblSearchFor.TabIndex = 1; this.m_lblSearchFor.Text = "Find what:"; // // m_grpSearchIn // this.m_grpSearchIn.Controls.Add(this.m_cbTags); this.m_grpSearchIn.Controls.Add(this.m_cbGroupName); this.m_grpSearchIn.Controls.Add(this.m_cbUuid); this.m_grpSearchIn.Controls.Add(this.m_cbOtherFields); this.m_grpSearchIn.Controls.Add(this.m_cbNotes); this.m_grpSearchIn.Controls.Add(this.m_cbURL); this.m_grpSearchIn.Controls.Add(this.m_cbPassword); this.m_grpSearchIn.Controls.Add(this.m_cbUserName); this.m_grpSearchIn.Controls.Add(this.m_cbTitle); this.m_grpSearchIn.Location = new System.Drawing.Point(12, 118); this.m_grpSearchIn.Name = "m_grpSearchIn"; this.m_grpSearchIn.Size = new System.Drawing.Size(327, 89); this.m_grpSearchIn.TabIndex = 3; this.m_grpSearchIn.TabStop = false; this.m_grpSearchIn.Text = "Search in"; // // m_cbTags // this.m_cbTags.AutoSize = true; this.m_cbTags.Location = new System.Drawing.Point(113, 65); this.m_cbTags.Name = "m_cbTags"; this.m_cbTags.Size = new System.Drawing.Size(50, 17); this.m_cbTags.TabIndex = 7; this.m_cbTags.Text = "T&ags"; this.m_cbTags.UseVisualStyleBackColor = true; // // m_cbGroupName // this.m_cbGroupName.AutoSize = true; this.m_cbGroupName.Location = new System.Drawing.Point(217, 65); this.m_cbGroupName.Name = "m_cbGroupName"; this.m_cbGroupName.Size = new System.Drawing.Size(84, 17); this.m_cbGroupName.TabIndex = 8; this.m_cbGroupName.Text = "&Group name"; this.m_cbGroupName.UseVisualStyleBackColor = true; // // m_cbUuid // this.m_cbUuid.AutoSize = true; this.m_cbUuid.Location = new System.Drawing.Point(9, 65); this.m_cbUuid.Name = "m_cbUuid"; this.m_cbUuid.Size = new System.Drawing.Size(53, 17); this.m_cbUuid.TabIndex = 6; this.m_cbUuid.Text = "UU&ID"; this.m_cbUuid.UseVisualStyleBackColor = true; // // m_cbOtherFields // this.m_cbOtherFields.AutoSize = true; this.m_cbOtherFields.Location = new System.Drawing.Point(217, 42); this.m_cbOtherFields.Name = "m_cbOtherFields"; this.m_cbOtherFields.Size = new System.Drawing.Size(79, 17); this.m_cbOtherFields.TabIndex = 5; this.m_cbOtherFields.Text = "&Other fields"; this.m_cbOtherFields.UseVisualStyleBackColor = true; // // m_cbNotes // this.m_cbNotes.AutoSize = true; this.m_cbNotes.Location = new System.Drawing.Point(113, 42); this.m_cbNotes.Name = "m_cbNotes"; this.m_cbNotes.Size = new System.Drawing.Size(54, 17); this.m_cbNotes.TabIndex = 4; this.m_cbNotes.Text = "Note&s"; this.m_cbNotes.UseVisualStyleBackColor = true; // // m_cbURL // this.m_cbURL.AutoSize = true; this.m_cbURL.Location = new System.Drawing.Point(9, 42); this.m_cbURL.Name = "m_cbURL"; this.m_cbURL.Size = new System.Drawing.Size(48, 17); this.m_cbURL.TabIndex = 3; this.m_cbURL.Text = "&URL"; this.m_cbURL.UseVisualStyleBackColor = true; // // m_cbPassword // this.m_cbPassword.AutoSize = true; this.m_cbPassword.Location = new System.Drawing.Point(217, 19); this.m_cbPassword.Name = "m_cbPassword"; this.m_cbPassword.Size = new System.Drawing.Size(72, 17); this.m_cbPassword.TabIndex = 2; this.m_cbPassword.Text = "&Password"; this.m_cbPassword.UseVisualStyleBackColor = true; // // m_cbUserName // this.m_cbUserName.AutoSize = true; this.m_cbUserName.Location = new System.Drawing.Point(113, 19); this.m_cbUserName.Name = "m_cbUserName"; this.m_cbUserName.Size = new System.Drawing.Size(77, 17); this.m_cbUserName.TabIndex = 1; this.m_cbUserName.Text = "User &name"; this.m_cbUserName.UseVisualStyleBackColor = true; // // m_cbTitle // this.m_cbTitle.AutoSize = true; this.m_cbTitle.Location = new System.Drawing.Point(9, 19); this.m_cbTitle.Name = "m_cbTitle"; this.m_cbTitle.Size = new System.Drawing.Size(46, 17); this.m_cbTitle.TabIndex = 0; this.m_cbTitle.Text = "&Title"; this.m_cbTitle.UseVisualStyleBackColor = true; // // m_grpOptions // this.m_grpOptions.Controls.Add(this.m_cbDerefData); this.m_grpOptions.Controls.Add(this.m_cbExcludeExpired); this.m_grpOptions.Controls.Add(this.m_cbCaseSensitive); this.m_grpOptions.Location = new System.Drawing.Point(12, 212); this.m_grpOptions.Name = "m_grpOptions"; this.m_grpOptions.Size = new System.Drawing.Size(327, 92); this.m_grpOptions.TabIndex = 4; this.m_grpOptions.TabStop = false; this.m_grpOptions.Text = "Options"; // // m_cbDerefData // this.m_cbDerefData.AutoSize = true; this.m_cbDerefData.Location = new System.Drawing.Point(9, 65); this.m_cbDerefData.Name = "m_cbDerefData"; this.m_cbDerefData.Size = new System.Drawing.Size(140, 17); this.m_cbDerefData.TabIndex = 2; this.m_cbDerefData.Text = "Resolve fiel&d references"; this.m_cbDerefData.UseVisualStyleBackColor = true; // // m_cbExcludeExpired // this.m_cbExcludeExpired.AutoSize = true; this.m_cbExcludeExpired.Location = new System.Drawing.Point(9, 42); this.m_cbExcludeExpired.Name = "m_cbExcludeExpired"; this.m_cbExcludeExpired.Size = new System.Drawing.Size(135, 17); this.m_cbExcludeExpired.TabIndex = 1; this.m_cbExcludeExpired.Text = "Exclude &expired entries"; this.m_cbExcludeExpired.UseVisualStyleBackColor = true; // // m_cbCaseSensitive // this.m_cbCaseSensitive.AutoSize = true; this.m_cbCaseSensitive.Location = new System.Drawing.Point(9, 19); this.m_cbCaseSensitive.Name = "m_cbCaseSensitive"; this.m_cbCaseSensitive.Size = new System.Drawing.Size(94, 17); this.m_cbCaseSensitive.TabIndex = 0; this.m_cbCaseSensitive.Text = "Case-sensiti&ve"; this.m_cbCaseSensitive.UseVisualStyleBackColor = true; // // m_cbRegEx // this.m_cbRegEx.AutoSize = true; this.m_cbRegEx.Location = new System.Drawing.Point(74, 95); this.m_cbRegEx.Name = "m_cbRegEx"; this.m_cbRegEx.Size = new System.Drawing.Size(116, 17); this.m_cbRegEx.TabIndex = 2; this.m_cbRegEx.Text = "&Regular expression"; this.m_cbRegEx.UseVisualStyleBackColor = true; // // SearchForm // 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(351, 349); this.Controls.Add(this.m_cbRegEx); this.Controls.Add(this.m_grpOptions); this.Controls.Add(this.m_grpSearchIn); this.Controls.Add(this.m_lblSearchFor); this.Controls.Add(this.m_tbSearch); this.Controls.Add(this.m_btnCancel); this.Controls.Add(this.m_btnOK); this.Controls.Add(this.m_bannerImage); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "SearchForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Find"; this.Load += new System.EventHandler(this.OnFormLoad); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).EndInit(); this.m_grpSearchIn.ResumeLayout(false); this.m_grpSearchIn.PerformLayout(); this.m_grpOptions.ResumeLayout(false); this.m_grpOptions.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.PictureBox m_bannerImage; private System.Windows.Forms.Button m_btnOK; private System.Windows.Forms.Button m_btnCancel; private System.Windows.Forms.TextBox m_tbSearch; private System.Windows.Forms.Label m_lblSearchFor; private System.Windows.Forms.GroupBox m_grpSearchIn; private System.Windows.Forms.CheckBox m_cbNotes; private System.Windows.Forms.CheckBox m_cbURL; private System.Windows.Forms.CheckBox m_cbPassword; private System.Windows.Forms.CheckBox m_cbUserName; private System.Windows.Forms.CheckBox m_cbTitle; private System.Windows.Forms.GroupBox m_grpOptions; private System.Windows.Forms.CheckBox m_cbCaseSensitive; private System.Windows.Forms.CheckBox m_cbOtherFields; private System.Windows.Forms.CheckBox m_cbRegEx; private System.Windows.Forms.CheckBox m_cbExcludeExpired; private System.Windows.Forms.CheckBox m_cbGroupName; private System.Windows.Forms.CheckBox m_cbUuid; private System.Windows.Forms.CheckBox m_cbTags; private System.Windows.Forms.CheckBox m_cbDerefData; } }keepass2-2.25/KeePass/Forms/DuplicationForm.cs0000664000175000017500000000755412261553106021176 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePass.App; using KeePass.Resources; using KeePass.UI; using KeePassLib; using KeePassLib.Collections; using KeePassLib.Security; namespace KeePass.Forms { public partial class DuplicationForm : Form { // Copy data from controls to simple member variables, // because ApplyTo must work after the dialog has been destroyed. private bool m_bAppendCopy = true; // public bool AppendCopyToTitles // { // get { return m_bAppendCopy; } // } private bool m_bFieldRefs = false; // public bool ReplaceDataByFieldRefs // { // get { return m_bFieldRefs; } // } private bool m_bCopyHistory = true; // public bool CopyHistory // { // get { return m_bCopyHistory; } // } public void ApplyTo(PwEntry peNew, PwEntry pe, PwDatabase pd) { if((peNew == null) || (pe == null)) { Debug.Assert(false); return; } Debug.Assert(peNew.Strings.ReadSafe(PwDefs.UserNameField) == pe.Strings.ReadSafe(PwDefs.UserNameField)); Debug.Assert(peNew.Strings.ReadSafe(PwDefs.PasswordField) == pe.Strings.ReadSafe(PwDefs.PasswordField)); if(m_bAppendCopy && (pd != null)) { string strTitle = peNew.Strings.ReadSafe(PwDefs.TitleField); peNew.Strings.Set(PwDefs.TitleField, new ProtectedString( pd.MemoryProtection.ProtectTitle, strTitle + " - " + KPRes.CopyOfItem)); } if(m_bFieldRefs && (pd != null)) { string strUser = @"{REF:U@I:" + pe.Uuid.ToHexString() + @"}"; peNew.Strings.Set(PwDefs.UserNameField, new ProtectedString( pd.MemoryProtection.ProtectUserName, strUser)); string strPw = @"{REF:P@I:" + pe.Uuid.ToHexString() + @"}"; peNew.Strings.Set(PwDefs.PasswordField, new ProtectedString( pd.MemoryProtection.ProtectPassword, strPw)); } if(!m_bCopyHistory) peNew.History = new PwObjectList(); } public DuplicationForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } private void OnFormLoad(object sender, EventArgs e) { GlobalWindowManager.AddWindow(this); this.Icon = Properties.Resources.KeePass; FontUtil.AssignDefaultBold(m_cbAppendCopy); FontUtil.AssignDefaultBold(m_cbFieldRefs); FontUtil.AssignDefaultBold(m_cbCopyHistory); m_cbAppendCopy.Checked = m_bAppendCopy; m_cbFieldRefs.Checked = m_bFieldRefs; m_cbCopyHistory.Checked = m_bCopyHistory; } private void OnFormClosed(object sender, FormClosedEventArgs e) { GlobalWindowManager.RemoveWindow(this); } private void OnFieldRefsLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { AppHelp.ShowHelp(AppDefs.HelpTopics.FieldRefs, null); } private void OnBtnOK(object sender, EventArgs e) { m_bAppendCopy = m_cbAppendCopy.Checked; m_bFieldRefs = m_cbFieldRefs.Checked; m_bCopyHistory = m_cbCopyHistory.Checked; } } } keepass2-2.25/KeePass/Forms/ColumnsForm.resx0000664000175000017500000001326611675671206020726 0ustar jtaylorjtaylor 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 keepass2-2.25/KeePass/Forms/FileBrowserForm.cs0000664000175000017500000003711212261553106021137 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Text; using System.Windows.Forms; using System.IO; using System.Diagnostics; using KeePass.Native; using KeePass.Resources; using KeePass.UI; using KeePass.Util; using KeePassLib; using KeePassLib.Utility; namespace KeePass.Forms { public partial class FileBrowserForm : Form { private bool m_bSaveMode = false; private string m_strTitle = PwDefs.ShortProductName; private string m_strHint = string.Empty; private string m_strContext = null; private ImageList m_ilFolders = null; private List m_vFolderImages = new List(); private ImageList m_ilFiles = null; private List m_vFileImages = new List(); private int m_nIconDim = 16; private const string StrDummyNode = "66913D76EA3F4F2A8B1A0899B7322EC3"; private sealed class FbfPrivTviComparer : IComparer { public int Compare(TreeNode x, TreeNode y) { Debug.Assert((x != null) && (y != null)); return StrUtil.CompareNaturally(x.Text, y.Text); } } private sealed class FbfPrivLviComparer : IComparer { public int Compare(ListViewItem x, ListViewItem y) { Debug.Assert((x != null) && (y != null)); return StrUtil.CompareNaturally(x.Text, y.Text); } } private string m_strSelectedFile = null; public string SelectedFile { get { return m_strSelectedFile; } } public void InitEx(bool bSaveMode, string strTitle, string strHint, string strContext) { m_bSaveMode = bSaveMode; if(strTitle != null) m_strTitle = strTitle; if(strHint != null) m_strHint = strHint; m_strContext = strContext; } public FileBrowserForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } private void OnFormLoad(object sender, EventArgs e) { GlobalWindowManager.AddWindow(this); this.Icon = Properties.Resources.KeePass; this.Text = m_strTitle; m_nIconDim = m_tvFolders.ItemHeight; if(UIUtil.VistaStyleListsSupported) { m_tvFolders.ShowLines = false; UIUtil.SetExplorerTheme(m_tvFolders, true); UIUtil.SetExplorerTheme(m_lvFiles, true); } m_btnOK.Text = (m_bSaveMode ? KPRes.SaveCmd : KPRes.OpenCmd); m_lblHint.Text = m_strHint; if(UIUtil.ColorsEqual(m_lblHint.ForeColor, Color.Black)) m_lblHint.ForeColor = Color.FromArgb(96, 96, 96); int nWidth = m_lvFiles.ClientRectangle.Width - UIUtil.GetVScrollBarWidth(); m_lvFiles.Columns.Add(KPRes.Name, (nWidth * 3) / 4); m_lvFiles.Columns.Add(KPRes.Size, nWidth / 4, HorizontalAlignment.Right); InitialPopulateFolders(); string strWorkDir = Program.Config.Application.GetWorkingDirectory(m_strContext); if(string.IsNullOrEmpty(strWorkDir)) strWorkDir = WinUtil.GetHomeDirectory(); BrowseToFolder(strWorkDir); EnableControlsEx(); } private void OnFormClosed(object sender, FormClosedEventArgs e) { m_tvFolders.Nodes.Clear(); m_lvFiles.Items.Clear(); m_tvFolders.ImageList = null; m_lvFiles.SmallImageList = null; if(m_ilFolders != null) { m_ilFolders.Dispose(); m_ilFolders = null; } if(m_ilFiles != null) { m_ilFiles.Dispose(); m_ilFiles = null; } foreach(Image imgFld in m_vFolderImages) imgFld.Dispose(); m_vFolderImages.Clear(); foreach(Image imgFile in m_vFileImages) imgFile.Dispose(); m_vFileImages.Clear(); GlobalWindowManager.RemoveWindow(this); } private void EnableControlsEx() { m_btnOK.Enabled = (m_lvFiles.SelectedIndices.Count == 1); } private void InitialPopulateFolders() { List l = new List(); string str = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); if(!string.IsNullOrEmpty(str)) { TreeNode tn = CreateFolderNode(str, false, null); if(tn != null) l.Add(tn); } str = Environment.GetEnvironmentVariable("USERPROFILE"); if(!string.IsNullOrEmpty(str)) { TreeNode tn = CreateFolderNode(str, false, null); if(tn != null) l.Add(tn); } DriveInfo[] vDrives = DriveInfo.GetDrives(); foreach(DriveInfo drv in vDrives) { try { DirectoryInfo diDrive = drv.RootDirectory; TreeNode tn = CreateFolderNode(diDrive.FullName, true, drv); if(tn != null) l.Add(tn); } catch(Exception) { Debug.Assert(false); } } RebuildFolderImageList(); m_tvFolders.Nodes.AddRange(l.ToArray()); } private void GetObjectProps(string strPath, DriveInfo drvHint, out Image img, ref string strDisplayName) { GetObjectPropsUnscaled(strPath, drvHint, out img, ref strDisplayName); if(img != null) { if((img.Width != m_nIconDim) || (img.Height != m_nIconDim)) { Bitmap bmp = new Bitmap(m_nIconDim, m_nIconDim, PixelFormat.Format32bppArgb); using(Graphics g = Graphics.FromImage(bmp)) { g.Clear(Color.Transparent); g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.SmoothingMode = SmoothingMode.HighQuality; g.DrawImage(img, new Rectangle(0, 0, m_nIconDim, m_nIconDim)); } img.Dispose(); img = bmp; } } } private void GetObjectPropsUnscaled(string strPath, DriveInfo drvHint, out Image img, ref string strDisplayName) { img = null; try { string strName; NativeMethods.SHGetFileInfo(strPath, m_nIconDim, out img, out strName); if(!string.IsNullOrEmpty(strName) && (strName.IndexOf( Path.DirectorySeparatorChar) < 0)) strDisplayName = strName; if(img != null) return; } catch(Exception) { Debug.Assert(false); } ImageList.ImageCollection icons = Program.MainForm.ClientIcons.Images; if((strPath.Length <= 3) && (drvHint != null)) { switch(drvHint.DriveType) { case DriveType.Fixed: img = new Bitmap(icons[(int)PwIcon.Drive]); break; case DriveType.CDRom: img = new Bitmap(icons[(int)PwIcon.CDRom]); break; case DriveType.Network: img = new Bitmap(icons[(int)PwIcon.NetworkServer]); break; case DriveType.Ram: img = new Bitmap(icons[(int)PwIcon.Memory]); break; case DriveType.Removable: img = new Bitmap(icons[(int)PwIcon.Disk]); break; default: img = new Bitmap(icons[(int)PwIcon.Folder]); break; } return; } img = UIUtil.GetFileIcon(strPath, m_nIconDim, m_nIconDim); if(img != null) return; if(Directory.Exists(strPath)) { img = new Bitmap(icons[(int)PwIcon.Folder]); return; } if(File.Exists(strPath)) { img = new Bitmap(icons[(int)PwIcon.PaperNew]); return; } Debug.Assert(false); img = new Bitmap(icons[(int)PwIcon.Star]); } private TreeNode CreateFolderNode(string strDir, bool bForcePlusMinus, DriveInfo drvHint) { try { DirectoryInfo di = new DirectoryInfo(strDir); Image img; string strText = di.Name; GetObjectProps(di.FullName, drvHint, out img, ref strText); m_vFolderImages.Add(img); TreeNode tn = new TreeNode(strText, m_vFolderImages.Count - 1, m_vFolderImages.Count - 1); tn.Tag = di.FullName; InitNodePlusMinus(tn, di, bForcePlusMinus); return tn; } catch(Exception) { Debug.Assert(false); } return null; } private static void InitNodePlusMinus(TreeNode tn, DirectoryInfo di, bool bForce) { bool bMark = true; if(!bForce) { try { DirectoryInfo[] vDirs = di.GetDirectories(); bool bFoundDir = false; foreach(DirectoryInfo diSub in vDirs) { if(!IsValidFileSystemObject(diSub)) continue; bFoundDir = true; break; } if(!bFoundDir) bMark = false; } catch(Exception) { bMark = false; } // Usually unauthorized } if(bMark) { tn.Nodes.Add(StrDummyNode); tn.Collapse(); } } private void RebuildFolderImageList() { ImageList imgNew = UIUtil.BuildImageListUnscaled( m_vFolderImages, m_nIconDim, m_nIconDim); m_tvFolders.ImageList = imgNew; if(m_ilFolders != null) m_ilFolders.Dispose(); m_ilFolders = imgNew; } private void BuildFilesList(DirectoryInfo di) { m_lvFiles.BeginUpdate(); m_lvFiles.Items.Clear(); DirectoryInfo[] vDirs; FileInfo[] vFiles; try { vDirs = di.GetDirectories(); vFiles = di.GetFiles(); } catch(Exception) { m_lvFiles.EndUpdate(); return; } // Unauthorized foreach(Image imgFile in m_vFileImages) imgFile.Dispose(); m_vFileImages.Clear(); List lDirItems = new List(); List lFileItems = new List(); foreach(DirectoryInfo diSub in vDirs) { AddFileItem(diSub, m_vFileImages, lDirItems, -1); } foreach(FileInfo fi in vFiles) { AddFileItem(fi, m_vFileImages, lFileItems, fi.Length); } m_lvFiles.SmallImageList = null; if(m_ilFiles != null) m_ilFiles.Dispose(); m_ilFiles = UIUtil.BuildImageListUnscaled(m_vFileImages, m_nIconDim, m_nIconDim); m_lvFiles.SmallImageList = m_ilFiles; lDirItems.Sort(new FbfPrivLviComparer()); m_lvFiles.Items.AddRange(lDirItems.ToArray()); lFileItems.Sort(new FbfPrivLviComparer()); m_lvFiles.Items.AddRange(lFileItems.ToArray()); m_lvFiles.EndUpdate(); EnableControlsEx(); } private static bool IsValidFileSystemObject(FileSystemInfo fsi) { if(fsi == null) { Debug.Assert(false); return false; } string strName = fsi.Name; if(string.IsNullOrEmpty(strName) || (strName == ".") || (strName == "..")) return false; if(strName.EndsWith(".lnk", StrUtil.CaseIgnoreCmp)) return false; if(strName.EndsWith(".url", StrUtil.CaseIgnoreCmp)) return false; FileAttributes fa = fsi.Attributes; if((long)(fa & FileAttributes.ReparsePoint) != 0) return false; if(((long)(fa & FileAttributes.System) != 0) && ((long)(fa & FileAttributes.Hidden) != 0)) return false; return true; } private void AddFileItem(FileSystemInfo fsi, List lImages, List lItems, long lFileLength) { if(!IsValidFileSystemObject(fsi)) return; Image img; string strText = fsi.Name; GetObjectProps(fsi.FullName, null, out img, ref strText); lImages.Add(img); ListViewItem lvi = new ListViewItem(strText, lImages.Count - 1); lvi.Tag = fsi.FullName; if(lFileLength < 0) lvi.SubItems.Add(string.Empty); else lvi.SubItems.Add(StrUtil.FormatDataSizeKB((ulong)lFileLength)); lItems.Add(lvi); } private bool PerformFileSelection() { ListView.SelectedListViewItemCollection lvsic = m_lvFiles.SelectedItems; if((lvsic == null) || (lvsic.Count != 1)) { Debug.Assert(false); return false; } string str = (lvsic[0].Tag as string); if(string.IsNullOrEmpty(str)) { Debug.Assert(false); return false; } try { if(Directory.Exists(str)) { TreeNode tn = m_tvFolders.SelectedNode; if(tn == null) { Debug.Assert(false); return false; } if(!tn.IsExpanded) tn.Expand(); foreach(TreeNode tnSub in tn.Nodes) { string strSub = (tnSub.Tag as string); if(string.IsNullOrEmpty(strSub)) { Debug.Assert(false); continue; } if(strSub.Equals(str, StrUtil.CaseIgnoreCmp)) { m_tvFolders.SelectedNode = tnSub; tnSub.EnsureVisible(); return false; // Success, but not a file selection! } } Debug.Assert(false); } else if(File.Exists(str)) { m_strSelectedFile = str; Program.Config.Application.SetWorkingDirectory(m_strContext, UrlUtil.GetFileDirectory(str, false, true)); return true; } else { Debug.Assert(false); } } catch(Exception) { Debug.Assert(false); } return false; } private void OnBtnOK(object sender, EventArgs e) { if(!PerformFileSelection()) this.DialogResult = DialogResult.None; } private void OnFilesItemActivate(object sender, EventArgs e) { if(PerformFileSelection()) this.DialogResult = DialogResult.OK; } private void OnFoldersBeforeExpand(object sender, TreeViewCancelEventArgs e) { TreeNode tn = e.Node; if(tn == null) { Debug.Assert(false); e.Cancel = true; return; } if((tn.Nodes.Count == 1) && (tn.Nodes[0].Text == StrDummyNode)) { tn.Nodes.Clear(); List lNodes = new List(); try { DirectoryInfo di = new DirectoryInfo(tn.Tag as string); DirectoryInfo[] vSubDirs = di.GetDirectories(); foreach(DirectoryInfo diSub in vSubDirs) { if(!IsValidFileSystemObject(diSub)) continue; TreeNode tnSub = CreateFolderNode(diSub.FullName, false, null); if(tnSub != null) lNodes.Add(tnSub); } } catch(Exception) { Debug.Assert(false); } RebuildFolderImageList(); lNodes.Sort(new FbfPrivTviComparer()); tn.Nodes.AddRange(lNodes.ToArray()); } } private void BrowseToFolder(string strPath) { try { DirectoryInfo di = new DirectoryInfo(strPath); string[] vPath = di.FullName.Split(new char[]{ Path.DirectorySeparatorChar }); if((vPath == null) || (vPath.Length == 0)) { Debug.Assert(false); return; } TreeNode tn = null; string str = string.Empty; for(int i = 0; i < vPath.Length; ++i) { if(i > 0) str = UrlUtil.EnsureTerminatingSeparator(str, false); str += vPath[i]; if(i == 0) str = UrlUtil.EnsureTerminatingSeparator(str, false); TreeNodeCollection tnc = ((tn != null) ? tn.Nodes : m_tvFolders.Nodes); tn = null; foreach(TreeNode tnSub in tnc) { string strSub = (tnSub.Tag as string); if(string.IsNullOrEmpty(strSub)) { Debug.Assert(false); continue; } if(strSub.Equals(str, StrUtil.CaseIgnoreCmp)) { tn = tnSub; break; } } if(tn == null) { Debug.Assert(false); break; } if((i != (vPath.Length - 1)) && !tn.IsExpanded) tn.Expand(); } if(tn != null) { m_tvFolders.SelectedNode = tn; tn.EnsureVisible(); } else { Debug.Assert(false); } } catch(Exception) { Debug.Assert(false); } } private void OnFoldersAfterSelect(object sender, TreeViewEventArgs e) { TreeNode tn = e.Node; string strPath = (tn.Tag as string); if(strPath == null) { Debug.Assert(false); return; } try { DirectoryInfo di = new DirectoryInfo(strPath); BuildFilesList(di); } catch(Exception) { Debug.Assert(false); } } private void OnFilesSelectedIndexChanged(object sender, EventArgs e) { EnableControlsEx(); } } } keepass2-2.25/KeePass/Forms/DataEditorForm.Designer.cs0000664000175000017500000005314412273141172022475 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class DataEditorForm { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if(disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.m_menuMain = new System.Windows.Forms.MenuStrip(); this.m_menuFile = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSave = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuFileSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuFileExit = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuView = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuViewFont = new System.Windows.Forms.ToolStripMenuItem(); this.m_menuViewSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_menuViewWordWrap = new System.Windows.Forms.ToolStripMenuItem(); this.m_toolFile = new System.Windows.Forms.ToolStrip(); this.m_tbFileSave = new System.Windows.Forms.ToolStripButton(); this.m_tbFileSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_tbEditCut = new System.Windows.Forms.ToolStripButton(); this.m_tbEditCopy = new System.Windows.Forms.ToolStripButton(); this.m_tbEditPaste = new System.Windows.Forms.ToolStripButton(); this.m_tbFileSep1 = new System.Windows.Forms.ToolStripSeparator(); this.m_tbEditUndo = new System.Windows.Forms.ToolStripButton(); this.m_tbEditRedo = new System.Windows.Forms.ToolStripButton(); this.m_tbFileSep2 = new System.Windows.Forms.ToolStripSeparator(); this.m_tbFind = new System.Windows.Forms.ToolStripTextBox(); this.m_toolFormat = new System.Windows.Forms.ToolStrip(); this.m_tbFontCombo = new System.Windows.Forms.ToolStripComboBox(); this.m_tbFontSizeCombo = new System.Windows.Forms.ToolStripComboBox(); this.m_tbFormatSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_tbFormatBold = new System.Windows.Forms.ToolStripButton(); this.m_tbFormatItalic = new System.Windows.Forms.ToolStripButton(); this.m_tbFormatUnderline = new System.Windows.Forms.ToolStripButton(); this.m_tbFormatStrikeout = new System.Windows.Forms.ToolStripButton(); this.m_tbFormatSep1 = new System.Windows.Forms.ToolStripSeparator(); this.m_tbColorForeground = new System.Windows.Forms.ToolStripButton(); this.m_tbColorBackground = new System.Windows.Forms.ToolStripButton(); this.m_tbFormatSep2 = new System.Windows.Forms.ToolStripSeparator(); this.m_tbAlignLeft = new System.Windows.Forms.ToolStripButton(); this.m_tbAlignCenter = new System.Windows.Forms.ToolStripButton(); this.m_tbAlignRight = new System.Windows.Forms.ToolStripButton(); this.m_statusMain = new System.Windows.Forms.StatusStrip(); this.m_tssStatusMain = new System.Windows.Forms.ToolStripStatusLabel(); this.m_rtbText = new KeePass.UI.CustomRichTextBoxEx(); this.m_menuMain.SuspendLayout(); this.m_toolFile.SuspendLayout(); this.m_toolFormat.SuspendLayout(); this.m_statusMain.SuspendLayout(); this.SuspendLayout(); // // m_menuMain // this.m_menuMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuFile, this.m_menuView}); this.m_menuMain.Location = new System.Drawing.Point(0, 0); this.m_menuMain.Name = "m_menuMain"; this.m_menuMain.Size = new System.Drawing.Size(608, 24); this.m_menuMain.TabIndex = 1; // // m_menuFile // this.m_menuFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuFileSave, this.m_menuFileSep0, this.m_menuFileExit}); this.m_menuFile.Name = "m_menuFile"; this.m_menuFile.Size = new System.Drawing.Size(39, 20); this.m_menuFile.Text = "&File"; // // m_menuFileSave // this.m_menuFileSave.Image = global::KeePass.Properties.Resources.B16x16_FileSave; this.m_menuFileSave.Name = "m_menuFileSave"; this.m_menuFileSave.Size = new System.Drawing.Size(105, 22); this.m_menuFileSave.Text = "&Save"; this.m_menuFileSave.Click += new System.EventHandler(this.OnFileSave); // // m_menuFileSep0 // this.m_menuFileSep0.Name = "m_menuFileSep0"; this.m_menuFileSep0.Size = new System.Drawing.Size(102, 6); // // m_menuFileExit // this.m_menuFileExit.Image = global::KeePass.Properties.Resources.B16x16_Exit; this.m_menuFileExit.Name = "m_menuFileExit"; this.m_menuFileExit.Size = new System.Drawing.Size(105, 22); this.m_menuFileExit.Text = "&Close"; this.m_menuFileExit.Click += new System.EventHandler(this.OnFileExit); // // m_menuView // this.m_menuView.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_menuViewFont, this.m_menuViewSep0, this.m_menuViewWordWrap}); this.m_menuView.Name = "m_menuView"; this.m_menuView.Size = new System.Drawing.Size(45, 20); this.m_menuView.Text = "&View"; // // m_menuViewFont // this.m_menuViewFont.Name = "m_menuViewFont"; this.m_menuViewFont.Size = new System.Drawing.Size(135, 22); this.m_menuViewFont.Text = "&Font..."; this.m_menuViewFont.Click += new System.EventHandler(this.OnViewFont); // // m_menuViewSep0 // this.m_menuViewSep0.Name = "m_menuViewSep0"; this.m_menuViewSep0.Size = new System.Drawing.Size(132, 6); // // m_menuViewWordWrap // this.m_menuViewWordWrap.Name = "m_menuViewWordWrap"; this.m_menuViewWordWrap.Size = new System.Drawing.Size(135, 22); this.m_menuViewWordWrap.Text = "Word &Wrap"; this.m_menuViewWordWrap.Click += new System.EventHandler(this.OnViewWordWrap); // // m_toolFile // this.m_toolFile.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_tbFileSave, this.m_tbFileSep0, this.m_tbEditCut, this.m_tbEditCopy, this.m_tbEditPaste, this.m_tbFileSep1, this.m_tbEditUndo, this.m_tbEditRedo, this.m_tbFileSep2, this.m_tbFind}); this.m_toolFile.Location = new System.Drawing.Point(0, 24); this.m_toolFile.Name = "m_toolFile"; this.m_toolFile.Size = new System.Drawing.Size(608, 25); this.m_toolFile.TabIndex = 2; // // m_tbFileSave // this.m_tbFileSave.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbFileSave.Image = global::KeePass.Properties.Resources.B16x16_FileSave; this.m_tbFileSave.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbFileSave.Name = "m_tbFileSave"; this.m_tbFileSave.Size = new System.Drawing.Size(23, 22); this.m_tbFileSave.Click += new System.EventHandler(this.OnFileSave); // // m_tbFileSep0 // this.m_tbFileSep0.Name = "m_tbFileSep0"; this.m_tbFileSep0.Size = new System.Drawing.Size(6, 25); // // m_tbEditCut // this.m_tbEditCut.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbEditCut.Image = global::KeePass.Properties.Resources.B16x16_Cut; this.m_tbEditCut.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbEditCut.Name = "m_tbEditCut"; this.m_tbEditCut.Size = new System.Drawing.Size(23, 22); this.m_tbEditCut.Click += new System.EventHandler(this.OnEditCut); // // m_tbEditCopy // this.m_tbEditCopy.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbEditCopy.Image = global::KeePass.Properties.Resources.B16x16_EditCopy; this.m_tbEditCopy.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbEditCopy.Name = "m_tbEditCopy"; this.m_tbEditCopy.Size = new System.Drawing.Size(23, 22); this.m_tbEditCopy.Click += new System.EventHandler(this.OnEditCopy); // // m_tbEditPaste // this.m_tbEditPaste.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbEditPaste.Image = global::KeePass.Properties.Resources.B16x16_EditPaste; this.m_tbEditPaste.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbEditPaste.Name = "m_tbEditPaste"; this.m_tbEditPaste.Size = new System.Drawing.Size(23, 22); this.m_tbEditPaste.Click += new System.EventHandler(this.OnEditPaste); // // m_tbFileSep1 // this.m_tbFileSep1.Name = "m_tbFileSep1"; this.m_tbFileSep1.Size = new System.Drawing.Size(6, 25); // // m_tbEditUndo // this.m_tbEditUndo.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbEditUndo.Image = global::KeePass.Properties.Resources.B16x16_Undo; this.m_tbEditUndo.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbEditUndo.Name = "m_tbEditUndo"; this.m_tbEditUndo.Size = new System.Drawing.Size(23, 22); this.m_tbEditUndo.Click += new System.EventHandler(this.OnEditUndo); // // m_tbEditRedo // this.m_tbEditRedo.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbEditRedo.Image = global::KeePass.Properties.Resources.B16x16_Redo; this.m_tbEditRedo.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbEditRedo.Name = "m_tbEditRedo"; this.m_tbEditRedo.Size = new System.Drawing.Size(23, 22); this.m_tbEditRedo.Click += new System.EventHandler(this.OnEditRedo); // // m_tbFileSep2 // this.m_tbFileSep2.Name = "m_tbFileSep2"; this.m_tbFileSep2.Size = new System.Drawing.Size(6, 25); // // m_tbFind // this.m_tbFind.AcceptsReturn = true; this.m_tbFind.Name = "m_tbFind"; this.m_tbFind.Size = new System.Drawing.Size(121, 25); this.m_tbFind.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnTextFindKeyDown); this.m_tbFind.KeyUp += new System.Windows.Forms.KeyEventHandler(this.OnTextFindKeyUp); // // m_toolFormat // this.m_toolFormat.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_tbFontCombo, this.m_tbFontSizeCombo, this.m_tbFormatSep0, this.m_tbFormatBold, this.m_tbFormatItalic, this.m_tbFormatUnderline, this.m_tbFormatStrikeout, this.m_tbFormatSep1, this.m_tbColorForeground, this.m_tbColorBackground, this.m_tbFormatSep2, this.m_tbAlignLeft, this.m_tbAlignCenter, this.m_tbAlignRight}); this.m_toolFormat.Location = new System.Drawing.Point(0, 49); this.m_toolFormat.Name = "m_toolFormat"; this.m_toolFormat.Size = new System.Drawing.Size(608, 25); this.m_toolFormat.TabIndex = 3; // // m_tbFontCombo // this.m_tbFontCombo.Name = "m_tbFontCombo"; this.m_tbFontCombo.Size = new System.Drawing.Size(160, 25); this.m_tbFontCombo.SelectedIndexChanged += new System.EventHandler(this.OnFontComboSelectedIndexChanged); this.m_tbFontCombo.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnFontComboKeyDown); // // m_tbFontSizeCombo // this.m_tbFontSizeCombo.Name = "m_tbFontSizeCombo"; this.m_tbFontSizeCombo.Size = new System.Drawing.Size(75, 25); this.m_tbFontSizeCombo.SelectedIndexChanged += new System.EventHandler(this.OnFontSizeComboSelectedIndexChanged); this.m_tbFontSizeCombo.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnFontSizeComboKeyDown); // // m_tbFormatSep0 // this.m_tbFormatSep0.Name = "m_tbFormatSep0"; this.m_tbFormatSep0.Size = new System.Drawing.Size(6, 25); // // m_tbFormatBold // this.m_tbFormatBold.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbFormatBold.Image = global::KeePass.Properties.Resources.B16x16_FontBold; this.m_tbFormatBold.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbFormatBold.Name = "m_tbFormatBold"; this.m_tbFormatBold.Size = new System.Drawing.Size(23, 22); this.m_tbFormatBold.Click += new System.EventHandler(this.OnFormatBoldClicked); // // m_tbFormatItalic // this.m_tbFormatItalic.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbFormatItalic.Image = global::KeePass.Properties.Resources.B16x16_FontItalic; this.m_tbFormatItalic.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbFormatItalic.Name = "m_tbFormatItalic"; this.m_tbFormatItalic.Size = new System.Drawing.Size(23, 22); this.m_tbFormatItalic.Click += new System.EventHandler(this.OnFormatItalicClicked); // // m_tbFormatUnderline // this.m_tbFormatUnderline.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbFormatUnderline.Image = global::KeePass.Properties.Resources.B16x16_FontUnderline; this.m_tbFormatUnderline.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbFormatUnderline.Name = "m_tbFormatUnderline"; this.m_tbFormatUnderline.Size = new System.Drawing.Size(23, 22); this.m_tbFormatUnderline.Click += new System.EventHandler(this.OnFormatUnderlineClicked); // // m_tbFormatStrikeout // this.m_tbFormatStrikeout.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbFormatStrikeout.Image = global::KeePass.Properties.Resources.B16x16_FontStrikeout; this.m_tbFormatStrikeout.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbFormatStrikeout.Name = "m_tbFormatStrikeout"; this.m_tbFormatStrikeout.Size = new System.Drawing.Size(23, 22); this.m_tbFormatStrikeout.Click += new System.EventHandler(this.OnFormatStrikeoutClicked); // // m_tbFormatSep1 // this.m_tbFormatSep1.Name = "m_tbFormatSep1"; this.m_tbFormatSep1.Size = new System.Drawing.Size(6, 25); // // m_tbColorForeground // this.m_tbColorForeground.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbColorForeground.Image = global::KeePass.Properties.Resources.B16x16_Colorize; this.m_tbColorForeground.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbColorForeground.Name = "m_tbColorForeground"; this.m_tbColorForeground.Size = new System.Drawing.Size(23, 22); this.m_tbColorForeground.Click += new System.EventHandler(this.OnColorForegroundClicked); // // m_tbColorBackground // this.m_tbColorBackground.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbColorBackground.Image = global::KeePass.Properties.Resources.B16x16_Color_Fill; this.m_tbColorBackground.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbColorBackground.Name = "m_tbColorBackground"; this.m_tbColorBackground.Size = new System.Drawing.Size(23, 22); this.m_tbColorBackground.Click += new System.EventHandler(this.OnColorBackgroundClicked); // // m_tbFormatSep2 // this.m_tbFormatSep2.Name = "m_tbFormatSep2"; this.m_tbFormatSep2.Size = new System.Drawing.Size(6, 25); // // m_tbAlignLeft // this.m_tbAlignLeft.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbAlignLeft.Image = global::KeePass.Properties.Resources.B16x16_TextAlignLeft; this.m_tbAlignLeft.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbAlignLeft.Name = "m_tbAlignLeft"; this.m_tbAlignLeft.Size = new System.Drawing.Size(23, 22); this.m_tbAlignLeft.Click += new System.EventHandler(this.OnAlignLeftClicked); // // m_tbAlignCenter // this.m_tbAlignCenter.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbAlignCenter.Image = global::KeePass.Properties.Resources.B16x16_TextAlignCenter; this.m_tbAlignCenter.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbAlignCenter.Name = "m_tbAlignCenter"; this.m_tbAlignCenter.Size = new System.Drawing.Size(23, 22); this.m_tbAlignCenter.Click += new System.EventHandler(this.OnAlignCenterClicked); // // m_tbAlignRight // this.m_tbAlignRight.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.m_tbAlignRight.Image = global::KeePass.Properties.Resources.B16x16_TextAlignRight; this.m_tbAlignRight.ImageTransparentColor = System.Drawing.Color.Magenta; this.m_tbAlignRight.Name = "m_tbAlignRight"; this.m_tbAlignRight.Size = new System.Drawing.Size(23, 22); this.m_tbAlignRight.Click += new System.EventHandler(this.OnAlignRightClicked); // // m_statusMain // this.m_statusMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_tssStatusMain}); this.m_statusMain.Location = new System.Drawing.Point(0, 394); this.m_statusMain.Name = "m_statusMain"; this.m_statusMain.Size = new System.Drawing.Size(608, 22); this.m_statusMain.TabIndex = 4; // // m_tssStatusMain // this.m_tssStatusMain.Name = "m_tssStatusMain"; this.m_tssStatusMain.Size = new System.Drawing.Size(593, 17); this.m_tssStatusMain.Spring = true; this.m_tssStatusMain.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // m_rtbText // this.m_rtbText.AcceptsTab = true; this.m_rtbText.HideSelection = false; this.m_rtbText.Location = new System.Drawing.Point(25, 102); this.m_rtbText.Name = "m_rtbText"; this.m_rtbText.Size = new System.Drawing.Size(100, 96); this.m_rtbText.TabIndex = 0; this.m_rtbText.Text = ""; this.m_rtbText.SelectionChanged += new System.EventHandler(this.OnTextSelectionChanged); this.m_rtbText.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.OnTextLinkClicked); this.m_rtbText.TextChanged += new System.EventHandler(this.OnTextTextChanged); // // DataEditorForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(608, 416); this.Controls.Add(this.m_rtbText); this.Controls.Add(this.m_statusMain); this.Controls.Add(this.m_toolFormat); this.Controls.Add(this.m_toolFile); this.Controls.Add(this.m_menuMain); this.MainMenuStrip = this.m_menuMain; this.MinimizeBox = false; this.Name = "DataEditorForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "<>"; this.Load += new System.EventHandler(this.OnFormLoad); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing); this.m_menuMain.ResumeLayout(false); this.m_menuMain.PerformLayout(); this.m_toolFile.ResumeLayout(false); this.m_toolFile.PerformLayout(); this.m_toolFormat.ResumeLayout(false); this.m_toolFormat.PerformLayout(); this.m_statusMain.ResumeLayout(false); this.m_statusMain.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private KeePass.UI.CustomRichTextBoxEx m_rtbText; private System.Windows.Forms.MenuStrip m_menuMain; private System.Windows.Forms.ToolStripMenuItem m_menuFile; private System.Windows.Forms.ToolStripMenuItem m_menuFileSave; private System.Windows.Forms.ToolStripSeparator m_menuFileSep0; private System.Windows.Forms.ToolStripMenuItem m_menuFileExit; private System.Windows.Forms.ToolStrip m_toolFile; private System.Windows.Forms.ToolStripButton m_tbFileSave; private System.Windows.Forms.ToolStrip m_toolFormat; private System.Windows.Forms.ToolStripComboBox m_tbFontCombo; private System.Windows.Forms.StatusStrip m_statusMain; private System.Windows.Forms.ToolStripComboBox m_tbFontSizeCombo; private System.Windows.Forms.ToolStripSeparator m_tbFormatSep0; private System.Windows.Forms.ToolStripButton m_tbFormatBold; private System.Windows.Forms.ToolStripButton m_tbFormatItalic; private System.Windows.Forms.ToolStripButton m_tbFormatUnderline; private System.Windows.Forms.ToolStripButton m_tbFormatStrikeout; private System.Windows.Forms.ToolStripButton m_tbColorForeground; private System.Windows.Forms.ToolStripButton m_tbColorBackground; private System.Windows.Forms.ToolStripSeparator m_tbFormatSep1; private System.Windows.Forms.ToolStripSeparator m_tbFormatSep2; private System.Windows.Forms.ToolStripButton m_tbAlignLeft; private System.Windows.Forms.ToolStripButton m_tbAlignCenter; private System.Windows.Forms.ToolStripButton m_tbAlignRight; private System.Windows.Forms.ToolStripSeparator m_tbFileSep0; private System.Windows.Forms.ToolStripButton m_tbEditCut; private System.Windows.Forms.ToolStripButton m_tbEditCopy; private System.Windows.Forms.ToolStripButton m_tbEditPaste; private System.Windows.Forms.ToolStripSeparator m_tbFileSep1; private System.Windows.Forms.ToolStripButton m_tbEditUndo; private System.Windows.Forms.ToolStripButton m_tbEditRedo; private System.Windows.Forms.ToolStripMenuItem m_menuView; private System.Windows.Forms.ToolStripMenuItem m_menuViewFont; private System.Windows.Forms.ToolStripSeparator m_menuViewSep0; private System.Windows.Forms.ToolStripMenuItem m_menuViewWordWrap; private System.Windows.Forms.ToolStripStatusLabel m_tssStatusMain; private System.Windows.Forms.ToolStripSeparator m_tbFileSep2; private System.Windows.Forms.ToolStripTextBox m_tbFind; } }keepass2-2.25/KeePass/Forms/PluginsForm.cs0000664000175000017500000001217012261553106020332 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePass.Plugins; using KeePass.Resources; using KeePass.UI; using KeePass.Util; using KeePassLib; using KeePassLib.Utility; namespace KeePass.Forms { public partial class PluginsForm : Form, IGwmWindow { private PluginManager m_mgr = null; private bool m_bBlockListUpdate = false; private ImageList m_ilIcons = new ImageList(); public bool CanCloseWithoutDataLoss { get { return true; } } internal void InitEx(PluginManager mgr) { Debug.Assert(mgr != null); m_mgr = mgr; } public PluginsForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_mgr != null); if(m_mgr == null) throw new ArgumentException(); GlobalWindowManager.AddWindow(this, this); BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_BlockDevice, KPRes.Plugins, KPRes.PluginsDesc); this.Icon = Properties.Resources.KeePass; m_cbCacheDeleteOld.Checked = Program.Config.Application.Start.PluginCacheDeleteOld; m_lvPlugins.Columns.Add(KPRes.Plugin, 197); m_lvPlugins.Columns.Add(KPRes.Version, 106); m_lvPlugins.Columns.Add(KPRes.Author, 136); m_lvPlugins.Columns.Add(KPRes.Description, 0); m_lvPlugins.Columns.Add(KPRes.File, 119); m_ilIcons.ImageSize = new Size(16, 16); m_ilIcons.ColorDepth = ColorDepth.Depth32Bit; m_lblCacheSize.Text += " " + StrUtil.FormatDataSize( PlgxCache.GetUsedCacheSize()) + "."; m_lvPlugins.SmallImageList = m_ilIcons; UpdatePluginsList(); if(m_lvPlugins.Items.Count > 0) { m_lvPlugins.Items[0].Selected = true; UIUtil.SetFocus(m_lvPlugins, this); } UpdatePluginDescription(); } private void CleanUpEx() { if(m_ilIcons != null) { m_lvPlugins.SmallImageList = null; // Detach event handlers m_ilIcons.Dispose(); m_ilIcons = null; } } private void UpdatePluginsList() { if(m_bBlockListUpdate) return; m_bBlockListUpdate = true; m_lvPlugins.Items.Clear(); m_ilIcons.Images.Clear(); m_ilIcons.Images.Add(Properties.Resources.B16x16_BlockDevice); foreach(PluginInfo plugin in m_mgr) { ListViewItem lvi = new ListViewItem(plugin.Name); ListViewItem lviNew = m_lvPlugins.Items.Add(lvi); lviNew.SubItems.Add(plugin.FileVersion); lviNew.SubItems.Add(plugin.Author); lviNew.SubItems.Add(plugin.Description); lviNew.SubItems.Add(plugin.DisplayFilePath); int nImageIndex = 0; Debug.Assert(plugin.Interface != null); if((plugin.Interface != null) && (plugin.Interface.SmallIcon != null)) { nImageIndex = m_ilIcons.Images.Count; m_ilIcons.Images.Add(plugin.Interface.SmallIcon); } lviNew.ImageIndex = nImageIndex; } m_bBlockListUpdate = false; UpdatePluginDescription(); } private void UpdatePluginDescription() { ListView.SelectedListViewItemCollection lvsic = m_lvPlugins.SelectedItems; if(lvsic.Count == 0) { m_grpPluginDesc.Text = string.Empty; m_lblSelectedPluginDesc.Text = string.Empty; return; } ListViewItem lvi = lvsic[0]; m_grpPluginDesc.Text = lvi.SubItems[0].Text; m_lblSelectedPluginDesc.Text = lvi.SubItems[3].Text; } private void OnBtnClose(object sender, EventArgs e) { } private void OnPluginListSelectedIndexChanged(object sender, EventArgs e) { UpdatePluginDescription(); } private void OnPluginsLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { WinUtil.OpenUrl(PwDefs.PluginsUrl, null); } private void OnFormClosed(object sender, FormClosedEventArgs e) { CleanUpEx(); GlobalWindowManager.RemoveWindow(this); } private void OnBtnClearCache(object sender, EventArgs e) { Program.Config.Application.Start.PluginCacheClearOnce = true; MessageService.ShowInfo(KPRes.PluginCacheClearInfo); } private void OnFormClosing(object sender, FormClosingEventArgs e) { Program.Config.Application.Start.PluginCacheDeleteOld = m_cbCacheDeleteOld.Checked; } } } keepass2-2.25/KeePass/Forms/ExchangeDataForm.cs0000664000175000017500000002250112261553106021224 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.App; using KeePass.DataExchange; using KeePass.Resources; using KeePass.UI; using KeePassLib; using KeePassLib.Utility; namespace KeePass.Forms { public partial class ExchangeDataForm : Form { private bool m_bExport = false; private PwDatabase m_pwDatabaseInfo = null; private PwGroup m_pgRootInfo = null; private ImageList m_ilFormats = null; private FileFormatProvider m_fmtCur = null; // Current selection private FileFormatProvider m_fmtFinal = null; // Returned as result private string[] m_vFiles = null; internal sealed class FormatGroupEx { private ListViewGroup m_lvg; public ListViewGroup Group { get { return m_lvg; } } private List m_vItems = new List(); public List Items { get { return m_vItems; } } public FormatGroupEx(string strGroupName) { m_lvg = new ListViewGroup(strGroupName); } } public FileFormatProvider ResultFormat { get { return m_fmtFinal; } } public string[] ResultFiles { get { return m_vFiles; } } public void InitEx(bool bExport, PwDatabase pwDatabaseInfo, PwGroup pgRootInfo) { m_bExport = bExport; m_pwDatabaseInfo = pwDatabaseInfo; m_pgRootInfo = pgRootInfo; } public ExchangeDataForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } private void OnFormLoad(object sender, EventArgs e) { Debug.Assert((m_pwDatabaseInfo != null) || (m_pgRootInfo != null)); if((m_pwDatabaseInfo == null) && (m_pgRootInfo == null)) throw new InvalidOperationException(); GlobalWindowManager.AddWindow(this); string strWndTitle = (m_bExport ? KPRes.ExportFileTitle : KPRes.ImportFileTitle); string strWndDesc = (m_bExport ? KPRes.ExportFileDesc : KPRes.ImportFileDesc); Bitmap bmpBanner = (m_bExport ? Properties.Resources.B48x48_Folder_Txt : Properties.Resources.B48x48_Folder_Download); BannerFactory.CreateBannerEx(this, m_bannerImage, bmpBanner, strWndTitle, strWndDesc); this.Icon = Properties.Resources.KeePass; this.Text = strWndTitle; if(m_bExport) { m_lblFile.Text = KPRes.ExportToPrompt; UIUtil.SetButtonImage(m_btnSelFile, Properties.Resources.B16x16_FileSaveAs, false); m_lnkFileFormats.Enabled = false; m_lnkFileFormats.Visible = false; } else // Import mode { m_lblFile.Text = KPRes.ImportFilesPrompt; UIUtil.SetButtonImage(m_btnSelFile, Properties.Resources.B16x16_Folder_Yellow_Open, false); } m_lvFormats.ShowGroups = true; m_lvFormats.Columns.Add(string.Empty); m_lvFormats.Columns[0].Width = m_lvFormats.ClientRectangle.Width - UIUtil.GetVScrollBarWidth() - 1; m_ilFormats = new ImageList(); m_ilFormats.ColorDepth = ColorDepth.Depth32Bit; m_ilFormats.ImageSize = new Size(16, 16); Dictionary dictGroups = new Dictionary(); foreach(FileFormatProvider f in Program.FileFormatPool) { if(m_bExport && (f.SupportsExport == false)) continue; if((m_bExport == false) && (f.SupportsImport == false)) continue; string strDisplayName = f.DisplayName; if((strDisplayName == null) || (strDisplayName.Length == 0)) continue; string strAppGroup = f.ApplicationGroup; if((strAppGroup == null) || (strAppGroup.Length == 0)) strAppGroup = KPRes.General; FormatGroupEx grp; if(!dictGroups.TryGetValue(strAppGroup, out grp)) { grp = new FormatGroupEx(strAppGroup); dictGroups.Add(strAppGroup, grp); } ListViewItem lvi = new ListViewItem(strDisplayName); lvi.Group = grp.Group; lvi.Tag = f; Image imgSmallIcon = f.SmallIcon; if(imgSmallIcon == null) imgSmallIcon = Properties.Resources.B16x16_Folder_Inbox; m_ilFormats.Images.Add(imgSmallIcon); lvi.ImageIndex = m_ilFormats.Images.Count - 1; grp.Items.Add(lvi); } foreach(FormatGroupEx formatGroup in dictGroups.Values) { m_lvFormats.Groups.Add(formatGroup.Group); foreach(ListViewItem lvi in formatGroup.Items) m_lvFormats.Items.Add(lvi); } m_lvFormats.SmallImageList = m_ilFormats; CustomizeForScreenReader(); UpdateUIState(); } private void CleanUpEx() { if(m_ilFormats != null) { m_lvFormats.SmallImageList = null; // Detach event handlers m_ilFormats.Dispose(); m_ilFormats = null; } } private void CustomizeForScreenReader() { if(!Program.Config.UI.OptimizeForScreenReader) return; m_btnSelFile.Text = KPRes.SelectFile; } private void OnLinkFileFormats(object sender, LinkLabelLinkClickedEventArgs e) { AppHelp.ShowHelp(AppDefs.HelpTopics.ImportExport, null); } private void OnBtnSelFile(object sender, EventArgs e) { if(m_fmtCur == null) { Debug.Assert(false); return; } if(!m_fmtCur.RequiresFile) return; // Break on double-click string strFormat = m_fmtCur.FormatName; if(string.IsNullOrEmpty(strFormat)) strFormat = KPRes.Data; string strExts = m_fmtCur.DefaultExtension; if(string.IsNullOrEmpty(strExts)) strExts = "export"; string strPriExt = UIUtil.GetPrimaryFileTypeExt(strExts); if(strPriExt.Length == 0) strPriExt = "export"; // In case of "|" string strFilter = UIUtil.CreateFileTypeFilter(strExts, strFormat, true); if(m_bExport == false) // Import { OpenFileDialogEx ofd = UIUtil.CreateOpenFileDialog(KPRes.Import + ": " + strFormat, strFilter, 1, strPriExt, true, AppDefs.FileDialogContext.Import); if(ofd.ShowDialog() != DialogResult.OK) return; StringBuilder sb = new StringBuilder(); foreach(string str in ofd.FileNames) { if(sb.Length > 0) sb.Append(';'); if(str.IndexOf(';') >= 0) MessageService.ShowWarning(str, KPRes.FileNameContainsSemicolonError); else sb.Append(str); } string strFiles = sb.ToString(); if(strFiles.Length < m_tbFile.MaxLength) m_tbFile.Text = strFiles; else MessageService.ShowWarning(KPRes.TooManyFilesError); } else // Export { SaveFileDialogEx sfd = UIUtil.CreateSaveFileDialog(KPRes.Export + ": " + strFormat, null, strFilter, 1, strPriExt, AppDefs.FileDialogContext.Export); string strSuggestion; if((m_pwDatabaseInfo != null) && (m_pwDatabaseInfo.IOConnectionInfo.Path.Length > 0)) { strSuggestion = UrlUtil.StripExtension(UrlUtil.GetFileName( m_pwDatabaseInfo.IOConnectionInfo.Path)); } else strSuggestion = KPRes.Database; strSuggestion += "." + strPriExt; sfd.FileName = strSuggestion; if(sfd.ShowDialog() != DialogResult.OK) return; m_tbFile.Text = sfd.FileName; } UpdateUIState(); } private void OnBtnOK(object sender, EventArgs e) { if(!PrepareExchangeEx()) this.DialogResult = DialogResult.None; } private void OnBtnCancel(object sender, EventArgs e) { } private void UpdateUIState() { bool bFormatSelected = true; ListView.SelectedListViewItemCollection lvsc = m_lvFormats.SelectedItems; if((lvsc == null) || (lvsc.Count != 1)) bFormatSelected = false; if(bFormatSelected) m_fmtCur = (lvsc[0].Tag as FileFormatProvider); else m_fmtCur = null; if(m_fmtCur != null) m_tbFile.Enabled = m_btnSelFile.Enabled = m_fmtCur.RequiresFile; else m_tbFile.Enabled = m_btnSelFile.Enabled = false; m_btnOK.Enabled = (bFormatSelected && ((m_tbFile.Text.Length != 0) || !m_fmtCur.RequiresFile)); } private bool PrepareExchangeEx() { UpdateUIState(); if(m_fmtCur == null) return false; m_fmtFinal = m_fmtCur; m_vFiles = m_tbFile.Text.Split(new char[]{ ';' }, StringSplitOptions.RemoveEmptyEntries); if(m_bExport) { Debug.Assert(m_vFiles.Length <= 1); } return true; } private void OnFormatsSelectedIndexChanged(object sender, EventArgs e) { UpdateUIState(); } private void OnFormClosed(object sender, FormClosedEventArgs e) { CleanUpEx(); GlobalWindowManager.RemoveWindow(this); } private void OnImportFileTextChanged(object sender, EventArgs e) { UpdateUIState(); } private void OnFormatsItemActivate(object sender, EventArgs e) { OnBtnSelFile(sender, e); } } } keepass2-2.25/KeePass/Forms/EditStringForm.Designer.cs0000664000175000017500000002103211527513164022525 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class EditStringForm { /// /// 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() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditStringForm)); this.m_bannerImage = new System.Windows.Forms.PictureBox(); this.m_lblStringValueDesc = new System.Windows.Forms.Label(); this.m_lblStringIdDesc = new System.Windows.Forms.Label(); this.m_lblIDIntro = new System.Windows.Forms.Label(); this.m_richStringValue = new KeePass.UI.CustomRichTextBoxEx(); this.m_lblSeparator = new System.Windows.Forms.Label(); this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_btnHelp = new System.Windows.Forms.Button(); this.m_cbProtect = new System.Windows.Forms.CheckBox(); this.m_lblValidationInfo = new System.Windows.Forms.Label(); this.m_cmbStringName = new System.Windows.Forms.ComboBox(); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).BeginInit(); this.SuspendLayout(); // // m_bannerImage // this.m_bannerImage.Dock = System.Windows.Forms.DockStyle.Top; this.m_bannerImage.Location = new System.Drawing.Point(0, 0); this.m_bannerImage.Name = "m_bannerImage"; this.m_bannerImage.Size = new System.Drawing.Size(409, 60); this.m_bannerImage.TabIndex = 0; this.m_bannerImage.TabStop = false; // // m_lblStringValueDesc // this.m_lblStringValueDesc.AutoSize = true; this.m_lblStringValueDesc.Location = new System.Drawing.Point(12, 156); this.m_lblStringValueDesc.Name = "m_lblStringValueDesc"; this.m_lblStringValueDesc.Size = new System.Drawing.Size(37, 13); this.m_lblStringValueDesc.TabIndex = 2; this.m_lblStringValueDesc.Text = "Value:"; // // m_lblStringIdDesc // this.m_lblStringIdDesc.AutoSize = true; this.m_lblStringIdDesc.Location = new System.Drawing.Point(12, 116); this.m_lblStringIdDesc.Name = "m_lblStringIdDesc"; this.m_lblStringIdDesc.Size = new System.Drawing.Size(38, 13); this.m_lblStringIdDesc.TabIndex = 10; this.m_lblStringIdDesc.Text = "Name:"; // // m_lblIDIntro // this.m_lblIDIntro.Location = new System.Drawing.Point(12, 67); this.m_lblIDIntro.Name = "m_lblIDIntro"; this.m_lblIDIntro.Size = new System.Drawing.Size(385, 40); this.m_lblIDIntro.TabIndex = 9; this.m_lblIDIntro.Text = resources.GetString("m_lblIDIntro.Text"); // // m_richStringValue // this.m_richStringValue.Location = new System.Drawing.Point(56, 154); this.m_richStringValue.Name = "m_richStringValue"; this.m_richStringValue.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical; this.m_richStringValue.Size = new System.Drawing.Size(341, 78); this.m_richStringValue.TabIndex = 3; this.m_richStringValue.Text = ""; // // m_lblSeparator // this.m_lblSeparator.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.m_lblSeparator.Location = new System.Drawing.Point(0, 271); this.m_lblSeparator.Name = "m_lblSeparator"; this.m_lblSeparator.Size = new System.Drawing.Size(409, 2); this.m_lblSeparator.TabIndex = 5; // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(241, 282); this.m_btnOK.Name = "m_btnOK"; this.m_btnOK.Size = new System.Drawing.Size(75, 23); this.m_btnOK.TabIndex = 6; this.m_btnOK.Text = "&OK"; 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(322, 282); this.m_btnCancel.Name = "m_btnCancel"; this.m_btnCancel.Size = new System.Drawing.Size(75, 23); this.m_btnCancel.TabIndex = 7; this.m_btnCancel.Text = "&Cancel"; this.m_btnCancel.UseVisualStyleBackColor = true; this.m_btnCancel.Click += new System.EventHandler(this.OnBtnCancel); // // m_btnHelp // this.m_btnHelp.Location = new System.Drawing.Point(12, 282); this.m_btnHelp.Name = "m_btnHelp"; this.m_btnHelp.Size = new System.Drawing.Size(75, 23); this.m_btnHelp.TabIndex = 8; this.m_btnHelp.Text = "&Help"; this.m_btnHelp.UseVisualStyleBackColor = true; this.m_btnHelp.Click += new System.EventHandler(this.OnBtnHelp); // // m_cbProtect // this.m_cbProtect.AutoSize = true; this.m_cbProtect.Location = new System.Drawing.Point(56, 238); this.m_cbProtect.Name = "m_cbProtect"; this.m_cbProtect.Size = new System.Drawing.Size(159, 17); this.m_cbProtect.TabIndex = 4; this.m_cbProtect.Text = "Enable in-memory &protection"; this.m_cbProtect.UseVisualStyleBackColor = true; // // m_lblValidationInfo // this.m_lblValidationInfo.ForeColor = System.Drawing.Color.Crimson; this.m_lblValidationInfo.Location = new System.Drawing.Point(53, 137); this.m_lblValidationInfo.Name = "m_lblValidationInfo"; this.m_lblValidationInfo.Size = new System.Drawing.Size(344, 14); this.m_lblValidationInfo.TabIndex = 1; this.m_lblValidationInfo.Text = "<>"; // // m_cmbStringName // this.m_cmbStringName.FormattingEnabled = true; this.m_cmbStringName.Location = new System.Drawing.Point(56, 113); this.m_cmbStringName.Name = "m_cmbStringName"; this.m_cmbStringName.Size = new System.Drawing.Size(341, 21); this.m_cmbStringName.TabIndex = 0; this.m_cmbStringName.TextChanged += new System.EventHandler(this.OnNameTextChanged); // // EditStringForm // 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(409, 317); this.Controls.Add(this.m_cmbStringName); this.Controls.Add(this.m_lblValidationInfo); this.Controls.Add(this.m_cbProtect); this.Controls.Add(this.m_btnHelp); this.Controls.Add(this.m_btnCancel); this.Controls.Add(this.m_btnOK); this.Controls.Add(this.m_lblSeparator); this.Controls.Add(this.m_richStringValue); this.Controls.Add(this.m_lblIDIntro); this.Controls.Add(this.m_lblStringIdDesc); this.Controls.Add(this.m_lblStringValueDesc); this.Controls.Add(this.m_bannerImage); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "EditStringForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Edit Entry String"; this.Load += new System.EventHandler(this.OnFormLoad); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.PictureBox m_bannerImage; private System.Windows.Forms.Label m_lblStringValueDesc; private System.Windows.Forms.Label m_lblStringIdDesc; private System.Windows.Forms.Label m_lblIDIntro; private KeePass.UI.CustomRichTextBoxEx m_richStringValue; private System.Windows.Forms.Label m_lblSeparator; private System.Windows.Forms.Button m_btnOK; private System.Windows.Forms.Button m_btnCancel; private System.Windows.Forms.Button m_btnHelp; private System.Windows.Forms.CheckBox m_cbProtect; private System.Windows.Forms.Label m_lblValidationInfo; private System.Windows.Forms.ComboBox m_cmbStringName; } }keepass2-2.25/KeePass/Forms/UrlSchemeForm.Designer.cs0000664000175000017500000001074611230125006022333 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class UrlSchemeForm { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if(disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_lblScheme = new System.Windows.Forms.Label(); this.m_tbScheme = new System.Windows.Forms.TextBox(); this.m_lblUrlOverride = new System.Windows.Forms.Label(); this.m_tbOverride = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(160, 100); this.m_btnOK.Name = "m_btnOK"; this.m_btnOK.Size = new System.Drawing.Size(75, 23); this.m_btnOK.TabIndex = 3; this.m_btnOK.Text = "&OK"; 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(241, 100); this.m_btnCancel.Name = "m_btnCancel"; this.m_btnCancel.Size = new System.Drawing.Size(75, 23); this.m_btnCancel.TabIndex = 4; this.m_btnCancel.Text = "&Cancel"; this.m_btnCancel.UseVisualStyleBackColor = true; // // m_lblScheme // this.m_lblScheme.AutoSize = true; this.m_lblScheme.Location = new System.Drawing.Point(9, 15); this.m_lblScheme.Name = "m_lblScheme"; this.m_lblScheme.Size = new System.Drawing.Size(49, 13); this.m_lblScheme.TabIndex = 5; this.m_lblScheme.Text = "Scheme:"; // // m_tbScheme // this.m_tbScheme.Location = new System.Drawing.Point(64, 12); this.m_tbScheme.Name = "m_tbScheme"; this.m_tbScheme.Size = new System.Drawing.Size(252, 20); this.m_tbScheme.TabIndex = 0; // // m_lblUrlOverride // this.m_lblUrlOverride.AutoSize = true; this.m_lblUrlOverride.Location = new System.Drawing.Point(9, 45); this.m_lblUrlOverride.Name = "m_lblUrlOverride"; this.m_lblUrlOverride.Size = new System.Drawing.Size(73, 13); this.m_lblUrlOverride.TabIndex = 1; this.m_lblUrlOverride.Text = "URL override:"; // // m_tbOverride // this.m_tbOverride.Location = new System.Drawing.Point(12, 63); this.m_tbOverride.Name = "m_tbOverride"; this.m_tbOverride.Size = new System.Drawing.Size(304, 20); this.m_tbOverride.TabIndex = 2; // // UrlSchemeForm // 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(328, 135); this.Controls.Add(this.m_tbOverride); this.Controls.Add(this.m_lblUrlOverride); this.Controls.Add(this.m_tbScheme); this.Controls.Add(this.m_lblScheme); 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 = "UrlSchemeForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "<>"; 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_lblScheme; private System.Windows.Forms.TextBox m_tbScheme; private System.Windows.Forms.Label m_lblUrlOverride; private System.Windows.Forms.TextBox m_tbOverride; } }keepass2-2.25/KeePass/Forms/EcasTriggersForm.Designer.cs0000664000175000017500000003001211154001140023007 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class EcasTriggersForm { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if(disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.m_bannerImage = new System.Windows.Forms.PictureBox(); this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_lvTriggers = new KeePass.UI.CustomListViewEx(); this.m_btnAdd = new System.Windows.Forms.Button(); this.m_btnEdit = new System.Windows.Forms.Button(); this.m_btnDelete = new System.Windows.Forms.Button(); this.m_lblSep = new System.Windows.Forms.Label(); this.m_cbEnableTriggers = new System.Windows.Forms.CheckBox(); this.m_btnMoveUp = new System.Windows.Forms.Button(); this.m_btnMoveDown = new System.Windows.Forms.Button(); this.m_btnTools = new System.Windows.Forms.Button(); this.m_ctxTools = new System.Windows.Forms.ContextMenuStrip(this.components); this.m_ctxToolsHelp = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxToolsSep0 = new System.Windows.Forms.ToolStripSeparator(); this.m_ctxToolsCopyTriggers = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxToolsCopySelectedTriggers = new System.Windows.Forms.ToolStripMenuItem(); this.m_ctxToolsPasteTriggers = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).BeginInit(); this.m_ctxTools.SuspendLayout(); this.SuspendLayout(); // // m_bannerImage // this.m_bannerImage.Dock = System.Windows.Forms.DockStyle.Top; this.m_bannerImage.Location = new System.Drawing.Point(0, 0); this.m_bannerImage.Name = "m_bannerImage"; this.m_bannerImage.Size = new System.Drawing.Size(626, 60); this.m_bannerImage.TabIndex = 0; this.m_bannerImage.TabStop = false; // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(458, 389); 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 = "&OK"; 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(539, 389); 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_lvTriggers // this.m_lvTriggers.FullRowSelect = true; this.m_lvTriggers.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; this.m_lvTriggers.HideSelection = false; this.m_lvTriggers.Location = new System.Drawing.Point(12, 96); this.m_lvTriggers.Name = "m_lvTriggers"; this.m_lvTriggers.Size = new System.Drawing.Size(521, 268); this.m_lvTriggers.TabIndex = 3; this.m_lvTriggers.UseCompatibleStateImageBehavior = false; this.m_lvTriggers.View = System.Windows.Forms.View.Details; this.m_lvTriggers.ItemActivate += new System.EventHandler(this.OnTriggersItemActivate); this.m_lvTriggers.SelectedIndexChanged += new System.EventHandler(this.OnTriggersSelectedIndexChanged); // // m_btnAdd // this.m_btnAdd.Location = new System.Drawing.Point(539, 95); this.m_btnAdd.Name = "m_btnAdd"; this.m_btnAdd.Size = new System.Drawing.Size(75, 23); this.m_btnAdd.TabIndex = 4; this.m_btnAdd.Text = "&Add..."; this.m_btnAdd.UseVisualStyleBackColor = true; this.m_btnAdd.Click += new System.EventHandler(this.OnBtnAdd); // // m_btnEdit // this.m_btnEdit.Location = new System.Drawing.Point(539, 124); this.m_btnEdit.Name = "m_btnEdit"; this.m_btnEdit.Size = new System.Drawing.Size(75, 23); this.m_btnEdit.TabIndex = 5; this.m_btnEdit.Text = "&Edit..."; this.m_btnEdit.UseVisualStyleBackColor = true; this.m_btnEdit.Click += new System.EventHandler(this.OnBtnEdit); // // m_btnDelete // this.m_btnDelete.Location = new System.Drawing.Point(539, 153); this.m_btnDelete.Name = "m_btnDelete"; this.m_btnDelete.Size = new System.Drawing.Size(75, 23); this.m_btnDelete.TabIndex = 6; this.m_btnDelete.Text = "&Delete"; this.m_btnDelete.UseVisualStyleBackColor = true; this.m_btnDelete.Click += new System.EventHandler(this.OnBtnDelete); // // m_lblSep // this.m_lblSep.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.m_lblSep.Location = new System.Drawing.Point(0, 377); this.m_lblSep.Name = "m_lblSep"; this.m_lblSep.Size = new System.Drawing.Size(626, 2); this.m_lblSep.TabIndex = 9; // // m_cbEnableTriggers // this.m_cbEnableTriggers.AutoSize = true; this.m_cbEnableTriggers.Location = new System.Drawing.Point(12, 73); this.m_cbEnableTriggers.Name = "m_cbEnableTriggers"; this.m_cbEnableTriggers.Size = new System.Drawing.Size(126, 17); this.m_cbEnableTriggers.TabIndex = 2; this.m_cbEnableTriggers.Text = "Enable trigger system"; this.m_cbEnableTriggers.UseVisualStyleBackColor = true; // // m_btnMoveUp // this.m_btnMoveUp.Image = global::KeePass.Properties.Resources.B16x16_1UpArrow; this.m_btnMoveUp.Location = new System.Drawing.Point(539, 199); this.m_btnMoveUp.Name = "m_btnMoveUp"; this.m_btnMoveUp.Size = new System.Drawing.Size(75, 23); this.m_btnMoveUp.TabIndex = 7; this.m_btnMoveUp.UseVisualStyleBackColor = true; this.m_btnMoveUp.Click += new System.EventHandler(this.OnBtnMoveUp); // // m_btnMoveDown // this.m_btnMoveDown.Image = global::KeePass.Properties.Resources.B16x16_1DownArrow; this.m_btnMoveDown.Location = new System.Drawing.Point(539, 228); this.m_btnMoveDown.Name = "m_btnMoveDown"; this.m_btnMoveDown.Size = new System.Drawing.Size(75, 23); this.m_btnMoveDown.TabIndex = 8; this.m_btnMoveDown.UseVisualStyleBackColor = true; this.m_btnMoveDown.Click += new System.EventHandler(this.OnBtnMoveDown); // // m_btnTools // this.m_btnTools.Location = new System.Drawing.Point(12, 389); this.m_btnTools.Name = "m_btnTools"; this.m_btnTools.Size = new System.Drawing.Size(75, 23); this.m_btnTools.TabIndex = 10; this.m_btnTools.Text = "&Tools"; this.m_btnTools.UseVisualStyleBackColor = true; this.m_btnTools.Click += new System.EventHandler(this.OnBtnTools); // // m_ctxTools // this.m_ctxTools.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.m_ctxToolsHelp, this.m_ctxToolsSep0, this.m_ctxToolsCopyTriggers, this.m_ctxToolsCopySelectedTriggers, this.m_ctxToolsPasteTriggers}); this.m_ctxTools.Name = "m_ctxTools"; this.m_ctxTools.Size = new System.Drawing.Size(244, 98); // // m_ctxToolsHelp // this.m_ctxToolsHelp.Image = global::KeePass.Properties.Resources.B16x16_Help; this.m_ctxToolsHelp.Name = "m_ctxToolsHelp"; this.m_ctxToolsHelp.Size = new System.Drawing.Size(243, 22); this.m_ctxToolsHelp.Text = "&Help"; this.m_ctxToolsHelp.Click += new System.EventHandler(this.OnCtxToolsHelp); // // m_ctxToolsSep0 // this.m_ctxToolsSep0.Name = "m_ctxToolsSep0"; this.m_ctxToolsSep0.Size = new System.Drawing.Size(240, 6); // // m_ctxToolsCopyTriggers // this.m_ctxToolsCopyTriggers.Image = global::KeePass.Properties.Resources.B16x16_EditCopy; this.m_ctxToolsCopyTriggers.Name = "m_ctxToolsCopyTriggers"; this.m_ctxToolsCopyTriggers.Size = new System.Drawing.Size(243, 22); this.m_ctxToolsCopyTriggers.Text = "&Copy Triggers to Clipboard"; this.m_ctxToolsCopyTriggers.Click += new System.EventHandler(this.OnCtxToolsCopyTriggers); // // m_ctxToolsCopySelectedTriggers // this.m_ctxToolsCopySelectedTriggers.Image = global::KeePass.Properties.Resources.B16x16_EditCopy; this.m_ctxToolsCopySelectedTriggers.Name = "m_ctxToolsCopySelectedTriggers"; this.m_ctxToolsCopySelectedTriggers.Size = new System.Drawing.Size(243, 22); this.m_ctxToolsCopySelectedTriggers.Text = "Copy &Selected Triggers to Clipboard"; this.m_ctxToolsCopySelectedTriggers.Click += new System.EventHandler(this.OnCtxToolsCopySelectedTriggers); // // m_ctxToolsPasteTriggers // this.m_ctxToolsPasteTriggers.Image = global::KeePass.Properties.Resources.B16x16_EditPaste; this.m_ctxToolsPasteTriggers.Name = "m_ctxToolsPasteTriggers"; this.m_ctxToolsPasteTriggers.Size = new System.Drawing.Size(243, 22); this.m_ctxToolsPasteTriggers.Text = "&Paste Triggers from Clipboard"; this.m_ctxToolsPasteTriggers.Click += new System.EventHandler(this.OnCtxToolsPasteTriggers); // // EcasTriggersForm // 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(626, 424); this.Controls.Add(this.m_btnTools); this.Controls.Add(this.m_btnMoveDown); this.Controls.Add(this.m_btnMoveUp); this.Controls.Add(this.m_cbEnableTriggers); this.Controls.Add(this.m_lblSep); this.Controls.Add(this.m_btnDelete); this.Controls.Add(this.m_btnEdit); this.Controls.Add(this.m_btnAdd); this.Controls.Add(this.m_lvTriggers); this.Controls.Add(this.m_btnCancel); this.Controls.Add(this.m_btnOK); this.Controls.Add(this.m_bannerImage); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "EcasTriggersForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "<>"; this.Load += new System.EventHandler(this.OnFormLoad); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).EndInit(); this.m_ctxTools.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.PictureBox m_bannerImage; private System.Windows.Forms.Button m_btnOK; private System.Windows.Forms.Button m_btnCancel; private KeePass.UI.CustomListViewEx m_lvTriggers; private System.Windows.Forms.Button m_btnAdd; private System.Windows.Forms.Button m_btnEdit; private System.Windows.Forms.Button m_btnDelete; private System.Windows.Forms.Label m_lblSep; private System.Windows.Forms.CheckBox m_cbEnableTriggers; private System.Windows.Forms.Button m_btnMoveUp; private System.Windows.Forms.Button m_btnMoveDown; private System.Windows.Forms.Button m_btnTools; private System.Windows.Forms.ContextMenuStrip m_ctxTools; private System.Windows.Forms.ToolStripMenuItem m_ctxToolsHelp; private System.Windows.Forms.ToolStripSeparator m_ctxToolsSep0; private System.Windows.Forms.ToolStripMenuItem m_ctxToolsCopyTriggers; private System.Windows.Forms.ToolStripMenuItem m_ctxToolsCopySelectedTriggers; private System.Windows.Forms.ToolStripMenuItem m_ctxToolsPasteTriggers; } }keepass2-2.25/KeePass/Forms/ProxyForm.cs0000664000175000017500000000706512261553106020041 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePass.App.Configuration; using KeePass.UI; using KeePassLib; using KeePassLib.Serialization; namespace KeePass.Forms { public partial class ProxyForm : Form { public ProxyForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } private void OnFormLoad(object sender, EventArgs e) { GlobalWindowManager.AddWindow(this); this.Icon = Properties.Resources.KeePass; ProxyServerType pst = Program.Config.Integration.ProxyType; if(pst == ProxyServerType.None) m_rbNoProxy.Checked = true; else if(pst == ProxyServerType.Manual) m_rbManualProxy.Checked = true; else m_rbSystemProxy.Checked = true; m_tbAddress.Text = Program.Config.Integration.ProxyAddress; m_tbPort.Text = Program.Config.Integration.ProxyPort; m_tbUser.Text = Program.Config.Integration.ProxyUserName; m_tbPassword.Text = Program.Config.Integration.ProxyPassword; } private void OnFormClosed(object sender, FormClosedEventArgs e) { GlobalWindowManager.RemoveWindow(this); } private void OnBtnOK(object sender, EventArgs e) { ProxyServerType pst = ProxyServerType.System; if(m_rbNoProxy.Checked) pst = ProxyServerType.None; else if(m_rbManualProxy.Checked) pst = ProxyServerType.Manual; AceIntegration ace = Program.Config.Integration; ace.ProxyType = pst; ace.ProxyAddress = m_tbAddress.Text; ace.ProxyPort = m_tbPort.Text; ace.ProxyUserName = m_tbUser.Text; ace.ProxyPassword = m_tbPassword.Text; Program.Config.Apply(AceApplyFlags.Proxy); } private void EnableControlsEx() { if(m_rbNoProxy.Checked) { m_tbUser.Enabled = m_tbPassword.Enabled = m_lblUser.Enabled = m_lblPassword.Enabled = false; m_grpAuth.Enabled = false; } else { m_grpAuth.Enabled = true; m_tbUser.Enabled = m_tbPassword.Enabled = m_lblUser.Enabled = m_lblPassword.Enabled = true; } m_lblAddress.Enabled = m_tbAddress.Enabled = m_lblPort.Enabled = m_tbPort.Enabled = m_rbManualProxy.Checked; if(!m_rbManualProxy.Checked) m_btnOK.Enabled = true; else m_btnOK.Enabled = (m_tbAddress.Text.Length > 0); } private void OnNoProxyCheckedChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnSystemProxyCheckedChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnManualProxyCheckedChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnAddressTextChanged(object sender, EventArgs e) { EnableControlsEx(); } } } keepass2-2.25/KeePass/Forms/CsvImportForm.cs0000664000175000017500000006520412265551756020662 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Globalization; using System.Diagnostics; using KeePass.App; using KeePass.DataExchange; using KeePass.Resources; using KeePass.UI; using KeePass.Util; using KeePassLib; using KeePassLib.Utility; namespace KeePass.Forms { public partial class CsvImportForm : Form { private byte[] m_pbData = null; private PwDatabase m_pwDatabase = null; private bool m_bInitializing = false; private uint m_uStartOffset = 0; private CsvFieldType m_tLastCsvType = CsvFieldType.Count; private readonly string StrCharTab = @"{Tab}"; private readonly string StrCharNewLine = @"{" + KPRes.NewLine + @"}"; private enum CsvFieldType { Ignore = 0, Group, Title, UserName, Password, Url, Notes, CustomString, CreationTime, // LastAccessTime, LastModTime, ExpiryTime, Tags, Count, // Last enum item + 1 First = 0 } private sealed class CsvFieldInfo { private readonly CsvFieldType m_t; public CsvFieldType Type { get { return m_t; } } private readonly string m_strName; public string Name { get { return m_strName; } } private readonly string m_strFormat; public string Format { get { return m_strFormat; } } public CsvFieldInfo(CsvFieldType t, string strName, string strFormat) { m_t = t; m_strName = strName; // May be null m_strFormat = strFormat; // May be null } } public void InitEx(PwDatabase pwStorage, byte[] pbInData) { m_pwDatabase = pwStorage; m_pbData = pbInData; } public CsvImportForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } private void OnFormLoad(object sender, EventArgs e) { if((m_pbData == null) || (m_pwDatabase == null)) throw new InvalidOperationException(); m_bInitializing = true; GlobalWindowManager.AddWindow(this); this.Icon = Properties.Resources.KeePass; this.Text = KPRes.GenericCsvImporter + " - " + PwDefs.ShortProductName; // FontUtil.AssignDefaultBold(m_grpSyntax); // FontUtil.AssignDefaultBold(m_grpSem); UIUtil.SetExplorerTheme(m_lvFields, false); UIUtil.SetExplorerTheme(m_lvImportPreview, false); foreach(StrEncodingInfo seiEnum in StrUtil.Encodings) { m_cmbEnc.Items.Add(seiEnum.Name); } StrEncodingInfo seiGuess = BinaryDataClassifier.GetStringEncoding( m_pbData, out m_uStartOffset); int iSel = 0; if(seiGuess != null) iSel = Math.Max(m_cmbEnc.FindStringExact(seiGuess.Name), 0); m_cmbEnc.SelectedIndex = iSel; string[] vChars = new string[] { ",", ";", ".", ":", "\"", @"'", StrCharTab, StrCharNewLine }; foreach(string strChar in vChars) { m_cmbFieldSep.Items.Add(strChar); m_cmbRecSep.Items.Add(strChar); m_cmbTextQual.Items.Add(strChar); } m_cmbFieldSep.SelectedIndex = 0; m_cmbRecSep.SelectedIndex = 7; m_cmbTextQual.SelectedIndex = 4; m_lvFields.Columns.Add(KPRes.Field); AddCsvField(CsvFieldType.Title, null, null); AddCsvField(CsvFieldType.UserName, null, null); AddCsvField(CsvFieldType.Password, null, null); AddCsvField(CsvFieldType.Url, null, null); AddCsvField(CsvFieldType.Notes, null, null); for(int i = (int)CsvFieldType.First; i < (int)CsvFieldType.Count; ++i) m_cmbFieldType.Items.Add(CsvFieldToString((CsvFieldType)i)); m_cmbFieldType.SelectedIndex = (int)CsvFieldType.Group; m_cmbFieldFormat.Text = string.Empty; m_bInitializing = false; UpdateTextPreview(); UpdateImportPreview(); GuessCsvStructure(); ProcessResize(); EnableControlsEx(); UIUtil.SetFocus(m_btnTabNext, this); } private void OnFormClosed(object sender, FormClosedEventArgs e) { GlobalWindowManager.RemoveWindow(this); } private void EnableControlsEx() { if(m_bInitializing) return; List lFields = GetCsvFieldInfos(); bool bSelField = (m_lvFields.SelectedIndices.Count >= 1); bool bSel1Field = (m_lvFields.SelectedIndices.Count == 1); m_btnFieldDel.Enabled = bSelField; m_btnFieldMoveUp.Enabled = bSel1Field; m_btnFieldMoveDown.Enabled = bSel1Field; bool bFieldName, bFieldFormat; CsvFieldType t = GetCsvFieldType(out bFieldName, out bFieldFormat); m_lblFieldName.Enabled = bFieldName; m_tbFieldName.Enabled = bFieldName; m_lblFieldFormat.Enabled = bFieldFormat; m_cmbFieldFormat.Enabled = bFieldFormat; m_linkFieldFormat.Enabled = IsTimeField(t); int iTab = m_tabMain.SelectedIndex, nTabs = m_tabMain.TabCount; m_btnTabBack.Enabled = (iTab > 0); m_btnTabNext.Enabled = (iTab < (nTabs - 1)); bool bValidFieldSep = (GetCharFromDef(m_cmbFieldSep.Text) != char.MinValue); bool bValidRecSep = (GetCharFromDef(m_cmbRecSep.Text) != char.MinValue); bool bValidTextQual = (GetCharFromDef(m_cmbTextQual.Text) != char.MinValue); if(bValidFieldSep) m_cmbFieldSep.ResetBackColor(); else m_cmbFieldSep.BackColor = AppDefs.ColorEditError; if(bValidRecSep) m_cmbRecSep.ResetBackColor(); else m_cmbRecSep.BackColor = AppDefs.ColorEditError; if(bValidTextQual) m_cmbTextQual.ResetBackColor(); else m_cmbTextQual.BackColor = AppDefs.ColorEditError; bool bOK = true; bOK &= (iTab == (nTabs - 1)); bOK &= (bValidFieldSep && bValidRecSep && bValidTextQual); m_btnOK.Enabled = bOK; if(t != m_tLastCsvType) { m_cmbFieldFormat.Items.Clear(); string[] vItems; if(IsTimeField(t)) vItems = new string[] { string.Empty, @"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffzz", @"ddd, dd MMM yyyy HH':'mm':'ss 'GMT'", @"yyyy'-'MM'-'dd'T'HH':'mm':'ss", @"yyyy'-'MM'-'dd HH':'mm':'ss'Z'", @"yyyy/MM/dd HH:mm:ss", @"yyyy/MM/dd", @"MM/dd/yy", @"MMMM dd, yyyy", @"MM/dd/yy H:mm:ss zzz" }; else if(t == CsvFieldType.Group) vItems = new string[] { string.Empty, ".", "/", "\\" }; else vItems = new string[0]; foreach(string strPre in vItems) m_cmbFieldFormat.Items.Add(strPre); if(t == CsvFieldType.Group) m_lblFieldFormat.Text = KPRes.Separator + ":"; else m_lblFieldFormat.Text = KPRes.Format + ":"; } m_tLastCsvType = t; bool bHasGroup = false; foreach(CsvFieldInfo cfi in lFields) { if(cfi.Type == CsvFieldType.Group) { bHasGroup = true; break; } } if(!bHasGroup) m_cbMergeGroups.Checked = false; m_cbMergeGroups.Enabled = bHasGroup; } private string GetDecodedText() { StrEncodingInfo sei = StrUtil.GetEncoding(m_cmbEnc.Text); try { return (sei.Encoding.GetString(m_pbData, (int)m_uStartOffset, m_pbData.Length - (int)m_uStartOffset) ?? string.Empty); } catch(Exception) { } return string.Empty; } private void UpdateTextPreview() { if(m_bInitializing) return; m_rtbEncPreview.Clear(); // Clear formatting m_rtbEncPreview.Text = GetDecodedText(); } private void UpdateImportPreview() { if(m_bInitializing) return; PerformImport(new PwGroup(true, true), true); } private void ProcessResize() { if(m_bInitializing) return; int dx = m_lvFields.ClientRectangle.Width; m_lvFields.Columns[0].Width = dx - UIUtil.GetVScrollBarWidth(); // Add some space for usability dx = m_lvImportPreview.ClientRectangle.Width; int nCols = m_lvImportPreview.Columns.Count; for(int c = 0; c < nCols; ++c) m_lvImportPreview.Columns[c].Width = dx / nCols; } private static string CsvFieldToString(CsvFieldType t) { string strText; if(t == CsvFieldType.Ignore) strText = "(" + KPRes.Ignore + ")"; else if(t == CsvFieldType.Group) strText = KPRes.Group; else if(t == CsvFieldType.Title) strText = KPRes.Title; else if(t == CsvFieldType.UserName) strText = KPRes.UserName; else if(t == CsvFieldType.Password) strText = KPRes.Password; else if(t == CsvFieldType.Url) strText = KPRes.Url; else if(t == CsvFieldType.Notes) strText = KPRes.Notes; else if(t == CsvFieldType.CustomString) strText = KPRes.String; else if(t == CsvFieldType.CreationTime) strText = KPRes.CreationTime; // else if(t == CsvFieldType.LastAccessTime) // strText = KPRes.LastAccessTime; else if(t == CsvFieldType.LastModTime) strText = KPRes.LastModificationTime; else if(t == CsvFieldType.ExpiryTime) strText = KPRes.ExpiryTime; else if(t == CsvFieldType.Tags) strText = KPRes.Tags; else { Debug.Assert(false); strText = KPRes.Unknown; } return strText; } private void AddCsvField(CsvFieldType t, string strName, string strFormat) { string strText = CsvFieldToString(t); string strSub = string.Empty; if(strName != null) strSub += strName; if(!string.IsNullOrEmpty(strFormat)) { if(strSub.Length > 0) strSub += ", "; strSub += strFormat; } if(strSub.Length > 0) strText += " (" + strSub + ")"; ListViewItem lvi = m_lvFields.Items.Add(strText); lvi.Tag = new CsvFieldInfo(t, strName, strFormat); } private CsvFieldType GetCsvFieldType() { bool bName, bFormat; return GetCsvFieldType(out bName, out bFormat); } private CsvFieldType GetCsvFieldType(out bool bName, out bool bFormat) { int i = m_cmbFieldType.SelectedIndex; if((i < (int)CsvFieldType.First) || (i >= (int)CsvFieldType.Count)) { Debug.Assert(false); bName = false; bFormat = false; return CsvFieldType.Ignore; } CsvFieldType t = (CsvFieldType)i; bName = (t == CsvFieldType.CustomString); bFormat = (IsTimeField(t) || (t == CsvFieldType.Group)); return t; } private char GetCharFromDef(string strDef) { if(strDef.Equals(StrCharTab, StrUtil.CaseIgnoreCmp)) return '\t'; if(strDef.Equals(StrCharNewLine, StrUtil.CaseIgnoreCmp)) return '\n'; if(strDef.Length == 1) return strDef[0]; return char.MinValue; } private void OnEncSelectedIndexChanged(object sender, EventArgs e) { UpdateTextPreview(); } private void OnFieldSepTextUpdate(object sender, EventArgs e) { EnableControlsEx(); } private void OnRecSepTextUpdate(object sender, EventArgs e) { EnableControlsEx(); } private void OnTextQualTextUpdate(object sender, EventArgs e) { EnableControlsEx(); } private void OnBtnFieldDel(object sender, EventArgs e) { ListView.SelectedIndexCollection lvsic = m_lvFields.SelectedIndices; for(int i = lvsic.Count - 1; i >= 0; --i) m_lvFields.Items.RemoveAt(lvsic[i]); EnableControlsEx(); } private void OnFieldsSelectedIndexChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnBtnFieldMoveUp(object sender, EventArgs e) { ListView.SelectedIndexCollection lvsic = m_lvFields.SelectedIndices; if(lvsic.Count != 1) { Debug.Assert(false); return; } int iPos = lvsic[0]; if(iPos == 0) return; ListViewItem lviMove = m_lvFields.Items[iPos]; m_lvFields.Items.RemoveAt(iPos); m_lvFields.Items.Insert(iPos - 1, lviMove); } private void OnBtnFieldMoveDown(object sender, EventArgs e) { ListView.SelectedIndexCollection lvsic = m_lvFields.SelectedIndices; if(lvsic.Count != 1) { Debug.Assert(false); return; } int iPos = lvsic[0]; if(iPos == (m_lvFields.Items.Count - 1)) return; ListViewItem lviMove = m_lvFields.Items[iPos]; m_lvFields.Items.RemoveAt(iPos); m_lvFields.Items.Insert(iPos + 1, lviMove); } private void OnFieldTypeSelectedIndexChanged(object sender, EventArgs e) { CsvFieldType t = GetCsvFieldType(); if(t != m_tLastCsvType) m_cmbFieldFormat.Text = string.Empty; EnableControlsEx(); } private void OnFieldFormatLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { CsvFieldType t = GetCsvFieldType(); string strUrl = null; if(IsTimeField(t)) strUrl = @"http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx"; // else if(t == CsvFieldType.Group) // { // AppHelp.ShowHelp(AppDefs.HelpTopics.ImportExport, // AppDefs.HelpTopics.ImportExportGenericCsv); // return; // } else { Debug.Assert(false); return; } try { Process.Start(strUrl); } catch(Exception ex) { MessageService.ShowWarning(strUrl, ex.Message); } } private void OnBtnFieldAdd(object sender, EventArgs e) { bool bName, bFormat; CsvFieldType t = GetCsvFieldType(out bName, out bFormat); string strName = (bName ? m_tbFieldName.Text : null); string strFormat = (bFormat ? m_cmbFieldFormat.Text : null); AddCsvField(t, strName, strFormat); ProcessResize(); for(int i = 0; i < (m_lvFields.Items.Count - 1); ++i) m_lvFields.Items[i].Selected = false; m_lvFields.EnsureVisible(m_lvFields.Items.Count - 1); UIUtil.SetFocusedItem(m_lvFields, m_lvFields.Items[ m_lvFields.Items.Count - 1], true); } private void OnTabMainSelectedIndexChanged(object sender, EventArgs e) { if(m_tabMain.SelectedTab == m_tabPreview) UpdateImportPreview(); EnableControlsEx(); } private CsvOptions GetCsvOptions() { CsvOptions opt = new CsvOptions(); opt.FieldSeparator = GetCharFromDef(m_cmbFieldSep.Text); opt.RecordSeparator = GetCharFromDef(m_cmbRecSep.Text); opt.TextQualifier = GetCharFromDef(m_cmbTextQual.Text); if((opt.FieldSeparator == char.MinValue) || (opt.RecordSeparator == char.MinValue) || (opt.TextQualifier == char.MinValue)) return null; opt.BackslashIsEscape = m_cbBackEscape.Checked; opt.TrimFields = m_cbTrim.Checked; return opt; } private List GetCsvFieldInfos() { List lFields = new List(); for(int i = 0; i < m_lvFields.Items.Count; ++i) { CsvFieldInfo cfi = (m_lvFields.Items[i].Tag as CsvFieldInfo); if(cfi == null) { Debug.Assert(false); continue; } lFields.Add(cfi); } return lFields; } private void PerformImport(PwGroup pgStorage, bool bCreatePreview) { List lFields = GetCsvFieldInfos(); if(bCreatePreview) { int dx = m_lvImportPreview.ClientRectangle.Width; // Before clearing m_lvImportPreview.Items.Clear(); m_lvImportPreview.Columns.Clear(); foreach(CsvFieldInfo cfi in lFields) { string strCol = CsvFieldToString(cfi.Type); if(cfi.Type == CsvFieldType.CustomString) strCol = (cfi.Name ?? string.Empty); m_lvImportPreview.Columns.Add(strCol, dx / lFields.Count); } } CsvOptions opt = GetCsvOptions(); if(opt == null) { Debug.Assert(bCreatePreview); return; } string strData = GetDecodedText(); CsvStreamReaderEx csr = new CsvStreamReaderEx(strData, opt); Dictionary dGroups = new Dictionary(); dGroups[string.Empty] = pgStorage; if(bCreatePreview) m_lvImportPreview.BeginUpdate(); DateTime dtNow = DateTime.Now; DateTime dtNoExpire = KdbTime.NeverExpireTime.ToDateTime(); bool bIgnoreFirstRow = m_cbIgnoreFirst.Checked; bool bIsFirstRow = true; bool bMergeGroups = m_cbMergeGroups.Checked; while(true) { string[] v = csr.ReadLine(); if(v == null) break; if(v.Length == 0) continue; if((v.Length == 1) && (v[0].Length == 0)) continue; if(bIsFirstRow && bIgnoreFirstRow) { bIsFirstRow = false; continue; } bIsFirstRow = false; PwGroup pg = pgStorage; PwEntry pe = new PwEntry(true, true); ListViewItem lvi = null; for(int i = 0; i < Math.Min(v.Length, lFields.Count); ++i) { string strField = v[i]; CsvFieldInfo cfi = lFields[i]; if(cfi.Type == CsvFieldType.Ignore) { } else if(cfi.Type == CsvFieldType.Group) pg = FindCreateGroup(strField, pgStorage, dGroups, cfi.Format, opt, bMergeGroups); else if(cfi.Type == CsvFieldType.Title) ImportUtil.AppendToField(pe, PwDefs.TitleField, strField, m_pwDatabase); else if(cfi.Type == CsvFieldType.UserName) ImportUtil.AppendToField(pe, PwDefs.UserNameField, strField, m_pwDatabase); else if(cfi.Type == CsvFieldType.Password) ImportUtil.AppendToField(pe, PwDefs.PasswordField, strField, m_pwDatabase); else if(cfi.Type == CsvFieldType.Url) ImportUtil.AppendToField(pe, PwDefs.UrlField, strField, m_pwDatabase); else if(cfi.Type == CsvFieldType.Notes) ImportUtil.AppendToField(pe, PwDefs.NotesField, strField, m_pwDatabase); else if(cfi.Type == CsvFieldType.CustomString) ImportUtil.AppendToField(pe, (string.IsNullOrEmpty(cfi.Name) ? PwDefs.NotesField : cfi.Name), strField, m_pwDatabase); else if(cfi.Type == CsvFieldType.CreationTime) pe.CreationTime = ParseDateTime(ref strField, cfi, dtNow); // else if(cfi.Type == CsvFieldType.LastAccessTime) // pe.LastAccessTime = ParseDateTime(ref strField, cfi, dtNow); else if(cfi.Type == CsvFieldType.LastModTime) pe.LastModificationTime = ParseDateTime(ref strField, cfi, dtNow); else if(cfi.Type == CsvFieldType.ExpiryTime) { bool bParseSuccess; pe.ExpiryTime = ParseDateTime(ref strField, cfi, dtNow, out bParseSuccess); pe.Expires = (bParseSuccess && (pe.ExpiryTime != dtNoExpire)); } else if(cfi.Type == CsvFieldType.Tags) { List lTags = StrUtil.StringToTags(strField); foreach(string strTag in lTags) pe.AddTag(strTag); } else { Debug.Assert(false); } if(bCreatePreview) { strField = StrUtil.MultiToSingleLine(strField); if(lvi != null) lvi.SubItems.Add(strField); else lvi = m_lvImportPreview.Items.Add(strField); } } if(bCreatePreview) { // Create remaining subitems for(int r = v.Length; r < lFields.Count; ++r) { if(lvi != null) lvi.SubItems.Add(string.Empty); else lvi = m_lvImportPreview.Items.Add(string.Empty); } } pg.AddEntry(pe, true); } if(bCreatePreview) { m_lvImportPreview.EndUpdate(); ProcessResize(); } } private static DateTime ParseDateTime(ref string strData, CsvFieldInfo cfi, DateTime dtDefault) { bool bDummy; return ParseDateTime(ref strData, cfi, dtDefault, out bDummy); } private static DateTime ParseDateTime(ref string strData, CsvFieldInfo cfi, DateTime dtDefault, out bool bSuccess) { DateTime? odt = null; if(!string.IsNullOrEmpty(cfi.Format)) { const DateTimeStyles dts = (DateTimeStyles.AllowWhiteSpaces | DateTimeStyles.AssumeLocal); DateTime dtExact; if(DateTime.TryParseExact(strData, cfi.Format, null, dts, out dtExact)) odt = dtExact; } if(!odt.HasValue) { DateTime dtStd; if(DateTime.TryParse(strData, out dtStd)) odt = dtStd; } if(odt.HasValue) { strData = TimeUtil.ToDisplayString(odt.Value); bSuccess = true; } else { strData = string.Empty; bSuccess = false; odt = dtDefault; } return odt.Value; } private static List SplitGroupPath(string strSpec, string strSep, CsvOptions opt) { List l = new List(); if(string.IsNullOrEmpty(strSep)) l.Add(strSpec); else { string[] vChain = strSpec.Split(new string[1] { strSep }, StringSplitOptions.RemoveEmptyEntries); for(int i = 0; i < vChain.Length; ++i) { string strGrp = vChain[i]; if(opt.TrimFields) strGrp = strGrp.Trim(); if(strGrp.Length > 0) l.Add(strGrp); } if(l.Count == 0) l.Add(strSpec); } return l; } private static string AssembleGroupPath(List l, int iOffset, char chSep) { StringBuilder sb = new StringBuilder(); for(int i = iOffset; i < l.Count; ++i) { if(i > iOffset) sb.Append(chSep); sb.Append(l[i]); } return sb.ToString(); } private static PwGroup FindCreateGroup(string strSpec, PwGroup pgStorage, Dictionary dRootGroups, string strSep, CsvOptions opt, bool bMergeGroups) { List l = SplitGroupPath(strSpec, strSep, opt); if(bMergeGroups) { char chSep = StrUtil.GetUnusedChar(strSpec); string strPath = AssembleGroupPath(l, 0, chSep); return pgStorage.FindCreateSubTree(strPath, new char[1] { chSep }); } string strRootSub = l[0]; if(!dRootGroups.ContainsKey(strRootSub)) { PwGroup pgNew = new PwGroup(true, true); pgNew.Name = strRootSub; pgStorage.AddGroup(pgNew, true); dRootGroups[strRootSub] = pgNew; } PwGroup pg = dRootGroups[strRootSub]; if(l.Count > 1) { char chSep = StrUtil.GetUnusedChar(strSpec); string strSubPath = AssembleGroupPath(l, 1, chSep); pg = pg.FindCreateSubTree(strSubPath, new char[1] { chSep }); } return pg; } private void OnBtnTabBack(object sender, EventArgs e) { int i = m_tabMain.SelectedIndex; if(i > 0) m_tabMain.SelectedIndex = i - 1; } private void OnBtnTabNext(object sender, EventArgs e) { int i = m_tabMain.SelectedIndex; if(i < (m_tabMain.TabCount - 1)) m_tabMain.SelectedIndex = i + 1; } private void OnBtnOK(object sender, EventArgs e) { PerformImport(m_pwDatabase.RootGroup, false); } private void OnFieldSepSelectedIndexChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnRecSepSelectedIndexChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnTextQualSelectedIndexChanged(object sender, EventArgs e) { EnableControlsEx(); } private void GuessCsvStructure() { bool bFieldsGuessed = GuessFieldTypes(); m_cbIgnoreFirst.Checked = bFieldsGuessed; } private bool GuessFieldTypes() { CsvOptions opt = GetCsvOptions(); if(opt == null) { Debug.Assert(false); return false; } string strData = GetDecodedText(); CsvStreamReaderEx csv = new CsvStreamReaderEx(strData, opt); string[] v; while(true) { v = csv.ReadLine(); if(v == null) return false; if(v.Length == 0) continue; if((v.Length == 1) && (v[0].Length == 0)) continue; break; } if(v.Length <= 3) return false; CsvFieldInfo[] vFields = new CsvFieldInfo[v.Length]; int nDetermined = 0; for(int i = 0; i < v.Length; ++i) { CsvFieldInfo fi = GuessFieldType(v[i]); if(fi != null) ++nDetermined; else fi = new CsvFieldInfo(CsvFieldType.Ignore, null, null); vFields[i] = fi; } // Accept the guesses only if at least half of them are // probably correct if(nDetermined < (v.Length + 1) / 2) return false; m_lvFields.Items.Clear(); foreach(CsvFieldInfo fi in vFields) AddCsvField(fi.Type, fi.Name, fi.Format); return true; } private static CsvFieldInfo GuessFieldType(string strRawName) { if(strRawName == null) return null; string strName = strRawName.Trim(); if(strName.Length == 0) return null; string str = ImportUtil.MapNameToStandardField(strName, false); if(str == PwDefs.TitleField) return new CsvFieldInfo(CsvFieldType.Title, null, null); if(str == PwDefs.UserNameField) return new CsvFieldInfo(CsvFieldType.UserName, null, null); if(str == PwDefs.PasswordField) return new CsvFieldInfo(CsvFieldType.Password, null, null); if(str == PwDefs.UrlField) return new CsvFieldInfo(CsvFieldType.Url, null, null); if(str == PwDefs.NotesField) return new CsvFieldInfo(CsvFieldType.Notes, null, null); string[] vGroupNames = new string[] { "Password Groups", "Group", "Groups", "Group Tree", KPRes.Group }; foreach(string strGroupName in vGroupNames) { if(strName.Equals(strGroupName, StrUtil.CaseIgnoreCmp)) return new CsvFieldInfo(CsvFieldType.Group, null, null); } string[] vCreationNames = new string[] { "Creation", "Creation Time", KPRes.CreationTime }; foreach(string strCreation in vCreationNames) { if(strName.Equals(strCreation, StrUtil.CaseIgnoreCmp)) return new CsvFieldInfo(CsvFieldType.CreationTime, null, null); } // string[] vLastAccess = new string[] { // "Last Access", "Last Access Time", // KPRes.LastAccessTime // }; // foreach(string strLastAccess in vLastAccess) // { // if(strName.Equals(strLastAccess, StrUtil.CaseIgnoreCmp)) // return new CsvFieldInfo(CsvFieldType.LastAccessTime, null, null); // } string[] vLastMod = new string[] { "Last Modification", "Last Mod", "Last Modification Time", "Last Mod Time", KPRes.LastModificationTime }; foreach(string strLastMod in vLastMod) { if(strName.Equals(strLastMod, StrUtil.CaseIgnoreCmp)) return new CsvFieldInfo(CsvFieldType.LastModTime, null, null); } string[] vExpiry = new string[] { "Expires", "Expire", "Expiry", "Expiry Time", KPRes.ExpiryTime, KPRes.ExpiryTimeDateOnly }; foreach(string strExpire in vExpiry) { if(strName.Equals(strExpire, StrUtil.CaseIgnoreCmp)) return new CsvFieldInfo(CsvFieldType.ExpiryTime, null, null); } string[] vTags = new string[] { "Tags", "Tag", KPRes.Tags, KPRes.Tag }; foreach(string strTag in vTags) { if(strName.Equals(strTag, StrUtil.CaseIgnoreCmp)) return new CsvFieldInfo(CsvFieldType.Tags, null, null); } return null; } private static bool IsTimeField(CsvFieldType t) { return ((t == CsvFieldType.CreationTime) || // (t == CsvFieldType.LastAccessTime) || (t == CsvFieldType.LastModTime) || (t == CsvFieldType.ExpiryTime)); } private void OnBtnHelp(object sender, EventArgs e) { AppHelp.ShowHelp(AppDefs.HelpTopics.ImportExport, AppDefs.HelpTopics.ImportExportGenericCsv); } } } keepass2-2.25/KeePass/Forms/EditAutoTypeItemForm.resx0000664000175000017500000001326611744606124022477 0ustar jtaylorjtaylor 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 keepass2-2.25/KeePass/Forms/ImportMethodForm.Designer.cs0000664000175000017500000002603712163553174023100 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class ImportMethodForm { /// /// 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() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImportMethodForm)); this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_lblIntro = new System.Windows.Forms.Label(); this.m_bannerImage = new System.Windows.Forms.PictureBox(); this.m_radioCreateNew = new System.Windows.Forms.RadioButton(); this.m_lblCreateNewHint = new System.Windows.Forms.Label(); this.m_radioKeepExisting = new System.Windows.Forms.RadioButton(); this.m_lblExistingHint = new System.Windows.Forms.Label(); this.m_radioOverwrite = new System.Windows.Forms.RadioButton(); this.m_lblOverwriteHint = new System.Windows.Forms.Label(); this.m_radioOverwriteIfNewer = new System.Windows.Forms.RadioButton(); this.m_lblOverwriteIfNewerHint = new System.Windows.Forms.Label(); this.m_radioSynchronize = new System.Windows.Forms.RadioButton(); this.m_lblSynchronizeHint = new System.Windows.Forms.Label(); this.m_lblSeparator = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).BeginInit(); this.SuspendLayout(); // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(345, 431); this.m_btnOK.Name = "m_btnOK"; this.m_btnOK.Size = new System.Drawing.Size(75, 23); this.m_btnOK.TabIndex = 11; this.m_btnOK.Text = "&OK"; 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(426, 431); this.m_btnCancel.Name = "m_btnCancel"; this.m_btnCancel.Size = new System.Drawing.Size(75, 23); this.m_btnCancel.TabIndex = 12; this.m_btnCancel.Text = "&Cancel"; this.m_btnCancel.UseVisualStyleBackColor = true; this.m_btnCancel.Click += new System.EventHandler(this.OnBtnCancel); // // m_lblIntro // this.m_lblIntro.Location = new System.Drawing.Point(12, 72); this.m_lblIntro.Name = "m_lblIntro"; this.m_lblIntro.Size = new System.Drawing.Size(489, 28); this.m_lblIntro.TabIndex = 1; this.m_lblIntro.Text = "The file format that you have selected to import supports group and/or entry IDs." + " Please choose an import behavior."; // // m_bannerImage // this.m_bannerImage.Dock = System.Windows.Forms.DockStyle.Top; this.m_bannerImage.Location = new System.Drawing.Point(0, 0); this.m_bannerImage.Name = "m_bannerImage"; this.m_bannerImage.Size = new System.Drawing.Size(513, 60); this.m_bannerImage.TabIndex = 3; this.m_bannerImage.TabStop = false; // // m_radioCreateNew // this.m_radioCreateNew.AutoSize = true; this.m_radioCreateNew.Location = new System.Drawing.Point(15, 114); this.m_radioCreateNew.Name = "m_radioCreateNew"; this.m_radioCreateNew.Size = new System.Drawing.Size(60, 17); this.m_radioCreateNew.TabIndex = 0; this.m_radioCreateNew.TabStop = true; this.m_radioCreateNew.Text = ""; this.m_radioCreateNew.UseVisualStyleBackColor = true; // // m_lblCreateNewHint // this.m_lblCreateNewHint.Location = new System.Drawing.Point(32, 134); this.m_lblCreateNewHint.Name = "m_lblCreateNewHint"; this.m_lblCreateNewHint.Size = new System.Drawing.Size(469, 28); this.m_lblCreateNewHint.TabIndex = 2; this.m_lblCreateNewHint.Text = "If you select this option, KeePass will create new IDs for all groups and entries" + ". Consequently no existing groups and entries of the currently opened database w" + "ill be modified or overwritten."; // // m_radioKeepExisting // this.m_radioKeepExisting.AutoSize = true; this.m_radioKeepExisting.Location = new System.Drawing.Point(15, 174); this.m_radioKeepExisting.Name = "m_radioKeepExisting"; this.m_radioKeepExisting.Size = new System.Drawing.Size(60, 17); this.m_radioKeepExisting.TabIndex = 3; this.m_radioKeepExisting.TabStop = true; this.m_radioKeepExisting.Text = ""; this.m_radioKeepExisting.UseVisualStyleBackColor = true; // // m_lblExistingHint // this.m_lblExistingHint.Location = new System.Drawing.Point(32, 194); this.m_lblExistingHint.Name = "m_lblExistingHint"; this.m_lblExistingHint.Size = new System.Drawing.Size(469, 27); this.m_lblExistingHint.TabIndex = 4; this.m_lblExistingHint.Text = "Existing entries of the currently opened database will not be modified. Only new " + "entries will be added."; // // m_radioOverwrite // this.m_radioOverwrite.AutoSize = true; this.m_radioOverwrite.Location = new System.Drawing.Point(15, 233); this.m_radioOverwrite.Name = "m_radioOverwrite"; this.m_radioOverwrite.Size = new System.Drawing.Size(60, 17); this.m_radioOverwrite.TabIndex = 5; this.m_radioOverwrite.TabStop = true; this.m_radioOverwrite.Text = ""; this.m_radioOverwrite.UseVisualStyleBackColor = true; // // m_lblOverwriteHint // this.m_lblOverwriteHint.Location = new System.Drawing.Point(32, 253); this.m_lblOverwriteHint.Name = "m_lblOverwriteHint"; this.m_lblOverwriteHint.Size = new System.Drawing.Size(469, 28); this.m_lblOverwriteHint.TabIndex = 6; this.m_lblOverwriteHint.Text = "KeePass will replace all existing groups and entries by the ones in the file to i" + "mport, if they have the same ID."; // // m_radioOverwriteIfNewer // this.m_radioOverwriteIfNewer.AutoSize = true; this.m_radioOverwriteIfNewer.Location = new System.Drawing.Point(15, 293); this.m_radioOverwriteIfNewer.Name = "m_radioOverwriteIfNewer"; this.m_radioOverwriteIfNewer.Size = new System.Drawing.Size(60, 17); this.m_radioOverwriteIfNewer.TabIndex = 7; this.m_radioOverwriteIfNewer.TabStop = true; this.m_radioOverwriteIfNewer.Text = ""; this.m_radioOverwriteIfNewer.UseVisualStyleBackColor = true; // // m_lblOverwriteIfNewerHint // this.m_lblOverwriteIfNewerHint.Location = new System.Drawing.Point(32, 313); this.m_lblOverwriteIfNewerHint.Name = "m_lblOverwriteIfNewerHint"; this.m_lblOverwriteIfNewerHint.Size = new System.Drawing.Size(469, 27); this.m_lblOverwriteIfNewerHint.TabIndex = 8; this.m_lblOverwriteIfNewerHint.Text = "KeePass will compare the last-modified times of the groups/entries and replace th" + "e existing ones only if the ones to import are newer."; // // m_radioSynchronize // this.m_radioSynchronize.AutoSize = true; this.m_radioSynchronize.Location = new System.Drawing.Point(15, 352); this.m_radioSynchronize.Name = "m_radioSynchronize"; this.m_radioSynchronize.Size = new System.Drawing.Size(60, 17); this.m_radioSynchronize.TabIndex = 9; this.m_radioSynchronize.TabStop = true; this.m_radioSynchronize.Text = ""; this.m_radioSynchronize.UseVisualStyleBackColor = true; // // m_lblSynchronizeHint // this.m_lblSynchronizeHint.Location = new System.Drawing.Point(32, 372); this.m_lblSynchronizeHint.Name = "m_lblSynchronizeHint"; this.m_lblSynchronizeHint.Size = new System.Drawing.Size(469, 40); this.m_lblSynchronizeHint.TabIndex = 10; this.m_lblSynchronizeHint.Text = resources.GetString("m_lblSynchronizeHint.Text"); // // m_lblSeparator // this.m_lblSeparator.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.m_lblSeparator.Location = new System.Drawing.Point(0, 425); this.m_lblSeparator.Name = "m_lblSeparator"; this.m_lblSeparator.Size = new System.Drawing.Size(513, 2); this.m_lblSeparator.TabIndex = 13; // // ImportMethodForm // 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(513, 466); this.Controls.Add(this.m_lblSeparator); this.Controls.Add(this.m_lblSynchronizeHint); this.Controls.Add(this.m_radioSynchronize); this.Controls.Add(this.m_lblOverwriteIfNewerHint); this.Controls.Add(this.m_radioOverwriteIfNewer); this.Controls.Add(this.m_lblOverwriteHint); this.Controls.Add(this.m_radioOverwrite); this.Controls.Add(this.m_lblExistingHint); this.Controls.Add(this.m_radioKeepExisting); this.Controls.Add(this.m_lblCreateNewHint); this.Controls.Add(this.m_radioCreateNew); this.Controls.Add(this.m_bannerImage); this.Controls.Add(this.m_lblIntro); 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 = "ImportMethodForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = ""; this.Load += new System.EventHandler(this.OnFormLoad); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).EndInit(); 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_lblIntro; private System.Windows.Forms.PictureBox m_bannerImage; private System.Windows.Forms.RadioButton m_radioCreateNew; private System.Windows.Forms.Label m_lblCreateNewHint; private System.Windows.Forms.RadioButton m_radioKeepExisting; private System.Windows.Forms.Label m_lblExistingHint; private System.Windows.Forms.RadioButton m_radioOverwrite; private System.Windows.Forms.Label m_lblOverwriteHint; private System.Windows.Forms.RadioButton m_radioOverwriteIfNewer; private System.Windows.Forms.Label m_lblOverwriteIfNewerHint; private System.Windows.Forms.RadioButton m_radioSynchronize; private System.Windows.Forms.Label m_lblSynchronizeHint; private System.Windows.Forms.Label m_lblSeparator; } }keepass2-2.25/KeePass/Forms/PwGeneratorForm.Designer.cs0000664000175000017500000006412412135465750022722 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class PwGeneratorForm { /// /// 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.components = new System.ComponentModel.Container(); this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_rbStandardCharSet = new System.Windows.Forms.RadioButton(); this.m_lblNumGenChars = new System.Windows.Forms.Label(); this.m_numGenChars = new System.Windows.Forms.NumericUpDown(); this.m_bannerImage = new System.Windows.Forms.PictureBox(); this.m_lblProfile = new System.Windows.Forms.Label(); this.m_cmbProfiles = new System.Windows.Forms.ComboBox(); this.m_btnProfileAdd = new System.Windows.Forms.Button(); this.m_btnProfileRemove = new System.Windows.Forms.Button(); this.m_ttMain = new System.Windows.Forms.ToolTip(this.components); this.m_grpCurOpt = new System.Windows.Forms.GroupBox(); this.m_btnCustomOpt = new System.Windows.Forms.Button(); this.m_cmbCustomAlgo = new System.Windows.Forms.ComboBox(); this.m_rbCustom = new System.Windows.Forms.RadioButton(); this.m_cbPatternPermute = new System.Windows.Forms.CheckBox(); this.m_lblCustomChars = new System.Windows.Forms.Label(); this.m_tbCustomChars = new System.Windows.Forms.TextBox(); this.m_cbHighAnsi = new System.Windows.Forms.CheckBox(); this.m_cbBrackets = new System.Windows.Forms.CheckBox(); this.m_cbSpecial = new System.Windows.Forms.CheckBox(); this.m_cbSpace = new System.Windows.Forms.CheckBox(); this.m_cbUnderline = new System.Windows.Forms.CheckBox(); this.m_cbMinus = new System.Windows.Forms.CheckBox(); this.m_cbDigits = new System.Windows.Forms.CheckBox(); this.m_cbLowerCase = new System.Windows.Forms.CheckBox(); this.m_cbUpperCase = new System.Windows.Forms.CheckBox(); this.m_cbEntropy = new System.Windows.Forms.CheckBox(); this.m_tbPattern = new System.Windows.Forms.TextBox(); this.m_rbPattern = new System.Windows.Forms.RadioButton(); this.m_cbExcludeLookAlike = new System.Windows.Forms.CheckBox(); this.m_btnHelp = new System.Windows.Forms.Button(); this.m_tabMain = new System.Windows.Forms.TabControl(); this.m_tabSettings = new System.Windows.Forms.TabPage(); this.m_tabAdvanced = new System.Windows.Forms.TabPage(); this.m_tbExcludeChars = new System.Windows.Forms.TextBox(); this.m_lblExcludeChars = new System.Windows.Forms.Label(); this.m_cbNoRepeat = new System.Windows.Forms.CheckBox(); this.m_lblSecRedInfo = new System.Windows.Forms.Label(); this.m_tabPreview = new System.Windows.Forms.TabPage(); this.m_pbPreview = new System.Windows.Forms.ProgressBar(); this.m_tbPreview = new System.Windows.Forms.TextBox(); this.m_lblPreview = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.m_numGenChars)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).BeginInit(); this.m_grpCurOpt.SuspendLayout(); this.m_tabMain.SuspendLayout(); this.m_tabSettings.SuspendLayout(); this.m_tabAdvanced.SuspendLayout(); this.m_tabPreview.SuspendLayout(); this.SuspendLayout(); // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(321, 515); 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 = "&OK"; 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(402, 515); 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_rbStandardCharSet // this.m_rbStandardCharSet.AutoSize = true; this.m_rbStandardCharSet.Checked = true; this.m_rbStandardCharSet.Location = new System.Drawing.Point(9, 20); this.m_rbStandardCharSet.Name = "m_rbStandardCharSet"; this.m_rbStandardCharSet.Size = new System.Drawing.Size(165, 17); this.m_rbStandardCharSet.TabIndex = 0; this.m_rbStandardCharSet.TabStop = true; this.m_rbStandardCharSet.Text = "Generate using character set:"; this.m_rbStandardCharSet.UseVisualStyleBackColor = true; // // m_lblNumGenChars // this.m_lblNumGenChars.AutoSize = true; this.m_lblNumGenChars.Location = new System.Drawing.Point(26, 45); this.m_lblNumGenChars.Name = "m_lblNumGenChars"; this.m_lblNumGenChars.Size = new System.Drawing.Size(154, 13); this.m_lblNumGenChars.TabIndex = 1; this.m_lblNumGenChars.Text = "Length of generated password:"; // // m_numGenChars // this.m_numGenChars.Location = new System.Drawing.Point(228, 43); this.m_numGenChars.Maximum = new decimal(new int[] { 30000, 0, 0, 0}); this.m_numGenChars.Name = "m_numGenChars"; this.m_numGenChars.Size = new System.Drawing.Size(69, 20); this.m_numGenChars.TabIndex = 2; this.m_numGenChars.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // m_bannerImage // this.m_bannerImage.Dock = System.Windows.Forms.DockStyle.Top; this.m_bannerImage.Location = new System.Drawing.Point(0, 0); this.m_bannerImage.Name = "m_bannerImage"; this.m_bannerImage.Size = new System.Drawing.Size(489, 60); this.m_bannerImage.TabIndex = 10; this.m_bannerImage.TabStop = false; // // m_lblProfile // this.m_lblProfile.AutoSize = true; this.m_lblProfile.Location = new System.Drawing.Point(6, 9); this.m_lblProfile.Name = "m_lblProfile"; this.m_lblProfile.Size = new System.Drawing.Size(39, 13); this.m_lblProfile.TabIndex = 0; this.m_lblProfile.Text = "Profile:"; // // m_cmbProfiles // this.m_cmbProfiles.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.m_cmbProfiles.FormattingEnabled = true; this.m_cmbProfiles.Location = new System.Drawing.Point(51, 6); this.m_cmbProfiles.MaxDropDownItems = 16; this.m_cmbProfiles.Name = "m_cmbProfiles"; this.m_cmbProfiles.Size = new System.Drawing.Size(341, 21); this.m_cmbProfiles.TabIndex = 1; this.m_cmbProfiles.SelectedIndexChanged += new System.EventHandler(this.OnProfilesSelectedIndexChanged); // // m_btnProfileAdd // this.m_btnProfileAdd.Location = new System.Drawing.Point(398, 5); this.m_btnProfileAdd.Name = "m_btnProfileAdd"; this.m_btnProfileAdd.Size = new System.Drawing.Size(25, 23); this.m_btnProfileAdd.TabIndex = 2; this.m_btnProfileAdd.UseVisualStyleBackColor = true; this.m_btnProfileAdd.Click += new System.EventHandler(this.OnBtnProfileSave); // // m_btnProfileRemove // this.m_btnProfileRemove.Location = new System.Drawing.Point(426, 5); this.m_btnProfileRemove.Name = "m_btnProfileRemove"; this.m_btnProfileRemove.Size = new System.Drawing.Size(25, 23); this.m_btnProfileRemove.TabIndex = 3; this.m_btnProfileRemove.UseVisualStyleBackColor = true; this.m_btnProfileRemove.Click += new System.EventHandler(this.OnBtnProfileRemove); // // m_grpCurOpt // this.m_grpCurOpt.Controls.Add(this.m_btnCustomOpt); this.m_grpCurOpt.Controls.Add(this.m_cmbCustomAlgo); this.m_grpCurOpt.Controls.Add(this.m_rbCustom); this.m_grpCurOpt.Controls.Add(this.m_cbPatternPermute); this.m_grpCurOpt.Controls.Add(this.m_lblCustomChars); this.m_grpCurOpt.Controls.Add(this.m_tbCustomChars); this.m_grpCurOpt.Controls.Add(this.m_cbHighAnsi); this.m_grpCurOpt.Controls.Add(this.m_cbBrackets); this.m_grpCurOpt.Controls.Add(this.m_cbSpecial); this.m_grpCurOpt.Controls.Add(this.m_cbSpace); this.m_grpCurOpt.Controls.Add(this.m_cbUnderline); this.m_grpCurOpt.Controls.Add(this.m_cbMinus); this.m_grpCurOpt.Controls.Add(this.m_cbDigits); this.m_grpCurOpt.Controls.Add(this.m_cbLowerCase); this.m_grpCurOpt.Controls.Add(this.m_cbUpperCase); this.m_grpCurOpt.Controls.Add(this.m_cbEntropy); this.m_grpCurOpt.Controls.Add(this.m_tbPattern); this.m_grpCurOpt.Controls.Add(this.m_rbPattern); this.m_grpCurOpt.Controls.Add(this.m_lblNumGenChars); this.m_grpCurOpt.Controls.Add(this.m_rbStandardCharSet); this.m_grpCurOpt.Controls.Add(this.m_numGenChars); this.m_grpCurOpt.Location = new System.Drawing.Point(6, 31); this.m_grpCurOpt.Name = "m_grpCurOpt"; this.m_grpCurOpt.Size = new System.Drawing.Size(445, 377); this.m_grpCurOpt.TabIndex = 4; this.m_grpCurOpt.TabStop = false; this.m_grpCurOpt.Text = "Current settings"; // // m_btnCustomOpt // this.m_btnCustomOpt.Image = global::KeePass.Properties.Resources.B16x16_Misc; this.m_btnCustomOpt.Location = new System.Drawing.Point(414, 321); this.m_btnCustomOpt.Name = "m_btnCustomOpt"; this.m_btnCustomOpt.Size = new System.Drawing.Size(25, 23); this.m_btnCustomOpt.TabIndex = 19; this.m_btnCustomOpt.UseVisualStyleBackColor = true; this.m_btnCustomOpt.Click += new System.EventHandler(this.OnBtnCustomOpt); // // m_cmbCustomAlgo // this.m_cmbCustomAlgo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.m_cmbCustomAlgo.FormattingEnabled = true; this.m_cmbCustomAlgo.Location = new System.Drawing.Point(29, 322); this.m_cmbCustomAlgo.Name = "m_cmbCustomAlgo"; this.m_cmbCustomAlgo.Size = new System.Drawing.Size(379, 21); this.m_cmbCustomAlgo.TabIndex = 18; // // m_rbCustom // this.m_rbCustom.AutoSize = true; this.m_rbCustom.Location = new System.Drawing.Point(9, 299); this.m_rbCustom.Name = "m_rbCustom"; this.m_rbCustom.Size = new System.Drawing.Size(182, 17); this.m_rbCustom.TabIndex = 17; this.m_rbCustom.TabStop = true; this.m_rbCustom.Text = "Generate using custom algorithm:"; this.m_rbCustom.UseVisualStyleBackColor = true; // // m_cbPatternPermute // this.m_cbPatternPermute.AutoSize = true; this.m_cbPatternPermute.Location = new System.Drawing.Point(29, 276); this.m_cbPatternPermute.Name = "m_cbPatternPermute"; this.m_cbPatternPermute.Size = new System.Drawing.Size(227, 17); this.m_cbPatternPermute.TabIndex = 16; this.m_cbPatternPermute.Text = "Randomly permute characters of password"; this.m_cbPatternPermute.UseVisualStyleBackColor = true; // // m_lblCustomChars // this.m_lblCustomChars.AutoSize = true; this.m_lblCustomChars.Location = new System.Drawing.Point(26, 183); this.m_lblCustomChars.Name = "m_lblCustomChars"; this.m_lblCustomChars.Size = new System.Drawing.Size(182, 13); this.m_lblCustomChars.TabIndex = 12; this.m_lblCustomChars.Text = "Also include the following characters:"; // // m_tbCustomChars // this.m_tbCustomChars.Location = new System.Drawing.Point(29, 199); this.m_tbCustomChars.Name = "m_tbCustomChars"; this.m_tbCustomChars.Size = new System.Drawing.Size(410, 20); this.m_tbCustomChars.TabIndex = 13; // // m_cbHighAnsi // this.m_cbHighAnsi.AutoSize = true; this.m_cbHighAnsi.Location = new System.Drawing.Point(228, 137); this.m_cbHighAnsi.Name = "m_cbHighAnsi"; this.m_cbHighAnsi.Size = new System.Drawing.Size(129, 17); this.m_cbHighAnsi.TabIndex = 10; this.m_cbHighAnsi.Text = "High ANSI characters"; this.m_cbHighAnsi.UseVisualStyleBackColor = true; // // m_cbBrackets // this.m_cbBrackets.AutoSize = true; this.m_cbBrackets.Location = new System.Drawing.Point(228, 115); this.m_cbBrackets.Name = "m_cbBrackets"; this.m_cbBrackets.Size = new System.Drawing.Size(68, 17); this.m_cbBrackets.TabIndex = 8; this.m_cbBrackets.Text = "Brackets"; this.m_cbBrackets.UseVisualStyleBackColor = true; // // m_cbSpecial // this.m_cbSpecial.AutoSize = true; this.m_cbSpecial.Location = new System.Drawing.Point(228, 93); this.m_cbSpecial.Name = "m_cbSpecial"; this.m_cbSpecial.Size = new System.Drawing.Size(61, 17); this.m_cbSpecial.TabIndex = 6; this.m_cbSpecial.Text = "Special"; this.m_cbSpecial.UseVisualStyleBackColor = true; // // m_cbSpace // this.m_cbSpace.AutoSize = true; this.m_cbSpace.Location = new System.Drawing.Point(228, 71); this.m_cbSpace.Name = "m_cbSpace"; this.m_cbSpace.Size = new System.Drawing.Size(57, 17); this.m_cbSpace.TabIndex = 4; this.m_cbSpace.Text = "Space"; this.m_cbSpace.UseVisualStyleBackColor = true; // // m_cbUnderline // this.m_cbUnderline.AutoSize = true; this.m_cbUnderline.Location = new System.Drawing.Point(29, 159); this.m_cbUnderline.Name = "m_cbUnderline"; this.m_cbUnderline.Size = new System.Drawing.Size(71, 17); this.m_cbUnderline.TabIndex = 11; this.m_cbUnderline.Text = "Underline"; this.m_cbUnderline.UseVisualStyleBackColor = true; // // m_cbMinus // this.m_cbMinus.AutoSize = true; this.m_cbMinus.Location = new System.Drawing.Point(29, 137); this.m_cbMinus.Name = "m_cbMinus"; this.m_cbMinus.Size = new System.Drawing.Size(54, 17); this.m_cbMinus.TabIndex = 9; this.m_cbMinus.Text = "Minus"; this.m_cbMinus.UseVisualStyleBackColor = true; // // m_cbDigits // this.m_cbDigits.AutoSize = true; this.m_cbDigits.Location = new System.Drawing.Point(29, 115); this.m_cbDigits.Name = "m_cbDigits"; this.m_cbDigits.Size = new System.Drawing.Size(52, 17); this.m_cbDigits.TabIndex = 7; this.m_cbDigits.Text = "Digits"; this.m_cbDigits.UseVisualStyleBackColor = true; // // m_cbLowerCase // this.m_cbLowerCase.AutoSize = true; this.m_cbLowerCase.Location = new System.Drawing.Point(29, 93); this.m_cbLowerCase.Name = "m_cbLowerCase"; this.m_cbLowerCase.Size = new System.Drawing.Size(81, 17); this.m_cbLowerCase.TabIndex = 5; this.m_cbLowerCase.Text = "Lower-case"; this.m_cbLowerCase.UseVisualStyleBackColor = true; // // m_cbUpperCase // this.m_cbUpperCase.AutoSize = true; this.m_cbUpperCase.Location = new System.Drawing.Point(29, 71); this.m_cbUpperCase.Name = "m_cbUpperCase"; this.m_cbUpperCase.Size = new System.Drawing.Size(81, 17); this.m_cbUpperCase.TabIndex = 3; this.m_cbUpperCase.Text = "Upper-case"; this.m_cbUpperCase.UseVisualStyleBackColor = true; // // m_cbEntropy // this.m_cbEntropy.AutoSize = true; this.m_cbEntropy.Location = new System.Drawing.Point(9, 352); this.m_cbEntropy.Name = "m_cbEntropy"; this.m_cbEntropy.Size = new System.Drawing.Size(144, 17); this.m_cbEntropy.TabIndex = 20; this.m_cbEntropy.Text = "Collect additional entropy"; this.m_cbEntropy.UseVisualStyleBackColor = true; // // m_tbPattern // this.m_tbPattern.Location = new System.Drawing.Point(29, 250); this.m_tbPattern.Name = "m_tbPattern"; this.m_tbPattern.Size = new System.Drawing.Size(410, 20); this.m_tbPattern.TabIndex = 15; // // m_rbPattern // this.m_rbPattern.AutoSize = true; this.m_rbPattern.Location = new System.Drawing.Point(9, 227); this.m_rbPattern.Name = "m_rbPattern"; this.m_rbPattern.Size = new System.Drawing.Size(136, 17); this.m_rbPattern.TabIndex = 14; this.m_rbPattern.TabStop = true; this.m_rbPattern.Text = "Generate using pattern:"; this.m_rbPattern.UseVisualStyleBackColor = true; // // m_cbExcludeLookAlike // this.m_cbExcludeLookAlike.AutoSize = true; this.m_cbExcludeLookAlike.Location = new System.Drawing.Point(12, 39); this.m_cbExcludeLookAlike.Name = "m_cbExcludeLookAlike"; this.m_cbExcludeLookAlike.Size = new System.Drawing.Size(165, 17); this.m_cbExcludeLookAlike.TabIndex = 1; this.m_cbExcludeLookAlike.Text = "Exclude look-alike characters"; this.m_cbExcludeLookAlike.UseVisualStyleBackColor = true; // // m_btnHelp // this.m_btnHelp.Location = new System.Drawing.Point(12, 515); this.m_btnHelp.Name = "m_btnHelp"; this.m_btnHelp.Size = new System.Drawing.Size(75, 23); this.m_btnHelp.TabIndex = 3; this.m_btnHelp.Text = "&Help"; this.m_btnHelp.UseVisualStyleBackColor = true; this.m_btnHelp.Click += new System.EventHandler(this.OnBtnHelp); // // m_tabMain // this.m_tabMain.Controls.Add(this.m_tabSettings); this.m_tabMain.Controls.Add(this.m_tabAdvanced); this.m_tabMain.Controls.Add(this.m_tabPreview); this.m_tabMain.Location = new System.Drawing.Point(12, 66); this.m_tabMain.Name = "m_tabMain"; this.m_tabMain.SelectedIndex = 0; this.m_tabMain.Size = new System.Drawing.Size(465, 439); this.m_tabMain.TabIndex = 2; this.m_tabMain.SelectedIndexChanged += new System.EventHandler(this.OnTabMainSelectedIndexChanged); // // m_tabSettings // this.m_tabSettings.Controls.Add(this.m_lblProfile); this.m_tabSettings.Controls.Add(this.m_cmbProfiles); this.m_tabSettings.Controls.Add(this.m_grpCurOpt); this.m_tabSettings.Controls.Add(this.m_btnProfileAdd); this.m_tabSettings.Controls.Add(this.m_btnProfileRemove); this.m_tabSettings.Location = new System.Drawing.Point(4, 22); this.m_tabSettings.Name = "m_tabSettings"; this.m_tabSettings.Padding = new System.Windows.Forms.Padding(3); this.m_tabSettings.Size = new System.Drawing.Size(457, 413); this.m_tabSettings.TabIndex = 0; this.m_tabSettings.Text = "Settings"; this.m_tabSettings.UseVisualStyleBackColor = true; // // m_tabAdvanced // this.m_tabAdvanced.Controls.Add(this.m_tbExcludeChars); this.m_tabAdvanced.Controls.Add(this.m_lblExcludeChars); this.m_tabAdvanced.Controls.Add(this.m_cbExcludeLookAlike); this.m_tabAdvanced.Controls.Add(this.m_cbNoRepeat); this.m_tabAdvanced.Controls.Add(this.m_lblSecRedInfo); this.m_tabAdvanced.Location = new System.Drawing.Point(4, 22); this.m_tabAdvanced.Name = "m_tabAdvanced"; this.m_tabAdvanced.Size = new System.Drawing.Size(457, 413); this.m_tabAdvanced.TabIndex = 2; this.m_tabAdvanced.Text = "Advanced"; this.m_tabAdvanced.UseVisualStyleBackColor = true; // // m_tbExcludeChars // this.m_tbExcludeChars.Location = new System.Drawing.Point(12, 84); this.m_tbExcludeChars.Name = "m_tbExcludeChars"; this.m_tbExcludeChars.Size = new System.Drawing.Size(432, 20); this.m_tbExcludeChars.TabIndex = 3; // // m_lblExcludeChars // this.m_lblExcludeChars.AutoSize = true; this.m_lblExcludeChars.Location = new System.Drawing.Point(9, 68); this.m_lblExcludeChars.Name = "m_lblExcludeChars"; this.m_lblExcludeChars.Size = new System.Drawing.Size(163, 13); this.m_lblExcludeChars.TabIndex = 2; this.m_lblExcludeChars.Text = "Exclude the following characters:"; // // m_cbNoRepeat // this.m_cbNoRepeat.AutoSize = true; this.m_cbNoRepeat.Location = new System.Drawing.Point(12, 16); this.m_cbNoRepeat.Name = "m_cbNoRepeat"; this.m_cbNoRepeat.Size = new System.Drawing.Size(218, 17); this.m_cbNoRepeat.TabIndex = 0; this.m_cbNoRepeat.Text = "Each character must occur at most once"; this.m_cbNoRepeat.UseVisualStyleBackColor = true; // // m_lblSecRedInfo // this.m_lblSecRedInfo.Location = new System.Drawing.Point(9, 362); this.m_lblSecRedInfo.Name = "m_lblSecRedInfo"; this.m_lblSecRedInfo.Size = new System.Drawing.Size(445, 41); this.m_lblSecRedInfo.TabIndex = 4; this.m_lblSecRedInfo.Text = "Options/rules marked with an asterisk reduce the security of generated passwords." + " Only enable them if you are forced to follow such rules by the website, applica" + "tion or password policy."; // // m_tabPreview // this.m_tabPreview.Controls.Add(this.m_pbPreview); this.m_tabPreview.Controls.Add(this.m_tbPreview); this.m_tabPreview.Controls.Add(this.m_lblPreview); this.m_tabPreview.Location = new System.Drawing.Point(4, 22); this.m_tabPreview.Name = "m_tabPreview"; this.m_tabPreview.Padding = new System.Windows.Forms.Padding(3); this.m_tabPreview.Size = new System.Drawing.Size(457, 413); this.m_tabPreview.TabIndex = 1; this.m_tabPreview.Text = "Preview"; this.m_tabPreview.UseVisualStyleBackColor = true; // // m_pbPreview // this.m_pbPreview.Location = new System.Drawing.Point(9, 30); this.m_pbPreview.Name = "m_pbPreview"; this.m_pbPreview.Size = new System.Drawing.Size(437, 15); this.m_pbPreview.TabIndex = 1; // // m_tbPreview // this.m_tbPreview.AcceptsReturn = true; this.m_tbPreview.Location = new System.Drawing.Point(9, 51); this.m_tbPreview.Multiline = true; this.m_tbPreview.Name = "m_tbPreview"; this.m_tbPreview.ReadOnly = true; this.m_tbPreview.ScrollBars = System.Windows.Forms.ScrollBars.Both; this.m_tbPreview.Size = new System.Drawing.Size(437, 350); this.m_tbPreview.TabIndex = 2; this.m_tbPreview.WordWrap = false; // // m_lblPreview // this.m_lblPreview.Location = new System.Drawing.Point(6, 12); this.m_lblPreview.Name = "m_lblPreview"; this.m_lblPreview.Size = new System.Drawing.Size(445, 15); this.m_lblPreview.TabIndex = 0; this.m_lblPreview.Text = "Here you see a few sample passwords matching the rules specified on the first tab" + " pages."; // // PwGeneratorForm // 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(489, 550); this.Controls.Add(this.m_tabMain); this.Controls.Add(this.m_btnHelp); this.Controls.Add(this.m_bannerImage); 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 = "PwGeneratorForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Password Generator"; this.Load += new System.EventHandler(this.OnFormLoad); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing); ((System.ComponentModel.ISupportInitialize)(this.m_numGenChars)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).EndInit(); this.m_grpCurOpt.ResumeLayout(false); this.m_grpCurOpt.PerformLayout(); this.m_tabMain.ResumeLayout(false); this.m_tabSettings.ResumeLayout(false); this.m_tabSettings.PerformLayout(); this.m_tabAdvanced.ResumeLayout(false); this.m_tabAdvanced.PerformLayout(); this.m_tabPreview.ResumeLayout(false); this.m_tabPreview.PerformLayout(); this.ResumeLayout(false); } #endregion private System.Windows.Forms.Button m_btnOK; private System.Windows.Forms.Button m_btnCancel; private System.Windows.Forms.RadioButton m_rbStandardCharSet; private System.Windows.Forms.Label m_lblNumGenChars; private System.Windows.Forms.NumericUpDown m_numGenChars; private System.Windows.Forms.PictureBox m_bannerImage; private System.Windows.Forms.Label m_lblProfile; private System.Windows.Forms.ComboBox m_cmbProfiles; private System.Windows.Forms.Button m_btnProfileAdd; private System.Windows.Forms.ToolTip m_ttMain; private System.Windows.Forms.Button m_btnProfileRemove; private System.Windows.Forms.GroupBox m_grpCurOpt; private System.Windows.Forms.TextBox m_tbPattern; private System.Windows.Forms.RadioButton m_rbPattern; private System.Windows.Forms.CheckBox m_cbEntropy; private System.Windows.Forms.Button m_btnHelp; private System.Windows.Forms.TabControl m_tabMain; private System.Windows.Forms.TabPage m_tabSettings; private System.Windows.Forms.TabPage m_tabPreview; private System.Windows.Forms.Label m_lblPreview; private System.Windows.Forms.TextBox m_tbPreview; private System.Windows.Forms.ProgressBar m_pbPreview; private System.Windows.Forms.CheckBox m_cbHighAnsi; private System.Windows.Forms.CheckBox m_cbBrackets; private System.Windows.Forms.CheckBox m_cbSpecial; private System.Windows.Forms.CheckBox m_cbSpace; private System.Windows.Forms.CheckBox m_cbUnderline; private System.Windows.Forms.CheckBox m_cbMinus; private System.Windows.Forms.CheckBox m_cbDigits; private System.Windows.Forms.CheckBox m_cbLowerCase; private System.Windows.Forms.CheckBox m_cbUpperCase; private System.Windows.Forms.CheckBox m_cbExcludeLookAlike; private System.Windows.Forms.Label m_lblCustomChars; private System.Windows.Forms.TextBox m_tbCustomChars; private System.Windows.Forms.CheckBox m_cbPatternPermute; private System.Windows.Forms.TabPage m_tabAdvanced; private System.Windows.Forms.CheckBox m_cbNoRepeat; private System.Windows.Forms.Label m_lblSecRedInfo; private System.Windows.Forms.TextBox m_tbExcludeChars; private System.Windows.Forms.Label m_lblExcludeChars; private System.Windows.Forms.ComboBox m_cmbCustomAlgo; private System.Windows.Forms.RadioButton m_rbCustom; private System.Windows.Forms.Button m_btnCustomOpt; } }keepass2-2.25/KeePass/Forms/AboutForm.Designer.cs0000664000175000017500000002027011503154044021516 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class AboutForm { /// /// 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_bannerImage = new System.Windows.Forms.PictureBox(); this.m_lblCopyright = new System.Windows.Forms.Label(); this.m_lblOsi = new System.Windows.Forms.Label(); this.m_lblGpl = new System.Windows.Forms.Label(); this.m_linkHomepage = new System.Windows.Forms.LinkLabel(); this.m_linkHelp = new System.Windows.Forms.LinkLabel(); this.m_linkLicense = new System.Windows.Forms.LinkLabel(); this.m_linkAcknowledgements = new System.Windows.Forms.LinkLabel(); this.m_linkDonate = new System.Windows.Forms.LinkLabel(); this.m_btnOK = new System.Windows.Forms.Button(); this.m_lvComponents = new KeePass.UI.CustomListViewEx(); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).BeginInit(); this.SuspendLayout(); // // m_bannerImage // this.m_bannerImage.Dock = System.Windows.Forms.DockStyle.Top; this.m_bannerImage.Location = new System.Drawing.Point(0, 0); this.m_bannerImage.Name = "m_bannerImage"; this.m_bannerImage.Size = new System.Drawing.Size(424, 60); this.m_bannerImage.TabIndex = 0; this.m_bannerImage.TabStop = false; // // m_lblCopyright // this.m_lblCopyright.Location = new System.Drawing.Point(10, 72); this.m_lblCopyright.Name = "m_lblCopyright"; this.m_lblCopyright.Size = new System.Drawing.Size(402, 15); this.m_lblCopyright.TabIndex = 1; // // m_lblOsi // this.m_lblOsi.Location = new System.Drawing.Point(10, 96); this.m_lblOsi.Name = "m_lblOsi"; this.m_lblOsi.Size = new System.Drawing.Size(402, 14); this.m_lblOsi.TabIndex = 2; this.m_lblOsi.Text = "KeePass is OSI Certified Open Source Software."; // // m_lblGpl // this.m_lblGpl.Location = new System.Drawing.Point(10, 119); this.m_lblGpl.Name = "m_lblGpl"; this.m_lblGpl.Size = new System.Drawing.Size(402, 27); this.m_lblGpl.TabIndex = 3; this.m_lblGpl.Text = "The program is distributed under the terms of the GNU General Public License v2 o" + "r later."; // // m_linkHomepage // this.m_linkHomepage.AutoSize = true; this.m_linkHomepage.Location = new System.Drawing.Point(10, 155); this.m_linkHomepage.Name = "m_linkHomepage"; this.m_linkHomepage.Size = new System.Drawing.Size(91, 13); this.m_linkHomepage.TabIndex = 4; this.m_linkHomepage.TabStop = true; this.m_linkHomepage.Text = "KeePass Website"; this.m_linkHomepage.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.OnLinkHomepage); // // m_linkHelp // this.m_linkHelp.AutoSize = true; this.m_linkHelp.Location = new System.Drawing.Point(213, 155); this.m_linkHelp.Name = "m_linkHelp"; this.m_linkHelp.Size = new System.Drawing.Size(29, 13); this.m_linkHelp.TabIndex = 6; this.m_linkHelp.TabStop = true; this.m_linkHelp.Text = "Help"; this.m_linkHelp.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.OnLinkHelpFile); // // m_linkLicense // this.m_linkLicense.AutoSize = true; this.m_linkLicense.Location = new System.Drawing.Point(10, 177); this.m_linkLicense.Name = "m_linkLicense"; this.m_linkLicense.Size = new System.Drawing.Size(44, 13); this.m_linkLicense.TabIndex = 7; this.m_linkLicense.TabStop = true; this.m_linkLicense.Text = "License"; this.m_linkLicense.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.OnLinkLicenseFile); // // m_linkAcknowledgements // this.m_linkAcknowledgements.AutoSize = true; this.m_linkAcknowledgements.Location = new System.Drawing.Point(107, 155); this.m_linkAcknowledgements.Name = "m_linkAcknowledgements"; this.m_linkAcknowledgements.Size = new System.Drawing.Size(100, 13); this.m_linkAcknowledgements.TabIndex = 5; this.m_linkAcknowledgements.TabStop = true; this.m_linkAcknowledgements.Text = "Acknowledgements"; this.m_linkAcknowledgements.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.OnLinkAcknowledgements); // // m_linkDonate // this.m_linkDonate.AutoSize = true; this.m_linkDonate.Location = new System.Drawing.Point(107, 177); this.m_linkDonate.Name = "m_linkDonate"; this.m_linkDonate.Size = new System.Drawing.Size(42, 13); this.m_linkDonate.TabIndex = 8; this.m_linkDonate.TabStop = true; this.m_linkDonate.Text = "Donate"; this.m_linkDonate.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.OnLinkDonate); // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(337, 315); 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 = "&OK"; this.m_btnOK.UseVisualStyleBackColor = true; // // m_lvComponents // this.m_lvComponents.FullRowSelect = true; this.m_lvComponents.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; this.m_lvComponents.Location = new System.Drawing.Point(13, 203); this.m_lvComponents.Name = "m_lvComponents"; this.m_lvComponents.Size = new System.Drawing.Size(398, 101); this.m_lvComponents.TabIndex = 9; this.m_lvComponents.UseCompatibleStateImageBehavior = false; this.m_lvComponents.View = System.Windows.Forms.View.Details; // // AboutForm // this.AcceptButton = this.m_btnOK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.m_btnOK; this.ClientSize = new System.Drawing.Size(424, 350); this.Controls.Add(this.m_lvComponents); this.Controls.Add(this.m_btnOK); this.Controls.Add(this.m_linkDonate); this.Controls.Add(this.m_linkAcknowledgements); this.Controls.Add(this.m_linkLicense); this.Controls.Add(this.m_linkHelp); this.Controls.Add(this.m_linkHomepage); this.Controls.Add(this.m_lblGpl); this.Controls.Add(this.m_lblOsi); this.Controls.Add(this.m_lblCopyright); this.Controls.Add(this.m_bannerImage); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "AboutForm"; this.ShowInTaskbar = false; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "About KeePass"; this.Load += new System.EventHandler(this.OnFormLoad); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.PictureBox m_bannerImage; private System.Windows.Forms.Label m_lblCopyright; private System.Windows.Forms.Label m_lblOsi; private System.Windows.Forms.Label m_lblGpl; private System.Windows.Forms.LinkLabel m_linkHomepage; private System.Windows.Forms.LinkLabel m_linkHelp; private System.Windows.Forms.LinkLabel m_linkLicense; private System.Windows.Forms.LinkLabel m_linkAcknowledgements; private System.Windows.Forms.LinkLabel m_linkDonate; private System.Windows.Forms.Button m_btnOK; private KeePass.UI.CustomListViewEx m_lvComponents; } }keepass2-2.25/KeePass/Forms/XmlReplaceForm.resx0000664000175000017500000001326612250421470021324 0ustar jtaylorjtaylor 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 keepass2-2.25/KeePass/Forms/TextEncodingForm.Designer.cs0000664000175000017500000001277611717723006023062 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class TextEncodingForm { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if(disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_lblSelEnc = new System.Windows.Forms.Label(); this.m_cmbEnc = new System.Windows.Forms.ComboBox(); this.m_lblPreview = new System.Windows.Forms.Label(); this.m_rtbPreview = new KeePass.UI.CustomRichTextBoxEx(); this.m_lblContext = new System.Windows.Forms.Label(); this.SuspendLayout(); // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(459, 12); 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 = "&OK"; 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(459, 41); 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_lblSelEnc // this.m_lblSelEnc.AutoSize = true; this.m_lblSelEnc.Location = new System.Drawing.Point(9, 37); this.m_lblSelEnc.Name = "m_lblSelEnc"; this.m_lblSelEnc.Size = new System.Drawing.Size(155, 13); this.m_lblSelEnc.TabIndex = 3; this.m_lblSelEnc.Text = "Select the encoding of the text:"; // // m_cmbEnc // this.m_cmbEnc.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.m_cmbEnc.FormattingEnabled = true; this.m_cmbEnc.Location = new System.Drawing.Point(12, 53); this.m_cmbEnc.MaxDropDownItems = 12; this.m_cmbEnc.Name = "m_cmbEnc"; this.m_cmbEnc.Size = new System.Drawing.Size(385, 21); this.m_cmbEnc.TabIndex = 4; this.m_cmbEnc.SelectedIndexChanged += new System.EventHandler(this.OnEncSelectedIndexChanged); // // m_lblPreview // this.m_lblPreview.AutoSize = true; this.m_lblPreview.Location = new System.Drawing.Point(9, 86); this.m_lblPreview.Name = "m_lblPreview"; this.m_lblPreview.Size = new System.Drawing.Size(71, 13); this.m_lblPreview.TabIndex = 5; this.m_lblPreview.Text = "Text preview:"; // // m_rtbPreview // this.m_rtbPreview.AcceptsTab = true; this.m_rtbPreview.DetectUrls = false; this.m_rtbPreview.Location = new System.Drawing.Point(12, 102); this.m_rtbPreview.Name = "m_rtbPreview"; this.m_rtbPreview.ReadOnly = true; this.m_rtbPreview.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedBoth; this.m_rtbPreview.Size = new System.Drawing.Size(522, 314); this.m_rtbPreview.TabIndex = 6; this.m_rtbPreview.Text = ""; this.m_rtbPreview.WordWrap = false; // // m_lblContext // this.m_lblContext.Location = new System.Drawing.Point(9, 13); this.m_lblContext.Name = "m_lblContext"; this.m_lblContext.Size = new System.Drawing.Size(444, 17); this.m_lblContext.TabIndex = 2; this.m_lblContext.Text = "<>"; // // TextEncodingForm // 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(546, 428); this.Controls.Add(this.m_lblContext); this.Controls.Add(this.m_rtbPreview); this.Controls.Add(this.m_lblPreview); this.Controls.Add(this.m_cmbEnc); this.Controls.Add(this.m_lblSelEnc); 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 = "TextEncodingForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Text Encoding"; 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_lblSelEnc; private System.Windows.Forms.ComboBox m_cmbEnc; private System.Windows.Forms.Label m_lblPreview; private KeePass.UI.CustomRichTextBoxEx m_rtbPreview; private System.Windows.Forms.Label m_lblContext; } }keepass2-2.25/KeePass/Forms/FieldRefForm.resx0000664000175000017500000001326611572445304020760 0ustar jtaylorjtaylor 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 keepass2-2.25/KeePass/Forms/GroupForm.resx0000664000175000017500000001326612162301310020354 0ustar jtaylorjtaylor 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 keepass2-2.25/KeePass/Forms/UrlSchemeForm.cs0000664000175000017500000000373212261553106020604 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePass.App.Configuration; using KeePass.Resources; using KeePass.UI; namespace KeePass.Forms { public partial class UrlSchemeForm : Form { private AceUrlSchemeOverride m_ovr = null; public void InitEx(AceUrlSchemeOverride ovr) { m_ovr = ovr; } public UrlSchemeForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } private void OnFormLoad(object sender, EventArgs e) { if(m_ovr == null) throw new InvalidOperationException(); GlobalWindowManager.AddWindow(this); this.Icon = Properties.Resources.KeePass; this.Text = KPRes.UrlSchemeOverride; m_tbScheme.Text = m_ovr.Scheme; m_tbOverride.Text = m_ovr.UrlOverride; } private void OnFormClosed(object sender, FormClosedEventArgs e) { GlobalWindowManager.RemoveWindow(this); } private void OnBtnOK(object sender, EventArgs e) { m_ovr.Scheme = m_tbScheme.Text; m_ovr.UrlOverride = m_tbOverride.Text; } } } keepass2-2.25/KeePass/Forms/EditStringForm.cs0000664000175000017500000001765512261553106021002 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Threading; using KeePass.App; using KeePass.UI; using KeePass.Resources; using KeePassLib; using KeePassLib.Delegates; using KeePassLib.Security; using KeePassLib.Collections; namespace KeePass.Forms { public partial class EditStringForm : Form { private ProtectedStringDictionary m_vStringDict = null; private string m_strStringName = null; private ProtectedString m_psStringInitialValue = null; private RichTextBoxContextMenu m_ctxValue = new RichTextBoxContextMenu(); private PwDatabase m_pwContext = null; private volatile List m_vSuggestedNames = new List(); public EditStringForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } /// /// Initialize the dialog. Needs to be called before the dialog is shown. /// /// String container. Must not be null. /// Initial name of the string. May be null. /// Initial value. May be null. public void InitEx(ProtectedStringDictionary vStringDict, string strStringName, ProtectedString psStringInitialValue, PwDatabase pwContext) { Debug.Assert(vStringDict != null); if(vStringDict == null) throw new ArgumentNullException("vStringDict"); m_vStringDict = vStringDict; m_strStringName = strStringName; m_psStringInitialValue = psStringInitialValue; m_pwContext = pwContext; } private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_vStringDict != null); if(m_vStringDict == null) throw new InvalidOperationException(); GlobalWindowManager.AddWindow(this); m_ctxValue.Attach(m_richStringValue, this); string strTitle, strDesc; if(m_strStringName == null) { strTitle = KPRes.AddStringField; strDesc = KPRes.AddStringFieldDesc; } else { strTitle = KPRes.EditStringField; strDesc = KPRes.EditStringFieldDesc; } BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_Font, strTitle, strDesc); this.Icon = Properties.Resources.KeePass; UIUtil.EnableAutoCompletion(m_cmbStringName, true); UIUtil.PrepareStandardMultilineControl(m_richStringValue, true, true); if(m_strStringName != null) m_cmbStringName.Text = m_strStringName; if(m_psStringInitialValue != null) { m_richStringValue.Text = m_psStringInitialValue.ReadString(); m_cbProtect.Checked = m_psStringInitialValue.IsProtected; } ValidateStringName(); PopulateNamesComboBox(); // UIUtil.SetFocus(m_cmbStringName, this); // See PopulateNamesComboBox } private bool ValidateStringNameEx(string str) { if(str == null) { Debug.Assert(false); return false; } if(PwDefs.IsStandardField(str)) return false; if(str.Length <= 0) return false; char[] vInvalidChars = new char[] { '{', '}' }; if(str.IndexOfAny(vInvalidChars) >= 0) return false; string strStart = (m_strStringName != null) ? m_strStringName : string.Empty; if(!strStart.Equals(str) && m_vStringDict.Exists(str)) return false; // See ValidateStringName return true; } private bool ValidateStringName() { string str = m_cmbStringName.Text; string strStart = (m_strStringName != null) ? m_strStringName : string.Empty; char[] vInvalidChars = new char[]{ '{', '}' }; if(PwDefs.IsStandardField(str)) { m_lblValidationInfo.Text = KPRes.FieldNameInvalid; m_cmbStringName.BackColor = AppDefs.ColorEditError; m_btnOK.Enabled = false; return false; } else if(str.Length <= 0) { m_lblValidationInfo.Text = KPRes.FieldNamePrompt; m_cmbStringName.ResetBackColor(); m_btnOK.Enabled = false; return false; } else if(str.IndexOfAny(vInvalidChars) >= 0) { m_lblValidationInfo.Text = KPRes.FieldNameInvalid; m_cmbStringName.BackColor = AppDefs.ColorEditError; m_btnOK.Enabled = false; return false; } else if(!strStart.Equals(str) && m_vStringDict.Exists(str)) { m_lblValidationInfo.Text = KPRes.FieldNameExistsAlready; m_cmbStringName.BackColor = AppDefs.ColorEditError; m_btnOK.Enabled = false; return false; } else { m_lblValidationInfo.Text = string.Empty; m_cmbStringName.ResetBackColor(); m_btnOK.Enabled = true; } // See ValidateStringNameEx return true; } private void OnBtnOK(object sender, EventArgs e) { string strName = m_cmbStringName.Text; if(!ValidateStringName()) { this.DialogResult = DialogResult.None; return; } if(m_strStringName == null) // Add string field { Debug.Assert(!m_vStringDict.Exists(strName)); } else // Edit string field { if(!m_strStringName.Equals(strName)) m_vStringDict.Remove(m_strStringName); } ProtectedString ps = new ProtectedString(m_cbProtect.Checked, m_richStringValue.Text); m_vStringDict.Set(strName, ps); } private void OnBtnCancel(object sender, EventArgs e) { } private void CleanUpEx() { m_ctxValue.Detach(); } private void PopulateNamesComboBox() { ThreadStart ts = new ThreadStart(this.PopulateNamesCollectFunc); Thread th = new Thread(ts); th.Start(); } private void PopulateNamesCollectFunc() { if(m_pwContext == null) { Debug.Assert(false); return; } EntryHandler eh = delegate(PwEntry pe) { if(pe == null) { Debug.Assert(false); return true; } foreach(KeyValuePair kvp in pe.Strings) { if(ValidateStringNameEx(kvp.Key) && !m_vSuggestedNames.Contains(kvp.Key)) { m_vSuggestedNames.Add(kvp.Key); } } return true; }; m_pwContext.RootGroup.TraverseTree(TraversalMethod.PreOrder, null, eh); m_vSuggestedNames.Sort(); if(m_cmbStringName.InvokeRequired) m_cmbStringName.Invoke(new VoidDelegate(this.PopulateNamesAddFunc)); else this.PopulateNamesAddFunc(); } private void PopulateNamesAddFunc() { foreach(string str in m_vSuggestedNames) m_cmbStringName.Items.Add(str); UIUtil.SetFocus(m_cmbStringName, this); } private void OnBtnHelp(object sender, EventArgs e) { AppHelp.ShowHelp(AppDefs.HelpTopics.Entry, AppDefs.HelpTopics.EntryStrings); } private void OnFormClosed(object sender, FormClosedEventArgs e) { GlobalWindowManager.RemoveWindow(this); } private void OnNameTextChanged(object sender, EventArgs e) { ValidateStringName(); } protected override bool ProcessDialogKey(Keys keyData) { if(((keyData == Keys.Return) || (keyData == Keys.Enter)) && m_richStringValue.Focused) return false; // Forward to RichTextBox return base.ProcessDialogKey(keyData); } private void OnFormClosing(object sender, FormClosingEventArgs e) { CleanUpEx(); } } }keepass2-2.25/KeePass/Forms/SingleLineEditForm.cs0000664000175000017500000000701412261553106021551 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePass.UI; namespace KeePass.Forms { public partial class SingleLineEditForm : Form { private string m_strTitle = string.Empty; private string m_strDesc = string.Empty; private string m_strLongDesc = string.Empty; private Image m_imgIcon = null; private string m_strDefaultText = string.Empty; private string[] m_vSelectable = null; private string m_strResultString = string.Empty; public string ResultString { get { return m_strResultString; } } public SingleLineEditForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } public void InitEx(string strTitle, string strDesc, string strLongDesc, Image imgIcon, string strDefaultText, string[] vSelectable) { m_strTitle = strTitle; m_strDesc = strDesc; m_strLongDesc = strLongDesc; m_imgIcon = imgIcon; m_strDefaultText = strDefaultText; m_vSelectable = vSelectable; } private void OnFormLoad(object sender, EventArgs e) { if(m_strTitle == null) throw new InvalidOperationException(); if(m_strDesc == null) throw new InvalidOperationException(); if(m_strLongDesc == null) throw new InvalidOperationException(); if(m_imgIcon == null) throw new InvalidOperationException(); if(m_strDefaultText == null) throw new InvalidOperationException(); GlobalWindowManager.AddWindow(this); BannerFactory.CreateBannerEx(this, m_bannerImage, m_imgIcon, m_strTitle, m_strDesc); this.Icon = Properties.Resources.KeePass; this.Text = m_strTitle; m_lblLongDesc.Text = m_strLongDesc; Control cFocus = null; if((m_vSelectable == null) || (m_vSelectable.Length == 0)) { m_cmbEdit.Enabled = false; m_cmbEdit.Visible = false; cFocus = m_tbEdit; } else // With selectable values { m_tbEdit.Enabled = false; m_tbEdit.Visible = false; cFocus = m_cmbEdit; foreach(string strPreDef in m_vSelectable) m_cmbEdit.Items.Add(strPreDef); UIUtil.EnableAutoCompletion(m_cmbEdit, false); } cFocus.Text = m_strDefaultText; this.Invalidate(); UIUtil.SetFocus(cFocus, this); } private void OnBtnOK(object sender, EventArgs e) { if((m_vSelectable == null) || (m_vSelectable.Length == 0)) m_strResultString = m_tbEdit.Text; else m_strResultString = m_cmbEdit.Text; } private void OnBtnCancel(object sender, EventArgs e) { } private void OnFormClosed(object sender, FormClosedEventArgs e) { GlobalWindowManager.RemoveWindow(this); } } } keepass2-2.25/KeePass/Forms/EcasEventForm.resx0000664000175000017500000001326612113701700021140 0ustar jtaylorjtaylor 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 keepass2-2.25/KeePass/Forms/TanWizardForm.cs0000664000175000017500000001040412261553106020612 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePass.UI; using KeePass.Resources; using KeePassLib; using KeePassLib.Security; namespace KeePass.Forms { public partial class TanWizardForm : Form { private PwDatabase m_pwDatabase = null; private PwGroup m_pgStorage = null; public void InitEx(PwDatabase pwParent, PwGroup pgStorage) { m_pwDatabase = pwParent; m_pgStorage = pgStorage; } public TanWizardForm() { 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_pgStorage != null); if(m_pgStorage == null) throw new InvalidOperationException(); GlobalWindowManager.AddWindow(this); BannerFactory.CreateBannerEx(this, m_bannerImage, KeePass.Properties.Resources.B48x48_Wizard, KPRes.TanWizard, KPRes.TanWizardDesc); this.Icon = Properties.Resources.KeePass; this.Text = KPRes.TanWizard; if((m_pgStorage.Name != null) && (m_pgStorage.Name.Length > 0)) m_lblToGroup.Text += ": " + m_pgStorage.Name + "."; else m_lblToGroup.Text += "."; m_tbTanChars.Text = Program.Config.Defaults.TanCharacters; EnableControlsEx(); } private void OnBtnOK(object sender, EventArgs e) { ParseTans(); } private void OnBtnCancel(object sender, EventArgs e) { } private void CleanUpEx() { Program.Config.Defaults.TanCharacters = m_tbTanChars.Text; } private void EnableControlsEx() { m_numTANsIndex.Enabled = m_cbNumberTans.Checked; } private void ParseTans() { StringBuilder sb = new StringBuilder(); string strText = m_tbTANs.Text; int nTanIndex = (int)m_numTANsIndex.Value; bool bSetIndex = m_cbNumberTans.Checked; string strTanChars = m_tbTanChars.Text; for(int i = 0; i < strText.Length; ++i) { char ch = strText[i]; if(strTanChars.IndexOf(ch) >= 0) sb.Append(ch); else { AddTan(sb.ToString(), bSetIndex, ref nTanIndex); sb = new StringBuilder(); // Reset string } } if(sb.Length > 0) AddTan(sb.ToString(), bSetIndex, ref nTanIndex); } private void AddTan(string strTan, bool bSetIndex, ref int nTanIndex) { if(strTan.Length == 0) return; PwEntry pe = new PwEntry(true, true); pe.Strings.Set(PwDefs.TitleField, new ProtectedString( m_pwDatabase.MemoryProtection.ProtectTitle, PwDefs.TanTitle)); pe.Strings.Set(PwDefs.PasswordField, new ProtectedString( m_pwDatabase.MemoryProtection.ProtectPassword, strTan)); if(bSetIndex && (nTanIndex >= 0)) { Debug.Assert(PwDefs.TanIndexField == PwDefs.UserNameField); pe.Strings.Set(PwDefs.TanIndexField, new ProtectedString( m_pwDatabase.MemoryProtection.ProtectUserName, nTanIndex.ToString())); ++nTanIndex; } m_pgStorage.AddEntry(pe, true); } private void OnNumberTANsCheckedChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnFormClosed(object sender, FormClosedEventArgs e) { GlobalWindowManager.RemoveWindow(this); } private void OnFormClosing(object sender, FormClosingEventArgs e) { CleanUpEx(); } } } keepass2-2.25/KeePass/Forms/IconPickerForm.resx0000664000175000017500000001326612075525244021327 0ustar jtaylorjtaylor 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 keepass2-2.25/KeePass/Forms/FieldRefForm.cs0000664000175000017500000001577312261553106020405 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePass.App; using KeePass.Resources; using KeePass.UI; using KeePassLib; using KeePassLib.Collections; using KeePassLib.Utility; namespace KeePass.Forms { public partial class FieldRefForm : Form { private PwGroup m_pgEntrySource = null; private ImageList m_ilIcons = null; private string m_strResultRef = string.Empty; private List> m_vColumns = new List>(); public string ResultReference { get { return m_strResultRef; } } public void InitEx(PwGroup pgEntrySource, ImageList ilClientIcons) { m_pgEntrySource = pgEntrySource; m_ilIcons = ilClientIcons; } public FieldRefForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } private void OnFormLoad(object sender, EventArgs e) { if(m_pgEntrySource == null) { Debug.Assert(false); return; } if(m_ilIcons == null) { Debug.Assert(false); return; } GlobalWindowManager.AddWindow(this); this.Icon = Properties.Resources.KeePass; UIUtil.SetExplorerTheme(m_lvEntries, true); m_vColumns.Add(new KeyValuePair(PwDefs.TitleField, KPRes.Title)); m_vColumns.Add(new KeyValuePair(PwDefs.UserNameField, KPRes.UserName)); m_vColumns.Add(new KeyValuePair(PwDefs.UrlField, KPRes.Url)); m_vColumns.Add(new KeyValuePair(PwDefs.NotesField, KPRes.Notes)); PwObjectList vEntries = m_pgEntrySource.GetEntries(true); UIUtil.CreateEntryList(m_lvEntries, vEntries, m_vColumns, m_ilIcons); m_radioIdUuid.Checked = true; m_radioRefPassword.Checked = true; } private void CleanUpEx() { m_lvEntries.SmallImageList = null; // Detach event handlers } private void OnFormClosed(object sender, FormClosedEventArgs e) { CleanUpEx(); GlobalWindowManager.RemoveWindow(this); } private PwEntry GetSelectedEntry() { ListView.SelectedListViewItemCollection lvsic = m_lvEntries.SelectedItems; if((lvsic == null) || (lvsic.Count != 1)) return null; return (lvsic[0].Tag as PwEntry); } private bool CreateResultRef() { PwEntry pe = this.GetSelectedEntry(); if(pe == null) return false; string str = @"{REF:"; if(m_radioRefTitle.Checked) str += "T"; else if(m_radioRefUserName.Checked) str += "U"; else if(m_radioRefPassword.Checked) str += "P"; else if(m_radioRefUrl.Checked) str += "A"; else if(m_radioRefNotes.Checked) str += "N"; else { Debug.Assert(false); return false; } str += @"@"; string strId; if(m_radioIdTitle.Checked) strId = @"T:" + pe.Strings.ReadSafe(PwDefs.TitleField); else if(m_radioIdUserName.Checked) strId = @"U:" + pe.Strings.ReadSafe(PwDefs.UserNameField); else if(m_radioIdPassword.Checked) strId = @"P:" + pe.Strings.ReadSafe(PwDefs.PasswordField); else if(m_radioIdUrl.Checked) strId = @"A:" + pe.Strings.ReadSafe(PwDefs.UrlField); else if(m_radioIdNotes.Checked) strId = @"N:" + pe.Strings.ReadSafe(PwDefs.NotesField); else if(m_radioIdUuid.Checked) strId = @"I:" + pe.Uuid.ToHexString(); else { Debug.Assert(false); return false; } char[] vInvalidChars = new char[] { '{', '}', '\r', '\n' }; if(strId.IndexOfAny(vInvalidChars) >= 0) { MessageService.ShowWarning(KPRes.FieldRefInvalidChars); return false; } string strIdData = strId.Substring(2, strId.Length - 2); if(IdMatchesMultipleTimes(strIdData, strId[0])) { MessageService.ShowWarning(KPRes.FieldRefMultiMatch, KPRes.FieldRefMultiMatchHint); return false; } str += strId + @"}"; m_strResultRef = str; return true; } private bool IdMatchesMultipleTimes(string strSearch, char tchField) { if(m_pgEntrySource == null) { Debug.Assert(false); return false; } SearchParameters sp = SearchParameters.None; sp.SearchString = strSearch; sp.RespectEntrySearchingDisabled = false; if(tchField == 'T') sp.SearchInTitles = true; else if(tchField == 'U') sp.SearchInUserNames = true; else if(tchField == 'P') sp.SearchInPasswords = true; else if(tchField == 'A') sp.SearchInUrls = true; else if(tchField == 'N') sp.SearchInNotes = true; else if(tchField == 'I') sp.SearchInUuids = true; else { Debug.Assert(false); return true; } PwObjectList l = new PwObjectList(); m_pgEntrySource.SearchEntries(sp, l); if(l.UCount == 0) { Debug.Assert(false); return false; } else if(l.UCount == 1) return false; return true; } private void OnBtnOK(object sender, EventArgs e) { if(!CreateResultRef()) this.DialogResult = DialogResult.None; } private void OnBtnCancel(object sender, EventArgs e) { } private void EnableChildControls() { m_btnOK.Enabled = (GetSelectedEntry() != null); } private void OnEntriesSelectedIndexChanged(object sender, EventArgs e) { EnableChildControls(); } private void OnBtnHelp(object sender, EventArgs e) { AppHelp.ShowHelp(AppDefs.HelpTopics.FieldRefs, null); } protected override bool ProcessDialogKey(Keys keyData) { if(((keyData == Keys.Return) || (keyData == Keys.Enter)) && m_tbFilter.Focused) return false; // Forward to TextBox return base.ProcessDialogKey(keyData); } private void OnFilterKeyDown(object sender, KeyEventArgs e) { if((e.KeyCode == Keys.Return) || (e.KeyCode == Keys.Enter)) { e.SuppressKeyPress = true; SearchParameters sp = new SearchParameters(); sp.SearchString = m_tbFilter.Text; sp.SearchInPasswords = true; PwObjectList lResults = new PwObjectList(); m_pgEntrySource.SearchEntries(sp, lResults); UIUtil.CreateEntryList(m_lvEntries, lResults, m_vColumns, m_ilIcons); } } private void OnFilterKeyUp(object sender, KeyEventArgs e) { if((e.KeyCode == Keys.Return) || (e.KeyCode == Keys.Enter)) e.SuppressKeyPress = true; } } } keepass2-2.25/KeePass/Forms/GroupForm.Designer.cs0000664000175000017500000003760712162301310021544 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class GroupForm { /// /// 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_lblName = new System.Windows.Forms.Label(); this.m_bannerImage = new System.Windows.Forms.PictureBox(); this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_tbName = new System.Windows.Forms.TextBox(); this.m_lblIcon = new System.Windows.Forms.Label(); this.m_btnIcon = new System.Windows.Forms.Button(); this.m_tabMain = new System.Windows.Forms.TabControl(); this.m_tabGeneral = new System.Windows.Forms.TabPage(); this.m_dtExpires = new System.Windows.Forms.DateTimePicker(); this.m_cbExpires = new System.Windows.Forms.CheckBox(); this.m_tabNotes = new System.Windows.Forms.TabPage(); this.m_lblNotesHint = new System.Windows.Forms.Label(); this.m_tbNotes = new System.Windows.Forms.TextBox(); this.m_tabBehavior = new System.Windows.Forms.TabPage(); this.m_cmbEnableSearching = new System.Windows.Forms.ComboBox(); this.m_cmbEnableAutoType = new System.Windows.Forms.ComboBox(); this.m_lblEnableSearching = new System.Windows.Forms.Label(); this.m_lblEnableAutoType = new System.Windows.Forms.Label(); this.m_tabAutoType = new System.Windows.Forms.TabPage(); this.m_btnAutoTypeEdit = new System.Windows.Forms.Button(); this.m_rbAutoTypeOverride = new System.Windows.Forms.RadioButton(); this.m_rbAutoTypeInherit = new System.Windows.Forms.RadioButton(); this.m_lblAutoTypeDesc = new System.Windows.Forms.Label(); this.m_tbDefaultAutoTypeSeq = new System.Windows.Forms.TextBox(); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).BeginInit(); this.m_tabMain.SuspendLayout(); this.m_tabGeneral.SuspendLayout(); this.m_tabNotes.SuspendLayout(); this.m_tabBehavior.SuspendLayout(); this.m_tabAutoType.SuspendLayout(); this.SuspendLayout(); // // m_lblName // this.m_lblName.AutoSize = true; this.m_lblName.Location = new System.Drawing.Point(3, 11); this.m_lblName.Name = "m_lblName"; this.m_lblName.Size = new System.Drawing.Size(38, 13); this.m_lblName.TabIndex = 1; this.m_lblName.Text = "Name:"; // // m_bannerImage // this.m_bannerImage.Dock = System.Windows.Forms.DockStyle.Top; this.m_bannerImage.Location = new System.Drawing.Point(0, 0); this.m_bannerImage.Name = "m_bannerImage"; this.m_bannerImage.Size = new System.Drawing.Size(388, 60); this.m_bannerImage.TabIndex = 1; this.m_bannerImage.TabStop = false; // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(220, 238); this.m_btnOK.Name = "m_btnOK"; this.m_btnOK.Size = new System.Drawing.Size(75, 23); this.m_btnOK.TabIndex = 1; this.m_btnOK.Text = "&OK"; 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(301, 238); this.m_btnCancel.Name = "m_btnCancel"; this.m_btnCancel.Size = new System.Drawing.Size(75, 23); this.m_btnCancel.TabIndex = 2; this.m_btnCancel.Text = "&Cancel"; this.m_btnCancel.UseVisualStyleBackColor = true; this.m_btnCancel.Click += new System.EventHandler(this.OnBtnCancel); // // m_tbName // this.m_tbName.Location = new System.Drawing.Point(60, 11); this.m_tbName.Name = "m_tbName"; this.m_tbName.Size = new System.Drawing.Size(286, 20); this.m_tbName.TabIndex = 0; // // m_lblIcon // this.m_lblIcon.AutoSize = true; this.m_lblIcon.Location = new System.Drawing.Point(3, 39); this.m_lblIcon.Name = "m_lblIcon"; this.m_lblIcon.Size = new System.Drawing.Size(31, 13); this.m_lblIcon.TabIndex = 2; this.m_lblIcon.Text = "Icon:"; // // m_btnIcon // this.m_btnIcon.Location = new System.Drawing.Point(60, 37); this.m_btnIcon.Name = "m_btnIcon"; this.m_btnIcon.Size = new System.Drawing.Size(33, 23); this.m_btnIcon.TabIndex = 3; this.m_btnIcon.UseVisualStyleBackColor = true; this.m_btnIcon.Click += new System.EventHandler(this.OnBtnIcon); // // m_tabMain // this.m_tabMain.Controls.Add(this.m_tabGeneral); this.m_tabMain.Controls.Add(this.m_tabNotes); this.m_tabMain.Controls.Add(this.m_tabBehavior); this.m_tabMain.Controls.Add(this.m_tabAutoType); this.m_tabMain.Location = new System.Drawing.Point(12, 66); this.m_tabMain.Name = "m_tabMain"; this.m_tabMain.SelectedIndex = 0; this.m_tabMain.Size = new System.Drawing.Size(364, 166); this.m_tabMain.TabIndex = 0; // // m_tabGeneral // this.m_tabGeneral.Controls.Add(this.m_dtExpires); this.m_tabGeneral.Controls.Add(this.m_cbExpires); this.m_tabGeneral.Controls.Add(this.m_lblName); this.m_tabGeneral.Controls.Add(this.m_btnIcon); this.m_tabGeneral.Controls.Add(this.m_tbName); this.m_tabGeneral.Controls.Add(this.m_lblIcon); this.m_tabGeneral.Location = new System.Drawing.Point(4, 22); this.m_tabGeneral.Name = "m_tabGeneral"; this.m_tabGeneral.Size = new System.Drawing.Size(356, 140); this.m_tabGeneral.TabIndex = 0; this.m_tabGeneral.Text = "General"; this.m_tabGeneral.UseVisualStyleBackColor = true; // // m_dtExpires // this.m_dtExpires.Format = System.Windows.Forms.DateTimePickerFormat.Custom; this.m_dtExpires.Location = new System.Drawing.Point(87, 105); this.m_dtExpires.Name = "m_dtExpires"; this.m_dtExpires.Size = new System.Drawing.Size(259, 20); this.m_dtExpires.TabIndex = 5; // // m_cbExpires // this.m_cbExpires.AutoSize = true; this.m_cbExpires.Location = new System.Drawing.Point(6, 105); this.m_cbExpires.Name = "m_cbExpires"; this.m_cbExpires.Size = new System.Drawing.Size(63, 17); this.m_cbExpires.TabIndex = 4; this.m_cbExpires.Text = "Expires:"; this.m_cbExpires.UseVisualStyleBackColor = true; // // m_tabNotes // this.m_tabNotes.Controls.Add(this.m_lblNotesHint); this.m_tabNotes.Controls.Add(this.m_tbNotes); this.m_tabNotes.Location = new System.Drawing.Point(4, 22); this.m_tabNotes.Name = "m_tabNotes"; this.m_tabNotes.Size = new System.Drawing.Size(356, 140); this.m_tabNotes.TabIndex = 2; this.m_tabNotes.Text = "Notes"; this.m_tabNotes.UseVisualStyleBackColor = true; // // m_lblNotesHint // this.m_lblNotesHint.AutoSize = true; this.m_lblNotesHint.Location = new System.Drawing.Point(3, 121); this.m_lblNotesHint.Name = "m_lblNotesHint"; this.m_lblNotesHint.Size = new System.Drawing.Size(167, 13); this.m_lblNotesHint.TabIndex = 1; this.m_lblNotesHint.Text = "Notes are shown in group tooltips."; // // m_tbNotes // this.m_tbNotes.AcceptsReturn = true; this.m_tbNotes.Location = new System.Drawing.Point(6, 10); this.m_tbNotes.Multiline = true; this.m_tbNotes.Name = "m_tbNotes"; this.m_tbNotes.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.m_tbNotes.Size = new System.Drawing.Size(341, 107); this.m_tbNotes.TabIndex = 0; // // m_tabBehavior // this.m_tabBehavior.Controls.Add(this.m_cmbEnableSearching); this.m_tabBehavior.Controls.Add(this.m_cmbEnableAutoType); this.m_tabBehavior.Controls.Add(this.m_lblEnableSearching); this.m_tabBehavior.Controls.Add(this.m_lblEnableAutoType); this.m_tabBehavior.Location = new System.Drawing.Point(4, 22); this.m_tabBehavior.Name = "m_tabBehavior"; this.m_tabBehavior.Size = new System.Drawing.Size(356, 140); this.m_tabBehavior.TabIndex = 3; this.m_tabBehavior.Text = "Behavior"; this.m_tabBehavior.UseVisualStyleBackColor = true; // // m_cmbEnableSearching // this.m_cmbEnableSearching.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.m_cmbEnableSearching.FormattingEnabled = true; this.m_cmbEnableSearching.Location = new System.Drawing.Point(9, 74); this.m_cmbEnableSearching.Name = "m_cmbEnableSearching"; this.m_cmbEnableSearching.Size = new System.Drawing.Size(334, 21); this.m_cmbEnableSearching.TabIndex = 3; // // m_cmbEnableAutoType // this.m_cmbEnableAutoType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.m_cmbEnableAutoType.FormattingEnabled = true; this.m_cmbEnableAutoType.Location = new System.Drawing.Point(9, 25); this.m_cmbEnableAutoType.Name = "m_cmbEnableAutoType"; this.m_cmbEnableAutoType.Size = new System.Drawing.Size(334, 21); this.m_cmbEnableAutoType.TabIndex = 1; // // m_lblEnableSearching // this.m_lblEnableSearching.AutoSize = true; this.m_lblEnableSearching.Location = new System.Drawing.Point(6, 58); this.m_lblEnableSearching.Name = "m_lblEnableSearching"; this.m_lblEnableSearching.Size = new System.Drawing.Size(152, 13); this.m_lblEnableSearching.TabIndex = 2; this.m_lblEnableSearching.Text = "Searching entries in this group:"; // // m_lblEnableAutoType // this.m_lblEnableAutoType.AutoSize = true; this.m_lblEnableAutoType.Location = new System.Drawing.Point(6, 9); this.m_lblEnableAutoType.Name = "m_lblEnableAutoType"; this.m_lblEnableAutoType.Size = new System.Drawing.Size(168, 13); this.m_lblEnableAutoType.TabIndex = 0; this.m_lblEnableAutoType.Text = "Auto-Type for entries in this group:"; // // m_tabAutoType // this.m_tabAutoType.Controls.Add(this.m_btnAutoTypeEdit); this.m_tabAutoType.Controls.Add(this.m_rbAutoTypeOverride); this.m_tabAutoType.Controls.Add(this.m_rbAutoTypeInherit); this.m_tabAutoType.Controls.Add(this.m_lblAutoTypeDesc); this.m_tabAutoType.Controls.Add(this.m_tbDefaultAutoTypeSeq); this.m_tabAutoType.Location = new System.Drawing.Point(4, 22); this.m_tabAutoType.Name = "m_tabAutoType"; this.m_tabAutoType.Size = new System.Drawing.Size(356, 140); this.m_tabAutoType.TabIndex = 1; this.m_tabAutoType.Text = "Auto-Type"; this.m_tabAutoType.UseVisualStyleBackColor = true; // // m_btnAutoTypeEdit // this.m_btnAutoTypeEdit.Location = new System.Drawing.Point(315, 54); this.m_btnAutoTypeEdit.Name = "m_btnAutoTypeEdit"; this.m_btnAutoTypeEdit.Size = new System.Drawing.Size(32, 23); this.m_btnAutoTypeEdit.TabIndex = 3; this.m_btnAutoTypeEdit.UseVisualStyleBackColor = true; this.m_btnAutoTypeEdit.Click += new System.EventHandler(this.OnBtnAutoTypeEdit); // // m_rbAutoTypeOverride // this.m_rbAutoTypeOverride.AutoSize = true; this.m_rbAutoTypeOverride.Location = new System.Drawing.Point(9, 33); this.m_rbAutoTypeOverride.Name = "m_rbAutoTypeOverride"; this.m_rbAutoTypeOverride.Size = new System.Drawing.Size(153, 17); this.m_rbAutoTypeOverride.TabIndex = 1; this.m_rbAutoTypeOverride.TabStop = true; this.m_rbAutoTypeOverride.Text = "Override default sequence:"; this.m_rbAutoTypeOverride.UseVisualStyleBackColor = true; // // m_rbAutoTypeInherit // this.m_rbAutoTypeInherit.AutoSize = true; this.m_rbAutoTypeInherit.Location = new System.Drawing.Point(9, 10); this.m_rbAutoTypeInherit.Name = "m_rbAutoTypeInherit"; this.m_rbAutoTypeInherit.Size = new System.Drawing.Size(272, 17); this.m_rbAutoTypeInherit.TabIndex = 0; this.m_rbAutoTypeInherit.TabStop = true; this.m_rbAutoTypeInherit.Text = "Inherit default auto-type sequence from parent group"; this.m_rbAutoTypeInherit.UseVisualStyleBackColor = true; this.m_rbAutoTypeInherit.CheckedChanged += new System.EventHandler(this.OnAutoTypeInheritCheckedChanged); // // m_lblAutoTypeDesc // this.m_lblAutoTypeDesc.Location = new System.Drawing.Point(26, 79); this.m_lblAutoTypeDesc.Name = "m_lblAutoTypeDesc"; this.m_lblAutoTypeDesc.Size = new System.Drawing.Size(321, 27); this.m_lblAutoTypeDesc.TabIndex = 4; this.m_lblAutoTypeDesc.Text = "All subgroups and entries in the current group that inherit the group\'s auto-type" + " sequence will use the one entered above."; // // m_tbDefaultAutoTypeSeq // this.m_tbDefaultAutoTypeSeq.Location = new System.Drawing.Point(29, 56); this.m_tbDefaultAutoTypeSeq.Name = "m_tbDefaultAutoTypeSeq"; this.m_tbDefaultAutoTypeSeq.Size = new System.Drawing.Size(280, 20); this.m_tbDefaultAutoTypeSeq.TabIndex = 2; // // GroupForm // 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(388, 273); this.Controls.Add(this.m_tabMain); this.Controls.Add(this.m_btnCancel); this.Controls.Add(this.m_btnOK); this.Controls.Add(this.m_bannerImage); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "GroupForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = ""; this.Load += new System.EventHandler(this.OnFormLoad); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).EndInit(); this.m_tabMain.ResumeLayout(false); this.m_tabGeneral.ResumeLayout(false); this.m_tabGeneral.PerformLayout(); this.m_tabNotes.ResumeLayout(false); this.m_tabNotes.PerformLayout(); this.m_tabBehavior.ResumeLayout(false); this.m_tabBehavior.PerformLayout(); this.m_tabAutoType.ResumeLayout(false); this.m_tabAutoType.PerformLayout(); this.ResumeLayout(false); } #endregion private System.Windows.Forms.Label m_lblName; private System.Windows.Forms.PictureBox m_bannerImage; private System.Windows.Forms.Button m_btnOK; private System.Windows.Forms.Button m_btnCancel; private System.Windows.Forms.TextBox m_tbName; private System.Windows.Forms.Label m_lblIcon; private System.Windows.Forms.Button m_btnIcon; private System.Windows.Forms.TabControl m_tabMain; private System.Windows.Forms.TabPage m_tabGeneral; private System.Windows.Forms.TabPage m_tabAutoType; private System.Windows.Forms.Label m_lblAutoTypeDesc; private System.Windows.Forms.TextBox m_tbDefaultAutoTypeSeq; private System.Windows.Forms.CheckBox m_cbExpires; private System.Windows.Forms.DateTimePicker m_dtExpires; private System.Windows.Forms.RadioButton m_rbAutoTypeInherit; private System.Windows.Forms.RadioButton m_rbAutoTypeOverride; private System.Windows.Forms.Button m_btnAutoTypeEdit; private System.Windows.Forms.TabPage m_tabNotes; private System.Windows.Forms.TextBox m_tbNotes; private System.Windows.Forms.TabPage m_tabBehavior; private System.Windows.Forms.Label m_lblEnableSearching; private System.Windows.Forms.Label m_lblEnableAutoType; private System.Windows.Forms.ComboBox m_cmbEnableSearching; private System.Windows.Forms.ComboBox m_cmbEnableAutoType; private System.Windows.Forms.Label m_lblNotesHint; } }keepass2-2.25/KeePass/Forms/InternalBrowserForm.resx0000664000175000017500000001441311352443100022377 0ustar jtaylorjtaylor 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 122, 17 241, 17 17, 17 keepass2-2.25/KeePass/Forms/EcasEventForm.Designer.cs0000664000175000017500000001414512113701700022320 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class EcasEventForm { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if(disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.m_lblEvent = new System.Windows.Forms.Label(); this.m_cmbEvents = new System.Windows.Forms.ComboBox(); this.m_btnOK = new System.Windows.Forms.Button(); this.m_btnCancel = new System.Windows.Forms.Button(); this.m_dgvParams = new System.Windows.Forms.DataGridView(); this.m_lblParamHint = new System.Windows.Forms.Label(); this.m_lblSep = new System.Windows.Forms.Label(); this.m_btnHelp = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.m_dgvParams)).BeginInit(); this.SuspendLayout(); // // m_lblEvent // this.m_lblEvent.AutoSize = true; this.m_lblEvent.Location = new System.Drawing.Point(9, 14); this.m_lblEvent.Name = "m_lblEvent"; this.m_lblEvent.Size = new System.Drawing.Size(38, 13); this.m_lblEvent.TabIndex = 7; this.m_lblEvent.Text = "Event:"; // // m_cmbEvents // this.m_cmbEvents.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.m_cmbEvents.FormattingEnabled = true; this.m_cmbEvents.Location = new System.Drawing.Point(12, 30); this.m_cmbEvents.Name = "m_cmbEvents"; this.m_cmbEvents.Size = new System.Drawing.Size(510, 21); this.m_cmbEvents.TabIndex = 0; this.m_cmbEvents.SelectedIndexChanged += new System.EventHandler(this.OnEventsSelectedIndexChanged); // // m_btnOK // this.m_btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; this.m_btnOK.Location = new System.Drawing.Point(366, 289); this.m_btnOK.Name = "m_btnOK"; this.m_btnOK.Size = new System.Drawing.Size(75, 23); this.m_btnOK.TabIndex = 5; this.m_btnOK.Text = "&OK"; 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(447, 289); this.m_btnCancel.Name = "m_btnCancel"; this.m_btnCancel.Size = new System.Drawing.Size(75, 23); this.m_btnCancel.TabIndex = 6; this.m_btnCancel.Text = "&Cancel"; this.m_btnCancel.UseVisualStyleBackColor = true; this.m_btnCancel.Click += new System.EventHandler(this.OnBtnCancel); // // m_dgvParams // this.m_dgvParams.AllowUserToAddRows = false; this.m_dgvParams.AllowUserToDeleteRows = false; this.m_dgvParams.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.m_dgvParams.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.m_dgvParams.Location = new System.Drawing.Point(12, 57); this.m_dgvParams.Name = "m_dgvParams"; this.m_dgvParams.Size = new System.Drawing.Size(510, 180); this.m_dgvParams.TabIndex = 1; // // m_lblParamHint // this.m_lblParamHint.Location = new System.Drawing.Point(9, 249); this.m_lblParamHint.Name = "m_lblParamHint"; this.m_lblParamHint.Size = new System.Drawing.Size(513, 15); this.m_lblParamHint.TabIndex = 2; this.m_lblParamHint.Text = "<>"; // // m_lblSep // this.m_lblSep.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.m_lblSep.Location = new System.Drawing.Point(0, 280); this.m_lblSep.Name = "m_lblSep"; this.m_lblSep.Size = new System.Drawing.Size(535, 2); this.m_lblSep.TabIndex = 3; // // m_btnHelp // this.m_btnHelp.Location = new System.Drawing.Point(12, 289); this.m_btnHelp.Name = "m_btnHelp"; this.m_btnHelp.Size = new System.Drawing.Size(75, 23); this.m_btnHelp.TabIndex = 4; this.m_btnHelp.Text = "&Help"; this.m_btnHelp.UseVisualStyleBackColor = true; this.m_btnHelp.Click += new System.EventHandler(this.OnBtnHelp); // // EcasEventForm // 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(534, 324); this.Controls.Add(this.m_btnHelp); this.Controls.Add(this.m_lblSep); this.Controls.Add(this.m_lblParamHint); this.Controls.Add(this.m_dgvParams); this.Controls.Add(this.m_btnCancel); this.Controls.Add(this.m_btnOK); this.Controls.Add(this.m_lblEvent); this.Controls.Add(this.m_cmbEvents); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "EcasEventForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "<>"; this.Load += new System.EventHandler(this.OnFormLoad); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); ((System.ComponentModel.ISupportInitialize)(this.m_dgvParams)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.Label m_lblEvent; private System.Windows.Forms.ComboBox m_cmbEvents; private System.Windows.Forms.Button m_btnOK; private System.Windows.Forms.Button m_btnCancel; private System.Windows.Forms.DataGridView m_dgvParams; private System.Windows.Forms.Label m_lblParamHint; private System.Windows.Forms.Label m_lblSep; private System.Windows.Forms.Button m_btnHelp; } }keepass2-2.25/KeePass/Forms/PluginsForm.Designer.cs0000664000175000017500000002061711324405344022075 0ustar jtaylorjtaylornamespace KeePass.Forms { partial class PluginsForm { /// /// 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_btnClose = new System.Windows.Forms.Button(); this.m_lvPlugins = new KeePass.UI.CustomListViewEx(); this.m_lblSeparator = new System.Windows.Forms.Label(); this.m_bannerImage = new System.Windows.Forms.PictureBox(); this.m_grpPluginDesc = new System.Windows.Forms.GroupBox(); this.m_lblSelectedPluginDesc = new System.Windows.Forms.Label(); this.m_linkPlugins = new System.Windows.Forms.LinkLabel(); this.m_grpCache = new System.Windows.Forms.GroupBox(); this.m_cbCacheDeleteOld = new System.Windows.Forms.CheckBox(); this.m_btnClearCache = new System.Windows.Forms.Button(); this.m_lblCacheSize = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).BeginInit(); this.m_grpPluginDesc.SuspendLayout(); this.m_grpCache.SuspendLayout(); this.SuspendLayout(); // // m_btnClose // this.m_btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.m_btnClose.Location = new System.Drawing.Point(532, 431); this.m_btnClose.Name = "m_btnClose"; this.m_btnClose.Size = new System.Drawing.Size(75, 23); this.m_btnClose.TabIndex = 0; this.m_btnClose.Text = "&Close"; this.m_btnClose.UseVisualStyleBackColor = true; this.m_btnClose.Click += new System.EventHandler(this.OnBtnClose); // // m_lvPlugins // this.m_lvPlugins.FullRowSelect = true; this.m_lvPlugins.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; this.m_lvPlugins.HideSelection = false; this.m_lvPlugins.Location = new System.Drawing.Point(12, 66); this.m_lvPlugins.Name = "m_lvPlugins"; this.m_lvPlugins.ShowItemToolTips = true; this.m_lvPlugins.Size = new System.Drawing.Size(595, 165); this.m_lvPlugins.TabIndex = 1; this.m_lvPlugins.UseCompatibleStateImageBehavior = false; this.m_lvPlugins.View = System.Windows.Forms.View.Details; this.m_lvPlugins.SelectedIndexChanged += new System.EventHandler(this.OnPluginListSelectedIndexChanged); // // m_lblSeparator // this.m_lblSeparator.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.m_lblSeparator.Location = new System.Drawing.Point(0, 422); this.m_lblSeparator.Name = "m_lblSeparator"; this.m_lblSeparator.Size = new System.Drawing.Size(619, 2); this.m_lblSeparator.TabIndex = 4; // // m_bannerImage // this.m_bannerImage.Dock = System.Windows.Forms.DockStyle.Top; this.m_bannerImage.Location = new System.Drawing.Point(0, 0); this.m_bannerImage.Name = "m_bannerImage"; this.m_bannerImage.Size = new System.Drawing.Size(619, 60); this.m_bannerImage.TabIndex = 0; this.m_bannerImage.TabStop = false; // // m_grpPluginDesc // this.m_grpPluginDesc.Controls.Add(this.m_lblSelectedPluginDesc); this.m_grpPluginDesc.Location = new System.Drawing.Point(12, 237); this.m_grpPluginDesc.Name = "m_grpPluginDesc"; this.m_grpPluginDesc.Size = new System.Drawing.Size(595, 102); this.m_grpPluginDesc.TabIndex = 2; this.m_grpPluginDesc.TabStop = false; // // m_lblSelectedPluginDesc // this.m_lblSelectedPluginDesc.Location = new System.Drawing.Point(6, 16); this.m_lblSelectedPluginDesc.Name = "m_lblSelectedPluginDesc"; this.m_lblSelectedPluginDesc.Size = new System.Drawing.Size(583, 64); this.m_lblSelectedPluginDesc.TabIndex = 0; this.m_lblSelectedPluginDesc.Text = "<>"; // // m_linkPlugins // this.m_linkPlugins.AutoSize = true; this.m_linkPlugins.Location = new System.Drawing.Point(9, 436); this.m_linkPlugins.Name = "m_linkPlugins"; this.m_linkPlugins.Size = new System.Drawing.Size(95, 13); this.m_linkPlugins.TabIndex = 5; this.m_linkPlugins.TabStop = true; this.m_linkPlugins.Text = "Get more plugins..."; this.m_linkPlugins.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.OnPluginsLinkClicked); // // m_grpCache // this.m_grpCache.Controls.Add(this.m_cbCacheDeleteOld); this.m_grpCache.Controls.Add(this.m_btnClearCache); this.m_grpCache.Controls.Add(this.m_lblCacheSize); this.m_grpCache.Location = new System.Drawing.Point(12, 345); this.m_grpCache.Name = "m_grpCache"; this.m_grpCache.Size = new System.Drawing.Size(595, 65); this.m_grpCache.TabIndex = 3; this.m_grpCache.TabStop = false; this.m_grpCache.Text = "Plugin Cache"; // // m_cbCacheDeleteOld // this.m_cbCacheDeleteOld.AutoSize = true; this.m_cbCacheDeleteOld.Location = new System.Drawing.Point(9, 40); this.m_cbCacheDeleteOld.Name = "m_cbCacheDeleteOld"; this.m_cbCacheDeleteOld.Size = new System.Drawing.Size(215, 17); this.m_cbCacheDeleteOld.TabIndex = 2; this.m_cbCacheDeleteOld.Text = "Delete old files from cache automatically"; this.m_cbCacheDeleteOld.UseVisualStyleBackColor = true; // // m_btnClearCache // this.m_btnClearCache.Location = new System.Drawing.Point(509, 19); this.m_btnClearCache.Name = "m_btnClearCache"; this.m_btnClearCache.Size = new System.Drawing.Size(75, 23); this.m_btnClearCache.TabIndex = 1; this.m_btnClearCache.Text = "C&lear"; this.m_btnClearCache.UseVisualStyleBackColor = true; this.m_btnClearCache.Click += new System.EventHandler(this.OnBtnClearCache); // // m_lblCacheSize // this.m_lblCacheSize.Location = new System.Drawing.Point(6, 19); this.m_lblCacheSize.Name = "m_lblCacheSize"; this.m_lblCacheSize.Size = new System.Drawing.Size(497, 18); this.m_lblCacheSize.TabIndex = 0; this.m_lblCacheSize.Text = "Data in cache (size):"; // // PluginsForm // this.AcceptButton = this.m_btnClose; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.m_btnClose; this.ClientSize = new System.Drawing.Size(619, 466); this.Controls.Add(this.m_grpCache); this.Controls.Add(this.m_linkPlugins); this.Controls.Add(this.m_grpPluginDesc); this.Controls.Add(this.m_lblSeparator); this.Controls.Add(this.m_lvPlugins); this.Controls.Add(this.m_btnClose); this.Controls.Add(this.m_bannerImage); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "PluginsForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Plugins"; this.Load += new System.EventHandler(this.OnFormLoad); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OnFormClosed); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing); ((System.ComponentModel.ISupportInitialize)(this.m_bannerImage)).EndInit(); this.m_grpPluginDesc.ResumeLayout(false); this.m_grpCache.ResumeLayout(false); this.m_grpCache.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.PictureBox m_bannerImage; private System.Windows.Forms.Button m_btnClose; private KeePass.UI.CustomListViewEx m_lvPlugins; private System.Windows.Forms.Label m_lblSeparator; private System.Windows.Forms.GroupBox m_grpPluginDesc; private System.Windows.Forms.Label m_lblSelectedPluginDesc; private System.Windows.Forms.LinkLabel m_linkPlugins; private System.Windows.Forms.GroupBox m_grpCache; private System.Windows.Forms.Button m_btnClearCache; private System.Windows.Forms.Label m_lblCacheSize; private System.Windows.Forms.CheckBox m_cbCacheDeleteOld; } }keepass2-2.25/KeePass/Forms/ImportMethodForm.resx0000664000175000017500000001375412163553174021717 0ustar jtaylorjtaylor 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 Behaves like 'Overwrite if newer', but also applies deletions of the database to be imported. When an entry has been deleted in the database to be imported, it will also be deleted in the currently opened database. keepass2-2.25/KeePass/Forms/UpdateCheckForm.cs0000664000175000017500000001403012261553106021066 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePass.Native; using KeePass.Resources; using KeePass.UI; using KeePass.Util; using KeePassLib; using KeePassLib.Utility; namespace KeePass.Forms { public partial class UpdateCheckForm : Form, IGwmWindow { private List m_lInfo = null; private ImageList m_ilIcons = null; public bool CanCloseWithoutDataLoss { get { return true; } } public void InitEx(List lInfo, bool bModal) { m_lInfo = lInfo; if(!bModal) this.ShowInTaskbar = true; } public UpdateCheckForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } private void OnFormLoad(object sender, EventArgs e) { if(m_lInfo == null) throw new InvalidOperationException(); GlobalWindowManager.AddWindow(this, this); BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_WWW, KPRes.UpdateCheck, KPRes.UpdateCheckResults); this.Icon = Properties.Resources.KeePass; this.Text = KPRes.UpdateCheck + " - " + PwDefs.ShortProductName; UIUtil.SetExplorerTheme(m_lvInfo, true); int nWidth = m_lvInfo.ClientRectangle.Width - UIUtil.GetVScrollBarWidth(); m_lvInfo.Columns.Add(KPRes.Component, (nWidth * 2) / 6); m_lvInfo.Columns.Add(KPRes.Status, (nWidth * 2) / 6); m_lvInfo.Columns.Add(KPRes.Installed, nWidth / 6); m_lvInfo.Columns.Add(KPRes.Available, nWidth / 6); List lImages = new List(); lImages.Add(Properties.Resources.B16x16_Help); lImages.Add(Properties.Resources.B16x16_Apply); lImages.Add(Properties.Resources.B16x16_Redo); lImages.Add(Properties.Resources.B16x16_History); lImages.Add(Properties.Resources.B16x16_Error); m_ilIcons = UIUtil.BuildImageListUnscaled(lImages, 16, 16); m_lvInfo.SmallImageList = m_ilIcons; string strCat = string.Empty; ListViewGroup lvg = null; foreach(UpdateComponentInfo uc in m_lInfo) { if(uc.Category != strCat) { lvg = new ListViewGroup(uc.Category); m_lvInfo.Groups.Add(lvg); strCat = uc.Category; } ListViewItem lvi = new ListViewItem(uc.Name); string strStatus = KPRes.Unknown + "."; if(uc.Status == UpdateComponentStatus.UpToDate) { strStatus = KPRes.UpToDate + "."; lvi.ImageIndex = 1; } else if(uc.Status == UpdateComponentStatus.NewVerAvailable) { strStatus = KPRes.NewVersionAvailable + "!"; lvi.ImageIndex = 2; } else if(uc.Status == UpdateComponentStatus.PreRelease) { strStatus = KPRes.PreReleaseVersion + "."; lvi.ImageIndex = 3; } else if(uc.Status == UpdateComponentStatus.DownloadFailed) { strStatus = KPRes.UpdateCheckFailedNoDl; lvi.ImageIndex = 4; } else lvi.ImageIndex = 0; lvi.SubItems.Add(strStatus); lvi.SubItems.Add(StrUtil.VersionToString(uc.VerInstalled, true)); if((uc.Status == UpdateComponentStatus.UpToDate) || (uc.Status == UpdateComponentStatus.NewVerAvailable) || (uc.Status == UpdateComponentStatus.PreRelease)) lvi.SubItems.Add(StrUtil.VersionToString(uc.VerAvailable, true)); else lvi.SubItems.Add("?"); if(lvg != null) lvi.Group = lvg; m_lvInfo.Items.Add(lvi); } } private void CleanUpEx() { if(m_ilIcons != null) { m_lvInfo.SmallImageList = null; // Detach event handlers m_ilIcons.Dispose(); m_ilIcons = null; } } private void OnFormClosed(object sender, FormClosedEventArgs e) { CleanUpEx(); GlobalWindowManager.RemoveWindow(this); } private void OnLinkWeb(object sender, LinkLabelLinkClickedEventArgs e) { OpenUrl(PwDefs.HomepageUrl); } private void OnLinkPlugins(object sender, LinkLabelLinkClickedEventArgs e) { OpenUrl(PwDefs.PluginsUrl); } private void OpenUrl(string strUrl) { if(!KeePassLib.Native.NativeLib.IsUnix()) { // Process.Start has a considerable delay when opening URLs // here (different thread, etc.), therefore try the native // ShellExecute first (which doesn't have any delay) try { IntPtr h = NativeMethods.ShellExecute(this.Handle, null, strUrl, null, null, NativeMethods.SW_SHOW); long l = h.ToInt64(); if((l < 0) || (l > 32)) return; else { Debug.Assert(false); } } catch(Exception) { Debug.Assert(false); } } try { Process.Start(strUrl); } catch(Exception) { Debug.Assert(false); } } private void OnInfoItemActivate(object sender, EventArgs e) { ListView.SelectedListViewItemCollection lvsic = m_lvInfo.SelectedItems; if((lvsic == null) || (lvsic.Count != 1)) { Debug.Assert(false); return; } ListViewItem lvi = lvsic[0]; if((lvi == null) || (lvi.Group == null)) { Debug.Assert(false); return; } string strGroup = (lvi.Group.Header ?? string.Empty); if(strGroup == PwDefs.ShortProductName) OpenUrl(PwDefs.HomepageUrl); else if(strGroup == KPRes.Plugins) OpenUrl(PwDefs.PluginsUrl); else { Debug.Assert(false); } } } } keepass2-2.25/KeePass/Forms/IconPickerForm.cs0000664000175000017500000003164312261553106020745 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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.Drawing.Imaging; using System.Text; using System.Windows.Forms; using System.Diagnostics; using System.IO; using KeePass.App; using KeePass.Resources; using KeePass.UI; using KeePassLib; using KeePassLib.Utility; namespace KeePass.Forms { public partial class IconPickerForm : Form { private ImageList m_ilIcons = null; private uint m_uNumberOfStandardIcons = 0; private PwDatabase m_pwDatabase = null; private uint m_uDefaultIcon = 0; private PwUuid m_pwDefaultCustomIcon = PwUuid.Zero; private uint m_uChosenImageID = 0; private PwUuid m_pwChosenCustomImageUuid = PwUuid.Zero; public uint ChosenIconId { get { return m_uChosenImageID; } } public PwUuid ChosenCustomIconUuid { get { return m_pwChosenCustomImageUuid; } } public IconPickerForm() { InitializeComponent(); Program.Translation.ApplyTo(this); } public void InitEx(ImageList ilIcons, uint uNumberOfStandardIcons, PwDatabase pwDatabase, uint uDefaultIcon, PwUuid pwCustomIconUuid) { m_ilIcons = ilIcons; m_uNumberOfStandardIcons = uNumberOfStandardIcons; m_pwDatabase = pwDatabase; m_uDefaultIcon = uDefaultIcon; m_pwDefaultCustomIcon = pwCustomIconUuid; } private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_ilIcons != null); if(m_ilIcons == null) throw new InvalidOperationException(); Debug.Assert(m_pwDatabase != null); if(m_pwDatabase == null) throw new InvalidOperationException(); GlobalWindowManager.AddWindow(this); this.Icon = Properties.Resources.KeePass; FontUtil.AssignDefaultBold(m_radioStandard); FontUtil.AssignDefaultBold(m_radioCustom); m_lvIcons.SmallImageList = m_ilIcons; for(uint i = 0; i < m_uNumberOfStandardIcons; ++i) m_lvIcons.Items.Add(i.ToString(), (int)i); int iFoundCustom = RecreateCustomIconList(false); if(!m_pwDefaultCustomIcon.Equals(PwUuid.Zero) && (iFoundCustom >= 0)) { m_radioCustom.Checked = true; m_lvCustomIcons.Items[iFoundCustom].Selected = true; m_lvCustomIcons.EnsureVisible(iFoundCustom); UIUtil.SetFocus(m_lvCustomIcons, this); } else if(m_uDefaultIcon < m_uNumberOfStandardIcons) { m_radioStandard.Checked = true; m_lvIcons.Items[(int)m_uDefaultIcon].Selected = true; m_lvIcons.EnsureVisible((int)m_uDefaultIcon); UIUtil.SetFocus(m_lvIcons, this); } else { Debug.Assert(false); m_radioStandard.Checked = true; } EnableControlsEx(); } private void EnableControlsEx() { ListView.SelectedIndexCollection lvsic = m_lvCustomIcons.SelectedIndices; if(m_radioStandard.Checked && (m_lvIcons.SelectedIndices.Count == 1)) m_btnOK.Enabled = true; else if(m_radioCustom.Checked && (lvsic.Count == 1)) m_btnOK.Enabled = true; else m_btnOK.Enabled = false; m_btnCustomRemove.Enabled = (lvsic.Count >= 1); m_btnCustomExport.Enabled = (lvsic.Count >= 1); // if(m_bBlockCancel) // { // m_btnCancel.Enabled = false; // if(this.ControlBox) this.ControlBox = false; // } } /// /// Recreate the custom icons list view. /// /// Index of the previous custom icon, if specified. private int RecreateCustomIconList(bool bSelectLastIcon) { m_lvCustomIcons.Items.Clear(); ImageList ilCustom = UIUtil.BuildImageList(m_pwDatabase.CustomIcons, 16, 16); m_lvCustomIcons.SmallImageList = ilCustom; int j = 0, iFoundCustom = -1; foreach(PwCustomIcon pwci in m_pwDatabase.CustomIcons) { ListViewItem lvi = m_lvCustomIcons.Items.Add(j.ToString(), j); lvi.Tag = pwci.Uuid; if(pwci.Uuid.Equals(m_pwDefaultCustomIcon)) iFoundCustom = j; ++j; } if(bSelectLastIcon && (m_lvCustomIcons.Items.Count > 0)) { m_lvCustomIcons.Items[m_lvCustomIcons.Items.Count - 1].Selected = true; m_lvCustomIcons.EnsureVisible(m_lvCustomIcons.Items.Count - 1); UIUtil.SetFocus(m_lvCustomIcons, this); } return iFoundCustom; } private void OnBtnOK(object sender, EventArgs e) { if(!SaveChosenIcon()) { this.DialogResult = DialogResult.None; MessageService.ShowWarning(KPRes.PickIcon); } } private bool SaveChosenIcon() { if(m_radioStandard.Checked) { ListView.SelectedIndexCollection lvsi = m_lvIcons.SelectedIndices; if(lvsi.Count != 1) return false; m_uChosenImageID = (uint)lvsi[0]; } else // Custom icon { ListView.SelectedListViewItemCollection lvsic = m_lvCustomIcons.SelectedItems; if(lvsic.Count != 1) return false; m_pwChosenCustomImageUuid = (PwUuid)lvsic[0].Tag; } return true; } private void OnIconsItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { m_radioCustom.Checked = false; m_radioStandard.Checked = true; EnableControlsEx(); } private void OnCustomIconsItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { m_radioStandard.Checked = false; m_radioCustom.Checked = true; EnableControlsEx(); } private void CleanUpEx() { // Detach event handlers m_lvIcons.SmallImageList = null; m_lvCustomIcons.SmallImageList = null; } private void OnFormClosed(object sender, FormClosedEventArgs e) { CleanUpEx(); GlobalWindowManager.RemoveWindow(this); } private void OnStandardRadioCheckedChanged(object sender, EventArgs e) { EnableControlsEx(); } private void OnBtnCustomAdd(object sender, EventArgs e) { string strAllSupportedFilter = KPRes.AllSupportedFiles + @" (*.bmp; *.emf; *.gif; *.ico; *.jpg; *.jpe; *.jpeg; *.jfif; *.jfi; *.jif; *.png; *.tif; *.tiff; *.wmf)" + @"|*.bmp;*.emf;*.gif;*.ico;*.jpg;*.jpe;*.jpeg;*.jfif;*.jfi;*.jif;*.png;*.tif;*.tiff;*.wmf"; StringBuilder sbFilter = new StringBuilder(); sbFilter.Append(strAllSupportedFilter); AddFileType(sbFilter, "*.bmp", "Windows Bitmap (*.bmp)"); AddFileType(sbFilter, "*.emf", "Windows Enhanced Metafile (*.emf)"); AddFileType(sbFilter, "*.gif", "Graphics Interchange Format (*.gif)"); AddFileType(sbFilter, "*.ico", "Windows Icon (*.ico)"); AddFileType(sbFilter, "*.jpg;*.jpe;*.jpeg;*.jfif;*.jfi;*.jif", "JPEG (*.jpg; *.jpe; *.jpeg; *.jfif; *.jfi; *.jif)"); AddFileType(sbFilter, "*.png", "Portable Network Graphics (*.png)"); AddFileType(sbFilter, "*.tif;*.tiff", "Tagged Image File Format (*.tif; *.tiff)"); AddFileType(sbFilter, "*.wmf", "Windows Metafile (*.wmf)"); sbFilter.Append(@"|" + KPRes.AllFiles + @" (*.*)|*.*"); OpenFileDialogEx ofd = UIUtil.CreateOpenFileDialog(KPRes.ImportFileTitle, sbFilter.ToString(), 1, null, true, AppDefs.FileDialogContext.Import); if(ofd.ShowDialog() == DialogResult.OK) { bool bSelectLastIcon = false; foreach(string strFile in ofd.FileNames) { bool bUnsupportedFormat = false; try { if(!File.Exists(strFile)) throw new FileNotFoundException(); // Image img = Image.FromFile(strFile); // Image img = Image.FromFile(strFile, false); // Image img = Bitmap.FromFile(strFile); // Bitmap img = new Bitmap(strFile); // Image img = Image.FromFile(strFile); byte[] pb = File.ReadAllBytes(strFile); // MemoryStream msSource = new MemoryStream(pb, false); // Image img = Image.FromStream(msSource); // msSource.Close(); Image img = GfxUtil.LoadImage(pb); MemoryStream ms = new MemoryStream(); if((img.Width == 16) && (img.Height == 16)) img.Save(ms, ImageFormat.Png); else { // Image imgNew = new Bitmap(img, new Size(16, 16)); Bitmap imgSc = UIUtil.CreateScaledImage(img, 16, 16); imgSc.Save(ms, ImageFormat.Png); imgSc.Dispose(); } img.Dispose(); PwCustomIcon pwci = new PwCustomIcon(new PwUuid(true), ms.ToArray()); m_pwDatabase.CustomIcons.Add(pwci); ms.Close(); m_pwDatabase.UINeedsIconUpdate = true; m_pwDatabase.Modified = true; bSelectLastIcon = true; } catch(ArgumentException) { bUnsupportedFormat = true; } catch(System.Runtime.InteropServices.ExternalException) { bUnsupportedFormat = true; } catch(Exception exImg) { MessageService.ShowWarning(strFile, exImg); } if(bUnsupportedFormat) MessageService.ShowWarning(strFile, KPRes.ImageFormatFeatureUnsupported); } RecreateCustomIconList(bSelectLastIcon); } EnableControlsEx(); } private static void AddFileType(StringBuilder sbBuffer, string strEnding, string strName) { if(sbBuffer.Length > 0) sbBuffer.Append('|'); sbBuffer.Append(strName); sbBuffer.Append('|'); sbBuffer.Append(strEnding); } private void OnBtnCustomRemove(object sender, EventArgs e) { ListView.SelectedListViewItemCollection lvsicSel = m_lvCustomIcons.SelectedItems; List vUuidsToDelete = new List(); foreach(ListViewItem lvi in lvsicSel) { PwUuid uuidIcon = lvi.Tag as PwUuid; Debug.Assert(uuidIcon != null); if(uuidIcon != null) vUuidsToDelete.Add(uuidIcon); } m_pwDatabase.DeleteCustomIcons(vUuidsToDelete); if(vUuidsToDelete.Count > 0) { m_pwDatabase.UINeedsIconUpdate = true; m_pwDatabase.Modified = true; } RecreateCustomIconList(false); EnableControlsEx(); } private void OnIconsItemActivate(object sender, EventArgs e) { OnIconsItemSelectionChanged(sender, null); if(!SaveChosenIcon()) return; this.DialogResult = DialogResult.OK; } private void OnCustomIconsItemActivate(object sender, EventArgs e) { OnCustomIconsItemSelectionChanged(sender, null); if(!SaveChosenIcon()) return; this.DialogResult = DialogResult.OK; } private void OnBtnCustomSave(object sender, EventArgs e) { ListView.SelectedListViewItemCollection lvsic = m_lvCustomIcons.SelectedItems; if((lvsic == null) || (lvsic.Count == 0)) return; if(lvsic.Count == 1) { StringBuilder sbFilter = new StringBuilder(); AddFileType(sbFilter, "*.png", "Portable Network Graphics (*.png)"); // AddFileType(sbFilter, "*.ico", "Windows Icon (*.ico)"); sbFilter.Append(@"|" + KPRes.AllFiles + @" (*.*)|*.*"); SaveFileDialogEx sfd = UIUtil.CreateSaveFileDialog(KPRes.ExportFileTitle, KPRes.Export + ".png", sbFilter.ToString(), 1, null, AppDefs.FileDialogContext.Export); if(sfd.ShowDialog() == DialogResult.OK) SaveImageFile(lvsic[0], sfd.FileName); } else // lvsic.Count >= 2 { FolderBrowserDialog fbd = UIUtil.CreateFolderBrowserDialog(KPRes.ExportToPrompt); if(fbd.ShowDialog() == DialogResult.OK) { string strDir = UrlUtil.EnsureTerminatingSeparator( fbd.SelectedPath, false); int nExportIndex = 0; foreach(ListViewItem lvi in lvsic) { try { string strFile; do { strFile = strDir + KPRes.Export + nExportIndex.ToString() + ".png"; ++nExportIndex; } while(File.Exists(strFile)); SaveImageFile(lvi, strFile); } catch(Exception ex) { MessageService.ShowWarning(ex.Message); } } } } } private void SaveImageFile(ListViewItem lvi, string strFile) { if((lvi == null) || string.IsNullOrEmpty(strFile)) { Debug.Assert(false); return; } try { PwUuid pwUuid = (lvi.Tag as PwUuid); if(pwUuid == null) { Debug.Assert(false); return; } Image img = m_pwDatabase.GetCustomIcon(pwUuid); if(img == null) { Debug.Assert(false); return; } // string strExt = UrlUtil.GetExtension(strFile); ImageFormat fmt = ImageFormat.Png; // if(strExt.Equals("ico", StrUtil.CaseIgnoreCmp)) fmt = ImageFormat.Icon; img.Save(strFile, fmt); } catch(Exception ex) { MessageService.ShowWarning(ex.Message); } } } } keepass2-2.25/KeePass/Forms/DataViewerForm.resx0000664000175000017500000001410512267251736021332 0ustar jtaylorjtaylor 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 126, 17 17, 17 keepass2-2.25/KeePass/Forms/CharPickerForm.cs0000664000175000017500000002170612261553106020731 0ustar jtaylorjtaylor/* KeePass Password Safe - The Open-Source Password Manager Copyright (C) 2003-2014 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 KeePass.App; using KeePass.App.Configuration; using KeePass.Native; using KeePass.Resources; using KeePass.UI; using KeePassLib; using KeePassLib.Security; namespace KeePass.Forms { public partial class CharPickerForm : Form { private ProtectedString m_psWord = null; private ProtectedString m_psSelected = ProtectedString.Empty; private SecureEdit m_secWord = new SecureEdit(); private List