diff --git a/src/wp_aes_block.c b/src/wp_aes_block.c index 5e5e2a8e..21806675 100644 --- a/src/wp_aes_block.c +++ b/src/wp_aes_block.c @@ -507,9 +507,6 @@ static int wp_aes_block_update(wp_AesBlockCtx *ctx, unsigned char *out, (ctx->tls_version == 0)) { nextBlocks -= AES_BLOCK_SIZE; } - if (outSize < oLen) { - ok = 0; - } } if (ok && (nextBlocks > 0)) { if (!wp_aes_block_doit(ctx, out, in, nextBlocks)) { diff --git a/src/wp_des.c b/src/wp_des.c index 994662d0..d6cb1115 100644 --- a/src/wp_des.c +++ b/src/wp_des.c @@ -457,9 +457,6 @@ static int wp_des3_block_update(wp_Des3BlockCtx *ctx, unsigned char *out, (ctx->tls_version == 0)) { nextBlocks -= DES_BLOCK_SIZE; } - if (outSize < oLen) { - ok = 0; - } } if (ok && (nextBlocks > 0)) { if (!wp_des3_block_doit(ctx, out, in, nextBlocks)) { diff --git a/src/wp_dh_exch.c b/src/wp_dh_exch.c index bac53629..5c93bd7d 100644 --- a/src/wp_dh_exch.c +++ b/src/wp_dh_exch.c @@ -158,6 +158,7 @@ static wp_DhCtx* wp_dh_dupctx(wp_DhCtx* src) wp_dh_free(dst->peer); wp_dh_free(dst->key); OPENSSL_free(dst); + dst = NULL; } } @@ -369,7 +370,7 @@ static int wp_dh_derive(wp_DhCtx* ctx, unsigned char* secret, } } - if ((!done) && ok) { + if ((!done) && ok && (out != NULL)) { /* DH key exchange derivation using wolfSSL. */ ok = wp_dh_derive_secret(ctx, out, &outLen, maxLen); } diff --git a/src/wp_dh_kmgmt.c b/src/wp_dh_kmgmt.c index bddd913e..54ddc3b0 100644 --- a/src/wp_dh_kmgmt.c +++ b/src/wp_dh_kmgmt.c @@ -784,7 +784,7 @@ static int wp_dh_get_params(wp_Dh* dh, OSSL_PARAM params[]) if (p != NULL) { /* When buffer is NULL, return the size irrespective of type */ if (p->data == NULL) { - ok = wp_params_set_mp(params, OSSL_PKEY_PARAM_FFC_P, &dh->key.g, 1); + ok = wp_params_set_mp(params, OSSL_PKEY_PARAM_FFC_P, &dh->key.p, 1); } /* When buffer is non-NULL, type must be int or uint */ else diff --git a/src/wp_ecdh_exch.c b/src/wp_ecdh_exch.c index 154a38b8..472d7d4b 100644 --- a/src/wp_ecdh_exch.c +++ b/src/wp_ecdh_exch.c @@ -159,6 +159,7 @@ static wp_EcdhCtx* wp_ecdh_dup(wp_EcdhCtx* src) wp_ecc_free(src->peer); wp_ecc_free(src->key); OPENSSL_free(dst); + dst = NULL; } } diff --git a/src/wp_ecx_exch.c b/src/wp_ecx_exch.c index a88b8c7c..41d87fa2 100644 --- a/src/wp_ecx_exch.c +++ b/src/wp_ecx_exch.c @@ -117,6 +117,7 @@ static wp_EcxCtx* wp_ecx_dupctx(wp_EcxCtx* src) if (!ok) { wp_ecx_free(src->key); OPENSSL_free(dst); + dst = NULL; } } diff --git a/src/wp_kdf_exch.c b/src/wp_kdf_exch.c index 024ff2e4..984d50f0 100644 --- a/src/wp_kdf_exch.c +++ b/src/wp_kdf_exch.c @@ -134,6 +134,7 @@ static wp_KdfCtx* wp_kdf_ctx_dup(wp_KdfCtx* src) if (!ok) { OPENSSL_free(dst); + dst = NULL; } } diff --git a/src/wp_mac_kmgmt.c b/src/wp_mac_kmgmt.c index 2d96dcea..9e8bebb3 100644 --- a/src/wp_mac_kmgmt.c +++ b/src/wp_mac_kmgmt.c @@ -318,7 +318,7 @@ static int wp_mac_has(const wp_Mac* mac, int selection) if (mac == NULL) { ok = 0; } - if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) { + if (ok && ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)) { ok &= mac->key != NULL; } @@ -387,7 +387,7 @@ static int wp_mac_import(wp_Mac *mac, int selection, const OSSL_PARAM params[]) ok = 0; } p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PROPERTIES); - if (p != NULL) { + if (ok && (p != NULL)) { OPENSSL_free(mac->properties); mac->properties = NULL; if (!OSSL_PARAM_get_utf8_string(p, &mac->properties, 0)) { @@ -495,7 +495,7 @@ static int wp_mac_export(wp_Mac *mac, int selection, OSSL_CALLBACK *paramCb, ok = 0; } } - if (ok && !wp_mac_export_priv_key(mac, params, ¶msSz, data, &idx)) { + if (ok && (data != NULL) && !wp_mac_export_priv_key(mac, params, ¶msSz, data, &idx)) { ok = 0; } } diff --git a/src/wp_mac_sig.c b/src/wp_mac_sig.c index 5d79110b..a146e183 100644 --- a/src/wp_mac_sig.c +++ b/src/wp_mac_sig.c @@ -82,6 +82,7 @@ static wp_MacSigCtx* wp_mac_ctx_new(WOLFPROV_CTX* provCtx, if (propQuery != NULL) { p = OPENSSL_strdup(propQuery); if (p == NULL) { + OPENSSL_free(ctx); ctx = NULL; ok = 0; } @@ -342,7 +343,7 @@ static const OSSL_PARAM *wp_mac_settable_ctx_params(wp_MacSigCtx *ctx, OSSL_PARAM_int(OSSL_MAC_PARAM_DIGEST_ONESHOT, NULL), OSSL_PARAM_size_t(OSSL_MAC_PARAM_TLS_DATA_SIZE, NULL), OSSL_PARAM_END - }; + }; return settable_ctx_params; }