1*2175Sjp161948=pod 2*2175Sjp161948 3*2175Sjp161948=head1 NAME 4*2175Sjp161948 5*2175Sjp161948EVP_VerifyInit, EVP_VerifyUpdate, EVP_VerifyFinal - EVP signature verification functions 6*2175Sjp161948 7*2175Sjp161948=head1 SYNOPSIS 8*2175Sjp161948 9*2175Sjp161948 #include <openssl/evp.h> 10*2175Sjp161948 11*2175Sjp161948 int EVP_VerifyInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl); 12*2175Sjp161948 int EVP_VerifyUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt); 13*2175Sjp161948 int EVP_VerifyFinal(EVP_MD_CTX *ctx,unsigned char *sigbuf, unsigned int siglen,EVP_PKEY *pkey); 14*2175Sjp161948 15*2175Sjp161948 int EVP_VerifyInit(EVP_MD_CTX *ctx, const EVP_MD *type); 16*2175Sjp161948 17*2175Sjp161948=head1 DESCRIPTION 18*2175Sjp161948 19*2175Sjp161948The EVP signature verification routines are a high level interface to digital 20*2175Sjp161948signatures. 21*2175Sjp161948 22*2175Sjp161948EVP_VerifyInit_ex() sets up verification context B<ctx> to use digest 23*2175Sjp161948B<type> from ENGINE B<impl>. B<ctx> must be initialized by calling 24*2175Sjp161948EVP_MD_CTX_init() before calling this function. 25*2175Sjp161948 26*2175Sjp161948EVP_VerifyUpdate() hashes B<cnt> bytes of data at B<d> into the 27*2175Sjp161948verification context B<ctx>. This function can be called several times on the 28*2175Sjp161948same B<ctx> to include additional data. 29*2175Sjp161948 30*2175Sjp161948EVP_VerifyFinal() verifies the data in B<ctx> using the public key B<pkey> 31*2175Sjp161948and against the B<siglen> bytes at B<sigbuf>. 32*2175Sjp161948 33*2175Sjp161948EVP_VerifyInit() initializes verification context B<ctx> to use the default 34*2175Sjp161948implementation of digest B<type>. 35*2175Sjp161948 36*2175Sjp161948=head1 RETURN VALUES 37*2175Sjp161948 38*2175Sjp161948EVP_VerifyInit_ex() and EVP_VerifyUpdate() return 1 for success and 0 for 39*2175Sjp161948failure. 40*2175Sjp161948 41*2175Sjp161948EVP_VerifyFinal() returns 1 for a correct signature, 0 for failure and -1 if some 42*2175Sjp161948other error occurred. 43*2175Sjp161948 44*2175Sjp161948The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>. 45*2175Sjp161948 46*2175Sjp161948=head1 NOTES 47*2175Sjp161948 48*2175Sjp161948The B<EVP> interface to digital signatures should almost always be used in 49*2175Sjp161948preference to the low level interfaces. This is because the code then becomes 50*2175Sjp161948transparent to the algorithm used and much more flexible. 51*2175Sjp161948 52*2175Sjp161948Due to the link between message digests and public key algorithms the correct 53*2175Sjp161948digest algorithm must be used with the correct public key type. A list of 54*2175Sjp161948algorithms and associated public key algorithms appears in 55*2175Sjp161948L<EVP_DigestInit(3)|EVP_DigestInit(3)>. 56*2175Sjp161948 57*2175Sjp161948The call to EVP_VerifyFinal() internally finalizes a copy of the digest context. 58*2175Sjp161948This means that calls to EVP_VerifyUpdate() and EVP_VerifyFinal() can be called 59*2175Sjp161948later to digest and verify additional data. 60*2175Sjp161948 61*2175Sjp161948Since only a copy of the digest context is ever finalized the context must 62*2175Sjp161948be cleaned up after use by calling EVP_MD_CTX_cleanup() or a memory leak 63*2175Sjp161948will occur. 64*2175Sjp161948 65*2175Sjp161948=head1 BUGS 66*2175Sjp161948 67*2175Sjp161948Older versions of this documentation wrongly stated that calls to 68*2175Sjp161948EVP_VerifyUpdate() could not be made after calling EVP_VerifyFinal(). 69*2175Sjp161948 70*2175Sjp161948=head1 SEE ALSO 71*2175Sjp161948 72*2175Sjp161948L<evp(3)|evp(3)>, 73*2175Sjp161948L<EVP_SignInit(3)|EVP_SignInit(3)>, 74*2175Sjp161948L<EVP_DigestInit(3)|EVP_DigestInit(3)>, L<err(3)|err(3)>, 75*2175Sjp161948L<evp(3)|evp(3)>, L<hmac(3)|hmac(3)>, L<md2(3)|md2(3)>, 76*2175Sjp161948L<md5(3)|md5(3)>, L<mdc2(3)|mdc2(3)>, L<ripemd(3)|ripemd(3)>, 77*2175Sjp161948L<sha(3)|sha(3)>, L<dgst(1)|dgst(1)> 78*2175Sjp161948 79*2175Sjp161948=head1 HISTORY 80*2175Sjp161948 81*2175Sjp161948EVP_VerifyInit(), EVP_VerifyUpdate() and EVP_VerifyFinal() are 82*2175Sjp161948available in all versions of SSLeay and OpenSSL. 83*2175Sjp161948 84*2175Sjp161948EVP_VerifyInit_ex() was added in OpenSSL 0.9.7 85*2175Sjp161948 86*2175Sjp161948=cut 87