diff options
Diffstat (limited to 'src/lib/libcrypto/man/EVP_PKEY_verify.3')
| -rw-r--r-- | src/lib/libcrypto/man/EVP_PKEY_verify.3 | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/EVP_PKEY_verify.3 b/src/lib/libcrypto/man/EVP_PKEY_verify.3 new file mode 100644 index 0000000000..bec3283349 --- /dev/null +++ b/src/lib/libcrypto/man/EVP_PKEY_verify.3 | |||
| @@ -0,0 +1,109 @@ | |||
| 1 | .Dd $Mdocdate: November 3 2016 $ | ||
| 2 | .Dt EVP_PKEY_VERIFY 3 | ||
| 3 | .Os | ||
| 4 | .Sh NAME | ||
| 5 | .Nm EVP_PKEY_verify_init , | ||
| 6 | .Nm EVP_PKEY_verify | ||
| 7 | .Nd signature verification using a public key algorithm | ||
| 8 | .Sh SYNOPSIS | ||
| 9 | .In openssl/evp.h | ||
| 10 | .Ft int | ||
| 11 | .Fo EVP_PKEY_verify_init | ||
| 12 | .Fa "EVP_PKEY_CTX *ctx" | ||
| 13 | .Fc | ||
| 14 | .Ft int | ||
| 15 | .Fo EVP_PKEY_verify | ||
| 16 | .Fa "EVP_PKEY_CTX *ctx" | ||
| 17 | .Fa "const unsigned char *sig" | ||
| 18 | .Fa "size_t siglen" | ||
| 19 | .Fa "const unsigned char *tbs" | ||
| 20 | .Fa "size_t tbslen" | ||
| 21 | .Fc | ||
| 22 | .Sh DESCRIPTION | ||
| 23 | The | ||
| 24 | .Fn EVP_PKEY_verify_init | ||
| 25 | function initializes a public key algorithm context using key | ||
| 26 | .Fa ctx->pkey | ||
| 27 | for a signature verification operation. | ||
| 28 | .Pp | ||
| 29 | The | ||
| 30 | .Fn EVP_PKEY_verify | ||
| 31 | function performs a public key verification operation using | ||
| 32 | .Fa ctx . | ||
| 33 | The signature is specified using the | ||
| 34 | .Fa sig | ||
| 35 | and | ||
| 36 | .Fa siglen | ||
| 37 | parameters. | ||
| 38 | The verified data (i.e. the data believed originally signed) is | ||
| 39 | specified using the | ||
| 40 | .Fa tbs | ||
| 41 | and | ||
| 42 | .Fa tbslen | ||
| 43 | parameters. | ||
| 44 | .Pp | ||
| 45 | After the call to | ||
| 46 | .Fn EVP_PKEY_verify_init , | ||
| 47 | algorithm specific control operations can be performed to set any | ||
| 48 | appropriate parameters for the operation. | ||
| 49 | .Pp | ||
| 50 | The function | ||
| 51 | .Fn EVP_PKEY_verify | ||
| 52 | can be called more than once on the same context if several operations | ||
| 53 | are performed using the same parameters. | ||
| 54 | .Sh RETURN VALUES | ||
| 55 | .Fn EVP_PKEY_verify_init | ||
| 56 | and | ||
| 57 | .Fn EVP_PKEY_verify | ||
| 58 | return 1 if the verification was successful and 0 if it failed. | ||
| 59 | Unlike other functions the return value 0 from | ||
| 60 | .Fn EVP_PKEY_verify | ||
| 61 | only indicates that the signature did not verify successfully. | ||
| 62 | That is, | ||
| 63 | .Fa tbs | ||
| 64 | did not match the original data or the signature was of invalid form. | ||
| 65 | It is not an indication of a more serious error. | ||
| 66 | .Pp | ||
| 67 | A negative value indicates an error other that signature verification | ||
| 68 | failure. | ||
| 69 | In particular, a return value of -2 indicates the operation is not | ||
| 70 | supported by the public key algorithm. | ||
| 71 | .Sh EXAMPLES | ||
| 72 | Verify signature using PKCS#1 and SHA256 digest: | ||
| 73 | .Bd -literal | ||
| 74 | #include <openssl/evp.h> | ||
| 75 | #include <openssl/rsa.h> | ||
| 76 | |||
| 77 | EVP_PKEY_CTX *ctx; | ||
| 78 | unsigned char *md, *sig; | ||
| 79 | size_t mdlen, siglen; | ||
| 80 | EVP_PKEY *verify_key; | ||
| 81 | /* NB: assumes verify_key, sig, siglen md and mdlen are already set up | ||
| 82 | * and that verify_key is an RSA public key | ||
| 83 | */ | ||
| 84 | ctx = EVP_PKEY_CTX_new(verify_key); | ||
| 85 | if (!ctx) | ||
| 86 | /* Error occurred */ | ||
| 87 | if (EVP_PKEY_verify_init(ctx) <= 0) | ||
| 88 | /* Error */ | ||
| 89 | if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0) | ||
| 90 | /* Error */ | ||
| 91 | if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0) | ||
| 92 | /* Error */ | ||
| 93 | |||
| 94 | /* Perform operation */ | ||
| 95 | ret = EVP_PKEY_verify(ctx, sig, siglen, md, mdlen); | ||
| 96 | |||
| 97 | /* ret == 1 indicates success, 0 verify failure and < 0 for some | ||
| 98 | * other error. | ||
| 99 | */ | ||
| 100 | .Ed | ||
| 101 | .Sh SEE ALSO | ||
| 102 | .Xr EVP_PKEY_CTX_new 3 , | ||
| 103 | .Xr EVP_PKEY_decrypt 3 , | ||
| 104 | .Xr EVP_PKEY_derive 3 , | ||
| 105 | .Xr EVP_PKEY_encrypt 3 , | ||
| 106 | .Xr EVP_PKEY_sign 3 , | ||
| 107 | .Xr EVP_PKEY_verify_recover 3 | ||
| 108 | .Sh HISTORY | ||
| 109 | These functions were first added to OpenSSL 1.0.0. | ||
