summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/EVP_PKEY_sign.3
diff options
context:
space:
mode:
authorschwarze <>2016-11-03 09:35:34 +0000
committerschwarze <>2016-11-03 09:35:34 +0000
commit4d607f17ea3eb38ed9f7703afd423f6055c686d4 (patch)
tree58d82d0d7f6aeee380eaadbcfaa231ecbe6b90a0 /src/lib/libcrypto/man/EVP_PKEY_sign.3
parentcf67afe5881727d740e9f6c772aa478123f7d698 (diff)
downloadopenbsd-4d607f17ea3eb38ed9f7703afd423f6055c686d4.tar.gz
openbsd-4d607f17ea3eb38ed9f7703afd423f6055c686d4.tar.bz2
openbsd-4d607f17ea3eb38ed9f7703afd423f6055c686d4.zip
convert EVP manuals from pod to mdoc
Diffstat (limited to 'src/lib/libcrypto/man/EVP_PKEY_sign.3')
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_sign.3120
1 files changed, 120 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/EVP_PKEY_sign.3 b/src/lib/libcrypto/man/EVP_PKEY_sign.3
new file mode 100644
index 0000000000..f8e4da7a9d
--- /dev/null
+++ b/src/lib/libcrypto/man/EVP_PKEY_sign.3
@@ -0,0 +1,120 @@
1.Dd $Mdocdate: November 3 2016 $
2.Dt EVP_PKEY_SIGN 3
3.Os
4.Sh NAME
5.Nm EVP_PKEY_sign_init ,
6.Nm EVP_PKEY_sign
7.Nd sign using a public key algorithm
8.Sh SYNOPSIS
9.In openssl/evp.h
10.Ft int
11.Fo EVP_PKEY_sign_init
12.Fa "EVP_PKEY_CTX *ctx"
13.Fc
14.Ft int
15.Fo EVP_PKEY_sign
16.Fa "EVP_PKEY_CTX *ctx"
17.Fa "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_sign_init
25function initializes a public key algorithm context using the key
26.Fa ctx->pkey
27for a signing operation.
28.Pp
29The
30.Fn EVP_PKEY_sign
31function performs a public key signing operation using
32.Fa ctx .
33The data to be signed is specified using the
34.Fa tbs
35and
36.Fa tbslen
37parameters.
38If
39.Fa sig
40is
41.Dv NULL ,
42then the maximum size of the output buffer is written to the
43.Fa siglen
44parameter.
45If
46.Fa sig
47is not
48.Dv NULL ,
49then before the call the
50.Fa siglen
51parameter should contain the length of the
52.Fa sig
53buffer.
54If the call is successful the signature is written to
55.Fa sig
56and the amount of data written to
57.Fa siglen .
58.Pp
59After the call to
60.Fn EVP_PKEY_sign_init ,
61algorithm specific control operations can be performed to set any
62appropriate parameters for the operation.
63.Pp
64The function
65.Fn EVP_PKEY_sign
66can be called more than once on the same context if several operations
67are performed using the same parameters.
68.Sh RETURN VALUES
69.Fn EVP_PKEY_sign_init
70and
71.Fn EVP_PKEY_sign
72return 1 for success and 0 or a negative value for failure.
73In particular, a return value of -2 indicates the operation is not
74supported by the public key algorithm.
75.Sh EXAMPLES
76Sign data using RSA with PKCS#1 padding and SHA256 digest:
77.Bd -literal
78#include <openssl/evp.h>
79#include <openssl/rsa.h>
80
81EVP_PKEY_CTX *ctx;
82unsigned char *md, *sig;
83size_t mdlen, siglen;
84EVP_PKEY *signing_key;
85/* NB: assumes signing_key, md and mdlen are already set up
86 * and that signing_key is an RSA private key
87 */
88ctx = EVP_PKEY_CTX_new(signing_key);
89if (!ctx)
90 /* Error occurred */
91if (EVP_PKEY_sign_init(ctx) <= 0)
92 /* Error */
93if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)
94 /* Error */
95if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0)
96 /* Error */
97
98/* Determine buffer length */
99if (EVP_PKEY_sign(ctx, NULL, &siglen, md, mdlen) <= 0)
100 /* Error */
101
102sig = malloc(siglen);
103
104if (!sig)
105 /* malloc failure */
106
107if (EVP_PKEY_sign(ctx, sig, &siglen, md, mdlen) <= 0)
108 /* Error */
109
110/* Signature is siglen bytes written to buffer sig */
111.Ed
112.Sh SEE ALSO
113.Xr EVP_PKEY_CTX_new 3 ,
114.Xr EVP_PKEY_decrypt 3 ,
115.Xr EVP_PKEY_derive 3 ,
116.Xr EVP_PKEY_encrypt 3 ,
117.Xr EVP_PKEY_verify 3 ,
118.Xr EVP_PKEY_verify_recover 3
119.Sh HISTORY
120These functions were first added to OpenSSL 1.0.0.