Beispiel #1
0
        /// <summary>
        /// Unlocks the database prompted to unlock on the KeyPromptForm
        /// </summary>
        /// <param name="ioInfo">IOConnectionInfo that represents the database.</param>
        /// <param name="keyPromptForm">KeyPromptForm to unlock the database from.</param>
        internal async static void UnlockDatabase(IOConnectionInfo ioInfo, KeyPromptForm keyPromptForm)
        {
            // Only one try is allowed
            if (WinHelloUnlockExt.tries < 1)
            {
                if (KeePass.Program.Config.Security.MasterKeyOnSecureDesktop)
                {
                    WinHelloUnlockExt.secureChaged = true;
                    WinHelloUnlockExt.isMonitoring = true;
                    var _ = Task.Factory.StartNew(() => CloseWarning());
                    KeePass.Program.Config.Security.MasterKeyOnSecureDesktop = false;

                    UWPLibrary.Unlock(keyPromptForm, new CompositeKey());
                }
                else
                {
                    await UWPLibrary.UnlockDatabase(ioInfo, keyPromptForm);

                    ++WinHelloUnlockExt.tries;

                    if (WinHelloUnlockExt.secureChaged)
                    {
                        KeePass.Program.Config.Security.MasterKeyOnSecureDesktop = true;
                        WinHelloUnlockExt.secureChaged = false;
                    }
                }
            }
            else
            {
                keyPromptForm.Visible = true;
                keyPromptForm.Opacity = 1;
            }

            WinHelloUnlockExt.opened = true;
        }