Skip to content

Commit f6971f8

Browse files
authored
CDRIVER-5634 Address MinGW compilation warnings for PBKDF2 related functions (#1699)
* Address -Wpointer-sign warnings on MinGW * Address -Wunused-function warnings on MinGW
1 parent b4bf5a1 commit f6971f8

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/libmongoc/src/mongoc/mongoc-crypto-cng.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,6 @@ _mongoc_crypto_cng_hmac_or_hash (
143143
return retval;
144144
}
145145

146-
static int
147-
_crypto_hash_size (mongoc_crypto_t *crypto)
148-
{
149-
if (crypto->algorithm == MONGOC_CRYPTO_ALGORITHM_SHA_1) {
150-
return MONGOC_SCRAM_SHA_1_HASH_SIZE;
151-
} else if (crypto->algorithm == MONGOC_CRYPTO_ALGORITHM_SHA_256) {
152-
return MONGOC_SCRAM_SHA_256_HASH_SIZE;
153-
} else {
154-
BSON_UNREACHABLE ("Unexpected crypto algorithm");
155-
}
156-
}
157-
158146
#if defined(MONGOC_HAVE_BCRYPT_PBKDF2)
159147
// Ensure lossless conversion between `uint64_t` and `ULONGLONG` below.
160148
BSON_STATIC_ASSERT2 (sizeof_ulonglong_uint64_t, sizeof (ULONGLONG) == sizeof (uint64_t));
@@ -189,7 +177,7 @@ _bcrypt_derive_key_pbkdf2 (BCRYPT_ALG_HANDLE prf,
189177

190178
// Make non-const versions of password and salt.
191179
char *password_copy = bson_strndup (password, password_len);
192-
char *salt_copy = bson_strndup (salt, salt_len);
180+
char *salt_copy = bson_strndup ((const char *) salt, salt_len);
193181

194182
NTSTATUS status = BCryptDeriveKeyPBKDF2 (prf,
195183
(unsigned char *) password_copy,
@@ -211,6 +199,19 @@ _bcrypt_derive_key_pbkdf2 (BCRYPT_ALG_HANDLE prf,
211199
}
212200

213201
#else
202+
203+
static size_t
204+
_crypto_hash_size (mongoc_crypto_t *crypto)
205+
{
206+
if (crypto->algorithm == MONGOC_CRYPTO_ALGORITHM_SHA_1) {
207+
return MONGOC_SCRAM_SHA_1_HASH_SIZE;
208+
} else if (crypto->algorithm == MONGOC_CRYPTO_ALGORITHM_SHA_256) {
209+
return MONGOC_SCRAM_SHA_256_HASH_SIZE;
210+
} else {
211+
BSON_UNREACHABLE ("Unexpected crypto algorithm");
212+
}
213+
}
214+
214215
/* Manually salts password if BCryptDeriveKeyPBKDF2 is unavailable */
215216
static bool
216217
_bcrypt_derive_key_pbkdf2 (BCRYPT_ALG_HANDLE algorithm,

0 commit comments

Comments
 (0)