summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/EVP_SignInit.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/EVP_SignInit.3')
-rw-r--r--src/lib/libcrypto/man/EVP_SignInit.3167
1 files changed, 167 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/EVP_SignInit.3 b/src/lib/libcrypto/man/EVP_SignInit.3
new file mode 100644
index 0000000000..22f81148a2
--- /dev/null
+++ b/src/lib/libcrypto/man/EVP_SignInit.3
@@ -0,0 +1,167 @@
1.Dd $Mdocdate: November 3 2016 $
2.Dt EVP_SIGNINIT 3
3.Os
4.Sh NAME
5.Nm EVP_SignInit ,
6.Nm EVP_SignUpdate ,
7.Nm EVP_SignFinal ,
8.Nm EVP_PKEY_size
9.Nd EVP signing functions
10.Sh SYNOPSIS
11.In openssl/evp.h
12.Ft int
13.Fo EVP_SignInit_ex
14.Fa "EVP_MD_CTX *ctx"
15.Fa "const EVP_MD *type"
16.Fa "ENGINE *impl"
17.Fc
18.Ft int
19.Fo EVP_SignUpdate
20.Fa "EVP_MD_CTX *ctx"
21.Fa "const void *d"
22.Fa "unsigned int cnt"
23.Fc
24.Ft int
25.Fo EVP_SignFinal
26.Fa "EVP_MD_CTX *ctx"
27.Fa "unsigned char *sig"
28.Fa "unsigned int *s"
29.Fa "EVP_PKEY *pkey"
30.Fc
31.Ft void
32.Fo EVP_SignInit
33.Fa "EVP_MD_CTX *ctx"
34.Fa "const EVP_MD *type"
35.Fc
36.Ft int
37.Fo EVP_PKEY_size
38.Fa "EVP_PKEY *pkey"
39.Fc
40.Sh DESCRIPTION
41The EVP signature routines are a high level interface to digital
42signatures.
43.Pp
44.Fn EVP_SignInit_ex
45sets up a signing context
46.Fa ctx
47to use the digest
48.Fa type
49from
50.Vt ENGINE
51.Fa impl .
52.Fa ctx
53must be initialized with
54.Xr EVP_MD_CTX_init 3
55before calling this function.
56.Pp
57.Fn EVP_SignUpdate
58hashes
59.Fa cnt
60bytes of data at
61.Fa d
62into the signature context
63.Fa ctx .
64This function can be called several times on the same
65.Fa ctx
66to include additional data.
67.Pp
68.Fn EVP_SignFinal
69signs the data in
70.Fa ctx
71using the private key
72.Fa pkey
73and places the signature in
74.Fa sig .
75.Fa sig
76must be at least
77.Fn EVP_PKEY_size pkey
78bytes in size.
79.Fa s
80is an OUT parameter, and not used as an IN parameter.
81The number of bytes of data written (i.e.
82the length of the signature) will be written to the integer at
83.Fa s .
84At most
85.Fn EVP_PKEY_size pkey
86bytes will be written.
87.Pp
88.Fn EVP_SignInit
89initializes a signing context
90.Fa ctx
91to use the default implementation of digest
92.Fa type .
93.Pp
94.Fn EVP_PKEY_size
95returns the maximum size of a signature in bytes.
96The actual signature returned by
97.Fn EVP_SignFinal
98may be smaller.
99.Pp
100The EVP interface to digital signatures should almost always be
101used in preference to the low level interfaces.
102This is because the code then becomes transparent to the algorithm used
103and much more flexible.
104.Pp
105Due to the link between message digests and public key algorithms the
106correct digest algorithm must be used with the correct public key type.
107A list of algorithms and associated public key algorithms appears in
108.Xr EVP_DigestInit 3 .
109.Pp
110The call to
111.Fn EVP_SignFinal
112internally finalizes a copy of the digest context.
113This means that calls to
114.Fn EVP_SignUpdate
115and
116.Fn EVP_SignFinal
117can be called later to digest and sign additional data.
118.Pp
119Since only a copy of the digest context is ever finalized, the context
120must be cleaned up after use by calling
121.Xr EVP_MD_CTX_cleanup 3
122or a memory leak will occur.
123.Sh RETURN VALUES
124.Fn EVP_SignInit_ex ,
125.Fn EVP_SignUpdate ,
126and
127.Fn EVP_SignFinal
128return 1 for success and 0 for failure.
129.Pp
130.Fn EVP_PKEY_size
131returns the maximum size of a signature in bytes.
132.Pp
133The error codes can be obtained by
134.Xr ERR_get_error 3 .
135.Sh SEE ALSO
136.Xr ERR 3 ,
137.Xr evp 3 ,
138.Xr EVP_DigestInit 3 ,
139.Xr EVP_VerifyInit 3
140.Sh HISTORY
141.Fn EVP_SignInit ,
142.Fn EVP_SignUpdate ,
143and
144.Fn EVP_SignFinal
145are available in all versions of SSLeay and OpenSSL.
146.Pp
147.Fn EVP_SignInit_ex
148was added in OpenSSL 0.9.7.
149.Sh BUGS
150Older versions of this documentation wrongly stated that calls to
151.Fn EVP_SignUpdate
152could not be made after calling
153.Fn EVP_SignFinal .
154.Pp
155Since the private key is passed in the call to
156.Fn EVP_SignFinal
157any error relating to the private key (for example an unsuitable key and
158digest combination) will not be indicated until after potentially large
159amounts of data have been passed through
160.Fn EVP_SignUpdate .
161.Pp
162It is not possible to change the signing parameters using these
163function.
164.Pp
165The previous two bugs are fixed in the newer
166.Xr EVP_SignDigest* 3
167function.