xref: /netbsd-src/crypto/external/bsd/openssl/dist/doc/man3/CMS_verify.pod (revision b0d1725196a7921d003d2c66a14f186abda4176b)
113d40330Schristos=pod
213d40330Schristos
313d40330Schristos=head1 NAME
413d40330Schristos
513d40330SchristosCMS_verify, CMS_get0_signers - verify a CMS SignedData structure
613d40330Schristos
713d40330Schristos=head1 SYNOPSIS
813d40330Schristos
913d40330Schristos #include <openssl/cms.h>
1013d40330Schristos
1113d40330Schristos int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs, X509_STORE *store,
1213d40330Schristos                BIO *indata, BIO *out, unsigned int flags);
1313d40330Schristos
1413d40330Schristos STACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms);
1513d40330Schristos
1613d40330Schristos=head1 DESCRIPTION
1713d40330Schristos
186f6db51eSchristosCMS_verify() is very similar to L<PKCS7_verify(3)>. It verifies a
196f6db51eSchristosB<CMS SignedData> structure contained in a structure of type B<CMS_ContentInfo>.
206f6db51eSchristosI<cms> points to the B<CMS_ContentInfo> structure to verify.
216f6db51eSchristosThe optional I<certs> parameter refers to a set of certificates
226f6db51eSchristosin which to search for signing certificates.
236f6db51eSchristosI<cms> may contain extra untrusted CA certificates that may be used for
246f6db51eSchristoschain building as well as CRLs that may be used for certificate validation.
256f6db51eSchristosI<store> may be NULL or point to
266f6db51eSchristosthe trusted certificate store to use for chain verification.
276f6db51eSchristosI<indata> refers to the signed data if the content is detached from I<cms>.
286f6db51eSchristosOtherwise I<indata> should be NULL and the signed data must be in I<cms>.
296f6db51eSchristosThe content is written to the BIO I<out> unless it is NULL.
306f6db51eSchristosI<flags> is an optional set of flags, which can be used to modify the operation.
3113d40330Schristos
326f6db51eSchristosCMS_get0_signers() retrieves the signing certificate(s) from I<cms>, it may only
3313d40330Schristosbe called after a successful CMS_verify() operation.
3413d40330Schristos
3513d40330Schristos=head1 VERIFY PROCESS
3613d40330Schristos
3713d40330SchristosNormally the verify process proceeds as follows.
3813d40330Schristos
396f6db51eSchristosInitially some sanity checks are performed on I<cms>. The type of I<cms> must
4013d40330Schristosbe SignedData. There must be at least one signature on the data and if
416f6db51eSchristosthe content is detached I<indata> cannot be NULL.
4213d40330Schristos
4313d40330SchristosAn attempt is made to locate all the signing certificate(s), first looking in
446f6db51eSchristosthe I<certs> parameter (if it is not NULL) and then looking in any
456f6db51eSchristoscertificates contained in the I<cms> structure unless B<CMS_NOINTERN> is set.
466f6db51eSchristosIf any signing certificate cannot be located the operation fails.
4713d40330Schristos
486f6db51eSchristosEach signing certificate is chain verified using the I<smimesign> purpose and
496f6db51eSchristosusing the trusted certificate store I<store> if supplied.
506f6db51eSchristosAny internal certificates in the message, which may have been added using
516f6db51eSchristosL<CMS_add1_cert(3)>, are used as untrusted CAs.
526f6db51eSchristosIf CRL checking is enabled in I<store> and B<CMS_NOCRL> is not set,
536f6db51eSchristosany internal CRLs, which may have been added using L<CMS_add1_crl(3)>,
546f6db51eSchristosare used in addition to attempting to look them up in I<store>.
556f6db51eSchristosIf I<store> is not NULL and any chain verify fails an error code is returned.
5613d40330Schristos
576f6db51eSchristosFinally the signed content is read (and written to I<out> unless it is NULL)
586f6db51eSchristosand the signature is checked.
5913d40330Schristos
606f6db51eSchristosIf all signatures verify correctly then the function is successful.
6113d40330Schristos
626f6db51eSchristosAny of the following flags (ored together) can be passed in the I<flags>
6313d40330Schristosparameter to change the default verify behaviour.
6413d40330Schristos
6513d40330SchristosIf B<CMS_NOINTERN> is set the certificates in the message itself are not
666f6db51eSchristossearched when locating the signing certificate(s).
676f6db51eSchristosThis means that all the signing certificates must be in the I<certs> parameter.
6813d40330Schristos
696f6db51eSchristosIf B<CMS_NOCRL> is set and CRL checking is enabled in I<store> then any
7013d40330SchristosCRLs in the message itself are ignored.
7113d40330Schristos
7213d40330SchristosIf the B<CMS_TEXT> flag is set MIME headers for type B<text/plain> are deleted
7313d40330Schristosfrom the content. If the content is not of type B<text/plain> then an error is
7413d40330Schristosreturned.
7513d40330Schristos
7613d40330SchristosIf B<CMS_NO_SIGNER_CERT_VERIFY> is set the signing certificates are not
77*b0d17251Schristoschain verified, unless B<CMS_CADES> flag is also set.
7813d40330Schristos
7913d40330SchristosIf B<CMS_NO_ATTR_VERIFY> is set the signed attributes signature is not
80*b0d17251Schristosverified, unless CMS_CADES flag is also set.
81*b0d17251Schristos
82*b0d17251SchristosIf B<CMS_CADES> is set, each signer certificate is checked against the
83*b0d17251SchristosESS signingCertificate or ESS signingCertificateV2 extension
84*b0d17251Schristosthat is required in the signed attributes of the signature.
8513d40330Schristos
8613d40330SchristosIf B<CMS_NO_CONTENT_VERIFY> is set then the content digest is not checked.
8713d40330Schristos
8813d40330Schristos=head1 NOTES
8913d40330Schristos
9013d40330SchristosOne application of B<CMS_NOINTERN> is to only accept messages signed by
9113d40330Schristosa small number of certificates. The acceptable certificates would be passed
926f6db51eSchristosin the I<certs> parameter. In this case if the signer certificate is not one
936f6db51eSchristosof the certificates supplied in I<certs> then the verify will fail because the
9413d40330Schristossigner cannot be found.
9513d40330Schristos
9613d40330SchristosIn some cases the standard techniques for looking up and validating
9713d40330Schristoscertificates are not appropriate: for example an application may wish to
9813d40330Schristoslookup certificates in a database or perform customised verification. This
996f6db51eSchristoscan be achieved by setting and verifying the signer certificates manually
10013d40330Schristosusing the signed data utility functions.
10113d40330Schristos
10213d40330SchristosCare should be taken when modifying the default verify behaviour, for example
10313d40330Schristossetting B<CMS_NO_CONTENT_VERIFY> will totally disable all content verification
10413d40330Schristosand any modified content will be considered valid. This combination is however
1056f6db51eSchristosuseful if one merely wishes to write the content to I<out> and its validity
10613d40330Schristosis not considered important.
10713d40330Schristos
10813d40330SchristosChain verification should arguably be performed using the signing time rather
109f30e0929Schristosthan the current time. However, since the signing time is supplied by the
11013d40330Schristossigner it cannot be trusted without additional evidence (such as a trusted
11113d40330Schristostimestamp).
11213d40330Schristos
11313d40330Schristos=head1 RETURN VALUES
11413d40330Schristos
1156f6db51eSchristosCMS_verify() returns 1 for a successful verification and 0 if an error occurred.
11613d40330Schristos
11713d40330SchristosCMS_get0_signers() returns all signers or NULL if an error occurred.
11813d40330Schristos
11913d40330SchristosThe error can be obtained from L<ERR_get_error(3)>
12013d40330Schristos
12113d40330Schristos=head1 BUGS
12213d40330Schristos
1236f6db51eSchristosThe trusted certificate store is not searched for the signing certificate.
1246f6db51eSchristosThis is primarily due to the inadequacies of the current B<X509_STORE>
12513d40330Schristosfunctionality.
12613d40330Schristos
12713d40330SchristosThe lack of single pass processing means that the signed content must all
12813d40330Schristosbe held in memory if it is not detached.
12913d40330Schristos
13013d40330Schristos=head1 SEE ALSO
13113d40330Schristos
1326f6db51eSchristosL<PKCS7_verify(3)>, L<CMS_add1_cert(3)>, L<CMS_add1_crl(3)>,
1336f6db51eSchristosL<OSSL_ESS_check_signing_certs(3)>,
13413d40330SchristosL<ERR_get_error(3)>, L<CMS_sign(3)>
13513d40330Schristos
13613d40330Schristos=head1 COPYRIGHT
13713d40330Schristos
1386f6db51eSchristosCopyright 2008-2022 The OpenSSL Project Authors. All Rights Reserved.
13913d40330Schristos
140*b0d17251SchristosLicensed under the Apache License 2.0 (the "License").  You may not use
14113d40330Schristosthis file except in compliance with the License.  You can obtain a copy
14213d40330Schristosin the file LICENSE in the source distribution or at
14313d40330SchristosL<https://www.openssl.org/source/license.html>.
14413d40330Schristos
14513d40330Schristos=cut
146