Skip to content

Commit e5b1509

Browse files
committed
Changes for clang
1 parent f7c7496 commit e5b1509

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

src/wp_kbkdf.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ static int wp_kbkdf_init_hmac(wp_KbkdfCtx* ctx, unsigned char* key,
386386
localKeyLen = blockSize;
387387
}
388388
else {
389-
localKeyLen = keyLen;
389+
localKeyLen = (word32)keyLen;
390390
}
391391

392392
if (ok) {
@@ -418,10 +418,10 @@ static int wp_kbkdf_init_mac(wp_KbkdfCtx* ctx, unsigned char* key,
418418
#ifdef WP_HAVE_CMAC
419419
case WP_MAC_TYPE_CMAC:
420420
#if LIBWOLFSSL_VERSION_HEX >= 0x05000000
421-
rc = wc_InitCmac_ex(&ctx->cmacCtx, key, keyLen, WC_CMAC_AES, NULL,
421+
rc = wc_InitCmac_ex(&ctx->cmacCtx, key, (word32)keyLen, WC_CMAC_AES, NULL,
422422
NULL, INVALID_DEVID);
423423
#else
424-
rc = wc_InitCmac_ex(&ctx->cmacCtx, key, keyLen, WC_CMAC_AES, NULL);
424+
rc = wc_InitCmac_ex(&ctx->cmacCtx, key, (word32)keyLen, WC_CMAC_AES, NULL);
425425
#endif
426426
break;
427427
#endif
@@ -466,12 +466,12 @@ static int wp_kbkdf_mac_update(wp_KbkdfCtx* ctx, const unsigned char *data,
466466
switch(ctx->mac) {
467467
#ifdef WP_HAVE_HMAC
468468
case WP_MAC_TYPE_HMAC:
469-
rc = wc_HmacUpdate(&ctx->hmacCtx, data, dataLen);
469+
rc = wc_HmacUpdate(&ctx->hmacCtx, data, (word32)dataLen);
470470
break;
471471
#endif
472472
#ifdef WP_HAVE_CMAC
473473
case WP_MAC_TYPE_CMAC:
474-
rc = wc_CmacUpdate(&ctx->cmacCtx, data, dataLen);
474+
rc = wc_CmacUpdate(&ctx->cmacCtx, data, (word32)dataLen);
475475
break;
476476
#endif
477477
default:
@@ -487,6 +487,7 @@ static int wp_kbkdf_mac_update(wp_KbkdfCtx* ctx, const unsigned char *data,
487487

488488
static void wp_kbkdf_mac_free(wp_KbkdfCtx* ctx)
489489
{
490+
int ret = 0;
490491
switch(ctx->mac) {
491492
#ifdef WP_HAVE_HMAC
492493
case WP_MAC_TYPE_HMAC:
@@ -495,19 +496,22 @@ static void wp_kbkdf_mac_free(wp_KbkdfCtx* ctx)
495496
#endif
496497
#ifdef WP_HAVE_CMAC
497498
case WP_MAC_TYPE_CMAC:
498-
int ret = wc_CmacFree(&ctx->cmacCtx);
499-
(void)ret;
499+
ret = wc_CmacFree(&ctx->cmacCtx);
500500
break;
501501
#endif
502-
default:
503502
}
503+
504+
(void)ret;
504505
}
505506

506507
static int wp_kbkdf_mac_final(wp_KbkdfCtx* ctx, unsigned char *out,
507508
size_t *outLen, size_t outSize)
508509
{
509510
int ok = 1;
510511
int rc = 0;
512+
word32 outSz;
513+
514+
(void)outSz;
511515

512516
switch(ctx->mac) {
513517
#ifdef WP_HAVE_HMAC
@@ -523,7 +527,7 @@ static int wp_kbkdf_mac_final(wp_KbkdfCtx* ctx, unsigned char *out,
523527
#endif
524528
#ifdef WP_HAVE_CMAC
525529
case WP_MAC_TYPE_CMAC:
526-
word32 outSz = (word32)outSize;
530+
outSz = (word32)outSize;
527531
rc = wc_CmacFinal(&ctx->cmacCtx, out, &outSz);
528532
if (rc != 0) {
529533
ok = 0;
@@ -647,7 +651,7 @@ static int wp_kdf_kbkdf_derive(wp_KbkdfCtx* ctx, unsigned char* key,
647651
}
648652
/* result(i) := result(i-1) || K(i)
649653
* KO := the leftmost L bits of result(n) */
650-
toWrite = MIN(keyLen - written, k_i_len);
654+
toWrite = MIN((int)(keyLen - written), (int)k_i_len);
651655
XMEMCPY(key + written, k_i, toWrite);
652656
written += toWrite;
653657
wp_kbkdf_mac_free(ctx);

0 commit comments

Comments
 (0)