diff options
author | Michael Stahl <mstahl@redhat.com> | 2018-01-11 10:25:23 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2018-01-11 11:04:59 +0100 |
commit | 162ffd57de49b1f007b88fb247a592acbac0aaf7 (patch) | |
tree | 6e01a9c91f542b97d8444d7656b21aacdf6ef80f | |
parent | 2711f7639811929fc9ea8dc168ea28f1c5545e67 (diff) |
(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
-rw-r--r-- | connectivity/source/commontools/ConnectionWrapper.cxx | 19 |
1 files changed, 9 insertions, 10 deletions
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 <com/sun/star/lang/DisposedException.hpp> #include <comphelper/uno3.hxx> #include <comphelper/sequence.hxx> +#include <comphelper/hash.hxx> #include <cppuhelper/supportsservice.hxx> #include <cppuhelper/typeprovider.hxx> #include <com/sun/star/reflection/ProxyFactory.hpp> -#include <rtl/digest.h> #include <algorithm> #include <string.h> @@ -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<unsigned char const*>(_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<unsigned char const*>(_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<unsigned char const*>(_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<unsigned char const*>(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<unsigned char const*>(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<unsigned char> result(sha1.finalize()); + std::copy(result.begin(), result.end(), _pBuffer); } |