@@ -143,18 +143,6 @@ _mongoc_crypto_cng_hmac_or_hash (
143
143
return retval ;
144
144
}
145
145
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
-
158
146
#if defined(MONGOC_HAVE_BCRYPT_PBKDF2 )
159
147
// Ensure lossless conversion between `uint64_t` and `ULONGLONG` below.
160
148
BSON_STATIC_ASSERT2 (sizeof_ulonglong_uint64_t , sizeof (ULONGLONG ) == sizeof (uint64_t ));
@@ -189,7 +177,7 @@ _bcrypt_derive_key_pbkdf2 (BCRYPT_ALG_HANDLE prf,
189
177
190
178
// Make non-const versions of password and salt.
191
179
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 );
193
181
194
182
NTSTATUS status = BCryptDeriveKeyPBKDF2 (prf ,
195
183
(unsigned char * ) password_copy ,
@@ -211,6 +199,19 @@ _bcrypt_derive_key_pbkdf2 (BCRYPT_ALG_HANDLE prf,
211
199
}
212
200
213
201
#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
+
214
215
/* Manually salts password if BCryptDeriveKeyPBKDF2 is unavailable */
215
216
static bool
216
217
_bcrypt_derive_key_pbkdf2 (BCRYPT_ALG_HANDLE algorithm ,
0 commit comments