summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/EVP_PKEY_verify.3
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_verify.3109
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
23The
24.Fn EVP_PKEY_verify_init
25function initializes a public key algorithm context using key
26.Fa ctx->pkey
27for a signature verification operation.
28.Pp
29The
30.Fn EVP_PKEY_verify
31function performs a public key verification operation using
32.Fa ctx .
33The signature is specified using the
34.Fa sig
35and
36.Fa siglen
37parameters.
38The verified data (i.e. the data believed originally signed) is
39specified using the
40.Fa tbs
41and
42.Fa tbslen
43parameters.
44.Pp
45After the call to
46.Fn EVP_PKEY_verify_init ,
47algorithm specific control operations can be performed to set any
48appropriate parameters for the operation.
49.Pp
50The function
51.Fn EVP_PKEY_verify
52can be called more than once on the same context if several operations
53are performed using the same parameters.
54.Sh RETURN VALUES
55.Fn EVP_PKEY_verify_init
56and
57.Fn EVP_PKEY_verify
58return 1 if the verification was successful and 0 if it failed.
59Unlike other functions the return value 0 from
60.Fn EVP_PKEY_verify
61only indicates that the signature did not verify successfully.
62That is,
63.Fa tbs
64did not match the original data or the signature was of invalid form.
65It is not an indication of a more serious error.
66.Pp
67A negative value indicates an error other that signature verification
68failure.
69In particular, a return value of -2 indicates the operation is not
70supported by the public key algorithm.
71.Sh EXAMPLES
72Verify signature using PKCS#1 and SHA256 digest:
73.Bd -literal
74#include <openssl/evp.h>
75#include <openssl/rsa.h>
76
77EVP_PKEY_CTX *ctx;
78unsigned char *md, *sig;
79size_t mdlen, siglen;
80EVP_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 */
84ctx = EVP_PKEY_CTX_new(verify_key);
85if (!ctx)
86 /* Error occurred */
87if (EVP_PKEY_verify_init(ctx) <= 0)
88 /* Error */
89if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)
90 /* Error */
91if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0)
92 /* Error */
93
94/* Perform operation */
95ret = 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
109These functions were first added to OpenSSL 1.0.0.