diff options
author | Eike Rathke <erack@redhat.com> | 2018-02-26 12:14:03 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-02-26 12:15:17 +0100 |
commit | 384954795c4f3c0641f4b0eb7cff6f27ebfbb5de (patch) | |
tree | f315c0b702c74f16ea4eb5d2bd084919eeb317de /include/comphelper | |
parent | f1a11b9ce9dda2a57bc77d3bf38167a31feff8f1 (diff) |
Move convenience abstractions to DocPasswordHelper, tdf#104250 follow-up
Change-Id: If0775ccf14b631918e51342a767412948e812c87
Diffstat (limited to 'include/comphelper')
-rw-r--r-- | include/comphelper/docpasswordhelper.hxx | 59 | ||||
-rw-r--r-- | include/comphelper/hash.hxx | 51 |
2 files changed, 60 insertions, 50 deletions
diff --git a/include/comphelper/docpasswordhelper.hxx b/include/comphelper/docpasswordhelper.hxx index e420cf3e69af..51ecb7102abd 100644 --- a/include/comphelper/docpasswordhelper.hxx +++ b/include/comphelper/docpasswordhelper.hxx @@ -180,6 +180,65 @@ public: const OUString& aString ); + /** 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. + + @param rPassword + UTF-16LE encoded string without leading BOM character + + @param rSaltValue + Base64 encoded salt that will be decoded and prepended to password + data. + + @param nSpinCount + If >0 the number of repeated iterations. + + @param rAlgorithmName + One of "SHA-512", "SHA-256", ... as listed 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. + + @return the raw hash value as sal_Int8 sequence. + */ + static css::uno::Sequence<sal_Int8> GetOoxHashAsSequence( + const rtl::OUString& rPassword, + const rtl::OUString& rSaltValue, + sal_uInt32 nSpinCount, + 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. + + @param rPassword + UTF-16LE encoded string without leading BOM character + + @param rSaltValue + Base64 encoded salt that will be decoded and prepended to password + data. + + @param nSpinCount + If >0 the number of repeated iterations. + + @param rAlgorithmName + One of "SHA-512", "SHA-256", ... as listed 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. + + @return the base64 encoded string of the hash value, that can be + compared against a stored base64 encoded hash value. + */ + static rtl::OUString GetOoxHashAsBase64( + const rtl::OUString& rPassword, + const rtl::OUString& rSaltValue, + sal_uInt32 nSpinCount, + const rtl::OUString& rAlgorithmName); + + /** This helper function generates a random sequence of bytes of requested length. */ diff --git a/include/comphelper/hash.hxx b/include/comphelper/hash.hxx index b3e97553060d..a9cda038b748 100644 --- a/include/comphelper/hash.hxx +++ b/include/comphelper/hash.hxx @@ -12,8 +12,6 @@ #include <comphelper/comphelperdllapi.h> -#include <com/sun/star/uno/Sequence.hxx> - #include <memory> #include <vector> @@ -73,7 +71,7 @@ public: /** Convenience function to calculate a salted hash with iterations. @param rPassword - UTF-16LE encoded string without leading BOM character + UTF-16LE encoded string, hashed byte-wise as unsigned char. @param rSaltValue Salt that will be prepended to password data. @@ -84,53 +82,6 @@ public: sal_uInt32 nSpinCount, HashType eType); - /** Convenience function to calculate a salted hash with iterations. - - @param rPassword - UTF-16LE encoded string without leading BOM character - - @param rSaltValue - Base64 encoded salt that will be decoded and prepended to password - data. - - @param rAlgorithmName - One of "SHA-512", "SHA-256", ... as listed 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. - - @return the raw hash value as sal_Int8 sequence. - */ - static css::uno::Sequence<sal_Int8> calculateHashSequence( - const rtl::OUString& rPassword, - const rtl::OUString& rSaltValue, - sal_uInt32 nSpinCount, - const rtl::OUString& rAlgorithmName); - - /** Convenience function to calculate a salted hash with iterations. - - @param rPassword - UTF-16LE encoded string without leading BOM character - - @param rSaltValue - Base64 encoded salt that will be decoded and prepended to password - data. - - @param rAlgorithmName - One of "SHA-512", "SHA-256", ... as listed 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. - - @return the base64 encoded string of the hash value, that can be - compared against a stored base64 encoded hash value. - */ - static rtl::OUString calculateHashBase64( - const rtl::OUString& rPassword, - const rtl::OUString& rSaltValue, - sal_uInt32 nSpinCount, - const rtl::OUString& rAlgorithmName); - size_t getLength() const; }; |