Rework X509_STORE_CTX_set_{purpose,trust}()
authortb <tb@openbsd.org>
Wed, 10 Jan 2024 17:31:28 +0000 (17:31 +0000)
committertb <tb@openbsd.org>
Wed, 10 Jan 2024 17:31:28 +0000 (17:31 +0000)
commit014898899f7b0cbfe42b5620b91ba230b9663e3d
tree1fc6893e08e3f6dacec6f553d4f2a76acc7bf8aa
parent1ef7e4b421a0186fe9e39a60352ef7f06bc4da26
Rework X509_STORE_CTX_set_{purpose,trust}()

Split the two codepaths in x509_vfy_purpose_inherit() into its two callers.
What remains is gross, but at least a reader has a chance of following all
this nonsense without leaving a significant amount of hair behind.

In short, purpose and trust are only overridden if they're not already
set.  Otherwise silently ignore valid purpose and trust identifiers that
were passed in and succeed. Error on almost all invalid trust or purpose
ids, except 0, because... well... who knows, really?

ok jsing
lib/libcrypto/x509/x509_vfy.c