Blame doc/man3/PKCS7_sign.pod

Packit Service 084de1
=pod
Packit Service 084de1
Packit Service 084de1
=head1 NAME
Packit Service 084de1
Packit Service 084de1
PKCS7_sign - create a PKCS#7 signedData structure
Packit Service 084de1
Packit Service 084de1
=head1 SYNOPSIS
Packit Service 084de1
Packit Service 084de1
 #include <openssl/pkcs7.h>
Packit Service 084de1
Packit Service 084de1
 PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
Packit Service 084de1
                   BIO *data, int flags);
Packit Service 084de1
Packit Service 084de1
=head1 DESCRIPTION
Packit Service 084de1
Packit Service 084de1
PKCS7_sign() creates and returns a PKCS#7 signedData structure. B<signcert> is
Packit Service 084de1
the certificate to sign with, B<pkey> is the corresponding private key.
Packit Service 084de1
B<certs> is an optional additional set of certificates to include in the PKCS#7
Packit Service 084de1
structure (for example any intermediate CAs in the chain).
Packit Service 084de1
Packit Service 084de1
The data to be signed is read from BIO B<data>.
Packit Service 084de1
Packit Service 084de1
B<flags> is an optional set of flags.
Packit Service 084de1
Packit Service 084de1
=head1 NOTES
Packit Service 084de1
Packit Service 084de1
Any of the following flags (ored together) can be passed in the B<flags>
Packit Service 084de1
parameter.
Packit Service 084de1
Packit Service 084de1
Many S/MIME clients expect the signed content to include valid MIME headers. If
Packit Service 084de1
the B<PKCS7_TEXT> flag is set MIME headers for type B<text/plain> are prepended
Packit Service 084de1
to the data.
Packit Service 084de1
Packit Service 084de1
If B<PKCS7_NOCERTS> is set the signer's certificate will not be included in the
Packit Service 084de1
PKCS7 structure, the signer's certificate must still be supplied in the
Packit Service 084de1
B<signcert> parameter though. This can reduce the size of the signature if the
Packit Service 084de1
signers certificate can be obtained by other means: for example a previously
Packit Service 084de1
signed message.
Packit Service 084de1
Packit Service 084de1
The data being signed is included in the PKCS7 structure, unless
Packit Service 084de1
B<PKCS7_DETACHED> is set in which case it is omitted. This is used for PKCS7
Packit Service 084de1
detached signatures which are used in S/MIME plaintext signed messages for
Packit Service 084de1
example.
Packit Service 084de1
Packit Service 084de1
Normally the supplied content is translated into MIME canonical format (as
Packit Service 084de1
required by the S/MIME specifications) if B<PKCS7_BINARY> is set no translation
Packit Service 084de1
occurs. This option should be used if the supplied data is in binary format
Packit Service 084de1
otherwise the translation will corrupt it.
Packit Service 084de1
Packit Service 084de1
The signedData structure includes several PKCS#7 authenticatedAttributes
Packit Service 084de1
including the signing time, the PKCS#7 content type and the supported list of
Packit Service 084de1
ciphers in an SMIMECapabilities attribute. If B<PKCS7_NOATTR> is set then no
Packit Service 084de1
authenticatedAttributes will be used. If B<PKCS7_NOSMIMECAP> is set then just
Packit Service 084de1
the SMIMECapabilities are omitted.
Packit Service 084de1
Packit Service 084de1
If present the SMIMECapabilities attribute indicates support for the following
Packit Service 084de1
algorithms: triple DES, 128 bit RC2, 64 bit RC2, DES and 40 bit RC2. If any of
Packit Service 084de1
these algorithms is disabled then it will not be included.
Packit Service 084de1
Packit Service 084de1
If the flags B<PKCS7_STREAM> is set then the returned B<PKCS7> structure is
Packit Service 084de1
just initialized ready to perform the signing operation. The signing is however
Packit Service 084de1
B<not> performed and the data to be signed is not read from the B<data>
Packit Service 084de1
parameter. Signing is deferred until after the data has been written. In this
Packit Service 084de1
way data can be signed in a single pass.
Packit Service 084de1
Packit Service 084de1
If the B<PKCS7_PARTIAL> flag is set a partial B<PKCS7> structure is output to
Packit Service 084de1
which additional signers and capabilities can be added before finalization.
Packit Service 084de1
Packit Service 084de1
=head1 NOTES
Packit Service 084de1
Packit Service 084de1
If the flag B<PKCS7_STREAM> is set the returned B<PKCS7> structure is B<not>
Packit Service 084de1
complete and outputting its contents via a function that does not properly
Packit Service 084de1
finalize the B<PKCS7> structure will give unpredictable results.
Packit Service 084de1
Packit Service 084de1
Several functions including SMIME_write_PKCS7(), i2d_PKCS7_bio_stream(),
Packit Service 084de1
PEM_write_bio_PKCS7_stream() finalize the structure. Alternatively finalization
Packit Service 084de1
can be performed by obtaining the streaming ASN1 B<BIO> directly using
Packit Service 084de1
BIO_new_PKCS7().
Packit Service 084de1
Packit Service 084de1
If a signer is specified it will use the default digest for the signing
Packit Service 084de1
algorithm. This is B<SHA1> for both RSA and DSA keys.
Packit Service 084de1
Packit Service 084de1
The B<certs>, B<signcert> and B<pkey> parameters can all be
Packit Service 084de1
B<NULL> if the B<PKCS7_PARTIAL> flag is set. One or more signers can be added
Packit Service 084de1
using the function PKCS7_sign_add_signer(). PKCS7_final() must also be
Packit Service 084de1
called to finalize the structure if streaming is not enabled. Alternative
Packit Service 084de1
signing digests can also be specified using this method.
Packit Service 084de1
Packit Service 084de1
If B<signcert> and B<pkey> are NULL then a certificates only
Packit Service 084de1
PKCS#7 structure is output.
Packit Service 084de1
Packit Service 084de1
In versions of OpenSSL before 1.0.0 the B<signcert> and B<pkey> parameters must
Packit Service 084de1
B<NOT> be NULL.
Packit Service 084de1
Packit Service 084de1
=head1 BUGS
Packit Service 084de1
Packit Service 084de1
Some advanced attributes such as counter signatures are not supported.
Packit Service 084de1
Packit Service 084de1
=head1 RETURN VALUES
Packit Service 084de1
Packit Service 084de1
PKCS7_sign() returns either a valid PKCS7 structure or NULL if an error
Packit Service 084de1
occurred.  The error can be obtained from ERR_get_error(3).
Packit Service 084de1
Packit Service 084de1
=head1 SEE ALSO
Packit Service 084de1
Packit Service 084de1
L<ERR_get_error(3)>, L<PKCS7_verify(3)>
Packit Service 084de1
Packit Service 084de1
=head1 HISTORY
Packit Service 084de1
Packit Service 084de1
The B<PKCS7_PARTIAL> flag, and the ability for B<certs>, B<signcert>,
Packit Service 084de1
and B<pkey> parameters to be B<NULL> were added in OpenSSL 1.0.0.
Packit Service 084de1
Packit Service 084de1
The B<PKCS7_STREAM> flag was added in OpenSSL 1.0.0.
Packit Service 084de1
Packit Service 084de1
=head1 COPYRIGHT
Packit Service 084de1
Packit Service 084de1
Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
Packit Service 084de1
Packit Service 084de1
Licensed under the OpenSSL license (the "License").  You may not use
Packit Service 084de1
this file except in compliance with the License.  You can obtain a copy
Packit Service 084de1
in the file LICENSE in the source distribution or at
Packit Service 084de1
L<https://www.openssl.org/source/license.html>.
Packit Service 084de1
Packit Service 084de1
=cut