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, BIO *data, int flags);
12

DESCRIPTION

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

NOTES

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

NOTES

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

BUGS

95       Some advanced attributes such as counter signatures are not supported.
96

RETURN VALUES

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

SEE ALSO

102       ERR_get_error(3), PKCS7_verify(3)
103

HISTORY

105       PKCS7_sign() was added to OpenSSL 0.9.5
106
107       The PKCS7_PARTIAL flag was added in OpenSSL 1.0.0
108
109       The PKCS7_STREAM flag was added in OpenSSL 1.0.0
110
111
112
1131.0.2o                            2020-08-01                     PKCS7_sign(3)
Impressum