diff options
Diffstat (limited to 'src/lib/libcrypto/man/EVP_PKEY_sign.3')
-rw-r--r-- | src/lib/libcrypto/man/EVP_PKEY_sign.3 | 190 |
1 files changed, 0 insertions, 190 deletions
diff --git a/src/lib/libcrypto/man/EVP_PKEY_sign.3 b/src/lib/libcrypto/man/EVP_PKEY_sign.3 deleted file mode 100644 index d73b0abb7b..0000000000 --- a/src/lib/libcrypto/man/EVP_PKEY_sign.3 +++ /dev/null | |||
@@ -1,190 +0,0 @@ | |||
1 | .\" $OpenBSD: EVP_PKEY_sign.3,v 1.9 2024/12/06 14:27:49 schwarze Exp $ | ||
2 | .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 | ||
3 | .\" | ||
4 | .\" This file was written by Dr. Stephen Henson <steve@openssl.org>. | ||
5 | .\" Copyright (c) 2006, 2009, 2013, 2014 The OpenSSL Project. | ||
6 | .\" All rights reserved. | ||
7 | .\" | ||
8 | .\" Redistribution and use in source and binary forms, with or without | ||
9 | .\" modification, are permitted provided that the following conditions | ||
10 | .\" are met: | ||
11 | .\" | ||
12 | .\" 1. Redistributions of source code must retain the above copyright | ||
13 | .\" notice, this list of conditions and the following disclaimer. | ||
14 | .\" | ||
15 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
16 | .\" notice, this list of conditions and the following disclaimer in | ||
17 | .\" the documentation and/or other materials provided with the | ||
18 | .\" distribution. | ||
19 | .\" | ||
20 | .\" 3. All advertising materials mentioning features or use of this | ||
21 | .\" software must display the following acknowledgment: | ||
22 | .\" "This product includes software developed by the OpenSSL Project | ||
23 | .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
24 | .\" | ||
25 | .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
26 | .\" endorse or promote products derived from this software without | ||
27 | .\" prior written permission. For written permission, please contact | ||
28 | .\" openssl-core@openssl.org. | ||
29 | .\" | ||
30 | .\" 5. Products derived from this software may not be called "OpenSSL" | ||
31 | .\" nor may "OpenSSL" appear in their names without prior written | ||
32 | .\" permission of the OpenSSL Project. | ||
33 | .\" | ||
34 | .\" 6. Redistributions of any form whatsoever must retain the following | ||
35 | .\" acknowledgment: | ||
36 | .\" "This product includes software developed by the OpenSSL Project | ||
37 | .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
38 | .\" | ||
39 | .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
40 | .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
41 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
42 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
43 | .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
44 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
45 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
46 | .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
47 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
48 | .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
49 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
50 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | ||
51 | .\" | ||
52 | .Dd $Mdocdate: December 6 2024 $ | ||
53 | .Dt EVP_PKEY_SIGN 3 | ||
54 | .Os | ||
55 | .Sh NAME | ||
56 | .Nm EVP_PKEY_sign_init , | ||
57 | .Nm EVP_PKEY_sign | ||
58 | .Nd sign using a public key algorithm | ||
59 | .Sh SYNOPSIS | ||
60 | .In openssl/evp.h | ||
61 | .Ft int | ||
62 | .Fo EVP_PKEY_sign_init | ||
63 | .Fa "EVP_PKEY_CTX *ctx" | ||
64 | .Fc | ||
65 | .Ft int | ||
66 | .Fo EVP_PKEY_sign | ||
67 | .Fa "EVP_PKEY_CTX *ctx" | ||
68 | .Fa "unsigned char *sig" | ||
69 | .Fa "size_t *siglen" | ||
70 | .Fa "const unsigned char *tbs" | ||
71 | .Fa "size_t tbslen" | ||
72 | .Fc | ||
73 | .Sh DESCRIPTION | ||
74 | The | ||
75 | .Fn EVP_PKEY_sign_init | ||
76 | function initializes a public key algorithm context using the key | ||
77 | .Fa ctx->pkey | ||
78 | for a signing operation. | ||
79 | .Pp | ||
80 | The | ||
81 | .Fn EVP_PKEY_sign | ||
82 | function performs a public key signing operation using | ||
83 | .Fa ctx . | ||
84 | The data to be signed is specified using the | ||
85 | .Fa tbs | ||
86 | and | ||
87 | .Fa tbslen | ||
88 | parameters. | ||
89 | If | ||
90 | .Fa sig | ||
91 | is | ||
92 | .Dv NULL , | ||
93 | then the maximum size of the output buffer is written to the | ||
94 | .Fa siglen | ||
95 | parameter. | ||
96 | If | ||
97 | .Fa sig | ||
98 | is not | ||
99 | .Dv NULL , | ||
100 | then before the call the | ||
101 | .Fa siglen | ||
102 | parameter should contain the length of the | ||
103 | .Fa sig | ||
104 | buffer. | ||
105 | If the call is successful, the signature is written to | ||
106 | .Fa sig | ||
107 | and the amount of data written to | ||
108 | .Fa siglen . | ||
109 | .Pp | ||
110 | .Fn EVP_PKEY_sign | ||
111 | does not hash the data to be signed, and therefore is normally used | ||
112 | to sign digests. | ||
113 | For signing arbitrary messages, see the | ||
114 | .Xr EVP_DigestSignInit 3 | ||
115 | and | ||
116 | .Xr EVP_SignInit 3 | ||
117 | signing interfaces instead. | ||
118 | .Pp | ||
119 | After the call to | ||
120 | .Fn EVP_PKEY_sign_init , | ||
121 | algorithm specific control operations can be performed to set any | ||
122 | appropriate parameters for the operation; see | ||
123 | .Xr EVP_PKEY_CTX_ctrl 3 . | ||
124 | .Pp | ||
125 | The function | ||
126 | .Fn EVP_PKEY_sign | ||
127 | can be called more than once on the same context if several operations | ||
128 | are performed using the same parameters. | ||
129 | .Sh RETURN VALUES | ||
130 | .Fn EVP_PKEY_sign_init | ||
131 | and | ||
132 | .Fn EVP_PKEY_sign | ||
133 | return 1 for success and 0 or a negative value for failure. | ||
134 | In particular, a return value of -2 indicates the operation is not | ||
135 | supported by the public key algorithm. | ||
136 | .Sh EXAMPLES | ||
137 | Sign data using RSA with PKCS#1 padding and SHA256 digest: | ||
138 | .Bd -literal -offset indent | ||
139 | #include <openssl/evp.h> | ||
140 | #include <openssl/rsa.h> | ||
141 | |||
142 | EVP_PKEY_CTX *ctx; | ||
143 | /* md is a SHA-256 digest in this example. */ | ||
144 | unsigned char *md, *sig; | ||
145 | size_t mdlen = 32, siglen; | ||
146 | EVP_PKEY *signing_key; | ||
147 | |||
148 | /* | ||
149 | * NB: assumes signing_key and md are set up before the next | ||
150 | * step. signing_key must be an RSA private key and md must | ||
151 | * point to the SHA-256 digest to be signed. | ||
152 | */ | ||
153 | ctx = EVP_PKEY_CTX_new(signing_key, NULL /* no engine */); | ||
154 | if (!ctx) | ||
155 | /* Error occurred */ | ||
156 | if (EVP_PKEY_sign_init(ctx) <= 0) | ||
157 | /* Error */ | ||
158 | if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0) | ||
159 | /* Error */ | ||
160 | if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0) | ||
161 | /* Error */ | ||
162 | |||
163 | /* Determine buffer length */ | ||
164 | if (EVP_PKEY_sign(ctx, NULL, &siglen, md, mdlen) <= 0) | ||
165 | /* Error */ | ||
166 | |||
167 | sig = malloc(siglen); | ||
168 | |||
169 | if (!sig) | ||
170 | /* malloc failure */ | ||
171 | |||
172 | if (EVP_PKEY_sign(ctx, sig, &siglen, md, mdlen) <= 0) | ||
173 | /* Error */ | ||
174 | |||
175 | /* Signature is siglen bytes written to buffer sig */ | ||
176 | .Ed | ||
177 | .Sh SEE ALSO | ||
178 | .Xr EVP_PKEY_CTX_ctrl 3 , | ||
179 | .Xr EVP_PKEY_CTX_new 3 , | ||
180 | .Xr EVP_PKEY_decrypt 3 , | ||
181 | .Xr EVP_PKEY_derive 3 , | ||
182 | .Xr EVP_PKEY_encrypt 3 , | ||
183 | .Xr EVP_PKEY_verify 3 , | ||
184 | .Xr EVP_PKEY_verify_recover 3 | ||
185 | .Sh HISTORY | ||
186 | .Fn EVP_PKEY_sign_init | ||
187 | and | ||
188 | .Fn EVP_PKEY_sign | ||
189 | first appeared in OpenSSL 1.0.0 and have been available since | ||
190 | .Ox 4.9 . | ||