summaryrefslogtreecommitdiff
path: root/include/comphelper
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2018-02-26 13:18:22 +0100
committerEike Rathke <erack@redhat.com>2018-02-26 13:19:12 +0100
commit530465964a487c9633305bc886c7826f97f7f1ce (patch)
treedfc33a3db957b83880bd1192dae6a60610f04aac /include/comphelper
parent389405cc49cb07a5414dd2b7ac10d9a7785e012b (diff)
Prepare to handle OOXML Agile Encryption password hash as well
... that prepends the iteration count to the hash instead of appending it Change-Id: I090393e6337c110029e35baaa259b40ef4e5d416
Diffstat (limited to 'include/comphelper')
-rw-r--r--include/comphelper/docpasswordhelper.hxx34
-rw-r--r--include/comphelper/hash.hxx15
2 files changed, 41 insertions, 8 deletions
diff --git a/include/comphelper/docpasswordhelper.hxx b/include/comphelper/docpasswordhelper.hxx
index 51ecb7102abd..0755106b1d23 100644
--- a/include/comphelper/docpasswordhelper.hxx
+++ b/include/comphelper/docpasswordhelper.hxx
@@ -194,11 +194,21 @@ public:
@param nSpinCount
If >0 the number of repeated iterations.
+ @param bPrependNotAppend
+ If <FALSE/>, append spin count in iterations as per
+ https://msdn.microsoft.com/en-us/library/dd920692
+ If <TRUE/>, prepend spin count in iterations as per
+ https://msdn.microsoft.com/en-us/library/dd924776 and
+ https://msdn.microsoft.com/en-us/library/dd925430
+
@param rAlgorithmName
- One of "SHA-512", "SHA-256", ... as listed in
+ One of "SHA-512", "SHA-256", ... as listed for AlgorithmName in
https://msdn.microsoft.com/en-us/library/dd920692
- that have a valid match in HashType. If not, an empty string is
- returned. Not all algorithm names are supported.
+ 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 hash value as sal_Int8 sequence.
*/
@@ -206,6 +216,7 @@ public:
const rtl::OUString& rPassword,
const rtl::OUString& rSaltValue,
sal_uInt32 nSpinCount,
+ bool bPrependNotAppend,
const rtl::OUString& rAlgorithmName);
@@ -223,11 +234,21 @@ public:
@param nSpinCount
If >0 the number of repeated iterations.
+ @param bPrependNotAppend
+ If <FALSE/>, append spin count in iterations as per
+ https://msdn.microsoft.com/en-us/library/dd920692
+ If <TRUE/>, prepend spin count in iterations as per
+ https://msdn.microsoft.com/en-us/library/dd924776 and
+ https://msdn.microsoft.com/en-us/library/dd925430
+
@param rAlgorithmName
- One of "SHA-512", "SHA-256", ... as listed in
+ One of "SHA-512", "SHA-256", ... as listed for AlgorithmName in
https://msdn.microsoft.com/en-us/library/dd920692
- that have a valid match in HashType. If not, an empty string is
- returned. Not all algorithm names are supported.
+ 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 base64 encoded string of the hash value, that can be
compared against a stored base64 encoded hash value.
@@ -236,6 +257,7 @@ public:
const rtl::OUString& rPassword,
const rtl::OUString& rSaltValue,
sal_uInt32 nSpinCount,
+ bool bPrependNotAppend,
const rtl::OUString& rAlgorithmName);
diff --git a/include/comphelper/hash.hxx b/include/comphelper/hash.hxx
index a9cda038b748..9ef2cbd58465 100644
--- a/include/comphelper/hash.hxx
+++ b/include/comphelper/hash.hxx
@@ -54,18 +54,28 @@ public:
(0-based, little endian) containing the number of the iteration
appended to the hash value is the input for the next iteration.
- This implements the algorithm as specified in
- https://msdn.microsoft.com/en-us/library/dd920692
+ This implements the algorithms as specified in
+ https://msdn.microsoft.com/en-us/library/dd920692 or
+ https://msdn.microsoft.com/en-us/library/dd924776 and
+ https://msdn.microsoft.com/en-us/library/dd925430
@param pSalt
may be nullptr thus no salt prepended
+ @param bPrependNotAppend
+ If <FALSE/>, append spin count in iterations as per
+ https://msdn.microsoft.com/en-us/library/dd920692
+ If <TRUE/>, prepend spin count in iterations as per
+ https://msdn.microsoft.com/en-us/library/dd924776 and
+ https://msdn.microsoft.com/en-us/library/dd925430
+
@return the raw hash value
*/
static std::vector<unsigned char> calculateHash(
const unsigned char* pInput, size_t nLength,
const unsigned char* pSalt, size_t nSaltLen,
sal_uInt32 nSpinCount,
+ bool bPrependNotAppend,
HashType eType);
/** Convenience function to calculate a salted hash with iterations.
@@ -80,6 +90,7 @@ public:
const rtl::OUString& rPassword,
const std::vector<unsigned char>& rSaltValue,
sal_uInt32 nSpinCount,
+ bool bPrependNotAppend,
HashType eType);
size_t getLength() const;