Document that lhash isn't thread safe under any circumstances and
[openssl.git] / doc / man3 / EVP_VerifyInit.pod
1 =pod
2
3 =head1 NAME
4
5 EVP_VerifyInit_ex,
6 EVP_VerifyInit, EVP_VerifyUpdate, EVP_VerifyFinal
7 - EVP signature verification functions
8
9 =head1 SYNOPSIS
10
11  #include <openssl/evp.h>
12
13  int EVP_VerifyInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
14  int EVP_VerifyUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
15  int EVP_VerifyFinal(EVP_MD_CTX *ctx, unsigned char *sigbuf, unsigned int siglen,
16                      EVP_PKEY *pkey);
17
18  int EVP_VerifyInit(EVP_MD_CTX *ctx, const EVP_MD *type);
19
20 =head1 DESCRIPTION
21
22 The EVP signature verification routines are a high level interface to digital
23 signatures.
24
25 EVP_VerifyInit_ex() sets up verification context B<ctx> to use digest
26 B<type> from ENGINE B<impl>. B<ctx> must be created by calling
27 EVP_MD_CTX_new() before calling this function.
28
29 EVP_VerifyUpdate() hashes B<cnt> bytes of data at B<d> into the
30 verification context B<ctx>. This function can be called several times on the
31 same B<ctx> to include additional data.
32
33 EVP_VerifyFinal() verifies the data in B<ctx> using the public key B<pkey>
34 and against the B<siglen> bytes at B<sigbuf>.
35
36 EVP_VerifyInit() initializes verification context B<ctx> to use the default
37 implementation of digest B<type>.
38
39 =head1 RETURN VALUES
40
41 EVP_VerifyInit_ex() and EVP_VerifyUpdate() return 1 for success and 0 for
42 failure.
43
44 EVP_VerifyFinal() returns 1 for a correct signature, 0 for failure and -1 if some
45 other error occurred.
46
47 The error codes can be obtained by L<ERR_get_error(3)>.
48
49 =head1 NOTES
50
51 The B<EVP> interface to digital signatures should almost always be used in
52 preference to the low level interfaces. This is because the code then becomes
53 transparent to the algorithm used and much more flexible.
54
55 Due to the link between message digests and public key algorithms the correct
56 digest algorithm must be used with the correct public key type. A list of
57 algorithms and associated public key algorithms appears in
58 L<EVP_DigestInit(3)>.
59
60 The call to EVP_VerifyFinal() internally finalizes a copy of the digest context.
61 This means that calls to EVP_VerifyUpdate() and EVP_VerifyFinal() can be called
62 later to digest and verify additional data.
63
64 Since only a copy of the digest context is ever finalized the context must
65 be cleaned up after use by calling EVP_MD_CTX_cleanup() or a memory leak
66 will occur.
67
68 =head1 BUGS
69
70 Older versions of this documentation wrongly stated that calls to
71 EVP_VerifyUpdate() could not be made after calling EVP_VerifyFinal().
72
73 Since the public key is passed in the call to EVP_SignFinal() any error
74 relating to the private key (for example an unsuitable key and digest
75 combination) will not be indicated until after potentially large amounts of
76 data have been passed through EVP_SignUpdate().
77
78 It is not possible to change the signing parameters using these function.
79
80 The previous two bugs are fixed in the newer EVP_VerifyDigest*() function.
81
82 =head1 SEE ALSO
83
84 L<evp(7)>,
85 L<EVP_SignInit(3)>,
86 L<EVP_DigestInit(3)>,
87 L<evp(7)>, L<HMAC(3)>, L<MD2(3)>,
88 L<MD5(3)>, L<MDC2(3)>, L<RIPEMD160(3)>,
89 L<SHA1(3)>, L<dgst(1)>
90
91 =head1 COPYRIGHT
92
93 Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
94
95 Licensed under the OpenSSL license (the "License").  You may not use
96 this file except in compliance with the License.  You can obtain a copy
97 in the file LICENSE in the source distribution or at
98 L<https://www.openssl.org/source/license.html>.
99
100 =cut