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

EXAMPLE

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        /* NB: assumes verify_key, sig and siglen are already set up
63         * and that verify_key is an RSA public key
64         */
65        ctx = EVP_PKEY_CTX_new(verify_key);
66        if (!ctx)
67               /* Error occurred */
68        if (EVP_PKEY_verify_recover_init(ctx) <= 0)
69               /* Error */
70        if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)
71               /* Error */
72        if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0)
73               /* Error */
74
75        /* Determine buffer length */
76        if (EVP_PKEY_verify_recover(ctx, NULL, &routlen, sig, siglen) <= 0)
77               /* Error */
78
79        rout = OPENSSL_malloc(routlen);
80
81        if (!rout)
82               /* malloc failure */
83
84        if (EVP_PKEY_verify_recover(ctx, rout, &routlen, sig, siglen) <= 0)
85               /* Error */
86
87        /* Recovered data is routlen bytes written to buffer rout */
88

SEE ALSO

90       EVP_PKEY_CTX_new(3), EVP_PKEY_encrypt(3), EVP_PKEY_decrypt(3),
91       EVP_PKEY_sign(3), EVP_PKEY_verify(3), EVP_PKEY_derive(3)
92

HISTORY

94       These functions were first added to OpenSSL 1.0.0.
95
96
97
981.0.2o                            2020-08-01        EVP_PKEY_verify_recover(3)
Impressum