dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / lib / libcrypto / man / EVP_DigestSignInit.3
blob26a56cad2b33ea364ba13737b529134e8a3ebbae
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
3 .\"
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.
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: November 26 2016 $
53 .Dt EVP_DIGESTSIGNINIT 3
54 .Os
55 .Sh NAME
56 .Nm EVP_DigestSignInit ,
57 .Nm EVP_DigestSignUpdate ,
58 .Nm EVP_DigestSignFinal
59 .Nd EVP signing functions
60 .Sh SYNOPSIS
61 .In openssl/evp.h
62 .Ft int
63 .Fo EVP_DigestSignInit
64 .Fa "EVP_MD_CTX *ctx"
65 .Fa "EVP_PKEY_CTX **pctx"
66 .Fa "const EVP_MD *type"
67 .Fa "ENGINE *e"
68 .Fa "EVP_PKEY *pkey"
69 .Fc
70 .Ft int
71 .Fo EVP_DigestSignUpdate
72 .Fa "EVP_MD_CTX *ctx"
73 .Fa "const void *d"
74 .Fa "size_t cnt"
75 .Fc
76 .Ft int
77 .Fo EVP_DigestSignFinal
78 .Fa "EVP_MD_CTX *ctx"
79 .Fa "unsigned char *sig"
80 .Fa "size_t *siglen"
81 .Fc
82 .Sh DESCRIPTION
83 The EVP signature routines are a high level interface to digital
84 signatures.
85 .Pp
86 .Fn EVP_DigestSignInit
87 sets up the signing context
88 .Fa ctx
89 to use the digest
90 .Fa type
91 from
92 .Vt ENGINE
93 .Fa e
94 and private key
95 .Fa pkey .
96 .Fa ctx
97 must be initialized with
98 .Xr EVP_MD_CTX_init 3
99 before calling this function.
101 .Fa pctx
102 is not
103 .Dv NULL ,
105 .Vt EVP_PKEY_CTX
106 of the signing operation will be written to
107 .Pf * Fa pctx :
108 this can be used to set alternative signing options.
110 .Fn EVP_DigestSignUpdate
111 hashes
112 .Fa cnt
113 bytes of data at
114 .Fa d
115 into the signature context
116 .Fa ctx .
117 This function can be called several times on the same
118 .Fa ctx
119 to include additional data.
120 This function is currently implemented using a macro.
122 .Fn EVP_DigestSignFinal
123 signs the data in
124 .Fa ctx
125 and places the signature in
126 .Fa sig .
128 .Fa sig
130 .Dv NULL ,
131 then the maximum size of the output buffer is written to
132 .Pf * Fa siglen .
134 .Fa sig
135 is not
136 .Dv NULL ,
137 then before the call
138 .Fa siglen
139 should contain the length of the
140 .Fa sig
141 buffer.
142 If the call is successful, the signature is written to
143 .Fa sig
144 and the amount of data written to
145 .Fa siglen .
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
155 .Xr EVP_dss1 3
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
158 discouraged.
160 The call to
161 .Fn EVP_DigestSignFinal
162 internally finalizes a copy of the digest context.
163 This means that
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.
174 The use of
175 .Xr EVP_PKEY_size 3
176 with these functions is discouraged because some signature operations
177 may have a signature length which depends on the parameters set.
178 As a result,
179 .Xr EVP_PKEY_size 3
180 would have to return a value which indicates the maximum possible
181 signature for any set of parameters.
182 .Sh RETURN VALUES
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 .
193 .Sh SEE ALSO
194 .Xr ERR 3 ,
195 .Xr evp 3 ,
196 .Xr EVP_DigestInit 3 ,
197 .Xr EVP_DigestVerifyInit 3
198 .Sh HISTORY
199 .Fn EVP_DigestSignInit ,
200 .Fn EVP_DigestSignUpdate ,
202 .Fn EVP_DigestSignFinal
203 were first added to OpenSSL 1.0.0.