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