Commit 8d0f837db8 for openssl.org

commit 8d0f837db83586b6e4b12a24ee68c5e2ea643d75
Author: 007bsd <22483432+007bsd@users.noreply.github.com>
Date:   Fri May 15 12:04:58 2026 +0300

    Fix key2ms_newctx() pointer type mismatch in MSBLOB/PVK key encoder

    key2ms_newctx() returned struct key2ms_ctx_st *, but is registered
    as OSSL_FUNC_ENCODER_NEWCTX and called through OSSL_FUNC_encoder_newctx_fn
    (void *(*)(void *)), which is a case of undefined behavior, flagged
    by -fsanitize=function.  Same class as [1], missed there.

    Give it the correct signature and add the self-check forward
    declaration, as key2ms_freectx() already has.

    [1] https://github.com/openssl/openssl/pull/31078

    CLA: trivial
    Fixes: 0cc0164d193f "PROV: Add MSBLOB and PVK encoders"

    Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
    Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
    Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
    Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
    Reviewed-by: Paul Dale <paul.dale@oracle.com>
    MergeDate: Tue Jun 23 14:45:54 2026
    (Merged from https://github.com/openssl/openssl/pull/31189)

diff --git a/providers/implementations/encode_decode/encode_key2ms.c b/providers/implementations/encode_decode/encode_key2ms.c
index 8ae4022e51..87b4242923 100644
--- a/providers/implementations/encode_decode/encode_key2ms.c
+++ b/providers/implementations/encode_decode/encode_key2ms.c
@@ -68,10 +68,11 @@ static int write_pvk(struct key2ms_ctx_st *ctx, OSSL_CORE_BIO *cout,
     return ret;
 }

+static OSSL_FUNC_encoder_newctx_fn key2ms_newctx;
 static OSSL_FUNC_encoder_freectx_fn key2ms_freectx;
 static OSSL_FUNC_encoder_does_selection_fn key2ms_does_selection;

-static struct key2ms_ctx_st *key2ms_newctx(void *provctx)
+static void *key2ms_newctx(void *provctx)
 {
     struct key2ms_ctx_st *ctx = OPENSSL_zalloc(sizeof(*ctx));