Skip to content

Commit

Permalink
Fix VS2010 build: Microsoft specific bool type is predefined. Intermi…
Browse files Browse the repository at this point in the history
…ngled declarations and code is not allowed.
  • Loading branch information
kiyolee committed Mar 19, 2019
1 parent 967802c commit d3847ea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#else
#elif !defined(__BOOL_DEFINED)
typedef char bool;
#define true 1
#define false 0
Expand Down
3 changes: 2 additions & 1 deletion lib/zip_crypto_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,13 @@ There is no #ifdef to control that, because this is working for all supported OS
bool
_zip_crypto_pbkdf2(const zip_uint8_t *key, zip_uint64_t key_length, const zip_uint8_t *salt, zip_uint16_t salt_length, zip_uint16_t iterations, zip_uint8_t *output, zip_uint16_t output_length) {
BCRYPT_ALG_HANDLE hAlgorithm = NULL;
bool result;

if (!BCRYPT_SUCCESS(BCryptOpenAlgorithmProvider(&hAlgorithm, BCRYPT_SHA1_ALGORITHM, NULL, BCRYPT_ALG_HANDLE_HMAC_FLAG))) {
return false;
}

bool result = BCRYPT_SUCCESS(BCryptDeriveKeyPBKDF2(hAlgorithm, (PUCHAR)key, (ULONG)key_length, (PUCHAR)salt, salt_length, iterations, output, output_length, 0));
result = BCRYPT_SUCCESS(BCryptDeriveKeyPBKDF2(hAlgorithm, (PUCHAR)key, (ULONG)key_length, (PUCHAR)salt, salt_length, iterations, output, output_length, 0));

BCryptCloseAlgorithmProvider(hAlgorithm, 0);

Expand Down

0 comments on commit d3847ea

Please sign in to comment.