/// <summary> /// Creates the data for WinHelloUnlock to work. /// 1. A Key Credential to sign a cryptographic key. /// 2. A Password vault to save the data into /// 3. A Password Credential in which to save the encrypted data (using the signed cryptographic key). /// </summary> /// <param name="dbPath">Database path. This is the identity of the database, if Database is moved or renamed, /// WinHelloUnlock will not work and new data needs to be created. /// </param> /// <returns>True if all the data was saved successfully.</returns> internal static async Task <bool> CreateHelloData(string dbPath) { bool isHelloAvailable = await UWPLibrary.IsHelloAvailable(); if (isHelloAvailable) { KeyCredentialCreationOption optionNew = KeyCredentialCreationOption.ReplaceExisting; KeyCredentialRetrievalResult retrievalResult = await UWPLibrary.CreateCredential(dbPath, optionNew); if (retrievalResult.Status == KeyCredentialStatus.Success) { KeyList keyList = Library.GetKeys(WinHelloUnlockExt.database); string resultSave = await UWPLibrary.SaveKeys(dbPath, keyList, retrievalResult); if (resultSave == "Success") { MessageService.ShowInfo("Database Keys saved successfuly"); UWPLibrary.ck = KeePass.Program.MainForm.ActiveDatabase.MasterKey; return(true); } else { if (resultSave.Substring(0, 20) == "Value cannot be null") { MessageService.ShowWarning("Error saving the composite key: MasterKey was null." + " Verify that \"Remember master password (in encrypted form) of a database while it is open\" option under Tools/Options/Security" + " is enabled, then lock and unlock the database."); } else { MessageService.ShowWarning("Error saving the composite key: " + resultSave); } } } else { WinHelloErrors(retrievalResult.Status, "Error creating the credential: "); } } else { MessageService.ShowWarning("Windows Hello is NOT Available"); } return(false); }
/// <summary> /// Creates the data for WinHelloUnlock to work. /// 1. A Key Credential to sign a cryptographic key. /// 2. A Password vault to save the data into /// 3. A Password Credential in which to save the encrypted data (using the signed cryptographic key). /// </summary> /// <param name="dbPath">Database path. This is the identity of the database, if Database is moved or renamed, /// WinHelloUnlock will not work and new data needs to be created. /// </param> /// <returns>True if all the data was saved successfully.</returns> internal static async Task <bool> CreateHelloData(string dbPath) { bool isHelloAvailable = await UWPLibrary.IsHelloAvailable(); if (isHelloAvailable) { KeyCredentialCreationOption optionNew = KeyCredentialCreationOption.ReplaceExisting; KeyCredentialRetrievalResult retrievalResult = await UWPLibrary.CreateCredential(dbPath, optionNew); if (retrievalResult.Status == KeyCredentialStatus.Success) { KeyList keyList = Library.GetKeys(WinHelloUnlockExt.database); string resultSave = await UWPLibrary.SaveKeys(dbPath, keyList, retrievalResult); if (resultSave == "Success") { MessageService.ShowInfo("Database Keys saved successfuly"); UWPLibrary.ck = KeePass.Program.MainForm.ActiveDatabase.MasterKey; return(true); } else { MessageService.ShowWarning("Error saving the composite key: " + resultSave); } } else { WinHelloErrors(retrievalResult.Status, "Error creating the credential: "); } } else { MessageService.ShowWarning("Windows Hello is NOT Available"); } return(false); }