*/
#include "cups-private.h"
+#include "debug-internal.h"
#ifdef __APPLE__
# include <CommonCrypto/CommonDigest.h>
#elif defined(HAVE_GNUTLS)
# include <gnutls/crypto.h>
# include "md5-internal.h"
+#elif _WIN32
+# include <windows.h>
+# include <bcrypt.h>
#else
# include "md5-internal.h"
#endif /* __APPLE__ */
if (algid)
{
- if (hashsize < hashlen)
+ if (hashsize < (size_t)hashlen)
goto too_small;
- if ((status = BCryptOpenAlgorithmProvider(&alg, algid, NULL, 0)) != STATUS_SUCCESS)
+ if ((status = BCryptOpenAlgorithmProvider(&alg, algid, NULL, 0)) < 0)
{
DEBUG_printf(("2cupsHashData: BCryptOpenAlgorithmProvider returned %d.", status));
if (tempsize > 0)
{
// Do a truncated SHA2-512 hash...
- status = BCryptHash(alg, NULL, 0, data, (ULONG)datalen, temp, sizeof(temp));
+ status = BCryptHash(alg, NULL, 0, (PUCHAR)data, (ULONG)datalen, temp, sizeof(temp));
memcpy(hash, temp, hashlen);
}
else
{
// Hash directly to buffer...
- status = BCryptHash(alg, NULL, 0, data, (ULONG)datalen, hash, hashlen);
+ status = BCryptHash(alg, NULL, 0, (PUCHAR)data, (ULONG)datalen, hash, (ULONG)hashlen);
}
- BCryptCloseAlgorithmProvider(alg);
+ BCryptCloseAlgorithmProvider(alg, 0);
- if (status != STATUS_SUCCESS)
+ if (status < 0)
{
DEBUG_printf(("2cupsHashData: BCryptHash returned %d.", status));
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
- <AdditionalDependencies>ws2_32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>bcrypt.lib;ws2_32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)libcups2.dll</OutputFile>
<ModuleDefinitionFile>..\cups\libcups2.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
- <AdditionalDependencies>ws2_32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>bcrypt.lib;ws2_32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)libcups2.dll</OutputFile>
<ModuleDefinitionFile>..\cups\libcups2.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>