summaryrefslogtreecommitdiff
path: root/include/comphelper/docpasswordhelper.hxx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2018-02-26 22:02:50 +0100
committerEike Rathke <erack@redhat.com>2018-02-26 22:03:42 +0100
commit94fa259e769b44f2c2ea7f1667b28f2c07489668 (patch)
tree1451c9c27a09dab3bb1738491a0f4cc7ee12fbba /include/comphelper/docpasswordhelper.hxx
parent3c0189c7f04b9b457ed5621fef68fcb1843df891 (diff)
Introduce DocPasswordHelper::GetOoxHashAsVector() with salt value vector
In preparation to use this in AgileEngine. Change-Id: I45fb6ba24b759a72af0c7afa22eae75f1ae728ce
Diffstat (limited to 'include/comphelper/docpasswordhelper.hxx')
-rw-r--r--include/comphelper/docpasswordhelper.hxx54
1 files changed, 52 insertions, 2 deletions
diff --git a/include/comphelper/docpasswordhelper.hxx b/include/comphelper/docpasswordhelper.hxx
index e37a6c71de22..62c856c40c9a 100644
--- a/include/comphelper/docpasswordhelper.hxx
+++ b/include/comphelper/docpasswordhelper.hxx
@@ -183,7 +183,10 @@ public:
/** Convenience function to calculate a salted hash with iterations as
specified in https://msdn.microsoft.com/en-us/library/dd920692 for the
- OOXML sheetProtection and fileSharing elements.
+ OOXML sheetProtection and fileSharing elements, or
+ https://msdn.microsoft.com/en-us/library/dd924776 and
+ https://msdn.microsoft.com/en-us/library/dd925430 for Standard and
+ Agile Encryption.
@param rPassword
UTF-16 encoded string without leading BOM character
@@ -225,7 +228,10 @@ public:
/** Convenience function to calculate a salted hash with iterations as
specified in https://msdn.microsoft.com/en-us/library/dd920692 for the
- OOXML sheetProtection and fileSharing elements.
+ OOXML sheetProtection and fileSharing elements, or
+ https://msdn.microsoft.com/en-us/library/dd924776 and
+ https://msdn.microsoft.com/en-us/library/dd925430 for Standard and
+ Agile Encryption.
@param rPassword
UTF-16 encoded string without leading BOM character
@@ -266,6 +272,50 @@ public:
const rtl::OUString& rAlgorithmName);
+ /** Convenience function to calculate a salted hash with iterations as
+ specified in https://msdn.microsoft.com/en-us/library/dd920692 for the
+ OOXML sheetProtection and fileSharing elements, or
+ https://msdn.microsoft.com/en-us/library/dd924776 and
+ https://msdn.microsoft.com/en-us/library/dd925430 for Standard and
+ Agile Encryption.
+
+ @param rPassword
+ UTF-16 encoded string without leading BOM character
+
+ @param rSaltValue
+ A raw salt that will be prepended to password data.
+
+ @param nSpinCount
+ If >0 the number of repeated iterations.
+
+ @param eIterCount
+ If Hash::IterCount::APPEND, append iteration count as per
+ https://msdn.microsoft.com/en-us/library/dd920692
+ If Hash::IterCount::PREPEND, prepend iteration count as per
+ https://msdn.microsoft.com/en-us/library/dd924776 and
+ https://msdn.microsoft.com/en-us/library/dd925430
+ If Hash::IterCount::NONE, do not add the iteration count to hash
+ iterations.
+
+ @param rAlgorithmName
+ One of "SHA-512", "SHA-256", ... as listed for AlgorithmName in
+ https://msdn.microsoft.com/en-us/library/dd920692
+ or "SHA512", "SHA256", ... as listed for HashAlgorithm in
+ https://msdn.microsoft.com/en-us/library/dd925810
+ that have a valid match in comphelper::HashType. If not, an
+ empty sequence is returned. Not all algorithm names are
+ supported.
+
+ @return the raw the hash value.
+ */
+ static std::vector<unsigned char> GetOoxHashAsVector(
+ const rtl::OUString& rPassword,
+ const std::vector<unsigned char>& rSaltValue,
+ sal_uInt32 nSpinCount,
+ comphelper::Hash::IterCount eIterCount,
+ const rtl::OUString& rAlgorithmName);
+
+
/** This helper function generates a random sequence of bytes of
requested length.
*/