diff --git a/src/tls.c b/src/tls.c index 039096967e..4fc15e53cd 100644 --- a/src/tls.c +++ b/src/tls.c @@ -939,7 +939,7 @@ static int Hmac_UpdateFinal_CT(Hmac* hmac, byte* digest, const byte* in, int blockBits, blockMask; int lastBlockLen, extraLen, eocIndex; int blocks, safeBlocks, lenBlock, eocBlock; - unsigned int maxLen; + word32 maxLen; int blockSz, padSz; int ret; word32 realLen; @@ -992,29 +992,30 @@ static int Hmac_UpdateFinal_CT(Hmac* hmac, byte* digest, const byte* in, blockMask = blockSz - 1; /* Size of data to HMAC if padding length byte is zero. */ - maxLen = headerSz + sz - 1 - macLen; + maxLen = WOLFSSL_TLS_HMAC_INNER_SZ + sz - 1 - (word32)macLen; + /* Complete data (including padding) has block for EOC and/or length. */ - extraBlock = ctSetLTE((maxLen + padSz) & blockMask, padSz); + extraBlock = ctSetLTE(((int)maxLen + padSz) & blockMask, padSz); /* Total number of blocks for data including padding. */ - blocks = ((maxLen + blockSz - 1) >> blockBits) + extraBlock; + blocks = ((int)(maxLen + (word32)blockSz - 1) >> blockBits) + extraBlock; /* Up to last 6 blocks can be hashed safely. */ safeBlocks = blocks - 6; /* Length of message data. */ realLen = maxLen - in[sz - 1]; /* Number of message bytes in last block. */ - lastBlockLen = realLen & blockMask; + lastBlockLen = (int)realLen & blockMask; /* Number of padding bytes in last block. */ extraLen = ((blockSz * 2 - padSz - lastBlockLen) & blockMask) + 1; /* Number of blocks to create for hash. */ - lenBlock = (realLen + extraLen) >> blockBits; + lenBlock = ((int)realLen + extraLen) >> blockBits; /* Block containing EOC byte. */ - eocBlock = realLen >> blockBits; + eocBlock = (int)(realLen >> (word32)blockBits); /* Index of EOC byte in block. */ - eocIndex = realLen & blockMask; + eocIndex = (int)(realLen & (word32)blockMask); /* Add length of hmac's ipad to total length. */ - realLen += blockSz; + realLen += (word32)blockSz; /* Length as bits - 8 bytes bigendian. */ c32toa(realLen >> ((sizeof(word32) * 8) - 3), lenBytes); c32toa(realLen << 3, lenBytes + sizeof(word32)); @@ -1029,7 +1030,9 @@ static int Hmac_UpdateFinal_CT(Hmac* hmac, byte* digest, const byte* in, ret = Hmac_HashUpdate(hmac, header, headerSz); if (ret != 0) return ret; - ret = Hmac_HashUpdate(hmac, in, safeBlocks * blockSz - headerSz); + ret = Hmac_HashUpdate(hmac, in, (word32)(safeBlocks * blockSz - + WOLFSSL_TLS_HMAC_INNER_SZ)); + if (ret != 0) return ret; } @@ -1341,7 +1344,9 @@ int TLS_hmac(WOLFSSL* ssl, byte* digest, const byte* in, word32 sz, int padSz, #endif { ret = Hmac_UpdateFinal_CT(&hmac, digest, in, - sz + hashSz + padSz + 1, hashSz, myInner, innerSz); + (sz + hashSz + (word32)padSz + 1), + (int)hashSz, myInner, innerSz); + } #else ret = Hmac_UpdateFinal(&hmac, digest, in, sz + hashSz + padSz + 1, @@ -7726,7 +7731,7 @@ static int TLSX_KeyShare_GenEccKey(WOLFSSL *ssl, KeyShareEntry* kse) #endif { /* set curve info for EccMakeKey "peer" info */ - ret = wc_ecc_set_curve(eccKey, kse->keyLen, curveId); + ret = wc_ecc_set_curve(eccKey, (int)kse->keyLen, curveId); if (ret == 0) { #ifdef WOLFSSL_ASYNC_CRYPT /* Detect when private key generation is done */ @@ -12572,7 +12577,7 @@ static int TLSX_GetSize(TLSX* list, byte* semaphore, byte msgType, continue; /* skip! */ /* ssl level extensions are expected to override ctx level ones. */ - if (!IS_OFF(semaphore, TLSX_ToSemaphore(extension->type))) + if (!IS_OFF(semaphore, TLSX_ToSemaphore((word16)extension->type))) continue; /* skip! */ /* extension type + extension data length. */ @@ -12741,7 +12746,7 @@ static int TLSX_GetSize(TLSX* list, byte* semaphore, byte msgType, /* marks the extension as processed so ctx level */ /* extensions don't overlap with ssl level ones. */ - TURN_ON(semaphore, TLSX_ToSemaphore(extension->type)); + TURN_ON(semaphore, TLSX_ToSemaphore((word16)extension->type)); } *pLength += length; @@ -12768,11 +12773,11 @@ static int TLSX_Write(TLSX* list, byte* output, byte* semaphore, continue; /* skip! */ /* ssl level extensions are expected to override ctx level ones. */ - if (!IS_OFF(semaphore, TLSX_ToSemaphore(extension->type))) + if (!IS_OFF(semaphore, TLSX_ToSemaphore((word16)extension->type))) continue; /* skip! */ /* writes extension type. */ - c16toa(extension->type, output + offset); + c16toa((word16)extension->type, output + offset); offset += HELLO_EXT_TYPE_SZ + OPAQUE16_LEN; length_offset = offset; @@ -12995,7 +13000,7 @@ static int TLSX_Write(TLSX* list, byte* output, byte* semaphore, /* marks the extension as processed so ctx level */ /* extensions don't overlap with ssl level ones. */ - TURN_ON(semaphore, TLSX_ToSemaphore(extension->type)); + TURN_ON(semaphore, TLSX_ToSemaphore((word16)extension->type)); /* if we encountered an error propagate it */ if (ret != 0) diff --git a/src/tls13.c b/src/tls13.c index a4d3aab70d..17a4fd1af3 100644 --- a/src/tls13.c +++ b/src/tls13.c @@ -7028,7 +7028,7 @@ int DoTls13ClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, if (ret != 0) goto exit_dch; #else - if ((ret = HashInput(ssl, input + args->begin, helloSz)) != 0) + if ((ret = HashInput(ssl, input + args->begin, (int)helloSz)) != 0) goto exit_dch; #endif @@ -7472,7 +7472,7 @@ int SendTls13ServerHello(WOLFSSL* ssl, byte extMsgType) } #endif /* WOLFSSL_DTLS13 */ - ssl->buffers.outputBuffer.length += sendSz; + ssl->buffers.outputBuffer.length += (word32)sendSz; if (!ssl->options.groupMessages || extMsgType != server_hello) ret = SendBuffered(ssl); @@ -7620,11 +7620,12 @@ static int SendTls13EncryptedExtensions(WOLFSSL* ssl) /* This handshake message is always encrypted. */ sendSz = BuildTls13Message(ssl, output, sendSz, output + RECORD_HEADER_SZ, - idx - RECORD_HEADER_SZ, handshake, 1, 0, 0); + (int)(idx - RECORD_HEADER_SZ), + handshake, 1, 0, 0); if (sendSz < 0) return sendSz; - ssl->buffers.outputBuffer.length += sendSz; + ssl->buffers.outputBuffer.length += (word32)sendSz; ssl->options.buildingMsg = 0; ssl->options.serverState = SERVER_ENCRYPTED_EXTENSIONS_COMPLETE; @@ -7650,7 +7651,7 @@ static int SendTls13EncryptedExtensions(WOLFSSL* ssl) * returns 0 on success, otherwise failure. */ static int SendTls13CertificateRequest(WOLFSSL* ssl, byte* reqCtx, - int reqCtxLen) + word32 reqCtxLen) { byte* output; int ret; @@ -7738,7 +7739,7 @@ static int SendTls13CertificateRequest(WOLFSSL* ssl, byte* reqCtx, /* Always encrypted. */ sendSz = BuildTls13Message(ssl, output, sendSz, output + RECORD_HEADER_SZ, - i - RECORD_HEADER_SZ, handshake, 1, 0, 0); + (int)(i - RECORD_HEADER_SZ), handshake, 1, 0, 0); if (sendSz < 0) return sendSz; @@ -7753,7 +7754,7 @@ static int SendTls13CertificateRequest(WOLFSSL* ssl, byte* reqCtx, } #endif - ssl->buffers.outputBuffer.length += sendSz; + ssl->buffers.outputBuffer.length += (word32)sendSz; ssl->options.buildingMsg = 0; if (!ssl->options.groupMessages) ret = SendBuffered(ssl); @@ -8524,7 +8525,7 @@ static int SendTls13Certificate(WOLFSSL* ssl) certSz = 0; certChainSz = 0; headerSz = OPAQUE8_LEN + certReqCtxLen + CERT_HEADER_SZ; - length = headerSz; + length = (sword32)headerSz; listSz = 0; } else { @@ -8556,7 +8557,7 @@ static int SendTls13Certificate(WOLFSSL* ssl) } /* Length of message data with one certificate and extensions. */ - length = headerSz + certSz + extSz; + length = (sword32)(headerSz + certSz + extSz); /* Length of list data with one certificate and extensions. */ listSz = CERT_HEADER_SZ + certSz + extSz; @@ -8565,7 +8566,7 @@ static int SendTls13Certificate(WOLFSSL* ssl) p = ssl->buffers.certChain->buffer; /* Chain length including extensions. */ certChainSz = ssl->buffers.certChain->length + - OPAQUE16_LEN * ssl->buffers.certChainCnt; + OPAQUE16_LEN * (word32)ssl->buffers.certChainCnt; length += certChainSz; listSz += certChainSz; } @@ -8573,7 +8574,7 @@ static int SendTls13Certificate(WOLFSSL* ssl) certChainSz = 0; } - payloadSz = length; + payloadSz = (word32)length; if (ssl->fragOffset != 0) length -= (ssl->fragOffset + headerSz); @@ -8717,7 +8718,8 @@ static int SendTls13Certificate(WOLFSSL* ssl) { /* This message is always encrypted. */ sendSz = BuildTls13Message(ssl, output, sendSz, - output + RECORD_HEADER_SZ, i - RECORD_HEADER_SZ, handshake, 1, + output + RECORD_HEADER_SZ, (int)(i - RECORD_HEADER_SZ), + handshake, 1, 0, 0); if (sendSz < 0) return sendSz; @@ -8733,7 +8735,7 @@ static int SendTls13Certificate(WOLFSSL* ssl) } #endif - ssl->buffers.outputBuffer.length += sendSz; + ssl->buffers.outputBuffer.length += (word32)sendSz; ssl->options.buildingMsg = 0; if (!ssl->options.groupMessages) ret = SendBuffered(ssl); @@ -9168,7 +9170,8 @@ static int SendTls13CertificateVerify(WOLFSSL* ssl) #endif /* !NO_RSA */ #ifdef HAVE_ECC if (ssl->hsType == DYNAMIC_TYPE_ECC) { - args->sigLen = args->sendSz - args->idx - HASH_SIG_SIZE - + args->sigLen = (word32)args->sendSz - args->idx - + HASH_SIG_SIZE - VERIFY_HEADER; #if defined(WOLFSSL_SM2) && defined(WOLFSSL_SM3) if (ssl->buffers.keyType != sm2_sa_algo) @@ -9593,7 +9596,7 @@ static int SendTls13CertificateVerify(WOLFSSL* ssl) } #endif - ssl->buffers.outputBuffer.length += args->sendSz; + ssl->buffers.outputBuffer.length += (word32)args->sendSz; ssl->options.buildingMsg = 0; if (!ssl->options.groupMessages) ret = SendBuffered(ssl); @@ -10884,7 +10887,8 @@ static int SendTls13Finished(WOLFSSL* ssl) input = output + Dtls13GetRlHeaderLength(ssl, 1); #endif /* WOLFSSL_DTLS13 */ - AddTls13HandShakeHeader(input, (word32)finishedSz, 0, finishedSz, finished, ssl); + AddTls13HandShakeHeader(input, (word32)finishedSz, 0, (word32)finishedSz, + finished, ssl); #if defined(WOLFSSL_RENESAS_TSIP_TLS) if (ssl->options.side == WOLFSSL_CLIENT_END) { @@ -10969,7 +10973,7 @@ static int SendTls13Finished(WOLFSSL* ssl) } #endif - ssl->buffers.outputBuffer.length += sendSz; + ssl->buffers.outputBuffer.length += (word32)sendSz; ssl->options.buildingMsg = 0; } @@ -11178,7 +11182,7 @@ static int SendTls13KeyUpdate(WOLFSSL* ssl) } #endif - ssl->buffers.outputBuffer.length += sendSz; + ssl->buffers.outputBuffer.length += (word32)sendSz; ret = SendBuffered(ssl); diff --git a/tests/api.c b/tests/api.c index 4821345cff..f7352eed6f 100644 --- a/tests/api.c +++ b/tests/api.c @@ -2671,7 +2671,7 @@ static int test_cm_load_ca_buffer(const byte* cert_buf, size_t cert_sz, return -1; } - ret = wolfSSL_CertManagerLoadCABuffer(cm, cert_buf, cert_sz, file_type); + ret = wolfSSL_CertManagerLoadCABuffer(cm, cert_buf, (sword32)cert_sz, file_type); wolfSSL_CertManagerFree(cm); @@ -2710,7 +2710,8 @@ static int test_cm_load_ca_file(const char* ca_cert_file) #if defined(WOLFSSL_PEM_TO_DER) if (ret == WOLFSSL_SUCCESS) { /* test loading DER */ - ret = wc_PemToDer(cert_buf, cert_sz, CA_TYPE, &pDer, NULL, NULL, NULL); + ret = wc_PemToDer(cert_buf, (sword32)cert_sz, CA_TYPE, &pDer, + NULL, NULL, NULL); if (ret == 0 && pDer != NULL) { ret = test_cm_load_ca_buffer(pDer->buffer, pDer->length, WOLFSSL_FILETYPE_ASN1); @@ -2738,7 +2739,7 @@ static int test_cm_load_ca_buffer_ex(const byte* cert_buf, size_t cert_sz, return -1; } - ret = wolfSSL_CertManagerLoadCABuffer_ex(cm, cert_buf, cert_sz, file_type, + ret = wolfSSL_CertManagerLoadCABuffer_ex(cm, cert_buf, (sword32)cert_sz, file_type, 0, flags); wolfSSL_CertManagerFree(cm); @@ -2779,7 +2780,8 @@ static int test_cm_load_ca_file_ex(const char* ca_cert_file, word32 flags) #if defined(WOLFSSL_PEM_TO_DER) if (ret == WOLFSSL_SUCCESS) { /* test loading DER */ - ret = wc_PemToDer(cert_buf, cert_sz, CA_TYPE, &pDer, NULL, NULL, NULL); + ret = wc_PemToDer(cert_buf, (sword32)cert_sz, CA_TYPE, &pDer, + NULL, NULL, NULL); if (ret == 0 && pDer != NULL) { ret = test_cm_load_ca_buffer_ex(pDer->buffer, pDer->length, WOLFSSL_FILETYPE_ASN1, flags); @@ -5048,13 +5050,13 @@ static int test_wolfSSL_CTX_use_certificate_chain_buffer_format(void) WC_NO_ERR_TRACE(BAD_FUNC_ARG)); ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer(ctx, NULL, 0), WC_NO_ERR_TRACE(ASN_NO_PEM_HEADER)); - ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer(NULL, buf, (long)len), + ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer(NULL, buf, (sword32)len), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); ExpectIntEQ(wolfSSL_use_certificate_chain_buffer(NULL, NULL, 0), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); ExpectIntEQ(wolfSSL_use_certificate_chain_buffer(ssl, NULL, 0), WC_NO_ERR_TRACE(ASN_NO_PEM_HEADER)); - ExpectIntEQ(wolfSSL_use_certificate_chain_buffer(NULL, buf, (long)len), + ExpectIntEQ(wolfSSL_use_certificate_chain_buffer(NULL, buf, (sword32)len), WC_NO_ERR_TRACE(BAD_FUNC_ARG)); ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer_format(ctx, @@ -5062,14 +5064,14 @@ static int test_wolfSSL_CTX_use_certificate_chain_buffer_format(void) WOLFSSL_FILETYPE_ASN1), WOLFSSL_SUCCESS); ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer_format(ctx, buf, - (long)len, WOLFSSL_FILETYPE_PEM), WOLFSSL_SUCCESS); + (sword32)len, WOLFSSL_FILETYPE_PEM), WOLFSSL_SUCCESS); - ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer(ctx, buf, (long)len), + ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer(ctx, buf, (sword32)len), WOLFSSL_SUCCESS); ExpectIntEQ(wolfSSL_CTX_use_certificate_chain_buffer(ctx, server_cert_der_2048, sizeof_server_cert_der_2048), WC_NO_ERR_TRACE(ASN_NO_PEM_HEADER)); - ExpectIntEQ(wolfSSL_use_certificate_chain_buffer(ssl, buf, (long)len), + ExpectIntEQ(wolfSSL_use_certificate_chain_buffer(ssl, buf, (sword32)len), WOLFSSL_SUCCESS); ExpectIntEQ(wolfSSL_use_certificate_chain_buffer(ssl, server_cert_der_2048, sizeof_server_cert_der_2048), WC_NO_ERR_TRACE(ASN_NO_PEM_HEADER)); @@ -7512,7 +7514,7 @@ static int test_ssl_memio_do_handshake(test_ssl_memio_ctx* ctx, int max_rounds, err != WOLFSSL_ERROR_WANT_WRITE) { char buff[WOLFSSL_MAX_ERROR_SZ]; fprintf(stderr, "error = %d, %s\n", err, - wolfSSL_ERR_error_string(err, buff)); + wolfSSL_ERR_error_string((word32)err, buff)); failing_c = 1; hs_c = 1; if (failing_c && failing_s) { @@ -7534,7 +7536,7 @@ static int test_ssl_memio_do_handshake(test_ssl_memio_ctx* ctx, int max_rounds, err != WOLFSSL_ERROR_WANT_WRITE) { char buff[WOLFSSL_MAX_ERROR_SZ]; fprintf(stderr, "error = %d, %s\n", err, - wolfSSL_ERR_error_string(err, buff)); + wolfSSL_ERR_error_string((word32)err, buff)); failing_s = 1; hs_s = 1; if (failing_c && failing_s) { @@ -8051,7 +8053,7 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_nofail(void* args) if (ret != WOLFSSL_SUCCESS) { char buff[WOLFSSL_MAX_ERROR_SZ]; fprintf(stderr, "error = %d, %s\n", err, - wolfSSL_ERR_error_string(err, buff)); + wolfSSL_ERR_error_string((word32)err, buff)); /*err_sys("SSL_accept failed");*/ goto done; } @@ -8499,7 +8501,7 @@ static int test_client_nofail(void* args, cbType cb) if (ret != WOLFSSL_SUCCESS) { char buff[WOLFSSL_MAX_ERROR_SZ]; fprintf(stderr, "error = %d, %s\n", err, - wolfSSL_ERR_error_string(err, buff)); + wolfSSL_ERR_error_string((word32)err, buff)); /*err_sys("SSL_connect failed");*/ goto done; } @@ -8509,7 +8511,7 @@ static int test_client_nofail(void* args, cbType cb) cipherSuite = wolfSSL_get_current_cipher_suite(ssl); cipherName1 = wolfSSL_get_cipher_name(ssl); cipherName2 = wolfSSL_get_cipher_name_from_suite( - (cipherSuite >> 8), cipherSuite & 0xFF); + (byte)(cipherSuite >> 8), cipherSuite & 0xFF); AssertStrEQ(cipherName1, cipherName2); /* IANA Cipher Suites Names */ @@ -8522,7 +8524,7 @@ static int test_client_nofail(void* args, cbType cb) #if !defined(WOLFSSL_CIPHER_INTERNALNAME) && !defined(NO_ERROR_STRINGS) && \ !defined(WOLFSSL_QT) cipherName1 = wolfSSL_get_cipher_name_iana_from_suite( - (cipherSuite >> 8), cipherSuite & 0xFF); + (byte)(cipherSuite >> 8), cipherSuite & 0xFF); AssertStrEQ(cipherName1, cipherName2); #endif @@ -9069,7 +9071,7 @@ static THREAD_RETURN WOLFSSL_THREAD run_wolfssl_server(void* args) if (ret != WOLFSSL_SUCCESS) { char buff[WOLFSSL_MAX_ERROR_SZ]; fprintf(stderr, "accept error = %d, %s\n", err, - wolfSSL_ERR_error_string(err, buff)); + wolfSSL_ERR_error_string((word32)err, buff)); /*err_sys("SSL_accept failed");*/ } else { @@ -9287,7 +9289,7 @@ static void run_wolfssl_client(void* args) if (ret != WOLFSSL_SUCCESS) { char buff[WOLFSSL_MAX_ERROR_SZ]; fprintf(stderr, "error = %d, %s\n", err, - wolfSSL_ERR_error_string(err, buff)); + wolfSSL_ERR_error_string((word32)err, buff)); /*err_sys("SSL_connect failed");*/ } else { @@ -11356,8 +11358,8 @@ static int test_wolfSSL_UseSNI_params(void) ExpectIntNE(WOLFSSL_SUCCESS, wolfSSL_CTX_UseSNI(NULL, 0, "ctx", 3)); ExpectIntNE(WOLFSSL_SUCCESS, wolfSSL_UseSNI( NULL, 0, "ssl", 3)); /* invalid type */ - ExpectIntNE(WOLFSSL_SUCCESS, wolfSSL_CTX_UseSNI(ctx, -1, "ctx", 3)); - ExpectIntNE(WOLFSSL_SUCCESS, wolfSSL_UseSNI( ssl, -1, "ssl", 3)); + ExpectIntNE(WOLFSSL_SUCCESS, wolfSSL_CTX_UseSNI(ctx, (byte)-1, "ctx", 3)); + ExpectIntNE(WOLFSSL_SUCCESS, wolfSSL_UseSNI( ssl, (byte)-1, "ssl", 3)); /* invalid data */ ExpectIntNE(WOLFSSL_SUCCESS, wolfSSL_CTX_UseSNI(ctx, 0, NULL, 3)); ExpectIntNE(WOLFSSL_SUCCESS, wolfSSL_UseSNI( ssl, 0, NULL, 3)); @@ -12658,7 +12660,7 @@ static int BufferInfoRecv(WOLFSSL* ssl, char* buf, int sz, void* ctx) XMEMCPY(buf, msg->buffer, len); /* Move over returned data. */ msg->buffer += len; - msg->length -= len; + msg->length -= (word32)len; /* Amount actually copied. */ return len; @@ -19139,7 +19141,7 @@ static int test_wc_Chacha_Process(void) ExpectIntEQ(wc_Chacha_Process(&enc, cipher, (byte*)input, (word32)inlen), 0); ExpectIntEQ(wc_Chacha_Process(&dec, plain, cipher, (word32)inlen), 0); - ExpectIntEQ(XMEMCMP(input, plain, (int)inlen), 0); + ExpectIntEQ(XMEMCMP(input, plain, inlen), 0); #if !defined(USE_INTEL_CHACHA_SPEEDUP) && !defined(WOLFSSL_ARMASM) /* test checking and using leftovers, currently just in C code */ @@ -19154,7 +19156,7 @@ static int test_wc_Chacha_Process(void) (word32)inlen - 2), 0); ExpectIntEQ(wc_Chacha_Process(&dec, cipher + (inlen - 2), (byte*)input + (inlen - 2), 2), 0); - ExpectIntEQ(XMEMCMP(input, plain, (int)inlen), 0); + ExpectIntEQ(XMEMCMP(input, plain, inlen), 0); /* check edge cases with counter increment */ { @@ -19201,7 +19203,7 @@ static int test_wc_Chacha_Process(void) int i; for (i = 0; i < 256; i++) - input2[i] = i; + input2[i] = (byte)i; ExpectIntEQ(wc_Chacha_SetIV(&enc, iv2, 0), 0); @@ -20661,8 +20663,8 @@ static int test_wc_RsaPublicKeyDecodeRaw(void) RsaKey key; const byte n = 0x23; const byte e = 0x03; - int nSz = sizeof(n); - int eSz = sizeof(e); + word32 nSz = sizeof(n); + word32 eSz = sizeof(e); ExpectIntEQ(wc_InitRsaKey(&key, HEAP_HINT), 0); ExpectIntEQ(wc_RsaPublicKeyDecodeRaw(&n, nSz, &e, eSz, &key), 0); @@ -54933,7 +54935,7 @@ static int test_wc_PemToDer(void) ExpectIntEQ(load_file(ecc_private_key, &cert_buf, &cert_sz), 0); key_buf[0] = '\n'; ExpectNotNull(XMEMCPY(key_buf + 1, cert_buf, cert_sz)); - ExpectIntNE((ret = wc_PemToDer(key_buf, cert_sz + 1, CERT_TYPE, + ExpectIntNE((ret = wc_PemToDer(key_buf, (long int)cert_sz + 1, CERT_TYPE, &pDer, NULL, &info, &eccKey)), 0); #ifdef OPENSSL_EXTRA @@ -64795,7 +64797,7 @@ static int test_wolfSSL_MD4(void) XMEMSET(out, 0, sizeof(out)); MD4_Init(&md4); - MD4_Update(&md4, (const void*)msg, (unsigned long)msgSz); + MD4_Update(&md4, (const void*)msg, (word32)msgSz); MD4_Final(out, &md4); ExpectIntEQ(XMEMCMP(out, test, sizeof(out)), 0); #endif @@ -73363,9 +73365,9 @@ static int test_wolfSSL_OBJ_sn(void) } #if !defined(NO_BIO) -static unsigned long TXT_DB_hash(const WOLFSSL_STRING *s) +static word32 TXT_DB_hash(const WOLFSSL_STRING *s) { - return lh_strhash(s[3]); + return (word32)lh_strhash(s[3]); } static int TXT_DB_cmp(const WOLFSSL_STRING *a, const WOLFSSL_STRING *b) @@ -73413,7 +73415,8 @@ static int test_wolfSSL_TXT_DB(void) BIO_free(bio); /* Test index */ - ExpectIntEQ(TXT_DB_create_index(db, 3, NULL, (wolf_sk_hash_cb)TXT_DB_hash, + ExpectIntEQ(TXT_DB_create_index(db, 3, NULL, + (wolf_sk_hash_cb)(long unsigned int)TXT_DB_hash, (wolf_lh_compare_cb)TXT_DB_cmp), 1); ExpectNotNull(TXT_DB_get_by_index(db, 3, (WOLFSSL_STRING*)fields)); fields[3] = "12DA"; @@ -75429,7 +75432,7 @@ static int test_wc_ParseCert_Error(void) /* Test data */ const struct testStruct { const byte* c; - const int cSz; + word32 cSz; const int expRet; } t[] = { {c0, sizeof(c0), WC_NO_ERR_TRACE(ASN_PARSE_E)}, /* Invalid bit-string length */ @@ -81239,7 +81242,7 @@ static int test_ForceZero(void) for (i = 0; i < sizeof(data); i++) { for (len = 1; len < sizeof(data) - i; len++) { for (j = 0; j < sizeof(data); j++) - data[j] = j + 1; + data[j] = ((unsigned char)j + 1); ForceZero(data + i, len); @@ -86904,7 +86907,7 @@ static int load_ca_into_cm(WOLFSSL_CERT_MANAGER* cm, char* certA) if ((ret = wolfSSL_CertManagerLoadCA(cm, certA, 0)) != WOLFSSL_SUCCESS) { fprintf(stderr, "loading cert %s failed\n", certA); fprintf(stderr, "Error: (%d): %s\n", ret, - wolfSSL_ERR_reason_error_string(ret)); + wolfSSL_ERR_reason_error_string((word32)ret)); return -1; } @@ -86918,7 +86921,7 @@ static int verify_cert_with_cm(WOLFSSL_CERT_MANAGER* cm, char* certA) != WOLFSSL_SUCCESS) { fprintf(stderr, "could not verify the cert: %s\n", certA); fprintf(stderr, "Error: (%d): %s\n", ret, - wolfSSL_ERR_reason_error_string(ret)); + wolfSSL_ERR_reason_error_string((word32)ret)); return -1; } else { @@ -87197,7 +87200,7 @@ static int test_wolfSSL_THREADID_hash(void) CRYPTO_THREADID id; CRYPTO_THREADID_current(NULL); - /* Hash result is unsigned long. */ + /* Hash result is word32. */ ExpectTrue(CRYPTO_THREADID_hash(NULL) == 0UL); XMEMSET(&id, 0, sizeof(id)); ExpectTrue(CRYPTO_THREADID_hash(&id) == 0UL); @@ -88231,7 +88234,7 @@ static int error_test(void) break; } } - errStr = wolfSSL_ERR_reason_error_string(i); + errStr = wolfSSL_ERR_reason_error_string((word32)i); if (! this_missing) { ExpectIntNE(XSTRCMP(errStr, unknownStr), 0); @@ -88279,10 +88282,10 @@ static int test_wolfSSL_ERR_strings(void) ExpectNotNull(err = ERR_lib_error_string(PEM_R_PROBLEMS_GETTING_PASSWORD)); ExpectIntEQ(XSTRNCMP(err, err2, XSTRLEN(err2)), 0); #else - ExpectNotNull(err = wolfSSL_ERR_reason_error_string(WC_NO_ERR_TRACE(UNSUPPORTED_SUITE))); + ExpectNotNull(err = wolfSSL_ERR_reason_error_string(WC_NO_ERR_TRACE((word32)UNSUPPORTED_SUITE))); ExpectIntEQ(XSTRNCMP(err, err1, XSTRLEN(err1)), 0); - ExpectNotNull(err = wolfSSL_ERR_func_error_string(WC_NO_ERR_TRACE(UNSUPPORTED_SUITE))); + ExpectNotNull(err = wolfSSL_ERR_func_error_string(WC_NO_ERR_TRACE((word32)UNSUPPORTED_SUITE))); ExpectIntEQ((*err == '\0'), 1); /* The value -MIN_CODE_E+2 is PEM_R_PROBLEMS_GETTING_PASSWORD. */ @@ -92326,7 +92329,7 @@ static int test_short_session_id_ssl_ready(WOLFSSL* ssl) EXPECT_DECLS; WOLFSSL_SESSION *sess = NULL; /* Setup the session to avoid errors */ - ssl->session->timeout = -1; + ssl->session->timeout = (word32)-1; ssl->session->side = WOLFSSL_CLIENT_END; #if defined(SESSION_CERTS) || (defined(WOLFSSL_TLS13) && \ defined(HAVE_SESSION_TICKET)) @@ -94990,7 +94993,7 @@ static int test_tls_multi_handshakes_one_record(void) } rh = (RecordLayerHeader*)(test_ctx.c_buff); len = &rh->length[0]; - c16toa(newRecIdx - RECORD_HEADER_SZ, len); + c16toa((word16)newRecIdx - RECORD_HEADER_SZ, len); test_ctx.c_len = newRecIdx; ExpectIntEQ(wolfSSL_connect(ssl_c), -1); diff --git a/tests/unit.h b/tests/unit.h index 63825bc237..87e80ce847 100644 --- a/tests/unit.h +++ b/tests/unit.h @@ -243,7 +243,7 @@ const byte* _x = (const byte*)(x); \ const byte* _y = (const byte*)(y); \ int _z = (int)(z); \ - int _w = ((_x) && (_y)) ? XMEMCMP(_x, _y, _z) : -1; \ + int _w = ((_x) && (_y)) ? XMEMCMP(_x, _y, (unsigned long)_z) : -1; \ Expect(_w op 0, ("%s " #op " %s for %s", #x, #y, #z), \ ("\"%p\" " #er " \"%p\" for \"%d\"", \ (const void *)_x, (const void *)_y, _z)); \ diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index df2a14534c..fa2e64b136 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -4127,7 +4127,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t sha512_test(void) /* Unaligned memory access test */ for (i = 1; i < 16; i++) { ret = wc_Sha512Update(&sha, (byte*)large_input + i, - LARGE_HASH_TEST_INPUT_SZ - i); + LARGE_HASH_TEST_INPUT_SZ - (word32)i); if (ret != 0) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit); ret = wc_Sha512Final(&sha, hash); @@ -4285,7 +4285,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t sha512_224_test(void) /* Unaligned memory access test */ for (i = 1; i < 16; i++) { ret = wc_Sha512_224Update(&sha, (byte*)large_input + i, - (word32)sizeof(large_input) - i); + (word32)sizeof(large_input) - (word32)i); if (ret != 0) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit); ret = wc_Sha512_224Final(&sha, hash); @@ -4438,7 +4438,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t sha512_256_test(void) /* Unaligned memory access test */ for (i = 1; i < 16; i++) { ret = wc_Sha512_256Update(&sha, (byte*)large_input + i, - (word32)sizeof(large_input) - i); + (word32)sizeof(large_input) - (word32)i); if (ret != 0) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit); ret = wc_Sha512_256Final(&sha, hash); @@ -6020,14 +6020,14 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hash_test(void) return WC_TEST_RET_ENC_I(i); if (exp_ret == 0) { ret = wc_Hash(typesGood[i], data, sizeof(data), hashOut, - digestSz - 1); + (word32)digestSz - 1); if (ret != WC_NO_ERR_TRACE(BUFFER_E)) return WC_TEST_RET_ENC_I(i); } ret = wc_Hash(typesGood[i], data, sizeof(data), hashOut, (word32)digestSz); if (ret != exp_ret) return WC_TEST_RET_ENC_I(i); - if (exp_ret == 0 && XMEMCMP(out, hashOut, digestSz) != 0) + if (exp_ret == 0 && XMEMCMP(out, hashOut, (word32)digestSz) != 0) return WC_TEST_RET_ENC_I(i); ret = wc_HashGetBlockSize(typesGood[i]); @@ -7825,10 +7825,10 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t chacha_test(void) if (ret != 0) return ret; - if (XMEMCMP(plain_big, input_big, block_size)) + if (XMEMCMP(plain_big, input_big, (word32)block_size)) return WC_TEST_RET_ENC_I(i); - if (XMEMCMP(cipher_big, cipher_big_result, block_size)) + if (XMEMCMP(cipher_big, cipher_big_result, (word32)block_size)) return WC_TEST_RET_ENC_I(i); } @@ -14618,18 +14618,18 @@ static wc_test_ret_t aesgcm_default_test_helper(byte* key, int keySz, byte* iv, ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); /* AES-GCM encrypt and decrypt both use AES encrypt internally */ - ret = wc_AesGcmEncrypt(enc, resultC, plain, (word32)plainSz, iv, ivSz, - resultT, (word32)tagSz, aad, aadSz); + ret = wc_AesGcmEncrypt(enc, resultC, plain, (word32)plainSz, iv, (word32)ivSz, + resultT, (word32)tagSz, aad, (word32)aadSz); #if defined(WOLFSSL_ASYNC_CRYPT) ret = wc_AsyncWait(ret, &enc->asyncDev, WC_ASYNC_FLAG_NONE); #endif if (ret != 0) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); if (cipher != NULL) { - if (XMEMCMP(cipher, resultC, cipherSz)) + if (XMEMCMP(cipher, resultC, (word32)cipherSz)) ERROR_OUT(WC_TEST_RET_ENC_NC, out); } - if (XMEMCMP(tag, resultT, tagSz)) + if (XMEMCMP(tag, resultT, (unsigned long)tagSz)) ERROR_OUT(WC_TEST_RET_ENC_NC, out); #if defined(DEBUG_VECTOR_REGISTER_ACCESS) && defined(WC_C_DYNAMIC_FALLBACK) @@ -14643,7 +14643,7 @@ static wc_test_ret_t aesgcm_default_test_helper(byte* key, int keySz, byte* iv, if (ret != 0) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); if (cipher != NULL) { - if (XMEMCMP(cipher, resultC, cipherSz)) + if (XMEMCMP(cipher, resultC, (unsigned long)cipherSz)) ERROR_OUT(WC_TEST_RET_ENC_NC, out); } if (XMEMCMP(tag, resultT, tagSz)) @@ -14656,14 +14656,14 @@ static wc_test_ret_t aesgcm_default_test_helper(byte* key, int keySz, byte* iv, ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); ret = wc_AesGcmDecrypt(dec, resultP, resultC, (word32)cipherSz, - iv, (word32)ivSz, resultT, tagSz, aad, aadSz); + iv, (word32)ivSz, resultT, (word32)tagSz, aad, (word32)aadSz); #if defined(WOLFSSL_ASYNC_CRYPT) ret = wc_AsyncWait(ret, &dec->asyncDev, WC_ASYNC_FLAG_NONE); #endif if (ret != 0) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); if (plain != NULL) { - if (XMEMCMP(plain, resultP, plainSz)) + if (XMEMCMP(plain, resultP, (unsigned long)plainSz)) ERROR_OUT(WC_TEST_RET_ENC_NC, out); } @@ -14678,7 +14678,7 @@ static wc_test_ret_t aesgcm_default_test_helper(byte* key, int keySz, byte* iv, if (ret != 0) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); if (plain != NULL) { - if (XMEMCMP(plain, resultP, plainSz)) + if (XMEMCMP(plain, resultP, (unsigned long)plainSz)) ERROR_OUT(WC_TEST_RET_ENC_NC, out); } #endif @@ -17873,7 +17873,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t random_test(void) #endif #if defined(WOLFSSL_STATIC_MEMORY) || !defined(WOLFSSL_NO_MALLOC) -static int simple_mem_test(int sz) +static int simple_mem_test(size_t sz) { int ret = 0; byte* b; @@ -17884,11 +17884,11 @@ static int simple_mem_test(int sz) return WC_TEST_RET_ENC_NC; } /* utilize memory */ - for (i = 0; i < sz; i++) { + for (i = 0; i < (int)sz; i++) { b[i] = (byte)i; } /* read back and verify */ - for (i = 0; i < sz; i++) { + for (i = 0; i < (int)sz; i++) { if (b[i] != (byte)i) { ret = WC_TEST_RET_ENC_NC; break; @@ -18048,7 +18048,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t memory_test(void) #if defined(WOLFSSL_STATIC_MEMORY) || !defined(WOLFSSL_NO_MALLOC) /* simple test */ - ret = simple_mem_test(MEM_TEST_SZ); + ret = simple_mem_test((size_t)MEM_TEST_SZ); if (ret != 0) return ret; #endif @@ -18056,7 +18056,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t memory_test(void) #ifdef COMPLEX_MEM_TEST /* test various size blocks */ for (i = 1; i < MEM_TEST_SZ; i*=2) { - ret = simple_mem_test(i); + ret = simple_mem_test((size_t)i); if (ret != 0) return ret; } @@ -19958,7 +19958,7 @@ static wc_test_ret_t rsa_pss_test(WC_RNG* rng, RsaKey* key) #endif if (ret >= 0) { ret = wc_RsaPSS_Sign_ex(digest, digestSz, out, outSz, hash[0], - mgf[0], digestSz + 1, key, rng); + mgf[0], (int)digestSz + 1, key, rng); } } while (ret == WC_NO_ERR_TRACE(WC_PENDING_E)); if (ret != WC_NO_ERR_TRACE(PSS_SALTLEN_E)) @@ -19986,7 +19986,7 @@ static wc_test_ret_t rsa_pss_test(WC_RNG* rng, RsaKey* key) #endif if (ret >= 0) { ret = wc_RsaPSS_VerifyInline_ex(sig, outSz, &plain, hash[0], mgf[0], - digestSz + 1, key); + (int)digestSz + 1, key); } } while (ret == WC_NO_ERR_TRACE(WC_PENDING_E)); if (ret != WC_NO_ERR_TRACE(PSS_SALTLEN_E)) @@ -26664,7 +26664,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t pkcs12_pbkdf_test(void) if (ret < 0) return WC_TEST_RET_ENC_EC(ret); - if (XMEMCMP(derived, verify, kLen) != 0) + if (XMEMCMP(derived, verify, (unsigned long)kLen) != 0) return WC_TEST_RET_ENC_NC; iterations = 1000; @@ -26949,7 +26949,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hkdf_test(void) if (ret != 0) return WC_TEST_RET_ENC_EC(ret); - if (XMEMCMP(okm1, res1, L) != 0) + if (XMEMCMP(okm1, res1, (unsigned long)L) != 0) return WC_TEST_RET_ENC_NC; #ifndef HAVE_FIPS @@ -26960,7 +26960,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hkdf_test(void) if (ret != 0) return WC_TEST_RET_ENC_EC(ret); - if (XMEMCMP(okm1, res2, L) != 0) + if (XMEMCMP(okm1, res2, (unsigned long)L) != 0) return WC_TEST_RET_ENC_NC; #endif /* HAVE_FIPS */ #endif /* !NO_SHA */ @@ -26971,7 +26971,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hkdf_test(void) if (ret != 0) return WC_TEST_RET_ENC_EC(ret); - if (XMEMCMP(okm1, res3, L) != 0) + if (XMEMCMP(okm1, res3, (unsigned long)L) != 0) return WC_TEST_RET_ENC_NC; #ifndef HAVE_FIPS @@ -26981,7 +26981,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hkdf_test(void) if (ret != 0) return WC_TEST_RET_ENC_EC(ret); - if (XMEMCMP(okm1, res4, L) != 0) + if (XMEMCMP(okm1, res4, (unsigned long)L) != 0) return WC_TEST_RET_ENC_NC; #endif /* HAVE_FIPS */ #endif /* !NO_SHA256 */ @@ -27188,7 +27188,8 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t prf_test(void) int lblsdL = LBSL; int hash_type = sha384_mac; - ret = wc_PRF(dig, (word32)digL, secret, secL, lablSd, lblsdL, hash_type, + ret = wc_PRF(dig, (word32)digL, secret, (word32)secL, lablSd, + (word32)lblsdL, hash_type, HEAP_HINT, INVALID_DEVID); if (ret != 0) { printf("Failed w/ code: %d\n", ret); @@ -27839,111 +27840,117 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t tls13_kdf_test(void) ret = wc_Tls13_HKDF_Extract(secret, NULL, 0, (tv->pskSz == 0) ? zeroes : (byte*)tv->psk, - tv->pskSz, tv->hashAlg); + tv->pskSz, (int)tv->hashAlg); if (ret != 0) break; ret = wc_Tls13_HKDF_Expand_Label(output, (word32)hashAlgSz, secret, (word32)hashAlgSz, (byte*)protocolLabel, (word32)XSTRLEN(protocolLabel), (byte*)ceTrafficLabel, (word32)XSTRLEN(ceTrafficLabel), - tv->hashHello1, (word32)hashAlgSz, tv->hashAlg); + tv->hashHello1, (word32)hashAlgSz, (int)tv->hashAlg); if (ret != 0) break; - ret = XMEMCMP(tv->clientEarlyTrafficSecret, output, hashAlgSz); + ret = XMEMCMP(tv->clientEarlyTrafficSecret, output, + (unsigned long)hashAlgSz); if (ret != 0) break; ret = wc_Tls13_HKDF_Expand_Label(output, (word32)hashAlgSz, secret, (word32)hashAlgSz, (byte*)protocolLabel, (word32)XSTRLEN(protocolLabel), (byte*)eExpMasterLabel, (word32)XSTRLEN(eExpMasterLabel), - tv->hashHello1, (word32)hashAlgSz, tv->hashAlg); + tv->hashHello1, (word32)hashAlgSz, (int)tv->hashAlg); if (ret != 0) break; - ret = XMEMCMP(tv->earlyExporterMasterSecret, output, hashAlgSz); + ret = XMEMCMP(tv->earlyExporterMasterSecret, output, + (unsigned long)hashAlgSz); if (ret != 0) break; ret = wc_Tls13_HKDF_Expand_Label(salt, (word32)hashAlgSz, secret, (word32)hashAlgSz, (byte*)protocolLabel, (word32)XSTRLEN(protocolLabel), (byte*)derivedLabel, (word32)XSTRLEN(derivedLabel), - hashZero, (word32)hashAlgSz, tv->hashAlg); + hashZero, (word32)hashAlgSz, (int)tv->hashAlg); if (ret != 0) break; ret = wc_Tls13_HKDF_Extract(secret, salt, (word32)(word32)hashAlgSz, (tv->dheSz == 0) ? zeroes : (byte*)tv->dhe, - tv->dheSz, tv->hashAlg); + tv->dheSz, (int)tv->hashAlg); if (ret != 0) break; ret = wc_Tls13_HKDF_Expand_Label(output, (word32)hashAlgSz, secret, (word32)hashAlgSz, (byte*)protocolLabel, (word32)XSTRLEN(protocolLabel), (byte*)cHsTrafficLabel, (word32)XSTRLEN(cHsTrafficLabel), - tv->hashHello2, (word32)hashAlgSz, tv->hashAlg); + tv->hashHello2, (word32)hashAlgSz, (int)tv->hashAlg); if (ret != 0) break; ret = XMEMCMP(tv->clientHandshakeTrafficSecret, - output, hashAlgSz); + output, (unsigned long)hashAlgSz); if (ret != 0) break; ret = wc_Tls13_HKDF_Expand_Label(output, (word32)hashAlgSz, secret, (word32)hashAlgSz, (byte*)protocolLabel, (word32)XSTRLEN(protocolLabel), (byte*)sHsTrafficLabel, (word32)XSTRLEN(sHsTrafficLabel), - tv->hashHello2, (word32)hashAlgSz, tv->hashAlg); + tv->hashHello2, (word32)hashAlgSz, (int)tv->hashAlg); if (ret != 0) break; - ret = XMEMCMP(tv->serverHandshakeTrafficSecret, output, hashAlgSz); + ret = XMEMCMP(tv->serverHandshakeTrafficSecret, output, + (unsigned long)hashAlgSz); if (ret != 0) break; ret = wc_Tls13_HKDF_Expand_Label(salt, (word32)hashAlgSz, secret, (word32)hashAlgSz, (byte*)protocolLabel, (word32)XSTRLEN(protocolLabel), (byte*)derivedLabel, (word32)XSTRLEN(derivedLabel), - hashZero, (word32)hashAlgSz, tv->hashAlg); + hashZero, (word32)hashAlgSz, (int)tv->hashAlg); if (ret != 0) break; ret = wc_Tls13_HKDF_Extract(secret, salt, (word32)(word32)hashAlgSz, - zeroes, (word32)(word32)hashAlgSz, tv->hashAlg); + zeroes, (word32)(word32)hashAlgSz, (int)tv->hashAlg); if (ret != 0) break; ret = wc_Tls13_HKDF_Expand_Label(output, (word32)hashAlgSz, secret, (word32)hashAlgSz, (byte*)protocolLabel, (word32)XSTRLEN(protocolLabel), (byte*)cAppTrafficLabel, (word32)XSTRLEN(cAppTrafficLabel), - tv->hashFinished1, (word32)hashAlgSz, tv->hashAlg); + tv->hashFinished1, (word32)hashAlgSz, (int)tv->hashAlg); if (ret != 0) break; - ret = XMEMCMP(tv->clientApplicationTrafficSecret, output, hashAlgSz); + ret = XMEMCMP(tv->clientApplicationTrafficSecret, output, + (unsigned long)hashAlgSz); if (ret != 0) break; ret = wc_Tls13_HKDF_Expand_Label(output, (word32)hashAlgSz, secret, (word32)hashAlgSz, (byte*)protocolLabel, (word32)XSTRLEN(protocolLabel), (byte*)sAppTrafficLabel, (word32)XSTRLEN(sAppTrafficLabel), - tv->hashFinished1, (word32)hashAlgSz, tv->hashAlg); + tv->hashFinished1, (word32)hashAlgSz, (int)tv->hashAlg); if (ret != 0) break; - ret = XMEMCMP(tv->serverApplicationTrafficSecret, output, hashAlgSz); + ret = XMEMCMP(tv->serverApplicationTrafficSecret, output, + (unsigned long)hashAlgSz); if (ret != 0) break; ret = wc_Tls13_HKDF_Expand_Label(output, (word32)hashAlgSz, secret, (word32)hashAlgSz, (byte*)protocolLabel, (word32)XSTRLEN(protocolLabel), (byte*)expMasterLabel, (word32)XSTRLEN(expMasterLabel), - tv->hashFinished1, (word32)hashAlgSz, tv->hashAlg); + tv->hashFinished1, (word32)hashAlgSz, (int)tv->hashAlg); if (ret != 0) break; - ret = XMEMCMP(tv->exporterMasterSecret, output, hashAlgSz); + ret = XMEMCMP(tv->exporterMasterSecret, output, (unsigned long)hashAlgSz); if (ret != 0) break; ret = wc_Tls13_HKDF_Expand_Label(output, (word32)hashAlgSz, secret, (word32)hashAlgSz, (byte*)protocolLabel, (word32)XSTRLEN(protocolLabel), (byte*)resMasterLabel, (word32)XSTRLEN(resMasterLabel), - tv->hashFinished2, (word32)hashAlgSz, tv->hashAlg); + tv->hashFinished2, (word32)hashAlgSz, (int)tv->hashAlg); if (ret != 0) break; - ret = XMEMCMP(tv->resumptionMasterSecret, output, hashAlgSz); + ret = XMEMCMP(tv->resumptionMasterSecret, output, + (unsigned long)hashAlgSz); if (ret != 0) break; }