From 16781248cb15841e756ec842ca8f9622a2cff94e Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Mon, 9 Aug 2021 12:00:55 +0300 Subject: [PATCH] cov 354644 --- client/src/mifare/desfirecrypto.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/src/mifare/desfirecrypto.c b/client/src/mifare/desfirecrypto.c index 85ce60f40..020d3c7e4 100644 --- a/client/src/mifare/desfirecrypto.c +++ b/client/src/mifare/desfirecrypto.c @@ -346,10 +346,12 @@ void DesfireCryptoCMAC(DesfireContext *ctx, uint8_t *data, size_t len, uint8_t * // This function is almot like cmac(...). but with some key differences. void MifareKdfAn10922(DesfireContext *ctx, DesfireCryptoOpKeyType key_type, const uint8_t *data, size_t len) { - int kbs = desfire_get_key_block_length(ctx->keyType); // 8 or 16 - if (ctx == NULL || kbs == 0 || data == NULL || len < 1 || len > 31) { + if (ctx == NULL || data == NULL || len < 1 || len > 31) + return; + + int kbs = desfire_get_key_block_length(ctx->keyType); // 8 or 16 + if (kbs == 0) return; - } uint8_t cmac[DESFIRE_MAX_CRYPTO_BLOCK_SIZE * 3] = {0}; uint8_t buffer[DESFIRE_MAX_CRYPTO_BLOCK_SIZE * 3] = {0};