1 .\" $OpenBSD: EVP_DigestSignInit.3,v 1.3 2016/11/26 17:38:55 schwarze Exp $
2 .\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400
4 .\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5 .\" Copyright (c) 2006, 2009, 2015, 2016 The OpenSSL Project.
6 .\" All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
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
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/)"
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.
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.
34 .\" 6. Redistributions of any form whatsoever must retain the following
36 .\" "This product includes software developed by the OpenSSL Project
37 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
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.
52 .Dd $Mdocdate: November 26 2016 $
53 .Dt EVP_DIGESTSIGNINIT 3
56 .Nm EVP_DigestSignInit ,
57 .Nm EVP_DigestSignUpdate ,
58 .Nm EVP_DigestSignFinal
59 .Nd EVP signing functions
63 .Fo EVP_DigestSignInit
65 .Fa "EVP_PKEY_CTX **pctx"
66 .Fa "const EVP_MD *type"
71 .Fo EVP_DigestSignUpdate
77 .Fo EVP_DigestSignFinal
79 .Fa "unsigned char *sig"
83 The EVP signature routines are a high level interface to digital
86 .Fn EVP_DigestSignInit
87 sets up the signing context
97 must be initialized with
99 before calling this function.
106 of the signing operation will be written to
108 this can be used to set alternative signing options.
110 .Fn EVP_DigestSignUpdate
115 into the signature context
117 This function can be called several times on the same
119 to include additional data.
120 This function is currently implemented using a macro.
122 .Fn EVP_DigestSignFinal
125 and places the signature in
131 then the maximum size of the output buffer is written to
139 should contain the length of the
142 If the call is successful, the signature is written to
144 and the amount of data written to
147 The EVP interface to digital signatures should almost always be
148 used in preference to the low level interfaces.
149 This is because the code then becomes transparent to the algorithm used
150 and much more flexible.
152 In previous versions of OpenSSL, there was a link between message digest
153 types and public key algorithms.
154 This meant that "clone" digests such as
156 needed to be used to sign using SHA1 and DSA.
157 This is no longer necessary and the use of clone digest is now
161 .Fn EVP_DigestSignFinal
162 internally finalizes a copy of the digest context.
164 .Fn EVP_DigestSignUpdate
166 .Fn EVP_DigestSignFinal
167 can be called later to digest and sign additional data.
169 Since only a copy of the digest context is ever finalized, the context
170 must be cleaned up after use by calling
171 .Xr EVP_MD_CTX_cleanup 3 ,
172 or a memory leak will occur.
176 with these functions is discouraged because some signature operations
177 may have a signature length which depends on the parameters set.
180 would have to return a value which indicates the maximum possible
181 signature for any set of parameters.
183 .Fn EVP_DigestSignInit ,
184 .Fn EVP_DigestSignUpdate ,
186 .Fn EVP_DigestSignFinal
187 return 1 for success and 0 or a negative value for failure.
188 In particular, a return value of -2 indicates the operation is not
189 supported by the public key algorithm.
191 The error codes can be obtained from
192 .Xr ERR_get_error 3 .
196 .Xr EVP_DigestInit 3 ,
197 .Xr EVP_DigestVerifyInit 3
199 .Fn EVP_DigestSignInit ,
200 .Fn EVP_DigestSignUpdate ,
202 .Fn EVP_DigestSignFinal
203 were first added to OpenSSL 1.0.0.