public void Release() { Debug.Assert(!m_bInitializing); if (m_tbPassword == null) { return; } m_secPassword.Detach(); m_secRepeat.Detach(); m_cbHide.CheckedChanged -= this.OnHideCheckedChanged; m_tbPassword = null; m_cbHide = null; m_lblRepeat = null; m_tbRepeat = null; m_lblQualityPrompt = null; m_pbQuality = null; m_lblQualityInfo = null; m_ttHint = null; m_fParent = null; m_secPassword = null; m_secRepeat = null; }
public bool ContentsEqualTo(SecureEdit secOther) { Debug.Assert(secOther != null); if (secOther == null) { return(false); } byte[] pbThis = this.ToUtf8(); byte[] pbOther = secOther.ToUtf8(); bool bEqual = true; if (pbThis.Length != pbOther.Length) { bEqual = false; } else { for (int i = 0; i < pbThis.Length; ++i) { if (pbThis[i] != pbOther[i]) { bEqual = false; break; } } } Array.Clear(pbThis, 0, pbThis.Length); Array.Clear(pbOther, 0, pbOther.Length); return(bEqual); }
public PasswordDialog() { InitializeComponent(); if (Type.GetType("Mono.Runtime") == null) Icon = Properties.Resources.KeeAgent_icon; else Icon = Properties.Resources.KeeAgent_icon_mono; mSecureEdit = new SecureEdit(); mSecureEdit.Attach(passwordTextBox, null, true); }
public bool ContentsEqualTo(SecureEdit secOther) { Debug.Assert(secOther != null); if (secOther == null) { return(false); } byte[] pbThis = ToUtf8(); byte[] pbOther = secOther.ToUtf8(); bool bEqual = MemUtil.ArraysEqual(pbThis, pbOther); MemUtil.ZeroByteArray(pbThis); MemUtil.ZeroByteArray(pbOther); return(bEqual); }
public void Release() { Debug.Assert(!m_bInitializing); if(m_tbPassword == null) return; m_secPassword.Detach(); m_secRepeat.Detach(); m_cbHide.CheckedChanged -= this.OnHideCheckedChanged; m_tbPassword = null; m_cbHide = null; m_lblRepeat = null; m_tbRepeat = null; m_lblQualityPrompt = null; m_pbQuality = null; m_lblQualityBits = null; m_fParent = null; m_secPassword = null; m_secRepeat = null; }
public void Attach(TextBox tbPassword, CheckBox cbHide, Label lblRepeat, TextBox tbRepeat, Label lblQualityPrompt, QualityProgressBar pbQuality, Label lblQualityBits, Form fParent, bool bInitialHide, bool bSecureDesktopMode) { if(tbPassword == null) throw new ArgumentNullException("tbPassword"); if(cbHide == null) throw new ArgumentNullException("cbHide"); if(lblRepeat == null) throw new ArgumentNullException("lblRepeat"); if(tbRepeat == null) throw new ArgumentNullException("tbRepeat"); if(lblQualityPrompt == null) throw new ArgumentNullException("lblQualityPrompt"); if(pbQuality == null) throw new ArgumentNullException("pbQuality"); if(lblQualityBits == null) throw new ArgumentNullException("lblQualityBits"); if(fParent == null) throw new ArgumentNullException("fParent"); Release(); m_bInitializing = true; m_tbPassword = tbPassword; m_cbHide = cbHide; m_lblRepeat = lblRepeat; m_tbRepeat = tbRepeat; m_lblQualityPrompt = lblQualityPrompt; m_pbQuality = pbQuality; m_lblQualityBits = lblQualityBits; m_fParent = fParent; m_secPassword = new SecureEdit(); m_secPassword.SecureDesktopMode = bSecureDesktopMode; m_secPassword.Attach(m_tbPassword, this.OnPasswordTextChanged, bInitialHide); m_secRepeat = new SecureEdit(); m_secRepeat.SecureDesktopMode = bSecureDesktopMode; m_secRepeat.Attach(m_tbRepeat, this.OnRepeatTextChanged, bInitialHide); m_cbHide.Checked = bInitialHide; m_cbHide.CheckedChanged += this.OnHideCheckedChanged; Debug.Assert(m_pbQuality.Minimum == 0); Debug.Assert(m_pbQuality.Maximum == 100); m_bInitializing = false; UpdateUI(); }
public void Attach(TextBox tbPassword, CheckBox cbHide, Label lblRepeat, TextBox tbRepeat, Label lblQualityPrompt, QualityProgressBar pbQuality, Label lblQualityInfo, ToolTip ttHint, Form fParent, bool bInitialHide, bool bSecureDesktopMode) { if (tbPassword == null) { throw new ArgumentNullException("tbPassword"); } if (cbHide == null) { throw new ArgumentNullException("cbHide"); } if (lblRepeat == null) { throw new ArgumentNullException("lblRepeat"); } if (tbRepeat == null) { throw new ArgumentNullException("tbRepeat"); } if (lblQualityPrompt == null) { throw new ArgumentNullException("lblQualityPrompt"); } if (pbQuality == null) { throw new ArgumentNullException("pbQuality"); } if (lblQualityInfo == null) { throw new ArgumentNullException("lblQualityInfo"); } // ttHint may be null if (fParent == null) { throw new ArgumentNullException("fParent"); } Release(); m_bInitializing = true; m_tbPassword = tbPassword; m_cbHide = cbHide; m_lblRepeat = lblRepeat; m_tbRepeat = tbRepeat; m_lblQualityPrompt = lblQualityPrompt; m_pbQuality = pbQuality; m_lblQualityInfo = lblQualityInfo; m_ttHint = ttHint; m_fParent = fParent; m_secPassword = new SecureEdit(); m_secPassword.SecureDesktopMode = bSecureDesktopMode; m_secPassword.Attach(m_tbPassword, this.OnPasswordTextChanged, bInitialHide); m_secRepeat = new SecureEdit(); m_secRepeat.SecureDesktopMode = bSecureDesktopMode; m_secRepeat.Attach(m_tbRepeat, this.OnRepeatTextChanged, bInitialHide); ConfigureHideButton(m_cbHide, m_ttHint); m_cbHide.Checked = bInitialHide; m_cbHide.CheckedChanged += this.OnHideCheckedChanged; Debug.Assert(m_pbQuality.Minimum == 0); Debug.Assert(m_pbQuality.Maximum == 100); m_bInitializing = false; UpdateUI(); }
private bool InitializeChildView(TabPage page, String uuid) { if (et_to_label != null) { add_child_items_to_tab(page); return true; } init_pwgen_button(); et_to_label = new Dictionary<EntryTemplate, Label>(); et_to_control = new Dictionary<EntryTemplate, Control>(); et_to_secure_edit = new Dictionary<EntryTemplate, SecureEdit>(); et_to_control2 = new Dictionary<EntryTemplate, Control>(); SecureEdit entry_pass = null; SecureEdit entry_pass_confirm = null; int control_offset_y = 10; PwUuid par_uuid = new PwUuid(KeePassLib.Utility.MemUtil.HexStringToByteArray(uuid)); PwEntry par_template = m_host.Database.RootGroup.FindEntry(par_uuid, true); if (par_template == null) return false; if (par_template.Strings.Get("_etm_template") == null) return false; List<EntryTemplate> cur = parse_entry(par_template.Strings); const int LABEL_WIDTH = 130; const int LEFT_CONTROL_OFFSET = LABEL_WIDTH + 5; int CONTROL_WIDTH = TAB_WIDTH - LABEL_WIDTH - 55; foreach (EntryTemplate t in cur) { Label label = new Label(); label.Top = control_offset_y; label.Left = 0; label.Text = t.title + ":"; label.AutoSize = false; label.Width = LABEL_WIDTH; label.AutoEllipsis = true; label.TextAlign = ContentAlignment.MiddleRight; FontUtil.AssignDefaultBold(label); et_to_label[t] = label; if (t.type == "Divider") { label.Font = new Font(label.Font.FontFamily, label.Font.Size * 1.1f, FontStyle.Bold | FontStyle.Underline); label.TextAlign = ContentAlignment.BottomLeft; label.Width = CONTROL_WIDTH + LABEL_WIDTH; label.Text = t.title;//remove : et_to_control[t] = null; } else if (t.type == "Checkbox") { CheckBox checkbox = new CheckBox(); checkbox.Top = control_offset_y; checkbox.Left = LEFT_CONTROL_OFFSET; et_to_control[t] = checkbox; } else if (t.type == "Listbox"){ ComboBox combobox = new ComboBox(); combobox.Top = control_offset_y; combobox.Left = LEFT_CONTROL_OFFSET; et_to_control[t] = combobox; if (!String.IsNullOrEmpty(t.options)){ String[] opts = t.options.Split(new[]{','}, StringSplitOptions.RemoveEmptyEntries); foreach (String opt in opts) combobox.Items.Add(opt.Trim()); } } else if (t.type == "Date" || t.type == "Time" || t.type == "Date Time") { DateTimePicker picker = new DateTimePicker(); picker.Top = control_offset_y; picker.Left = LEFT_CONTROL_OFFSET; picker.CustomFormat = ""; picker.Width = CONTROL_WIDTH; picker.Format = DateTimePickerFormat.Custom; if (t.type == "Date" || t.type == "Date Time") picker.CustomFormat = System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern; if (t.type == "Date Time") picker.CustomFormat += " "; if (t.type == "Time" || t.type == "Date Time") picker.CustomFormat += System.Globalization.DateTimeFormatInfo.CurrentInfo.LongTimePattern; if (t.fieldName == "@exp_date") picker.ShowCheckBox = true; et_to_control[t] = picker; } else if (t.type == "Inline" || t.type == "Protected Inline" || t.type == "Inline URL") { TextBox box = new TextBox(); box.Top = control_offset_y; box.Left = LEFT_CONTROL_OFFSET; box.Width = t.type == "Inline URL" ? CONTROL_WIDTH-30 : CONTROL_WIDTH; int lines = LinesFromOption(t.options); if (t.type == "Inline URL") lines = 1; if (lines > 1) { box.Multiline = true; box.AcceptsReturn = true; box.Height = 13 * lines + 10; box.ScrollBars = ScrollBars.Both; control_offset_y += 13 * (lines-1); } et_to_control[t] = box; if (t.type == "Protected Inline") { SecureEdit sedit = new SecureEdit(); sedit.Attach(box, null, true); et_to_secure_edit[t] = sedit; if (t.fieldName != "@confirm") { CheckBox chk = new CheckBox(); chk.Appearance = Appearance.Button; chk.Image = Resources.Resources.B17x05_3BlackDots; chk.Location = new Point(box.Left + box.Width + 10, control_offset_y); chk.Size = new Size(32, 23); chk.TextAlign = ContentAlignment.MiddleCenter; chk.UseVisualStyleBackColor = true; chk.Tag = t; chk.Checked = true; chk.CheckedChanged += chk_CheckedChanged; et_to_control2[t] = chk; } else { et_to_control2[t] = m_btnGenPw; et_to_control2[t].Location = new Point(box.Left + box.Width + 10, control_offset_y); current_password_confirm_field = sedit; current_password_confirm_field_txt = box; entry_pass_confirm = sedit; } if (t.fieldName == PwDefs.PasswordField) { entry_pass = current_password_field = sedit; } }else if (t.type == "Inline URL") { var link= new LinkLabel {Text = "Open"}; link.LinkClicked += (sender, args) => WinUtil.OpenUrl(box.Text??"", form.EntryRef); link.Location = new Point(box.Left + box.Width + 10, control_offset_y); link.Width = 50; et_to_control2[t] = link; } } else if (t.type == "Popout" || t.type == "Protected Popout") { Button btn = new Button(); btn.Text = "View/Edit"; if (t.type == "Protected Popout") btn.Text = "View/Edit Secure"; btn.Tag = t; btn.Width = CONTROL_WIDTH; btn.Left = LEFT_CONTROL_OFFSET; //btn.Height = 20; btn.Top = control_offset_y; btn.Click += btn_popout_Click; et_to_control[t] = btn; } control_offset_y += 30; } client_remove_button = new Button(); client_remove_button.Text = "Remove As Template Child"; client_remove_button.Width = CONTROL_WIDTH; client_remove_button.Left = LEFT_CONTROL_OFFSET; //client_remove_button.Height = 20; client_remove_button.Top = control_offset_y; client_remove_button.Click += client_remove_button_Click; if (entry_pass_confirm != null && entry_pass != null){ } add_child_items_to_tab(page); return true; }
public bool ContentsEqualTo(SecureEdit secOther) { Debug.Assert(secOther != null); if(secOther == null) return false; byte[] pbThis = ToUtf8(); byte[] pbOther = secOther.ToUtf8(); bool bEqual = MemUtil.ArraysEqual(pbThis, pbOther); MemUtil.ZeroByteArray(pbThis); MemUtil.ZeroByteArray(pbOther); return bEqual; }
public bool ContentsEqualTo(SecureEdit secOther) { Debug.Assert(secOther != null); if(secOther == null) return false; byte[] pbThis = this.ToUtf8(); byte[] pbOther = secOther.ToUtf8(); bool bEqual = true; if(pbThis.Length != pbOther.Length) bEqual = false; else { for(int i = 0; i < pbThis.Length; ++i) { if(pbThis[i] != pbOther[i]) { bEqual = false; break; } } } Array.Clear(pbThis, 0, pbThis.Length); Array.Clear(pbOther, 0, pbOther.Length); return bEqual; }
private CompositeKey CreateCompositeKey(string masterKey) { CompositeKey m_pKey = new CompositeKey (); SecureEdit se = new SecureEdit (masterKey); byte[] pb = se.ToUtf8 (); m_pKey.AddUserKey (new KcpPassword (pb)); Array.Clear (pb, 0, pb.Length); return m_pKey; }