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 // SSDLSession.h - CSP session for security server CSP/DL.
22 #ifndef _H_SSCSPSESSION
23 #define _H_SSCSPSESSION
25 #include "SSCSPDLSession.h"
27 #include <Security/SecurityServerClient.h>
35 class SSCSPSession
: public CSPFullPluginSession
38 SSCSPDLSession
&mSSCSPDLSession
;
39 SSFactory
&mSSFactory
;
40 CssmClient::CSP
&mRawCsp
;
42 SSCSPSession(CSSM_MODULE_HANDLE handle
,
44 const CSSM_VERSION
&version
,
46 CSSM_SERVICE_TYPE subserviceType
,
47 CSSM_ATTACH_FLAGS attachFlags
,
48 const CSSM_UPCALLS
&upcalls
,
49 SSCSPDLSession
&ssCSPDLSession
,
50 CssmClient::CSP
&rawCsp
);
52 SecurityServer::ClientSession
&clientSession()
53 { return mClientSession
; }
55 CSPContext
*contextCreate(CSSM_CC_HANDLE handle
, const Context
&context
);
57 void contextUpdate(CSSM_CC_HANDLE handle
, const Context
&context
,
59 void contextDelete(CSSM_CC_HANDLE handle
, const Context
&context
,
63 void setupContext(CSPContext
* &ctx
, const Context
&context
,
66 SSDatabase
getDatabase(CSSM_DL_DB_HANDLE
*aDLDbHandle
);
67 SSDatabase
getDatabase(const Context
&context
);
69 void makeReferenceKey(SecurityServer::KeyHandle inKeyHandle
,
70 CssmKey
&outKey
, SSDatabase
&inSSDatabase
,
71 uint32 inKeyAttr
, const CssmData
*inKeyLabel
);
72 SSKey
&lookupKey(const CssmKey
&inKey
);
74 void WrapKey(CSSM_CC_HANDLE CCHandle
,
75 const Context
&Context
,
76 const AccessCredentials
&AccessCred
,
78 const CssmData
*DescriptiveData
,
80 CSSM_PRIVILEGE Privilege
);
81 void UnwrapKey(CSSM_CC_HANDLE CCHandle
,
82 const Context
&Context
,
83 const CssmKey
*PublicKey
,
84 const CssmKey
&WrappedKey
,
87 const CssmData
*KeyLabel
,
88 const CSSM_RESOURCE_CONTROL_CONTEXT
*CredAndAclEntry
,
89 CssmKey
&UnwrappedKey
,
90 CssmData
&DescriptiveData
,
91 CSSM_PRIVILEGE Privilege
);
92 void DeriveKey(CSSM_CC_HANDLE CCHandle
,
93 const Context
&Context
,
97 const CssmData
*KeyLabel
,
98 const CSSM_RESOURCE_CONTROL_CONTEXT
*CredAndAclEntry
,
100 void GenerateKey(CSSM_CC_HANDLE ccHandle
,
101 const Context
&context
,
104 const CssmData
*keyLabel
,
105 const CSSM_RESOURCE_CONTROL_CONTEXT
*credAndAclEntry
,
107 CSSM_PRIVILEGE privilege
);
108 void GenerateKeyPair(CSSM_CC_HANDLE ccHandle
,
109 const Context
&context
,
110 uint32 publicKeyUsage
,
111 uint32 publicKeyAttr
,
112 const CssmData
*publicKeyLabel
,
114 uint32 privateKeyUsage
,
115 uint32 privateKeyAttr
,
116 const CssmData
*privateKeyLabel
,
117 const CSSM_RESOURCE_CONTROL_CONTEXT
*credAndAclEntry
,
119 CSSM_PRIVILEGE privilege
);
120 void ObtainPrivateKeyFromPublicKey(const CssmKey
&PublicKey
,
121 CssmKey
&PrivateKey
);
122 void QueryKeySizeInBits(CSSM_CC_HANDLE CCHandle
,
123 const Context
&Context
,
125 CSSM_KEY_SIZE
&KeySize
);
126 void FreeKey(const AccessCredentials
*AccessCred
,
127 CssmKey
&key
, CSSM_BOOL Delete
);
128 void GenerateRandom(CSSM_CC_HANDLE ccHandle
,
129 const Context
&context
,
130 CssmData
&randomNumber
);
131 void Login(const AccessCredentials
&AccessCred
,
132 const CssmData
*LoginName
,
133 const void *Reserved
);
135 void VerifyDevice(const CssmData
&DeviceCert
);
136 void GetOperationalStatistics(CSPOperationalStatistics
&statistics
);
137 void RetrieveCounter(CssmData
&Counter
);
138 void RetrieveUniqueId(CssmData
&UniqueID
);
139 void GetTimeValue(CSSM_ALGORITHMS TimeAlgorithm
, CssmData
&TimeData
);
140 void GetKeyOwner(const CssmKey
&Key
,
141 CSSM_ACL_OWNER_PROTOTYPE
&Owner
);
142 void ChangeKeyOwner(const AccessCredentials
&AccessCred
,
144 const CSSM_ACL_OWNER_PROTOTYPE
&NewOwner
);
145 void GetKeyAcl(const CssmKey
&Key
,
146 const CSSM_STRING
*SelectionTag
,
147 uint32
&NumberOfAclInfos
,
148 CSSM_ACL_ENTRY_INFO_PTR
&AclInfos
);
149 void ChangeKeyAcl(const AccessCredentials
&AccessCred
,
150 const CSSM_ACL_EDIT
&AclEdit
,
152 void GetLoginOwner(CSSM_ACL_OWNER_PROTOTYPE
&Owner
);
153 void ChangeLoginOwner(const AccessCredentials
&AccessCred
,
154 const CSSM_ACL_OWNER_PROTOTYPE
&NewOwner
);
155 void GetLoginAcl(const CSSM_STRING
*SelectionTag
,
156 uint32
&NumberOfAclInfos
,
157 CSSM_ACL_ENTRY_INFO_PTR
&AclInfos
);
158 void ChangeLoginAcl(const AccessCredentials
&AccessCred
,
159 const CSSM_ACL_EDIT
&AclEdit
);
160 void PassThrough(CSSM_CC_HANDLE CCHandle
,
161 const Context
&Context
,
162 uint32 PassThroughId
,
166 /* Validate requested key attr flags for newly generated keys */
167 void validateKeyAttr(uint32 reqKeyAttr
);
169 SecurityServer::ClientSession mClientSession
;
174 #endif // _H_SSCSPSESSION