diff --git a/src/bio.c b/src/bio.c index 34b5861f78..7cd87f97e1 100644 --- a/src/bio.c +++ b/src/bio.c @@ -608,7 +608,7 @@ static int wolfSSL_BIO_MEMORY_write(WOLFSSL_BIO* bio, const void* data, if (len == 0) return WOLFSSL_SUCCESS; /* Return early to make logic simpler */ - if (wolfSSL_BUF_MEM_grow_ex(bio->mem_buf, bio->wrSz + len, 0) + if (wolfSSL_BUF_MEM_grow_ex(bio->mem_buf, (size_t)(bio->wrSz + len), 0) == 0) { WOLFSSL_MSG("Error growing memory area"); return WOLFSSL_FAILURE; @@ -1320,7 +1320,7 @@ size_t wolfSSL_BIO_ctrl_pending(WOLFSSL_BIO *bio) if (pair->wrIdx > 0 && pair->wrIdx <= pair->rdIdx) { /* in wrap around state where beginning of buffer is being * overwritten */ - return pair->wrSz - pair->rdIdx + pair->wrIdx; + return (size_t)(pair->wrSz - pair->rdIdx + pair->wrIdx); } else { /* simple case where has not wrapped around */ diff --git a/src/pk.c b/src/pk.c index 410c16df92..a236ef595c 100644 --- a/src/pk.c +++ b/src/pk.c @@ -5630,7 +5630,8 @@ static int dsa_do_verify(const unsigned char* d, int dLen, unsigned char* sig, ret = dLen == WC_SHA_DIGEST_SIZE ? wc_DsaVerify(d, sig, (DsaKey*)dsa->internal, dsacheck) : BAD_FUNC_ARG; #else - ret = wc_DsaVerify_ex(d, dLen, sig, (DsaKey*)dsa->internal, dsacheck); + ret = wc_DsaVerify_ex(d, (word32)dLen, sig, (DsaKey*)dsa->internal, + dsacheck); #endif if (ret != 0) { WOLFSSL_MSG("DsaVerify failed"); @@ -9475,16 +9476,16 @@ int wolfSSL_i2d_ECPKParameters(const WOLFSSL_EC_GROUP* grp, unsigned char** pp) /* Get the actual DER encoding of the OID. ecc_sets[grp->curve_idx].oid * is just the numerical representation. */ - if (wc_ecc_get_oid(grp->curve_oid, &oid, &oidSz) < 0) + if (wc_ecc_get_oid((word32)grp->curve_oid, &oid, &oidSz) < 0) return WOLFSSL_FATAL_ERROR; - len = SetObjectId(oidSz, NULL) + oidSz; + len = SetObjectId((int)oidSz, NULL) + (int)oidSz; if (pp == NULL) return len; if (*pp == NULL) { - out = (unsigned char*)XMALLOC(len, NULL, DYNAMIC_TYPE_ASN1); + out = (unsigned char*)XMALLOC((size_t)len, NULL, DYNAMIC_TYPE_ASN1); if (out == NULL) return WOLFSSL_FATAL_ERROR; } @@ -9492,7 +9493,7 @@ int wolfSSL_i2d_ECPKParameters(const WOLFSSL_EC_GROUP* grp, unsigned char** pp) out = *pp; } - idx = SetObjectId(oidSz, out); + idx = SetObjectId((int)oidSz, out); XMEMCPY(out + idx, oid, oidSz); if (*pp == NULL) *pp = out; @@ -16537,7 +16538,7 @@ int pkcs8_encode(WOLFSSL_EVP_PKEY* pkey, byte* key, word32* keySz) if (keySz == NULL) return BAD_FUNC_ARG; - *keySz = pkey->pkey_sz; + *keySz = (word32)pkey->pkey_sz; if (key == NULL) return LENGTH_ONLY_E; diff --git a/src/ssl.c b/src/ssl.c index dd50545bf0..8dc1dd0886 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -7363,16 +7363,16 @@ WOLFSSL_PKCS8_PRIV_KEY_INFO* wolfSSL_d2i_PKCS8_PKEY( pkcs8Der->length, &algId); if (ret >= 0) { if (advanceLen == 0) /* Set only if not PEM */ - advanceLen = inOutIdx + ret; + advanceLen = (int)inOutIdx + ret; if (algId == DHk) { /* Special case for DH as we expect the DER buffer to be always * be in PKCS8 format */ rawDer.buffer = pkcs8Der->buffer; - rawDer.length = inOutIdx + ret; + rawDer.length = inOutIdx + (word32)ret; } else { rawDer.buffer = pkcs8Der->buffer + inOutIdx; - rawDer.length = ret; + rawDer.length = (word32)ret; } ret = 0; /* good DER */ } @@ -7434,7 +7434,7 @@ int wolfSSL_i2d_PKCS8_PKEY(WOLFSSL_PKCS8_PRIV_KEY_INFO* key, unsigned char** pp) return len; if (*pp == NULL) { - out = (unsigned char*)XMALLOC(len, NULL, DYNAMIC_TYPE_ASN1); + out = (unsigned char*)XMALLOC((size_t)len, NULL, DYNAMIC_TYPE_ASN1); if (out == NULL) return WOLFSSL_FATAL_ERROR; } diff --git a/src/tls13.c b/src/tls13.c index 08174467e9..5fd84dab09 100644 --- a/src/tls13.c +++ b/src/tls13.c @@ -1024,7 +1024,7 @@ int Tls13_Exporter(WOLFSSL* ssl, unsigned char *out, size_t outLen, ret = Tls13HKDFExpandLabel(ssl, firstExpand, hashLen, ssl->arrays->exporterSecret, hashLen, protocol, protocolLen, (byte*)label, (word32)labelLen, - emptyHash, hashLen, hashType); + emptyHash, hashLen, (int)hashType); if (ret != 0) return ret; @@ -1035,7 +1035,7 @@ int Tls13_Exporter(WOLFSSL* ssl, unsigned char *out, size_t outLen, ret = Tls13HKDFExpandLabel(ssl, out, (word32)outLen, firstExpand, hashLen, protocol, protocolLen, exporterLabel, EXPORTER_LABEL_SZ, - hashOut, hashLen, hashType); + hashOut, hashLen, (int)hashType); return ret; } @@ -8434,7 +8434,7 @@ static word32 NextCert(byte* data, word32 length, word32* idx) * offset index offset * returns Total number of bytes written. */ -static word32 WriteCSRToBuffer(WOLFSSL* ssl, DerBuffer** certExts, +static int WriteCSRToBuffer(WOLFSSL* ssl, DerBuffer** certExts, word16* extSz, word16 extSz_num) { int ret = 0; @@ -8452,7 +8452,7 @@ static word32 WriteCSRToBuffer(WOLFSSL* ssl, DerBuffer** certExts, if (csr) { for (extIdx = 0; extIdx < (word16)(extSz_num); extIdx++) { - tmpSz = TLSX_CSR_GetSize_ex(csr, 0, extIdx); + tmpSz = TLSX_CSR_GetSize_ex(csr, 0, (int)extIdx); if (tmpSz > (OPAQUE8_LEN + OPAQUE24_LEN) && certExts[extIdx] == NULL) { @@ -8487,7 +8487,7 @@ static word32 WriteCSRToBuffer(WOLFSSL* ssl, DerBuffer** certExts, /* chain cert empty extension size */ totalSz += OPAQUE16_LEN * extSz_num; } - return totalSz; + return (int)totalSz; } #endif /* HAVE_CERTIFICATE_STATUS_REQUEST */ /* Add certificate data and empty extension to output up to the fragment size. diff --git a/src/x509.c b/src/x509.c index 1f5dfca0c9..9df453486d 100644 --- a/src/x509.c +++ b/src/x509.c @@ -194,7 +194,7 @@ int wolfSSL_X509_get_ext_count(const WOLFSSL_X509* passedCert) FreeDecodedCert(cert); return WOLFSSL_FAILURE; } - idx += length; + idx += (word32)length; extCount++; } @@ -516,8 +516,8 @@ static int wolfssl_dns_entry_othername_to_gn(DNS_entry* dns, const unsigned char* oid; word32 oidSz; - if ((oid = OidFromId(dns->oidSum, oidCertAltNameType, &oidSz)) == - NULL) { + if ((oid = OidFromId((word32)dns->oidSum, oidCertAltNameType, + &oidSz)) == NULL) { if (dns->oidSum == UPN_OID) { oid = upn_oid; oidSz = (word32)sizeof(upn_oid); @@ -633,7 +633,8 @@ static int DNS_to_GENERAL_NAME(WOLFSSL_GENERAL_NAME* gn, DNS_entry* dns) if (gn->d.registeredID == NULL) { return WOLFSSL_FAILURE; } - gn->d.registeredID->obj = (const unsigned char*)XMALLOC(dns->len, + gn->d.registeredID->obj = (const unsigned char*)XMALLOC( + (size_t)dns->len, gn->d.registeredID->heap, DYNAMIC_TYPE_ASN1); if (gn->d.registeredID->obj == NULL) { /* registeredID gets free'd up by caller after failure */ @@ -641,7 +642,7 @@ static int DNS_to_GENERAL_NAME(WOLFSSL_GENERAL_NAME* gn, DNS_entry* dns) } gn->d.registeredID->dynamic |= WOLFSSL_ASN1_DYNAMIC_DATA; XMEMCPY((byte*)gn->d.registeredID->obj, dns->ridString, dns->len); - gn->d.registeredID->objSz = dns->len; + gn->d.registeredID->objSz = (unsigned int)dns->len; gn->d.registeredID->grp = oidCertExtType; gn->d.registeredID->nid = WC_NID_registeredAddress; break; @@ -669,7 +670,7 @@ static int wolfssl_x509_alt_names_to_gn(WOLFSSL_X509* x509, #ifdef OPENSSL_ALL ret = wolfSSL_ASN1_STRING_set(&ext->value, x509->subjAltNameSrc, - x509->subjAltNameSz); + (int)x509->subjAltNameSz); if (ret != WOLFSSL_SUCCESS) { WOLFSSL_MSG("ASN1_STRING_set() failed"); goto err; @@ -869,7 +870,7 @@ WOLFSSL_X509_EXTENSION* wolfSSL_X509_set_ext(WOLFSSL_X509* x509, int loc) /* Continue while loop until extCount == loc or idx > sz */ if (extCount != loc) { - idx += length; + idx += (word32)length; extCount++; continue; } @@ -914,8 +915,9 @@ WOLFSSL_X509_EXTENSION* wolfSSL_X509_set_ext(WOLFSSL_X509* x509, int loc) /* Skip the critical information */ if (input[dataIdx] == ASN_BOOLEAN) { dataIdx++; - ret = GetLength(input, &dataIdx, &dataLen, sz) >= 0; - dataIdx += dataLen; + ret = GetLength(input, &dataIdx, &dataLen, + (word32)sz) >= 0; + dataIdx += (word32)dataLen; } } if (ret) { @@ -1041,7 +1043,7 @@ WOLFSSL_X509_EXTENSION* wolfSSL_X509_set_ext(WOLFSSL_X509* x509, int loc) break; ret = wolfSSL_ASN1_STRING_set(&ext->value, x509->authKeyId, - x509->authKeyIdSz); + (int)x509->authKeyIdSz); if (ret != WOLFSSL_SUCCESS) { WOLFSSL_MSG("ASN1_STRING_set() failed"); wolfSSL_X509_EXTENSION_free(ext); @@ -1059,7 +1061,7 @@ WOLFSSL_X509_EXTENSION* wolfSSL_X509_set_ext(WOLFSSL_X509* x509, int loc) break; ret = wolfSSL_ASN1_STRING_set(&ext->value, x509->subjKeyId, - x509->subjKeyIdSz); + (int)x509->subjKeyIdSz); if (ret != WOLFSSL_SUCCESS) { WOLFSSL_MSG("ASN1_STRING_set() failed"); wolfSSL_X509_EXTENSION_free(ext); @@ -1103,7 +1105,7 @@ WOLFSSL_X509_EXTENSION* wolfSSL_X509_set_ext(WOLFSSL_X509* x509, int loc) break; ret = wolfSSL_ASN1_STRING_set(&ext->value, x509->extKeyUsageSrc, - x509->extKeyUsageSz); + (int)x509->extKeyUsageSz); if (ret != WOLFSSL_SUCCESS) { WOLFSSL_MSG("ASN1_STRING_set() failed"); wolfSSL_X509_EXTENSION_free(ext); @@ -1151,7 +1153,7 @@ WOLFSSL_X509_EXTENSION* wolfSSL_X509_set_ext(WOLFSSL_X509* x509, int loc) #endif return NULL; } - oidBuf = (byte*)XMALLOC(length+1+MAX_LENGTH_SZ, NULL, + oidBuf = (byte*)XMALLOC((size_t)length+1+MAX_LENGTH_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (oidBuf == NULL) { WOLFSSL_MSG("Failed to malloc tmp buffer"); @@ -1164,7 +1166,7 @@ WOLFSSL_X509_EXTENSION* wolfSSL_X509_set_ext(WOLFSSL_X509* x509, int loc) } oidBuf[0] = ASN_OBJECT_ID; objSz++; - objSz += SetLength(length, oidBuf + 1); + objSz += SetLength((word32)length, oidBuf + 1); objSz += length; /* Set object size and reallocate space in object buffer */ @@ -1210,7 +1212,7 @@ WOLFSSL_X509_EXTENSION* wolfSSL_X509_set_ext(WOLFSSL_X509* x509, int loc) ext->crit = 0; /* Get extension data and copy as ASN1_STRING */ - tmpIdx = idx + length; + tmpIdx = idx + (word32)length; if ((tmpIdx >= (word32)sz) || (input[tmpIdx] != ASN_OCTET_STRING)) { @@ -1236,7 +1238,7 @@ WOLFSSL_X509_EXTENSION* wolfSSL_X509_set_ext(WOLFSSL_X509* x509, int loc) #endif return NULL; } - ext->value.data = (char*)XMALLOC(length, NULL, + ext->value.data = (char*)XMALLOC((size_t)length, NULL, DYNAMIC_TYPE_ASN1); ext->value.isDynamic = 1; if (ext->value.data == NULL) { @@ -1287,7 +1289,7 @@ static int asn1_string_copy_to_buffer(WOLFSSL_ASN1_STRING* str, byte** buf, if (*buf) XFREE(*buf, heap, DYNAMIC_TYPE_X509_EXT); *len = 0; - *buf = (byte*)XMALLOC(str->length, heap, DYNAMIC_TYPE_X509_EXT); + *buf = (byte*)XMALLOC((size_t)str->length, heap, DYNAMIC_TYPE_X509_EXT); if (!*buf) { WOLFSSL_MSG("malloc error"); return WOLFSSL_FAILURE; @@ -1371,7 +1373,7 @@ int wolfSSL_X509_add_ext(WOLFSSL_X509 *x509, WOLFSSL_X509_EXTENSION *ext, } else if (!gn || !gn->d.ia5 || wolfSSL_X509_add_altname_ex(x509, gn->d.ia5->data, - gn->d.ia5->length, gn->type) != WOLFSSL_SUCCESS) { + (word32)gn->d.ia5->length, gn->type) != WOLFSSL_SUCCESS) { WOLFSSL_MSG("Subject alternative name missing extension"); return WOLFSSL_FAILURE; } @@ -1458,7 +1460,7 @@ int wolfSSL_X509_add_ext(WOLFSSL_X509 *x509, WOLFSSL_X509_EXTENSION *ext, /* This is a viable custom extension. */ oid = (char*)XMALLOC(MAX_OID_STRING_SZ, x509->heap, DYNAMIC_TYPE_X509_EXT); - val = (byte*)XMALLOC(ext->value.length, x509->heap, + val = (byte*)XMALLOC((size_t)ext->value.length, x509->heap, DYNAMIC_TYPE_X509_EXT); if ((oid == NULL) || (val == NULL)) { WOLFSSL_MSG("Memory allocation failure.\n"); @@ -1820,7 +1822,7 @@ static WOLFSSL_AUTHORITY_INFO_ACCESS* wolfssl_x509v3_ext_aia_d2i( /* Set the URI into GENERAL_NAME. */ ret = wolfSSL_ASN1_STRING_set(ad->location->d.uniformResourceIdentifier, - aiaEntry->obj, aiaEntry->objSz); + aiaEntry->obj, (int)aiaEntry->objSz); if (ret != WOLFSSL_SUCCESS) { WOLFSSL_MSG("ASN1_STRING_set() failed"); err = 1; @@ -2167,7 +2169,7 @@ int wolfSSL_X509_get_ext_by_NID(const WOLFSSL_X509* x509, int nid, int lastPos) } } - idx += length; + idx += (word32)length; extCount++; } /* while(idx < sz) */ @@ -2291,13 +2293,13 @@ void* wolfSSL_X509_get_ext_d2i(const WOLFSSL_X509* x509, int nid, int* c, { int localIdx = 0; unsigned char* n = (unsigned char*)XMALLOC( - dns->len + MAX_SEQ_SZ, x509->heap, - DYNAMIC_TYPE_TMP_BUFFER); + (size_t)dns->len + MAX_SEQ_SZ, x509->heap, + DYNAMIC_TYPE_TMP_BUFFER); if (n == NULL) { goto err; } - localIdx += SetSequence(dns->len, n); + localIdx += SetSequence((word32)dns->len, n); XMEMCPY(n + localIdx, dns->name, dns->len); gn->d.dirn = wolfSSL_d2i_X509_NAME(NULL, &n, dns->len + localIdx); @@ -3023,7 +3025,7 @@ WOLFSSL_X509_EXTENSION *wolfSSL_X509V3_EXT_i2d(int nid, int crit, asn1str = (WOLFSSL_ASN1_STRING*)data; ext->value = *asn1str; if (asn1str->isDynamic) { - ext->value.data = (char*)XMALLOC(asn1str->length, NULL, + ext->value.data = (char*)XMALLOC((size_t)asn1str->length, NULL, DYNAMIC_TYPE_OPENSSL); if (!ext->value.data) { WOLFSSL_MSG("malloc failed"); @@ -3232,8 +3234,8 @@ int wolfSSL_X509_digest(const WOLFSSL_X509* x509, const WOLFSSL_EVP_MD* digest, return WOLFSSL_FAILURE; } - ret = wolfSSL_EVP_Digest(x509->derCert->buffer, x509->derCert->length, buf, - len, digest, NULL); + ret = wolfSSL_EVP_Digest(x509->derCert->buffer, + (int)x509->derCert->length, buf, len, digest, NULL); WOLFSSL_LEAVE("wolfSSL_X509_digest", ret); return ret; } @@ -3365,7 +3367,7 @@ char* wolfSSL_X509_NAME_oneline(WOLFSSL_X509_NAME* name, char* in, int sz) WOLFSSL_MSG("Using static memory -- please pass in a buffer"); return NULL; #else - in = (char*)XMALLOC(name->sz, NULL, DYNAMIC_TYPE_OPENSSL); + in = (char*)XMALLOC((size_t)name->sz, NULL, DYNAMIC_TYPE_OPENSSL); if (!in) return in; copySz = name->sz; @@ -3557,7 +3559,7 @@ char* wolfSSL_X509_get_name_oneline(WOLFSSL_X509_NAME* name, char* in, int sz) */ if (i != count - 1) { strSz = (int)XSTRLEN(sn) + nameSz + 4; - str = (char*)XMALLOC(strSz, NULL, DYNAMIC_TYPE_TMP_BUFFER); + str = (char*)XMALLOC((size_t)strSz, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (str == NULL) { WOLFSSL_MSG("Memory error"); return NULL; @@ -3575,7 +3577,7 @@ char* wolfSSL_X509_get_name_oneline(WOLFSSL_X509_NAME* name, char* in, int sz) * Add extra strSz for '=' and '\0' characters in XSNPRINTF. */ strSz = (int)XSTRLEN(sn) + nameSz + 2; - str = (char*)XMALLOC(strSz, NULL, DYNAMIC_TYPE_TMP_BUFFER); + str = (char*)XMALLOC((size_t)strSz, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (str == NULL) { WOLFSSL_MSG("Memory error"); return NULL; diff --git a/tests/quic.c b/tests/quic.c index c58625db48..f0d90aedce 100644 --- a/tests/quic.c +++ b/tests/quic.c @@ -554,7 +554,7 @@ static int ctx_send_alert(WOLFSSL *ssl, WOLFSSL_ENCRYPTION_LEVEL level, uint8_t if (ctx->verbose) { printf("[%s] send_alert: level=%d, err=%d\n", ctx->name, level, err); } - ctx->alert_level = level; + ctx->alert_level = (int)level; ctx->alert = alert; return 1; } diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index 612ef0f736..2777c62970 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -7505,7 +7505,7 @@ static int _HMAC_K(byte* K, word32 KSz, byte* V, word32 VSz, ret = init = wc_HmacInit(&hmac, heap, INVALID_DEVID); if (ret == 0) - ret = wc_HmacSetKey(&hmac, hashType, K, KSz); + ret = wc_HmacSetKey(&hmac, (int)hashType, K, KSz); if (ret == 0) ret = wc_HmacUpdate(&hmac, V, VSz); @@ -12809,7 +12809,7 @@ static int accel_fp_mul(int idx, const mp_int* k, ecc_point *R, mp_int* a, by x bits from the start */ bitpos = (unsigned)x; for (y = z = 0; y < FP_LUT; y++) { - z |= ((kb[bitpos>>3] >> (bitpos&7)) & 1) << y; + z |= (unsigned)((kb[bitpos>>3] >> (bitpos&7)) & 1) << y; bitpos += lut_gap; /* it's y*lut_gap + x, but here we can avoid the mult in each loop */ } @@ -13062,8 +13062,8 @@ static int accel_fp_mul2add(int idx1, int idx2, offset by x bits from the start */ bitpos = (unsigned)x; for (y = zA = zB = 0; y < FP_LUT; y++) { - zA |= ((kb[0][bitpos>>3] >> (bitpos&7)) & 1) << y; - zB |= ((kb[1][bitpos>>3] >> (bitpos&7)) & 1) << y; + zA |= (unsigned)((kb[0][bitpos>>3] >> (bitpos&7)) & 1) << y; + zB |= (unsigned)((kb[1][bitpos>>3] >> (bitpos&7)) & 1) << y; bitpos += lut_gap; /* it's y*lut_gap + x, but here we can avoid the mult in each loop */ } diff --git a/wolfcrypt/src/evp.c b/wolfcrypt/src/evp.c index 6f53af9941..336c7db746 100644 --- a/wolfcrypt/src/evp.c +++ b/wolfcrypt/src/evp.c @@ -2629,7 +2629,7 @@ int wolfSSL_EVP_PKEY_derive(WOLFSSL_EVP_PKEY_CTX *ctx, unsigned char *key, size_ return WOLFSSL_FAILURE; } if (ctx->pkey->hkdfMode == WOLFSSL_EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND) { - if (wc_HKDF(hkdfHashType, ctx->pkey->hkdfKey, ctx->pkey->hkdfKeySz, + if (wc_HKDF((int)hkdfHashType, ctx->pkey->hkdfKey, ctx->pkey->hkdfKeySz, ctx->pkey->hkdfSalt, ctx->pkey->hkdfSaltSz, ctx->pkey->hkdfInfo, ctx->pkey->hkdfInfoSz, key, (word32)*keylen) != 0) { @@ -2638,7 +2638,7 @@ int wolfSSL_EVP_PKEY_derive(WOLFSSL_EVP_PKEY_CTX *ctx, unsigned char *key, size_ } } else if (ctx->pkey->hkdfMode == WOLFSSL_EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY) { - if (wc_HKDF_Extract(hkdfHashType, ctx->pkey->hkdfSalt, + if (wc_HKDF_Extract((int)hkdfHashType, ctx->pkey->hkdfSalt, ctx->pkey->hkdfSaltSz, ctx->pkey->hkdfKey, ctx->pkey->hkdfKeySz, key) != 0) { WOLFSSL_MSG("wc_HKDF_Extract failed."); @@ -2655,7 +2655,7 @@ int wolfSSL_EVP_PKEY_derive(WOLFSSL_EVP_PKEY_CTX *ctx, unsigned char *key, size_ } } else if (ctx->pkey->hkdfMode == WOLFSSL_EVP_PKEY_HKDEF_MODE_EXPAND_ONLY) { - if (wc_HKDF_Expand(hkdfHashType, ctx->pkey->hkdfKey, + if (wc_HKDF_Expand((int)hkdfHashType, ctx->pkey->hkdfKey, ctx->pkey->hkdfKeySz, ctx->pkey->hkdfInfo, ctx->pkey->hkdfInfoSz, key, (word32)*keylen) != 0) { @@ -4872,7 +4872,7 @@ int wolfSSL_PKCS5_PBKDF2_HMAC(const char *pass, int passlen, } ret = wc_PBKDF2((byte*)out, (byte*)pass, passlen, (byte*)salt, saltlen, - iter, keylen, EvpMd2MacType(digest)); + iter, keylen, (int)EvpMd2MacType(digest)); if (ret == 0) return WOLFSSL_SUCCESS; else diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 0c877ef301..df89dd90c1 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -9194,7 +9194,7 @@ static wc_test_ret_t EVP_test(const WOLFSSL_EVP_CIPHER* type, const byte* key, } cipherSz += idx; - if ((expectedSz != cipherSz) || XMEMCMP(plain, cipher, plainSz)) { + if ((expectedSz != cipherSz) || XMEMCMP(plain, cipher, (size_t)plainSz)) { ret = WC_TEST_RET_ENC_NC; goto EVP_TEST_END; } @@ -11136,9 +11136,11 @@ static wc_test_ret_t aes_xts_128_test(void) for (k = 0; k < j; k += WC_AES_BLOCK_SIZE) { if ((j - k) < WC_AES_BLOCK_SIZE*2) - ret = wc_AesXtsEncryptFinal(aes, large_input + k, large_input + k, j - k, &stream); + ret = wc_AesXtsEncryptFinal(aes, large_input + k, + large_input + k, (word32)(j - k), &stream); else - ret = wc_AesXtsEncryptUpdate(aes, large_input + k, large_input + k, WC_AES_BLOCK_SIZE, &stream); + ret = wc_AesXtsEncryptUpdate(aes, large_input + k, + large_input + k, WC_AES_BLOCK_SIZE, &stream); #if defined(WOLFSSL_ASYNC_CRYPT) ret = wc_AsyncWait(ret, &aes->aes.asyncDev, WC_ASYNC_FLAG_NONE); #endif @@ -11198,9 +11200,11 @@ static wc_test_ret_t aes_xts_128_test(void) for (k = 0; k < j; k += WC_AES_BLOCK_SIZE) { if ((j - k) < WC_AES_BLOCK_SIZE*2) - ret = wc_AesXtsDecryptFinal(aes, large_input + k, large_input + k, j - k, &stream); + ret = wc_AesXtsDecryptFinal(aes, large_input + k, + large_input + k, (word32)(j - k), &stream); else - ret = wc_AesXtsDecryptUpdate(aes, large_input + k, large_input + k, WC_AES_BLOCK_SIZE, &stream); + ret = wc_AesXtsDecryptUpdate(aes, large_input + k, + large_input + k, WC_AES_BLOCK_SIZE, &stream); #if defined(WOLFSSL_ASYNC_CRYPT) #ifdef WC_AES_XTS_SUPPORT_SIMULTANEOUS_ENC_AND_DEC_KEYS ret = wc_AsyncWait(ret, &aes->aes_decrypt.asyncDev, @@ -11787,7 +11791,7 @@ static wc_test_ret_t aes_xts_192_test(void) ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_ENCRYPTION); if (ret != 0) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); - ret = wc_AesXtsEncrypt(aes, large_input, large_input, j, i1, + ret = wc_AesXtsEncrypt(aes, large_input, large_input, (word32)j, i1, sizeof(i1)); #if defined(WOLFSSL_ASYNC_CRYPT) ret = wc_AsyncWait(ret, &aes->aes.asyncDev, WC_ASYNC_FLAG_NONE); @@ -11798,7 +11802,7 @@ static wc_test_ret_t aes_xts_192_test(void) ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_DECRYPTION); if (ret != 0) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); - ret = wc_AesXtsDecrypt(aes, large_input, large_input, j, i1, + ret = wc_AesXtsDecrypt(aes, large_input, large_input, (word32)j, i1, sizeof(i1)); #if defined(WOLFSSL_ASYNC_CRYPT) #ifdef WC_AES_XTS_SUPPORT_SIMULTANEOUS_ENC_AND_DEC_KEYS @@ -11836,9 +11840,11 @@ static wc_test_ret_t aes_xts_192_test(void) for (k = 0; k < j; k += WC_AES_BLOCK_SIZE) { if ((j - k) < WC_AES_BLOCK_SIZE*2) - ret = wc_AesXtsEncryptFinal(aes, large_input + k, large_input + k, j - k, &stream); + ret = wc_AesXtsEncryptFinal(aes, large_input + k, + large_input + k, (word32)(j - k), &stream); else - ret = wc_AesXtsEncryptUpdate(aes, large_input + k, large_input + k, WC_AES_BLOCK_SIZE, &stream); + ret = wc_AesXtsEncryptUpdate(aes, large_input + k, + large_input + k, WC_AES_BLOCK_SIZE, &stream); #if defined(WOLFSSL_ASYNC_CRYPT) ret = wc_AsyncWait(ret, &aes->aes.asyncDev, WC_ASYNC_FLAG_NONE); #endif @@ -11898,9 +11904,11 @@ static wc_test_ret_t aes_xts_192_test(void) for (k = 0; k < j; k += WC_AES_BLOCK_SIZE) { if ((j - k) < WC_AES_BLOCK_SIZE*2) - ret = wc_AesXtsDecryptFinal(aes, large_input + k, large_input + k, j - k, &stream); + ret = wc_AesXtsDecryptFinal(aes, large_input + k, + large_input + k, (word32)(j - k), &stream); else - ret = wc_AesXtsDecryptUpdate(aes, large_input + k, large_input + k, WC_AES_BLOCK_SIZE, &stream); + ret = wc_AesXtsDecryptUpdate(aes, large_input + k, + large_input + k, WC_AES_BLOCK_SIZE, &stream); #if defined(WOLFSSL_ASYNC_CRYPT) #ifdef WC_AES_XTS_SUPPORT_SIMULTANEOUS_ENC_AND_DEC_KEYS ret = wc_AsyncWait(ret, &aes->aes_decrypt.asyncDev, @@ -12243,7 +12251,7 @@ static wc_test_ret_t aes_xts_256_test(void) ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_ENCRYPTION); if (ret != 0) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); - ret = wc_AesXtsEncrypt(aes, large_input, large_input, j, i1, + ret = wc_AesXtsEncrypt(aes, large_input, large_input, (word32)j, i1, sizeof(i1)); #if defined(WOLFSSL_ASYNC_CRYPT) ret = wc_AsyncWait(ret, &aes->aes.asyncDev, WC_ASYNC_FLAG_NONE); @@ -12254,7 +12262,7 @@ static wc_test_ret_t aes_xts_256_test(void) ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_DECRYPTION); if (ret != 0) ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out); - ret = wc_AesXtsDecrypt(aes, large_input, large_input, j, i1, + ret = wc_AesXtsDecrypt(aes, large_input, large_input, (word32)j, i1, sizeof(i1)); #if defined(WOLFSSL_ASYNC_CRYPT) #ifdef WC_AES_XTS_SUPPORT_SIMULTANEOUS_ENC_AND_DEC_KEYS