1EVP_PKEY_VERIFY(3ossl)              OpenSSL             EVP_PKEY_VERIFY(3ossl)
2
3
4

NAME

6       EVP_PKEY_verify_init, EVP_PKEY_verify_init_ex, EVP_PKEY_verify -
7       signature verification using a public key algorithm
8

SYNOPSIS

10        #include <openssl/evp.h>
11
12        int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx);
13        int EVP_PKEY_verify_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]);
14        int EVP_PKEY_verify(EVP_PKEY_CTX *ctx,
15                            const unsigned char *sig, size_t siglen,
16                            const unsigned char *tbs, size_t tbslen);
17

DESCRIPTION

19       EVP_PKEY_verify_init() initializes a public key algorithm context ctx
20       for signing using the algorithm given when the context was created
21       using EVP_PKEY_CTX_new(3) or variants thereof.  The algorithm is used
22       to fetch a EVP_SIGNATURE method implicitly, see "Implicit fetch" in
23       provider(7) for more information about implicit fetches.
24
25       EVP_PKEY_verify_init_ex() is the same as EVP_PKEY_verify_init() but
26       additionally sets the passed parameters params on the context before
27       returning.
28
29       The EVP_PKEY_verify() function performs a public key verification
30       operation using ctx. The signature is specified using the sig and
31       siglen parameters. The verified data (i.e. the data believed originally
32       signed) is specified using the tbs and tbslen parameters.
33

NOTES

35       After the call to EVP_PKEY_verify_init() algorithm specific control
36       operations can be performed to set any appropriate parameters for the
37       operation.
38
39       The function EVP_PKEY_verify() can be called more than once on the same
40       context if several operations are performed using the same parameters.
41

RETURN VALUES

43       EVP_PKEY_verify_init() and EVP_PKEY_verify() return 1 if the
44       verification was successful and 0 if it failed. Unlike other functions
45       the return value 0 from EVP_PKEY_verify() only indicates that the
46       signature did not verify successfully (that is tbs did not match the
47       original data or the signature was of invalid form) it is not an
48       indication of a more serious error.
49
50       A negative value indicates an error other that signature verification
51       failure.  In particular a return value of -2 indicates the operation is
52       not supported by the public key algorithm.
53

EXAMPLES

55       Verify signature using PKCS#1 and SHA256 digest:
56
57        #include <openssl/evp.h>
58        #include <openssl/rsa.h>
59
60        EVP_PKEY_CTX *ctx;
61        unsigned char *md, *sig;
62        size_t mdlen, siglen;
63        EVP_PKEY *verify_key;
64
65        /*
66         * NB: assumes verify_key, sig, siglen md and mdlen are already set up
67         * and that verify_key is an RSA public key
68         */
69        ctx = EVP_PKEY_CTX_new(verify_key, NULL /* no engine */);
70        if (!ctx)
71            /* Error occurred */
72        if (EVP_PKEY_verify_init(ctx) <= 0)
73            /* Error */
74        if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)
75            /* Error */
76        if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0)
77            /* Error */
78
79        /* Perform operation */
80        ret = EVP_PKEY_verify(ctx, sig, siglen, md, mdlen);
81
82        /*
83         * ret == 1 indicates success, 0 verify failure and < 0 for some
84         * other error.
85         */
86

SEE ALSO

88       EVP_PKEY_CTX_new(3), EVP_PKEY_encrypt(3), EVP_PKEY_decrypt(3),
89       EVP_PKEY_sign(3), EVP_PKEY_verify_recover(3), EVP_PKEY_derive(3)
90

HISTORY

92       The EVP_PKEY_verify_init() and EVP_PKEY_verify() functions were added
93       in OpenSSL 1.0.0.
94
95       The EVP_PKEY_verify_init_ex() function was added in OpenSSL 3.0.
96
98       Copyright 2006-2021 The OpenSSL Project Authors. All Rights Reserved.
99
100       Licensed under the Apache License 2.0 (the "License").  You may not use
101       this file except in compliance with the License.  You can obtain a copy
102       in the file LICENSE in the source distribution or at
103       <https://www.openssl.org/source/license.html>.
104
105
106
1073.0.5                             2022-07-05            EVP_PKEY_VERIFY(3ossl)
Impressum