Initial import from FreeBSD RELENG_4:
[dragonfly.git] / secure / lib / libcrypto / man / PKCS7_verify.3
1 .\" Automatically generated by Pod::Man version 1.15
2 .\" Wed Feb 19 16:42:56 2003
3 .\"
4 .\" Standard preamble:
5 .\" ======================================================================
6 .de Sh \" Subsection heading
7 .br
8 .if t .Sp
9 .ne 5
10 .PP
11 \fB\\$1\fR
12 .PP
13 ..
14 .de Sp \" Vertical space (when we can't use .PP)
15 .if t .sp .5v
16 .if n .sp
17 ..
18 .de Ip \" List item
19 .br
20 .ie \\n(.$>=3 .ne \\$3
21 .el .ne 3
22 .IP "\\$1" \\$2
23 ..
24 .de Vb \" Begin verbatim text
25 .ft CW
26 .nf
27 .ne \\$1
28 ..
29 .de Ve \" End verbatim text
30 .ft R
31
32 .fi
33 ..
34 .\" Set up some character translations and predefined strings.  \*(-- will
35 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
36 .\" double quote, and \*(R" will give a right double quote.  | will give a
37 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used
38 .\" to do unbreakable dashes and therefore won't be available.  \*(C` and
39 .\" \*(C' expand to `' in nroff, nothing in troff, for use with C<>
40 .tr \(*W-|\(bv\*(Tr
41 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
42 .ie n \{\
43 .    ds -- \(*W-
44 .    ds PI pi
45 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
46 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
47 .    ds L" ""
48 .    ds R" ""
49 .    ds C` ""
50 .    ds C' ""
51 'br\}
52 .el\{\
53 .    ds -- \|\(em\|
54 .    ds PI \(*p
55 .    ds L" ``
56 .    ds R" ''
57 'br\}
58 .\"
59 .\" If the F register is turned on, we'll generate index entries on stderr
60 .\" for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and
61 .\" index entries marked with X<> in POD.  Of course, you'll have to process
62 .\" the output yourself in some meaningful fashion.
63 .if \nF \{\
64 .    de IX
65 .    tm Index:\\$1\t\\n%\t"\\$2"
66 ..
67 .    nr % 0
68 .    rr F
69 .\}
70 .\"
71 .\" For nroff, turn off justification.  Always turn off hyphenation; it
72 .\" makes way too many mistakes in technical documents.
73 .hy 0
74 .if n .na
75 .\"
76 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
77 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
78 .bd B 3
79 .    \" fudge factors for nroff and troff
80 .if n \{\
81 .    ds #H 0
82 .    ds #V .8m
83 .    ds #F .3m
84 .    ds #[ \f1
85 .    ds #] \fP
86 .\}
87 .if t \{\
88 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
89 .    ds #V .6m
90 .    ds #F 0
91 .    ds #[ \&
92 .    ds #] \&
93 .\}
94 .    \" simple accents for nroff and troff
95 .if n \{\
96 .    ds ' \&
97 .    ds ` \&
98 .    ds ^ \&
99 .    ds , \&
100 .    ds ~ ~
101 .    ds /
102 .\}
103 .if t \{\
104 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
105 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
106 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
107 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
108 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
109 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
110 .\}
111 .    \" troff and (daisy-wheel) nroff accents
112 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
113 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
114 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
115 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
116 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
117 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
118 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
119 .ds ae a\h'-(\w'a'u*4/10)'e
120 .ds Ae A\h'-(\w'A'u*4/10)'E
121 .    \" corrections for vroff
122 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
123 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
124 .    \" for low resolution devices (crt and lpr)
125 .if \n(.H>23 .if \n(.V>19 \
126 \{\
127 .    ds : e
128 .    ds 8 ss
129 .    ds o a
130 .    ds d- d\h'-1'\(ga
131 .    ds D- D\h'-1'\(hy
132 .    ds th \o'bp'
133 .    ds Th \o'LP'
134 .    ds ae ae
135 .    ds Ae AE
136 .\}
137 .rm #[ #] #H #V #F C
138 .\" ======================================================================
139 .\"
140 .IX Title "PKCS7_verify 3"
141 .TH PKCS7_verify 3 "0.9.7a" "2003-02-19" "OpenSSL"
142 .UC
143 .SH "NAME"
144 PKCS7_verify \- verify a PKCS#7 signedData structure
145 .SH "SYNOPSIS"
146 .IX Header "SYNOPSIS"
147 int PKCS7_verify(\s-1PKCS7\s0 *p7, STACK_OF(X509) *certs, X509_STORE *store, \s-1BIO\s0 *indata, \s-1BIO\s0 *out, int flags);
148 .PP
149 int PKCS7_get0_signers(\s-1PKCS7\s0 *p7, STACK_OF(X509) *certs, int flags);
150 .SH "DESCRIPTION"
151 .IX Header "DESCRIPTION"
152 \&\fIPKCS7_verify()\fR verifies a PKCS#7 signedData structure. \fBp7\fR is the \s-1PKCS7\s0
153 structure to verify. \fBcerts\fR is a set of certificates in which to search for
154 the signer's certificate. \fBstore\fR is a trusted certficate store (used for
155 chain verification). \fBindata\fR is the signed data if the content is not
156 present in \fBp7\fR (that is it is detached). The content is written to \fBout\fR
157 if it is not \s-1NULL\s0.
158 .PP
159 \&\fBflags\fR is an optional set of flags, which can be used to modify the verify
160 operation.
161 .PP
162 \&\fIPKCS7_get0_signers()\fR retrieves the signer's certificates from \fBp7\fR, it does
163 \&\fBnot\fR check their validity or whether any signatures are valid. The \fBcerts\fR
164 and \fBflags\fR parameters have the same meanings as in \fIPKCS7_verify()\fR.
165 .SH "VERIFY PROCESS"
166 .IX Header "VERIFY PROCESS"
167 Normally the verify process proceeds as follows.
168 .PP
169 Initially some sanity checks are performed on \fBp7\fR. The type of \fBp7\fR must
170 be signedData. There must be at least one signature on the data and if
171 the content is detached \fBindata\fR cannot be \fB\s-1NULL\s0\fR.
172 .PP
173 An attempt is made to locate all the signer's certificates, first looking in
174 the \fBcerts\fR parameter (if it is not \fB\s-1NULL\s0\fR) and then looking in any certificates
175 contained in the \fBp7\fR structure itself. If any signer's certificates cannot be
176 located the operation fails.
177 .PP
178 Each signer's certificate is chain verified using the \fBsmimesign\fR purpose and
179 the supplied trusted certificate store. Any internal certificates in the message
180 are used as untrusted CAs. If any chain verify fails an error code is returned.
181 .PP
182 Finally the signed content is read (and written to \fBout\fR is it is not \s-1NULL\s0) and
183 the signature's checked.
184 .PP
185 If all signature's verify correctly then the function is successful.
186 .PP
187 Any of the following flags (ored together) can be passed in the \fBflags\fR parameter
188 to change the default verify behaviour. Only the flag \fB\s-1PKCS7_NOINTERN\s0\fR is
189 meaningful to \fIPKCS7_get0_signers()\fR.
190 .PP
191 If \fB\s-1PKCS7_NOINTERN\s0\fR is set the certificates in the message itself are not 
192 searched when locating the signer's certificate. This means that all the signers
193 certificates must be in the \fBcerts\fR parameter.
194 .PP
195 If the \fB\s-1PKCS7_TEXT\s0\fR flag is set \s-1MIME\s0 headers for type \fBtext/plain\fR are deleted
196 from the content. If the content is not of type \fBtext/plain\fR then an error is
197 returned.
198 .PP
199 If \fB\s-1PKCS7_NOVERIFY\s0\fR is set the signer's certificates are not chain verified.
200 .PP
201 If \fB\s-1PKCS7_NOCHAIN\s0\fR is set then the certificates contained in the message are
202 not used as untrusted CAs. This means that the whole verify chain (apart from
203 the signer's certificate) must be contained in the trusted store.
204 .PP
205 If \fB\s-1PKCS7_NOSIGS\s0\fR is set then the signatures on the data are not checked.
206 .SH "NOTES"
207 .IX Header "NOTES"
208 One application of \fB\s-1PKCS7_NOINTERN\s0\fR is to only accept messages signed by
209 a small number of certificates. The acceptable certificates would be passed
210 in the \fBcerts\fR parameter. In this case if the signer is not one of the
211 certificates supplied in \fBcerts\fR then the verify will fail because the
212 signer cannot be found.
213 .PP
214 Care should be taken when modifying the default verify behaviour, for example
215 setting \fBPKCS7_NOVERIFY|PKCS7_NOSIGS\fR will totally disable all verification 
216 and any signed message will be considered valid. This combination is however
217 useful if one merely wishes to write the content to \fBout\fR and its validity
218 is not considered important.
219 .PP
220 Chain verification should arguably be performed  using the signing time rather
221 than the current time. However since the signing time is supplied by the
222 signer it cannot be trusted without additional evidence (such as a trusted
223 timestamp).
224 .SH "RETURN VALUES"
225 .IX Header "RETURN VALUES"
226 \&\fIPKCS7_verify()\fR returns 1 for a successful verification and zero or a negative
227 value if an error occurs.
228 .PP
229 \&\fIPKCS7_get0_signers()\fR returns all signers or \fB\s-1NULL\s0\fR if an error occurred.
230 .PP
231 The error can be obtained from ERR_get_error(3)
232 .SH "BUGS"
233 .IX Header "BUGS"
234 The trusted certificate store is not searched for the signers certificate,
235 this is primarily due to the inadequacies of the current \fBX509_STORE\fR
236 functionality.
237 .PP
238 The lack of single pass processing and need to hold all data in memory as
239 mentioned in \fIPKCS7_sign()\fR also applies to \fIPKCS7_verify()\fR.
240 .SH "SEE ALSO"
241 .IX Header "SEE ALSO"
242 ERR_get_error(3), PKCS7_sign(3)
243 .SH "HISTORY"
244 .IX Header "HISTORY"
245 \&\fIPKCS7_verify()\fR was added to OpenSSL 0.9.5