diff options
author | Sarper Akdemir <sarper.akdemir.extern@allotropia.de> | 2023-11-08 07:36:52 +0300 |
---|---|---|
committer | Sarper Akdemir <sarper.akdemir.extern@allotropia.de> | 2023-11-15 19:48:38 +0100 |
commit | cdcff8c34144e883eca9dc6e1a85968ed34909c2 (patch) | |
tree | 3e976e02a3b3b43aa7962850b07efad63f5f25b1 /include | |
parent | 51d9c9899f54200a2bf9bf49df16c03cca403498 (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')
-rw-r--r-- | include/sal/log-areas.dox | 2 | ||||
-rw-r--r-- | include/svl/PasswordHelper.hxx | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox index 0b3907e08610..0315b006f333 100644 --- a/include/sal/log-areas.dox +++ b/include/sal/log-areas.dox @@ -128,7 +128,6 @@ certain functionality. @li @c cui.factory @li @c cui.options @li @c cui.tabpages -@li @c cui.util @section drawinglayer @@ -388,6 +387,7 @@ certain functionality. @li @c svl @li @c svl.crypto @li @c svl.items +@li @c svl.misc @li @c svl.numbers @section svtools 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 |