Add EVP_DigestSign and EVP_DigesVerify
[openssl.git] / doc / man3 / EVP_DigestVerifyInit.pod
1 =pod
2
3 =head1 NAME
4
5 EVP_DigestVerifyInit, EVP_DigestVerifyUpdate, EVP_DigestVerifyFinal,
6 EVP_DigestVerify - EVP signature verification functions
7
8 =head1 SYNOPSIS
9
10  #include <openssl/evp.h>
11
12  int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
13                         const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);
14  int EVP_DigestVerifyUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt);
15  int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig,
16                            size_t siglen);
17  int EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret,
18                       size_t siglen, const unsigned char *tbs, size_t tbslen);
19
20 =head1 DESCRIPTION
21
22 The EVP signature routines are a high level interface to digital signatures.
23
24 EVP_DigestVerifyInit() sets up verification context B<ctx> to use digest
25 B<type> from ENGINE B<impl> and public key B<pkey>. B<ctx> must be created
26 with EVP_MD_CTX_new() before calling this function. If B<pctx> is not NULL the
27 EVP_PKEY_CTX of the verification operation will be written to B<*pctx>: this
28 can be used to set alternative verification options.
29
30 EVP_DigestVerifyUpdate() hashes B<cnt> bytes of data at B<d> into the
31 verification context B<ctx>. This function can be called several times on the
32 same B<ctx> to include additional data. This function is currently implemented
33 using a macro.
34
35 EVP_DigestVerifyFinal() verifies the data in B<ctx> against the signature in
36 B<sig> of length B<siglen>.
37
38 EVP_DogestVerify() verifies B<tbslen> bytes at B<tbs> against the signature
39 in B<sig> of length B<siglen>.
40
41 =head1 RETURN VALUES
42
43 EVP_DigestVerifyInit() and EVP_DigestVerifyUpdate() return 1 for success and 0
44 for failure.
45
46 EVP_DigestVerifyFinal() and EVP_DigestVerify() return 1 for success; any other
47 value indicates failure.  A return value of zero indicates that the signature
48 did not verify successfully (that is, B<tbs> did not match the original data or
49 the signature had an invalid form), while other values indicate a more serious
50 error (and sometimes also indicate an invalid signature form).
51
52 The error codes can be obtained from L<ERR_get_error(3)>.
53
54 =head1 NOTES
55
56 The B<EVP> interface to digital signatures should almost always be used in
57 preference to the low level interfaces. This is because the code then becomes
58 transparent to the algorithm used and much more flexible.
59
60 EVP_DigesVerify() is a single part operation which verifies a single block of
61 data in one function. It is equivalent to calling EVP_DigestVerifyUpdate() and
62 EVP_DigestVerifyFinal().
63
64 In previous versions of OpenSSL there was a link between message digest types
65 and public key algorithms. This meant that "clone" digests such as EVP_dss1()
66 needed to be used to sign using SHA1 and DSA. This is no longer necessary and
67 the use of clone digest is now discouraged.
68
69 For some key types and parameters the random number generator must be seeded
70 or the operation will fail.
71
72 The call to EVP_DigestVerifyFinal() internally finalizes a copy of the digest
73 context. This means that EVP_VerifyUpdate() and EVP_VerifyFinal() can
74 be called later to digest and verify additional data.
75
76 Since only a copy of the digest context is ever finalized the context must
77 be cleaned up after use by calling EVP_MD_CTX_cleanup() or a memory leak
78 will occur.
79
80 =head1 SEE ALSO
81
82 L<EVP_DigestSignInit(3)>,
83 L<EVP_DigestInit(3)>,
84 L<evp(7)>, L<HMAC(3)>, L<MD2(3)>,
85 L<MD5(3)>, L<MDC2(3)>, L<RIPEMD160(3)>,
86 L<SHA1(3)>, L<dgst(1)>
87
88 =head1 HISTORY
89
90 EVP_DigestVerifyInit(), EVP_DigestVerifyUpdate() and EVP_DigestVerifyFinal()
91 were first added to OpenSSL 1.0.0.
92
93 =head1 COPYRIGHT
94
95 Copyright 2006-2017 The OpenSSL Project Authors. All Rights Reserved.
96
97 Licensed under the OpenSSL license (the "License").  You may not use
98 this file except in compliance with the License.  You can obtain a copy
99 in the file LICENSE in the source distribution or at
100 L<https://www.openssl.org/source/license.html>.
101
102 =cut