Various fixes in {dh,dsa}_priv_encode()
authortb <tb@openbsd.org>
Thu, 10 Aug 2023 09:43:51 +0000 (09:43 +0000)
committertb <tb@openbsd.org>
Thu, 10 Aug 2023 09:43:51 +0000 (09:43 +0000)
commitd46624175283f46a1ac475a3696b25e035298657
tree66dc1e8ab3100e55ea9df4a07a59998dcfac8df1
parente4c1e59cffd82e818709a41b0b9b9fa7d92ee41d
Various fixes in {dh,dsa}_priv_encode()

Avoid creating an ASN1_STRING with negative length, set type, data
and length via ASN1_STRING_type_new() and ASN1_STRING_set0() instead
of doing this manually. Check return value for i2d_ASN1_INTEGER()
and use an intermediate ASN1_OBJECT instead of nested function calls.
Finally, clear sensitive data with freezero().

ok jsing
lib/libcrypto/dh/dh_ameth.c
lib/libcrypto/dsa/dsa_ameth.c