Prepare to provide EVP_MD_CTX{,_set}_pkey_ctx()
authortb <tb@openbsd.org>
Sun, 9 Jan 2022 15:15:25 +0000 (15:15 +0000)
committertb <tb@openbsd.org>
Sun, 9 Jan 2022 15:15:25 +0000 (15:15 +0000)
commit628f93c2695399ebd72c19db70c875dfa8d622eb
treed5f2c7d017f879916dd14334bf99877d27bd46e7
parentda03a6df25e45651a0f3d04319cd895dc92a9c32
Prepare to provide EVP_MD_CTX{,_set}_pkey_ctx()

This API with very strange ownership handling is used by Ruby 3.1,
unfortunately.

For unclear reasons, it was decided that the caller retains ownership of
the pctx passed in.  EVP_PKEY_CTX aren't refcounted, so a flag was added to
make sure that md_ctx->pctx is not freed in EVP_MD_CTX_{cleanup,reset}().
Since EVP_MD_CTX_copy_ex() duplicates the md_ctx->pctx, the flag also needs
to be unset on the duplicated EVP_MD_CTX.

ok inoguchi jsing
lib/libcrypto/evp/digest.c
lib/libcrypto/evp/evp.h
lib/libcrypto/evp/evp_lib.c
lib/libcrypto/evp/evp_locl.h