1EVP_PKEY_VERIFY_RECOVER(3)          OpenSSL         EVP_PKEY_VERIFY_RECOVER(3)
2
3
4

NAME

6       EVP_PKEY_verify_recover_init, EVP_PKEY_verify_recover - recover
7       signature using a public key algorithm
8

SYNOPSIS

10        #include <openssl/evp.h>
11
12        int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx);
13        int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,
14                                    unsigned char *rout, size_t *routlen,
15                                    const unsigned char *sig, size_t siglen);
16

DESCRIPTION

18       The EVP_PKEY_verify_recover_init() function initializes a public key
19       algorithm context using key pkey for a verify recover operation.
20
21       The EVP_PKEY_verify_recover() function recovers signed data using ctx.
22       The signature is specified using the sig and siglen parameters. If rout
23       is NULL then the maximum size of the output buffer is written to the
24       routlen parameter. If rout is not NULL then before the call the routlen
25       parameter should contain the length of the rout buffer, if the call is
26       successful recovered data is written to rout and the amount of data
27       written to routlen.
28

NOTES

30       Normally an application is only interested in whether a signature
31       verification operation is successful in those cases the EVP_verify()
32       function should be used.
33
34       Sometimes however it is useful to obtain the data originally signed
35       using a signing operation. Only certain public key algorithms can
36       recover a signature in this way (for example RSA in PKCS padding mode).
37
38       After the call to EVP_PKEY_verify_recover_init() algorithm specific
39       control operations can be performed to set any appropriate parameters
40       for the operation.
41
42       The function EVP_PKEY_verify_recover() can be called more than once on
43       the same context if several operations are performed using the same
44       parameters.
45

RETURN VALUES

47       EVP_PKEY_verify_recover_init() and EVP_PKEY_verify_recover() return 1
48       for success and 0 or a negative value for failure. In particular a
49       return value of -2 indicates the operation is not supported by the
50       public key algorithm.
51

EXAMPLES

53       Recover digest originally signed using PKCS#1 and SHA256 digest:
54
55        #include <openssl/evp.h>
56        #include <openssl/rsa.h>
57
58        EVP_PKEY_CTX *ctx;
59        unsigned char *rout, *sig;
60        size_t routlen, siglen;
61        EVP_PKEY *verify_key;
62
63        /*
64         * NB: assumes verify_key, sig and siglen are already set up
65         * and that verify_key is an RSA public key
66         */
67        ctx = EVP_PKEY_CTX_new(verify_key, NULL /* no engine */);
68        if (!ctx)
69            /* Error occurred */
70        if (EVP_PKEY_verify_recover_init(ctx) <= 0)
71            /* Error */
72        if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)
73            /* Error */
74        if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0)
75            /* Error */
76
77        /* Determine buffer length */
78        if (EVP_PKEY_verify_recover(ctx, NULL, &routlen, sig, siglen) <= 0)
79            /* Error */
80
81        rout = OPENSSL_malloc(routlen);
82
83        if (!rout)
84            /* malloc failure */
85
86        if (EVP_PKEY_verify_recover(ctx, rout, &routlen, sig, siglen) <= 0)
87            /* Error */
88
89        /* Recovered data is routlen bytes written to buffer rout */
90

SEE ALSO

92       EVP_PKEY_CTX_new(3), EVP_PKEY_encrypt(3), EVP_PKEY_decrypt(3),
93       EVP_PKEY_sign(3), EVP_PKEY_verify(3), EVP_PKEY_derive(3)
94

HISTORY

96       These functions were added in OpenSSL 1.0.0.
97
99       Copyright 2013-2019 The OpenSSL Project Authors. All Rights Reserved.
100
101       Licensed under the OpenSSL license (the "License").  You may not use
102       this file except in compliance with the License.  You can obtain a copy
103       in the file LICENSE in the source distribution or at
104       <https://www.openssl.org/source/license.html>.
105
106
107
1081.1.1i                            2021-07-22        EVP_PKEY_VERIFY_RECOVER(3)
Impressum