xref: /openbsd-src/lib/libcrypto/man/EVP_PKEY_get_default_digest_nid.3 (revision 957fef74ea2defb01661cfed78145e2e0965fa27)
1.\" $OpenBSD: EVP_PKEY_get_default_digest_nid.3,v 1.10 2024/12/06 12:51:13 schwarze Exp $
2.\" full merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2006, 2009, 2013, 2018 The OpenSSL Project.
23.\" All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\"    notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\"    notice, this list of conditions and the following disclaimer in
34.\"    the documentation and/or other materials provided with the
35.\"    distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\"    software must display the following acknowledgment:
39.\"    "This product includes software developed by the OpenSSL Project
40.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\"    endorse or promote products derived from this software without
44.\"    prior written permission. For written permission, please contact
45.\"    openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\"    nor may "OpenSSL" appear in their names without prior written
49.\"    permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\"    acknowledgment:
53.\"    "This product includes software developed by the OpenSSL Project
54.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: December 6 2024 $
70.Dt EVP_PKEY_GET_DEFAULT_DIGEST_NID 3
71.Os
72.Sh NAME
73.Nm EVP_PKEY_get_default_digest_nid
74.Nd get default signature digest
75.Sh SYNOPSIS
76.In openssl/evp.h
77.Ft int
78.Fo EVP_PKEY_get_default_digest_nid
79.Fa "EVP_PKEY *pkey"
80.Fa "int *pnid"
81.Fc
82.Sh DESCRIPTION
83The
84.Fn EVP_PKEY_get_default_digest_nid
85function sets
86.Pf * Fa pnid
87to the default message digest NID for the public key signature
88operations associated with
89.Fa pkey .
90.Pp
91Some signature algorithms, for example
92.Dv EVP_PKEY_ED25519 ,
93do not use a digest during signing.
94In this case,
95.Pf * Fa pnid
96is set to
97.Dv NID_undef .
98.Pp
99Support for the following public key algorithms is built into the library:
100.Pp
101.Bl -column -compact EVP_PKEY_base_id(3) NID_sha256 mandatory
102.It Xr EVP_PKEY_base_id 3 Ta Pf * Fa pnid               Ta return value
103.It Dv EVP_PKEY_DSA       Ta Dv NID_sha1                Ta mandatory
104.It Dv EVP_PKEY_EC        Ta Dv NID_sha1                Ta mandatory
105.It Dv EVP_PKEY_ED25519   Ta Dv NID_undef               Ta mandatory
106.It Dv EVP_PKEY_HMAC      Ta Dv NID_sha1                Ta advisory
107.It Dv EVP_PKEY_RSA       Ta Dv NID_sha256              Ta advisory
108.El
109.Sh RETURN VALUES
110The
111.Fn EVP_PKEY_get_default_digest_nid
112function returns 1 if the message digest is advisory (that is other
113digests can be used) and 2 if it is mandatory (other digests cannot be
114used).
115It returns 0 or a negative value for failure.
116In particular, a return value of -2 indicates the operation is not
117supported by the public key algorithm.
118.Sh SEE ALSO
119.Xr EVP_PKEY_CTX_ctrl 3 ,
120.Xr EVP_PKEY_CTX_new 3 ,
121.Xr EVP_PKEY_new 3 ,
122.Xr EVP_PKEY_sign 3 ,
123.Xr EVP_PKEY_verify 3 ,
124.Xr EVP_PKEY_verify_recover 3
125.Sh HISTORY
126.Fn EVP_PKEY_get_default_digest_nid
127first appeared in OpenSSL 1.0.0 and has been available since
128.Ox 4.9 .
129