Blame doc/man3/CMS_verify.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
CMS_verify, CMS_get0_signers - verify a CMS SignedData structure
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
 #include <openssl/cms.h>
Packit c4476c
Packit c4476c
 int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs, X509_STORE *store,
Packit c4476c
                BIO *indata, BIO *out, unsigned int flags);
Packit c4476c
Packit c4476c
 STACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms);
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
CMS_verify() verifies a CMS SignedData structure. B<cms> is the CMS_ContentInfo
Packit c4476c
structure to verify. B<certs> is a set of certificates in which to search for
Packit c4476c
the signing certificate(s). B<store> is a trusted certificate store used for
Packit c4476c
chain verification. B<indata> is the detached content if the content is not
Packit c4476c
present in B<cms>. The content is written to B<out> if it is not NULL.
Packit c4476c
Packit c4476c
B<flags> is an optional set of flags, which can be used to modify the verify
Packit c4476c
operation.
Packit c4476c
Packit c4476c
CMS_get0_signers() retrieves the signing certificate(s) from B<cms>, it must
Packit c4476c
be called after a successful CMS_verify() operation.
Packit c4476c
Packit c4476c
=head1 VERIFY PROCESS
Packit c4476c
Packit c4476c
Normally the verify process proceeds as follows.
Packit c4476c
Packit c4476c
Initially some sanity checks are performed on B<cms>. The type of B<cms> must
Packit c4476c
be SignedData. There must be at least one signature on the data and if
Packit c4476c
the content is detached B<indata> cannot be B<NULL>.
Packit c4476c
Packit c4476c
An attempt is made to locate all the signing certificate(s), first looking in
Packit c4476c
the B<certs> parameter (if it is not NULL) and then looking in any
Packit c4476c
certificates contained in the B<cms> structure itself. If any signing
Packit c4476c
certificate cannot be located the operation fails.
Packit c4476c
Packit c4476c
Each signing certificate is chain verified using the B<smimesign> purpose and
Packit c4476c
the supplied trusted certificate store. Any internal certificates in the message
Packit c4476c
are used as untrusted CAs. If CRL checking is enabled in B<store> any internal
Packit c4476c
CRLs are used in addition to attempting to look them up in B<store>. If any
Packit c4476c
chain verify fails an error code is returned.
Packit c4476c
Packit c4476c
Finally the signed content is read (and written to B<out> if it is not NULL)
Packit c4476c
and the signature's checked.
Packit c4476c
Packit c4476c
If all signature's verify correctly then the function is successful.
Packit c4476c
Packit c4476c
Any of the following flags (ored together) can be passed in the B<flags>
Packit c4476c
parameter to change the default verify behaviour.
Packit c4476c
Packit c4476c
If B<CMS_NOINTERN> is set the certificates in the message itself are not
Packit c4476c
searched when locating the signing certificate(s). This means that all the
Packit c4476c
signing certificates must be in the B<certs> parameter.
Packit c4476c
Packit c4476c
If B<CMS_NOCRL> is set and CRL checking is enabled in B<store> then any
Packit c4476c
CRLs in the message itself are ignored.
Packit c4476c
Packit c4476c
If the B<CMS_TEXT> flag is set MIME headers for type B<text/plain> are deleted
Packit c4476c
from the content. If the content is not of type B<text/plain> then an error is
Packit c4476c
returned.
Packit c4476c
Packit c4476c
If B<CMS_NO_SIGNER_CERT_VERIFY> is set the signing certificates are not
Packit c4476c
verified.
Packit c4476c
Packit c4476c
If B<CMS_NO_ATTR_VERIFY> is set the signed attributes signature is not
Packit c4476c
verified.
Packit c4476c
Packit c4476c
If B<CMS_NO_CONTENT_VERIFY> is set then the content digest is not checked.
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
One application of B<CMS_NOINTERN> is to only accept messages signed by
Packit c4476c
a small number of certificates. The acceptable certificates would be passed
Packit c4476c
in the B<certs> parameter. In this case if the signer is not one of the
Packit c4476c
certificates supplied in B<certs> then the verify will fail because the
Packit c4476c
signer cannot be found.
Packit c4476c
Packit c4476c
In some cases the standard techniques for looking up and validating
Packit c4476c
certificates are not appropriate: for example an application may wish to
Packit c4476c
lookup certificates in a database or perform customised verification. This
Packit c4476c
can be achieved by setting and verifying the signers certificates manually
Packit c4476c
using the signed data utility functions.
Packit c4476c
Packit c4476c
Care should be taken when modifying the default verify behaviour, for example
Packit c4476c
setting B<CMS_NO_CONTENT_VERIFY> will totally disable all content verification
Packit c4476c
and any modified content will be considered valid. This combination is however
Packit c4476c
useful if one merely wishes to write the content to B<out> and its validity
Packit c4476c
is not considered important.
Packit c4476c
Packit c4476c
Chain verification should arguably be performed using the signing time rather
Packit c4476c
than the current time. However since the signing time is supplied by the
Packit c4476c
signer it cannot be trusted without additional evidence (such as a trusted
Packit c4476c
timestamp).
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
CMS_verify() returns 1 for a successful verification and zero if an error
Packit c4476c
occurred.
Packit c4476c
Packit c4476c
CMS_get0_signers() returns all signers or NULL if an error occurred.
Packit c4476c
Packit c4476c
The error can be obtained from L<ERR_get_error(3)>
Packit c4476c
Packit c4476c
=head1 BUGS
Packit c4476c
Packit c4476c
The trusted certificate store is not searched for the signing certificate,
Packit c4476c
this is primarily due to the inadequacies of the current B<X509_STORE>
Packit c4476c
functionality.
Packit c4476c
Packit c4476c
The lack of single pass processing means that the signed content must all
Packit c4476c
be held in memory if it is not detached.
Packit c4476c
Packit c4476c
=head1 SEE ALSO
Packit c4476c
Packit c4476c
L<ERR_get_error(3)>, L<CMS_sign(3)>
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2008-2019 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut