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"
28 #include <Security/oidsalg.h>
30 AppleTPSession::AppleTPSession(
31 CSSM_MODULE_HANDLE theHandle
,
33 const CSSM_VERSION
&version
,
35 CSSM_SERVICE_TYPE subserviceType
,
36 CSSM_ATTACH_FLAGS attachFlags
,
37 const CSSM_UPCALLS
&upcalls
)
38 : TPPluginSession(theHandle
, plug
, version
, subserviceId
,
39 subserviceType
,attachFlags
, upcalls
)
43 AppleTPSession::~AppleTPSession()
47 void AppleTPSession::CertCreateTemplate(CSSM_CL_HANDLE CLHandle
,
48 uint32 NumberOfFields
,
49 const CSSM_FIELD CertFields
[],
50 CssmData
&CertTemplate
)
52 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
55 void AppleTPSession::CrlVerify(CSSM_CL_HANDLE CLHandle
,
56 CSSM_CSP_HANDLE CSPHandle
,
57 const CSSM_ENCODED_CRL
&CrlToBeVerified
,
58 const CSSM_CERTGROUP
&SignerCertGroup
,
59 const CSSM_TP_VERIFY_CONTEXT
*VerifyContext
,
60 CSSM_TP_VERIFY_CONTEXT_RESULT
*RevokerVerifyResult
)
62 /* verify input args */
63 if(RevokerVerifyResult
!= NULL
) {
64 /* not yet, but probably someday */
65 CssmError::throwMe(CSSMERR_TP_INVALID_REQUEST_INPUTS
);
67 switch(CrlToBeVerified
.CrlType
) {
68 case CSSM_CRL_TYPE_X_509v1
:
69 case CSSM_CRL_TYPE_X_509v2
:
72 CssmError::throwMe(CSSMERR_TP_INVALID_CRL_TYPE
);
74 switch(CrlToBeVerified
.CrlEncoding
) {
75 case CSSM_CRL_ENCODING_BER
:
76 case CSSM_CRL_ENCODING_DER
:
79 CssmError::throwMe(CSSMERR_TP_INVALID_CRL_ENCODING
);
82 /* optional arguments */
83 CSSM_TIMESTRING cssmTimeStr
= NULL
;
84 const CSSM_TP_CALLERAUTH_CONTEXT
*cred
= NULL
;
85 uint32 NumberOfAnchorCerts
= 0;
86 CSSM_DATA_PTR AnchorCerts
= NULL
;
87 CSSM_DL_DB_LIST_PTR DBList
= NULL
;
88 CSSM_APPLE_TP_ACTION_FLAGS actionFlags
= 0;
89 CSSM_APPLE_TP_ACTION_DATA
*actionData
= NULL
;
91 if(VerifyContext
!= NULL
) {
92 cred
= VerifyContext
->Cred
;
94 (CSSM_APPLE_TP_ACTION_DATA
*)VerifyContext
->ActionData
.Data
;
95 if(actionData
!= NULL
) {
96 switch(actionData
->Version
) {
97 case CSSM_APPLE_TP_ACTION_VERSION
:
98 if(VerifyContext
->ActionData
.Length
!=
99 sizeof(CSSM_APPLE_TP_ACTION_DATA
)) {
100 CssmError::throwMe(CSSMERR_TP_INVALID_ACTION_DATA
);
103 /* handle backwards versions here if we ever go
104 * beyond version 0 */
106 CssmError::throwMe(CSSMERR_TP_INVALID_ACTION_DATA
);
108 actionFlags
= actionData
->ActionFlags
;
112 cssmTimeStr
= cred
->VerifyTime
;
113 NumberOfAnchorCerts
= cred
->NumberOfAnchorCerts
;
114 AnchorCerts
= cred
->AnchorCerts
;
115 DBList
= cred
->DBList
;
118 /* this must be parseable, throw immediately if not */
119 TPCrlInfo
crlToVerify(CLHandle
, CSPHandle
, &CrlToBeVerified
.CrlBlob
,
120 TIC_NoCopy
, cssmTimeStr
);
122 /* Both required at the API but in fact may be empty */
123 TPCertGroup
inCertGroup(SignerCertGroup
, CLHandle
, CSPHandle
, *this,
124 cssmTimeStr
, // optional 'this' time
125 false, // firstCertMustBeValid
127 TPCertGroup
gatheredCerts(*this, TGO_Group
);
129 /* common CRL/OCSP verify parameters */
130 TPVerifyContext
vfyCtx(*this,
137 NULL
, // no CRLs, we're on our own
144 &CSSMOID_APPLE_TP_REVOCATION_CRL
,
145 NULL
, // UT policyString
150 * We assert the doCrlVerify flag to ensure CRL verification
151 * if intermediate certs which verifyWithContext() gathers to
154 CSSM_RETURN crtn
= crlToVerify
.verifyWithContext(vfyCtx
, NULL
, true);
156 tpCrlDebug("CrlVerify failure");
157 CssmError::throwMe(crtn
);
161 void AppleTPSession::CertReclaimKey(const CSSM_CERTGROUP
&CertGroup
,
163 CSSM_LONG_HANDLE KeyCacheHandle
,
164 CSSM_CSP_HANDLE CSPHandle
,
165 const CSSM_RESOURCE_CONTROL_CONTEXT
*CredAndAclEntry
)
167 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
170 /*** CertGroupVerify, CertGroupConstruct in TPCertGroup.cpp ***/
172 void AppleTPSession::CertSign(CSSM_CL_HANDLE CLHandle
,
173 CSSM_CC_HANDLE CCHandle
,
174 const CssmData
&CertTemplateToBeSigned
,
175 const CSSM_CERTGROUP
&SignerCertGroup
,
176 const CSSM_TP_VERIFY_CONTEXT
*SignerVerifyContext
,
177 CSSM_TP_VERIFY_CONTEXT_RESULT
*SignerVerifyResult
,
178 CssmData
&SignedCert
)
180 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
183 void AppleTPSession::TupleGroupToCertGroup(CSSM_CL_HANDLE CLHandle
,
184 const CSSM_TUPLEGROUP
&TupleGroup
,
185 CSSM_CERTGROUP_PTR
&CertTemplates
)
187 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
190 void AppleTPSession::ReceiveConfirmation(const CssmData
&ReferenceIdentifier
,
191 CSSM_TP_CONFIRM_RESPONSE_PTR
&Responses
,
194 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
197 void AppleTPSession::PassThrough(CSSM_CL_HANDLE CLHandle
,
198 CSSM_CC_HANDLE CCHandle
,
199 const CSSM_DL_DB_LIST
*DBList
,
200 uint32 PassThroughId
,
201 const void *InputParams
,
204 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
207 void AppleTPSession::CertRemoveFromCrlTemplate(CSSM_CL_HANDLE CLHandle
,
208 CSSM_CSP_HANDLE CSPHandle
,
209 const CssmData
*OldCrlTemplate
,
210 const CSSM_CERTGROUP
&CertGroupToBeRemoved
,
211 const CSSM_CERTGROUP
&RevokerCertGroup
,
212 const CSSM_TP_VERIFY_CONTEXT
&RevokerVerifyContext
,
213 CSSM_TP_VERIFY_CONTEXT_RESULT
&RevokerVerifyResult
,
214 CssmData
&NewCrlTemplate
)
216 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
219 void AppleTPSession::CertRevoke(CSSM_CL_HANDLE CLHandle
,
220 CSSM_CSP_HANDLE CSPHandle
,
221 const CssmData
*OldCrlTemplate
,
222 const CSSM_CERTGROUP
&CertGroupToBeRevoked
,
223 const CSSM_CERTGROUP
&RevokerCertGroup
,
224 const CSSM_TP_VERIFY_CONTEXT
&RevokerVerifyContext
,
225 CSSM_TP_VERIFY_CONTEXT_RESULT
&RevokerVerifyResult
,
226 CSSM_TP_CERTCHANGE_REASON Reason
,
227 CssmData
&NewCrlTemplate
)
229 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
232 void AppleTPSession::CertReclaimAbort(CSSM_LONG_HANDLE KeyCacheHandle
)
234 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
237 void AppleTPSession::CrlCreateTemplate(CSSM_CL_HANDLE CLHandle
,
238 uint32 NumberOfFields
,
239 const CSSM_FIELD CrlFields
[],
240 CssmData
&NewCrlTemplate
)
242 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
245 void AppleTPSession::CertGroupToTupleGroup(CSSM_CL_HANDLE CLHandle
,
246 const CSSM_CERTGROUP
&CertGroup
,
247 CSSM_TUPLEGROUP_PTR
&TupleGroup
)
249 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
252 void AppleTPSession::FormRequest(const CSSM_TP_AUTHORITY_ID
*PreferredAuthority
,
253 CSSM_TP_FORM_TYPE FormType
,
256 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
259 void AppleTPSession::CrlSign(CSSM_CL_HANDLE CLHandle
,
260 CSSM_CC_HANDLE CCHandle
,
261 const CSSM_ENCODED_CRL
&CrlToBeSigned
,
262 const CSSM_CERTGROUP
&SignerCertGroup
,
263 const CSSM_TP_VERIFY_CONTEXT
*SignerVerifyContext
,
264 CSSM_TP_VERIFY_CONTEXT_RESULT
*SignerVerifyResult
,
267 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
270 void AppleTPSession::CertGroupPrune(CSSM_CL_HANDLE CLHandle
,
271 const CSSM_DL_DB_LIST
&DBList
,
272 const CSSM_CERTGROUP
&OrderedCertGroup
,
273 CSSM_CERTGROUP_PTR
&PrunedCertGroup
)
275 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
278 void AppleTPSession::ApplyCrlToDb(CSSM_CL_HANDLE CLHandle
,
279 CSSM_CSP_HANDLE CSPHandle
,
280 const CSSM_ENCODED_CRL
&CrlToBeApplied
,
281 const CSSM_CERTGROUP
&SignerCertGroup
,
282 const CSSM_TP_VERIFY_CONTEXT
*ApplyCrlVerifyContext
,
283 CSSM_TP_VERIFY_CONTEXT_RESULT
&ApplyCrlVerifyResult
)
285 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
288 void AppleTPSession::CertGetAllTemplateFields(CSSM_CL_HANDLE CLHandle
,
289 const CssmData
&CertTemplate
,
290 uint32
&NumberOfFields
,
291 CSSM_FIELD_PTR
&CertFields
)
293 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
296 void AppleTPSession::ConfirmCredResult(const CssmData
&ReferenceIdentifier
,
297 const CSSM_TP_CALLERAUTH_CONTEXT
*CallerAuthCredentials
,
298 const CSSM_TP_CONFIRM_RESPONSE
&Responses
,
299 const CSSM_TP_AUTHORITY_ID
*PreferredAuthority
)
301 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);
304 void AppleTPSession::FormSubmit(CSSM_TP_FORM_TYPE FormType
,
305 const CssmData
&Form
,
306 const CSSM_TP_AUTHORITY_ID
*ClearanceAuthority
,
307 const CSSM_TP_AUTHORITY_ID
*RepresentedAuthority
,
308 AccessCredentials
*Credentials
)
310 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED
);