summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-07-14 21:16:07 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-07-15 09:16:05 +0200
commit4fcd42afd3ba92f909b48be72c9392314689ec89 (patch)
treed5d21339948547909bd3f1afb81249d89fc28921 /include
parent96ada688eaf7454791a5d8f8e0abe68e2c417e26 (diff)
comphelper: don't hardcode hash sizes in Hash::getLength()
Instead move the constants from filter to comphelper and reuse them. Change-Id: Ib7061e9028ccf6067b4e86f50145c1472c2b01d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98785 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'include')
-rw-r--r--include/comphelper/hash.hxx6
-rw-r--r--include/filter/msfilter/mscodec.hxx8
2 files changed, 9 insertions, 5 deletions
diff --git a/include/comphelper/hash.hxx b/include/comphelper/hash.hxx
index 52ad5e5cdf1e..54ab3a25105c 100644
--- a/include/comphelper/hash.hxx
+++ b/include/comphelper/hash.hxx
@@ -11,6 +11,7 @@
#define INCLUDED_COMPHELPER_HASH_HXX
#include <comphelper/comphelperdllapi.h>
+#include <rtl/digest.h>
#include <memory>
#include <vector>
@@ -29,6 +30,11 @@ enum class HashType
SHA512
};
+const sal_uInt32 MD5_HASH_LENGTH = RTL_DIGEST_LENGTH_MD5;
+const sal_uInt32 SHA1_HASH_LENGTH = RTL_DIGEST_LENGTH_SHA1;
+const sal_uInt32 SHA256_HASH_LENGTH = 32;
+const sal_uInt32 SHA512_HASH_LENGTH = 64;
+
struct HashImpl;
class COMPHELPER_DLLPUBLIC Hash
diff --git a/include/filter/msfilter/mscodec.hxx b/include/filter/msfilter/mscodec.hxx
index a7917ec1aa09..f40003efe0d6 100644
--- a/include/filter/msfilter/mscodec.hxx
+++ b/include/filter/msfilter/mscodec.hxx
@@ -25,6 +25,7 @@
#include <rtl/cipher.h>
#include <rtl/digest.h>
#include <sal/types.h>
+#include <comphelper/hash.hxx>
#include <vector>
namespace com::sun::star {
@@ -442,9 +443,6 @@ const sal_uInt32 AGILE_ENCRYPTION_RESERVED = 0x00000040;
const sal_uInt32 SALT_LENGTH = 16;
const sal_uInt32 ENCRYPTED_VERIFIER_LENGTH = 16;
-const sal_uInt32 SHA1_HASH_LENGTH = RTL_DIGEST_LENGTH_SHA1; // 20
-const sal_uInt32 SHA256_HASH_LENGTH = 32;
-const sal_uInt32 SHA512_HASH_LENGTH = 64;
struct MSFILTER_DLLPUBLIC EncryptionStandardHeader
{
@@ -466,7 +464,7 @@ struct MSFILTER_DLLPUBLIC EncryptionVerifierAES
sal_uInt8 salt[SALT_LENGTH] = {}; // random generated salt value
sal_uInt8 encryptedVerifier[ENCRYPTED_VERIFIER_LENGTH] = {}; // randomly generated verifier value
sal_uInt32 encryptedVerifierHashSize; // actually written hash size - depends on algorithm
- sal_uInt8 encryptedVerifierHash[SHA256_HASH_LENGTH] = {}; // verifier value hash - itself also encrypted
+ sal_uInt8 encryptedVerifierHash[comphelper::SHA256_HASH_LENGTH] = {}; // verifier value hash - itself also encrypted
EncryptionVerifierAES();
};
@@ -477,7 +475,7 @@ struct MSFILTER_DLLPUBLIC EncryptionVerifierRC4
sal_uInt8 salt[SALT_LENGTH] = {}; // random generated salt value
sal_uInt8 encryptedVerifier[ENCRYPTED_VERIFIER_LENGTH] = {}; // randomly generated verifier value
sal_uInt32 encryptedVerifierHashSize; // actually written hash size - depends on algorithm
- sal_uInt8 encryptedVerifierHash[SHA1_HASH_LENGTH] = {}; // verifier value hash - itself also encrypted
+ sal_uInt8 encryptedVerifierHash[comphelper::SHA1_HASH_LENGTH] = {}; // verifier value hash - itself also encrypted
EncryptionVerifierRC4();
};