]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/lib/libcrypto/man/man3/EVP_DigestInit.3
MFV r358616:
[FreeBSD/FreeBSD.git] / secure / lib / libcrypto / man / man3 / EVP_DigestInit.3
1 .\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.39)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 .    ds C`
42 .    ds C'
43 'br\}
44 .\"
45 .\" Escape single quotes in literal strings from groff's Unicode transform.
46 .ie \n(.g .ds Aq \(aq
47 .el       .ds Aq '
48 .\"
49 .\" If the F register is >0, we'll generate index entries on stderr for
50 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51 .\" entries marked with X<> in POD.  Of course, you'll have to process the
52 .\" output yourself in some meaningful fashion.
53 .\"
54 .\" Avoid warning from groff about undefined register 'F'.
55 .de IX
56 ..
57 .nr rF 0
58 .if \n(.g .if rF .nr rF 1
59 .if (\n(rF:(\n(.g==0)) \{\
60 .    if \nF \{\
61 .        de IX
62 .        tm Index:\\$1\t\\n%\t"\\$2"
63 ..
64 .        if !\nF==2 \{\
65 .            nr % 0
66 .            nr F 2
67 .        \}
68 .    \}
69 .\}
70 .rr rF
71 .\"
72 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
73 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
74 .    \" fudge factors for nroff and troff
75 .if n \{\
76 .    ds #H 0
77 .    ds #V .8m
78 .    ds #F .3m
79 .    ds #[ \f1
80 .    ds #] \fP
81 .\}
82 .if t \{\
83 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
84 .    ds #V .6m
85 .    ds #F 0
86 .    ds #[ \&
87 .    ds #] \&
88 .\}
89 .    \" simple accents for nroff and troff
90 .if n \{\
91 .    ds ' \&
92 .    ds ` \&
93 .    ds ^ \&
94 .    ds , \&
95 .    ds ~ ~
96 .    ds /
97 .\}
98 .if t \{\
99 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
100 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
101 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
102 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
103 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
104 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
105 .\}
106 .    \" troff and (daisy-wheel) nroff accents
107 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
108 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
109 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
110 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
111 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
112 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
113 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
114 .ds ae a\h'-(\w'a'u*4/10)'e
115 .ds Ae A\h'-(\w'A'u*4/10)'E
116 .    \" corrections for vroff
117 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
118 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
119 .    \" for low resolution devices (crt and lpr)
120 .if \n(.H>23 .if \n(.V>19 \
121 \{\
122 .    ds : e
123 .    ds 8 ss
124 .    ds o a
125 .    ds d- d\h'-1'\(ga
126 .    ds D- D\h'-1'\(hy
127 .    ds th \o'bp'
128 .    ds Th \o'LP'
129 .    ds ae ae
130 .    ds Ae AE
131 .\}
132 .rm #[ #] #H #V #F C
133 .\" ========================================================================
134 .\"
135 .IX Title "EVP_DIGESTINIT 3"
136 .TH EVP_DIGESTINIT 3 "2019-09-10" "1.1.1d" "OpenSSL"
137 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
138 .\" way too many mistakes in technical documents.
139 .if n .ad l
140 .nh
141 .SH "NAME"
142 EVP_MD_CTX_new, EVP_MD_CTX_reset, EVP_MD_CTX_free, EVP_MD_CTX_copy_ex, EVP_MD_CTX_ctrl, EVP_MD_CTX_set_flags, EVP_MD_CTX_clear_flags, EVP_MD_CTX_test_flags, EVP_DigestInit_ex, EVP_DigestInit, EVP_DigestUpdate, EVP_DigestFinal_ex, EVP_DigestFinalXOF, EVP_DigestFinal, EVP_MD_CTX_copy, EVP_MD_type, EVP_MD_pkey_type, EVP_MD_size, EVP_MD_block_size, EVP_MD_CTX_md, EVP_MD_CTX_size, EVP_MD_CTX_block_size, EVP_MD_CTX_type, EVP_MD_CTX_md_data, EVP_md_null, EVP_get_digestbyname, EVP_get_digestbynid, EVP_get_digestbyobj, EVP_MD_CTX_set_pkey_ctx \- EVP digest routines
143 .SH "SYNOPSIS"
144 .IX Header "SYNOPSIS"
145 .Vb 1
146 \& #include <openssl/evp.h>
147 \&
148 \& EVP_MD_CTX *EVP_MD_CTX_new(void);
149 \& int EVP_MD_CTX_reset(EVP_MD_CTX *ctx);
150 \& void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
151 \& void EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void* p2);
152 \& void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);
153 \& void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);
154 \& int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags);
155 \&
156 \& int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
157 \& int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt);
158 \& int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s);
159 \& int EVP_DigestFinalXOF(EVP_MD_CTX *ctx, unsigned char *md, size_t len);
160 \&
161 \& int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in);
162 \&
163 \& int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
164 \& int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s);
165 \&
166 \& int EVP_MD_CTX_copy(EVP_MD_CTX *out, EVP_MD_CTX *in);
167 \&
168 \& int EVP_MD_type(const EVP_MD *md);
169 \& int EVP_MD_pkey_type(const EVP_MD *md);
170 \& int EVP_MD_size(const EVP_MD *md);
171 \& int EVP_MD_block_size(const EVP_MD *md);
172 \&
173 \& const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx);
174 \& int EVP_MD_CTX_size(const EVP_MD *ctx);
175 \& int EVP_MD_CTX_block_size(const EVP_MD *ctx);
176 \& int EVP_MD_CTX_type(const EVP_MD *ctx);
177 \& void *EVP_MD_CTX_md_data(const EVP_MD_CTX *ctx);
178 \&
179 \& const EVP_MD *EVP_md_null(void);
180 \&
181 \& const EVP_MD *EVP_get_digestbyname(const char *name);
182 \& const EVP_MD *EVP_get_digestbynid(int type);
183 \& const EVP_MD *EVP_get_digestbyobj(const ASN1_OBJECT *o);
184 \&
185 \& void EVP_MD_CTX_set_pkey_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pctx);
186 .Ve
187 .SH "DESCRIPTION"
188 .IX Header "DESCRIPTION"
189 The \s-1EVP\s0 digest routines are a high level interface to message digests,
190 and should be used instead of the cipher-specific functions.
191 .IP "\fBEVP_MD_CTX_new()\fR" 4
192 .IX Item "EVP_MD_CTX_new()"
193 Allocates and returns a digest context.
194 .IP "\fBEVP_MD_CTX_reset()\fR" 4
195 .IX Item "EVP_MD_CTX_reset()"
196 Resets the digest context \fBctx\fR.  This can be used to reuse an already
197 existing context.
198 .IP "\fBEVP_MD_CTX_free()\fR" 4
199 .IX Item "EVP_MD_CTX_free()"
200 Cleans up digest context \fBctx\fR and frees up the space allocated to it.
201 .IP "\fBEVP_MD_CTX_ctrl()\fR" 4
202 .IX Item "EVP_MD_CTX_ctrl()"
203 Performs digest-specific control actions on context \fBctx\fR.
204 .IP "\fBEVP_MD_CTX_set_flags()\fR, \fBEVP_MD_CTX_clear_flags()\fR, \fBEVP_MD_CTX_test_flags()\fR" 4
205 .IX Item "EVP_MD_CTX_set_flags(), EVP_MD_CTX_clear_flags(), EVP_MD_CTX_test_flags()"
206 Sets, clears and tests \fBctx\fR flags.  See \*(L"\s-1FLAGS\*(R"\s0 below for more information.
207 .IP "\fBEVP_DigestInit_ex()\fR" 4
208 .IX Item "EVP_DigestInit_ex()"
209 Sets up digest context \fBctx\fR to use a digest \fBtype\fR from \s-1ENGINE\s0 \fBimpl\fR.
210 \&\fBtype\fR will typically be supplied by a function such as \fBEVP_sha1()\fR.  If
211 \&\fBimpl\fR is \s-1NULL\s0 then the default implementation of digest \fBtype\fR is used.
212 .IP "\fBEVP_DigestUpdate()\fR" 4
213 .IX Item "EVP_DigestUpdate()"
214 Hashes \fBcnt\fR bytes of data at \fBd\fR into the digest context \fBctx\fR. This
215 function can be called several times on the same \fBctx\fR to hash additional
216 data.
217 .IP "\fBEVP_DigestFinal_ex()\fR" 4
218 .IX Item "EVP_DigestFinal_ex()"
219 Retrieves the digest value from \fBctx\fR and places it in \fBmd\fR. If the \fBs\fR
220 parameter is not \s-1NULL\s0 then the number of bytes of data written (i.e. the
221 length of the digest) will be written to the integer at \fBs\fR, at most
222 \&\fB\s-1EVP_MAX_MD_SIZE\s0\fR bytes will be written.  After calling \fBEVP_DigestFinal_ex()\fR
223 no additional calls to \fBEVP_DigestUpdate()\fR can be made, but
224 \&\fBEVP_DigestInit_ex()\fR can be called to initialize a new digest operation.
225 .IP "\fBEVP_DigestFinalXOF()\fR" 4
226 .IX Item "EVP_DigestFinalXOF()"
227 Interfaces to extendable-output functions, XOFs, such as \s-1SHAKE128\s0 and \s-1SHAKE256.\s0
228 It retrieves the digest value from \fBctx\fR and places it in \fBlen\fR\-sized <B>md.
229 After calling this function no additional calls to \fBEVP_DigestUpdate()\fR can be
230 made, but \fBEVP_DigestInit_ex()\fR can be called to initialize a new operation.
231 .IP "\fBEVP_MD_CTX_copy_ex()\fR" 4
232 .IX Item "EVP_MD_CTX_copy_ex()"
233 Can be used to copy the message digest state from \fBin\fR to \fBout\fR. This is
234 useful if large amounts of data are to be hashed which only differ in the last
235 few bytes.
236 .IP "\fBEVP_DigestInit()\fR" 4
237 .IX Item "EVP_DigestInit()"
238 Behaves in the same way as \fBEVP_DigestInit_ex()\fR except it always uses the
239 default digest implementation.
240 .IP "\fBEVP_DigestFinal()\fR" 4
241 .IX Item "EVP_DigestFinal()"
242 Similar to \fBEVP_DigestFinal_ex()\fR except the digest context \fBctx\fR is
243 automatically cleaned up.
244 .IP "\fBEVP_MD_CTX_copy()\fR" 4
245 .IX Item "EVP_MD_CTX_copy()"
246 Similar to \fBEVP_MD_CTX_copy_ex()\fR except the destination \fBout\fR does not have to
247 be initialized.
248 .IP "\fBEVP_MD_size()\fR, \fBEVP_MD_CTX_size()\fR" 4
249 .IX Item "EVP_MD_size(), EVP_MD_CTX_size()"
250 Return the size of the message digest when passed an \fB\s-1EVP_MD\s0\fR or an
251 \&\fB\s-1EVP_MD_CTX\s0\fR structure, i.e. the size of the hash.
252 .IP "\fBEVP_MD_block_size()\fR, \fBEVP_MD_CTX_block_size()\fR" 4
253 .IX Item "EVP_MD_block_size(), EVP_MD_CTX_block_size()"
254 Return the block size of the message digest when passed an \fB\s-1EVP_MD\s0\fR or an
255 \&\fB\s-1EVP_MD_CTX\s0\fR structure.
256 .IP "\fBEVP_MD_type()\fR, \fBEVP_MD_CTX_type()\fR" 4
257 .IX Item "EVP_MD_type(), EVP_MD_CTX_type()"
258 Return the \s-1NID\s0 of the \s-1OBJECT IDENTIFIER\s0 representing the given message digest
259 when passed an \fB\s-1EVP_MD\s0\fR structure.  For example, \f(CW\*(C`EVP_MD_type(EVP_sha1())\*(C'\fR
260 returns \fBNID_sha1\fR. This function is normally used when setting \s-1ASN1\s0 OIDs.
261 .IP "\fBEVP_MD_CTX_md_data()\fR" 4
262 .IX Item "EVP_MD_CTX_md_data()"
263 Return the digest method private data for the passed \fB\s-1EVP_MD_CTX\s0\fR.
264 The space is allocated by OpenSSL and has the size originally set with
265 \&\fBEVP_MD_meth_set_app_datasize()\fR.
266 .IP "\fBEVP_MD_CTX_md()\fR" 4
267 .IX Item "EVP_MD_CTX_md()"
268 Returns the \fB\s-1EVP_MD\s0\fR structure corresponding to the passed \fB\s-1EVP_MD_CTX\s0\fR.
269 .IP "\fBEVP_MD_pkey_type()\fR" 4
270 .IX Item "EVP_MD_pkey_type()"
271 Returns the \s-1NID\s0 of the public key signing algorithm associated with this
272 digest. For example \fBEVP_sha1()\fR is associated with \s-1RSA\s0 so this will return
273 \&\fBNID_sha1WithRSAEncryption\fR. Since digests and signature algorithms are no
274 longer linked this function is only retained for compatibility reasons.
275 .IP "\fBEVP_md_null()\fR" 4
276 .IX Item "EVP_md_null()"
277 A \*(L"null\*(R" message digest that does nothing: i.e. the hash it returns is of zero
278 length.
279 .IP "\fBEVP_get_digestbyname()\fR, \fBEVP_get_digestbynid()\fR, \fBEVP_get_digestbyobj()\fR" 4
280 .IX Item "EVP_get_digestbyname(), EVP_get_digestbynid(), EVP_get_digestbyobj()"
281 Returns an \fB\s-1EVP_MD\s0\fR structure when passed a digest name, a digest \fB\s-1NID\s0\fR or an
282 \&\fB\s-1ASN1_OBJECT\s0\fR structure respectively.
283 .IP "\fBEVP_MD_CTX_set_pkey_ctx()\fR" 4
284 .IX Item "EVP_MD_CTX_set_pkey_ctx()"
285 Assigns an \fB\s-1EVP_PKEY_CTX\s0\fR to \fB\s-1EVP_MD_CTX\s0\fR. This is usually used to provide
286 a customzied \fB\s-1EVP_PKEY_CTX\s0\fR to \fBEVP_DigestSignInit\fR\|(3) or
287 \&\fBEVP_DigestVerifyInit\fR\|(3). The \fBpctx\fR passed to this function should be freed
288 by the caller. A \s-1NULL\s0 \fBpctx\fR pointer is also allowed to clear the \fB\s-1EVP_PKEY_CTX\s0\fR
289 assigned to \fBctx\fR. In such case, freeing the cleared \fB\s-1EVP_PKEY_CTX\s0\fR or not
290 depends on how the \fB\s-1EVP_PKEY_CTX\s0\fR is created.
291 .SH "FLAGS"
292 .IX Header "FLAGS"
293 \&\fBEVP_MD_CTX_set_flags()\fR, \fBEVP_MD_CTX_clear_flags()\fR and \fBEVP_MD_CTX_test_flags()\fR
294 can be used the manipulate and test these \fB\s-1EVP_MD_CTX\s0\fR flags:
295 .IP "\s-1EVP_MD_CTX_FLAG_ONESHOT\s0" 4
296 .IX Item "EVP_MD_CTX_FLAG_ONESHOT"
297 This flag instructs the digest to optimize for one update only, if possible.
298 .IP "\s-1EVP_MD_CTX_FLAG_NO_INIT\s0" 4
299 .IX Item "EVP_MD_CTX_FLAG_NO_INIT"
300 This flag instructs \fBEVP_DigestInit()\fR and similar not to initialise the
301 implementation specific data.
302 .IP "\s-1EVP_MD_CTX_FLAG_FINALISE\s0" 4
303 .IX Item "EVP_MD_CTX_FLAG_FINALISE"
304 Some functions such as EVP_DigestSign only finalise copies of internal
305 contexts so additional data can be included after the finalisation call.
306 This is inefficient if this functionality is not required, and can be
307 disabled with this flag.
308 .SH "RETURN VALUES"
309 .IX Header "RETURN VALUES"
310 .IP "\fBEVP_DigestInit_ex()\fR, \fBEVP_DigestUpdate()\fR, \fBEVP_DigestFinal_ex()\fR" 4
311 .IX Item "EVP_DigestInit_ex(), EVP_DigestUpdate(), EVP_DigestFinal_ex()"
312 Returns 1 for
313 success and 0 for failure.
314 .IP "\fBEVP_MD_CTX_ctrl()\fR" 4
315 .IX Item "EVP_MD_CTX_ctrl()"
316 Returns 1 if successful or 0 for failure.
317 .IP "\fBEVP_MD_CTX_copy_ex()\fR" 4
318 .IX Item "EVP_MD_CTX_copy_ex()"
319 Returns 1 if successful or 0 for failure.
320 .IP "\fBEVP_MD_type()\fR, \fBEVP_MD_pkey_type()\fR, \fBEVP_MD_type()\fR" 4
321 .IX Item "EVP_MD_type(), EVP_MD_pkey_type(), EVP_MD_type()"
322 Returns the \s-1NID\s0 of the corresponding \s-1OBJECT IDENTIFIER\s0 or NID_undef if none
323 exists.
324 .IP "\fBEVP_MD_size()\fR, \fBEVP_MD_block_size()\fR, \fBEVP_MD_CTX_size()\fR, \fBEVP_MD_CTX_block_size()\fR" 4
325 .IX Item "EVP_MD_size(), EVP_MD_block_size(), EVP_MD_CTX_size(), EVP_MD_CTX_block_size()"
326 Returns the digest or block size in bytes.
327 .IP "\fBEVP_md_null()\fR" 4
328 .IX Item "EVP_md_null()"
329 Returns a pointer to the \fB\s-1EVP_MD\s0\fR structure of the \*(L"null\*(R" message digest.
330 .IP "\fBEVP_get_digestbyname()\fR, \fBEVP_get_digestbynid()\fR, \fBEVP_get_digestbyobj()\fR" 4
331 .IX Item "EVP_get_digestbyname(), EVP_get_digestbynid(), EVP_get_digestbyobj()"
332 Returns either an \fB\s-1EVP_MD\s0\fR structure or \s-1NULL\s0 if an error occurs.
333 .IP "\fBEVP_MD_CTX_set_pkey_ctx()\fR" 4
334 .IX Item "EVP_MD_CTX_set_pkey_ctx()"
335 This function has no return value.
336 .SH "NOTES"
337 .IX Header "NOTES"
338 The \fB\s-1EVP\s0\fR interface to message digests should almost always be used in
339 preference to the low level interfaces. This is because the code then becomes
340 transparent to the digest used and much more flexible.
341 .PP
342 New applications should use the \s-1SHA\-2\s0 (such as \fBEVP_sha256\fR\|(3)) or the \s-1SHA\-3\s0
343 digest algorithms (such as \fBEVP_sha3_512\fR\|(3)). The other digest algorithms
344 are still in common use.
345 .PP
346 For most applications the \fBimpl\fR parameter to \fBEVP_DigestInit_ex()\fR will be
347 set to \s-1NULL\s0 to use the default digest implementation.
348 .PP
349 The functions \fBEVP_DigestInit()\fR, \fBEVP_DigestFinal()\fR and \fBEVP_MD_CTX_copy()\fR are
350 obsolete but are retained to maintain compatibility with existing code. New
351 applications should use \fBEVP_DigestInit_ex()\fR, \fBEVP_DigestFinal_ex()\fR and
352 \&\fBEVP_MD_CTX_copy_ex()\fR because they can efficiently reuse a digest context
353 instead of initializing and cleaning it up on each call and allow non default
354 implementations of digests to be specified.
355 .PP
356 If digest contexts are not cleaned up after use,
357 memory leaks will occur.
358 .PP
359 \&\fBEVP_MD_CTX_size()\fR, \fBEVP_MD_CTX_block_size()\fR, \fBEVP_MD_CTX_type()\fR,
360 \&\fBEVP_get_digestbynid()\fR and \fBEVP_get_digestbyobj()\fR are defined as
361 macros.
362 .PP
363 \&\fBEVP_MD_CTX_ctrl()\fR sends commands to message digests for additional configuration
364 or control.
365 .SH "EXAMPLES"
366 .IX Header "EXAMPLES"
367 This example digests the data \*(L"Test Message\en\*(R" and \*(L"Hello World\en\*(R", using the
368 digest name passed on the command line.
369 .PP
370 .Vb 3
371 \& #include <stdio.h>
372 \& #include <string.h>
373 \& #include <openssl/evp.h>
374 \&
375 \& int main(int argc, char *argv[])
376 \& {
377 \&     EVP_MD_CTX *mdctx;
378 \&     const EVP_MD *md;
379 \&     char mess1[] = "Test Message\en";
380 \&     char mess2[] = "Hello World\en";
381 \&     unsigned char md_value[EVP_MAX_MD_SIZE];
382 \&     unsigned int md_len, i;
383 \&
384 \&     if (argv[1] == NULL) {
385 \&         printf("Usage: mdtest digestname\en");
386 \&         exit(1);
387 \&     }
388 \&
389 \&     md = EVP_get_digestbyname(argv[1]);
390 \&     if (md == NULL) {
391 \&         printf("Unknown message digest %s\en", argv[1]);
392 \&         exit(1);
393 \&     }
394 \&
395 \&     mdctx = EVP_MD_CTX_new();
396 \&     EVP_DigestInit_ex(mdctx, md, NULL);
397 \&     EVP_DigestUpdate(mdctx, mess1, strlen(mess1));
398 \&     EVP_DigestUpdate(mdctx, mess2, strlen(mess2));
399 \&     EVP_DigestFinal_ex(mdctx, md_value, &md_len);
400 \&     EVP_MD_CTX_free(mdctx);
401 \&
402 \&     printf("Digest is: ");
403 \&     for (i = 0; i < md_len; i++)
404 \&         printf("%02x", md_value[i]);
405 \&     printf("\en");
406 \&
407 \&     exit(0);
408 \& }
409 .Ve
410 .SH "SEE ALSO"
411 .IX Header "SEE ALSO"
412 \&\fBdgst\fR\|(1),
413 \&\fBevp\fR\|(7)
414 .PP
415 The full list of digest algorithms are provided below.
416 .PP
417 \&\fBEVP_blake2b512\fR\|(3),
418 \&\fBEVP_md2\fR\|(3),
419 \&\fBEVP_md4\fR\|(3),
420 \&\fBEVP_md5\fR\|(3),
421 \&\fBEVP_mdc2\fR\|(3),
422 \&\fBEVP_ripemd160\fR\|(3),
423 \&\fBEVP_sha1\fR\|(3),
424 \&\fBEVP_sha224\fR\|(3),
425 \&\fBEVP_sha3_224\fR\|(3),
426 \&\fBEVP_sm3\fR\|(3),
427 \&\fBEVP_whirlpool\fR\|(3)
428 .SH "HISTORY"
429 .IX Header "HISTORY"
430 The \fBEVP_MD_CTX_create()\fR and \fBEVP_MD_CTX_destroy()\fR functions were renamed to
431 \&\fBEVP_MD_CTX_new()\fR and \fBEVP_MD_CTX_free()\fR in OpenSSL 1.1.0, respectively.
432 .PP
433 The link between digests and signing algorithms was fixed in OpenSSL 1.0 and
434 later, so now \fBEVP_sha1()\fR can be used with \s-1RSA\s0 and \s-1DSA.\s0
435 .PP
436 The \fBEVP_dss1()\fR function was removed in OpenSSL 1.1.0.
437 .PP
438 The \fBEVP_MD_CTX_set_pkey_ctx()\fR function was added in 1.1.1.
439 .SH "COPYRIGHT"
440 .IX Header "COPYRIGHT"
441 Copyright 2000\-2019 The OpenSSL Project Authors. All Rights Reserved.
442 .PP
443 Licensed under the OpenSSL license (the \*(L"License\*(R").  You may not use
444 this file except in compliance with the License.  You can obtain a copy
445 in the file \s-1LICENSE\s0 in the source distribution or at
446 <https://www.openssl.org/source/license.html>.