summaryrefslogtreecommitdiff
path: root/include/svl/PasswordHelper.hxx
diff options
context:
space:
mode:
authorSarper Akdemir <sarper.akdemir.extern@allotropia.de>2023-11-08 07:36:52 +0300
committerSarper Akdemir <sarper.akdemir.extern@allotropia.de>2023-11-15 19:48:38 +0100
commitcdcff8c34144e883eca9dc6e1a85968ed34909c2 (patch)
tree3e976e02a3b3b43aa7962850b07efad63f5f25b1 /include/svl/PasswordHelper.hxx
parent51d9c9899f54200a2bf9bf49df16c03cca403498 (diff)
tdf#157518: add password strength meter to setmasterpassworddlg
Moves PasswordStrength bits that provide utility functions from cui to svl, merging them with PasswordHelper there. Adds password strength bar for the set master password dialog. (accessible via Tools -> Options -> LibreOffice -> Security -> Passwords for Web Connections) Change-Id: I8dc1090a041f8388c2e139beb1d0d9a0beb8acb0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159370 Tested-by: Jenkins Reviewed-by: Sarper Akdemir <sarper.akdemir.extern@allotropia.de>
Diffstat (limited to 'include/svl/PasswordHelper.hxx')
-rw-r--r--include/svl/PasswordHelper.hxx25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/svl/PasswordHelper.hxx b/include/svl/PasswordHelper.hxx
index aa7e55867343..405b3962aab6 100644
--- a/include/svl/PasswordHelper.hxx
+++ b/include/svl/PasswordHelper.hxx
@@ -23,6 +23,7 @@
#include <sal/config.h>
#include <string_view>
+#include <optional>
#include <svl/svldllapi.h>
#include <sal/types.h>
@@ -48,6 +49,30 @@ public:
ODF 1.2, requiring UTF-8 encoding.
*/
SVL_DLLPUBLIC static bool CompareHashPassword(const css::uno::Sequence<sal_Int8>& rOldPassHash, std::u16string_view sNewPass);
+
+ /** Get password strength percentage
+
+ Maps the calculated password entropy bit amount to password strength percentage:
+ 0 bits -> 0%
+ >= 112 bits -> 100%
+
+ @param pPassword null terminated password string.
+ @returns Password strength percentage in the range [0.0, 100.0]
+ */
+ SVL_DLLPUBLIC static double GetPasswordStrengthPercentage(const char* pPassword);
+ SVL_DLLPUBLIC static double GetPasswordStrengthPercentage(const OUString& aPassword);
+
+ /** Checks if the password meets the password policies
+
+ @param pPassword null terminated password string.
+ @param oPasswordPolicy Regular expression string that defines the password policy.
+
+ @returns true if password meets the policy or there is no policy enforced.
+ */
+ SVL_DLLPUBLIC static bool PasswordMeetsPolicy(const char* pPassword,
+ const std::optional<OUString>& oPasswordPolicy);
+ SVL_DLLPUBLIC static bool PasswordMeetsPolicy(const OUString& aPassword,
+ const std::optional<OUString>& oPasswordPolicy);
};
#endif