summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2023-10-09 16:03:57 +0000
committertb <>2023-10-09 16:03:57 +0000
commit54a81b9e7be0eccb2197e86698f8ed9a9000b046 (patch)
treeed572206365cdd923495da951c81dc4054218bbf /src
parent70724bb12c878f2cfe14beeac390e4f2867ba008 (diff)
downloadopenbsd-54a81b9e7be0eccb2197e86698f8ed9a9000b046.tar.gz
openbsd-54a81b9e7be0eccb2197e86698f8ed9a9000b046.tar.bz2
openbsd-54a81b9e7be0eccb2197e86698f8ed9a9000b046.zip
Clarify documentation of X509_ALGOR_{set0,set_md}()
The X509_ALGOR_set0() and X509_ALGOR_set_md() documentation comes from upstream, which means it is as sloppy as the code and as vague as your average upstream manpage. Be precise on what X509_ALGOR_set0() does on different inputs and document return values and failure modes. X509_ALGOR_set_md() is a void function that calls X509_ALGOR_set0() in a way that can fail, leaving alg in a corrupted state. Document when that can occur and how to avoid or detect that, but do not go too far, because EVP_MD_meth_new(), one potential source of failures, is a whole another can of worms. joint work with schwarze
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/man/X509_ALGOR_dup.352
1 files changed, 45 insertions, 7 deletions
diff --git a/src/lib/libcrypto/man/X509_ALGOR_dup.3 b/src/lib/libcrypto/man/X509_ALGOR_dup.3
index 2cfe36184d..f20aea768b 100644
--- a/src/lib/libcrypto/man/X509_ALGOR_dup.3
+++ b/src/lib/libcrypto/man/X509_ALGOR_dup.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_ALGOR_dup.3,v 1.16 2021/07/06 16:05:44 schwarze Exp $ 1.\" $OpenBSD: X509_ALGOR_dup.3,v 1.17 2023/10/09 16:03:57 tb Exp $
2.\" OpenSSL 4692340e Jun 7 15:49:08 2016 -0400 2.\" OpenSSL 4692340e Jun 7 15:49:08 2016 -0400
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,7 +65,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: July 6 2021 $ 68.Dd $Mdocdate: October 9 2023 $
69.Dt X509_ALGOR_DUP 3 69.Dt X509_ALGOR_DUP 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
@@ -147,8 +147,20 @@ with value
147If 147If
148.Fa ptype 148.Fa ptype
149is 149is
150.Dv V_ASN1_UNDEF ,
151the parameter is omitted and
152.Fa pval
153is ignored.
154If
155.Fa ptype
156is zero,
157.Fa pval
158is ignored and the existing parameter is left unchanged, or if
159.Fa alg
160does not contain a parameter, a new, empty parameter of type
150.Dv V_ASN1_UNDEF 161.Dv V_ASN1_UNDEF
151the parameter is omitted, otherwise 162is added.
163Otherwise
152.Fa ptype 164.Fa ptype
153and 165and
154.Fa pval 166.Fa pval
@@ -158,9 +170,13 @@ and
158.Fa value 170.Fa value
159parameters to 171parameters to
160.Xr ASN1_TYPE_set 3 . 172.Xr ASN1_TYPE_set 3 .
161All the supplied parameters are used internally so must 173Ownership of
162.Sy NOT 174.Fa aobj
163be freed after this call. 175and, unless it is ignored, of
176.Fa pval
177is transferred to
178.Fa alg
179on success.
164.Pp 180.Pp
165.Fn X509_ALGOR_get0 181.Fn X509_ALGOR_get0
166is the inverse of 182is the inverse of
@@ -179,6 +195,21 @@ sets
179.Fa alg 195.Fa alg
180to appropriate values for the message digest 196to appropriate values for the message digest
181.Fa md . 197.Fa md .
198If the
199.Dv EVP_MD_FLAG_DIGALGID_ABSENT
200flag is not set on
201.Fa md ,
202.Fn X509_ALGOR_set_md
203can leave
204.Fa alg
205in a corrupted state due to memory allocation failure.
206This problem can be avoided by preallocating with an error-checked call to
207.Fn X509_ALGOR_set0 alg NULL 0 NULL ,
208or the failure can be identified by
209.Fn X509_ALGOR_get0 &aobj NULL NULL alg
210returning a
211.Dv NULL
212.Fa aobj .
182.Pp 213.Pp
183.Fn X509_ALGOR_cmp 214.Fn X509_ALGOR_cmp
184compares 215compares
@@ -196,7 +227,11 @@ object or
196if an error occurs. 227if an error occurs.
197.Pp 228.Pp
198.Fn X509_ALGOR_set0 229.Fn X509_ALGOR_set0
199returns 1 for success or 0 for failure. 230returns 1 for success or 0 if
231.Fa alg
232is
233.Dv NULL
234or memory allocation fails.
200.Pp 235.Pp
201.Fn X509_ALGOR_cmp 236.Fn X509_ALGOR_cmp
202returns 0 if 237returns 0 if
@@ -240,3 +275,6 @@ and has been available since
240.Fn X509_ALGOR_set_md 275.Fn X509_ALGOR_set_md
241first appeared in OpenSSL 1.0.1 and has been available since 276first appeared in OpenSSL 1.0.1 and has been available since
242.Ox 5.3 . 277.Ox 5.3 .
278.Sh BUGS
279.Fn X509_ALGOR_set_md
280can fail but cannot communicate failure to the caller.