159191Skris=pod
259191Skris
359191Skris=head1 NAME
459191Skris
559191SkrisEVP_VerifyInit, EVP_VerifyUpdate, EVP_VerifyFinal - EVP signature verification functions
659191Skris
759191Skris=head1 SYNOPSIS
859191Skris
959191Skris #include <openssl/evp.h>
1059191Skris
11109998Smarkm int EVP_VerifyInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
12109998Smarkm int EVP_VerifyUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
1359191Skris int EVP_VerifyFinal(EVP_MD_CTX *ctx,unsigned char *sigbuf, unsigned int siglen,EVP_PKEY *pkey);
1459191Skris
15109998Smarkm int EVP_VerifyInit(EVP_MD_CTX *ctx, const EVP_MD *type);
16109998Smarkm
1759191Skris=head1 DESCRIPTION
1859191Skris
1959191SkrisThe EVP signature verification routines are a high level interface to digital
2059191Skrissignatures.
2159191Skris
22109998SmarkmEVP_VerifyInit_ex() sets up verification context B<ctx> to use digest
23109998SmarkmB<type> from ENGINE B<impl>. B<ctx> must be initialized by calling
24109998SmarkmEVP_MD_CTX_init() before calling this function.
2559191Skris
2659191SkrisEVP_VerifyUpdate() hashes B<cnt> bytes of data at B<d> into the
2768651Skrisverification context B<ctx>. This function can be called several times on the
2859191Skrissame B<ctx> to include additional data.
2959191Skris
3059191SkrisEVP_VerifyFinal() verifies the data in B<ctx> using the public key B<pkey>
31109998Smarkmand against the B<siglen> bytes at B<sigbuf>.
3259191Skris
33109998SmarkmEVP_VerifyInit() initializes verification context B<ctx> to use the default
34109998Smarkmimplementation of digest B<type>.
35109998Smarkm
3659191Skris=head1 RETURN VALUES
3759191Skris
38109998SmarkmEVP_VerifyInit_ex() and EVP_VerifyUpdate() return 1 for success and 0 for
39109998Smarkmfailure.
4059191Skris
4159191SkrisEVP_VerifyFinal() returns 1 for a correct signature, 0 for failure and -1 if some
4259191Skrisother error occurred.
4359191Skris
4459191SkrisThe error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
4559191Skris
4659191Skris=head1 NOTES
4759191Skris
4859191SkrisThe B<EVP> interface to digital signatures should almost always be used in
4959191Skrispreference to the low level interfaces. This is because the code then becomes
5059191Skristransparent to the algorithm used and much more flexible.
5159191Skris
5259191SkrisDue to the link between message digests and public key algorithms the correct
5359191Skrisdigest algorithm must be used with the correct public key type. A list of
5459191Skrisalgorithms and associated public key algorithms appears in 
5559191SkrisL<EVP_DigestInit(3)|EVP_DigestInit(3)>.
5659191Skris
57109998SmarkmThe call to EVP_VerifyFinal() internally finalizes a copy of the digest context.
58109998SmarkmThis means that calls to EVP_VerifyUpdate() and EVP_VerifyFinal() can be called
59109998Smarkmlater to digest and verify additional data.
60109998Smarkm
61109998SmarkmSince only a copy of the digest context is ever finalized the context must
62109998Smarkmbe cleaned up after use by calling EVP_MD_CTX_cleanup() or a memory leak
63109998Smarkmwill occur.
64109998Smarkm
6559191Skris=head1 BUGS
6659191Skris
67109998SmarkmOlder versions of this documentation wrongly stated that calls to 
68109998SmarkmEVP_VerifyUpdate() could not be made after calling EVP_VerifyFinal().
6959191Skris
70238405SjkimSince the public key is passed in the call to EVP_SignFinal() any error
71238405Sjkimrelating to the private key (for example an unsuitable key and digest
72238405Sjkimcombination) will not be indicated until after potentially large amounts of
73238405Sjkimdata have been passed through EVP_SignUpdate().
74238405Sjkim
75238405SjkimIt is not possible to change the signing parameters using these function.
76238405Sjkim
77238405SjkimThe previous two bugs are fixed in the newer EVP_VerifyDigest*() function.
78238405Sjkim
7959191Skris=head1 SEE ALSO
8059191Skris
8168651SkrisL<evp(3)|evp(3)>,
8259191SkrisL<EVP_SignInit(3)|EVP_SignInit(3)>,
8359191SkrisL<EVP_DigestInit(3)|EVP_DigestInit(3)>, L<err(3)|err(3)>,
8459191SkrisL<evp(3)|evp(3)>, L<hmac(3)|hmac(3)>, L<md2(3)|md2(3)>,
8559191SkrisL<md5(3)|md5(3)>, L<mdc2(3)|mdc2(3)>, L<ripemd(3)|ripemd(3)>,
86100936SnectarL<sha(3)|sha(3)>, L<dgst(1)|dgst(1)>
8759191Skris
8859191Skris=head1 HISTORY
8959191Skris
9059191SkrisEVP_VerifyInit(), EVP_VerifyUpdate() and EVP_VerifyFinal() are
9159191Skrisavailable in all versions of SSLeay and OpenSSL.
9259191Skris
93109998SmarkmEVP_VerifyInit_ex() was added in OpenSSL 0.9.7
94109998Smarkm
9559191Skris=cut
96