[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - oox/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.com
Sun Mar 23 11:36:20 PDT 2014
oox/source/crypto/CryptTools.cxx | 44 +++++++++++++++++++++++++++++++++------
1 file changed, 38 insertions(+), 6 deletions(-)
New commits:
commit 7cf5d562e6e86b0f571edc95a150b8dce8f3ddef
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sun Mar 23 14:20:10 2014 +0100
fdo#75955 use SHA1 from openssl/nss instead of rtl_digest_sha1
Change-Id: I92186b2ed8426d59e31080cfb629beb02cd01c41
diff --git a/oox/source/crypto/CryptTools.cxx b/oox/source/crypto/CryptTools.cxx
index d9ba500..00be5e0 100644
--- a/oox/source/crypto/CryptTools.cxx
+++ b/oox/source/crypto/CryptTools.cxx
@@ -196,15 +196,47 @@ sal_uInt32 Encrypt::update(vector<sal_uInt8>& output, vector<sal_uInt8>& input,
bool sha1(vector<sal_uInt8>& output, vector<sal_uInt8>& input)
{
+ bool aResult = false;
+
+#if USE_TLS_OPENSSL
output.clear();
- output.resize(RTL_DIGEST_LENGTH_SHA1, 0);
+ output.resize(SHA_DIGEST_LENGTH, 0);
+
+ SHA_CTX context;
+ SHA1_Init(&context);
+ SHA1_Update(&context, &input[0], input.size());
+ SHA1_Final(&output[0], &context);
+ aResult = true;
+#endif
- rtlDigest aDigest = rtl_digest_create( rtl_Digest_AlgorithmSHA1 );
- rtl_digest_update( aDigest, &input[0], input.size() );
- rtl_digest_get( aDigest, &output[0], RTL_DIGEST_LENGTH_SHA1 );
- rtl_digest_destroy( aDigest );
+#if USE_TLS_NSS
+ output.clear();
+ output.resize(SHA1_LENGTH, 0);
- return true;
+ // Initialize NSS, database functions are not needed
+ NSS_NoDB_Init(NULL);
+ SECStatus status;
+
+ PK11Context* mContext = PK11_CreateDigestContext(SEC_OID_SHA1);
+ status = PK11_DigestBegin(mContext);
+ if (status != SECSuccess)
+ return false;
+
+ status = PK11_DigestOp(mContext, &input[0], input.size());
+ if (status != SECSuccess)
+ return false;
+
+ unsigned int outputLength = 0;
+
+ status = PK11_DigestFinal(mContext, &output[0], &outputLength, SHA1_LENGTH);
+ if (status != SECSuccess || outputLength != SHA1_LENGTH)
+ return false;
+
+ PK11_DestroyContext(mContext, PR_TRUE);
+
+ aResult = true;
+#endif
+ return aResult;
}
bool sha512(vector<sal_uInt8>& output, vector<sal_uInt8>& input)
More information about the Libreoffice-commits
mailing list