1PKCS7_SIGN(3)                       OpenSSL                      PKCS7_SIGN(3)
2
3
4

NAME

6       PKCS7_sign - create a PKCS#7 signedData structure
7

SYNOPSIS

9        #include <openssl/pkcs7.h>
10
11        PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
12                          BIO *data, int flags);
13

DESCRIPTION

15       PKCS7_sign() creates and returns a PKCS#7 signedData structure.
16       signcert is the certificate to sign with, pkey is the corresponding
17       private key.  certs is an optional additional set of certificates to
18       include in the PKCS#7 structure (for example any intermediate CAs in
19       the chain).
20
21       The data to be signed is read from BIO data.
22
23       flags is an optional set of flags.
24

NOTES

26       Any of the following flags (ored together) can be passed in the flags
27       parameter.
28
29       Many S/MIME clients expect the signed content to include valid MIME
30       headers. If the PKCS7_TEXT flag is set MIME headers for type text/plain
31       are prepended to the data.
32
33       If PKCS7_NOCERTS is set the signer's certificate will not be included
34       in the PKCS7 structure, the signer's certificate must still be supplied
35       in the signcert parameter though. This can reduce the size of the
36       signature if the signers certificate can be obtained by other means:
37       for example a previously signed message.
38
39       The data being signed is included in the PKCS7 structure, unless
40       PKCS7_DETACHED is set in which case it is omitted. This is used for
41       PKCS7 detached signatures which are used in S/MIME plaintext signed
42       messages for example.
43
44       Normally the supplied content is translated into MIME canonical format
45       (as required by the S/MIME specifications) if PKCS7_BINARY is set no
46       translation occurs. This option should be used if the supplied data is
47       in binary format otherwise the translation will corrupt it.
48
49       The signedData structure includes several PKCS#7
50       authenticatedAttributes including the signing time, the PKCS#7 content
51       type and the supported list of ciphers in an SMIMECapabilities
52       attribute. If PKCS7_NOATTR is set then no authenticatedAttributes will
53       be used. If PKCS7_NOSMIMECAP is set then just the SMIMECapabilities are
54       omitted.
55
56       If present the SMIMECapabilities attribute indicates support for the
57       following algorithms: triple DES, 128 bit RC2, 64 bit RC2, DES and 40
58       bit RC2. If any of these algorithms is disabled then it will not be
59       included.
60
61       If the flags PKCS7_STREAM is set then the returned PKCS7 structure is
62       just initialized ready to perform the signing operation. The signing is
63       however not performed and the data to be signed is not read from the
64       data parameter. Signing is deferred until after the data has been
65       written. In this way data can be signed in a single pass.
66
67       If the PKCS7_PARTIAL flag is set a partial PKCS7 structure is output to
68       which additional signers and capabilities can be added before
69       finalization.
70

NOTES

72       If the flag PKCS7_STREAM is set the returned PKCS7 structure is not
73       complete and outputting its contents via a function that does not
74       properly finalize the PKCS7 structure will give unpredictable results.
75
76       Several functions including SMIME_write_PKCS7(),
77       i2d_PKCS7_bio_stream(), PEM_write_bio_PKCS7_stream() finalize the
78       structure. Alternatively finalization can be performed by obtaining the
79       streaming ASN1 BIO directly using BIO_new_PKCS7().
80
81       If a signer is specified it will use the default digest for the signing
82       algorithm. This is SHA1 for both RSA and DSA keys.
83
84       The certs, signcert and pkey parameters can all be NULL if the
85       PKCS7_PARTIAL flag is set. One or more signers can be added using the
86       function PKCS7_sign_add_signer(). PKCS7_final() must also be called to
87       finalize the structure if streaming is not enabled. Alternative signing
88       digests can also be specified using this method.
89
90       If signcert and pkey are NULL then a certificates only PKCS#7 structure
91       is output.
92
93       In versions of OpenSSL before 1.0.0 the signcert and pkey parameters
94       must NOT be NULL.
95

BUGS

97       Some advanced attributes such as counter signatures are not supported.
98

RETURN VALUES

100       PKCS7_sign() returns either a valid PKCS7 structure or NULL if an error
101       occurred.  The error can be obtained from ERR_get_error(3).
102

SEE ALSO

104       ERR_get_error(3), PKCS7_verify(3)
105

HISTORY

107       The PKCS7_PARTIAL flag, and the ability for certs, signcert, and pkey
108       parameters to be NULL were added in OpenSSL 1.0.0.
109
110       The PKCS7_STREAM flag was added in OpenSSL 1.0.0.
111
113       Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
114
115       Licensed under the OpenSSL license (the "License").  You may not use
116       this file except in compliance with the License.  You can obtain a copy
117       in the file LICENSE in the source distribution or at
118       <https://www.openssl.org/source/license.html>.
119
120
121
1221.1.1k                            2021-03-26                     PKCS7_SIGN(3)
Impressum