From a3af1c036cd25da58017d59a375f7de8ccbd9fd8 Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Wed, 18 Jun 2025 11:59:04 +0200 Subject: [PATCH] test: Silence warnings on Win64 builds MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: SaÅ¡a Nedvědický Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/27806) --- test/acvp_test.c | 82 ++++++++--------- test/acvp_test.inc | 14 +-- test/algorithmid_test.c | 3 +- test/asn1_encode_test.c | 5 +- test/asn1_time_test.c | 2 +- test/asynciotest.c | 6 +- test/bad_dtls_test.c | 4 +- test/bftest.c | 8 +- test/bio_base64_test.c | 8 +- test/bio_callback_test.c | 4 +- test/bio_comp_test.c | 8 +- test/bio_core_test.c | 2 +- test/bio_dgram_test.c | 4 +- test/bio_enc_test.c | 2 +- test/bio_readbuffer_test.c | 4 +- test/bntest.c | 17 ++-- test/clienthellotest.c | 2 +- test/cmactest.c | 6 +- test/cmp_ctx_test.c | 20 ++-- test/cmp_protect_test.c | 2 +- test/cmsapitest.c | 4 +- test/constant_time_test.c | 10 +- test/crltest.c | 2 +- test/danetest.c | 4 +- test/decoder_propq_test.c | 2 +- test/destest.c | 20 ++-- test/dhkem_test.inc | 2 +- test/dhtest.c | 8 +- test/dsa_no_digest_size_test.c | 4 +- test/dtls_mtu_test.c | 2 +- test/ec_internal_test.c | 4 +- test/ecdsatest.c | 12 +-- test/ectest.c | 143 +++++++++++++++-------------- test/endecode_test.c | 28 +++--- test/enginetest.c | 2 +- test/evp_extra_test.c | 86 +++++++++-------- test/evp_extra_test2.c | 23 ++--- test/evp_fetch_prov_test.c | 2 +- test/evp_libctx_test.c | 8 +- test/evp_pkey_dhkem_test.c | 3 +- test/evp_test.c | 60 ++++++------ test/evp_xof_test.c | 2 +- test/fake_rsaprov.c | 4 +- test/fatalerrtest.c | 2 +- test/fips_version_test.c | 4 +- test/helpers/handshake.c | 20 ++-- test/helpers/pkcs12.c | 18 ++-- test/helpers/predefined_dhparams.c | 6 +- test/helpers/quictestlib.c | 4 +- test/helpers/ssltestlib.c | 8 +- test/http_test.c | 6 +- test/ideatest.c | 2 +- test/igetest.c | 12 +-- test/keymgmt_internal_test.c | 2 +- test/lhash_test.c | 8 +- test/list_test.c | 4 +- test/ml_dsa_test.c | 8 +- test/modes_internal_test.c | 2 +- test/params_test.c | 8 +- test/pbetest.c | 4 +- test/pemtest.c | 6 +- test/pkcs7_test.c | 2 +- test/quic_ackm_test.c | 11 ++- test/quic_multistream_test.c | 12 +-- test/quic_newcid_test.c | 6 +- test/quic_txp_test.c | 4 +- test/quic_wire_test.c | 2 +- test/quicapitest.c | 10 +- test/quicfaultstest.c | 2 +- test/radix/quic_bindings.c | 14 +-- test/radix/quic_ops.c | 2 +- test/servername_test.c | 4 +- test/siphash_internal_test.c | 2 +- test/slh_dsa_test.c | 6 +- test/sm2_internal_test.c | 3 +- test/ssl_old_test.c | 10 +- test/sslapitest.c | 90 +++++++++--------- test/testutil/format_output.c | 12 +-- test/testutil/testutil_init.c | 4 +- test/threadpool_test.c | 8 +- test/threadstest.c | 4 +- test/time_offset_test.c | 2 +- test/tls-provider.c | 3 +- test/tls13ccstest.c | 2 +- test/trace_api_test.c | 12 +-- test/uitest.c | 2 +- test/v3ext.c | 2 +- test/v3nametest.c | 4 +- test/x509_acert_test.c | 6 +- test/x509_dup_cert_test.c | 4 +- test/x509_test.c | 2 +- test/x509_time_test.c | 2 +- 92 files changed, 518 insertions(+), 493 deletions(-) diff --git a/test/acvp_test.c b/test/acvp_test.c index 2bcc886fd29..9cf7383404e 100644 --- a/test/acvp_test.c +++ b/test/acvp_test.c @@ -237,9 +237,9 @@ static int get_ecdsa_sig_rs_bytes(const unsigned char *sig, size_t sig_len, { int ret = 0; unsigned char *rbuf = NULL, *sbuf = NULL; - size_t r1_len, s1_len; + int r1_len, s1_len; const BIGNUM *r1, *s1; - ECDSA_SIG *sign = d2i_ECDSA_SIG(NULL, &sig, sig_len); + ECDSA_SIG *sign = d2i_ECDSA_SIG(NULL, &sig, (long)sig_len); if (sign == NULL) return 0; @@ -306,7 +306,7 @@ static int ecdsa_sigver_test(int id) EVP_PKEY *pkey = NULL; EVP_PKEY_CTX *pkey_ctx; ECDSA_SIG *sign = NULL; - size_t sig_len; + int sig_len; unsigned char *sig = NULL; BIGNUM *rbn = NULL, *sbn = NULL; const struct ecdsa_sigver_st *tst = &ecdsa_sigver_data[id]; @@ -316,8 +316,8 @@ static int ecdsa_sigver_test(int id) goto err; if (!TEST_ptr(sign = ECDSA_SIG_new()) - || !TEST_ptr(rbn = BN_bin2bn(tst->r, tst->r_len, NULL)) - || !TEST_ptr(sbn = BN_bin2bn(tst->s, tst->s_len, NULL)) + || !TEST_ptr(rbn = BN_bin2bn(tst->r, (int)tst->r_len, NULL)) + || !TEST_ptr(sbn = BN_bin2bn(tst->s, (int)tst->s_len, NULL)) || !TEST_true(ECDSA_SIG_set0(sign, rbn, sbn))) goto err; rbn = sbn = NULL; @@ -657,7 +657,7 @@ static int dsa_create_pkey(EVP_PKEY **pkey, if (!TEST_ptr(bld = OSSL_PARAM_BLD_new()) || !TEST_ptr(p_bn = BN_CTX_get(bn_ctx)) - || !TEST_ptr(BN_bin2bn(p, p_len, p_bn)) + || !TEST_ptr(BN_bin2bn(p, (int)p_len, p_bn)) || !TEST_true(OSSL_PARAM_BLD_push_int(bld, OSSL_PKEY_PARAM_FFC_VALIDATE_PQ, validate_pq)) @@ -666,13 +666,13 @@ static int dsa_create_pkey(EVP_PKEY **pkey, validate_g)) || !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_FFC_P, p_bn)) || !TEST_ptr(q_bn = BN_CTX_get(bn_ctx)) - || !TEST_ptr(BN_bin2bn(q, q_len, q_bn)) + || !TEST_ptr(BN_bin2bn(q, (int)q_len, q_bn)) || !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_FFC_Q, q_bn))) goto err; if (g != NULL) { if (!TEST_ptr(g_bn = BN_CTX_get(bn_ctx)) - || !TEST_ptr(BN_bin2bn(g, g_len, g_bn)) + || !TEST_ptr(BN_bin2bn(g, (int)g_len, g_bn)) || !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_FFC_G, g_bn))) goto err; @@ -690,7 +690,7 @@ static int dsa_create_pkey(EVP_PKEY **pkey, } if (pub != NULL) { if (!TEST_ptr(pub_bn = BN_CTX_get(bn_ctx)) - || !TEST_ptr(BN_bin2bn(pub, pub_len, pub_bn)) + || !TEST_ptr(BN_bin2bn(pub, (int)pub_len, pub_bn)) || !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_PUB_KEY, pub_bn))) @@ -746,9 +746,9 @@ static int get_dsa_sig_rs_bytes(const unsigned char *sig, size_t sig_len, { int ret = 0; unsigned char *rbuf = NULL, *sbuf = NULL; - size_t r1_len, s1_len; + int r1_len, s1_len; const BIGNUM *r1, *s1; - DSA_SIG *sign = d2i_DSA_SIG(NULL, &sig, sig_len); + DSA_SIG *sign = d2i_DSA_SIG(NULL, &sig, (long)sig_len); if (sign == NULL) return 0; @@ -816,7 +816,7 @@ static int dsa_sigver_test(int id) EVP_PKEY_CTX *ctx = NULL; EVP_PKEY *pkey = NULL; DSA_SIG *sign = NULL; - size_t sig_len; + int sig_len; unsigned char *sig = NULL; BIGNUM *rbn = NULL, *sbn = NULL; EVP_MD *md = NULL; @@ -833,8 +833,8 @@ static int dsa_sigver_test(int id) goto err; if (!TEST_ptr(sign = DSA_SIG_new()) - || !TEST_ptr(rbn = BN_bin2bn(tst->r, tst->r_len, NULL)) - || !TEST_ptr(sbn = BN_bin2bn(tst->s, tst->s_len, NULL)) + || !TEST_ptr(rbn = BN_bin2bn(tst->r, (int)tst->r_len, NULL)) + || !TEST_ptr(sbn = BN_bin2bn(tst->s, (int)tst->s_len, NULL)) || !TEST_true(DSA_SIG_set0(sign, rbn, sbn))) goto err; rbn = sbn = NULL; @@ -883,7 +883,7 @@ static int cipher_enc(const char *alg, || !TEST_ptr(cipher = EVP_CIPHER_fetch(libctx, alg, "")) || !TEST_true(EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, enc)) || !TEST_true(EVP_CIPHER_CTX_set_padding(ctx, 0)) - || !TEST_true(EVP_CipherUpdate(ctx, out, &len, pt, pt_len)) + || !TEST_true(EVP_CipherUpdate(ctx, out, &len, pt, (int)pt_len)) || !TEST_true(EVP_CipherFinal_ex(ctx, out + len, &out_len))) goto err; out_len += len; @@ -932,15 +932,15 @@ static int aes_ccm_enc_dec(const char *alg, if (!TEST_ptr(ctx = EVP_CIPHER_CTX_new()) || !TEST_ptr(cipher = EVP_CIPHER_fetch(libctx, alg, "")) || !TEST_true(EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, enc)) - || !TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, iv_len, - NULL), 0) - || !TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len, + || !TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, + (int)iv_len, NULL), 0) + || !TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, (int)tag_len, enc ? NULL : (void *)tag), 0) || !TEST_true(EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, enc)) || !TEST_true(EVP_CIPHER_CTX_set_padding(ctx, 0)) - || !TEST_true(EVP_CipherUpdate(ctx, NULL, &len, NULL, pt_len)) - || !TEST_true(EVP_CipherUpdate(ctx, NULL, &len, aad, aad_len)) - || !TEST_int_eq(EVP_CipherUpdate(ctx, out, &len, pt, pt_len), pass)) + || !TEST_true(EVP_CipherUpdate(ctx, NULL, &len, NULL, (int)pt_len)) + || !TEST_true(EVP_CipherUpdate(ctx, NULL, &len, aad, (int)aad_len)) + || !TEST_int_eq(EVP_CipherUpdate(ctx, out, &len, pt, (int)pt_len), pass)) goto err; if (!pass) { @@ -952,7 +952,7 @@ static int aes_ccm_enc_dec(const char *alg, if (enc) { out_len += len; if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, - tag_len, out + out_len), 0) + (int)tag_len, out + out_len), 0) || !TEST_mem_eq(out, out_len, ct, ct_len) || !TEST_mem_eq(out + out_len, tag_len, tag, tag_len)) goto err; @@ -1020,12 +1020,12 @@ static int aes_gcm_enc_dec(const char *alg, if (!TEST_ptr(ctx = EVP_CIPHER_CTX_new()) || !TEST_ptr(cipher = EVP_CIPHER_fetch(libctx, alg, "")) || !TEST_true(EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, enc)) - || !TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, iv_len, - NULL), 0)) + || !TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, + (int)iv_len, NULL), 0)) goto err; if (!enc) { - if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len, + if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, (int)tag_len, (void *)tag), 0)) goto err; } @@ -1036,8 +1036,8 @@ static int aes_gcm_enc_dec(const char *alg, */ if (!TEST_true(EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, enc)) || !TEST_true(EVP_CIPHER_CTX_set_padding(ctx, 0)) - || !TEST_true(EVP_CipherUpdate(ctx, NULL, &len, aad, aad_len)) - || !TEST_true(EVP_CipherUpdate(ctx, out, &len, pt, pt_len))) + || !TEST_true(EVP_CipherUpdate(ctx, NULL, &len, aad, (int)aad_len)) + || !TEST_true(EVP_CipherUpdate(ctx, out, &len, pt, (int)pt_len))) goto err; if (!TEST_int_eq(EVP_CipherFinal_ex(ctx, out + len, &olen), pass)) @@ -1050,7 +1050,7 @@ static int aes_gcm_enc_dec(const char *alg, if (enc) { if ((ct != NULL && !TEST_mem_eq(out, olen, ct, ct_len)) || !TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, - tag_len, out + olen), 0) + (int)tag_len, out + olen), 0) || (tag != NULL && !TEST_mem_eq(out + olen, tag_len, tag, tag_len))) goto err; @@ -1155,14 +1155,14 @@ static int dh_create_pkey(EVP_PKEY **pkey, const char *group_name, if (pub != NULL) { if (!TEST_ptr(pub_bn = BN_CTX_get(bn_ctx)) - || !TEST_ptr(BN_bin2bn(pub, pub_len, pub_bn)) + || !TEST_ptr(BN_bin2bn(pub, (int)pub_len, pub_bn)) || !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_PUB_KEY, pub_bn))) goto err; } if (priv != NULL) { if (!TEST_ptr(priv_bn = BN_CTX_get(bn_ctx)) - || !TEST_ptr(BN_bin2bn(priv, priv_len, priv_bn)) + || !TEST_ptr(BN_bin2bn(priv, (int)priv_len, priv_bn)) || !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_PRIV_KEY, priv_bn))) goto err; @@ -1259,20 +1259,20 @@ static int rsa_create_pkey(EVP_PKEY **pkey, if (!TEST_ptr(bld = OSSL_PARAM_BLD_new()) || !TEST_ptr(n_bn = BN_CTX_get(bn_ctx)) - || !TEST_ptr(BN_bin2bn(n, n_len, n_bn)) + || !TEST_ptr(BN_bin2bn(n, (int)n_len, n_bn)) || !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_N, n_bn))) goto err; if (e != NULL) { if (!TEST_ptr(e_bn = BN_CTX_get(bn_ctx)) - || !TEST_ptr(BN_bin2bn(e, e_len, e_bn)) + || !TEST_ptr(BN_bin2bn(e, (int)e_len, e_bn)) || !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_E, e_bn))) goto err; } if (d != NULL) { if (!TEST_ptr(d_bn = BN_CTX_get(bn_ctx)) - || !TEST_ptr(BN_bin2bn(d, d_len, d_bn)) + || !TEST_ptr(BN_bin2bn(d, (int)d_len, d_bn)) || !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_D, d_bn))) goto err; @@ -1311,12 +1311,12 @@ static int rsa_keygen_test(int id) const struct rsa_keygen_st *tst = &rsa_keygen_data[id]; if (!TEST_ptr(bld = OSSL_PARAM_BLD_new()) - || !TEST_ptr(xp1_bn = BN_bin2bn(tst->xp1, tst->xp1_len, NULL)) - || !TEST_ptr(xp2_bn = BN_bin2bn(tst->xp2, tst->xp2_len, NULL)) - || !TEST_ptr(xp_bn = BN_bin2bn(tst->xp, tst->xp_len, NULL)) - || !TEST_ptr(xq1_bn = BN_bin2bn(tst->xq1, tst->xq1_len, NULL)) - || !TEST_ptr(xq2_bn = BN_bin2bn(tst->xq2, tst->xq2_len, NULL)) - || !TEST_ptr(xq_bn = BN_bin2bn(tst->xq, tst->xq_len, NULL)) + || !TEST_ptr(xp1_bn = BN_bin2bn(tst->xp1, (int)tst->xp1_len, NULL)) + || !TEST_ptr(xp2_bn = BN_bin2bn(tst->xp2, (int)tst->xp2_len, NULL)) + || !TEST_ptr(xp_bn = BN_bin2bn(tst->xp, (int)tst->xp_len, NULL)) + || !TEST_ptr(xq1_bn = BN_bin2bn(tst->xq1, (int)tst->xq1_len, NULL)) + || !TEST_ptr(xq2_bn = BN_bin2bn(tst->xq2, (int)tst->xq2_len, NULL)) + || !TEST_ptr(xq_bn = BN_bin2bn(tst->xq, (int)tst->xq_len, NULL)) || !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_TEST_XP1, xp1_bn)) || !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_TEST_XP2, @@ -1333,7 +1333,7 @@ static int rsa_keygen_test(int id) goto err; if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "RSA", NULL)) - || !TEST_ptr(e_bn = BN_bin2bn(tst->e, tst->e_len, NULL)) + || !TEST_ptr(e_bn = BN_bin2bn(tst->e, (int)tst->e_len, NULL)) || !TEST_int_gt(EVP_PKEY_keygen_init(ctx), 0) || !TEST_int_gt(EVP_PKEY_CTX_set_params(ctx, params), 0) || !TEST_int_gt(EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, tst->mod), 0) @@ -1425,7 +1425,7 @@ static int rsa_siggen_test(int id) &salt_len); *p++ = OSSL_PARAM_construct_end(); - if (!TEST_ptr(pkey = EVP_PKEY_Q_keygen(libctx, NULL, "RSA", tst->mod)) + if (!TEST_ptr(pkey = EVP_PKEY_Q_keygen(libctx, NULL, "RSA", (size_t)tst->mod)) || !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_RSA_N, &n, &n_len)) || !TEST_true(pkey_get_bn_bytes(pkey, OSSL_PKEY_PARAM_RSA_E, &e, &e_len)) || !TEST_true(sig_gen(pkey, params, tst->digest_alg, diff --git a/test/acvp_test.inc b/test/acvp_test.inc index 67787f3740b..6a891762403 100644 --- a/test/acvp_test.inc +++ b/test/acvp_test.inc @@ -387,8 +387,8 @@ static const struct ecdsa_pub_verify_st eddsa_pv_data[] = { #ifndef OPENSSL_NO_DSA struct dsa_paramgen_st { - size_t L; - size_t N; + int L; + int N; }; struct dsa_pqver_st { @@ -404,8 +404,8 @@ struct dsa_pqver_st { struct dsa_siggen_st { const char *digest_alg; - size_t L; - size_t N; + int L; + int N; const unsigned char *msg; size_t msg_len; }; @@ -1161,7 +1161,7 @@ static const struct dh_safe_prime_keyver_st dh_safe_prime_keyver_data[] = { #endif /* OPENSSL_NO_DH */ struct rsa_keygen_st { - size_t mod; + int mod; const unsigned char *e; size_t e_len; const unsigned char *xp1; @@ -1344,7 +1344,7 @@ static const struct rsa_keygen_st rsa_keygen_data[] = { #define NO_PSS_SALT_LEN -1 struct rsa_siggen_st { const char *sig_pad_mode; - size_t mod; + int mod; const char *digest_alg; const unsigned char *msg; size_t msg_len; @@ -1381,7 +1381,7 @@ static const struct rsa_siggen_st rsa_siggen_data[] = { struct rsa_sigver_st { const char *sig_pad_mode; - size_t mod; + int mod; const char *digest_alg; const unsigned char *msg; size_t msg_len; diff --git a/test/algorithmid_test.c b/test/algorithmid_test.c index 0104425c1d4..816140d0a86 100644 --- a/test/algorithmid_test.c +++ b/test/algorithmid_test.c @@ -276,7 +276,8 @@ const OPTIONS *test_get_options(void) int setup_tests(void) { OPTION_CHOICE o; - int n, x509 = 0, spki = 0, testcount = 0; + size_t n; + int x509 = 0, spki = 0, testcount = 0; while ((o = opt_next()) != OPT_EOF) { switch (o) { diff --git a/test/asn1_encode_test.c b/test/asn1_encode_test.c index 88899dc9377..36e951de2e3 100644 --- a/test/asn1_encode_test.c +++ b/test/asn1_encode_test.c @@ -681,7 +681,7 @@ static int do_decode_custom(const TEST_CUSTOM_DATA *custom_data, if (encoding_length == 0) return -1; - ret = do_decode(encoding, encoding_length, expected, expected_size, + ret = do_decode(encoding, (long)encoding_length, expected, expected_size, package); OPENSSL_free(encoding); @@ -797,7 +797,8 @@ static int test_intern(const TEST_PACKAGE *package) EXPECTED *expected = (EXPECTED *)&((unsigned char *)package->encdec_data)[pos]; - switch (do_enc_dec(expected, package->encdec_data_elem_size, package)) { + switch (do_enc_dec(expected, (long)package->encdec_data_elem_size, + package)) { case -1: if (expected->success) { TEST_error("Failed encode/decode round trip %u of %s", diff --git a/test/asn1_time_test.c b/test/asn1_time_test.c index 32bc4ff2adb..1903a3ce3e1 100644 --- a/test/asn1_time_test.c +++ b/test/asn1_time_test.c @@ -167,7 +167,7 @@ static int test_table(struct testdata *tbl, int idx) int day, sec; atime.data = (unsigned char*)td->data; - atime.length = strlen((char*)atime.data); + atime.length = (int)strlen((char*)atime.data); atime.type = td->type; atime.flags = 0; diff --git a/test/asynciotest.c b/test/asynciotest.c index 10c958f667f..49fe923ce3c 100644 --- a/test/asynciotest.c +++ b/test/asynciotest.c @@ -125,7 +125,7 @@ static int async_write(BIO *bio, const char *in, int inl) { struct async_ctrs *ctrs; int ret = 0; - size_t written = 0; + int written = 0; BIO *next = BIO_next(bio); if (inl <= 0) @@ -238,7 +238,7 @@ static int async_write(BIO *bio, const char *in, int inl) } /* Write any data we have left after fragmenting */ ret = 0; - if ((int)written < inl) { + if (written < inl) { ret = BIO_write(next, in + written, inl - written); } @@ -281,7 +281,7 @@ static int async_gets(BIO *bio, char *buf, int size) static int async_puts(BIO *bio, const char *str) { - return async_write(bio, str, strlen(str)); + return async_write(bio, str, (int)strlen(str)); } #define MAX_ATTEMPTS 100 diff --git a/test/bad_dtls_test.c b/test/bad_dtls_test.c index 1df8cd84fe0..7e2dc21a8ba 100644 --- a/test/bad_dtls_test.c +++ b/test/bad_dtls_test.c @@ -335,7 +335,7 @@ static int send_record(BIO *rbio, unsigned char type, uint64_t seqnr, || !TEST_ptr(enc_ctx = EVP_CIPHER_CTX_new()) || !TEST_true(EVP_CipherInit_ex(enc_ctx, EVP_aes_128_cbc(), NULL, enc_key, iv, 1)) - || !TEST_int_ge(EVP_Cipher(enc_ctx, enc, enc, len), 0)) + || !TEST_int_ge(EVP_Cipher(enc_ctx, enc, enc, (unsigned int)len), 0)) goto end; /* Finally write header (from fragmented variables), IV and encrypted record */ @@ -348,7 +348,7 @@ static int send_record(BIO *rbio, unsigned char type, uint64_t seqnr, BIO_write(rbio, lenbytes, 2); BIO_write(rbio, iv, sizeof(iv)); - BIO_write(rbio, enc, len); + BIO_write(rbio, enc, (int)len); ret = 1; end: EVP_MAC_free(hmac); diff --git a/test/bftest.c b/test/bftest.c index 99e95edfc13..469500aa1e1 100644 --- a/test/bftest.c +++ b/test/bftest.c @@ -298,7 +298,7 @@ static int test_bf_ecb_raw(int n) BF_KEY key; BF_LONG data[2]; - BF_set_key(&key, strlen(bf_key[n]), (unsigned char *)bf_key[n]); + BF_set_key(&key, (int)strlen(bf_key[n]), (unsigned char *)bf_key[n]); data[0] = bf_plain[n][0]; data[1] = bf_plain[n][1]; @@ -354,7 +354,7 @@ static int test_bf_cbc(void) BF_KEY key; BF_LONG len; - len = strlen(cbc_data) + 1; + len = (BF_LONG)(strlen(cbc_data) + 1); BF_set_key(&key, 16, cbc_key); memset(cbc_in, 0, sizeof(cbc_in)); @@ -380,7 +380,7 @@ static int test_bf_cfb64(void) BF_KEY key; BF_LONG len; - len = strlen(cbc_data) + 1; + len = (BF_LONG)(strlen(cbc_data) + 1); BF_set_key(&key, 16, cbc_key); memset(cbc_in, 0, 40); @@ -412,7 +412,7 @@ static int test_bf_ofb64(void) BF_KEY key; BF_LONG len; - len = strlen(cbc_data) + 1; + len = (BF_LONG)(strlen(cbc_data) + 1); BF_set_key(&key, 16, cbc_key); memset(cbc_in, 0, 40); diff --git a/test/bio_base64_test.c b/test/bio_base64_test.c index 8d6ca7b58e1..40891ed72ae 100644 --- a/test/bio_base64_test.c +++ b/test/bio_base64_test.c @@ -100,7 +100,7 @@ static int encode(unsigned const char *buf, unsigned buflen, char *encoded, /* Use a verbatim encoding when provided */ if (encoded != NULL) { - int elen = strlen(encoded); + int elen = (int)strlen(encoded); return BIO_write(mem, encoded, elen) == elen; } @@ -152,8 +152,8 @@ static int genb64(char *prefix, char *suffix, unsigned const char *buf, unsigned buflen, int trunc, char *encoded, unsigned llen, unsigned wscnt, char **out) { - int preflen = strlen(prefix); - int sufflen = strlen(suffix); + int preflen = (int)strlen(prefix); + int sufflen = (int)strlen(suffix); int outlen; char newline = '\n'; BUF_MEM *bptr; @@ -174,7 +174,7 @@ static int genb64(char *prefix, char *suffix, unsigned const char *buf, /* Orphan the memory BIO's data buffer */ BIO_get_mem_ptr(mem, &bptr); *out = bptr->data; - outlen = bptr->length; + outlen = (int)bptr->length; bptr->data = NULL; (void) BIO_set_close(mem, BIO_NOCLOSE); BIO_free(mem); diff --git a/test/bio_callback_test.c b/test/bio_callback_test.c index c84346814e1..7f37447850c 100644 --- a/test/bio_callback_test.c +++ b/test/bio_callback_test.c @@ -60,8 +60,8 @@ static int test_bio_callback_ex(void) goto err; BIO_set_callback_ex(bio, my_bio_cb_ex); - i = BIO_write(bio, test1, test1len); - if (!TEST_int_eq(i, test1len) + i = BIO_write(bio, test1, (int)test1len); + if (!TEST_int_eq(i, (int)test1len) || !TEST_int_eq(my_param_count, 2) || !TEST_ptr_eq(my_param_b[0], bio) || !TEST_int_eq(my_param_oper[0], BIO_CB_WRITE) diff --git a/test/bio_comp_test.c b/test/bio_comp_test.c index 9f3bc9b6b1d..bbc5ad0aae7 100644 --- a/test/bio_comp_test.c +++ b/test/bio_comp_test.c @@ -51,8 +51,8 @@ static int do_bio_comp_test(const BIO_METHOD *meth, size_t size) if (!TEST_ptr(bmem = BIO_new(BIO_s_mem()))) goto err; BIO_push(bcomp, bmem); - osize = BIO_write(bcomp, original, size); - if (!TEST_int_eq(osize, size) + osize = BIO_write(bcomp, original, (int)size); + if (!TEST_int_eq(osize, (int)size) || !TEST_true(BIO_flush(bcomp))) goto err; BIO_free(bcomp); @@ -62,9 +62,9 @@ static int do_bio_comp_test(const BIO_METHOD *meth, size_t size) if (!TEST_ptr(bexp = BIO_new(meth))) goto err; BIO_push(bexp, bmem); - rsize = BIO_read(bexp, result, size); + rsize = BIO_read(bexp, result, (int)size); - if (!TEST_int_eq(size, rsize) + if (!TEST_int_eq((int)size, rsize) || !TEST_mem_eq(original, osize, result, rsize)) goto err; diff --git a/test/bio_core_test.c b/test/bio_core_test.c index be2ae49932e..28b7f29c38a 100644 --- a/test/bio_core_test.c +++ b/test/bio_core_test.c @@ -93,7 +93,7 @@ static int test_bio_core(void) goto err; buf[0] = '\0'; - if (!TEST_int_gt(BIO_write(cbio, msg, strlen(msg) + 1), 0) + if (!TEST_int_gt(BIO_write(cbio, msg, (int)(strlen(msg) + 1)), 0) || !TEST_int_gt(BIO_read(cbio, buf, sizeof(buf)), 0) || !TEST_str_eq(buf, msg)) goto err; diff --git a/test/bio_dgram_test.c b/test/bio_dgram_test.c index aca016ca95b..fa1f721aa86 100644 --- a/test/bio_dgram_test.c +++ b/test/bio_dgram_test.c @@ -534,7 +534,7 @@ static int test_bio_dgram_pair(int idx) * set a buffer big enough for 9 full sized datagrams. */ bufsz = 9 * (mtu1 + (sizeof(BIO_ADDR) * 2) + sizeof(size_t)); - if (!TEST_true(BIO_set_write_buf_size(bio1, bufsz))) + if (!TEST_true(BIO_set_write_buf_size(bio1, (long)bufsz))) goto err; } @@ -576,7 +576,7 @@ static int test_bio_dgram_pair(int idx) * the mtu. The default write buffer size is 9 * (sizeof(header) + mtu) so * we expect at least 9 maximally sized datagrams to fit in the buffer. */ - if (!TEST_int_ge(i, 9)) + if (!TEST_size_t_ge(i, 9)) goto err; /* Check we read back the same data */ diff --git a/test/bio_enc_test.c b/test/bio_enc_test.c index df16341fcb5..22d88b688b0 100644 --- a/test/bio_enc_test.c +++ b/test/bio_enc_test.c @@ -275,7 +275,7 @@ static int test_bio_enc_eof_read_flush(void) EVP_CIPHER_CTX *ctx = NULL; BIO *mem = NULL, *b64 = NULL, *cbio = NULL; unsigned char tag[16]; - size_t key_size, iv_size; + int key_size, iv_size; int n, ret = 0; memset(tag, 0, sizeof(tag)); diff --git a/test/bio_readbuffer_test.c b/test/bio_readbuffer_test.c index 58a03c21636..62eb3d7121a 100644 --- a/test/bio_readbuffer_test.c +++ b/test/bio_readbuffer_test.c @@ -35,7 +35,7 @@ static int test_readbuffer_file_bio(int tstid) if (!TEST_ptr(in = BIO_new_file(filename, "r")) || !TEST_int_eq(BIO_read_ex(in, expected, sizeof(expected), &readbytes), 1) - || !TEST_int_lt(readbytes, sizeof(expected))) + || !TEST_size_t_lt(readbytes, sizeof(expected))) goto err; BIO_free(in); in = NULL; @@ -86,7 +86,7 @@ static int test_readbuffer_file_bio(int tstid) count += bytes; len = sizeof(buf); /* fill the buffer on subsequent reads */ } - if (!TEST_int_eq(count, readbytes)) + if (!TEST_size_t_eq(count, readbytes)) goto err; ret = 1; err: diff --git a/test/bntest.c b/test/bntest.c index 3b3671a6225..9bb07936773 100644 --- a/test/bntest.c +++ b/test/bntest.c @@ -117,7 +117,7 @@ static int getint(STANZA *s, int *out, const char *attribute) int st = 0; if (!TEST_ptr(ret = getBN(s, attribute)) - || !TEST_ulong_le(word = BN_get_word(ret), INT_MAX)) + || !TEST_uint64_t_le(word = BN_get_word(ret), INT_MAX)) goto err; *out = (int)word; @@ -1808,7 +1808,7 @@ static int file_gcd(STANZA *s) static int test_bn2padded(void) { uint8_t zeros[256], out[256], reference[128]; - size_t bytes; + int bytes; BIGNUM *n; int st = 0; @@ -1941,7 +1941,7 @@ static int test_bn2signed(int i) * The interesting stuff happens in the last bytes of the buffers, * the beginning is just padding (i.e. sign extension). */ - i = sizeof(scratch) - test->mpi_len; + i = (int)(sizeof(scratch) - test->mpi_len); if (!TEST_int_eq(BN_signed_bn2bin(bn, scratch, sizeof(scratch)), sizeof(scratch)) || !TEST_true(copy_reversed(reversed, scratch, sizeof(scratch))) @@ -1968,7 +1968,7 @@ static int test_bn2signed(int i) * The interesting stuff happens in the first bytes of the buffers, * the end is just padding (i.e. sign extension). */ - i = sizeof(reversed) - test->mpi_len; + i = (int)(sizeof(reversed) - test->mpi_len); if (!TEST_int_eq(BN_signed_bn2lebin(bn, scratch, sizeof(scratch)), sizeof(scratch)) || !TEST_true(copy_reversed(reversed, scratch, sizeof(scratch))) @@ -2212,7 +2212,7 @@ static int test_mpi(int i) || !TEST_mem_eq(test->mpi, test->mpi_len, scratch, mpi_len)) goto err; - if (!TEST_ptr(bn2 = BN_mpi2bn(scratch, mpi_len, NULL))) + if (!TEST_ptr(bn2 = BN_mpi2bn(scratch, (int)mpi_len, NULL))) goto err; if (!TEST_BN_eq(bn, bn2)) { @@ -3358,7 +3358,8 @@ const OPTIONS *test_get_options(void) int setup_tests(void) { OPTION_CHOICE o; - int n, stochastic = 0; + size_t n; + int stochastic = 0; while ((o = opt_next()) != OPT_EOF) { switch (o) { @@ -3372,7 +3373,7 @@ int setup_tests(void) return 0; } } - n = test_get_argument_count(); + n = test_get_argument_count(); if (!TEST_ptr(ctx = BN_CTX_new())) return 0; @@ -3425,7 +3426,7 @@ int setup_tests(void) if (stochastic) ADD_TEST(test_rand_range); } else { - ADD_ALL_TESTS(run_file_tests, n); + ADD_ALL_TESTS(run_file_tests, (int)n); } return 1; } diff --git a/test/clienthellotest.c b/test/clienthellotest.c index 7fc21d9b126..c4077df5642 100644 --- a/test/clienthellotest.c +++ b/test/clienthellotest.c @@ -145,7 +145,7 @@ static int test_client_hello(int currtest) if (currtest == TEST_SET_SESSION_TICK_DATA_VER_NEG) { if (!TEST_true(SSL_set_session_ticket_ext(con, dummytick, - strlen(dummytick)))) + (int)strlen(dummytick)))) goto end; } diff --git a/test/cmactest.c b/test/cmactest.c index a550d4edecd..69067c6a5c3 100644 --- a/test/cmactest.c +++ b/test/cmactest.c @@ -135,7 +135,7 @@ static struct test_st { }, }; -static char *pt(unsigned char *md, unsigned int len); +static char *pt(unsigned char *md, size_t len); static int test_cmac_bad(void) { @@ -328,9 +328,9 @@ err: } #define OSSL_HEX_CHARS_PER_BYTE 2 -static char *pt(unsigned char *md, unsigned int len) +static char *pt(unsigned char *md, size_t len) { - unsigned int i; + size_t i; static char buf[81]; for (i = 0; i < len && (i + 1) * OSSL_HEX_CHARS_PER_BYTE < sizeof(buf); i++) diff --git a/test/cmp_ctx_test.c b/test/cmp_ctx_test.c index f38493b3344..529c0b7aa2a 100644 --- a/test/cmp_ctx_test.c +++ b/test/cmp_ctx_test.c @@ -136,7 +136,7 @@ static int msg_total_size = 0; static int msg_total_size_log_cb(const char *func, const char *file, int line, OSSL_CMP_severity level, const char *msg) { - msg_total_size += strlen(msg); + msg_total_size += (int)strlen(msg); TEST_note("total=%d len=%zu msg='%s'\n", msg_total_size, strlen(msg), msg); return 1; } @@ -171,28 +171,28 @@ static int execute_CTX_print_errors_test(OSSL_CMP_CTX_TEST_FIXTURE *fixture) res = 0; } else { ERR_raise(ERR_LIB_CMP, CMP_R_INVALID_ARGS); - base_err_msg_size = strlen("INVALID_ARGS"); + base_err_msg_size = (int)strlen("INVALID_ARGS"); ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT); - base_err_msg_size += strlen("NULL_ARGUMENT"); + base_err_msg_size += (int)strlen("NULL_ARGUMENT"); expected_size = base_err_msg_size; ossl_cmp_add_error_data("data1"); /* should prepend separator ":" */ - expected_size += strlen(":" "data1"); + expected_size += (int)strlen(":" "data1"); ossl_cmp_add_error_data("data2"); /* should prepend separator " : " */ - expected_size += strlen(" : " "data2"); + expected_size += (int)strlen(" : " "data2"); ossl_cmp_add_error_line("new line"); /* should prepend separator "\n" */ - expected_size += strlen("\n" "new line"); + expected_size += (int)strlen("\n" "new line"); OSSL_CMP_CTX_print_errors(ctx); if (!TEST_int_eq(msg_total_size, expected_size)) res = 0; ERR_raise(ERR_LIB_CMP, CMP_R_INVALID_ARGS); - base_err_msg_size = strlen("INVALID_ARGS") + strlen(":"); + base_err_msg_size = (int)(strlen("INVALID_ARGS") + strlen(":")); expected_size = base_err_msg_size; while (expected_size < 4096) { /* force split */ ERR_add_error_txt(STR_SEP, max_str_literal); - expected_size += strlen(STR_SEP) + strlen(max_str_literal); + expected_size += (int)(strlen(STR_SEP) + strlen(max_str_literal)); } - expected_size += base_err_msg_size - 2 * strlen(STR_SEP); + expected_size += base_err_msg_size - 2 * (int)strlen(STR_SEP); msg_total_size = 0; OSSL_CMP_CTX_print_errors(ctx); if (!TEST_int_eq(msg_total_size, expected_size)) @@ -609,7 +609,7 @@ typedef OSSL_HTTP_bio_cb_t OSSL_CMP_http_cb_t; static int OSSL_CMP_CTX_##SETN##_##FIELD##_str(CMP_CTX *ctx, char *val)\ { \ return OSSL_CMP_CTX_##SETN##_##FIELD(ctx, (unsigned char *)val, \ - strlen(val)); \ + (int)strlen(val)); \ } \ \ static char *OSSL_CMP_CTX_get1_##FIELD##_str(const CMP_CTX *ctx) \ diff --git a/test/cmp_protect_test.c b/test/cmp_protect_test.c index 9b975b86c3a..d54a5112072 100644 --- a/test/cmp_protect_test.c +++ b/test/cmp_protect_test.c @@ -211,7 +211,7 @@ static int test_MSG_protect_unprotected_request(void) static int test_MSG_protect_with_msg_sig_alg_protection_plus_rsa_key(void) { - const size_t size = sizeof(rand_data) / 2; + const int size = sizeof(rand_data) / 2; SETUP_TEST_FIXTURE(CMP_PROTECT_TEST_FIXTURE, set_up); fixture->expected = 1; diff --git a/test/cmsapitest.c b/test/cmsapitest.c index 59dd7faeb28..3d16162c1c3 100644 --- a/test/cmsapitest.c +++ b/test/cmsapitest.c @@ -26,7 +26,7 @@ static int test_encrypt_decrypt(const EVP_CIPHER *cipher) int testresult = 0; STACK_OF(X509) *certstack = sk_X509_new_null(); const char *msg = "Hello world"; - BIO *msgbio = BIO_new_mem_buf(msg, strlen(msg)); + BIO *msgbio = BIO_new_mem_buf(msg, (int)strlen(msg)); BIO *outmsgbio = BIO_new(BIO_s_mem()); CMS_ContentInfo* content = NULL; BIO *contentbio = NULL; @@ -53,7 +53,7 @@ static int test_encrypt_decrypt(const EVP_CIPHER *cipher) goto end; /* Check we got the message we first started with */ - if (!TEST_int_eq(BIO_gets(outmsgbio, buf, sizeof(buf)), strlen(msg)) + if (!TEST_int_eq(BIO_gets(outmsgbio, buf, sizeof(buf)), (int)strlen(msg)) || !TEST_int_eq(strcmp(buf, msg), 0)) goto end; diff --git a/test/constant_time_test.c b/test/constant_time_test.c index ad54dbef458..f658ea5f166 100644 --- a/test/constant_time_test.c +++ b/test/constant_time_test.c @@ -87,7 +87,7 @@ static int test_binary_op_s(size_t (*op) (size_t a, size_t b), { if (is_true && !TEST_size_t_eq(op(a, b), CONSTTIME_TRUE_S)) return 0; - if (!is_true && !TEST_uint_eq(op(a, b), CONSTTIME_FALSE_S)) + if (!is_true && !TEST_size_t_eq(op(a, b), CONSTTIME_FALSE_S)) return 0; return 1; } @@ -149,7 +149,7 @@ static int test_is_zero_s(int i) if (a == 0 && !TEST_size_t_eq(constant_time_is_zero_s(a), CONSTTIME_TRUE_S)) return 0; - if (a != 0 && !TEST_uint_eq(constant_time_is_zero_s(a), CONSTTIME_FALSE_S)) + if (a != 0 && !TEST_size_t_eq(constant_time_is_zero_s(a), CONSTTIME_FALSE_S)) return 0; return 1; } @@ -183,9 +183,9 @@ static int test_select_32(uint32_t a, uint32_t b) static int test_select_s(size_t a, size_t b) { - if (!TEST_uint_eq(constant_time_select_s(CONSTTIME_TRUE_S, a, b), a)) + if (!TEST_size_t_eq(constant_time_select_s(CONSTTIME_TRUE_S, a, b), a)) return 0; - if (!TEST_uint_eq(constant_time_select_s(CONSTTIME_FALSE_S, a, b), b)) + if (!TEST_size_t_eq(constant_time_select_s(CONSTTIME_FALSE_S, a, b), b)) return 0; return 1; } @@ -229,7 +229,7 @@ static int test_eq_s(size_t a, size_t b) { if (a == b && !TEST_size_t_eq(constant_time_eq_s(a, b), CONSTTIME_TRUE_S)) return 0; - if (a != b && !TEST_int_eq(constant_time_eq_s(a, b), CONSTTIME_FALSE_S)) + if (a != b && !TEST_size_t_eq(constant_time_eq_s(a, b), CONSTTIME_FALSE_S)) return 0; return 1; } diff --git a/test/crltest.c b/test/crltest.c index c1844812202..c4e30d14fca 100644 --- a/test/crltest.c +++ b/test/crltest.c @@ -199,7 +199,7 @@ static BIO *glue2bio(const char **pem, char **out) size_t s = 0; *out = glue_strings(pem, &s); - return BIO_new_mem_buf(*out, s); + return BIO_new_mem_buf(*out, (int)s); } /* diff --git a/test/danetest.c b/test/danetest.c index d7ef87b6d26..cce06f57fe1 100644 --- a/test/danetest.c +++ b/test/danetest.c @@ -115,7 +115,7 @@ static STACK_OF(X509) *load_chain(BIO *fp, int nelem) const unsigned char *p = data; if (!TEST_ptr(cert = d(0, &p, len)) - || !TEST_long_eq(p - data, len)) { + || !TEST_long_eq((long)(p - data), len)) { TEST_info("Certificate parsing error"); goto err; } @@ -155,7 +155,7 @@ static char *read_to_eol(BIO *f) if (BIO_gets(f, buf, sizeof(buf)) <= 0) return NULL; - n = strlen(buf); + n = (int)strlen(buf); if (buf[n - 1] != '\n') { if (n + 1 == sizeof(buf)) TEST_error("input too long"); diff --git a/test/decoder_propq_test.c b/test/decoder_propq_test.c index aa374da74c2..f6fe4332193 100644 --- a/test/decoder_propq_test.c +++ b/test/decoder_propq_test.c @@ -42,7 +42,7 @@ const OPTIONS *test_get_options(void) static int passcb(char *buf, int size, int rwflag, void *userdata) { strcpy(buf, "pass"); - return strlen(buf); + return (int)strlen(buf); } static int test_decode_nonfipsalg(void) diff --git a/test/destest.c b/test/destest.c index 7bc844ae88b..0b3bc6dd783 100644 --- a/test/destest.c +++ b/test/destest.c @@ -382,13 +382,13 @@ static int test_des_cbc(void) memset(cbc_out, 0, sizeof(cbc_out)); memset(cbc_in, 0, sizeof(cbc_in)); memcpy(iv3, cbc_iv, sizeof(cbc_iv)); - DES_ncbc_encrypt(cbc_data, cbc_out, cbc_data_len + 1, &ks, + DES_ncbc_encrypt(cbc_data, cbc_out, (long)(cbc_data_len + 1), &ks, &iv3, DES_ENCRYPT); if (!TEST_mem_eq(cbc_out, 32, cbc_ok, 32)) return 0; memcpy(iv3, cbc_iv, sizeof(cbc_iv)); - DES_ncbc_encrypt(cbc_out, cbc_in, cbc_data_len + 1, &ks, + DES_ncbc_encrypt(cbc_out, cbc_in, (long)(cbc_data_len + 1), &ks, &iv3, DES_DECRYPT); return TEST_mem_eq(cbc_in, cbc_data_len, cbc_data, cbc_data_len); } @@ -406,12 +406,12 @@ static int test_des_ede_cbc(void) memset(cbc_out, 0, sizeof(cbc_out)); memset(cbc_in, 0, sizeof(cbc_in)); memcpy(iv3, cbc_iv, sizeof(cbc_iv)); - DES_xcbc_encrypt(cbc_data, cbc_out, n, &ks, &iv3, &cbc2_key, &cbc3_key, + DES_xcbc_encrypt(cbc_data, cbc_out, (long)n, &ks, &iv3, &cbc2_key, &cbc3_key, DES_ENCRYPT); if (!TEST_mem_eq(cbc_out, sizeof(xcbc_ok), xcbc_ok, sizeof(xcbc_ok))) return 0; memcpy(iv3, cbc_iv, sizeof(cbc_iv)); - DES_xcbc_encrypt(cbc_out, cbc_in, n, &ks, &iv3, &cbc2_key, &cbc3_key, + DES_xcbc_encrypt(cbc_out, cbc_in, (long)n, &ks, &iv3, &cbc2_key, &cbc3_key, DES_DECRYPT); return TEST_mem_eq(cbc_data, n, cbc_data, n); } @@ -437,13 +437,13 @@ static int test_ede_cbc(void) DES_ede3_cbc_encrypt(cbc_data, cbc_out, 16L, &ks, &ks2, &ks3, &iv3, DES_ENCRYPT); - DES_ede3_cbc_encrypt(&cbc_data[16], &cbc_out[16], i - 16, &ks, &ks2, + DES_ede3_cbc_encrypt(&cbc_data[16], &cbc_out[16], (long)(i - 16), &ks, &ks2, &ks3, &iv3, DES_ENCRYPT); if (!TEST_mem_eq(cbc_out, n, cbc3_ok, n)) return 0; memcpy(iv3, cbc_iv, sizeof(cbc_iv)); - DES_ede3_cbc_encrypt(cbc_out, cbc_in, i, &ks, &ks2, &ks3, &iv3, + DES_ede3_cbc_encrypt(cbc_out, cbc_in, (long)i, &ks, &ks2, &ks3, &iv3, DES_DECRYPT); return TEST_mem_eq(cbc_in, i, cbc_data, i); } @@ -459,7 +459,7 @@ static int test_input_align(int i) memcpy(iv, cbc_iv, sizeof(cbc_iv)); if (!TEST_int_eq(DES_set_key_checked(&cbc_key, &ks), 0)) return 0; - DES_ncbc_encrypt(&cbc_data[i], cbc_out, n, &ks, &iv, DES_ENCRYPT); + DES_ncbc_encrypt(&cbc_data[i], cbc_out, (long)n, &ks, &iv, DES_ENCRYPT); return 1; } @@ -474,7 +474,7 @@ static int test_output_align(int i) memcpy(iv, cbc_iv, sizeof(cbc_iv)); if (!TEST_int_eq(DES_set_key_checked(&cbc_key, &ks), 0)) return 0; - DES_ncbc_encrypt(cbc_data, &cbc_out[i], n, &ks, &iv, DES_ENCRYPT); + DES_ncbc_encrypt(cbc_data, &cbc_out[i], (long)n, &ks, &iv, DES_ENCRYPT); return 1; } @@ -499,7 +499,7 @@ static int test_des_pcbc(void) unsigned char cbc_in[40]; unsigned char cbc_out[40]; DES_key_schedule ks; - const int n = strlen((char *)cbc_data) + 1; + const int n = (int)(strlen((char *)cbc_data) + 1); if (!TEST_int_eq(DES_set_key_checked(&cbc_key, &ks), 0)) return 0; @@ -682,7 +682,7 @@ static int test_des_cbc_cksum(void) unsigned char cret[8]; DES_set_key_checked(&cbc_key, &ks); - cs = DES_cbc_cksum(cbc_data, &cret, strlen((char *)cbc_data), &ks, + cs = DES_cbc_cksum(cbc_data, &cret, (long)strlen((char *)cbc_data), &ks, &cbc_iv); if (!TEST_cs_eq(cs, cbc_cksum_ret)) return 0; diff --git a/test/dhkem_test.inc b/test/dhkem_test.inc index 8b4d36bbd01..a7dbbf25489 100644 --- a/test/dhkem_test.inc +++ b/test/dhkem_test.inc @@ -575,7 +575,7 @@ static EVP_PKEY *new_raw_private_key(const char *curvename, (char *)priv, privlen)) goto err; } else { - privbn = BN_bin2bn(priv, privlen, NULL); + privbn = BN_bin2bn(priv, (int)privlen, NULL); if (privbn == NULL) goto err; if (!OSSL_PARAM_BLD_push_utf8_string(bld, OSSL_PKEY_PARAM_GROUP_NAME, diff --git a/test/dhtest.c b/test/dhtest.c index 7b101df1a07..3f98e3342fe 100644 --- a/test/dhtest.c +++ b/test/dhtest.c @@ -593,13 +593,13 @@ static int rfc5114_test(void) || !TEST_ptr(dhB = td->get_param())) goto bad_err; - if (!TEST_ptr(priv_key = BN_bin2bn(td->xA, td->xA_len, NULL)) - || !TEST_ptr(pub_key = BN_bin2bn(td->yA, td->yA_len, NULL)) + if (!TEST_ptr(priv_key = BN_bin2bn(td->xA, (int)td->xA_len, NULL)) + || !TEST_ptr(pub_key = BN_bin2bn(td->yA, (int)td->yA_len, NULL)) || !TEST_true(DH_set0_key(dhA, pub_key, priv_key))) goto bad_err; - if (!TEST_ptr(priv_key = BN_bin2bn(td->xB, td->xB_len, NULL)) - || !TEST_ptr(pub_key = BN_bin2bn(td->yB, td->yB_len, NULL)) + if (!TEST_ptr(priv_key = BN_bin2bn(td->xB, (int)td->xB_len, NULL)) + || !TEST_ptr(pub_key = BN_bin2bn(td->yB, (int)td->yB_len, NULL)) || !TEST_true(DH_set0_key(dhB, pub_key, priv_key))) goto bad_err; priv_key = pub_key = NULL; diff --git a/test/dsa_no_digest_size_test.c b/test/dsa_no_digest_size_test.c index 35bfa390394..9712111dbbb 100644 --- a/test/dsa_no_digest_size_test.c +++ b/test/dsa_no_digest_size_test.c @@ -190,12 +190,12 @@ static int sign_and_verify(int len) } /* Verify again using the raw DSA interface */ - if (DSA_verify(0, dataToSign, len, signature, sigLength, dsakey) != 1) { + if (DSA_verify(0, dataToSign, len, signature, (int)sigLength, dsakey) != 1) { TEST_error("Verification with unpadded data failed, len=%d", len); goto end; } - if (DSA_verify(0, paddedData, digestlen, signature, sigLength, dsakey) != 1) { + if (DSA_verify(0, paddedData, digestlen, signature, (int)sigLength, dsakey) != 1) { TEST_error("verify with length %d failed\n", len); goto end; } diff --git a/test/dtls_mtu_test.c b/test/dtls_mtu_test.c index f1b705fd59e..c24efdac7bf 100644 --- a/test/dtls_mtu_test.c +++ b/test/dtls_mtu_test.c @@ -102,7 +102,7 @@ static int mtu_test(SSL_CTX *ctx, const char *cs, int no_etm) for (s = mtus[0]; s <= mtus[29]; s++) { size_t reclen; - if (!TEST_int_eq(SSL_write(clnt_ssl, buf, s), (int)s)) + if (!TEST_int_eq(SSL_write(clnt_ssl, buf, (int)s), (int)s)) goto end; reclen = BIO_read(sc_bio, buf, sizeof(buf)); if (debug) diff --git a/test/ec_internal_test.c b/test/ec_internal_test.c index 0268142ae7f..a8eb33b985e 100644 --- a/test/ec_internal_test.c +++ b/test/ec_internal_test.c @@ -559,13 +559,13 @@ int setup_tests(void) ADD_TEST(ec2m_field_sanity); ADD_TEST(field_tests_ec2_simple); #endif - ADD_ALL_TESTS(field_tests_default, crv_len); + ADD_ALL_TESTS(field_tests_default, (int)crv_len); #ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 ADD_TEST(underflow_test); #endif ADD_TEST(set_private_key); ADD_TEST(decoded_flag_test); - ADD_ALL_TESTS(ecpkparams_i2d2i_test, crv_len); + ADD_ALL_TESTS(ecpkparams_i2d2i_test, (int)crv_len); ADD_TEST(named_group_creation_test); return 1; diff --git a/test/ecdsatest.c b/test/ecdsatest.c index 0ddbf6690dc..d79b02a9da5 100644 --- a/test/ecdsatest.c +++ b/test/ecdsatest.c @@ -45,8 +45,8 @@ static int fbytes(unsigned char *buf, size_t num, ossl_unused const char *name, || !TEST_int_lt(fbytes_counter, OSSL_NELEM(numbers)) || !TEST_true(BN_hex2bn(&tmp, numbers[fbytes_counter])) /* tmp might need leading zeros so pad it out */ - || !TEST_int_le(BN_num_bytes(tmp), num) - || !TEST_int_gt(BN_bn2binpad(tmp, buf, num), 0)) + || !TEST_int_le(BN_num_bytes(tmp), (int)num) + || !TEST_int_gt(BN_bn2binpad(tmp, buf, (int)num), 0)) goto err; fbytes_counter = (fbytes_counter + 1) % OSSL_NELEM(numbers); @@ -122,7 +122,7 @@ static int x9_62_tests(int n) || !TEST_true(p_len = EC_KEY_key2buf(key, POINT_CONVERSION_UNCOMPRESSED, &pbuf, NULL)) || !TEST_ptr(qbuf = OPENSSL_hexstr2buf(ecdsa_cavs_kats[n].Q, &q_len)) - || !TEST_int_eq(q_len, p_len) + || !TEST_size_t_eq((size_t)q_len, p_len) || !TEST_mem_eq(qbuf, q_len, pbuf, p_len)) goto err; @@ -249,7 +249,7 @@ static int test_builtin(int n, int as) || !TEST_true(EVP_DigestSignInit(mctx, NULL, NULL, NULL, pkey)) || (as == EVP_PKEY_SM2 && !set_sm2_id(mctx, pkey)) || !TEST_true(EVP_DigestSign(mctx, sig, &sig_len, tbs, sizeof(tbs))) - || !TEST_int_le(sig_len, ECDSA_size(eckey)) + || !TEST_size_t_le(sig_len, (size_t)ECDSA_size(eckey)) || !TEST_true(EVP_MD_CTX_reset(mctx)) /* negative test, verify with wrong key, 0 return */ || !TEST_true(EVP_DigestVerifyInit(mctx, NULL, NULL, NULL, pkey_neg)) @@ -404,10 +404,10 @@ int setup_tests(void) fake_rand_finish(fake_rand); return 0; } - ADD_ALL_TESTS(test_builtin_as_ec, crv_len); + ADD_ALL_TESTS(test_builtin_as_ec, (int)crv_len); ADD_TEST(test_ecdsa_sig_NULL); # ifndef OPENSSL_NO_SM2 - ADD_ALL_TESTS(test_builtin_as_sm2, crv_len); + ADD_ALL_TESTS(test_builtin_as_sm2, (int)crv_len); # endif ADD_ALL_TESTS(x9_62_tests, OSSL_NELEM(ecdsa_cavs_kats)); #endif diff --git a/test/ectest.c b/test/ectest.c index afbb852d7f7..24fc7e7d8ab 100644 --- a/test/ectest.c +++ b/test/ectest.c @@ -168,8 +168,8 @@ static int prime_field_tests(void) const BIGNUM *scalars[4]; #endif unsigned char buf[100]; - size_t len, r = 0; - int k; + size_t len; + int k, r = 0; if (!TEST_ptr(ctx = BN_CTX_new()) || !TEST_ptr(p = BN_new()) @@ -1576,8 +1576,8 @@ static int check_named_curve_test(int id) if (!TEST_int_eq(EC_GROUP_check_named_curve(group, 0, NULL), nid)) goto err; - if (!TEST_int_eq(EC_GROUP_set_seed(group, invalid_seed, invalid_seed_len), - invalid_seed_len)) + if (!TEST_size_t_eq(EC_GROUP_set_seed(group, invalid_seed, invalid_seed_len), + invalid_seed_len)) goto err; if (has_seed) { @@ -1596,7 +1596,7 @@ static int check_named_curve_test(int id) goto err; } /* Pass if the seed is unknown (as it is optional) */ - if (!TEST_int_eq(EC_GROUP_set_seed(group, NULL, 0), 1) + if (!TEST_size_t_eq(EC_GROUP_set_seed(group, NULL, 0), 1) || !TEST_int_eq(EC_GROUP_check_named_curve(group, 0, NULL), nid)) goto err; @@ -1906,8 +1906,8 @@ static int check_named_curve_from_ecparameters(int id) * An invalid seed in the parameters should be ignored: expect a "named" * group. */ - if (!TEST_int_eq(EC_GROUP_set_seed(tmpg, invalid_seed, invalid_seed_len), - invalid_seed_len) + if (!TEST_size_t_eq(EC_GROUP_set_seed(tmpg, invalid_seed, invalid_seed_len), + invalid_seed_len) || !TEST_ptr(other_params = *p_next++ = EC_GROUP_get_ecparameters(tmpg, NULL)) || !TEST_ptr(tgroup = *g_next++ = @@ -1924,7 +1924,7 @@ static int check_named_curve_from_ecparameters(int id) * A null seed in the parameters should be ignored, as it is optional: * expect a "named" group. */ - if (!TEST_int_eq(EC_GROUP_set_seed(tmpg, NULL, 0), 1) + if (!TEST_size_t_eq(EC_GROUP_set_seed(tmpg, NULL, 0), 1) || !TEST_ptr(other_params = *p_next++ = EC_GROUP_get_ecparameters(tmpg, NULL)) || !TEST_ptr(tgroup = *g_next++ = @@ -2498,7 +2498,7 @@ static int ec_point_hex2point_test(int id) } static int do_test_custom_explicit_fromdata(EC_GROUP *group, BN_CTX *ctx, - unsigned char *gen, int gen_size) + unsigned char *gen, size_t gen_size) { int ret = 0, i_out; EVP_PKEY_CTX *pctx = NULL; @@ -2722,7 +2722,8 @@ err: */ static int custom_generator_test(int id) { - int ret = 0, nid, bsize; + int ret = 0, nid; + size_t bsize; EC_GROUP *group = NULL; EC_POINT *G2 = NULL, *Q1 = NULL, *Q2 = NULL; BN_CTX *ctx = NULL; @@ -2741,7 +2742,7 @@ static int custom_generator_test(int id) goto err; /* expected byte length of encoded points */ - bsize = (EC_GROUP_get_degree(group) + 7) / 8; + bsize = ((size_t)EC_GROUP_get_degree(group) + 7) / 8; bsize = 1 + 2 * bsize; /* UNCOMPRESSED_POINT format */ if (!TEST_ptr(k = BN_CTX_get(ctx)) @@ -2755,13 +2756,13 @@ static int custom_generator_test(int id) /* Q1 := kG */ || !TEST_true(EC_POINT_mul(group, Q1, k, NULL, NULL, ctx)) /* pull out the bytes of that */ - || !TEST_int_eq(EC_POINT_point2oct(group, Q1, - POINT_CONVERSION_UNCOMPRESSED, NULL, - 0, ctx), bsize) + || !TEST_size_t_eq(EC_POINT_point2oct(group, Q1, + POINT_CONVERSION_UNCOMPRESSED, NULL, + 0, ctx), bsize) || !TEST_ptr(b1 = OPENSSL_malloc(bsize)) - || !TEST_int_eq(EC_POINT_point2oct(group, Q1, - POINT_CONVERSION_UNCOMPRESSED, b1, - bsize, ctx), bsize) + || !TEST_size_t_eq(EC_POINT_point2oct(group, Q1, + POINT_CONVERSION_UNCOMPRESSED, b1, + bsize, ctx), bsize) /* new generator is G2 := 2G */ || !TEST_true(EC_POINT_dbl(group, G2, EC_GROUP_get0_generator(group), ctx)) @@ -2772,13 +2773,13 @@ static int custom_generator_test(int id) || !TEST_true(BN_rshift1(k, k)) /* Q2 := k/2 G2 */ || !TEST_true(EC_POINT_mul(group, Q2, k, NULL, NULL, ctx)) - || !TEST_int_eq(EC_POINT_point2oct(group, Q2, - POINT_CONVERSION_UNCOMPRESSED, NULL, - 0, ctx), bsize) + || !TEST_size_t_eq(EC_POINT_point2oct(group, Q2, + POINT_CONVERSION_UNCOMPRESSED, NULL, + 0, ctx), bsize) || !TEST_ptr(b2 = OPENSSL_malloc(bsize)) - || !TEST_int_eq(EC_POINT_point2oct(group, Q2, - POINT_CONVERSION_UNCOMPRESSED, b2, - bsize, ctx), bsize) + || !TEST_size_t_eq(EC_POINT_point2oct(group, Q2, + POINT_CONVERSION_UNCOMPRESSED, b2, + bsize, ctx), bsize) /* Q1 = kG = k/2 G2 = Q2 should hold */ || !TEST_mem_eq(b1, bsize, b2, bsize)) goto err; @@ -2806,7 +2807,7 @@ static int custom_generator_test(int id) */ static int custom_params_test(int id) { - int ret = 0, nid, bsize; + int ret = 0, nid; const char *curve_name = NULL; EC_GROUP *group = NULL, *altgroup = NULL; EC_POINT *G2 = NULL, *Q1 = NULL, *Q2 = NULL; @@ -2820,7 +2821,7 @@ static int custom_params_test(int id) EC_KEY *eckey1 = NULL, *eckey2 = NULL; EVP_PKEY *pkey1 = NULL, *pkey2 = NULL; EVP_PKEY_CTX *pctx1 = NULL, *pctx2 = NULL, *dctx = NULL; - size_t sslen, t; + size_t sslen, t, bsize; unsigned char *pub1 = NULL , *pub2 = NULL; OSSL_PARAM_BLD *param_bld = NULL; OSSL_PARAM *params1 = NULL, *params2 = NULL; @@ -2855,7 +2856,7 @@ static int custom_params_test(int id) #endif /* expected byte length of encoded points */ - bsize = (EC_GROUP_get_degree(group) + 7) / 8; + bsize = ((size_t)EC_GROUP_get_degree(group) + 7) / 8; bsize = 1 + 2 * bsize; /* UNCOMPRESSED_POINT format */ /* extract parameters from built-in curve */ @@ -2865,13 +2866,13 @@ static int custom_params_test(int id) || !TEST_true(EC_POINT_dbl(group, G2, EC_GROUP_get0_generator(group), ctx)) /* pull out the bytes of that */ - || !TEST_int_eq(EC_POINT_point2oct(group, G2, - POINT_CONVERSION_UNCOMPRESSED, - NULL, 0, ctx), bsize) + || !TEST_size_t_eq(EC_POINT_point2oct(group, G2, + POINT_CONVERSION_UNCOMPRESSED, + NULL, 0, ctx), bsize) || !TEST_ptr(buf1 = OPENSSL_malloc(bsize)) - || !TEST_int_eq(EC_POINT_point2oct(group, G2, - POINT_CONVERSION_UNCOMPRESSED, - buf1, bsize, ctx), bsize) + || !TEST_size_t_eq(EC_POINT_point2oct(group, G2, + POINT_CONVERSION_UNCOMPRESSED, + buf1, bsize, ctx), bsize) || !TEST_ptr(z = EC_GROUP_get0_order(group)) || !TEST_ptr(cof = EC_GROUP_get0_cofactor(group)) ) @@ -2910,24 +2911,24 @@ static int custom_params_test(int id) /* Q1 := kG on group */ || !TEST_true(EC_POINT_mul(group, Q1, k, NULL, NULL, ctx)) /* pull out the bytes of that */ - || !TEST_int_eq(EC_POINT_point2oct(group, Q1, - POINT_CONVERSION_UNCOMPRESSED, - NULL, 0, ctx), bsize) - || !TEST_int_eq(EC_POINT_point2oct(group, Q1, - POINT_CONVERSION_UNCOMPRESSED, - buf1, bsize, ctx), bsize) + || !TEST_size_t_eq(EC_POINT_point2oct(group, Q1, + POINT_CONVERSION_UNCOMPRESSED, + NULL, 0, ctx), bsize) + || !TEST_size_t_eq(EC_POINT_point2oct(group, Q1, + POINT_CONVERSION_UNCOMPRESSED, + buf1, bsize, ctx), bsize) /* k := k/2 */ || !TEST_true(BN_rshift1(k, k)) /* Q2 := k/2 G2 on altgroup */ || !TEST_true(EC_POINT_mul(altgroup, Q2, k, NULL, NULL, ctx)) /* pull out the bytes of that */ - || !TEST_int_eq(EC_POINT_point2oct(altgroup, Q2, - POINT_CONVERSION_UNCOMPRESSED, - NULL, 0, ctx), bsize) + || !TEST_size_t_eq(EC_POINT_point2oct(altgroup, Q2, + POINT_CONVERSION_UNCOMPRESSED, + NULL, 0, ctx), bsize) || !TEST_ptr(buf2 = OPENSSL_malloc(bsize)) - || !TEST_int_eq(EC_POINT_point2oct(altgroup, Q2, - POINT_CONVERSION_UNCOMPRESSED, - buf2, bsize, ctx), bsize) + || !TEST_size_t_eq(EC_POINT_point2oct(altgroup, Q2, + POINT_CONVERSION_UNCOMPRESSED, + buf2, bsize, ctx), bsize) /* Q1 = kG = k/2 G2 = Q2 should hold */ || !TEST_mem_eq(buf1, bsize, buf2, bsize)) goto err; @@ -2952,24 +2953,24 @@ static int custom_params_test(int id) * define a provider key in the built-in group. */ if (!TEST_true(EC_POINT_mul(group, Q1, priv1, NULL, NULL, ctx)) - || !TEST_int_eq(EC_POINT_point2oct(group, Q1, - POINT_CONVERSION_UNCOMPRESSED, - NULL, 0, ctx), bsize) + || !TEST_size_t_eq(EC_POINT_point2oct(group, Q1, + POINT_CONVERSION_UNCOMPRESSED, + NULL, 0, ctx), bsize) || !TEST_ptr(pub1 = OPENSSL_malloc(bsize)) - || !TEST_int_eq(EC_POINT_point2oct(group, Q1, - POINT_CONVERSION_UNCOMPRESSED, - pub1, bsize, ctx), bsize)) + || !TEST_size_t_eq(EC_POINT_point2oct(group, Q1, + POINT_CONVERSION_UNCOMPRESSED, + pub1, bsize, ctx), bsize)) goto err; /* retrieve bytes for pub2 for later */ if (!TEST_ptr(Q = EC_KEY_get0_public_key(eckey2)) - || !TEST_int_eq(EC_POINT_point2oct(altgroup, Q, - POINT_CONVERSION_UNCOMPRESSED, - NULL, 0, ctx), bsize) + || !TEST_size_t_eq(EC_POINT_point2oct(altgroup, Q, + POINT_CONVERSION_UNCOMPRESSED, + NULL, 0, ctx), bsize) || !TEST_ptr(pub2 = OPENSSL_malloc(bsize)) - || !TEST_int_eq(EC_POINT_point2oct(altgroup, Q, - POINT_CONVERSION_UNCOMPRESSED, - pub2, bsize, ctx), bsize)) + || !TEST_size_t_eq(EC_POINT_point2oct(altgroup, Q, + POINT_CONVERSION_UNCOMPRESSED, + pub2, bsize, ctx), bsize)) goto err; /* create two `EVP_PKEY`s from the `EC_KEY`s */ @@ -2987,15 +2988,15 @@ static int custom_params_test(int id) || !TEST_int_eq(EVP_PKEY_derive_init(pctx1), 1) || !TEST_int_eq(EVP_PKEY_derive_set_peer(pctx1, pkey2), 1) || !TEST_int_eq(EVP_PKEY_derive(pctx1, NULL, &sslen), 1) - || !TEST_int_gt(bsize, sslen) + || !TEST_size_t_gt(bsize, sslen) || !TEST_int_eq(EVP_PKEY_derive(pctx1, buf1, &sslen), 1)) goto err; if (!TEST_ptr(pctx2 = EVP_PKEY_CTX_new(pkey2, NULL)) || !TEST_int_eq(EVP_PKEY_derive_init(pctx2), 1) || !TEST_int_eq(EVP_PKEY_derive_set_peer(pctx2, pkey1), 1) || !TEST_int_eq(EVP_PKEY_derive(pctx2, NULL, &t), 1) - || !TEST_int_gt(bsize, t) - || !TEST_int_le(sslen, t) + || !TEST_size_t_gt(bsize, t) + || !TEST_size_t_le(sslen, t) || !TEST_int_eq(EVP_PKEY_derive(pctx2, buf2, &t), 1)) goto err; @@ -3045,8 +3046,8 @@ static int custom_params_test(int id) || !TEST_ptr(dctx = EVP_PKEY_CTX_dup(pctx1)) || !TEST_int_eq(EVP_PKEY_derive_set_peer_ex(dctx, pkey2, 1), 1) || !TEST_int_eq(EVP_PKEY_derive(dctx, NULL, &t), 1) - || !TEST_int_gt(bsize, t) - || !TEST_int_le(sslen, t) + || !TEST_size_t_gt(bsize, t) + || !TEST_size_t_le(sslen, t) || !TEST_int_eq(EVP_PKEY_derive(dctx, buf1, &t), 1) /* compare with previous result */ || !TEST_mem_eq(buf1, t, buf2, sslen)) @@ -3131,7 +3132,7 @@ int setup_tests(void) ADD_TEST(parameter_test); ADD_TEST(ossl_parameter_test); ADD_TEST(cofactor_range_test); - ADD_ALL_TESTS(cardinality_test, crv_len); + ADD_ALL_TESTS(cardinality_test, (int)crv_len); ADD_TEST(prime_field_tests); #ifndef OPENSSL_NO_EC2M ADD_TEST(hybrid_point_encoding_test); @@ -3139,16 +3140,16 @@ int setup_tests(void) ADD_ALL_TESTS(char2_curve_test, OSSL_NELEM(char2_curve_tests)); #endif ADD_ALL_TESTS(nistp_single_test, OSSL_NELEM(nistp_tests_params)); - ADD_ALL_TESTS(internal_curve_test, crv_len); - ADD_ALL_TESTS(internal_curve_test_method, crv_len); + ADD_ALL_TESTS(internal_curve_test, (int)crv_len); + ADD_ALL_TESTS(internal_curve_test_method, (int)crv_len); ADD_TEST(group_field_test); - ADD_ALL_TESTS(check_named_curve_test, crv_len); - ADD_ALL_TESTS(check_named_curve_lookup_test, crv_len); - ADD_ALL_TESTS(check_ec_key_field_public_range_test, crv_len); - ADD_ALL_TESTS(check_named_curve_from_ecparameters, crv_len); - ADD_ALL_TESTS(ec_point_hex2point_test, crv_len); - ADD_ALL_TESTS(custom_generator_test, crv_len); - ADD_ALL_TESTS(custom_params_test, crv_len); + ADD_ALL_TESTS(check_named_curve_test, (int)crv_len); + ADD_ALL_TESTS(check_named_curve_lookup_test, (int)crv_len); + ADD_ALL_TESTS(check_ec_key_field_public_range_test, (int)crv_len); + ADD_ALL_TESTS(check_named_curve_from_ecparameters, (int)crv_len); + ADD_ALL_TESTS(ec_point_hex2point_test, (int)crv_len); + ADD_ALL_TESTS(custom_generator_test, (int)crv_len); + ADD_ALL_TESTS(custom_params_test, (int)crv_len); ADD_TEST(ec_d2i_publickey_test); return 1; } diff --git a/test/endecode_test.c b/test/endecode_test.c index d6ee5a59b91..76b9348ec1a 100644 --- a/test/endecode_test.c +++ b/test/endecode_test.c @@ -273,7 +273,7 @@ static int encode_EVP_PKEY_prov(const char *file, const int line, || !TEST_FL_true(OSSL_ENCODER_to_bio(ectx, mem_ser)) || !TEST_FL_true(BIO_get_mem_ptr(mem_ser, &mem_buf) > 0) || !TEST_FL_ptr(*encoded = mem_buf->data) - || !TEST_FL_long_gt(*encoded_len = mem_buf->length, 0)) + || !TEST_FL_long_gt(*encoded_len = (long)mem_buf->length, 0)) goto end; /* Detach the encoded output */ @@ -412,11 +412,11 @@ static int encode_EVP_PKEY_legacy_PEM(const char *file, const int line, if (!TEST_FL_ptr(mem_ser = BIO_new(BIO_s_mem())) || !TEST_FL_true(PEM_write_bio_PrivateKey_traditional(mem_ser, pkey, cipher, - upass, passlen, + upass, (int)passlen, NULL, NULL)) || !TEST_FL_true(BIO_get_mem_ptr(mem_ser, &mem_buf) > 0) || !TEST_FL_ptr(*encoded = mem_buf->data) - || !TEST_FL_long_gt(*encoded_len = mem_buf->length, 0)) + || !TEST_FL_long_gt(*encoded_len = (long)mem_buf->length, 0)) goto end; /* Detach the encoded output */ @@ -455,7 +455,7 @@ static int encode_EVP_PKEY_MSBLOB(const char *file, const int line, if (!TEST_FL_true(BIO_get_mem_ptr(mem_ser, &mem_buf) > 0) || !TEST_FL_ptr(*encoded = mem_buf->data) - || !TEST_FL_long_gt(*encoded_len = mem_buf->length, 0)) + || !TEST_FL_long_gt(*encoded_len = (long)mem_buf->length, 0)) goto end; /* Detach the encoded output */ @@ -471,7 +471,7 @@ static pem_password_cb pass_pw; static int pass_pw(char *buf, int size, int rwflag, void *userdata) { OPENSSL_strlcpy(buf, userdata, size); - return strlen(userdata); + return (int)strlen(userdata); } static int encode_EVP_PKEY_PVK(const char *file, const int line, @@ -495,7 +495,7 @@ static int encode_EVP_PKEY_PVK(const char *file, const int line, pass_pw, (void *)pass, testctx, testpropq), 0) || !TEST_FL_true(BIO_get_mem_ptr(mem_ser, &mem_buf) > 0) || !TEST_FL_ptr(*encoded = mem_buf->data) - || !TEST_FL_long_gt(*encoded_len = mem_buf->length, 0)) + || !TEST_FL_long_gt(*encoded_len = (long)mem_buf->length, 0)) goto end; /* Detach the encoded output */ @@ -562,7 +562,7 @@ static int check_unprotected_PKCS8_DER(const char *file, const int line, { const unsigned char *datap = data; PKCS8_PRIV_KEY_INFO *p8inf = - d2i_PKCS8_PRIV_KEY_INFO(NULL, &datap, data_len); + d2i_PKCS8_PRIV_KEY_INFO(NULL, &datap, (long)data_len); int ok = 0; if (TEST_FL_ptr(p8inf)) { @@ -647,7 +647,7 @@ static int check_params_DER(const char *file, const int line, itype = EVP_PKEY_EC; if (itype != NID_undef) { - pkey = d2i_KeyParams(itype, NULL, &datap, data_len); + pkey = d2i_KeyParams(itype, NULL, &datap, (long)data_len); ok = (pkey != NULL); EVP_PKEY_free(pkey); } @@ -718,7 +718,7 @@ static int check_MSBLOB(const char *file, const int line, const char *type, const void *data, size_t data_len) { const unsigned char *datap = data; - EVP_PKEY *pkey = b2i_PrivateKey(&datap, data_len); + EVP_PKEY *pkey = b2i_PrivateKey(&datap, (long)data_len); int ok = TEST_FL_ptr(pkey); EVP_PKEY_free(pkey); @@ -743,7 +743,8 @@ static int check_PVK(const char *file, const int line, unsigned int saltlen = 0, keylen = 0; int isdss = -1; - return ossl_do_PVK_header(&in, data_len, 0, &isdss, &saltlen, &keylen); + return ossl_do_PVK_header(&in, (unsigned int)data_len, 0, &isdss, &saltlen, + &keylen); } static int test_unprotected_via_PVK(const char *type, EVP_PKEY *key) @@ -765,7 +766,7 @@ static int check_protected_PKCS8_DER(const char *file, const int line, const void *data, size_t data_len) { const unsigned char *datap = data; - X509_SIG *p8 = d2i_X509_SIG(NULL, &datap, data_len); + X509_SIG *p8 = d2i_X509_SIG(NULL, &datap, (long)data_len); int ok = TEST_FL_ptr(p8); X509_SIG_free(p8); @@ -858,7 +859,8 @@ static int check_public_DER(const char *file, const int line, const char *type, const void *data, size_t data_len) { const unsigned char *datap = data; - EVP_PKEY *pkey = d2i_PUBKEY_ex(NULL, &datap, data_len, testctx, testpropq); + EVP_PKEY *pkey = d2i_PUBKEY_ex(NULL, &datap, (long)data_len, testctx, + testpropq); int ok = (TEST_FL_ptr(pkey) && TEST_FL_true(EVP_PKEY_is_a(pkey, type))); EVP_PKEY_free(pkey); @@ -903,7 +905,7 @@ static int check_public_MSBLOB(const char *file, const int line, const void *data, size_t data_len) { const unsigned char *datap = data; - EVP_PKEY *pkey = b2i_PublicKey(&datap, data_len); + EVP_PKEY *pkey = b2i_PublicKey(&datap, (long)data_len); int ok = TEST_FL_ptr(pkey); EVP_PKEY_free(pkey); diff --git a/test/enginetest.c b/test/enginetest.c index 79ffb230548..0a9128d506f 100644 --- a/test/enginetest.c +++ b/test/enginetest.c @@ -446,7 +446,7 @@ int setup_tests(void) #ifdef OPENSSL_NO_ENGINE TEST_note("No ENGINE support"); #else - int n; + size_t n; if (!test_skip_common_options()) { TEST_error("Error parsing test options\n"); diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index 3215ff655fe..99189a20b33 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -1361,11 +1361,11 @@ static int test_EC_priv_pub(void) goto err; /* Positive and negative testcase for EVP_PKEY_get1_encoded_public_key */ - if (!TEST_int_gt(EVP_PKEY_get1_encoded_public_key(params_and_pub, &encoded), 0)) + if (!TEST_size_t_gt(EVP_PKEY_get1_encoded_public_key(params_and_pub, &encoded), 0)) goto err; OPENSSL_free(encoded); encoded = NULL; - if (!TEST_int_eq(EVP_PKEY_get1_encoded_public_key(just_params, &encoded), 0)) { + if (!TEST_size_t_eq(EVP_PKEY_get1_encoded_public_key(just_params, &encoded), 0)) { OPENSSL_free(encoded); encoded = NULL; goto err; @@ -1375,14 +1375,14 @@ static int test_EC_priv_pub(void) if (!TEST_int_eq(EVP_PKEY_get_octet_string_param(params_and_pub, OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY, buffer, sizeof(buffer), &len), 1) - || !TEST_int_eq(len, 65)) + || !TEST_size_t_eq(len, 65)) goto err; len = 0; if (!TEST_int_eq(EVP_PKEY_get_octet_string_param(params_and_pub, OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY, NULL, 0, &len), 1) - || !TEST_int_eq(len, 65)) + || !TEST_size_t_eq(len, 65)) goto err; /* too-short buffer len*/ @@ -2201,7 +2201,7 @@ static int test_d2i_AutoPrivateKey(int i) int expected_id = ak->evptype; p = input; - if (!TEST_ptr(pkey = d2i_AutoPrivateKey(NULL, &p, input_len)) + if (!TEST_ptr(pkey = d2i_AutoPrivateKey(NULL, &p, (long)input_len)) || !TEST_ptr_eq(p, input + input_len) || !TEST_int_eq(EVP_PKEY_get_id(pkey), expected_id)) goto done; @@ -2310,7 +2310,7 @@ static int test_EVP_PKCS82PKEY_v2(int i) /* Can we parse PKCS#8 v2, ignoring the public key for now? */ p = input; - p8inf = d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, input_len); + p8inf = d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, (long)input_len); if (!TEST_ptr(p8inf) || !TEST_true(p == input + input_len)) goto done; @@ -2494,7 +2494,7 @@ static int test_EVP_SM2_verify(void) EVP_PKEY_CTX *pctx = NULL; EVP_MD *sm3 = NULL; - bio = BIO_new_mem_buf(pubkey, strlen(pubkey)); + bio = BIO_new_mem_buf(pubkey, (int)strlen(pubkey)); if (!TEST_true(bio != NULL)) goto done; @@ -2519,7 +2519,7 @@ static int test_EVP_SM2_verify(void) if (!TEST_true(EVP_DigestVerifyInit(mctx, NULL, sm3, NULL, pkey))) goto done; - if (!TEST_int_gt(EVP_PKEY_CTX_set1_id(pctx, id, strlen(id)), 0)) + if (!TEST_int_gt(EVP_PKEY_CTX_set1_id(pctx, id, (int)strlen(id)), 0)) goto done; if (!TEST_true(EVP_DigestVerifyUpdate(mctx, msg, strlen(msg)))) @@ -3127,7 +3127,7 @@ static struct keys_st { #ifndef OPENSSL_NO_ML_KEM static int -ml_kem_seed_to_priv(const char *alg, const unsigned char *seed, int seedlen, +ml_kem_seed_to_priv(const char *alg, const unsigned char *seed, size_t seedlen, unsigned char **ret, size_t *retlen) { OSSL_PARAM parr[2] = { OSSL_PARAM_END, OSSL_PARAM_END }; @@ -3571,7 +3571,7 @@ static int test_X509_PUBKEY_inplace(void) if (!TEST_ptr(xp)) goto done; - if (!TEST_ptr(d2i_X509_PUBKEY(&xp, &p, input_len))) + if (!TEST_ptr(d2i_X509_PUBKEY(&xp, &p, (long)input_len))) goto done; if (!TEST_ptr(X509_PUBKEY_get0(xp))) @@ -3580,7 +3580,7 @@ static int test_X509_PUBKEY_inplace(void) p = kExampleBadECPubKeyDER; input_len = sizeof(kExampleBadECPubKeyDER); - if (!TEST_ptr(xp = d2i_X509_PUBKEY(&xp, &p, input_len))) + if (!TEST_ptr(xp = d2i_X509_PUBKEY(&xp, &p, (long)input_len))) goto done; if (!TEST_true(X509_PUBKEY_get0(xp) == NULL)) @@ -3602,7 +3602,7 @@ static int test_X509_PUBKEY_dup(void) xp = X509_PUBKEY_new_ex(testctx, testpropq); if (!TEST_ptr(xp) - || !TEST_ptr(d2i_X509_PUBKEY(&xp, &p, input_len)) + || !TEST_ptr(d2i_X509_PUBKEY(&xp, &p, (long)input_len)) || !TEST_ptr(xq = X509_PUBKEY_dup(xp)) || !TEST_ptr_ne(xp, xq)) goto done; @@ -3617,7 +3617,7 @@ static int test_X509_PUBKEY_dup(void) p = kExampleBadECPubKeyDER; input_len = sizeof(kExampleBadECPubKeyDER); - if (!TEST_ptr(xp = d2i_X509_PUBKEY(&xp, &p, input_len)) + if (!TEST_ptr(xp = d2i_X509_PUBKEY(&xp, &p, (long)input_len)) || !TEST_ptr(xq = X509_PUBKEY_dup(xp))) goto done; @@ -4434,7 +4434,7 @@ static int test_evp_iv_aes(int idx) goto err; ivlen = EVP_CIPHER_CTX_get_iv_length(ctx); - if (!TEST_int_gt(ivlen, 0)) + if (!TEST_size_t_gt(ivlen, 0)) goto err; if (!TEST_mem_eq(init_iv, ivlen, oiv, ivlen) @@ -4551,7 +4551,7 @@ static int test_evp_iv_des(int idx) goto err; ivlen = EVP_CIPHER_CTX_get_iv_length(ctx); - if (!TEST_int_gt(ivlen, 0)) + if (!TEST_size_t_gt(ivlen, 0)) goto err; if (!TEST_mem_eq(init_iv, ivlen, oiv, ivlen) @@ -4873,7 +4873,8 @@ static int evp_init_seq_set_iv(EVP_CIPHER_CTX *ctx, const EVP_INIT_TEST_st *t) int res = 0; if (t->ivlen != 0) { - if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, t->ivlen, NULL), 0)) + if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, + (int)t->ivlen, NULL), 0)) goto err; } if (!TEST_true(EVP_CipherInit_ex(ctx, NULL, NULL, NULL, t->iv, -1))) @@ -4933,14 +4934,14 @@ static int test_evp_init_seq(int idx) errmsg = "FINAL_ENC_INIT"; goto err; } - if (!TEST_true(EVP_CipherUpdate(ctx, outbuf, &outlen1, t->input, t->inlen))) { + if (!TEST_true(EVP_CipherUpdate(ctx, outbuf, &outlen1, t->input, (int)t->inlen))) { errmsg = "CIPHER_UPDATE"; goto err; } if (t->finalenc == 0 && t->tag != NULL) { /* Set expected tag */ if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, - t->taglen, (void *)t->tag), 0)) { + (int)t->taglen, (void *)t->tag), 0)) { errmsg = "SET_TAG"; goto err; } @@ -4954,7 +4955,8 @@ static int test_evp_init_seq(int idx) goto err; } if (t->finalenc != 0 && t->tag != NULL) { - if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, taglen, tag), 0)) { + if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, + (int)taglen, tag), 0)) { errmsg = "GET_TAG"; goto err; } @@ -4991,14 +4993,16 @@ static int test_evp_reinit_seq(int idx) /* setup cipher context */ || !TEST_true(EVP_CipherInit_ex2(ctx, type, t->key, t->iv, t->initenc, NULL)) /* first iteration */ - || !TEST_true(EVP_CipherUpdate(ctx, outbuf1, &outlen1, t->input, t->inlen)) + || !TEST_true(EVP_CipherUpdate(ctx, outbuf1, &outlen1, t->input, + (int)t->inlen)) || !TEST_true(EVP_CipherFinal_ex(ctx, outbuf1, &outlen_final)) /* check test results iteration 1 */ || !TEST_mem_eq(t->expected, t->expectedlen, outbuf1, outlen1 + outlen_final) /* now re-init the context (same cipher, key and iv) */ || !TEST_true(EVP_CipherInit_ex2(ctx, NULL, NULL, NULL, -1, NULL)) /* second iteration */ - || !TEST_true(EVP_CipherUpdate(ctx, outbuf2, &outlen2, t->input, t->inlen)) + || !TEST_true(EVP_CipherUpdate(ctx, outbuf2, &outlen2, + t->input, (int)t->inlen)) || !TEST_true(EVP_CipherFinal_ex(ctx, outbuf2, &outlen_final)) /* check test results iteration 2 */ || !TEST_mem_eq(t->expected, t->expectedlen, outbuf2, outlen2 + outlen_final)) @@ -5059,7 +5063,8 @@ static int test_evp_reset(int idx) errmsg = "PADDING"; goto err; } - if (!TEST_true(EVP_CipherUpdate(ctx, outbuf, &outlen1, t->input, t->inlen))) { + if (!TEST_true(EVP_CipherUpdate(ctx, outbuf, &outlen1, + t->input, (int)t->inlen))) { errmsg = "CIPHER_UPDATE"; goto err; } @@ -5075,7 +5080,8 @@ static int test_evp_reset(int idx) errmsg = "CIPHER_REINIT"; goto err; } - if (!TEST_true(EVP_CipherUpdate(ctx, outbuf, &outlen1, t->input, t->inlen))) { + if (!TEST_true(EVP_CipherUpdate(ctx, outbuf, &outlen1, + t->input, (int)t->inlen))) { errmsg = "CIPHER_UPDATE (reinit)"; goto err; } @@ -5259,7 +5265,8 @@ static int test_gcm_reinit(int idx) errmsg = "ENC_INIT"; goto err; } - if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, t->ivlen1, NULL), 0)) { + if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, + (int)t->ivlen1, NULL), 0)) { errmsg = "SET_IVLEN1"; goto err; } @@ -5285,7 +5292,8 @@ static int test_gcm_reinit(int idx) errmsg = "WRONG_RESULT1"; goto err; } - if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, taglen, tag), 0)) { + if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, + (int)taglen, tag), 0)) { errmsg = "GET_TAG1"; goto err; } @@ -5294,7 +5302,8 @@ static int test_gcm_reinit(int idx) goto err; } /* Now reinit */ - if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, t->ivlen2, NULL), 0)) { + if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, + (int)t->ivlen2, NULL), 0)) { errmsg = "SET_IVLEN2"; goto err; } @@ -5319,7 +5328,8 @@ static int test_gcm_reinit(int idx) errmsg = "WRONG_RESULT2"; goto err; } - if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, taglen, tag), 0)) { + if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, + (int)taglen, tag), 0)) { errmsg = "GET_TAG2"; goto err; } @@ -6262,9 +6272,9 @@ static int aes_gcm_encrypt(const unsigned char *gcm_key, size_t gcm_key_s, if (!TEST_true(EVP_EncryptInit_ex2(ctx, cipher, gcm_key, gcm_iv, params)) || (gcm_aad != NULL && !TEST_true(EVP_EncryptUpdate(ctx, NULL, &outlen, - gcm_aad, gcm_aad_s))) + gcm_aad, (int)gcm_aad_s))) || !TEST_true(EVP_EncryptUpdate(ctx, outbuf, &outlen, - gcm_pt, gcm_pt_s)) + gcm_pt, (int)gcm_pt_s)) || !TEST_true(EVP_EncryptFinal_ex(ctx, outbuf, &tmplen))) goto err; @@ -6312,9 +6322,9 @@ static int aes_gcm_decrypt(const unsigned char *gcm_key, size_t gcm_key_s, if (!TEST_true(EVP_DecryptInit_ex2(ctx, cipher, gcm_key, gcm_iv, params)) || (gcm_aad != NULL && !TEST_true(EVP_DecryptUpdate(ctx, NULL, &outlen, - gcm_aad, gcm_aad_s))) + gcm_aad, (int)gcm_aad_s))) || !TEST_true(EVP_DecryptUpdate(ctx, outbuf, &outlen, - gcm_ct, gcm_ct_s)) + gcm_ct, (int)gcm_ct_s)) || !TEST_mem_eq(outbuf, outlen, gcm_pt, gcm_pt_s)) goto err; @@ -6398,7 +6408,7 @@ static int rc4_encrypt(const unsigned char *rc4_key, size_t rc4_key_s, if (!TEST_true(EVP_EncryptInit_ex2(ctx, cipher, rc4_key, NULL, params)) || !TEST_true(EVP_EncryptUpdate(ctx, outbuf, &outlen, - rc4_pt, rc4_pt_s)) + rc4_pt, (int)rc4_pt_s)) || !TEST_true(EVP_EncryptFinal_ex(ctx, outbuf, &tmplen))) goto err; @@ -6437,7 +6447,7 @@ static int rc4_decrypt(const unsigned char *rc4_key, size_t rc4_key_s, if (!TEST_true(EVP_DecryptInit_ex2(ctx, cipher, rc4_key, NULL, params)) || !TEST_true(EVP_DecryptUpdate(ctx, outbuf, &outlen, - rc4_ct, rc4_ct_s)) + rc4_ct, (int)rc4_ct_s)) || !TEST_mem_eq(outbuf, outlen, rc4_pt, rc4_pt_s)) goto err; @@ -6568,8 +6578,8 @@ static int test_evp_cipher_pipeline(void) || !TEST_ptr(tag_array[i] = OPENSSL_malloc(taglen))) goto err; - memset(iv_array[i], i + 33, ivlen); - memset(plaintext_array[i], i + 1, plaintextlen); + memset(iv_array[i], (unsigned char)(i + 33), ivlen); + memset(plaintext_array[i], (unsigned char)(i + 1), plaintextlen); inlen_array[i] = plaintextlen; outlen_array[i] = 0; ciphertextlen_array[i] = 0; @@ -6623,10 +6633,10 @@ static int test_evp_cipher_pipeline(void) if (!TEST_true(EVP_EncryptInit(ctx, cipher, key, iv_array[i])) || !TEST_true(EVP_EncryptUpdate(ctx, NULL, &outlen, plaintext_array[i], - plaintextlen)) + (int)plaintextlen)) || !TEST_true(EVP_EncryptUpdate(ctx, ciphertext, &outlen, plaintext_array[i], - plaintextlen))) + (int)plaintextlen))) goto err; ciphertextlen = outlen; @@ -6676,7 +6686,7 @@ static int test_evp_cipher_pipeline(void) goto err; for (i = 0; i < numpipes; i++) { - memset(exp_plaintext, i + 1, plaintextlen); + memset(exp_plaintext, (unsigned char)(i + 1), plaintextlen); if (!TEST_mem_eq(plaintext_array[i], plaintextlen, exp_plaintext, plaintextlen)) goto err; diff --git a/test/evp_extra_test2.c b/test/evp_extra_test2.c index 34cceb5ebfc..7dab65ab1db 100644 --- a/test/evp_extra_test2.c +++ b/test/evp_extra_test2.c @@ -601,8 +601,8 @@ static int test_d2i_AutoPrivateKey_ex(int i) BIGNUM *priv_bn = NULL; p = input; - if (!TEST_ptr(pkey = d2i_AutoPrivateKey_ex(NULL, &p, input_len, mainctx, - NULL)) + if (!TEST_ptr(pkey = d2i_AutoPrivateKey_ex(NULL, &p, (long)input_len, + mainctx, NULL)) || !TEST_ptr_eq(p, input + input_len) || !TEST_int_eq(EVP_PKEY_get_id(pkey), expected_id)) goto done; @@ -759,7 +759,7 @@ static int test_d2i_PrivateKey_ex(int testid) if (!TEST_ptr(provider = OSSL_PROVIDER_load(NULL, "default"))) goto err; - if (!TEST_ptr(key_bio = BIO_new_mem_buf(keydata[id].kder, keydata[id].size))) + if (!TEST_ptr(key_bio = BIO_new_mem_buf(keydata[id].kder, (int)keydata[id].size))) goto err; if (!TEST_ptr_null(pkey = PEM_read_bio_PrivateKey(key_bio, NULL, NULL, NULL))) goto err; @@ -786,7 +786,8 @@ static int test_PEM_read_bio_negative(int testid) BIO *key_bio = NULL; EVP_PKEY *pkey = NULL; - if (!TEST_ptr(key_bio = BIO_new_mem_buf(keydata[testid].kder, keydata[testid].size))) + if (!TEST_ptr(key_bio = BIO_new_mem_buf(keydata[testid].kder, + (int)keydata[testid].size))) goto err; ERR_clear_error(); if (!TEST_ptr_null(pkey = PEM_read_bio_PrivateKey(key_bio, NULL, NULL, NULL))) @@ -1058,7 +1059,7 @@ static int do_check_bn(OSSL_PARAM params[], const char *key, ret = TEST_ptr(p = OSSL_PARAM_locate(params, key)) && TEST_true(OSSL_PARAM_get_BN(p, &bn)) - && TEST_int_gt(len = BN_bn2binpad(bn, buffer, expected_len), 0) + && TEST_int_gt(len = BN_bn2binpad(bn, buffer, (int)expected_len), 0) && TEST_mem_eq(expected, expected_len, buffer, len); BN_free(bn); return ret; @@ -1216,7 +1217,7 @@ static int test_pkey_todata_null(void) int ret = 0; const unsigned char *pdata = keydata[0].kder; - ret = TEST_ptr(pkey = d2i_AutoPrivateKey_ex(NULL, &pdata, keydata[0].size, + ret = TEST_ptr(pkey = d2i_AutoPrivateKey_ex(NULL, &pdata, (long)keydata[0].size, mainctx, NULL)) && TEST_int_eq(EVP_PKEY_todata(NULL, EVP_PKEY_KEYPAIR, ¶ms), 0) && TEST_int_eq(EVP_PKEY_todata(pkey, EVP_PKEY_KEYPAIR, NULL), 0); @@ -1239,7 +1240,7 @@ static int test_pkey_export_null(void) int ret = 0; const unsigned char *pdata = keydata[0].kder; - ret = TEST_ptr(pkey = d2i_AutoPrivateKey_ex(NULL, &pdata, keydata[0].size, + ret = TEST_ptr(pkey = d2i_AutoPrivateKey_ex(NULL, &pdata, (long)keydata[0].size, mainctx, NULL)) && TEST_int_eq(EVP_PKEY_export(NULL, EVP_PKEY_KEYPAIR, test_pkey_export_cb, NULL), 0) @@ -1256,7 +1257,7 @@ static int test_pkey_export(void) #endif int ret = 1; const unsigned char *pdata = keydata[0].kder; - int pdata_len = keydata[0].size; + int pdata_len = (int)keydata[0].size; if (!TEST_ptr(pkey = d2i_AutoPrivateKey_ex(NULL, &pdata, pdata_len, mainctx, NULL)) @@ -1270,7 +1271,7 @@ static int test_pkey_export(void) #ifndef OPENSSL_NO_DEPRECATED_3_0 /* Now, try with a legacy key */ pdata = keydata[0].kder; - pdata_len = keydata[0].size; + pdata_len = (int)keydata[0].size; if (!TEST_ptr(pkey = EVP_PKEY_new()) || !TEST_ptr(rsa = d2i_RSAPrivateKey(NULL, &pdata, pdata_len)) || !TEST_true(EVP_PKEY_set1_RSA(pkey, rsa)) @@ -1304,13 +1305,13 @@ static int test_rsa_pss_sign(void) (char *)mdname, 0); sig_params[2] = OSSL_PARAM_construct_end(); - ret = TEST_ptr(pkey = d2i_AutoPrivateKey_ex(NULL, &pdata, keydata[0].size, + ret = TEST_ptr(pkey = d2i_AutoPrivateKey_ex(NULL, &pdata, (long)keydata[0].size, mainctx, NULL)) && TEST_ptr(pctx = EVP_PKEY_CTX_new_from_pkey(mainctx, pkey, NULL)) && TEST_int_gt(EVP_PKEY_sign_init_ex(pctx, sig_params), 0) && TEST_int_gt(EVP_PKEY_sign(pctx, NULL, &sig_len, mdbuf, sizeof(mdbuf)), 0) - && TEST_int_gt(sig_len, 0) + && TEST_size_t_gt(sig_len, 0) && TEST_ptr(sig = OPENSSL_malloc(sig_len)) && TEST_int_gt(EVP_PKEY_sign(pctx, sig, &sig_len, mdbuf, sizeof(mdbuf)), 0); diff --git a/test/evp_fetch_prov_test.c b/test/evp_fetch_prov_test.c index 876d6ccc0a3..71b59034bf6 100644 --- a/test/evp_fetch_prov_test.c +++ b/test/evp_fetch_prov_test.c @@ -270,7 +270,7 @@ static int encrypt_decrypt(const EVP_CIPHER *cipher, const unsigned char *msg, memset(key, 0, sizeof(key)); if (!TEST_ptr(ctx = EVP_CIPHER_CTX_new()) || !TEST_true(EVP_CipherInit_ex(ctx, cipher, NULL, key, NULL, 1)) - || !TEST_true(EVP_CipherUpdate(ctx, ct, &ctlen, msg, len)) + || !TEST_true(EVP_CipherUpdate(ctx, ct, &ctlen, msg, (int)len)) || !TEST_true(EVP_CipherFinal_ex(ctx, ct, &ctlen)) || !TEST_true(EVP_CipherInit_ex(ctx, cipher, NULL, key, NULL, 0)) || !TEST_true(EVP_CipherUpdate(ctx, pt, &ptlen, ct, ctlen)) diff --git a/test/evp_libctx_test.c b/test/evp_libctx_test.c index 706460170b9..6a3a44e14b6 100644 --- a/test/evp_libctx_test.c +++ b/test/evp_libctx_test.c @@ -561,7 +561,7 @@ static int rsa_keygen(int bits, EVP_PKEY **pub, EVP_PKEY **priv) || !TEST_true(OSSL_ENCODER_to_data(ectx, &pub_der, &len))) goto err; pp = pub_der; - if (!TEST_ptr(d2i_PublicKey(EVP_PKEY_RSA, pub, &pp, len))) + if (!TEST_ptr(d2i_PublicKey(EVP_PKEY_RSA, pub, &pp, (long)len))) goto err; ret = 1; err: @@ -591,8 +591,8 @@ static int kem_rsa_gen_recover(void) && TEST_int_eq(EVP_PKEY_encapsulate(dctx, NULL, NULL, NULL, NULL), 0) && TEST_int_eq(EVP_PKEY_encapsulate(dctx, NULL, &ctlen, NULL, &secretlen), 1) - && TEST_int_eq(ctlen, secretlen) - && TEST_int_eq(ctlen, bits / 8) + && TEST_size_t_eq(ctlen, secretlen) + && TEST_size_t_eq(ctlen, bits / 8) && TEST_int_eq(EVP_PKEY_encapsulate(dctx, ct, &ctlen, secret, &secretlen), 1) && TEST_ptr(rctx = EVP_PKEY_CTX_new_from_pkey(libctx, priv, NULL)) @@ -721,7 +721,7 @@ static int kem_rsa_params(void) && TEST_int_eq(EVP_PKEY_CTX_set_kem_op(privctx, "RSASVE"), 1) && TEST_int_eq(EVP_PKEY_decapsulate(privctx, secret, NULL, ct, sizeof(ct)), 1) && TEST_int_eq(EVP_PKEY_decapsulate(privctx, NULL, &secretlen, ct, sizeof(ct)), 1) - && TEST_int_eq(secretlen, 256) + && TEST_size_t_eq(secretlen, 256) /* Fail if passed NULL arguments */ && TEST_int_eq(EVP_PKEY_decapsulate(privctx, NULL, NULL, ct, sizeof(ct)), 0) && TEST_int_eq(EVP_PKEY_decapsulate(privctx, secret, &secretlen, NULL, 0), 0) diff --git a/test/evp_pkey_dhkem_test.c b/test/evp_pkey_dhkem_test.c index 1a8f93a6208..fb11a0215dd 100644 --- a/test/evp_pkey_dhkem_test.c +++ b/test/evp_pkey_dhkem_test.c @@ -471,7 +471,8 @@ static int test_ec_dhkem_derivekey(int tstid) const TEST_DERIVEKEY_DATA *t = &ec_derivekey_data[tstid]; unsigned char pubkey[133]; unsigned char privkey[66]; - size_t pubkeylen = 0, privkeylen = 0; + size_t pubkeylen = 0; + int privkeylen = 0; BIGNUM *priv = NULL; params[0] = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME, diff --git a/test/evp_test.c b/test/evp_test.c index df30982c23a..a355fd5cc53 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -840,8 +840,8 @@ static int digest_test_run(EVP_TEST *t) if (!test_duplicate_md_ctx(t, EVP_MD_CTX_dup(mctx))) goto err; - got_len = expected->output_len; - if (!EVP_DigestFinalXOF(mctx, got, got_len)) { + got_len = (unsigned int)expected->output_len; + if (!EVP_DigestFinalXOF(mctx, got, expected->output_len)) { t->err = "DIGESTFINALXOF_ERROR"; goto err; } @@ -851,7 +851,7 @@ static int digest_test_run(EVP_TEST *t) goto err; } } - if (!TEST_int_eq(expected->output_len, got_len)) { + if (!TEST_size_t_eq(expected->output_len, got_len)) { t->err = "DIGEST_LENGTH_MISMATCH"; goto err; } @@ -1181,7 +1181,7 @@ static int cipher_test_enc(EVP_TEST *t, int enc, size_t out_misalign, if (expected->iv) { if (expected->aead) { if (EVP_CIPHER_CTX_ctrl(ctx_base, EVP_CTRL_AEAD_SET_IVLEN, - expected->iv_len, 0) <= 0) { + (int)expected->iv_len, 0) <= 0) { t->err = "INVALID_IV_LENGTH"; goto err; } @@ -1205,7 +1205,7 @@ static int cipher_test_enc(EVP_TEST *t, int enc, size_t out_misalign, } if (tag || expected->aead != EVP_CIPH_GCM_MODE) { if (EVP_CIPHER_CTX_ctrl(ctx_base, EVP_CTRL_AEAD_SET_TAG, - expected->tag_len, tag) <= 0) + (int)expected->tag_len, tag) <= 0) goto err; } } @@ -1219,7 +1219,7 @@ static int cipher_test_enc(EVP_TEST *t, int enc, size_t out_misalign, } } - if (!EVP_CIPHER_CTX_set_key_length(ctx_base, expected->key_len)) { + if (!EVP_CIPHER_CTX_set_key_length(ctx_base, (int)expected->key_len)) { t->err = "INVALID_KEY_LENGTH"; goto err; } @@ -1309,7 +1309,7 @@ static int cipher_test_enc(EVP_TEST *t, int enc, size_t out_misalign, } if (expected->aead == EVP_CIPH_CCM_MODE) { - if (!EVP_CipherUpdate(ctx, NULL, &tmplen, NULL, out_len)) { + if (!EVP_CipherUpdate(ctx, NULL, &tmplen, NULL, (int)out_len)) { t->err = "CCM_PLAINTEXT_LENGTH_SET_ERROR"; goto err; } @@ -1323,13 +1323,13 @@ static int cipher_test_enc(EVP_TEST *t, int enc, size_t out_misalign, donelen = 0; do { - size_t current_aad_len = (size_t) data_chunk_size; + size_t current_aad_len = (size_t)data_chunk_size; - if (data_chunk_size == 0 || (size_t) data_chunk_size > aad_len) + if (data_chunk_size == 0 || current_aad_len > aad_len) current_aad_len = aad_len; if (!EVP_CipherUpdate(ctx, NULL, &chunklen, expected->aad[i] + donelen, - current_aad_len)) + (int)current_aad_len)) goto err; donelen += current_aad_len; aad_len -= current_aad_len; @@ -1346,7 +1346,7 @@ static int cipher_test_enc(EVP_TEST *t, int enc, size_t out_misalign, if (expected->aad_len[i] > 2) { if (!EVP_CipherUpdate(ctx, NULL, &chunklen, expected->aad[i] + donelen, - expected->aad_len[i] - 2)) + (int)(expected->aad_len[i] - 2))) goto err; donelen += expected->aad_len[i] - 2; } @@ -1379,13 +1379,13 @@ static int cipher_test_enc(EVP_TEST *t, int enc, size_t out_misalign, } else if (!enc && (expected->aead == EVP_CIPH_OCB_MODE || expected->tag_late)) { if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, - expected->tag_len, expected->tag) <= 0) { + (int)expected->tag_len, expected->tag) <= 0) { t->err = "TAG_SET_ERROR"; goto err; } } else if (!enc && expected->mac_key && expected->tag) { if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, - expected->tag_len, expected->tag) <= 0) { + (int)expected->tag_len, expected->tag) <= 0) { t->err = "TAG_SET_ERROR"; goto err; } @@ -1408,12 +1408,12 @@ static int cipher_test_enc(EVP_TEST *t, int enc, size_t out_misalign, if (!frag) { do { /* Supply the data all in one go or according to data_chunk_size */ - size_t current_in_len = (size_t) data_chunk_size; + size_t current_in_len = (size_t)data_chunk_size; - if (data_chunk_size == 0 || (size_t) data_chunk_size > in_len) + if (data_chunk_size == 0 || current_in_len > in_len) current_in_len = in_len; if (!EVP_CipherUpdate(ctx, tmp + out_misalign + tmplen, &chunklen, - in, current_in_len)) + in, (int)current_in_len)) goto err; tmplen += chunklen; in += current_in_len; @@ -1430,7 +1430,7 @@ static int cipher_test_enc(EVP_TEST *t, int enc, size_t out_misalign, } if (in_len > 1) { if (!EVP_CipherUpdate(ctx, tmp + out_misalign + tmplen, &chunklen, - in, in_len - 1)) + in, (int)(in_len - 1))) goto err; tmplen += chunklen; in += in_len - 1; @@ -1456,7 +1456,7 @@ static int cipher_test_enc(EVP_TEST *t, int enc, size_t out_misalign, if (expected->tls_version >= TLS1_1_VERSION && (EVP_CIPHER_is_a(expected->cipher, "AES-128-CBC-HMAC-SHA1") || EVP_CIPHER_is_a(expected->cipher, "AES-256-CBC-HMAC-SHA1"))) { - tmplen -= expected->iv_len; + tmplen -= (int)expected->iv_len; expected_out += expected->iv_len; out_misalign += expected->iv_len; } @@ -1474,7 +1474,7 @@ static int cipher_test_enc(EVP_TEST *t, int enc, size_t out_misalign, goto err; } if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, - expected->tag_len, rtag) <= 0) { + (int)expected->tag_len, rtag) <= 0) { t->err = "TAG_RETRIEVE_ERROR"; goto err; } @@ -3362,10 +3362,10 @@ static int pbe_test_run(EVP_TEST *t) goto err; } if (expected->pbe_type == PBE_TYPE_PBKDF2) { - if (PKCS5_PBKDF2_HMAC((char *)expected->pass, expected->pass_len, - expected->salt, expected->salt_len, + if (PKCS5_PBKDF2_HMAC((char *)expected->pass, (int)expected->pass_len, + expected->salt, (int)expected->salt_len, expected->iter, expected->md, - expected->key_len, key) == 0) { + (int)expected->key_len, key) == 0) { t->err = "PBKDF2_ERROR"; goto err; } @@ -3386,9 +3386,9 @@ static int pbe_test_run(EVP_TEST *t) t->err = "PKCS12_ERROR"; goto err; } - if (PKCS12_key_gen_uni(expected->pass, expected->pass_len, - expected->salt, expected->salt_len, - expected->id, expected->iter, expected->key_len, + if (PKCS12_key_gen_uni(expected->pass, (int)expected->pass_len, + expected->salt, (int)expected->salt_len, + expected->id, expected->iter, (int)expected->key_len, key, fetched_digest) == 0) { t->err = "PKCS12_ERROR"; goto err; @@ -3509,13 +3509,13 @@ static int encode_test_run(EVP_TEST *t) donelen = 0; output_len = 0; do { - size_t current_len = (size_t) data_chunk_size; + size_t current_len = (size_t)data_chunk_size; - if (data_chunk_size == 0 || (size_t) data_chunk_size > input_len) + if (data_chunk_size == 0 || current_len > input_len) current_len = input_len; if (!TEST_true(EVP_EncodeUpdate(encode_ctx, encode_out, &chunk_len, expected->input + donelen, - current_len))) + (int)current_len))) goto err; donelen += current_len; input_len -= current_len; @@ -3551,7 +3551,7 @@ static int encode_test_run(EVP_TEST *t) if (data_chunk_size == 0 || (size_t) data_chunk_size > input_len) current_len = input_len; if (EVP_DecodeUpdate(decode_ctx, decode_out + output_len, &chunk_len, - expected->output + donelen, current_len) < 0) { + expected->output + donelen, (int)current_len) < 0) { t->err = "DECODE_ERROR"; goto err; } @@ -5560,7 +5560,7 @@ int setup_tests(void) if (n == 0) return 0; - ADD_ALL_TESTS(run_file_tests, n); + ADD_ALL_TESTS(run_file_tests, (int)n); return 1; } diff --git a/test/evp_xof_test.c b/test/evp_xof_test.c index 42d358b638b..2e05116fad8 100644 --- a/test/evp_xof_test.c +++ b/test/evp_xof_test.c @@ -261,7 +261,7 @@ static int shake_kat_digestfinal_xoflen_test(void) if (!TEST_int_eq(EVP_MD_CTX_size(ctx), -1) || !TEST_int_eq(EVP_MD_CTX_set_params(ctx, params), 1) - || !TEST_int_eq(EVP_MD_CTX_size(ctx), sz) + || !TEST_int_eq(EVP_MD_CTX_size(ctx), (int)sz) || !TEST_int_eq(EVP_MD_get_size(md), 0) || !TEST_true(EVP_MD_xof(md)) || !TEST_true(EVP_DigestUpdate(ctx, shake256_input, diff --git a/test/fake_rsaprov.c b/test/fake_rsaprov.c index 46fc9104ef9..dab604419fc 100644 --- a/test/fake_rsaprov.c +++ b/test/fake_rsaprov.c @@ -355,7 +355,7 @@ static int fake_rsa_sig_sign(void *ctx, unsigned char *sig, *siglen = 256; /* record that the real sign operation was called */ if (sig != NULL) { - if (!TEST_int_ge(sigsize, *siglen)) + if (!TEST_size_t_ge(sigsize, *siglen)) return 0; *sigctx = 2; /* produce a fake signature */ @@ -468,7 +468,7 @@ static int fake_rsa_dgstsgnvfy_final(void *ctx, unsigned char *sig, *siglen = 256; /* record that the real sign operation was called */ if (sig != NULL) { - if (!TEST_int_ge(sigsize, *siglen)) + if (!TEST_size_t_ge(sigsize, *siglen)) return 0; /* produce a fake signature */ memset(sig, 'a', *siglen); diff --git a/test/fatalerrtest.c b/test/fatalerrtest.c index 30930d9ce8a..4304039b0a1 100644 --- a/test/fatalerrtest.c +++ b/test/fatalerrtest.c @@ -69,7 +69,7 @@ static int test_fatalerr(void) TEST_error("Unexpected success reading data: %s\n", buf); goto err; } - if (!TEST_int_le(SSL_write(sssl, msg, strlen(msg)), 0)) + if (!TEST_int_le(SSL_write(sssl, msg, (int)strlen(msg)), 0)) goto err; ret = 1; diff --git a/test/fips_version_test.c b/test/fips_version_test.c index dd23bb51e50..712262cc6f1 100644 --- a/test/fips_version_test.c +++ b/test/fips_version_test.c @@ -45,7 +45,7 @@ int setup_tests(void) { char *config_file = NULL; OPTION_CHOICE o; - int n; + size_t n; while ((o = opt_next()) != OPT_EOF) { switch (o) { @@ -67,7 +67,7 @@ int setup_tests(void) if (n == 0) return 0; - ADD_ALL_TESTS(test_fips_version, n); + ADD_ALL_TESTS(test_fips_version, (int)n); return 1; } diff --git a/test/helpers/handshake.c b/test/helpers/handshake.c index 64eb6ae4410..c312042c698 100644 --- a/test/helpers/handshake.c +++ b/test/helpers/handshake.c @@ -372,14 +372,14 @@ static int parse_protos(const char *protos, unsigned char **out, size_t *outlen) i = prefix + 1; while (i <= len) { if ((*out)[i] == ',') { - if (!TEST_int_gt(i - 1, prefix)) + if (!TEST_size_t_gt(i - 1, prefix)) goto err; (*out)[prefix] = (unsigned char)(i - 1 - prefix); prefix = i; } i++; } - if (!TEST_int_gt(len, prefix)) + if (!TEST_size_t_gt(len, prefix)) goto err; (*out)[prefix] = (unsigned char)(len - prefix); return 1; @@ -406,7 +406,7 @@ static int client_npn_cb(SSL *s, unsigned char **out, unsigned char *outlen, ret = SSL_select_next_proto(out, outlen, in, inlen, ctx_data->npn_protocols, - ctx_data->npn_protocols_len); + (unsigned int)ctx_data->npn_protocols_len); /* Accept both OPENSSL_NPN_NEGOTIATED and OPENSSL_NPN_NO_OVERLAP. */ return TEST_true(ret == OPENSSL_NPN_NEGOTIATED || ret == OPENSSL_NPN_NO_OVERLAP) ? SSL_TLSEXT_ERR_OK : SSL_TLSEXT_ERR_ALERT_FATAL; @@ -417,7 +417,7 @@ static int server_npn_cb(SSL *s, const unsigned char **data, { CTX_DATA *ctx_data = (CTX_DATA*)(arg); *data = ctx_data->npn_protocols; - *len = ctx_data->npn_protocols_len; + *len = (unsigned int)ctx_data->npn_protocols_len; return SSL_TLSEXT_ERR_OK; } #endif @@ -445,7 +445,7 @@ static int server_alpn_cb(SSL *s, const unsigned char **out, */ ret = SSL_select_next_proto(&tmp_out, outlen, ctx_data->alpn_protocols, - ctx_data->alpn_protocols_len, in, inlen); + (unsigned int)ctx_data->alpn_protocols_len, in, inlen); *out = tmp_out; /* Unlike NPN, we don't tolerate a mismatch. */ @@ -498,7 +498,7 @@ static int configure_handshake_ctx(SSL_CTX *server_ctx, SSL_CTX *server2_ctx, CTX_DATA *client_ctx_data) { unsigned char *ticket_keys; - size_t ticket_key_len; + long ticket_key_len; if (!TEST_int_eq(SSL_CTX_set_max_send_fragment(server_ctx, test->max_fragment_size), 1)) @@ -640,7 +640,7 @@ static int configure_handshake_ctx(SSL_CTX *server_ctx, SSL_CTX *server2_ctx, &alpn_protos, &alpn_protos_len)) /* Reversed return value convention... */ || !TEST_int_eq(SSL_CTX_set_alpn_protos(client_ctx, alpn_protos, - alpn_protos_len), 0)) + (unsigned int)alpn_protos_len), 0)) goto err; OPENSSL_free(alpn_protos); } @@ -670,9 +670,9 @@ static int configure_handshake_ctx(SSL_CTX *server_ctx, SSL_CTX *server2_ctx, */ ticket_key_len = SSL_CTX_set_tlsext_ticket_keys(server_ctx, NULL, 0); if (!TEST_ptr(ticket_keys = OPENSSL_zalloc(ticket_key_len)) - || !TEST_int_eq(SSL_CTX_set_tlsext_ticket_keys(server_ctx, - ticket_keys, - ticket_key_len), 1)) { + || !TEST_long_eq(SSL_CTX_set_tlsext_ticket_keys(server_ctx, + ticket_keys, + ticket_key_len), 1)) { OPENSSL_free(ticket_keys); goto err; } diff --git a/test/helpers/pkcs12.c b/test/helpers/pkcs12.c index e31018d9fa0..7b29a91dd61 100644 --- a/test/helpers/pkcs12.c +++ b/test/helpers/pkcs12.c @@ -172,7 +172,7 @@ static void generate_p12(PKCS12_BUILDER *pb, const PKCS12_ENC *mac) else md = EVP_MD_fetch(test_ctx, OBJ_nid2sn(mac->nid), test_propq); - if (!TEST_true(PKCS12_set_mac(p12, mac->pass, strlen(mac->pass), + if (!TEST_true(PKCS12_set_mac(p12, mac->pass, (int)strlen(mac->pass), NULL, 0, mac->iter, md))) { pb->success = 0; goto err; @@ -262,7 +262,7 @@ err: static int check_p12_mac(PKCS12 *p12, const PKCS12_ENC *mac) { return TEST_true(PKCS12_mac_present(p12)) - && TEST_true(PKCS12_verify_mac(p12, mac->pass, strlen(mac->pass))); + && TEST_true(PKCS12_verify_mac(p12, mac->pass, (int)strlen(mac->pass))); } @@ -319,7 +319,7 @@ static STACK_OF(PKCS12_SAFEBAG) *decode_contentinfo(STACK_OF(PKCS7) *safes, int if (enc) { if (!TEST_int_eq(bagnid, NID_pkcs7_encrypted)) goto err; - bags = PKCS12_unpack_p7encdata(p7, enc->pass, strlen(enc->pass)); + bags = PKCS12_unpack_p7encdata(p7, enc->pass, (int)strlen(enc->pass)); } else { if (!TEST_int_eq(bagnid, NID_pkcs7_data)) goto err; @@ -358,7 +358,7 @@ static int add_attributes(PKCS12_SAFEBAG *bag, const PKCS12_ATTR *attr) goto err; } else if (attr_nid == NID_localKeyID) { if (!TEST_true(PKCS12_add_localkeyid(bag, (unsigned char *)p_attr->value, - strlen(p_attr->value)))) + (int)strlen(p_attr->value)))) goto err; } else if (attr_nid == NID_oracle_jdk_trustedkeyusage) { attrs = (STACK_OF(X509_ATTRIBUTE)*)PKCS12_SAFEBAG_get0_attrs(bag); @@ -370,7 +370,7 @@ static int add_attributes(PKCS12_SAFEBAG *bag, const PKCS12_ATTR *attr) /* Custom attribute values limited to ASCII in these tests */ if (!TEST_true(PKCS12_add1_attr_by_txt(bag, p_attr->oid, MBSTRING_ASC, (unsigned char *)p_attr->value, - strlen(p_attr->value)))) + (int)strlen(p_attr->value)))) goto err; } p_attr++; @@ -456,7 +456,8 @@ void add_secretbag(PKCS12_BUILDER *pb, int secret_nid, const char *secret, TEST_info("Adding secret <%s>", secret); - bag = PKCS12_add_secret(&pb->bags, secret_nid, (const unsigned char *)secret, strlen(secret)); + bag = PKCS12_add_secret(&pb->bags, secret_nid, + (const unsigned char *)secret, (int)strlen(secret)); if (!TEST_ptr(bag)) { pb->success = 0; return; @@ -614,9 +615,10 @@ void check_keybag(PKCS12_BUILDER *pb, const unsigned char *bytes, int len, case NID_pkcs8ShroudedKeyBag: if (legacy) - p8 = PKCS12_decrypt_skey(bag, enc->pass, strlen(enc->pass)); + p8 = PKCS12_decrypt_skey(bag, enc->pass, (int)strlen(enc->pass)); else - p8 = PKCS12_decrypt_skey_ex(bag, enc->pass, strlen(enc->pass), test_ctx, test_propq); + p8 = PKCS12_decrypt_skey_ex(bag, enc->pass, (int)strlen(enc->pass), + test_ctx, test_propq); if (!TEST_ptr(p8)) { pb->success = 0; goto err; diff --git a/test/helpers/predefined_dhparams.c b/test/helpers/predefined_dhparams.c index 4bdadc41432..bde12b09ca6 100644 --- a/test/helpers/predefined_dhparams.c +++ b/test/helpers/predefined_dhparams.c @@ -53,11 +53,11 @@ static EVP_PKEY *get_dh_from_pg(OSSL_LIB_CTX *libctx, const char *type, EVP_PKEY *dhpkey = NULL; BIGNUM *p = NULL, *g = NULL, *q = NULL; - p = BN_bin2bn(pdata, plen, NULL); - g = BN_bin2bn(gdata, glen, NULL); + p = BN_bin2bn(pdata, (int)plen, NULL); + g = BN_bin2bn(gdata, (int)glen, NULL); if (p == NULL || g == NULL) goto err; - if (qdata != NULL && (q = BN_bin2bn(qdata, qlen, NULL)) == NULL) + if (qdata != NULL && (q = BN_bin2bn(qdata, (int)qlen, NULL)) == NULL) goto err; dhpkey = get_dh_from_pg_bn(libctx, type, p, g, q); diff --git a/test/helpers/quictestlib.c b/test/helpers/quictestlib.c index 420d3b5acd5..549eb5f0599 100644 --- a/test/helpers/quictestlib.c +++ b/test/helpers/quictestlib.c @@ -811,7 +811,7 @@ static int packet_plain_mutate(const QUIC_PKT_HDR *hdrin, * 14 long header (we assume token length is 0, * which is fine for server not so fine for client) */ - grow_allowance = 1200 - bufsz - 16 - 14; + grow_allowance = 1200 - (int)bufsz - 16 - 14; grow_allowance -= hdrin->dst_conn_id.id_len; grow_allowance -= hdrin->src_conn_id.id_len; assert(grow_allowance >= 0); @@ -1168,7 +1168,7 @@ static int pcipher_sendmmsg(BIO *b, BIO_MSG *msg, size_t stride, size_t *num_processed) { BIO *next = BIO_next(b); - ossl_ssize_t ret = 0; + int ret = 0; size_t i = 0, tmpnump; QUIC_PKT_HDR hdr; PACKET pkt; diff --git a/test/helpers/ssltestlib.c b/test/helpers/ssltestlib.c index 56d526f7525..c5120c2dafc 100644 --- a/test/helpers/ssltestlib.c +++ b/test/helpers/ssltestlib.c @@ -250,7 +250,7 @@ static int tls_dump_gets(BIO *bio, char *buf, int size) static int tls_dump_puts(BIO *bio, const char *str) { - return tls_dump_write(bio, str, strlen(str)); + return tls_dump_write(bio, str, (int)strlen(str)); } @@ -620,7 +620,7 @@ int mempacket_test_inject(BIO *bio, const char *in, int inl, int pktnum, */ if (duprec && i != 2) { memcpy(thispkt->data, in + len, inl - len); - thispkt->len = inl - len; + thispkt->len = inl - (int)len; } else { memcpy(thispkt->data, in, inl); thispkt->len = inl; @@ -748,7 +748,7 @@ static int mempacket_test_gets(BIO *bio, char *buf, int size) static int mempacket_test_puts(BIO *bio, const char *str) { - return mempacket_test_write(bio, str, strlen(str)); + return mempacket_test_write(bio, str, (int)strlen(str)); } static int always_retry_new(BIO *bi); @@ -1415,7 +1415,7 @@ int create_ssl_connection_ex(SSL *serverssl, SSL *clientssl, int want, */ for (i = 0; i < 2; i++) { if (SSL_read_ex(clientssl, &buf, sizeof(buf), &readbytes) > 0) { - if (!TEST_ulong_eq(readbytes, 0)) + if (!TEST_size_t_eq(readbytes, 0)) return 0; } else if (!TEST_int_eq(SSL_get_error(clientssl, 0), SSL_ERROR_WANT_READ)) { diff --git a/test/http_test.c b/test/http_test.c index 050db5b223a..66463002ac3 100644 --- a/test/http_test.c +++ b/test/http_test.c @@ -71,7 +71,7 @@ static int mock_http_server(BIO *in, BIO *out, char version, int keep_alive, hdr = strchr(hdr, ' '); if (hdr == NULL) return 0; - len = strlen("HTTP/1."); + len = (int)strlen("HTTP/1."); if (!TEST_strn_eq(++hdr, "HTTP/1.", len)) return 0; hdr += len; @@ -81,7 +81,7 @@ static int mock_http_server(BIO *in, BIO *out, char version, int keep_alive, if (!TEST_char_eq(*hdr++, '\r') || !TEST_char_eq(*hdr++, '\n')) return 0; - count -= (hdr - req); + count -= (long)(hdr - req); if (count < 0 || out == NULL) return 0; @@ -107,7 +107,7 @@ static int mock_http_server(BIO *in, BIO *out, char version, int keep_alive, if (is_get) { /* construct new header and body */ if (txt != NULL) - len = strlen(txt); + len = (int)strlen(txt); else if ((len = ASN1_item_i2d(rsp, NULL, it)) <= 0) return 0; if (BIO_printf(out, "Content-Type: %s\r\n" diff --git a/test/ideatest.c b/test/ideatest.c index f6d73d9d783..fd9985d70f0 100644 --- a/test/ideatest.c +++ b/test/ideatest.c @@ -77,7 +77,7 @@ static int test_idea_cbc(void) { IDEA_KEY_SCHEDULE key, dkey; unsigned char iv[IDEA_BLOCK]; - const size_t text_len = sizeof(text); + const long text_len = sizeof(text); IDEA_set_encrypt_key(k, &key); IDEA_set_decrypt_key(&key, &dkey); diff --git a/test/igetest.c b/test/igetest.c index 7a8ff688027..ffcd4166acb 100644 --- a/test/igetest.c +++ b/test/igetest.c @@ -154,7 +154,7 @@ static int test_ige_vectors(int n) unsigned char iv[AES_BLOCK_SIZE * 2]; int testresult = 1; - if (!TEST_int_le(v->length, MAX_VECTOR_SIZE)) + if (!TEST_size_t_le(v->length, MAX_VECTOR_SIZE)) return 0; if (v->encrypt == AES_ENCRYPT) @@ -195,15 +195,15 @@ static int test_bi_ige_vectors(int n) AES_KEY key2; unsigned char buf[MAX_VECTOR_SIZE]; - if (!TEST_int_le(v->length, MAX_VECTOR_SIZE)) + if (!TEST_size_t_le(v->length, MAX_VECTOR_SIZE)) return 0; if (v->encrypt == AES_ENCRYPT) { - AES_set_encrypt_key(v->key1, 8 * v->keysize, &key1); - AES_set_encrypt_key(v->key2, 8 * v->keysize, &key2); + AES_set_encrypt_key(v->key1, (int)(8 * v->keysize), &key1); + AES_set_encrypt_key(v->key2, (int)(8 * v->keysize), &key2); } else { - AES_set_decrypt_key(v->key1, 8 * v->keysize, &key1); - AES_set_decrypt_key(v->key2, 8 * v->keysize, &key2); + AES_set_decrypt_key(v->key1, (int)(8 * v->keysize), &key1); + AES_set_decrypt_key(v->key2, (int)(8 * v->keysize), &key2); } AES_bi_ige_encrypt(v->in, buf, v->length, &key1, &key2, v->iv, diff --git a/test/keymgmt_internal_test.c b/test/keymgmt_internal_test.c index 8d5aa22dab3..77f9dffe523 100644 --- a/test/keymgmt_internal_test.c +++ b/test/keymgmt_internal_test.c @@ -246,7 +246,7 @@ static int test_pass_rsa(FIXTURE *fixture) */ for (i = 0; i < OSSL_NELEM(expected); i++) { - int rv = TEST_int_eq(expected[i], keydata[i]); + int rv = TEST_uint64_t_eq((uint64_t)expected[i], (uint64_t)keydata[i]); if (!rv) TEST_info("i = %zu", i); diff --git a/test/lhash_test.c b/test/lhash_test.c index 94e9f3944ea..88282113325 100644 --- a/test/lhash_test.c +++ b/test/lhash_test.c @@ -109,7 +109,7 @@ static int test_int_lhash(void) } /* num_items */ - if (!TEST_int_eq((size_t)lh_int_num_items(h), n_int_tests)) + if (!TEST_size_t_eq((size_t)lh_int_num_items(h), n_int_tests)) goto end; /* retrieve */ @@ -257,7 +257,7 @@ static int test_int_hashtable(void) } /* num_items */ - if (!TEST_int_eq((size_t)ossl_ht_count(ht), n_int_tests)) + if (!TEST_size_t_eq(ossl_ht_count(ht), n_int_tests)) goto end; /* foreach, no arg */ @@ -277,7 +277,7 @@ static int test_int_hashtable(void) /* filter */ list = ossl_ht_filter(ht, 64, int_filter_all, NULL); - if (!TEST_int_eq((size_t)list->list_len, n_int_tests)) + if (!TEST_size_t_eq(list->list_len, n_int_tests)) goto end; ossl_ht_value_list_free(list); @@ -448,7 +448,7 @@ static int test_hashtable_stress(int idx) } /* make sure we stored everything */ - if (!TEST_int_eq((size_t)ossl_ht_count(h), n)) + if (!TEST_size_t_eq(ossl_ht_count(h), n)) goto end; /* delete or get in a different order */ diff --git a/test/list_test.c b/test/list_test.c index db288d1d08c..15a73ba306b 100644 --- a/test/list_test.c +++ b/test/list_test.c @@ -97,11 +97,11 @@ static int test_insert(void) INTL *c, *d; OSSL_LIST(int) l; INTL elem[20]; - size_t i; + int i; int n = 1; ossl_list_int_init(&l); - for (i = 0; i < OSSL_NELEM(elem); i++) { + for (i = 0; i < (int)OSSL_NELEM(elem); i++) { ossl_list_int_init_elem(elem + i); elem[i].n = i; } diff --git a/test/ml_dsa_test.c b/test/ml_dsa_test.c index a339ef7fa05..ef30c786252 100644 --- a/test/ml_dsa_test.c +++ b/test/ml_dsa_test.c @@ -152,7 +152,7 @@ static int ml_dsa_siggen_test(int tst_id) td->msg, td->msg_len), 1) || !TEST_true(EVP_PKEY_get_size_t_param(pkey, OSSL_PKEY_PARAM_MAX_SIZE, &sig_len2)) - || !TEST_int_eq(sig_len2, psig_len) + || !TEST_size_t_eq(sig_len2, psig_len) || !TEST_ptr(psig = OPENSSL_zalloc(psig_len)) || !TEST_int_eq(EVP_PKEY_sign(sctx, psig, &psig_len, td->msg, td->msg_len), 1) @@ -239,7 +239,7 @@ static int ml_dsa_siggen_upd_test(int tst_id) || !TEST_int_eq(EVP_PKEY_sign_message_final(sctx, NULL, &psig_len), 1) || !TEST_true(EVP_PKEY_get_size_t_param(pkey, OSSL_PKEY_PARAM_MAX_SIZE, &sig_len2)) - || !TEST_int_eq(sig_len2, psig_len) + || !TEST_size_t_eq(sig_len2, psig_len) || !TEST_ptr(psig = OPENSSL_zalloc(psig_len)) || !TEST_int_eq(EVP_PKEY_sign_message_final(sctx, psig, &psig_len), 1) || !TEST_int_eq(EVP_Q_digest(lib_ctx, "SHA256", NULL, psig, psig_len, @@ -419,11 +419,11 @@ static int ml_dsa_keygen_drbg_test(void) || !TEST_int_eq(EVP_PKEY_eq(pkey, pkey2), 0) || !TEST_int_eq(EVP_PKEY_eq(pkey, pkey3), -1) || !TEST_int_eq(EVP_PKEY_get_raw_private_key(pkey, NULL, &len), 1) - || !TEST_int_gt(len, 0) + || !TEST_size_t_gt(len, 0) || !TEST_ptr(priv = OPENSSL_malloc(len)) || !TEST_int_eq(EVP_PKEY_get_raw_private_key(pkey, priv, &len), 1) || !TEST_int_eq(EVP_PKEY_get_raw_public_key(pkey, NULL, &len), 1) - || !TEST_int_gt(len, 0) + || !TEST_size_t_gt(len, 0) || !TEST_ptr(pub = OPENSSL_malloc(len)) || !TEST_int_eq(EVP_PKEY_get_raw_public_key(pkey, pub, &len), 1) /* Load just the public part into a PKEY */ diff --git a/test/modes_internal_test.c b/test/modes_internal_test.c index aa667b16d16..8e80ed0a6c9 100644 --- a/test/modes_internal_test.c +++ b/test/modes_internal_test.c @@ -862,7 +862,7 @@ static int test_gcm128(int idx) if (C.size == 1) C.data = NULL; - AES_set_encrypt_key(K.data, K.size * 8, &key); + AES_set_encrypt_key(K.data, (int)(K.size * 8), &key); CRYPTO_gcm128_init(&ctx, &key, (block128_f)AES_encrypt); CRYPTO_gcm128_setiv(&ctx, IV.data, IV.size); diff --git a/test/params_test.c b/test/params_test.c index cd3c836c7ec..a7979100fca 100644 --- a/test/params_test.c +++ b/test/params_test.c @@ -139,7 +139,7 @@ static int raw_set_params(void *vobj, const OSSL_PARAM *params) } else if (strcmp(params->key, "p3") == 0) { BN_free(obj->p3); if (!TEST_ptr(obj->p3 = BN_native2bn(params->data, - params->data_size, NULL))) + (int)params->data_size, NULL))) return 0; } else if (strcmp(params->key, "p4") == 0) { OPENSSL_free(obj->p4); @@ -183,7 +183,7 @@ static int raw_get_params(void *vobj, OSSL_PARAM *params) params->return_size = BN_num_bytes(obj->p3); if (!TEST_size_t_ge(params->data_size, params->return_size)) return 0; - BN_bn2nativepad(obj->p3, params->data, params->return_size); + BN_bn2nativepad(obj->p3, params->data, (int)params->return_size); } else if (strcmp(params->key, "p4") == 0) { params->return_size = strlen(obj->p4); if (!TEST_size_t_gt(params->data_size, params->return_size)) @@ -460,7 +460,7 @@ static int test_case_variant(OSSL_PARAM *params, const struct provider_dispatch_ || !TEST_int_eq(app_p1, p1_init) /* "provider" value */ || !TEST_double_eq(app_p2, app_p2_init) /* Should remain untouched */ || !TEST_ptr(p = OSSL_PARAM_locate(params, "p3")) - || !TEST_ptr(BN_native2bn(bignumbin, p->return_size, app_p3)) + || !TEST_ptr(BN_native2bn(bignumbin, (int)p->return_size, app_p3)) || !TEST_BN_eq(app_p3, verify_p3) /* "provider" value */ || !TEST_str_eq(app_p4, p4_init) /* "provider" value */ || !TEST_ptr(p = OSSL_PARAM_locate(params, "p5")) @@ -511,7 +511,7 @@ static int test_case_variant(OSSL_PARAM *params, const struct provider_dispatch_ || !TEST_int_eq(app_p1, app_p1_init) /* app value */ || !TEST_double_eq(app_p2, app_p2_init) /* Should remain untouched */ || !TEST_ptr(p = OSSL_PARAM_locate(params, "p3")) - || !TEST_ptr(BN_native2bn(bignumbin, p->return_size, app_p3)) + || !TEST_ptr(BN_native2bn(bignumbin, (int)p->return_size, app_p3)) || !TEST_BN_eq(app_p3, verify_p3) /* app value */ || !TEST_str_eq(app_p4, app_p4_init) /* app value */ || !TEST_ptr(p = OSSL_PARAM_locate(params, "p5")) diff --git a/test/pbetest.c b/test/pbetest.c index cfffc2b9323..0cfe4327a7e 100644 --- a/test/pbetest.c +++ b/test/pbetest.c @@ -75,7 +75,7 @@ static int test_pkcs5_pbe(const EVP_CIPHER *cipher, const EVP_MD *md, if (!TEST_true(PKCS5_pbe_set0_algor(algor, EVP_CIPHER_nid(cipher), pbe_iter, pbe_salt, sizeof(pbe_salt))) - || !TEST_true(PKCS5_PBE_keyivgen(ctx, pbe_password, strlen(pbe_password), + || !TEST_true(PKCS5_PBE_keyivgen(ctx, pbe_password, (int)strlen(pbe_password), algor->parameter, cipher, md, 1)) || !TEST_true(EVP_CipherUpdate(ctx, out, &i, pbe_plaintext, sizeof(pbe_plaintext)))) @@ -91,7 +91,7 @@ static int test_pkcs5_pbe(const EVP_CIPHER *cipher, const EVP_MD *md, /* Decrypt */ - if (!TEST_true(PKCS5_PBE_keyivgen(ctx, pbe_password, strlen(pbe_password), + if (!TEST_true(PKCS5_PBE_keyivgen(ctx, pbe_password, (int)strlen(pbe_password), algor->parameter, cipher, md, 0)) || !TEST_true(EVP_CipherUpdate(ctx, out, &i, exp, exp_len))) goto err; diff --git a/test/pemtest.c b/test/pemtest.c index bf970983654..801eccc11b6 100644 --- a/test/pemtest.c +++ b/test/pemtest.c @@ -48,7 +48,7 @@ static int test_b64(int idx) PEM_FLAG_ONLY_B64))) goto err; if (!TEST_int_eq(memcmp(pemtype, name, strlen(pemtype)), 0) - || !TEST_int_eq(len, strlen(raw)) + || !TEST_long_eq(len, (long)strlen(raw)) || !TEST_int_eq(memcmp(data, raw, strlen(raw)), 0)) goto err; ret = 1; @@ -108,7 +108,7 @@ static int test_empty_payload(void) long len; int ret = 0; - b = BIO_new_mem_buf(emptypay, strlen(emptypay)); + b = BIO_new_mem_buf(emptypay, (int)strlen(emptypay)); if (!TEST_ptr(b)) return 0; @@ -138,7 +138,7 @@ static int test_protected_params(void) EVP_PKEY *pkey = NULL; int ret = 0; - b = BIO_new_mem_buf(protectedpay, strlen(protectedpay)); + b = BIO_new_mem_buf(protectedpay, (int)strlen(protectedpay)); if (!TEST_ptr(b)) return 0; diff --git a/test/pkcs7_test.c b/test/pkcs7_test.c index 7c038044440..74405c9868e 100644 --- a/test/pkcs7_test.c +++ b/test/pkcs7_test.c @@ -151,7 +151,7 @@ static int pkcs7_verify_test(void) for (i = 0; i < OSSL_NELEM(sig); ++i) BIO_puts(bio, sig[i]); - ret = TEST_ptr(msg_bio = BIO_new_mem_buf(signed_data, strlen(signed_data))) + ret = TEST_ptr(msg_bio = BIO_new_mem_buf(signed_data, (int)strlen(signed_data))) && TEST_ptr(x509_bio = BIO_new_mem_buf(cert_der, sizeof(cert_der))) && TEST_ptr(cert = d2i_X509_bio(x509_bio, NULL)) && TEST_int_eq(ERR_peek_error(), 0) diff --git a/test/quic_ackm_test.c b/test/quic_ackm_test.c index 0f26e9d38a0..2ffcf593359 100644 --- a/test/quic_ackm_test.c +++ b/test/quic_ackm_test.c @@ -913,6 +913,7 @@ static int test_rx_ack_actual(int tidx, int space) OSSL_ACKM_TX_PKT *txs = NULL, *tx; OSSL_TIME ack_deadline[QUIC_PN_SPACE_NUM]; size_t opn = 0; + int j; for (i = 0; i < QUIC_PN_SPACE_NUM; ++i) ack_deadline[i] = ossl_time_infinite(); @@ -988,13 +989,13 @@ static int test_rx_ack_actual(int tidx, int space) s->expect_deadline)) goto err; - for (i = 0; i < QUIC_PN_SPACE_NUM; ++i) { - if (i != (size_t)space - && !TEST_true(ossl_time_is_infinite(ossl_ackm_get_ack_deadline(h.ackm, i)))) + for (j = 0; j < QUIC_PN_SPACE_NUM; ++j) { + if (j != space + && !TEST_true(ossl_time_is_infinite(ossl_ackm_get_ack_deadline(h.ackm, j)))) goto err; - if (!TEST_int_eq(ossl_time_compare(ossl_ackm_get_ack_deadline(h.ackm, i), - ack_deadline[i]), 0)) + if (!TEST_int_eq(ossl_time_compare(ossl_ackm_get_ack_deadline(h.ackm, j), + ack_deadline[j]), 0)) goto err; } diff --git a/test/quic_multistream_test.c b/test/quic_multistream_test.c index ccac6e169c2..0849b5773a0 100644 --- a/test/quic_multistream_test.c +++ b/test/quic_multistream_test.c @@ -1273,7 +1273,7 @@ static int run_script_worker(struct helper *h, const struct script_op *script, /* 0 is the success case for SSL_set_alpn_protos(). */ if (!TEST_false(SSL_set_alpn_protos(h->c_conn, tmp_buf, - alpn_len + 1))) + (unsigned int)(alpn_len + 1)))) goto out; OPENSSL_free(tmp_buf); @@ -1642,7 +1642,7 @@ static int run_script_worker(struct helper *h, const struct script_op *script, if (!TEST_ptr(c_tgt)) goto out; - if (!TEST_true(SSL_set_default_stream_mode(c_tgt, op->arg1))) + if (!TEST_true(SSL_set_default_stream_mode(c_tgt, (uint32_t)op->arg1))) goto out; } break; @@ -1653,7 +1653,7 @@ static int run_script_worker(struct helper *h, const struct script_op *script, goto out; if (!TEST_true(SSL_set_incoming_stream_policy(c_tgt, - op->arg1, 0))) + (int)op->arg1, 0))) goto out; } break; @@ -1896,7 +1896,7 @@ static int run_script_worker(struct helper *h, const struct script_op *script, h->threads[i].h = h; h->threads[i].script = op->arg0; h->threads[i].script_name = script_name; - h->threads[i].thread_idx = i; + h->threads[i].thread_idx = (int)i; h->threads[i].m = ossl_crypto_mutex_new(); if (!TEST_ptr(h->threads[i].m)) @@ -2000,7 +2000,7 @@ static int run_script_worker(struct helper *h, const struct script_op *script, QUIC_CHANNEL *ch = ossl_quic_conn_get_channel(h->c_conn); ossl_quic_engine_set_inhibit_tick(ossl_quic_channel_get0_engine(ch), - op->arg1); + (int)op->arg1); } break; @@ -5449,7 +5449,7 @@ static int check_idle_timeout(struct helper *h, struct helper_local *hl) { uint64_t v = 0; - if (!TEST_true(SSL_get_value_uint(h->c_conn, hl->check_op->arg1, + if (!TEST_true(SSL_get_value_uint(h->c_conn, (uint32_t)hl->check_op->arg1, SSL_VALUE_QUIC_IDLE_TIMEOUT, &v))) return 0; diff --git a/test/quic_newcid_test.c b/test/quic_newcid_test.c index 80a15e1b7ab..957e047cd92 100644 --- a/test/quic_newcid_test.c +++ b/test/quic_newcid_test.c @@ -74,7 +74,7 @@ static int test_ncid_frame(int fail) if (!TEST_true(qtest_create_quic_connection(qtserv, cssl))) goto err; - if (!TEST_int_eq(SSL_write(cssl, msg, msglen), msglen)) + if (!TEST_int_eq(SSL_write(cssl, msg, (int)msglen), (int)msglen)) goto err; ossl_quic_tserver_tick(qtserv); @@ -115,13 +115,13 @@ static int test_ncid_frame(int fail) if (!TEST_true(SSL_handle_events(cssl))) goto err; - if (!TEST_int_eq(SSL_read(cssl, buf, sizeof(buf)), msglen)) + if (!TEST_int_eq(SSL_read(cssl, buf, sizeof(buf)), (int)msglen)) goto err; if (!TEST_mem_eq(msg, msglen, buf, bytesread)) goto err; - if (!TEST_int_eq(SSL_write(cssl, msg, msglen), msglen)) + if (!TEST_int_eq(SSL_write(cssl, msg, (int)msglen), (int)msglen)) goto err; ossl_quic_tserver_tick(qtserv); diff --git a/test/quic_txp_test.c b/test/quic_txp_test.c index 329953a3bd7..7b6248cc15e 100644 --- a/test/quic_txp_test.c +++ b/test/quic_txp_test.c @@ -1704,7 +1704,7 @@ int setup_tests(void) { ADD_ALL_TESTS(test_script, OSSL_NELEM(scripts)); ADD_ALL_TESTS(test_dyn_script_1, - OSSL_NELEM(dyn_script_1_crypto_1a) - - dyn_script_1_start_from + 1); + (int)(OSSL_NELEM(dyn_script_1_crypto_1a) + - dyn_script_1_start_from + 1)); return 1; } diff --git a/test/quic_wire_test.c b/test/quic_wire_test.c index 10630e8be39..df683c6c675 100644 --- a/test/quic_wire_test.c +++ b/test/quic_wire_test.c @@ -39,7 +39,7 @@ static int encode_case_1_dec(PACKET *pkt, ossl_ssize_t fail) /* No failure modes for padding */ return 1; - if (!TEST_int_eq(ossl_quic_wire_decode_padding(pkt), 3)) + if (!TEST_size_t_eq(ossl_quic_wire_decode_padding(pkt), 3)) return 0; return 1; diff --git a/test/quicapitest.c b/test/quicapitest.c index b98a9405530..2b256f02da7 100644 --- a/test/quicapitest.c +++ b/test/quicapitest.c @@ -147,7 +147,7 @@ static int test_quic_write_read(int idx) if (!TEST_true(SSL_read_ex(clientquic, buf, 1, &numbytes)) || !TEST_size_t_eq(numbytes, 1) || !TEST_true(SSL_has_pending(clientquic)) - || !TEST_int_eq(SSL_pending(clientquic), msglen - 1) + || !TEST_int_eq(SSL_pending(clientquic), (int)(msglen - 1)) || !TEST_true(SSL_read_ex(clientquic, buf + 1, sizeof(buf) - 1, &numbytes)) || !TEST_mem_eq(buf, numbytes + 1, msg, msglen)) @@ -298,7 +298,8 @@ static int test_ciphersuites(void) #endif TLS1_3_CK_AES_128_GCM_SHA256 }; - size_t i, j; + size_t i; + int j; if (!TEST_ptr(ctx)) return 0; @@ -701,11 +702,12 @@ static int test_new_token(void) static int ensure_valid_ciphers(const STACK_OF(SSL_CIPHER) *ciphers) { - size_t i; + int i; /* Ensure ciphersuite list is suitably subsetted. */ - for (i = 0; i < (size_t)sk_SSL_CIPHER_num(ciphers); ++i) { + for (i = 0; i < sk_SSL_CIPHER_num(ciphers); ++i) { const SSL_CIPHER *cipher = sk_SSL_CIPHER_value(ciphers, i); + switch (SSL_CIPHER_get_id(cipher)) { case TLS1_3_CK_AES_128_GCM_SHA256: case TLS1_3_CK_AES_256_GCM_SHA384: diff --git a/test/quicfaultstest.c b/test/quicfaultstest.c index c2187e1ea42..fbe36cdb634 100644 --- a/test/quicfaultstest.c +++ b/test/quicfaultstest.c @@ -41,7 +41,7 @@ static int test_basic(void) if (!TEST_true(qtest_create_quic_connection(qtserv, cssl))) goto err; - if (!TEST_int_eq(SSL_write(cssl, msg, msglen), msglen)) + if (!TEST_int_eq(SSL_write(cssl, msg, (int)msglen), (int)msglen)) goto err; ossl_quic_tserver_tick(qtserv); diff --git a/test/radix/quic_bindings.c b/test/radix/quic_bindings.c index 49b8e28ef69..b63e0d4fb14 100644 --- a/test/radix/quic_bindings.c +++ b/test/radix/quic_bindings.c @@ -330,14 +330,14 @@ static void RADIX_PROCESS_report_state(RADIX_PROCESS *rp, BIO *bio, static void RADIX_PROCESS_report_thread_results(RADIX_PROCESS *rp, BIO *bio) { - size_t i; + int i; RADIX_THREAD *rt; char *p; long l; char pfx_buf[64]; int rt_testresult; - for (i = 1; i < (size_t)sk_RADIX_THREAD_num(rp->threads); ++i) { + for (i = 1; i < sk_RADIX_THREAD_num(rp->threads); ++i) { rt = sk_RADIX_THREAD_value(rp->threads, i); ossl_crypto_mutex_lock(rt->m); @@ -372,7 +372,7 @@ static int RADIX_THREAD_join(RADIX_THREAD *rt); static int RADIX_PROCESS_join_all_threads(RADIX_PROCESS *rp, int *testresult) { int ok = 1; - size_t i; + int i; RADIX_THREAD *rt; int composite_testresult = 1; @@ -381,10 +381,10 @@ static int RADIX_PROCESS_join_all_threads(RADIX_PROCESS *rp, int *testresult) return 1; } - for (i = 1; i < (size_t)sk_RADIX_THREAD_num(rp->threads); ++i) { + for (i = 1; i < sk_RADIX_THREAD_num(rp->threads); ++i) { rt = sk_RADIX_THREAD_value(rp->threads, i); - BIO_printf(bio_err, "==> Joining thread %zu\n", i); + BIO_printf(bio_err, "==> Joining thread %d\n", i); if (!TEST_true(RADIX_THREAD_join(rt))) ok = 0; @@ -411,11 +411,11 @@ static void RADIX_THREAD_free(RADIX_THREAD *rt); static void RADIX_PROCESS_cleanup(RADIX_PROCESS *rp) { - size_t i; + int i; assert(rp->done_join_all_threads); - for (i = 0; i < (size_t)sk_RADIX_THREAD_num(rp->threads); ++i) + for (i = 0; i < sk_RADIX_THREAD_num(rp->threads); ++i) RADIX_THREAD_free(sk_RADIX_THREAD_value(rp->threads, i)); sk_RADIX_THREAD_free(rp->threads); diff --git a/test/radix/quic_ops.c b/test/radix/quic_ops.c index d987cfeadec..08e048eef70 100644 --- a/test/radix/quic_ops.c +++ b/test/radix/quic_ops.c @@ -583,7 +583,7 @@ DEF_FUNC(hf_write_rand) buf = OPENSSL_malloc(thislen); if (!TEST_ptr(buf)) goto err; - if (!TEST_int_eq(RAND_bytes(buf, thislen), 1)) + if (!TEST_int_eq(RAND_bytes(buf, (int)thislen), 1)) goto err; r = SSL_write_ex(ssl, buf, thislen, &bytes_written); if (!TEST_true(r) diff --git a/test/servername_test.c b/test/servername_test.c index b417f8bcacb..eb17d2c8680 100644 --- a/test/servername_test.c +++ b/test/servername_test.c @@ -78,11 +78,11 @@ static int get_sni_from_client_hello(BIO *bio, char **sni) goto end; if (type == TLSEXT_TYPE_server_name) { if (!TEST_true(PACKET_get_length_prefixed_2(&pkt3, &pkt4)) - || !TEST_uint_ne(PACKET_remaining(&pkt4), 0) + || !TEST_size_t_ne(PACKET_remaining(&pkt4), 0) || !TEST_true(PACKET_get_1(&pkt4, &servname_type)) || !TEST_uint_eq(servname_type, TLSEXT_NAMETYPE_host_name) || !TEST_true(PACKET_get_length_prefixed_2(&pkt4, &pkt5)) - || !TEST_uint_le(PACKET_remaining(&pkt5), TLSEXT_MAXLEN_host_name) + || !TEST_size_t_le(PACKET_remaining(&pkt5), TLSEXT_MAXLEN_host_name) || !TEST_false(PACKET_contains_zero_byte(&pkt5)) || !TEST_true(PACKET_strndup(&pkt5, sni))) goto end; diff --git a/test/siphash_internal_test.c b/test/siphash_internal_test.c index 7d1c6be9e84..560c6dbfa11 100644 --- a/test/siphash_internal_test.c +++ b/test/siphash_internal_test.c @@ -185,7 +185,7 @@ static int test_siphash(int idx) return 0; } - if (!TEST_int_le(inlen, sizeof(in))) + if (!TEST_size_t_le(inlen, sizeof(in))) return 0; /* key and in data are 00 01 02 ... */ diff --git a/test/slh_dsa_test.c b/test/slh_dsa_test.c index eff9071937a..2eb7e797e9f 100644 --- a/test/slh_dsa_test.c +++ b/test/slh_dsa_test.c @@ -274,7 +274,7 @@ static int slh_dsa_sign_verify_test(int tst_id) td->msg, td->msg_len), 1) || !TEST_true(EVP_PKEY_get_size_t_param(pkey, OSSL_PKEY_PARAM_MAX_SIZE, &sig_len2)) - || !TEST_int_eq(sig_len2, psig_len) + || !TEST_size_t_eq(sig_len2, psig_len) || !TEST_ptr(psig = OPENSSL_zalloc(psig_len)) || !TEST_int_eq(EVP_PKEY_sign(sctx, psig, &psig_len, td->msg, td->msg_len), 1)) @@ -338,10 +338,10 @@ static int slh_dsa_keygen_test(int tst_id) pub, sizeof(pub), &pub_len))) goto err; if (!TEST_true(EVP_PKEY_get_int_param(pkey, OSSL_PKEY_PARAM_BITS, &bits)) - || !TEST_int_eq(bits, 8 * 2 * n) + || !TEST_size_t_eq((size_t)bits, 8 * 2 * n) || !TEST_true(EVP_PKEY_get_int_param(pkey, OSSL_PKEY_PARAM_SECURITY_BITS, &sec_bits)) - || !TEST_int_eq(sec_bits, 8 * n) + || !TEST_size_t_eq((size_t)sec_bits, 8 * n) || !TEST_true(EVP_PKEY_get_int_param(pkey, OSSL_PKEY_PARAM_MAX_SIZE, &sig_len)) || !TEST_int_ge(sig_len, 7856) diff --git a/test/sm2_internal_test.c b/test/sm2_internal_test.c index 1623098fc6f..abe05bcac53 100644 --- a/test/sm2_internal_test.c +++ b/test/sm2_internal_test.c @@ -184,14 +184,13 @@ static int test_sm2_crypt(const EC_GROUP *group, goto done; if (!TEST_true(ossl_sm2_plaintext_size(ctext, ctext_len, &ptext_len)) - || !TEST_int_eq(ptext_len, msg_len)) + || !TEST_size_t_eq(ptext_len, msg_len)) goto done; recovered = OPENSSL_zalloc(ptext_len); if (!TEST_ptr(recovered) || !TEST_true(ossl_sm2_decrypt(key, digest, ctext, ctext_len, recovered, &recovered_len)) - || !TEST_int_eq(recovered_len, msg_len) || !TEST_mem_eq(recovered, recovered_len, message, msg_len)) goto done; diff --git a/test/ssl_old_test.c b/test/ssl_old_test.c index 8c26f3ed2f0..0b22795b6e7 100644 --- a/test/ssl_old_test.c +++ b/test/ssl_old_test.c @@ -299,9 +299,9 @@ static int cb_server_alpn(SSL *s, const unsigned char **out, abort(); } - if (SSL_select_next_proto - ((unsigned char **)out, outlen, protos, protos_len, in, - inlen) != OPENSSL_NPN_NEGOTIATED) { + if (SSL_select_next_proto((unsigned char **)out, outlen, protos, + (unsigned int)protos_len, + in, inlen) != OPENSSL_NPN_NEGOTIATED) { OPENSSL_free(protos); return SSL_TLSEXT_ERR_NOACK; } @@ -1056,7 +1056,7 @@ int main(int argc, char *argv[]) bytes = atol(*(++argv)); if (bytes == 0L) bytes = 1L; - i = strlen(argv[0]); + i = (int)strlen(argv[0]); if (argv[0][i - 1] == 'k') bytes *= 1024L; if (argv[0][i - 1] == 'm') @@ -1735,7 +1735,7 @@ int main(int argc, char *argv[]) goto end; } /* Returns 0 on success!! */ - if (SSL_CTX_set_alpn_protos(c_ctx, alpn, alpn_len)) { + if (SSL_CTX_set_alpn_protos(c_ctx, alpn, (unsigned int)alpn_len)) { BIO_printf(bio_err, "Error setting ALPN\n"); OPENSSL_free(alpn); goto end; diff --git a/test/sslapitest.c b/test/sslapitest.c index e4e0b9c085c..0031325d390 100644 --- a/test/sslapitest.c +++ b/test/sslapitest.c @@ -150,7 +150,7 @@ static int hostname_cb(SSL *s, int *al, void *arg) static void client_keylog_callback(const SSL *ssl, const char *line) { - int line_length = strlen(line); + int line_length = (int)strlen(line); /* If the log doesn't fit, error out. */ if (client_log_buffer_index + line_length > sizeof(client_log_buffer) - 1) { @@ -166,7 +166,7 @@ static void client_keylog_callback(const SSL *ssl, const char *line) static void server_keylog_callback(const SSL *ssl, const char *line) { - int line_length = strlen(line); + int line_length = (int)strlen(line); /* If the log doesn't fit, error out. */ if (server_log_buffer_index + line_length > sizeof(server_log_buffer) - 1) { @@ -394,8 +394,8 @@ static int test_keylog(void) || !TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE)) || !TEST_false(error_writing_log) - || !TEST_int_gt(client_log_buffer_index, 0) - || !TEST_int_gt(server_log_buffer_index, 0)) + || !TEST_size_t_gt(client_log_buffer_index, 0) + || !TEST_size_t_gt(server_log_buffer_index, 0)) goto end; /* @@ -917,14 +917,14 @@ static int test_ccs_change_cipher(void) /* Actually drive the renegotiation. */ for (i = 0; i < 3; i++) { if (SSL_read_ex(clientssl, &buf, sizeof(buf), &readbytes) > 0) { - if (!TEST_ulong_eq(readbytes, 0)) + if (!TEST_size_t_eq(readbytes, 0)) goto end; } else if (!TEST_int_eq(SSL_get_error(clientssl, 0), SSL_ERROR_WANT_READ)) { goto end; } if (SSL_read_ex(serverssl, &buf, sizeof(buf), &readbytes) > 0) { - if (!TEST_ulong_eq(readbytes, 0)) + if (!TEST_size_t_eq(readbytes, 0)) goto end; } else if (!TEST_int_eq(SSL_get_error(serverssl, 0), SSL_ERROR_WANT_READ)) { @@ -1780,7 +1780,7 @@ static int execute_cleanse_plaintext(const SSL_METHOD *smeth, rr = serversc->rlayer.tlsrecs; zbuf = &rr->data[rr->off]; - if (!TEST_int_eq(rr->length, sizeof(cbuf))) + if (!TEST_size_t_eq(rr->length, sizeof(cbuf))) goto end; /* @@ -2768,7 +2768,7 @@ static int test_extra_tickets(int idx) || !TEST_int_eq(idx * 2 + 2, new_called) || !TEST_true(SSL_read_ex(clientssl, buf, sizeof(buf), &nbytes)) || !TEST_int_eq(idx * 2 + 4, new_called) - || !TEST_int_eq(sizeof(buf), nbytes) + || !TEST_size_t_eq(sizeof(buf), nbytes) || !TEST_int_eq(c, buf[0]) || !TEST_false(SSL_read_ex(clientssl, buf, sizeof(buf), &nbytes))) goto end; @@ -2845,7 +2845,7 @@ static int test_extra_tickets(int idx) || !TEST_int_eq(0, new_called) || !TEST_true(SSL_read_ex(clientssl, buf, sizeof(buf), &nbytes)) || !TEST_int_eq(0, new_called) - || !TEST_int_eq(sizeof(buf), nbytes) + || !TEST_size_t_eq(sizeof(buf), nbytes) || !TEST_int_eq(c, buf[0]) || !TEST_false(SSL_read_ex(clientssl, buf, sizeof(buf), &nbytes))) goto end; @@ -2860,7 +2860,7 @@ static int test_extra_tickets(int idx) || !TEST_int_eq(2, new_called) || !TEST_true(SSL_read_ex(clientssl, buf, sizeof(buf), &nbytes)) || !TEST_int_eq(4, new_called) - || !TEST_int_eq(sizeof(buf), nbytes) + || !TEST_size_t_eq(sizeof(buf), nbytes) || !TEST_int_eq(c, buf[0]) || !TEST_false(SSL_read_ex(clientssl, buf, sizeof(buf), &nbytes))) goto end; @@ -3204,7 +3204,7 @@ static int test_set_sigalgs(int idx) int ret; if (curr->list != NULL) - ret = SSL_CTX_set1_sigalgs(cctx, curr->list, curr->listlen); + ret = SSL_CTX_set1_sigalgs(cctx, curr->list, (long)curr->listlen); else ret = SSL_CTX_set1_sigalgs_list(cctx, curr->liststr); @@ -3229,7 +3229,7 @@ static int test_set_sigalgs(int idx) int ret; if (curr->list != NULL) - ret = SSL_set1_sigalgs(clientssl, curr->list, curr->listlen); + ret = SSL_set1_sigalgs(clientssl, curr->list, (long)curr->listlen); else ret = SSL_set1_sigalgs_list(clientssl, curr->liststr); if (!ret) { @@ -3301,7 +3301,7 @@ static unsigned int psk_client_cb(SSL *ssl, const char *hint, char *id, unsigned char *psk, unsigned int max_psk_len) { - unsigned int psklen = 0; + size_t psklen = 0; psk_client_cb_cnt++; @@ -3321,7 +3321,7 @@ static unsigned int psk_client_cb(SSL *ssl, const char *hint, char *id, psklen = SSL_SESSION_get_master_key(clientpsk, psk, max_psk_len); strncpy(id, pskid, max_id_len); - return psklen; + return (unsigned int)psklen; } #endif /* OPENSSL_NO_PSK */ @@ -3357,7 +3357,7 @@ static int find_session_cb(SSL *ssl, const unsigned char *identity, static unsigned int psk_server_cb(SSL *ssl, const char *identity, unsigned char *psk, unsigned int max_psk_len) { - unsigned int psklen = 0; + size_t psklen = 0; psk_server_cb_cnt++; @@ -3378,7 +3378,7 @@ static unsigned int psk_server_cb(SSL *ssl, const char *identity, return 0; psklen = SSL_SESSION_get_master_key(serverpsk, psk, max_psk_len); - return psklen; + return (unsigned int)psklen; } #endif /* OPENSSL_NO_PSK */ @@ -5979,7 +5979,7 @@ static int generate_stateless_cookie_callback(SSL *ssl, unsigned char *cookie, static int verify_stateless_cookie_callback(SSL *ssl, const unsigned char *cookie, size_t cookie_len) { - return verify_cookie_callback(ssl, cookie, cookie_len); + return verify_cookie_callback(ssl, cookie, (unsigned int)cookie_len); } static int test_stateless(void) @@ -6861,14 +6861,14 @@ static int test_key_update(void) } /* Check that sending and receiving app data is ok */ - if (!TEST_int_eq(SSL_write(clientssl, mess, strlen(mess)), strlen(mess)) + if (!TEST_int_eq(SSL_write(clientssl, mess, (int)strlen(mess)), (int)strlen(mess)) || !TEST_int_eq(SSL_read(serverssl, buf, sizeof(buf)), - strlen(mess))) + (int)strlen(mess))) goto end; - if (!TEST_int_eq(SSL_write(serverssl, mess, strlen(mess)), strlen(mess)) + if (!TEST_int_eq(SSL_write(serverssl, mess, (int)strlen(mess)), (int)strlen(mess)) || !TEST_int_eq(SSL_read(clientssl, buf, sizeof(buf)), - strlen(mess))) + (int)strlen(mess))) goto end; } @@ -6929,7 +6929,7 @@ static int test_key_update_peer_in_write(int tst) bretry = NULL; /* Write data that we know will fail with SSL_ERROR_WANT_WRITE */ - if (!TEST_int_eq(SSL_write(peerwrite, mess, strlen(mess)), -1) + if (!TEST_int_eq(SSL_write(peerwrite, mess, (int)strlen(mess)), -1) || !TEST_int_eq(SSL_get_error(peerwrite, 0), SSL_ERROR_WANT_WRITE) || !TEST_true(SSL_want_write(peerwrite)) || !TEST_true(SSL_net_write_desired(peerwrite))) @@ -6950,13 +6950,13 @@ static int test_key_update_peer_in_write(int tst) * Complete the write we started previously and read it from the other * endpoint */ - if (!TEST_int_eq(SSL_write(peerwrite, mess, strlen(mess)), strlen(mess)) - || !TEST_int_eq(SSL_read(peerupdate, buf, sizeof(buf)), strlen(mess))) + if (!TEST_int_eq(SSL_write(peerwrite, mess, (int)strlen(mess)), (int)strlen(mess)) + || !TEST_int_eq(SSL_read(peerupdate, buf, sizeof(buf)), (int)strlen(mess))) goto end; /* Write more data to ensure we send the KeyUpdate message back */ - if (!TEST_int_eq(SSL_write(peerwrite, mess, strlen(mess)), strlen(mess)) - || !TEST_int_eq(SSL_read(peerupdate, buf, sizeof(buf)), strlen(mess))) + if (!TEST_int_eq(SSL_write(peerwrite, mess, (int)strlen(mess)), (int)strlen(mess)) + || !TEST_int_eq(SSL_read(peerupdate, buf, sizeof(buf)), (int)strlen(mess))) goto end; if (!TEST_false(SSL_net_read_desired(peerwrite)) @@ -7034,7 +7034,7 @@ static int test_key_update_peer_in_read(int tst) goto end; /* Now write some data in peer - we will write the key update */ - if (!TEST_int_eq(SSL_write(peer, mess, strlen(mess)), strlen(mess))) + if (!TEST_int_eq(SSL_write(peer, mess, (int)strlen(mess)), (int)strlen(mess))) goto end; /* @@ -7046,8 +7046,8 @@ static int test_key_update_peer_in_read(int tst) goto end; /* check that sending and receiving appdata ok */ - if (!TEST_int_eq(SSL_write(local, mess, strlen(mess)), strlen(mess)) - || !TEST_int_eq(SSL_read(peer, prbuf, sizeof(prbuf)), strlen(mess))) + if (!TEST_int_eq(SSL_write(local, mess, (int)strlen(mess)), (int)strlen(mess)) + || !TEST_int_eq(SSL_read(peer, prbuf, sizeof(prbuf)), (int)strlen(mess))) goto end; testresult = 1; @@ -7103,7 +7103,7 @@ static int test_key_update_local_in_write(int tst) bretry = NULL; /* write data in local will fail with SSL_ERROR_WANT_WRITE */ - if (!TEST_int_eq(SSL_write(local, mess, strlen(mess)), -1) + if (!TEST_int_eq(SSL_write(local, mess, (int)strlen(mess)), -1) || !TEST_int_eq(SSL_get_error(local, -1), SSL_ERROR_WANT_WRITE)) goto end; @@ -7118,7 +7118,7 @@ static int test_key_update_local_in_write(int tst) ERR_clear_error(); /* write data in local previously that we will complete */ - if (!TEST_int_eq(SSL_write(local, mess, strlen(mess)), strlen(mess))) + if (!TEST_int_eq(SSL_write(local, mess, (int)strlen(mess)), (int)strlen(mess))) goto end; /* SSL_key_update will succeed because there is no pending write data */ @@ -7130,13 +7130,13 @@ static int test_key_update_local_in_write(int tst) * we write some appdata in local * read data in peer - we will read the keyupdate msg */ - if (!TEST_int_eq(SSL_write(local, mess, strlen(mess)), strlen(mess)) - || !TEST_int_eq(SSL_read(peer, buf, sizeof(buf)), strlen(mess))) + if (!TEST_int_eq(SSL_write(local, mess, (int)strlen(mess)), (int)strlen(mess)) + || !TEST_int_eq(SSL_read(peer, buf, sizeof(buf)), (int)strlen(mess))) goto end; /* Write more peer more data to ensure we send the keyupdate message back */ - if (!TEST_int_eq(SSL_write(peer, mess, strlen(mess)), strlen(mess)) - || !TEST_int_eq(SSL_read(local, buf, sizeof(buf)), strlen(mess))) + if (!TEST_int_eq(SSL_write(peer, mess, (int)strlen(mess)), (int)strlen(mess)) + || !TEST_int_eq(SSL_read(local, buf, sizeof(buf)), (int)strlen(mess))) goto end; testresult = 1; @@ -7215,13 +7215,13 @@ static int test_key_update_local_in_read(int tst) * write data in local * read data in peer - we will read the key update */ - if (!TEST_int_eq(SSL_write(local, mess, strlen(mess)), strlen(mess)) - || !TEST_int_eq(SSL_read(peer, prbuf, sizeof(prbuf)), strlen(mess))) + if (!TEST_int_eq(SSL_write(local, mess, (int)strlen(mess)), (int)strlen(mess)) + || !TEST_int_eq(SSL_read(peer, prbuf, sizeof(prbuf)), (int)strlen(mess))) goto end; /* Write more peer data to ensure we send the keyupdate message back */ - if (!TEST_int_eq(SSL_write(peer, mess, strlen(mess)), strlen(mess)) - || !TEST_int_eq(SSL_read(local, lrbuf, sizeof(lrbuf)), strlen(mess))) + if (!TEST_int_eq(SSL_write(peer, mess, (int)strlen(mess)), (int)strlen(mess)) + || !TEST_int_eq(SSL_read(local, lrbuf, sizeof(lrbuf)), (int)strlen(mess))) goto end; testresult = 1; @@ -7390,7 +7390,7 @@ static int get_MFL_from_client_hello(BIO *bio, int *mfl_codemfl_code) goto end; if (type == TLSEXT_TYPE_max_fragment_length) { - if (!TEST_uint_ne(PACKET_remaining(&pkt3), 0) + if (!TEST_size_t_ne(PACKET_remaining(&pkt3), 0) || !TEST_true(PACKET_get_1(&pkt3, &MFL_code))) goto end; @@ -11500,12 +11500,12 @@ static int test_pipelining(int idx) { SSL_CTX *cctx = NULL, *sctx = NULL; SSL *clientssl = NULL, *serverssl = NULL, *peera, *peerb; - int testresult = 0, numreads; + int testresult = 0, numreads, numpipes = 5; /* A 55 byte message */ unsigned char *msg = (unsigned char *) "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123"; - size_t written, readbytes, offset, msglen, fragsize = 10, numpipes = 5; - size_t expectedreads; + size_t written, readbytes, offset, msglen, fragsize = 10; + int expectedreads; unsigned char *buf = NULL; ENGINE *e = NULL; @@ -11575,7 +11575,7 @@ static int test_pipelining(int idx) * Test that setting a split send fragment longer than the maximum * allowed fails */ - if (!TEST_false(SSL_set_split_send_fragment(peera, fragsize + 1))) + if (!TEST_false(SSL_set_split_send_fragment(peera, (long)(fragsize + 1)))) goto end; } @@ -11585,7 +11585,7 @@ static int test_pipelining(int idx) * but sufficient for our purposes */ if (!TEST_true(SSL_set_max_pipelines(peera, numpipes)) - || !TEST_true(SSL_set_split_send_fragment(peera, fragsize))) + || !TEST_true(SSL_set_split_send_fragment(peera, (long)fragsize))) goto end; if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE))) diff --git a/test/testutil/format_output.c b/test/testutil/format_output.c index 8e84e1a6b6a..0a0f464ca14 100644 --- a/test/testutil/format_output.c +++ b/test/testutil/format_output.c @@ -113,7 +113,7 @@ static void test_fail_string_common(const char *prefix, const char *file, m2 += n2; l1 -= n1; l2 -= n2; - cnt += width; + cnt += (unsigned int)width; } fin: test_flush_stderr(); @@ -206,7 +206,7 @@ static void test_bignum_zero_print(const BIGNUM *bn, char sep) static int convert_bn_memory(const unsigned char *in, size_t bytes, char *out, int *lz, const BIGNUM *bn) { - int n = bytes * 2, i; + int n = (int)(bytes * 2), i; char *p = out, *q = NULL; const char *r; @@ -307,15 +307,15 @@ static void test_fail_bignum_common(const char *prefix, const char *file, if (bn1 != NULL) { m1 = bufp; - BN_bn2binpad(bn1, m1, len); + BN_bn2binpad(bn1, m1, (int)len); } if (bn2 != NULL) { m2 = bufp + len; - BN_bn2binpad(bn2, m2, len); + BN_bn2binpad(bn2, m2, (int)len); } while (len > 0) { - cnt = 8 * (len - bytes); + cnt = (unsigned int)(8 * (len - bytes)); n1 = convert_bn_memory(m1, bytes, b1, &lz1, bn1); n2 = convert_bn_memory(m2, bytes, b2, &lz2, bn2); @@ -504,7 +504,7 @@ static void test_fail_memory_common(const char *prefix, const char *file, m2 += n2; l1 -= n1; l2 -= n2; - cnt += bytes; + cnt += (unsigned int)bytes; } fin: test_flush_stderr(); diff --git a/test/testutil/testutil_init.c b/test/testutil/testutil_init.c index 69ea27ed2b9..ccbafe96c84 100644 --- a/test/testutil/testutil_init.c +++ b/test/testutil/testutil_init.c @@ -39,7 +39,9 @@ static size_t internal_trace_cb(const char *buf, size_t cnt, BIO_set_prefix(trace_data->bio, buffer); break; case OSSL_TRACE_CTRL_WRITE: - ret = BIO_write(trace_data->bio, buf, cnt); + if (cnt > INT_MAX) + cnt = INT_MAX; + ret = BIO_write(trace_data->bio, buf, (int)cnt); break; case OSSL_TRACE_CTRL_END: trace_data->ingroup = 0; diff --git a/test/threadpool_test.c b/test/threadpool_test.c index e0d9cc9f09b..338de88e63b 100644 --- a/test/threadpool_test.c +++ b/test/threadpool_test.c @@ -98,7 +98,7 @@ static int test_thread_internal(void) uint32_t retval[3]; uint32_t local[3] = { 0 }; uint32_t threads_supported; - size_t i; + uint32_t i; void *t[3]; int status = 0; OSSL_LIB_CTX *cust_ctx = OSSL_LIB_CTX_new(); @@ -180,7 +180,7 @@ static int test_thread_internal(void) if (!TEST_int_eq(ossl_crypto_thread_join(t[i], &retval[0]), 1)) goto cleanup; - if (!TEST_int_eq(retval[0], i + 1) || !TEST_int_eq(local[0], i + 2)) + if (!TEST_uint_eq(retval[0], i + 1) || !TEST_uint_eq(local[0], i + 2)) goto cleanup; if (!TEST_int_eq(ossl_crypto_thread_clean(t[i]), 1)) @@ -207,7 +207,7 @@ static int test_thread_internal(void) goto cleanup; } for (i = 0; i < OSSL_NELEM(t); ++i) { - if (!TEST_int_eq(retval[i], i + 1) || !TEST_int_eq(local[i], i + 2)) + if (!TEST_uint_eq(retval[i], i + 1) || !TEST_uint_eq(local[i], i + 2)) goto cleanup; if (!TEST_int_eq(ossl_crypto_thread_clean(t[i]), 1)) goto cleanup; @@ -229,7 +229,7 @@ static int test_thread_internal(void) goto cleanup; } for (i = 0; i < OSSL_NELEM(t); ++i) { - if (!TEST_int_eq(retval[i], i + 1) || !TEST_int_eq(local[i], i + 2)) + if (!TEST_uint_eq(retval[i], i + 1) || !TEST_uint_eq(local[i], i + 2)) goto cleanup; if (!TEST_int_eq(ossl_crypto_thread_clean(t[i]), 1)) goto cleanup; diff --git a/test/threadstest.c b/test/threadstest.c index 76db07f3baf..08081c60730 100644 --- a/test/threadstest.c +++ b/test/threadstest.c @@ -880,7 +880,7 @@ static void thread_general_worker(void) if (!TEST_true(EVP_EncryptInit_ex(cipherctx, ciph, NULL, key, iv)) || !TEST_true(EVP_EncryptUpdate(cipherctx, out, &ciphoutl, (unsigned char *)message, - messlen)) + (int)messlen)) || !TEST_true(EVP_EncryptFinal(cipherctx, out, &ciphoutl))) goto err; } @@ -1272,7 +1272,7 @@ static void test_pem_read_one(void) goto err; } - pem = BIO_new_mem_buf(pemdata, len); + pem = BIO_new_mem_buf(pemdata, (int)len); if (pem == NULL) { multi_set_success(0); goto err; diff --git a/test/time_offset_test.c b/test/time_offset_test.c index 7da75fe9332..7e8466711ad 100644 --- a/test/time_offset_test.c +++ b/test/time_offset_test.c @@ -72,7 +72,7 @@ static int test_offset(int idx) int day, sec; at.data = (unsigned char*)testdata->data; - at.length = strlen(testdata->data); + at.length = (int)strlen(testdata->data); at.type = testdata->type; at.flags = 0; diff --git a/test/tls-provider.c b/test/tls-provider.c index 5afa5b5d728..f1206c99994 100644 --- a/test/tls-provider.c +++ b/test/tls-provider.c @@ -1386,7 +1386,8 @@ static X509_SIG *p8info_to_encp8(PKCS8_PRIV_KEY_INFO *p8info, return NULL; } /* First argument == -1 means "standard" */ - p8 = PKCS8_encrypt_ex(-1, ctx->cipher, kstr, klen, NULL, 0, 0, p8info, libctx, NULL); + p8 = PKCS8_encrypt_ex(-1, ctx->cipher, kstr, (int)klen, NULL, 0, 0, p8info, + libctx, NULL); OPENSSL_cleanse(kstr, klen); return p8; } diff --git a/test/tls13ccstest.c b/test/tls13ccstest.c index 6e1b7d978ce..ea36b2dfcb3 100644 --- a/test/tls13ccstest.c +++ b/test/tls13ccstest.c @@ -237,7 +237,7 @@ static int watchccs_gets(BIO *bio, char *buf, int size) static int watchccs_puts(BIO *bio, const char *str) { - return watchccs_write(bio, str, strlen(str)); + return watchccs_write(bio, str, (int)strlen(str)); } static int test_tls13ccs(int tst) diff --git a/test/trace_api_test.c b/test/trace_api_test.c index 0effee421ab..3d1a7e9eef5 100644 --- a/test/trace_api_test.c +++ b/test/trace_api_test.c @@ -103,13 +103,13 @@ static int put_trace_output(void) int res = 1; OSSL_TRACE_BEGIN(HTTP) { - res = TEST_int_eq(BIO_printf(trc_out, OSSL_HELLO), strlen(OSSL_HELLO)); - res += TEST_int_eq(trace_string(0, 0, OSSL_STR80), strlen(OSSL_STR80)); - res += TEST_int_eq(trace_string(0, 0, OSSL_STR81), strlen(OSSL_STR80)); - res += TEST_int_eq(trace_string(1, 1, OSSL_CTRL), strlen(OSSL_CTRL)); - res += TEST_int_eq(trace_string(0, 1, OSSL_MASKED), strlen(OSSL_MASKED) + res = TEST_int_eq(BIO_printf(trc_out, OSSL_HELLO), (int)strlen(OSSL_HELLO)); + res += TEST_int_eq(trace_string(0, 0, OSSL_STR80), (int)strlen(OSSL_STR80)); + res += TEST_int_eq(trace_string(0, 0, OSSL_STR81), (int)strlen(OSSL_STR80)); + res += TEST_int_eq(trace_string(1, 1, OSSL_CTRL), (int)strlen(OSSL_CTRL)); + res += TEST_int_eq(trace_string(0, 1, OSSL_MASKED), (int)strlen(OSSL_MASKED) + 1); /* newline added */ - res += TEST_int_eq(BIO_printf(trc_out, OSSL_BYE), strlen(OSSL_BYE)); + res += TEST_int_eq(BIO_printf(trc_out, OSSL_BYE), (int)strlen(OSSL_BYE)); res = res == 6; /* not using '&&' but '+' to catch potentially multiple test failures */ } OSSL_TRACE_END(HTTP); diff --git a/test/uitest.c b/test/uitest.c index 82c8c59204f..e8615217bd3 100644 --- a/test/uitest.c +++ b/test/uitest.c @@ -21,7 +21,7 @@ static int test_pem_password_cb(char *buf, int size, int rwflag, void *userdata) { OPENSSL_strlcpy(buf, (char *)userdata, (size_t)size); - return strlen(buf); + return (int)strlen(buf); } /* diff --git a/test/v3ext.c b/test/v3ext.c index fdc37acee5c..5be0c024131 100644 --- a/test/v3ext.c +++ b/test/v3ext.c @@ -376,7 +376,7 @@ static int test_ext_syntax(void) for (i = 0; i < OSSL_NELEM(extvalues); i++) { X509V3_CTX ctx; BIO *extbio = BIO_new_mem_buf(extvalues[i].value, - strlen(extvalues[i].value)); + (int)strlen(extvalues[i].value)); CONF *conf; long eline; diff --git a/test/v3nametest.c b/test/v3nametest.c index 152da1a1ddc..438dd9fcd6b 100644 --- a/test/v3nametest.c +++ b/test/v3nametest.c @@ -675,9 +675,9 @@ static int test_GENERAL_NAME_cmp(void) * We create two versions of each GENERAL_NAME so that we ensure when * we compare them they are always different pointers. */ - namesa[i] = d2i_GENERAL_NAME(NULL, &derp, gennames[i].derlen); + namesa[i] = d2i_GENERAL_NAME(NULL, &derp, (long)gennames[i].derlen); derp = gennames[i].der; - namesb[i] = d2i_GENERAL_NAME(NULL, &derp, gennames[i].derlen); + namesb[i] = d2i_GENERAL_NAME(NULL, &derp, (long)gennames[i].derlen); if (!TEST_ptr(namesa[i]) || !TEST_ptr(namesb[i])) goto end; } diff --git a/test/x509_acert_test.c b/test/x509_acert_test.c index 154ec3b607d..98384fcb38e 100644 --- a/test/x509_acert_test.c +++ b/test/x509_acert_test.c @@ -130,7 +130,7 @@ static int test_object_group_attr(int idx) p = test->data; - ias = d2i_OSSL_IETF_ATTR_SYNTAX(NULL, &p, test->len); + ias = d2i_OSSL_IETF_ATTR_SYNTAX(NULL, &p, (long)test->len); if ((test->valid && !TEST_ptr(ias)) || (!test->valid && !TEST_ptr_null(ias))) @@ -153,7 +153,7 @@ done: OPT_TEST_DECLARE_USAGE("[...]\n") int setup_tests(void) { - int cnt; + size_t cnt; if (!test_skip_common_options()) { TEST_error("Error parsing test options\n"); @@ -166,7 +166,7 @@ int setup_tests(void) return 0; } - ADD_ALL_TESTS(test_print_acert, cnt); + ADD_ALL_TESTS(test_print_acert, (int)cnt); ADD_TEST(test_acert_sign); ADD_ALL_TESTS(test_object_group_attr, OSSL_NELEM(ietf_syntax_tests)); diff --git a/test/x509_dup_cert_test.c b/test/x509_dup_cert_test.c index b09de70a8a5..745a6328240 100644 --- a/test/x509_dup_cert_test.c +++ b/test/x509_dup_cert_test.c @@ -43,9 +43,9 @@ int setup_tests(void) } n = test_get_argument_count(); - if (!TEST_int_gt(n, 0)) + if (!TEST_size_t_gt(n, 0)) return 0; - ADD_ALL_TESTS(test_509_dup_cert, n); + ADD_ALL_TESTS(test_509_dup_cert, (int)n); return 1; } diff --git a/test/x509_test.c b/test/x509_test.c index 1c6e569a4c4..f5a3c0ce208 100644 --- a/test/x509_test.c +++ b/test/x509_test.c @@ -181,7 +181,7 @@ OPT_TEST_DECLARE_USAGE("\n") int setup_tests(void) { const unsigned char *p; - int cnt; + size_t cnt; cnt = test_get_argument_count(); if (cnt != 1) { diff --git a/test/x509_time_test.c b/test/x509_time_test.c index 262f9ed7ce9..c668beaaf70 100644 --- a/test/x509_time_test.c +++ b/test/x509_time_test.c @@ -261,7 +261,7 @@ static int test_x509_cmp_time(int idx) memset(&t, 0, sizeof(t)); t.type = x509_cmp_tests[idx].type; t.data = (unsigned char*)(x509_cmp_tests[idx].data); - t.length = strlen(x509_cmp_tests[idx].data); + t.length = (int)strlen(x509_cmp_tests[idx].data); t.flags = 0; result = X509_cmp_time(&t, &x509_cmp_tests[idx].cmp_time); -- 2.47.2