diff options
author | Eike Rathke <erack@redhat.com> | 2018-02-24 14:18:04 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-02-24 21:02:41 +0100 |
commit | d841f348b94f30cb8e94a0d34e9b20aa34d33aca (patch) | |
tree | 06a5a02a4a0e77060a578bfbd113d8f90330b3fd /sc | |
parent | 5f4df7af832e886bd279db566dc6693db9bb6a89 (diff) |
Add ScOoxPasswordHash::verifyPassword(), tdf#104250 prep
Change-Id: Ife588fa0626b01336813e956a25e51541d1096e6
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/tabprotection.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/data/tabprotection.cxx | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/sc/inc/tabprotection.hxx b/sc/inc/tabprotection.hxx index 6a776807a191..f33981699b9b 100644 --- a/sc/inc/tabprotection.hxx +++ b/sc/inc/tabprotection.hxx @@ -55,6 +55,7 @@ struct ScOoxPasswordHash maHashValue.clear(); maSaltValue.clear(); } + bool verifyPassword( const OUString& aPassText ) const; }; namespace ScPassHashHelper diff --git a/sc/source/core/data/tabprotection.cxx b/sc/source/core/data/tabprotection.cxx index 6aecc83a3c11..2dec79100484 100644 --- a/sc/source/core/data/tabprotection.cxx +++ b/sc/source/core/data/tabprotection.cxx @@ -20,6 +20,7 @@ #include <tabprotection.hxx> #include <svl/PasswordHelper.hxx> #include <comphelper/docpasswordhelper.hxx> +#include <comphelper/hash.hxx> #include <osl/diagnose.h> #include <document.hxx> @@ -88,6 +89,19 @@ ScPasswordHash ScPassHashHelper::getHashTypeFromURI(const OUString& rURI) return PASSHASH_UNSPECIFIED; } +bool ScOoxPasswordHash::verifyPassword( const OUString& aPassText ) const +{ + if (!hasPassword()) + return false; + + const OUString aHash( comphelper::Hash::calculateHashBase64( aPassText, maSaltValue, mnSpinCount, maAlgorithmName)); + if (aHash.isEmpty()) + // unsupported algorithm + return false; + + return aHash == maHashValue; +} + ScPassHashProtectable::~ScPassHashProtectable() { } |