From 162ffd57de49b1f007b88fb247a592acbac0aaf7 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Thu, 11 Jan 2018 10:25:23 +0100 Subject: (related:tdf#114939) connectivity: use real SHA1 It looks like OConnectionWrapper::createUniqueId() doesn't really care what particular hash is used, it just wants to create something unique, so don't use the 'special' StarOffice SHA1 here. Change-Id: I817be900ecc9c6d686f21cce4a46f9eadd244b71 --- connectivity/source/commontools/ConnectionWrapper.cxx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'connectivity') diff --git a/connectivity/source/commontools/ConnectionWrapper.cxx b/connectivity/source/commontools/ConnectionWrapper.cxx index 7ac9ed6dc1c2..ff966e65bbee 100644 --- a/connectivity/source/commontools/ConnectionWrapper.cxx +++ b/connectivity/source/commontools/ConnectionWrapper.cxx @@ -23,10 +23,10 @@ #include #include #include +#include #include #include #include -#include #include #include @@ -195,12 +195,12 @@ void OConnectionWrapper::createUniqueId( const OUString& _rURL ,const OUString& _rPassword) { // first we create the digest we want to have - rtlDigest aDigest = rtl_digest_create( rtl_Digest_AlgorithmSHA1 ); - rtl_digest_update(aDigest,_rURL.getStr(),_rURL.getLength()*sizeof(sal_Unicode)); + ::comphelper::Hash sha1(::comphelper::HashType::SHA1); + sha1.update(reinterpret_cast(_rURL.getStr()), _rURL.getLength() * sizeof(sal_Unicode)); if ( !_rUserName.isEmpty() ) - rtl_digest_update(aDigest,_rUserName.getStr(),_rUserName.getLength()*sizeof(sal_Unicode)); + sha1.update(reinterpret_cast(_rUserName.getStr()), _rUserName.getLength() * sizeof(sal_Unicode)); if ( !_rPassword.isEmpty() ) - rtl_digest_update(aDigest,_rPassword.getStr(),_rPassword.getLength()*sizeof(sal_Unicode)); + sha1.update(reinterpret_cast(_rPassword.getStr()), _rPassword.getLength() * sizeof(sal_Unicode)); // now we need to sort the properties std::sort(_rInfo.begin(),_rInfo.end(),TPropertyValueLessFunctor()); @@ -221,20 +221,19 @@ void OConnectionWrapper::createUniqueId( const OUString& _rURL if ( prop.Value >>= aSeq ) { for(OUString const & s : aSeq) - rtl_digest_update(aDigest,s.getStr(),s.getLength()*sizeof(sal_Unicode)); + sha1.update(reinterpret_cast(s.getStr()), s.getLength() * sizeof(sal_Unicode)); } } } if ( !sValue.isEmpty() ) { // we don't have to convert this into UTF8 because we don't store on a file system - rtl_digest_update(aDigest,sValue.getStr(),sValue.getLength()*sizeof(sal_Unicode)); + sha1.update(reinterpret_cast(sValue.getStr()), sValue.getLength() * sizeof(sal_Unicode)); } } - rtl_digest_get(aDigest,_pBuffer,RTL_DIGEST_LENGTH_SHA1); - // we have to destroy the digest - rtl_digest_destroy(aDigest); + std::vector result(sha1.finalize()); + std::copy(result.begin(), result.end(), _pBuffer); } -- cgit