1EVP_DIGESTVERIFYINIT(3)             OpenSSL            EVP_DIGESTVERIFYINIT(3)
2
3
4

NAME

6       EVP_DigestVerifyInit, EVP_DigestVerifyUpdate, EVP_DigestVerifyFinal,
7       EVP_DigestVerify - EVP signature verification functions
8

SYNOPSIS

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

DESCRIPTION

21       The EVP signature routines are a high-level interface to digital
22       signatures.
23
24       EVP_DigestVerifyInit() sets up verification context ctx to use digest
25       type from ENGINE e and public key pkey. ctx must be created with
26       EVP_MD_CTX_new() before calling this function. If pctx is not NULL, the
27       EVP_PKEY_CTX of the verification operation will be written to *pctx:
28       this can be used to set alternative verification options. Note that any
29       existing value in *pctx is overwritten. The EVP_PKEY_CTX value returned
30       must not be freed directly by the application if ctx is not assigned an
31       EVP_PKEY_CTX value before being passed to EVP_DigestVerifyInit() (which
32       means the EVP_PKEY_CTX is created inside EVP_DigestVerifyInit() and it
33       will be freed automatically when the EVP_MD_CTX is freed).
34
35       No EVP_PKEY_CTX will be created by EVP_DigestSignInit() if the passed
36       ctx has already been assigned one via EVP_MD_CTX_set_pkey_ctx(3). See
37       also SM2(7).
38
39       EVP_DigestVerifyUpdate() hashes cnt bytes of data at d into the
40       verification context ctx. This function can be called several times on
41       the same ctx to include additional data. This function is currently
42       implemented using a macro.
43
44       EVP_DigestVerifyFinal() verifies the data in ctx against the signature
45       in sig of length siglen.
46
47       EVP_DigestVerify() verifies tbslen bytes at tbs against the signature
48       in sig of length siglen.
49

RETURN VALUES

51       EVP_DigestVerifyInit() and EVP_DigestVerifyUpdate() return 1 for
52       success and 0 for failure.
53
54       EVP_DigestVerifyFinal() and EVP_DigestVerify() return 1 for success;
55       any other value indicates failure.  A return value of zero indicates
56       that the signature did not verify successfully (that is, tbs did not
57       match the original data or the signature had an invalid form), while
58       other values indicate a more serious error (and sometimes also indicate
59       an invalid signature form).
60
61       The error codes can be obtained from ERR_get_error(3).
62

NOTES

64       The EVP interface to digital signatures should almost always be used in
65       preference to the low-level interfaces. This is because the code then
66       becomes transparent to the algorithm used and much more flexible.
67
68       EVP_DigestVerify() is a one shot operation which verifies a single
69       block of data in one function. For algorithms that support streaming it
70       is equivalent to calling EVP_DigestVerifyUpdate() and
71       EVP_DigestVerifyFinal(). For algorithms which do not support streaming
72       (e.g. PureEdDSA) it is the only way to verify data.
73
74       In previous versions of OpenSSL there was a link between message digest
75       types and public key algorithms. This meant that "clone" digests such
76       as EVP_dss1() needed to be used to sign using SHA1 and DSA. This is no
77       longer necessary and the use of clone digest is now discouraged.
78
79       For some key types and parameters the random number generator must be
80       seeded.  If the automatic seeding or reseeding of the OpenSSL CSPRNG
81       fails due to external circumstances (see RAND(7)), the operation will
82       fail.
83
84       The call to EVP_DigestVerifyFinal() internally finalizes a copy of the
85       digest context. This means that EVP_VerifyUpdate() and
86       EVP_VerifyFinal() can be called later to digest and verify additional
87       data.
88
89       Since only a copy of the digest context is ever finalized, the context
90       must be cleaned up after use by calling EVP_MD_CTX_free() or a memory
91       leak will occur.
92

SEE ALSO

94       EVP_DigestSignInit(3), EVP_DigestInit(3), evp(7), HMAC(3), MD2(3),
95       MD5(3), MDC2(3), RIPEMD160(3), SHA1(3), dgst(1), RAND(7)
96

HISTORY

98       EVP_DigestVerifyInit(), EVP_DigestVerifyUpdate() and
99       EVP_DigestVerifyFinal() were added in OpenSSL 1.0.0.
100
102       Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved.
103
104       Licensed under the OpenSSL license (the "License").  You may not use
105       this file except in compliance with the License.  You can obtain a copy
106       in the file LICENSE in the source distribution or at
107       <https://www.openssl.org/source/license.html>.
108
109
110
1111.1.1i                            2021-01-26           EVP_DIGESTVERIFYINIT(3)
Impressum