Debian Codegraph @

upstream/debian-unstable/man3/EVP_PKEY_verify_recover.3ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "EVP_PKEY_VERIFY_RECOVER 3SSL"
58 .TH EVP_PKEY_VERIFY_RECOVER 3SSL 2026-04-07 3.6.2 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 EVP_PKEY_verify_recover_init, EVP_PKEY_verify_recover_init_ex,
65 EVP_PKEY_verify_recover_init_ex2, EVP_PKEY_verify_recover
66 \&\- recover signature using a public key algorithm
67 .SH SYNOPSIS
68 .IX Header "SYNOPSIS"
69 .Vb 1
70 \& #include <openssl/evp.h>
71 \&
72 \& int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx);
73 \& int EVP_PKEY_verify_recover_init_ex(EVP_PKEY_CTX *ctx,
74 \& const OSSL_PARAM params[]);
75 \& int EVP_PKEY_verify_recover_init_ex2(EVP_PKEY_CTX *ctx, EVP_SIGNATURE *algo,
76 \& const OSSL_PARAM params[]);
77 \& int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,
78 \& unsigned char *rout, size_t *routlen,
79 \& const unsigned char *sig, size_t siglen);
80 .Ve
81 .SH DESCRIPTION
82 .IX Header "DESCRIPTION"
83 \&\fBEVP_PKEY_verify_recover_init()\fR initializes a public key algorithm context
84 \&\fIctx\fR for signing using the algorithm given when the context was created
85 using \fBEVP_PKEY_CTX_new\fR\|(3) or variants thereof. The algorithm is used to
86 fetch a \fBEVP_SIGNATURE\fR method implicitly, see "Implicit fetch" in \fBprovider\fR\|(7)
87 for more information about implicit fetches.
88 .PP
89 \&\fBEVP_PKEY_verify_recover_init_ex()\fR is the same as
90 \&\fBEVP_PKEY_verify_recover_init()\fR but additionally sets the passed parameters
91 \&\fIparams\fR on the context before returning.
92 .PP
93 \&\fBEVP_PKEY_verify_recover_init_ex2()\fR is the same as \fBEVP_PKEY_verify_recover_init_ex()\fR,
94 but works with an explicitly fetched \fBEVP_SIGNATURE\fR \fIalgo\fR.
95 A context \fIctx\fR without a pre-loaded key cannot be used with this function.
96 Depending on what algorithm was fetched, certain details revolving around the
97 treatment of the input to \fBEVP_PKEY_verify()\fR may be pre-determined, and in that
98 case, those details may normally not be changed.
99 See "NOTES" below for a deeper explanation.
100 .PP
101 The \fBEVP_PKEY_verify_recover()\fR function recovers signed data
102 using \fIctx\fR. The signature is specified using the \fIsig\fR and
103 \&\fIsiglen\fR parameters. If \fIrout\fR is NULL then the maximum size of the output
104 buffer is written to the \fIroutlen\fR parameter. If \fIrout\fR is not NULL then
105 before the call the \fIroutlen\fR parameter should contain the length of the
106 \&\fIrout\fR buffer, if the call is successful recovered data is written to
107 \&\fIrout\fR and the amount of data written to \fIroutlen\fR.
108 .SH NOTES
109 .IX Header "NOTES"
110 Normally an application is only interested in whether a signature verification
111 operation is successful in those cases the \fBEVP_verify()\fR function should be
112 used.
113 .PP
114 Sometimes however it is useful to obtain the data originally signed using a
115 signing operation. Only certain public key algorithms can recover a signature
116 in this way (for example RSA in PKCS padding mode).
117 .PP
118 After the call to \fBEVP_PKEY_verify_recover_init()\fR algorithm specific control
119 operations can be performed to set any appropriate parameters for the
120 operation.
121 .PP
122 After the call to \fBEVP_PKEY_verify_recover_init_ex2()\fR, algorithm specific control
123 operations may not be needed if the chosen algorithm implies that those controls
124 pre-set (and immutable).
125 .PP
126 The function \fBEVP_PKEY_verify_recover()\fR can be called more than once on the same
127 context if several operations are performed using the same parameters.
128 .SH "RETURN VALUES"
129 .IX Header "RETURN VALUES"
130 \&\fBEVP_PKEY_verify_recover_init()\fR and \fBEVP_PKEY_verify_recover()\fR return 1 for success
131 and 0 or a negative value for failure. In particular a return value of \-2
132 indicates the operation is not supported by the public key algorithm.
133 .SH EXAMPLES
134 .IX Header "EXAMPLES"
135 Recover digest originally signed using PKCS#1 and SHA256 digest:
136 .PP
137 .Vb 2
138 \& #include <openssl/evp.h>
139 \& #include <openssl/rsa.h>
140 \&
141 \& EVP_PKEY_CTX *ctx;
142 \& unsigned char *rout, *sig;
143 \& size_t routlen, siglen;
144 \& EVP_PKEY *verify_key;
145 \&
146 \& /*
147 \& * NB: assumes verify_key, sig and siglen are already set up
148 \& * and that verify_key is an RSA public key
149 \& */
150 \& ctx = EVP_PKEY_CTX_new(verify_key, NULL /* no engine */);
151 \& if (!ctx)
152 \& /* Error occurred */
153 \& if (EVP_PKEY_verify_recover_init(ctx) <= 0)
154 \& /* Error */
155 \& if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)
156 \& /* Error */
157 \& if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0)
158 \& /* Error */
159 \&
160 \& /* Determine buffer length */
161 \& if (EVP_PKEY_verify_recover(ctx, NULL, &routlen, sig, siglen) <= 0)
162 \& /* Error */
163 \&
164 \& rout = OPENSSL_malloc(routlen);
165 \&
166 \& if (!rout)
167 \& /* malloc failure */
168 \&
169 \& if (EVP_PKEY_verify_recover(ctx, rout, &routlen, sig, siglen) <= 0)
170 \& /* Error */
171 \&
172 \& /* Recovered data is routlen bytes written to buffer rout */
173 .Ve
174 .SH "SEE ALSO"
175 .IX Header "SEE ALSO"
176 \&\fBEVP_PKEY_CTX_new\fR\|(3),
177 \&\fBEVP_PKEY_encrypt\fR\|(3),
178 \&\fBEVP_PKEY_decrypt\fR\|(3),
179 \&\fBEVP_PKEY_sign\fR\|(3),
180 \&\fBEVP_PKEY_verify\fR\|(3),
181 \&\fBEVP_PKEY_derive\fR\|(3)
182 .SH HISTORY
183 .IX Header "HISTORY"
184 The \fBEVP_PKEY_verify_recover_init()\fR and \fBEVP_PKEY_verify_recover()\fR
185 functions were added in OpenSSL 1.0.0.
186 .PP
187 The \fBEVP_PKEY_verify_recover_init_ex()\fR function was added in OpenSSL 3.0.
188 .SH COPYRIGHT
189 .IX Header "COPYRIGHT"
190 Copyright 2013\-2024 The OpenSSL Project Authors. All Rights Reserved.
191 .PP
192 Licensed under the Apache License 2.0 (the "License"). You may not use
193 this file except in compliance with the License. You can obtain a copy
194 in the file LICENSE in the source distribution or at
195 <https://www.openssl.org/source/license.html>.