summaryrefslogtreecommitdiffstats
path: root/include/oox/crypto
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-03-23 18:27:11 +0100
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-03-23 18:36:59 +0100
commit970517af3e02e6c05e4d2b44d63745e8a414bb43 (patch)
tree53478016de414bd4e73b68ca544f27d7c8f6cdcb /include/oox/crypto
parentWaE: unused variables (diff)
downloadcore-970517af3e02e6c05e4d2b44d63745e8a414bb43.tar.gz
core-970517af3e02e6c05e4d2b44d63745e8a414bb43.zip
oox: add Digest class which uses NSS or OpenSSL for digest calc.
Document encryption and decryption uses either NSS or OpenSSL to calculate digest. Digest class hides the implementation details between the two implementations. Previously, functions sha1 and sha512 were used for this, but were less generic. Change-Id: I60119e2ab9c5c1f4a2b02bc417c3c89c53a63fda
Diffstat (limited to 'include/oox/crypto')
-rw-r--r--include/oox/crypto/CryptTools.hxx43
1 files changed, 39 insertions, 4 deletions
diff --git a/include/oox/crypto/CryptTools.hxx b/include/oox/crypto/CryptTools.hxx
index ae2c6f6f4209..dde778d4df8c 100644
--- a/include/oox/crypto/CryptTools.hxx
+++ b/include/oox/crypto/CryptTools.hxx
@@ -28,9 +28,11 @@
#include <openssl/evp.h>
#include <openssl/sha.h>
#endif // USE_TLS_OPENSSL
+
#if USE_TLS_NSS
#include <nss.h>
#include <pk11pub.h>
+#include <sechash.h>
#endif // USE_TLS_NSS
#include <rtl/digest.h>
@@ -115,12 +117,45 @@ public:
sal_uInt32 inputLength = 0);
};
-const sal_uInt32 SHA1_LENGTH = 20;
-const sal_uInt32 SHA512_LENGTH = 64;
+class Digest
+{
+public:
+ enum DigestType
+ {
+ UNKNOWN,
+ SHA1,
+ SHA512
+ };
+
+ static const sal_uInt32 DIGEST_LENGTH_SHA1;
+ static const sal_uInt32 DIGEST_LENGTH_SHA512;
+
+private:
+ DigestType meType;
-bool sha1( std::vector<sal_uInt8>& output, std::vector<sal_uInt8>& input );
+#if USE_TLS_OPENSSL
+ EVP_MD_CTX* mpContext;
+#endif
+
+#if USE_TLS_NSS
+ HASHContext* mpContext;
+#endif
+
+public:
+ Digest(DigestType eType);
+ virtual ~Digest();
+
+ bool update(std::vector<sal_uInt8>& input);
+ bool finalize(std::vector<sal_uInt8>& digest);
+
+ sal_uInt32 getLength();
+
+ static bool sha1( std::vector<sal_uInt8>& digest, std::vector<sal_uInt8>& input);
+ static bool sha512(std::vector<sal_uInt8>& digest, std::vector<sal_uInt8>& input);
+};
-bool sha512( std::vector<sal_uInt8>& output, std::vector<sal_uInt8>& input );
+bool sha1( std::vector<sal_uInt8>& digest, std::vector<sal_uInt8>& input);
+bool sha512(std::vector<sal_uInt8>& digest, std::vector<sal_uInt8>& input);
} // namespace core
} // namespace oox