23#include <rtl/digest.h>
32 reinterpret_cast<unsigned char const*
>(tmp.getStr()), tmp.getLength(),
33 ::comphelper::HashType::SHA256));
34 rPassHash.realloc(hash.size());
35 ::std::copy(hash.begin(), hash.end(), rPassHash.getArray());
36 rtl_secureZeroMemory(
const_cast<char *
>(tmp.getStr()), tmp.getLength());
43 reinterpret_cast<unsigned char const*
>(tmp.getStr()), tmp.getLength(),
44 ::comphelper::HashType::SHA1));
45 rPassHash.realloc(hash.size());
46 ::std::copy(hash.begin(), hash.end(), rPassHash.getArray());
47 rtl_secureZeroMemory(
const_cast<char *
>(tmp.getStr()), tmp.getLength());
52 rPassHash.realloc(RTL_DIGEST_LENGTH_SHA1);
54 rtlDigestError aError = rtl_digest_SHA1 (pPass, nLen,
reinterpret_cast<sal_uInt8*
>(rPassHash.getArray()), rPassHash.getLength());
55 if (aError != rtl_Digest_E_None)
63 sal_Int32 nSize(sPass.size());
64 std::unique_ptr<char[]> pCharBuffer(
new char[nSize *
sizeof(
sal_Unicode)]);
66 for (sal_Int32
i = 0;
i < nSize; ++
i)
69 pCharBuffer[2 *
i] =
static_cast< char >(
ch & 0xFF);
70 pCharBuffer[2 *
i + 1] =
static_cast< char >(
ch >> 8);
74 rtl_secureZeroMemory(pCharBuffer.get(), nSize *
sizeof(
sal_Unicode));
79 sal_Int32 nSize(sPass.size());
80 std::unique_ptr<char[]> pCharBuffer(
new char[nSize *
sizeof(
sal_Unicode)]);
82 for (sal_Int32
i = 0;
i < nSize; ++
i)
85 pCharBuffer[2 *
i] =
static_cast< char >(
ch >> 8);
86 pCharBuffer[2 *
i + 1] =
static_cast< char >(
ch & 0xFF);
90 rtl_secureZeroMemory(pCharBuffer.get(), nSize *
sizeof(
sal_Unicode));
100 bool bResult =
false;
102 if (rOldPassHash.getLength() == RTL_DIGEST_LENGTH_SHA1)
104 uno::Sequence<sal_Int8> aNewPass(RTL_DIGEST_LENGTH_SHA1);
106 if (aNewPass == rOldPassHash)
113 if (aNewPass == rOldPassHash)
118 bResult = (aNewPass == rOldPassHash);
122 else if (rOldPassHash.getLength() == 32)
124 uno::Sequence<sal_Int8> aNewPass;
126 bResult = aNewPass == rOldPassHash;
static void GetHashPasswordBigEndian(css::uno::Sequence< sal_Int8 > &rPassHash, std::u16string_view sPass)
static SVL_DLLPUBLIC void GetHashPassword(css::uno::Sequence< sal_Int8 > &rPassHash, const char *pPass, sal_uInt32 nLen)
static SVL_DLLPUBLIC void GetHashPasswordSHA1UTF8(css::uno::Sequence< sal_Int8 > &rPassHash, std::u16string_view sPass)
static SVL_DLLPUBLIC bool CompareHashPassword(const css::uno::Sequence< sal_Int8 > &rOldPassHash, std::u16string_view sNewPass)
Use this method to compare a given string with another given Hash value.
static SVL_DLLPUBLIC void GetHashPasswordSHA256(css::uno::Sequence< sal_Int8 > &rPassHash, std::u16string_view sPass)
static void GetHashPasswordLittleEndian(css::uno::Sequence< sal_Int8 > &rPassHash, std::u16string_view sPass)
static std::vector< unsigned char > calculateHash(const unsigned char *pInput, size_t length, HashType eType)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)