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
4 .\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5 .\" Copyright (c) 2015, 2016 The OpenSSL Project. All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
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
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/)"
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.
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.
33 .\" 6. Redistributions of any form whatsoever must retain the following
35 .\" "This product includes software developed by the OpenSSL Project
36 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
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.
51 .Dd $Mdocdate: December 5 2016 $
59 .Nm X509_REQ_sign_ctx ,
62 .Nm X509_CRL_sign_ctx ,
64 .Nd sign or verify certificate, certificate request, or CRL signature
71 .Fa "const EVP_MD *md"
87 .Fa "const EVP_MD *md"
103 .Fa "const EVP_MD *md"
106 .Fo X509_CRL_sign_ctx
108 .Fa "EVP_MD_CTX *ctx"
117 signs the certificate
119 using the private key
121 and the message digest
123 and sets the signature in
126 also signs the certificate
128 but uses the parameters contained in digest context
132 verifies the signature of certificate
136 Only the signature is checked: no other checks (such as certificate
137 chain validity) are performed.
140 .Fn X509_REQ_sign_ctx ,
141 .Fn X509_REQ_verify ,
143 .Fn X509_CRL_sign_ctx ,
146 sign and verify certificate requests and CRLs, respectively.
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.
164 .Fn X509_REQ_sign_ctx ,
167 .Fn X509_CRL_sign_ctx
168 return the size of the signature in bytes for success or 0 for failure.
171 .Fn X509_REQ_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.
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 ,
189 .Xr X509_verify_cert 3 ,
196 are available in all versions of OpenSSL.
199 .Fn X509_REQ_sign_ctx ,
201 .Fn X509_CRL_sign_ctx
202 were first added to OpenSSL 1.0.1.