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