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 * AppleTPSession.cpp - general session support and (mostly) unimplemented functions
23 #include "AppleTPSession.h"
24 #include "TPCertInfo.h"
25 #include "TPCrlInfo.h"
26 #include "tpCrlVerify.h"
27 #include "tpdebugging.h"
29 AppleTPSession::AppleTPSession(
30 CSSM_MODULE_HANDLE theHandle
,
32 const CSSM_VERSION
&version
,
34 CSSM_SERVICE_TYPE subserviceType
,
35 CSSM_ATTACH_FLAGS attachFlags
,
36 const CSSM_UPCALLS
&upcalls
)
37 : TPPluginSession(theHandle
, plug
, version
, subserviceId
,
38 subserviceType
,attachFlags
, upcalls
)
42 AppleTPSession::~AppleTPSession()
46 void AppleTPSession::CertCreateTemplate(CSSM_CL_HANDLE CLHandle
,
47 uint32 NumberOfFields
,
48 const CSSM_FIELD CertFields
[],
49 CssmData
&CertTemplate
)
51 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
54 void AppleTPSession::CrlVerify(CSSM_CL_HANDLE CLHandle
,
55 CSSM_CSP_HANDLE CSPHandle
,
56 const CSSM_ENCODED_CRL
&CrlToBeVerified
,
57 const CSSM_CERTGROUP
&SignerCertGroup
,
58 const CSSM_TP_VERIFY_CONTEXT
*VerifyContext
,
59 CSSM_TP_VERIFY_CONTEXT_RESULT
*RevokerVerifyResult
)
61 /* verify input args */
62 if(RevokerVerifyResult
!= NULL
) {
63 /* not yet, but probably someday */
64 CssmError::throwMe(CSSMERR_TP_INVALID_REQUEST_INPUTS
);
66 switch(CrlToBeVerified
.CrlType
) {
67 case CSSM_CRL_TYPE_X_509v1
:
68 case CSSM_CRL_TYPE_X_509v2
:
71 CssmError::throwMe(CSSMERR_TP_INVALID_CRL_TYPE
);
73 switch(CrlToBeVerified
.CrlEncoding
) {
74 case CSSM_CRL_ENCODING_BER
:
75 case CSSM_CRL_ENCODING_DER
:
78 CssmError::throwMe(CSSMERR_TP_INVALID_CRL_ENCODING
);
81 /* optional arguments */
82 CSSM_TIMESTRING cssmTimeStr
= NULL
;
83 const CSSM_TP_CALLERAUTH_CONTEXT
*cred
= NULL
;
84 uint32 NumberOfAnchorCerts
= 0;
85 CSSM_DATA_PTR AnchorCerts
= NULL
;
86 CSSM_DL_DB_LIST_PTR DBList
= NULL
;
87 CSSM_APPLE_TP_ACTION_FLAGS actionFlags
= 0;
88 CSSM_APPLE_TP_ACTION_DATA
*actionData
= NULL
;
90 if(VerifyContext
!= NULL
) {
91 cred
= VerifyContext
->Cred
;
93 (CSSM_APPLE_TP_ACTION_DATA
*)VerifyContext
->ActionData
.Data
;
94 if(actionData
!= NULL
) {
95 switch(actionData
->Version
) {
96 case CSSM_APPLE_TP_ACTION_VERSION
:
97 if(VerifyContext
->ActionData
.Length
!=
98 sizeof(CSSM_APPLE_TP_ACTION_DATA
)) {
99 CssmError::throwMe(CSSMERR_TP_INVALID_ACTION_DATA
);
102 /* handle backwards versions here if we ever go
103 * beyond version 0 */
105 CssmError::throwMe(CSSMERR_TP_INVALID_ACTION_DATA
);
107 actionFlags
= actionData
->ActionFlags
;
111 cssmTimeStr
= cred
->VerifyTime
;
112 NumberOfAnchorCerts
= cred
->NumberOfAnchorCerts
;
113 AnchorCerts
= cred
->AnchorCerts
;
114 DBList
= cred
->DBList
;
117 /* this must be parseable, throw immediately if not */
118 TPCrlInfo
crlToVerify(CLHandle
, CSPHandle
, &CrlToBeVerified
.CrlBlob
,
119 TIC_NoCopy
, cssmTimeStr
);
121 /* required at the API but in fact may be empty */
122 TPCertGroup
inCertGroup(SignerCertGroup
, CLHandle
, CSPHandle
, *this,
123 cssmTimeStr
, // optional 'this' time
124 false, // firstCertMustBeValid
127 /* common CRL verify parameters */
128 TPCrlVerifyContext
vfyCtx(*this,
135 NULL
, // no CRLs, we're on our own
136 NULL
, // gatheredCerts, none so far
138 kCrlNone
, // policy, varies per policy
140 0); // crlOptFlags, varies per policy
143 * We assert the doCrlVerify flag to ensure CRL verification
144 * if intermediate certs which verifyWithContext() gathers to
147 CSSM_RETURN crtn
= crlToVerify
.verifyWithContext(vfyCtx
, NULL
, true);
149 tpCrlDebug("CrlVerify failure");
150 CssmError::throwMe(crtn
);
154 void AppleTPSession::CertReclaimKey(const CSSM_CERTGROUP
&CertGroup
,
156 CSSM_LONG_HANDLE KeyCacheHandle
,
157 CSSM_CSP_HANDLE CSPHandle
,
158 const CSSM_RESOURCE_CONTROL_CONTEXT
*CredAndAclEntry
)
160 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
163 /*** CertGroupVerify, CertGroupConstruct in TPCertGroup.cpp ***/
165 void AppleTPSession::CertSign(CSSM_CL_HANDLE CLHandle
,
166 CSSM_CC_HANDLE CCHandle
,
167 const CssmData
&CertTemplateToBeSigned
,
168 const CSSM_CERTGROUP
&SignerCertGroup
,
169 const CSSM_TP_VERIFY_CONTEXT
*SignerVerifyContext
,
170 CSSM_TP_VERIFY_CONTEXT_RESULT
*SignerVerifyResult
,
171 CssmData
&SignedCert
)
173 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
176 void AppleTPSession::TupleGroupToCertGroup(CSSM_CL_HANDLE CLHandle
,
177 const CSSM_TUPLEGROUP
&TupleGroup
,
178 CSSM_CERTGROUP_PTR
&CertTemplates
)
180 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
183 void AppleTPSession::ReceiveConfirmation(const CssmData
&ReferenceIdentifier
,
184 CSSM_TP_CONFIRM_RESPONSE_PTR
&Responses
,
187 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
190 void AppleTPSession::PassThrough(CSSM_CL_HANDLE CLHandle
,
191 CSSM_CC_HANDLE CCHandle
,
192 const CSSM_DL_DB_LIST
*DBList
,
193 uint32 PassThroughId
,
194 const void *InputParams
,
197 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
200 void AppleTPSession::CertRemoveFromCrlTemplate(CSSM_CL_HANDLE CLHandle
,
201 CSSM_CSP_HANDLE CSPHandle
,
202 const CssmData
*OldCrlTemplate
,
203 const CSSM_CERTGROUP
&CertGroupToBeRemoved
,
204 const CSSM_CERTGROUP
&RevokerCertGroup
,
205 const CSSM_TP_VERIFY_CONTEXT
&RevokerVerifyContext
,
206 CSSM_TP_VERIFY_CONTEXT_RESULT
&RevokerVerifyResult
,
207 CssmData
&NewCrlTemplate
)
209 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
212 void AppleTPSession::CertRevoke(CSSM_CL_HANDLE CLHandle
,
213 CSSM_CSP_HANDLE CSPHandle
,
214 const CssmData
*OldCrlTemplate
,
215 const CSSM_CERTGROUP
&CertGroupToBeRevoked
,
216 const CSSM_CERTGROUP
&RevokerCertGroup
,
217 const CSSM_TP_VERIFY_CONTEXT
&RevokerVerifyContext
,
218 CSSM_TP_VERIFY_CONTEXT_RESULT
&RevokerVerifyResult
,
219 CSSM_TP_CERTCHANGE_REASON Reason
,
220 CssmData
&NewCrlTemplate
)
222 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
225 void AppleTPSession::CertReclaimAbort(CSSM_LONG_HANDLE KeyCacheHandle
)
227 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
230 void AppleTPSession::CrlCreateTemplate(CSSM_CL_HANDLE CLHandle
,
231 uint32 NumberOfFields
,
232 const CSSM_FIELD CrlFields
[],
233 CssmData
&NewCrlTemplate
)
235 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
238 void AppleTPSession::CertGroupToTupleGroup(CSSM_CL_HANDLE CLHandle
,
239 const CSSM_CERTGROUP
&CertGroup
,
240 CSSM_TUPLEGROUP_PTR
&TupleGroup
)
242 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
245 void AppleTPSession::FormRequest(const CSSM_TP_AUTHORITY_ID
*PreferredAuthority
,
246 CSSM_TP_FORM_TYPE FormType
,
249 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
252 void AppleTPSession::CrlSign(CSSM_CL_HANDLE CLHandle
,
253 CSSM_CC_HANDLE CCHandle
,
254 const CSSM_ENCODED_CRL
&CrlToBeSigned
,
255 const CSSM_CERTGROUP
&SignerCertGroup
,
256 const CSSM_TP_VERIFY_CONTEXT
*SignerVerifyContext
,
257 CSSM_TP_VERIFY_CONTEXT_RESULT
*SignerVerifyResult
,
260 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
263 void AppleTPSession::CertGroupPrune(CSSM_CL_HANDLE CLHandle
,
264 const CSSM_DL_DB_LIST
&DBList
,
265 const CSSM_CERTGROUP
&OrderedCertGroup
,
266 CSSM_CERTGROUP_PTR
&PrunedCertGroup
)
268 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
271 void AppleTPSession::ApplyCrlToDb(CSSM_CL_HANDLE CLHandle
,
272 CSSM_CSP_HANDLE CSPHandle
,
273 const CSSM_ENCODED_CRL
&CrlToBeApplied
,
274 const CSSM_CERTGROUP
&SignerCertGroup
,
275 const CSSM_TP_VERIFY_CONTEXT
*ApplyCrlVerifyContext
,
276 CSSM_TP_VERIFY_CONTEXT_RESULT
&ApplyCrlVerifyResult
)
278 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
281 void AppleTPSession::CertGetAllTemplateFields(CSSM_CL_HANDLE CLHandle
,
282 const CssmData
&CertTemplate
,
283 uint32
&NumberOfFields
,
284 CSSM_FIELD_PTR
&CertFields
)
286 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
289 void AppleTPSession::ConfirmCredResult(const CssmData
&ReferenceIdentifier
,
290 const CSSM_TP_CALLERAUTH_CONTEXT
*CallerAuthCredentials
,
291 const CSSM_TP_CONFIRM_RESPONSE
&Responses
,
292 const CSSM_TP_AUTHORITY_ID
*PreferredAuthority
)
294 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
297 void AppleTPSession::FormSubmit(CSSM_TP_FORM_TYPE FormType
,
298 const CssmData
&Form
,
299 const CSSM_TP_AUTHORITY_ID
*ClearanceAuthority
,
300 const CSSM_TP_AUTHORITY_ID
*RepresentedAuthority
,
301 AccessCredentials
*Credentials
)
303 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);