summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/PKCS7_sign.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/PKCS7_sign.3')
-rw-r--r--src/lib/libcrypto/man/PKCS7_sign.3190
1 files changed, 190 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/PKCS7_sign.3 b/src/lib/libcrypto/man/PKCS7_sign.3
new file mode 100644
index 0000000000..894472402d
--- /dev/null
+++ b/src/lib/libcrypto/man/PKCS7_sign.3
@@ -0,0 +1,190 @@
1.Dd $Mdocdate: November 3 2016 $
2.Dt PKCS7_SIGN 3
3.Os
4.Sh NAME
5.Nm PKCS7_sign
6.Nd create a PKCS#7 signedData structure
7.Sh SYNOPSIS
8.In openssl/pkcs7.h
9.Ft PKCS7 *
10.Fo PKCS7_sign
11.Fa "X509 *signcert"
12.Fa "EVP_PKEY *pkey"
13.Fa "STACK_OF(X509) *certs"
14.Fa "BIO *data"
15.Fa "int flags"
16.Fc
17.Sh DESCRIPTION
18.Fn PKCS7_sign
19creates and returns a PKCS#7 signedData structure.
20.Fa signcert
21is the certificate to sign with,
22.Fa pkey
23is the corresponding private key.
24.Fa certs
25is an optional additional set of certificates to include in the PKCS#7
26structure (for example any intermediate CAs in the chain).
27.Pp
28The data to be signed is read from
29.Vt BIO
30.Fa data .
31.Pp
32.Fa flags
33is an optional set of flags.
34.Pp
35Any of the following flags (OR'ed together) can be passed in the
36.Fa flags
37parameter.
38.Pp
39Many S/MIME clients expect the signed content to include valid MIME
40headers.
41If the
42.Dv PKCS7_TEXT
43flag is set, MIME headers for type
44.Sy text/plain
45are prepended to the data.
46.Pp
47If
48.Dv PKCS7_NOCERTS
49is set, the signer's certificate will not be included in the PKCS7
50structure, the signer's certificate must still be supplied in the
51.Fa signcert
52parameter though.
53This can reduce the size of the signature if the signers certificate can
54be obtained by other means: for example a previously signed message.
55.Pp
56The data being signed is included in the
57.Vt PKCS7
58structure, unless
59.Dv PKCS7_DETACHED
60is set in which case it is omitted.
61This is used for PKCS7 detached signatures which are used in S/MIME
62plaintext signed messages for example.
63.Pp
64Normally the supplied content is translated into MIME canonical format
65(as required by the S/MIME specifications).
66If
67.Dv PKCS7_BINARY
68is set, no translation occurs.
69This option should be used if the supplied data is in binary format;
70otherwise, the translation will corrupt it.
71.Pp
72The signedData structure includes several PKCS#7 authenticatedAttributes
73including the signing time, the PKCS#7 content type and the supported
74list of ciphers in an SMIMECapabilities attribute.
75If
76.Dv PKCS7_NOATTR
77is set, then no authenticatedAttributes will be used.
78If
79.Dv PKCS7_NOSMIMECAP
80is set, then just the SMIMECapabilities are omitted.
81.Pp
82If present, the SMIMECapabilities attribute indicates support for the
83following algorithms: triple DES, 128 bit RC2, 64 bit RC2, DES and 40
84bit RC2.
85If any of these algorithms is disabled then it will not be included.
86.Pp
87If the flags
88.Dv PKCS7_STREAM
89is set, then the returned
90.Vt PKCS7
91structure is just initialized ready to perform the signing operation.
92The signing is however
93.Sy not
94performed and the data to be signed is not read from the
95.Fa data
96parameter.
97Signing is deferred until after the data has been written.
98In this way data can be signed in a single pass.
99.Pp
100If the
101.Dv PKCS7_PARTIAL
102flag is set, a partial
103.Vt PKCS7
104structure is output to which additional signers and capabilities can be
105added before finalization.
106.Pp
107If the flag
108.Dv PKCS7_STREAM
109is set, the returned
110.Vt PKCS7
111structure is
112.Sy not
113complete and outputting its contents via a function that does not
114properly finalize the
115.Vt PKCS7
116structure will give unpredictable results.
117.Pp
118Several functions including
119.Xr SMIME_write_PKCS7 3 ,
120.Xr i2d_PKCS7_bio_stream 3 ,
121.Xr PEM_write_bio_PKCS7_stream 3
122finalize the structure.
123Alternatively finalization can be performed by obtaining the streaming
124ASN1
125.Vt BIO
126directly using
127.Xr BIO_new_PKCS7 3 .
128.Pp
129If a signer is specified, it will use the default digest for the
130signing algorithm.
131This is
132.Sy SHA1
133for both RSA and DSA keys.
134.Pp
135In OpenSSL 1.0.0, the
136.Fa certs ,
137.Fa signcert ,
138and
139.Fa pkey
140parameters can all be
141.Dv NULL
142if the
143.Dv PKCS7_PARTIAL
144flag is set.
145One or more signers can be added using the function
146.Xr PKCS7_sign_add_signer 3.
147.Xr PKCS7_final 3
148must also be called to finalize the structure if streaming is not
149enabled.
150Alternative signing digests can also be specified using this method.
151.Pp
152In OpenSSL 1.0.0, if
153.Fa signcert
154and
155.Fa pkey
156are
157.Dv NULL ,
158then a certificates only PKCS#7 structure is output.
159.Pp
160In versions of OpenSSL before 1.0.0 the
161.Fa signcert
162and
163.Fa pkey
164parameters must
165.Sy NOT
166be
167.Dv NULL .
168.Sh RETURN VALUES
169.Fn PKCS7_sign
170returns either a valid
171.Vt PKCS7
172structure or
173.Dv NULL
174if an error occurred.
175The error can be obtained from
176.Fn ERR_get_error 3 .
177.Sh SEE ALSO
178.Xr ERR_get_error 3 ,
179.Xr PKCS7_verify 3
180.Sh HISTORY
181.Fn PKCS7_sign
182was added to OpenSSL 0.9.5.
183.Pp
184The
185.Dv PKCS7_PARTIAL
186and
187.Dv PKCS7_STREAM
188flags were added in OpenSSL 1.0.0.
189.Sh BUGS
190Some advanced attributes such as counter signatures are not supported.