summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorschwarze <>2023-09-07 14:22:11 +0000
committerschwarze <>2023-09-07 14:22:11 +0000
commitac20bb42fcec4c75215a5bca5b62760f3476c869 (patch)
tree95e47c798b76d1bffba9f0c2b5167978aedf8509 /src/lib
parentc420d880d863c7e796d3b74a384e422cddc42734 (diff)
downloadopenbsd-ac20bb42fcec4c75215a5bca5b62760f3476c869.tar.gz
openbsd-ac20bb42fcec4c75215a5bca5b62760f3476c869.tar.bz2
openbsd-ac20bb42fcec4c75215a5bca5b62760f3476c869.zip
Split two new manual pages EVP_MD_nid(3) and EVP_MD_CTX_ctrl(3)
out of the large EVP_DigestInit(3). No text change.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/man/EVP_DigestInit.3319
-rw-r--r--src/lib/libcrypto/man/EVP_MD_CTX_ctrl.3274
-rw-r--r--src/lib/libcrypto/man/EVP_MD_nid.3213
-rw-r--r--src/lib/libcrypto/man/Makefile4
-rw-r--r--src/lib/libcrypto/man/evp.36
5 files changed, 501 insertions, 315 deletions
diff --git a/src/lib/libcrypto/man/EVP_DigestInit.3 b/src/lib/libcrypto/man/EVP_DigestInit.3
index 54cc771b10..562592b3c8 100644
--- a/src/lib/libcrypto/man/EVP_DigestInit.3
+++ b/src/lib/libcrypto/man/EVP_DigestInit.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_DigestInit.3,v 1.29 2023/08/27 15:33:08 schwarze Exp $ 1.\" $OpenBSD: EVP_DigestInit.3,v 1.30 2023/09/07 14:22:11 schwarze Exp $
2.\" full merge up to: OpenSSL 7f572e95 Dec 2 13:57:04 2015 +0000 2.\" full merge up to: OpenSSL 7f572e95 Dec 2 13:57:04 2015 +0000
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
@@ -70,7 +70,7 @@
70.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 70.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
71.\" OF THE POSSIBILITY OF SUCH DAMAGE. 71.\" OF THE POSSIBILITY OF SUCH DAMAGE.
72.\" 72.\"
73.Dd $Mdocdate: August 27 2023 $ 73.Dd $Mdocdate: September 7 2023 $
74.Dt EVP_DIGESTINIT 3 74.Dt EVP_DIGESTINIT 3
75.Os 75.Os
76.Sh NAME 76.Sh NAME
@@ -81,10 +81,6 @@
81.Nm EVP_MD_CTX_create , 81.Nm EVP_MD_CTX_create ,
82.Nm EVP_MD_CTX_cleanup , 82.Nm EVP_MD_CTX_cleanup ,
83.Nm EVP_MD_CTX_destroy , 83.Nm EVP_MD_CTX_destroy ,
84.Nm EVP_MD_CTX_ctrl ,
85.Nm EVP_MD_CTX_set_flags ,
86.Nm EVP_MD_CTX_clear_flags ,
87.Nm EVP_MD_CTX_test_flags ,
88.Nm EVP_DigestInit_ex , 84.Nm EVP_DigestInit_ex ,
89.Nm EVP_DigestUpdate , 85.Nm EVP_DigestUpdate ,
90.Nm EVP_DigestFinal_ex , 86.Nm EVP_DigestFinal_ex ,
@@ -94,18 +90,7 @@
94.Nm EVP_DigestFinal , 90.Nm EVP_DigestFinal ,
95.Nm EVP_MD_CTX_copy , 91.Nm EVP_MD_CTX_copy ,
96.Nm EVP_MAX_MD_SIZE , 92.Nm EVP_MAX_MD_SIZE ,
97.Nm EVP_MD_type ,
98.Nm EVP_MD_pkey_type ,
99.Nm EVP_MD_size ,
100.Nm EVP_MD_block_size ,
101.Nm EVP_MD_flags ,
102.Nm EVP_MD_CTX_md , 93.Nm EVP_MD_CTX_md ,
103.Nm EVP_MD_CTX_size ,
104.Nm EVP_MD_CTX_block_size ,
105.Nm EVP_MD_CTX_type ,
106.Nm EVP_MD_CTX_md_data ,
107.Nm EVP_MD_CTX_pkey_ctx ,
108.Nm EVP_MD_CTX_set_pkey_ctx ,
109.Nm EVP_md_null , 94.Nm EVP_md_null ,
110.Nm EVP_sha224 , 95.Nm EVP_sha224 ,
111.Nm EVP_sha256 , 96.Nm EVP_sha256 ,
@@ -145,28 +130,6 @@
145.Fa "EVP_MD_CTX *ctx" 130.Fa "EVP_MD_CTX *ctx"
146.Fc 131.Fc
147.Ft int 132.Ft int
148.Fo EVP_MD_CTX_ctrl
149.Fa "EVP_MD_CTX *ctx"
150.Fa "int command"
151.Fa "int p1"
152.Fa "void* p2"
153.Fc
154.Ft void
155.Fo EVP_MD_CTX_set_flags
156.Fa "EVP_MD_CTX *ctx"
157.Fa "int flags"
158.Fc
159.Ft void
160.Fo EVP_MD_CTX_clear_flags
161.Fa "EVP_MD_CTX *ctx"
162.Fa "int flags"
163.Fc
164.Ft int
165.Fo EVP_MD_CTX_test_flags
166.Fa "const EVP_MD_CTX *ctx"
167.Fa "int flags"
168.Fc
169.Ft int
170.Fo EVP_DigestInit_ex 133.Fo EVP_DigestInit_ex
171.Fa "EVP_MD_CTX *ctx" 134.Fa "EVP_MD_CTX *ctx"
172.Fa "const EVP_MD *type" 135.Fa "const EVP_MD *type"
@@ -215,55 +178,10 @@
215.Fa "EVP_MD_CTX *in" 178.Fa "EVP_MD_CTX *in"
216.Fc 179.Fc
217.Fd #define EVP_MAX_MD_SIZE 64 /* SHA512 */ 180.Fd #define EVP_MAX_MD_SIZE 64 /* SHA512 */
218.Ft int
219.Fo EVP_MD_type
220.Fa "const EVP_MD *md"
221.Fc
222.Ft int
223.Fo EVP_MD_pkey_type
224.Fa "const EVP_MD *md"
225.Fc
226.Ft int
227.Fo EVP_MD_size
228.Fa "const EVP_MD *md"
229.Fc
230.Ft int
231.Fo EVP_MD_block_size
232.Fa "const EVP_MD *md"
233.Fc
234.Ft unsigned long
235.Fo EVP_MD_flags
236.Fa "const EVP_MD *md"
237.Fc
238.Ft const EVP_MD * 181.Ft const EVP_MD *
239.Fo EVP_MD_CTX_md 182.Fo EVP_MD_CTX_md
240.Fa "const EVP_MD_CTX *ctx" 183.Fa "const EVP_MD_CTX *ctx"
241.Fc 184.Fc
242.Ft int
243.Fo EVP_MD_CTX_size
244.Fa "const EVP_MD_CTX *ctx"
245.Fc
246.Ft int
247.Fo EVP_MD_CTX_block_size
248.Fa "const EVP_MD_CTX *ctx"
249.Fc
250.Ft int
251.Fo EVP_MD_CTX_type
252.Fa "const EVP_MD_CTX *ctx"
253.Fc
254.Ft void *
255.Fo EVP_MD_CTX_md_data
256.Fa "const EVP_MD_CTX *ctx"
257.Fc
258.Ft EVP_PKEY_CTX *
259.Fo EVP_MD_CTX_pkey_ctx
260.Fa "const EVP_MD_CTX *ctx"
261.Fc
262.Ft void
263.Fo EVP_MD_CTX_set_pkey_ctx
264.Fa "EVP_MD_CTX *ctx"
265.Fa "EVP_PKEY_CTX *pctx"
266.Fc
267.Ft const EVP_MD * 185.Ft const EVP_MD *
268.Fn EVP_md_null void 186.Fn EVP_md_null void
269.Ft const EVP_MD * 187.Ft const EVP_MD *
@@ -329,70 +247,6 @@ and
329.Fn EVP_MD_CTX_free , 247.Fn EVP_MD_CTX_free ,
330respectively. 248respectively.
331.Pp 249.Pp
332.Fn EVP_MD_CTX_ctrl
333performs the digest-specific control
334.Fa command
335with the command-specific arguments
336.Fa p1
337and
338.Fa p2
339on
340.Fa ctx ,
341which needs to already be set up with
342.Fn EVP_DigestInit_ex
343before calling this function.
344Other restrictions may apply depending on the control
345.Fa command
346and digest implementation.
347.Pp
348If the
349.Fa command
350is
351.Dv EVP_MD_CTRL_MICALG ,
352.Fa p1
353is ignored and
354.Fa p2
355is an output argument of the type
356.Fa "char **p2" .
357A string specifying the digest Message Integrity Check algorithm
358is allocated and a pointer to this string is returned in
359.Pf * Fa p2 .
360It is the responsibility of the caller to
361.Xr free 3
362.Pf * Fa p2
363when it is no longer needed.
364This
365.Fa command
366is used by
367.Xr SMIME_write_ASN1 3
368when creating S/MIME multipart/signed messages as specified in RFC 3851.
369.Pp
370.Fn EVP_MD_CTX_set_flags
371sets and
372.Fn EVP_MD_CTX_clear_flags
373clears all the flag bits in
374.Fa ctx
375that are set in the
376.Fa flags
377argument.
378.Fn EVP_MD_CTX_test_flags
379tests which of the flag bits that are set in the
380.Fa flags
381argument are also set in
382.Fa ctx .
383Possible flag bits are:
384.Bl -tag -width Ds -offset 2n
385.It Dv EVP_MD_CTX_FLAG_NO_INIT
386Instruct
387.Fn EVP_DigestInit_ex
388and functions calling it not to initialise the internal data
389that is specific to the digest method and its implementation.
390.It Dv EVP_MD_CTX_FLAG_ONESHOT
391Instruct the digest to optimize for one update only, if possible.
392For digest algorithms built into the library, this flag usually
393has no effect.
394.El
395.Pp
396.Fn EVP_DigestInit_ex 250.Fn EVP_DigestInit_ex
397sets up the digest context 251sets up the digest context
398.Fa ctx 252.Fa ctx
@@ -505,111 +359,6 @@ except that it requires
505before a context that was already used can be passed as 359before a context that was already used can be passed as
506.Fa out . 360.Fa out .
507.Pp 361.Pp
508.Fn EVP_MD_size
509and
510.Fn EVP_MD_CTX_size
511return the size of the message digest when passed an
512.Vt EVP_MD
513or an
514.Vt EVP_MD_CTX
515structure, i.e. the size of the hash.
516.Pp
517.Fn EVP_MD_block_size
518and
519.Fn EVP_MD_CTX_block_size
520return the block size of the message digest when passed an
521.Vt EVP_MD
522or an
523.Vt EVP_MD_CTX
524structure.
525.Pp
526.Fn EVP_MD_type
527and
528.Fn EVP_MD_CTX_type
529return the NID of the OBJECT IDENTIFIER representing the message digest.
530For example
531.Fn EVP_MD_type EVP_sha512()
532returns
533.Dv NID_sha512 .
534These functions are normally used when setting ASN.1 OIDs.
535.Pp
536.Fn EVP_MD_CTX_md_data
537returns the digest method private data of
538.Fa ctx .
539The space was allocated and its size set with
540.Xr EVP_MD_meth_set_app_datasize 3 .
541.Pp
542.Fn EVP_MD_flags
543returns the
544.Fa md
545flags.
546These are different from the
547.Vt EVP_MD_CTX
548ones.
549See
550.Xr EVP_MD_meth_set_flags 3
551for more information.
552.Pp
553.Fn EVP_MD_pkey_type
554returns the NID of the public key signing algorithm associated with this
555digest.
556For example
557.Fn EVP_sha512
558is associated with RSA so this will return
559.Dv NID_sha512WithRSAEncryption .
560Since digests and signature algorithms are no longer linked, this
561function is only retained for compatibility reasons.
562.Pp
563.Fn EVP_MD_CTX_pkey_ctx
564returns the
565.Vt EVP_PKEY_CTX
566assigned to
567.Fa ctx .
568The returned pointer should not be freed by the caller.
569.Pp
570.Fn EVP_MD_CTX_set_pkey_ctx
571assigns
572.Fa pctx
573to
574.Fa ctx .
575This is normally used to provide a customized
576.Vt EVP_PKEY_CTX
577to
578.Xr EVP_DigestSignInit 3
579or
580.Xr EVP_DigestVerifyInit 3 .
581The caller retains ownership of the
582.Fa pctx
583passed to this function and is responsible for freeing it
584when it is no longer needed.
585.Pp
586If the
587.Fa ctx
588already contains a
589.Vt EVP_PKEY_CTX
590when this function is called, that old
591.Vt EVP_PKEY_CTX
592is freed if it was created internally, but if it was also installed with
593.Fn EVP_MD_CTX_set_pkey_ctx ,
594the pointer to the old
595.Vt EVP_PKEY_CTX
596is merely replaced by the new pointer and ownership of the old
597.Vt EVP_PKEY_CTX
598remains with the previous caller.
599.Pp
600Passing a
601.Dv NULL
602pointer for the
603.Fa pctx
604argument is also allowed.
605In that case, any
606.Vt EVP_PKEY_CTX
607already assigned to
608.Fa ctx
609is dissociated from it as described above, but no new
610.Vt EVP_PKEY_CTX
611is assigned.
612.Pp
613.Fn EVP_sha224 , 362.Fn EVP_sha224 ,
614.Fn EVP_sha256 , 363.Fn EVP_sha256 ,
615.Fn EVP_sha384 , 364.Fn EVP_sha384 ,
@@ -642,10 +391,7 @@ return an
642structure when passed a digest name, a digest NID, or an ASN1_OBJECT 391structure when passed a digest name, a digest NID, or an ASN1_OBJECT
643structure respectively. 392structure respectively.
644.Pp 393.Pp
645.Fn EVP_MD_CTX_size , 394.Fn EVP_get_digestbynid
646.Fn EVP_MD_CTX_block_size ,
647.Fn EVP_MD_CTX_type ,
648.Fn EVP_get_digestbynid ,
649and 395and
650.Fn EVP_get_digestbyobj 396.Fn EVP_get_digestbyobj
651are implemented as macros. 397are implemented as macros.
@@ -693,7 +439,6 @@ and
693.Fn EVP_MD_CTX_cleanup 439.Fn EVP_MD_CTX_cleanup
694always return 1. 440always return 1.
695.Pp 441.Pp
696.Fn EVP_MD_CTX_ctrl ,
697.Fn EVP_DigestInit_ex , 442.Fn EVP_DigestInit_ex ,
698.Fn EVP_DigestUpdate , 443.Fn EVP_DigestUpdate ,
699.Fn EVP_DigestFinal_ex , 444.Fn EVP_DigestFinal_ex ,
@@ -705,27 +450,6 @@ and
705.Fn EVP_MD_CTX_copy 450.Fn EVP_MD_CTX_copy
706return 1 for success or 0 for failure. 451return 1 for success or 0 for failure.
707.Pp 452.Pp
708.Fn EVP_MD_CTX_test_flags
709returns the bitwise OR of the
710.Fa flags
711argument and the flags set in
712.Fa ctx .
713.Pp
714.Fn EVP_MD_type ,
715.Fn EVP_MD_pkey_type ,
716and
717.Fn EVP_MD_CTX_type
718return the NID of the corresponding OBJECT IDENTIFIER or
719.Dv NID_undef
720if none exists.
721.Pp
722.Fn EVP_MD_size ,
723.Fn EVP_MD_block_size ,
724.Fn EVP_MD_CTX_size ,
725and
726.Fn EVP_MD_CTX_block_size
727return the digest or block size in bytes.
728.Pp
729.Fn EVP_MD_CTX_md 453.Fn EVP_MD_CTX_md
730returns the 454returns the
731.Vt EVP_MD 455.Vt EVP_MD
@@ -805,7 +529,9 @@ main(int argc, char *argv[])
805.Xr EVP_BytesToKey 3 , 529.Xr EVP_BytesToKey 3 ,
806.Xr EVP_DigestSignInit 3 , 530.Xr EVP_DigestSignInit 3 ,
807.Xr EVP_DigestVerifyInit 3 , 531.Xr EVP_DigestVerifyInit 3 ,
532.Xr EVP_MD_CTX_ctrl 3 ,
808.Xr EVP_MD_meth_new 3 , 533.Xr EVP_MD_meth_new 3 ,
534.Xr EVP_MD_nid 3 ,
809.Xr EVP_PKEY_CTX_set_signature_md 3 , 535.Xr EVP_PKEY_CTX_set_signature_md 3 ,
810.Xr EVP_PKEY_meth_set_signctx 3 , 536.Xr EVP_PKEY_meth_set_signctx 3 ,
811.Xr EVP_sha1 3 , 537.Xr EVP_sha1 3 ,
@@ -829,24 +555,14 @@ main(int argc, char *argv[])
829and 555and
830.Dv EVP_MAX_MD_SIZE 556.Dv EVP_MAX_MD_SIZE
831first appeared in SSLeay 0.5.1. 557first appeared in SSLeay 0.5.1.
832.Fn EVP_MD_size 558.Fn EVP_md_null
833first appeared in SSLeay 0.6.6.
834.Fn EVP_MD_CTX_size ,
835.Fn EVP_MD_CTX_type ,
836.Fn EVP_md_null ,
837and 559and
838.Fn EVP_get_digestbyname 560.Fn EVP_get_digestbyname
839first appeared in SSLeay 0.8.0. 561first appeared in SSLeay 0.8.0.
840.Fn EVP_MD_type , 562.Fn EVP_get_digestbynid
841.Fn EVP_MD_pkey_type ,
842.Fn EVP_get_digestbynid ,
843and 563and
844.Fn EVP_get_digestbyobj 564.Fn EVP_get_digestbyobj
845first appeared in SSLeay 0.8.1. 565first appeared in SSLeay 0.8.1.
846.Fn EVP_MD_block_size ,
847.Fn EVP_MD_CTX_size ,
848.Fn EVP_MD_CTX_block_size ,
849and
850.Fn EVP_ripemd160 566.Fn EVP_ripemd160
851first appeared in SSLeay 0.9.0. 567first appeared in SSLeay 0.9.0.
852All these functions have been available since 568All these functions have been available since
@@ -864,9 +580,6 @@ first appeared in OpenSSL 0.9.5 and has been available since
864.Fn EVP_MD_CTX_create , 580.Fn EVP_MD_CTX_create ,
865.Fn EVP_MD_CTX_cleanup , 581.Fn EVP_MD_CTX_cleanup ,
866.Fn EVP_MD_CTX_destroy , 582.Fn EVP_MD_CTX_destroy ,
867.Fn EVP_MD_CTX_set_flags ,
868.Fn EVP_MD_CTX_clear_flags ,
869.Fn EVP_MD_CTX_test_flags ,
870.Fn EVP_DigestInit_ex , 583.Fn EVP_DigestInit_ex ,
871.Fn EVP_DigestFinal_ex , 584.Fn EVP_DigestFinal_ex ,
872.Fn EVP_Digest , 585.Fn EVP_Digest ,
@@ -884,15 +597,6 @@ first appeared in OpenSSL 0.9.7h and 0.9.8a
884and have been available since 597and have been available since
885.Ox 4.0 . 598.Ox 4.0 .
886.Pp 599.Pp
887.Fn EVP_MD_flags
888first appeared in OpenSSL 1.0.0
889and has been available since
890.Ox 4.9 .
891.Pp
892.Fn EVP_MD_CTX_ctrl
893first appeared in OpenSSL 1.1.0 and has been available since
894.Ox 5.7 .
895.Pp
896.Fn EVP_MD_CTX_new , 600.Fn EVP_MD_CTX_new ,
897.Fn EVP_MD_CTX_reset , 601.Fn EVP_MD_CTX_reset ,
898and 602and
@@ -900,15 +604,6 @@ and
900first appeared in OpenSSL 1.1.0 and have been available since 604first appeared in OpenSSL 1.1.0 and have been available since
901.Ox 6.3 . 605.Ox 6.3 .
902.Pp 606.Pp
903.Fn EVP_MD_CTX_md_data
904and
905.Fn EVP_MD_CTX_pkey_ctx
906first appeared in OpenSSL 1.1.0 and
907.Fn EVP_MD_CTX_set_pkey_ctx
908in OpenSSL 1.1.1.
909These functions have been available since
910.Ox 7.1 .
911.Pp
912.Fn EVP_sha512_224 607.Fn EVP_sha512_224
913and 608and
914.Fn EVP_sha512_256 609.Fn EVP_sha512_256
diff --git a/src/lib/libcrypto/man/EVP_MD_CTX_ctrl.3 b/src/lib/libcrypto/man/EVP_MD_CTX_ctrl.3
new file mode 100644
index 0000000000..8b6f8724fc
--- /dev/null
+++ b/src/lib/libcrypto/man/EVP_MD_CTX_ctrl.3
@@ -0,0 +1,274 @@
1.\" $OpenBSD: EVP_MD_CTX_ctrl.3,v 1.1 2023/09/07 14:22:11 schwarze Exp $
2.\" full merge up to: OpenSSL man3/EVP_DigestInit.pod
3.\" 24a535ea Sep 22 13:14:20 2020 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Richard Levitte <levitte@openssl.org>,
23.\" Todd Short <tshort@akamai.com>, Paul Yang <yang.yang@baishancloud.com>,
24.\" and Antoine Salon <asalon@vmware.com>.
25.\" Copyright (c) 2015, 2016, 2018, 2019 The OpenSSL Project.
26.\" All rights reserved.
27.\"
28.\" Redistribution and use in source and binary forms, with or without
29.\" modification, are permitted provided that the following conditions
30.\" are met:
31.\"
32.\" 1. Redistributions of source code must retain the above copyright
33.\" notice, this list of conditions and the following disclaimer.
34.\"
35.\" 2. Redistributions in binary form must reproduce the above copyright
36.\" notice, this list of conditions and the following disclaimer in
37.\" the documentation and/or other materials provided with the
38.\" distribution.
39.\"
40.\" 3. All advertising materials mentioning features or use of this
41.\" software must display the following acknowledgment:
42.\" "This product includes software developed by the OpenSSL Project
43.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
44.\"
45.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
46.\" endorse or promote products derived from this software without
47.\" prior written permission. For written permission, please contact
48.\" openssl-core@openssl.org.
49.\"
50.\" 5. Products derived from this software may not be called "OpenSSL"
51.\" nor may "OpenSSL" appear in their names without prior written
52.\" permission of the OpenSSL Project.
53.\"
54.\" 6. Redistributions of any form whatsoever must retain the following
55.\" acknowledgment:
56.\" "This product includes software developed by the OpenSSL Project
57.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
58.\"
59.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
60.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
62.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
63.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
64.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
65.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
66.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
68.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
70.\" OF THE POSSIBILITY OF SUCH DAMAGE.
71.\"
72.Dd $Mdocdate: September 7 2023 $
73.Dt EVP_MD_CTX_CTRL 3
74.Os
75.Sh NAME
76.Nm EVP_MD_CTX_ctrl ,
77.Nm EVP_MD_CTX_set_flags ,
78.Nm EVP_MD_CTX_clear_flags ,
79.Nm EVP_MD_CTX_test_flags ,
80.Nm EVP_MD_CTX_pkey_ctx ,
81.Nm EVP_MD_CTX_set_pkey_ctx ,
82.Nm EVP_MD_CTX_md_data
83.Nd configure EVP message digest contexts
84.Sh SYNOPSIS
85.In openssl/evp.h
86.Ft int
87.Fo EVP_MD_CTX_ctrl
88.Fa "EVP_MD_CTX *ctx"
89.Fa "int command"
90.Fa "int p1"
91.Fa "void* p2"
92.Fc
93.Ft void
94.Fo EVP_MD_CTX_set_flags
95.Fa "EVP_MD_CTX *ctx"
96.Fa "int flags"
97.Fc
98.Ft void
99.Fo EVP_MD_CTX_clear_flags
100.Fa "EVP_MD_CTX *ctx"
101.Fa "int flags"
102.Fc
103.Ft int
104.Fo EVP_MD_CTX_test_flags
105.Fa "const EVP_MD_CTX *ctx"
106.Fa "int flags"
107.Fc
108.Ft EVP_PKEY_CTX *
109.Fo EVP_MD_CTX_pkey_ctx
110.Fa "const EVP_MD_CTX *ctx"
111.Fc
112.Ft void
113.Fo EVP_MD_CTX_set_pkey_ctx
114.Fa "EVP_MD_CTX *ctx"
115.Fa "EVP_PKEY_CTX *pctx"
116.Fc
117.Ft void *
118.Fo EVP_MD_CTX_md_data
119.Fa "const EVP_MD_CTX *ctx"
120.Fc
121.Sh DESCRIPTION
122.Fn EVP_MD_CTX_ctrl
123performs the digest-specific control
124.Fa command
125with the command-specific arguments
126.Fa p1
127and
128.Fa p2
129on
130.Fa ctx ,
131which needs to already be set up with
132.Xr EVP_DigestInit_ex 3
133before calling this function.
134Other restrictions may apply depending on the control
135.Fa command
136and digest implementation.
137.Pp
138If the
139.Fa command
140is
141.Dv EVP_MD_CTRL_MICALG ,
142.Fa p1
143is ignored and
144.Fa p2
145is an output argument of the type
146.Fa "char **p2" .
147A string specifying the digest Message Integrity Check algorithm
148is allocated and a pointer to this string is returned in
149.Pf * Fa p2 .
150It is the responsibility of the caller to
151.Xr free 3
152.Pf * Fa p2
153when it is no longer needed.
154This
155.Fa command
156is used by
157.Xr SMIME_write_ASN1 3
158when creating S/MIME multipart/signed messages as specified in RFC 3851.
159.Pp
160.Fn EVP_MD_CTX_set_flags
161sets and
162.Fn EVP_MD_CTX_clear_flags
163clears all the flag bits in
164.Fa ctx
165that are set in the
166.Fa flags
167argument.
168.Fn EVP_MD_CTX_test_flags
169tests which of the flag bits that are set in the
170.Fa flags
171argument are also set in
172.Fa ctx .
173Possible flag bits are:
174.Bl -tag -width Ds -offset 2n
175.It Dv EVP_MD_CTX_FLAG_NO_INIT
176Instruct
177.Xr EVP_DigestInit_ex 3
178and functions calling it not to initialise the internal data
179that is specific to the digest method and its implementation.
180.It Dv EVP_MD_CTX_FLAG_ONESHOT
181Instruct the digest to optimize for one update only, if possible.
182For digest algorithms built into the library, this flag usually
183has no effect.
184.El
185.Pp
186.Fn EVP_MD_CTX_pkey_ctx
187returns the
188.Vt EVP_PKEY_CTX
189assigned to
190.Fa ctx .
191The returned pointer should not be freed by the caller.
192.Pp
193.Fn EVP_MD_CTX_set_pkey_ctx
194assigns
195.Fa pctx
196to
197.Fa ctx .
198This is normally used to provide a customized
199.Vt EVP_PKEY_CTX
200to
201.Xr EVP_DigestSignInit 3
202or
203.Xr EVP_DigestVerifyInit 3 .
204The caller retains ownership of the
205.Fa pctx
206passed to this function and is responsible for freeing it
207when it is no longer needed.
208.Pp
209If the
210.Fa ctx
211already contains a
212.Vt EVP_PKEY_CTX
213when this function is called, that old
214.Vt EVP_PKEY_CTX
215is freed if it was created internally, but if it was also installed with
216.Fn EVP_MD_CTX_set_pkey_ctx ,
217the pointer to the old
218.Vt EVP_PKEY_CTX
219is merely replaced by the new pointer and ownership of the old
220.Vt EVP_PKEY_CTX
221remains with the previous caller.
222.Pp
223Passing a
224.Dv NULL
225pointer for the
226.Fa pctx
227argument is also allowed.
228In that case, any
229.Vt EVP_PKEY_CTX
230already assigned to
231.Fa ctx
232is dissociated from it as described above, but no new
233.Vt EVP_PKEY_CTX
234is assigned.
235.Pp
236.Fn EVP_MD_CTX_md_data
237returns the digest method private data of
238.Fa ctx .
239The space was allocated and its size set with
240.Xr EVP_MD_meth_set_app_datasize 3 .
241.Sh RETURN VALUES
242.Fn EVP_MD_CTX_ctrl
243returns 1 for success or 0 for failure.
244.Pp
245.Fn EVP_MD_CTX_test_flags
246returns the bitwise OR of the
247.Fa flags
248argument and the flags set in
249.Fa ctx .
250.Sh SEE ALSO
251.Xr evp 3 ,
252.Xr EVP_DigestInit 3 ,
253.Xr EVP_MD_meth_new 3 ,
254.Xr EVP_MD_nid 3
255.Sh HISTORY
256.Fn EVP_MD_CTX_set_flags ,
257.Fn EVP_MD_CTX_clear_flags ,
258and
259.Fn EVP_MD_CTX_test_flags ,
260first appeared in OpenSSL 0.9.7 and have been available since
261.Ox 3.2 .
262.Pp
263.Fn EVP_MD_CTX_ctrl
264first appeared in OpenSSL 1.1.0 and has been available since
265.Ox 5.7 .
266.Pp
267.Fn EVP_MD_CTX_pkey_ctx
268and
269.Fn EVP_MD_CTX_md_data
270first appeared in OpenSSL 1.1.0 and
271.Fn EVP_MD_CTX_set_pkey_ctx
272in OpenSSL 1.1.1.
273These functions have been available since
274.Ox 7.1 .
diff --git a/src/lib/libcrypto/man/EVP_MD_nid.3 b/src/lib/libcrypto/man/EVP_MD_nid.3
new file mode 100644
index 0000000000..3083653590
--- /dev/null
+++ b/src/lib/libcrypto/man/EVP_MD_nid.3
@@ -0,0 +1,213 @@
1.\" $OpenBSD: EVP_MD_nid.3,v 1.1 2023/09/07 14:22:11 schwarze Exp $
2.\" full merge up to: OpenSSL man3/EVP_DigestInit.pod
3.\" 24a535ea Sep 22 13:14:20 2020 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>
23.\" and Antoine Salon <asalon@vmware.com>.
24.\" Copyright (c) 2000, 2012, 2019 The OpenSSL Project.
25.\" All rights reserved.
26.\"
27.\" Redistribution and use in source and binary forms, with or without
28.\" modification, are permitted provided that the following conditions
29.\" are met:
30.\"
31.\" 1. Redistributions of source code must retain the above copyright
32.\" notice, this list of conditions and the following disclaimer.
33.\"
34.\" 2. Redistributions in binary form must reproduce the above copyright
35.\" notice, this list of conditions and the following disclaimer in
36.\" the documentation and/or other materials provided with the
37.\" distribution.
38.\"
39.\" 3. All advertising materials mentioning features or use of this
40.\" software must display the following acknowledgment:
41.\" "This product includes software developed by the OpenSSL Project
42.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
43.\"
44.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
45.\" endorse or promote products derived from this software without
46.\" prior written permission. For written permission, please contact
47.\" openssl-core@openssl.org.
48.\"
49.\" 5. Products derived from this software may not be called "OpenSSL"
50.\" nor may "OpenSSL" appear in their names without prior written
51.\" permission of the OpenSSL Project.
52.\"
53.\" 6. Redistributions of any form whatsoever must retain the following
54.\" acknowledgment:
55.\" "This product includes software developed by the OpenSSL Project
56.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
57.\"
58.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
59.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
61.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
62.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
63.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
64.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
65.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
67.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
69.\" OF THE POSSIBILITY OF SUCH DAMAGE.
70.\"
71.Dd $Mdocdate: September 7 2023 $
72.Dt EVP_MD_TYPE 3
73.Os
74.Sh NAME
75.Nm EVP_MD_type ,
76.Nm EVP_MD_CTX_type ,
77.Nm EVP_MD_size ,
78.Nm EVP_MD_CTX_size ,
79.Nm EVP_MD_block_size ,
80.Nm EVP_MD_CTX_block_size ,
81.Nm EVP_MD_flags ,
82.Nm EVP_MD_pkey_type
83.Nd inspect EVP_MD objects
84.Sh SYNOPSIS
85.In openssl/evp.h
86.Ft int
87.Fo EVP_MD_type
88.Fa "const EVP_MD *md"
89.Fc
90.Ft int
91.Fo EVP_MD_CTX_type
92.Fa "const EVP_MD_CTX *ctx"
93.Fc
94.Ft int
95.Fo EVP_MD_size
96.Fa "const EVP_MD *md"
97.Fc
98.Ft int
99.Fo EVP_MD_CTX_size
100.Fa "const EVP_MD_CTX *ctx"
101.Fc
102.Ft int
103.Fo EVP_MD_block_size
104.Fa "const EVP_MD *md"
105.Fc
106.Ft int
107.Fo EVP_MD_CTX_block_size
108.Fa "const EVP_MD_CTX *ctx"
109.Fc
110.Ft unsigned long
111.Fo EVP_MD_flags
112.Fa "const EVP_MD *md"
113.Fc
114.Ft int
115.Fo EVP_MD_pkey_type
116.Fa "const EVP_MD *md"
117.Fc
118.Sh DESCRIPTION
119.Fn EVP_MD_type
120and
121.Fn EVP_MD_CTX_type
122return the NID of the OBJECT IDENTIFIER representing the message digest.
123For example
124.Fn EVP_MD_type EVP_sha512()
125returns
126.Dv NID_sha512 .
127These functions are normally used when setting ASN.1 OIDs.
128.Pp
129.Fn EVP_MD_size
130and
131.Fn EVP_MD_CTX_size
132return the size of the message digest when passed an
133.Vt EVP_MD
134or an
135.Vt EVP_MD_CTX
136structure, i.e. the size of the hash.
137.Pp
138.Fn EVP_MD_block_size
139and
140.Fn EVP_MD_CTX_block_size
141return the block size of the message digest when passed an
142.Vt EVP_MD
143or an
144.Vt EVP_MD_CTX
145structure.
146.Pp
147.Fn EVP_MD_flags
148returns the
149.Fa md
150flags.
151These are different from the
152.Vt EVP_MD_CTX
153ones.
154See
155.Xr EVP_MD_meth_set_flags 3
156for more information.
157.Pp
158.Fn EVP_MD_pkey_type
159returns the NID of the public key signing algorithm associated with this
160digest.
161For example
162.Fn EVP_sha512
163is associated with RSA so this will return
164.Dv NID_sha512WithRSAEncryption .
165Since digests and signature algorithms are no longer linked, this
166function is only retained for compatibility reasons.
167.Pp
168.Fn EVP_MD_CTX_size ,
169.Fn EVP_MD_CTX_block_size ,
170and
171.Fn EVP_MD_CTX_type
172are implemented as macros.
173.Sh RETURN VALUES
174.Fn EVP_MD_type ,
175.Fn EVP_MD_CTX_type ,
176and
177.Fn EVP_MD_pkey_type
178return the NID of the corresponding OBJECT IDENTIFIER or
179.Dv NID_undef
180if none exists.
181.Pp
182.Fn EVP_MD_size ,
183.Fn EVP_MD_CTX_size ,
184.Fn EVP_MD_block_size ,
185and
186.Fn EVP_MD_CTX_block_size
187return the digest or block size in bytes.
188.Sh SEE ALSO
189.Xr evp 3 ,
190.Xr EVP_DigestInit 3 ,
191.Xr EVP_MD_CTX_ctrl 3
192.Sh HISTORY
193.Fn EVP_MD_size
194first appeared in SSLeay 0.6.6,
195.Fn EVP_MD_CTX_size
196and
197.Fn EVP_MD_CTX_type
198in SSLeay 0.8.0,
199.Fn EVP_MD_type
200and
201.Fn EVP_MD_pkey_type
202in SSLeay 0.8.1, and
203.Fn EVP_MD_block_size
204and
205.Fn EVP_MD_CTX_block_size
206in SSLeay 0.9.0.
207All these functions have been available since
208.Ox 2.4 .
209.Pp
210.Fn EVP_MD_flags
211first appeared in OpenSSL 1.0.0
212and has been available since
213.Ox 4.9 .
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile
index 654a4f02a2..c7a79fa7b6 100644
--- a/src/lib/libcrypto/man/Makefile
+++ b/src/lib/libcrypto/man/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.266 2023/08/31 17:27:41 schwarze Exp $ 1# $OpenBSD: Makefile,v 1.267 2023/09/07 14:22:11 schwarze Exp $
2 2
3.include <bsd.own.mk> 3.include <bsd.own.mk>
4 4
@@ -175,7 +175,9 @@ MAN= \
175 EVP_DigestVerifyInit.3 \ 175 EVP_DigestVerifyInit.3 \
176 EVP_EncodeInit.3 \ 176 EVP_EncodeInit.3 \
177 EVP_EncryptInit.3 \ 177 EVP_EncryptInit.3 \
178 EVP_MD_CTX_ctrl.3 \
178 EVP_MD_meth_new.3 \ 179 EVP_MD_meth_new.3 \
180 EVP_MD_nid.3 \
179 EVP_OpenInit.3 \ 181 EVP_OpenInit.3 \
180 EVP_PKCS82PKEY.3 \ 182 EVP_PKCS82PKEY.3 \
181 EVP_PKEY_CTX_ctrl.3 \ 183 EVP_PKEY_CTX_ctrl.3 \
diff --git a/src/lib/libcrypto/man/evp.3 b/src/lib/libcrypto/man/evp.3
index d2b92ae6a5..2f2d07c7a7 100644
--- a/src/lib/libcrypto/man/evp.3
+++ b/src/lib/libcrypto/man/evp.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: evp.3,v 1.22 2023/08/31 17:27:41 schwarze Exp $ 1.\" $OpenBSD: evp.3,v 1.23 2023/09/07 14:22:11 schwarze Exp $
2.\" full merge up to: OpenSSL man7/evp 24a535ea Sep 22 13:14:20 2020 +0100 2.\" full merge up to: OpenSSL man7/evp 24a535ea Sep 22 13:14:20 2020 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>, 4.\" This file was written by Ulf Moeller <ulf@openssl.org>,
@@ -51,7 +51,7 @@
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE. 52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\" 53.\"
54.Dd $Mdocdate: August 31 2023 $ 54.Dd $Mdocdate: September 7 2023 $
55.Dt EVP 3 55.Dt EVP 3
56.Os 56.Os
57.Sh NAME 57.Sh NAME
@@ -211,7 +211,9 @@ operations are more efficient using the high-level interfaces.
211.Xr EVP_DigestVerifyInit 3 , 211.Xr EVP_DigestVerifyInit 3 ,
212.Xr EVP_EncodeInit 3 , 212.Xr EVP_EncodeInit 3 ,
213.Xr EVP_EncryptInit 3 , 213.Xr EVP_EncryptInit 3 ,
214.Xr EVP_MD_CTX_ctrl 3 ,
214.Xr EVP_MD_meth_new 3 , 215.Xr EVP_MD_meth_new 3 ,
216.Xr EVP_MD_nid 3 ,
215.Xr EVP_OpenInit 3 , 217.Xr EVP_OpenInit 3 ,
216.Xr EVP_PKCS82PKEY 3 , 218.Xr EVP_PKCS82PKEY 3 ,
217.Xr EVP_PKEY_add1_attr 3 , 219.Xr EVP_PKEY_add1_attr 3 ,