![]() |
![]()
| ![]() |
![]()
NAME
SYNOPSIS
int
int
DESCRIPTIONThe
The
Normally an application is only interested in whether a signature verification operation is successful. In those cases, the EVP_PKEY_verify(3) function should be used. Sometimes however it is useful to obtain the data originally signed using a signing operation. Only certain public key algorithms can recover a signature in this way (for example RSA in PKCS padding mode). After the call to
The function
RETURN VALUES
EXAMPLESRecover digest originally signed using PKCS#1 and SHA256 digest: #include <openssl/evp.h> #include <openssl/rsa.h> EVP_PKEY_CTX *ctx; unsigned char *rout, *sig; size_t routlen, siglen; EVP_PKEY *verify_key; /* * Assumes that verify_key, sig, and siglen are already set up * and that verify_key is an RSA public key. */ ctx = EVP_PKEY_CTX_new(verify_key, NULL); if (!ctx) /* Error occurred */ if (EVP_PKEY_verify_recover_init(ctx) <= 0) /* Error */ if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0) /* Error */ if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0) /* Error */ /* Determine buffer length */ if (EVP_PKEY_verify_recover(ctx, NULL, &routlen, sig, siglen) <= 0) /* Error */ rout = malloc(routlen); if (!rout) /* malloc failure */ if (EVP_PKEY_verify_recover(ctx, rout, &routlen, sig, siglen) <= 0) /* Error */ /* Recovered data is routlen bytes written to buffer rout */ SEE ALSOEVP_PKEY_CTX_new(3), EVP_PKEY_decrypt(3), EVP_PKEY_derive(3), EVP_PKEY_encrypt(3), EVP_PKEY_sign(3), EVP_PKEY_verify(3) HISTORY
|