Skip to content

Commit 221eb3e

Browse files
committed
Fail _hash_size on unexpected algos
1 parent ee7e095 commit 221eb3e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ _crypto_hash_size (mongoc_crypto_t *crypto)
150150
return MONGOC_SCRAM_SHA_1_HASH_SIZE;
151151
} else if (crypto->algorithm == MONGOC_CRYPTO_ALGORITHM_SHA_256) {
152152
return MONGOC_SCRAM_SHA_256_HASH_SIZE;
153+
} else {
154+
BSON_UNREACHABLE ("Unexpected crypto algorithm");
153155
}
154-
return 0;
155156
}
156157

157158
/* Wrapper for BCryptDeriveKeyPBKDF2 */

src/libmongoc/src/mongoc/mongoc-scram.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ _scram_hash_size (mongoc_scram_t *scram)
119119
return MONGOC_SCRAM_SHA_1_HASH_SIZE;
120120
} else if (scram->crypto.algorithm == MONGOC_CRYPTO_ALGORITHM_SHA_256) {
121121
return MONGOC_SCRAM_SHA_256_HASH_SIZE;
122+
} else {
123+
BSON_UNREACHABLE ("Unexpected crypto algorithm");
122124
}
123-
return 0;
124125
}
125126

126127
/* Copies the cache's secrets to scram */

0 commit comments

Comments
 (0)