2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 // AppleX509CLSession.h - general CL session functions.
22 #ifndef _H_APPLEX509CLSESSION
23 #define _H_APPLEX509CLSESSION
25 #include <Security/CLsession.h>
26 #include "CLCachedEntry.h"
27 #include "DecodedCert.h"
28 #include "LockedMap.h"
29 #include <Security/threading.h>
30 #include <Security/cssmapple.h>
32 class AppleX509CLSession
: public CLPluginSession
{
37 CSSM_MODULE_HANDLE theHandle
,
39 const CSSM_VERSION
&version
,
41 CSSM_SERVICE_TYPE subserviceType
,
42 CSSM_ATTACH_FLAGS attachFlags
,
43 const CSSM_UPCALLS
&upcalls
);
45 ~AppleX509CLSession();
47 // ====================================================================
48 // Cert Interpretation
49 // ====================================================================
51 void CertDescribeFormat(
52 uint32
&NumberOfFields
,
53 CSSM_OID_PTR
&OidList
);
57 void CertGetAllFields(
59 uint32
&NumberOfFields
,
60 CSSM_FIELD_PTR
&CertFields
);
62 CSSM_HANDLE
CertGetFirstFieldValue(
64 const CssmData
&CertField
,
65 uint32
&NumberOfMatchedFields
,
66 CSSM_DATA_PTR
&Value
);
68 bool CertGetNextFieldValue(
69 CSSM_HANDLE ResultsHandle
,
70 CSSM_DATA_PTR
&Value
);
77 CSSM_HANDLE
&CertHandle
);
79 CSSM_HANDLE
CertGetFirstCachedFieldValue(
80 CSSM_HANDLE CertHandle
,
81 const CssmData
&CertField
,
82 uint32
&NumberOfMatchedFields
,
83 CSSM_DATA_PTR
&Value
);
85 bool CertGetNextCachedFieldValue(
86 CSSM_HANDLE ResultsHandle
,
87 CSSM_DATA_PTR
&Value
);
90 CSSM_HANDLE CertHandle
);
93 CSSM_HANDLE ResultsHandle
);
99 void CertCreateTemplate(
100 uint32 NumberOfFields
,
101 const CSSM_FIELD CertFields
[],
102 CssmData
&CertTemplate
);
104 void CertGetAllTemplateFields(
105 const CssmData
&CertTemplate
,
106 uint32
&NumberOfFields
,
107 CSSM_FIELD_PTR
&CertFields
);
113 uint32 NumberOfFields
,
114 CSSM_FIELD_PTR
&FieldArray
);
116 const CssmData
&CertOrCrlOid
,
122 const CssmData
&Cert
,
125 // ====================================================================
126 // CRL Interpretation
127 // ====================================================================
131 void CrlDescribeFormat(
132 uint32
&NumberOfFields
,
133 CSSM_OID_PTR
&OidList
);
135 void CrlGetAllFields(
137 uint32
&NumberOfCrlFields
,
138 CSSM_FIELD_PTR
&CrlFields
);
140 CSSM_HANDLE
CrlGetFirstFieldValue(
142 const CssmData
&CrlField
,
143 uint32
&NumberOfMatchedFields
,
144 CSSM_DATA_PTR
&Value
);
146 bool CrlGetNextFieldValue(
147 CSSM_HANDLE ResultsHandle
,
148 CSSM_DATA_PTR
&Value
);
151 const CssmData
&Cert
,
153 CSSM_BOOL
&CertFound
);
160 CSSM_HANDLE
&CrlHandle
);
162 void CrlGetAllCachedRecordFields(CSSM_HANDLE CrlHandle
,
163 const CssmData
&CrlRecordIndex
,
164 uint32
&NumberOfFields
,
165 CSSM_FIELD_PTR
&CrlFields
);
167 CSSM_HANDLE
CrlGetFirstCachedFieldValue(
168 CSSM_HANDLE CrlHandle
,
169 const CssmData
*CrlRecordIndex
,
170 const CssmData
&CrlField
,
171 uint32
&NumberOfMatchedFields
,
172 CSSM_DATA_PTR
&Value
);
174 bool CrlGetNextCachedFieldValue(
175 CSSM_HANDLE ResultsHandle
,
176 CSSM_DATA_PTR
&Value
);
178 void IsCertInCachedCrl(
179 const CssmData
&Cert
,
180 CSSM_HANDLE CrlHandle
,
181 CSSM_BOOL
&CertFound
,
182 CssmData
&CrlRecordIndex
);
185 CSSM_HANDLE CrlHandle
);
188 CSSM_HANDLE ResultsHandle
);
193 void CrlCreateTemplate(
194 uint32 NumberOfFields
,
195 const CSSM_FIELD
*CrlTemplate
,
199 uint32 NumberOfFields
,
200 const CSSM_FIELD
*CrlTemplate
,
201 const CssmData
&OldCrl
,
202 CssmData
&ModifiedCrl
);
205 CSSM_CC_HANDLE CCHandle
,
206 const CssmData
&Cert
,
207 uint32 NumberOfFields
,
208 const CSSM_FIELD CrlEntryFields
[],
209 const CssmData
&OldCrl
,
213 const CssmData
&Cert
,
214 const CssmData
&OldCrl
,
217 // ====================================================================
219 // ====================================================================
223 void CertVerifyWithKey(
224 CSSM_CC_HANDLE CCHandle
,
225 const CssmData
&CertToBeVerified
);
228 CSSM_CC_HANDLE CCHandle
,
229 const CssmData
&CertToBeVerified
,
230 const CssmData
*SignerCert
,
231 const CSSM_FIELD
*VerifyScope
,
235 CSSM_CC_HANDLE CCHandle
,
236 const CssmData
&CertTemplate
,
237 const CSSM_FIELD
*SignScope
,
239 CssmData
&SignedCert
);
243 void CertGroupFromVerifiedBundle(
244 CSSM_CC_HANDLE CCHandle
,
245 const CSSM_CERT_BUNDLE
&CertBundle
,
246 const CssmData
*SignerCert
,
247 CSSM_CERTGROUP_PTR
&CertGroup
);
249 void CertGroupToSignedBundle(
250 CSSM_CC_HANDLE CCHandle
,
251 const CSSM_CERTGROUP
&CertGroupToBundle
,
252 const CSSM_CERT_BUNDLE_HEADER
*BundleInfo
,
253 CssmData
&SignedBundle
);
257 void CrlVerifyWithKey(
258 CSSM_CC_HANDLE CCHandle
,
259 const CssmData
&CrlToBeVerified
);
262 CSSM_CC_HANDLE CCHandle
,
263 const CssmData
&CrlToBeVerified
,
264 const CssmData
*SignerCert
,
265 const CSSM_FIELD
*VerifyScope
,
269 CSSM_CC_HANDLE CCHandle
,
270 const CssmData
&UnsignedCrl
,
271 const CSSM_FIELD
*SignScope
,
273 CssmData
&SignedCrl
);
275 // ====================================================================
276 // Module Specific Pass-Through
277 // ====================================================================
280 CSSM_CC_HANDLE CCHandle
,
281 uint32 PassThroughId
,
282 const void *InputParams
,
283 void **OutputParams
);
286 /* routines in Session_Cert.cpp */
287 void getAllParsedCertFields(
288 const DecodedCert
&cert
,
289 uint32
&NumberOfFields
, // RETURNED
290 CSSM_FIELD_PTR
&CertFields
); // RETURNED
292 /* routines in Session_Crypto.cpp */
294 CSSM_CC_HANDLE ccHand
,
296 CssmOwnedData
&sig
); // mallocd and returned
298 CSSM_CC_HANDLE ccHand
,
300 const CssmData
&sig
);
302 /* routines in Session_CSR.cpp */
304 CSSM_CC_HANDLE CCHandle
,
305 const CSSM_APPLE_CL_CSR_REQUEST
*csrReq
,
306 CSSM_DATA_PTR
&csrPtr
);
308 const CSSM_DATA
*csrPtr
);
311 * Maps of cached certs, CRLs, and active queries
312 * This one holds cached certs and CRLs.
314 LockedMap
<CSSM_HANDLE
, CLCachedEntry
> cacheMap
;
315 LockedMap
<CSSM_HANDLE
, CLQuery
> queryMap
;
317 CLCachedCert
*lookupCachedCert(CSSM_HANDLE handle
);
318 CLCachedCRL
*lookupCachedCRL(CSSM_HANDLE handle
);
321 #endif //_H_APPLEX509CLSESSION