summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/tabprotection.hxx1
-rw-r--r--sc/source/core/data/tabprotection.cxx14
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()
{
}