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