xref: /freebsd/crypto/openssl/doc/man3/EVP_VerifyInit.pod (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5e71b7053SJung-uk KimEVP_VerifyInit_ex,
6*b077aed3SPierre ProncheryEVP_VerifyInit, EVP_VerifyUpdate, EVP_VerifyFinal_ex, EVP_VerifyFinal
7e71b7053SJung-uk Kim- EVP signature verification functions
8e71b7053SJung-uk Kim
9e71b7053SJung-uk Kim=head1 SYNOPSIS
10e71b7053SJung-uk Kim
11e71b7053SJung-uk Kim #include <openssl/evp.h>
12e71b7053SJung-uk Kim
13e71b7053SJung-uk Kim int EVP_VerifyInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
14e71b7053SJung-uk Kim int EVP_VerifyUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
15*b077aed3SPierre Pronchery int EVP_VerifyFinal_ex(EVP_MD_CTX *ctx, const unsigned char *sigbuf,
16*b077aed3SPierre Pronchery                        unsigned int siglen, EVP_PKEY *pkey,
17*b077aed3SPierre Pronchery                        OSSL_LIB_CTX *libctx, const char *propq);
18e71b7053SJung-uk Kim int EVP_VerifyFinal(EVP_MD_CTX *ctx, unsigned char *sigbuf, unsigned int siglen,
19e71b7053SJung-uk Kim                     EVP_PKEY *pkey);
20e71b7053SJung-uk Kim
21e71b7053SJung-uk Kim int EVP_VerifyInit(EVP_MD_CTX *ctx, const EVP_MD *type);
22e71b7053SJung-uk Kim
23e71b7053SJung-uk Kim=head1 DESCRIPTION
24e71b7053SJung-uk Kim
2558f35182SJung-uk KimThe EVP signature verification routines are a high-level interface to digital
26e71b7053SJung-uk Kimsignatures.
27e71b7053SJung-uk Kim
28*b077aed3SPierre ProncheryEVP_VerifyInit_ex() sets up verification context I<ctx> to use digest
29*b077aed3SPierre ProncheryI<type> from ENGINE I<impl>. I<ctx> must be created by calling
30e71b7053SJung-uk KimEVP_MD_CTX_new() before calling this function.
31e71b7053SJung-uk Kim
32*b077aed3SPierre ProncheryEVP_VerifyUpdate() hashes I<cnt> bytes of data at I<d> into the
33*b077aed3SPierre Proncheryverification context I<ctx>. This function can be called several times on the
34*b077aed3SPierre Proncherysame I<ctx> to include additional data.
35e71b7053SJung-uk Kim
36*b077aed3SPierre ProncheryEVP_VerifyFinal_ex() verifies the data in I<ctx> using the public key
37*b077aed3SPierre ProncheryI<pkey> and I<siglen> bytes in I<sigbuf>.
38*b077aed3SPierre ProncheryThe library context I<libctx> and property query I<propq> are used when creating
39*b077aed3SPierre Proncherya context to use with the key I<pkey>.
40e71b7053SJung-uk Kim
41*b077aed3SPierre ProncheryEVP_VerifyFinal() is similar to EVP_VerifyFinal_ex() but uses default
42*b077aed3SPierre Proncheryvalues of NULL for the library context I<libctx> and the property query I<propq>.
43*b077aed3SPierre Pronchery
44*b077aed3SPierre ProncheryEVP_VerifyInit() initializes verification context I<ctx> to use the default
45*b077aed3SPierre Proncheryimplementation of digest I<type>.
46e71b7053SJung-uk Kim
47e71b7053SJung-uk Kim=head1 RETURN VALUES
48e71b7053SJung-uk Kim
49e71b7053SJung-uk KimEVP_VerifyInit_ex() and EVP_VerifyUpdate() return 1 for success and 0 for
50e71b7053SJung-uk Kimfailure.
51e71b7053SJung-uk Kim
52*b077aed3SPierre ProncheryEVP_VerifyFinal_ex() and EVP_VerifyFinal() return 1 for a correct
53*b077aed3SPierre Proncherysignature, 0 for failure and a negative value if some other error occurred.
54e71b7053SJung-uk Kim
55e71b7053SJung-uk KimThe error codes can be obtained by L<ERR_get_error(3)>.
56e71b7053SJung-uk Kim
57e71b7053SJung-uk Kim=head1 NOTES
58e71b7053SJung-uk Kim
59e71b7053SJung-uk KimThe B<EVP> interface to digital signatures should almost always be used in
6058f35182SJung-uk Kimpreference to the low-level interfaces. This is because the code then becomes
61e71b7053SJung-uk Kimtransparent to the algorithm used and much more flexible.
62e71b7053SJung-uk Kim
63e71b7053SJung-uk KimThe call to EVP_VerifyFinal() internally finalizes a copy of the digest context.
64e71b7053SJung-uk KimThis means that calls to EVP_VerifyUpdate() and EVP_VerifyFinal() can be called
65e71b7053SJung-uk Kimlater to digest and verify additional data.
66e71b7053SJung-uk Kim
67e71b7053SJung-uk KimSince only a copy of the digest context is ever finalized the context must
68e71b7053SJung-uk Kimbe cleaned up after use by calling EVP_MD_CTX_free() or a memory leak
69e71b7053SJung-uk Kimwill occur.
70e71b7053SJung-uk Kim
71e71b7053SJung-uk Kim=head1 BUGS
72e71b7053SJung-uk Kim
73e71b7053SJung-uk KimOlder versions of this documentation wrongly stated that calls to
74e71b7053SJung-uk KimEVP_VerifyUpdate() could not be made after calling EVP_VerifyFinal().
75e71b7053SJung-uk Kim
76e71b7053SJung-uk KimSince the public key is passed in the call to EVP_SignFinal() any error
77e71b7053SJung-uk Kimrelating to the private key (for example an unsuitable key and digest
78e71b7053SJung-uk Kimcombination) will not be indicated until after potentially large amounts of
79e71b7053SJung-uk Kimdata have been passed through EVP_SignUpdate().
80e71b7053SJung-uk Kim
81e71b7053SJung-uk KimIt is not possible to change the signing parameters using these function.
82e71b7053SJung-uk Kim
83da327cd2SJung-uk KimThe previous two bugs are fixed in the newer EVP_DigestVerify*() function.
84e71b7053SJung-uk Kim
85e71b7053SJung-uk Kim=head1 SEE ALSO
86e71b7053SJung-uk Kim
87e71b7053SJung-uk KimL<evp(7)>,
88e71b7053SJung-uk KimL<EVP_SignInit(3)>,
89e71b7053SJung-uk KimL<EVP_DigestInit(3)>,
90e71b7053SJung-uk KimL<evp(7)>, L<HMAC(3)>, L<MD2(3)>,
91e71b7053SJung-uk KimL<MD5(3)>, L<MDC2(3)>, L<RIPEMD160(3)>,
92*b077aed3SPierre ProncheryL<SHA1(3)>, L<openssl-dgst(1)>
93*b077aed3SPierre Pronchery
94*b077aed3SPierre Pronchery=head1 HISTORY
95*b077aed3SPierre Pronchery
96*b077aed3SPierre ProncheryThe function EVP_VerifyFinal_ex() was added in OpenSSL 3.0.
97e71b7053SJung-uk Kim
98e71b7053SJung-uk Kim=head1 COPYRIGHT
99e71b7053SJung-uk Kim
100*b077aed3SPierre ProncheryCopyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
101e71b7053SJung-uk Kim
102*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
103e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
104e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
105e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
106e71b7053SJung-uk Kim
107e71b7053SJung-uk Kim=cut
108