Skip to content

Commit 85b8c52

Browse files
committed
provider: Fix segfault with 'openssl list -signature-algorithms -verbose'
Command 'openssl list -signature-algorithms -verbose' calls OpenSSL function EVP_SIGNATURE_settable_ctx_params() which in turn calls the provider's settable_ctx_params() function, but with NULL for the operation context. This causes segfaults in IBMCAs settable_ctx_params() functions, as they assume that the operation context is not NULL. While at it, make sure that the settable/gettable_ctx_md_params() functions do not crash if called with a NULL context. Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
1 parent e544577 commit 85b8c52

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/provider/ec_signature.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ static const OSSL_PARAM *ibmca_signature_ec_settable_ctx_params(
823823

824824
ibmca_debug_ctx(provctx, "ctx: %p", ctx);
825825

826-
if (ctx->ec.signature.set_md_allowed)
826+
if (ctx == NULL || ctx->ec.signature.set_md_allowed)
827827
params = ibmca_signature_ec_settable_params;
828828
else
829829
params = ibmca_signature_ec_settable_params_no_digest;

src/provider/p_context.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,10 @@ const OSSL_PARAM *ibmca_gettable_ctx_md_params(const struct ibmca_op_ctx *ctx,
392392
ibmca_debug_op_ctx(ctx, "ctx: %p", ctx);
393393

394394
if (md == NULL) {
395-
put_error_op_ctx(ctx, IBMCA_ERR_INVALID_PARAM,
396-
"Digest sign/verify context not initialized");
397-
return 0;
395+
if (ctx != NULL)
396+
put_error_op_ctx(ctx, IBMCA_ERR_INVALID_PARAM,
397+
"Digest sign/verify context not initialized");
398+
return NULL;
398399
}
399400

400401
params = EVP_MD_gettable_ctx_params(md);
@@ -413,9 +414,10 @@ const OSSL_PARAM *ibmca_settable_ctx_md_params(const struct ibmca_op_ctx *ctx,
413414
ibmca_debug_op_ctx(ctx, "ctx: %p", ctx);
414415

415416
if (md == NULL) {
416-
put_error_op_ctx(ctx, IBMCA_ERR_INVALID_PARAM,
417-
"Digest sign/verify context not initialized");
418-
return 0;
417+
if (ctx != NULL)
418+
put_error_op_ctx(ctx, IBMCA_ERR_INVALID_PARAM,
419+
"Digest sign/verify context not initialized");
420+
return NULL;
419421
}
420422

421423
params = EVP_MD_settable_ctx_params(md);

src/provider/rsa_signature.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1814,7 +1814,7 @@ static const OSSL_PARAM *ibmca_signature_rsa_settable_ctx_params(
18141814

18151815
ibmca_debug_ctx(provctx, "ctx: %p", ctx);
18161816

1817-
if (ctx->rsa.signature.set_md_allowed)
1817+
if (ctx == NULL || ctx->rsa.signature.set_md_allowed)
18181818
params = ibmca_signature_rsa_settable_params;
18191819
else
18201820
params = ibmca_signature_rsa_settable_params_no_digest;

0 commit comments

Comments
 (0)