import libcrypto (LibreSSL 2.5.2)
[unleashed.git] / lib / libcrypto / man / X509_sign.3
blob2680f0b0950b84879b48aa00766c72f44af3b4a8
1 .\"     $OpenBSD: X509_sign.3,v 1.1 2016/12/05 18:24:08 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) 2015, 2016 The OpenSSL Project.  All rights reserved.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\"
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\"
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\"    notice, this list of conditions and the following disclaimer in
16 .\"    the documentation and/or other materials provided with the
17 .\"    distribution.
18 .\"
19 .\" 3. All advertising materials mentioning features or use of this
20 .\"    software must display the following acknowledgment:
21 .\"    "This product includes software developed by the OpenSSL Project
22 .\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23 .\"
24 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25 .\"    endorse or promote products derived from this software without
26 .\"    prior written permission. For written permission, please contact
27 .\"    openssl-core@openssl.org.
28 .\"
29 .\" 5. Products derived from this software may not be called "OpenSSL"
30 .\"    nor may "OpenSSL" appear in their names without prior written
31 .\"    permission of the OpenSSL Project.
32 .\"
33 .\" 6. Redistributions of any form whatsoever must retain the following
34 .\"    acknowledgment:
35 .\"    "This product includes software developed by the OpenSSL Project
36 .\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37 .\"
38 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
42 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
50 .\"
51 .Dd $Mdocdate: December 5 2016 $
52 .Dt X509_SIGN 3
53 .Os
54 .Sh NAME
55 .Nm X509_sign ,
56 .Nm X509_sign_ctx ,
57 .Nm X509_verify ,
58 .Nm X509_REQ_sign ,
59 .Nm X509_REQ_sign_ctx ,
60 .Nm X509_REQ_verify ,
61 .Nm X509_CRL_sign ,
62 .Nm X509_CRL_sign_ctx ,
63 .Nm X509_CRL_verify
64 .Nd sign or verify certificate, certificate request, or CRL signature
65 .Sh SYNOPSIS
66 .In openssl/x509.h
67 .Ft int
68 .Fo X509_sign
69 .Fa "X509 *x"
70 .Fa "EVP_PKEY *pkey"
71 .Fa "const EVP_MD *md"
72 .Fc
73 .Ft int
74 .Fo X509_sign_ctx
75 .Fa "X509 *x"
76 .Fa "EVP_MD_CTX *ctx"
77 .Fc
78 .Ft int
79 .Fo X509_verify
80 .Fa "X509 *a"
81 .Fa "EVP_PKEY *r"
82 .Fc
83 .Ft int
84 .Fo X509_REQ_sign
85 .Fa "X509_REQ *x"
86 .Fa "EVP_PKEY *pkey"
87 .Fa "const EVP_MD *md"
88 .Fc
89 .Ft int
90 .Fo X509_REQ_sign_ctx
91 .Fa "X509_REQ *x"
92 .Fa "EVP_MD_CTX *ctx"
93 .Fc
94 .Ft int
95 .Fo X509_REQ_verify
96 .Fa "X509_REQ *a"
97 .Fa "EVP_PKEY *r"
98 .Fc
99 .Ft int
100 .Fo X509_CRL_sign
101 .Fa "X509_CRL *x"
102 .Fa "EVP_PKEY *pkey"
103 .Fa "const EVP_MD *md"
105 .Ft int
106 .Fo X509_CRL_sign_ctx
107 .Fa "X509_CRL *x"
108 .Fa "EVP_MD_CTX *ctx"
110 .Ft int
111 .Fo X509_CRL_verify
112 .Fa "X509_CRL *a"
113 .Fa "EVP_PKEY *r"
115 .Sh DESCRIPTION
116 .Fn X509_sign
117 signs the certificate
118 .Fa x
119 using the private key
120 .Fa pkey
121 and the message digest
122 .Fa md
123 and sets the signature in
124 .Fa x .
125 .Fn X509_sign_ctx
126 also signs the certificate
127 .Fa x
128 but uses the parameters contained in digest context
129 .Fa ctx .
131 .Fn X509_verify
132 verifies the signature of certificate
133 .Fa x
134 using the public key
135 .Fa pkey .
136 Only the signature is checked: no other checks (such as certificate
137 chain validity) are performed.
139 .Fn X509_REQ_sign ,
140 .Fn X509_REQ_sign_ctx ,
141 .Fn X509_REQ_verify ,
142 .Fn X509_CRL_sign ,
143 .Fn X509_CRL_sign_ctx ,
145 .Fn X509_CRL_verify
146 sign and verify certificate requests and CRLs, respectively.
148 .Fn X509_sign_ctx
149 is used where the default parameters for the corresponding public key
150 and digest are not suitable.
151 It can be used to sign keys using RSA-PSS for example.
153 For efficiency reasons and to work around ASN.1 encoding issues, the
154 encoding of the signed portion of a certificate, certificate request,
155 and CRL is cached internally.
156 If the signed portion of the structure is modified, the encoding is not
157 always updated, meaning a stale version is sometimes used.
158 This is not normally a problem because modifying the signed portion will
159 invalidate the signature and signing will always update the encoding.
160 .Sh RETURN VALUES
161 .Fn X509_sign ,
162 .Fn X509_sign_ctx ,
163 .Fn X509_REQ_sign ,
164 .Fn X509_REQ_sign_ctx ,
165 .Fn X509_CRL_sign ,
167 .Fn X509_CRL_sign_ctx
168 return the size of the signature in bytes for success or 0 for failure.
170 .Fn X509_verify ,
171 .Fn X509_REQ_verify ,
173 .Fn X509_CRL_verify
174 return 1 if the signature is valid or 0 if the signature check fails.
175 If the signature could not be checked at all because it was invalid or
176 some other error occurred, then -1 is returned.
177 .Sh SEE ALSO
178 .Xr d2i_X509 3 ,
179 .Xr ERR_get_error 3 ,
180 .Xr X509_CRL_get0_by_serial 3 ,
181 .Xr X509_get_pubkey 3 ,
182 .Xr X509_get_subject_name 3 ,
183 .Xr X509_get_version 3 ,
184 .Xr X509_NAME_add_entry_by_txt 3 ,
185 .Xr X509_NAME_ENTRY_get_object 3 ,
186 .Xr X509_NAME_get_index_by_NID 3 ,
187 .Xr X509_NAME_print_ex 3 ,
188 .Xr X509_new 3 ,
189 .Xr X509_verify_cert 3 ,
190 .Xr X509V3_get_d2i 3
191 .Sh HISTORY
192 .Fn X509_sign ,
193 .Fn X509_REQ_sign ,
195 .Fn X509_CRL_sign
196 are available in all versions of OpenSSL.
198 .Fn X509_sign_ctx ,
199 .Fn X509_REQ_sign_ctx ,
201 .Fn X509_CRL_sign_ctx
202 were first added to OpenSSL 1.0.1.