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(const Context
&context
);
68 void makeReferenceKey(SecurityServer::KeyHandle inKeyHandle
,
69 CssmKey
&outKey
, SSDatabase
&inSSDatabase
,
70 uint32 inKeyAttr
, const CssmData
*inKeyLabel
);
71 SSKey
&lookupKey(const CssmKey
&inKey
);
73 void WrapKey(CSSM_CC_HANDLE CCHandle
,
74 const Context
&Context
,
75 const AccessCredentials
&AccessCred
,
77 const CssmData
*DescriptiveData
,
79 CSSM_PRIVILEGE Privilege
);
80 void UnwrapKey(CSSM_CC_HANDLE CCHandle
,
81 const Context
&Context
,
82 const CssmKey
*PublicKey
,
83 const CssmKey
&WrappedKey
,
86 const CssmData
*KeyLabel
,
87 const CSSM_RESOURCE_CONTROL_CONTEXT
*CredAndAclEntry
,
88 CssmKey
&UnwrappedKey
,
89 CssmData
&DescriptiveData
,
90 CSSM_PRIVILEGE Privilege
);
91 void DeriveKey(CSSM_CC_HANDLE CCHandle
,
92 const Context
&Context
,
96 const CssmData
*KeyLabel
,
97 const CSSM_RESOURCE_CONTROL_CONTEXT
*CredAndAclEntry
,
99 void GenerateKey(CSSM_CC_HANDLE ccHandle
,
100 const Context
&context
,
103 const CssmData
*keyLabel
,
104 const CSSM_RESOURCE_CONTROL_CONTEXT
*credAndAclEntry
,
106 CSSM_PRIVILEGE privilege
);
107 void GenerateKeyPair(CSSM_CC_HANDLE ccHandle
,
108 const Context
&context
,
109 uint32 publicKeyUsage
,
110 uint32 publicKeyAttr
,
111 const CssmData
*publicKeyLabel
,
113 uint32 privateKeyUsage
,
114 uint32 privateKeyAttr
,
115 const CssmData
*privateKeyLabel
,
116 const CSSM_RESOURCE_CONTROL_CONTEXT
*credAndAclEntry
,
118 CSSM_PRIVILEGE privilege
);
119 void ObtainPrivateKeyFromPublicKey(const CssmKey
&PublicKey
,
120 CssmKey
&PrivateKey
);
121 void QueryKeySizeInBits(CSSM_CC_HANDLE CCHandle
,
122 const Context
&Context
,
124 CSSM_KEY_SIZE
&KeySize
);
125 void FreeKey(const AccessCredentials
*AccessCred
,
126 CssmKey
&key
, CSSM_BOOL Delete
);
127 void GenerateRandom(CSSM_CC_HANDLE ccHandle
,
128 const Context
&context
,
129 CssmData
&randomNumber
);
130 void Login(const AccessCredentials
&AccessCred
,
131 const CssmData
*LoginName
,
132 const void *Reserved
);
134 void VerifyDevice(const CssmData
&DeviceCert
);
135 void GetOperationalStatistics(CSPOperationalStatistics
&statistics
);
136 void RetrieveCounter(CssmData
&Counter
);
137 void RetrieveUniqueId(CssmData
&UniqueID
);
138 void GetTimeValue(CSSM_ALGORITHMS TimeAlgorithm
, CssmData
&TimeData
);
139 void GetKeyOwner(const CssmKey
&Key
,
140 CSSM_ACL_OWNER_PROTOTYPE
&Owner
);
141 void ChangeKeyOwner(const AccessCredentials
&AccessCred
,
143 const CSSM_ACL_OWNER_PROTOTYPE
&NewOwner
);
144 void GetKeyAcl(const CssmKey
&Key
,
145 const CSSM_STRING
*SelectionTag
,
146 uint32
&NumberOfAclInfos
,
147 CSSM_ACL_ENTRY_INFO_PTR
&AclInfos
);
148 void ChangeKeyAcl(const AccessCredentials
&AccessCred
,
149 const CSSM_ACL_EDIT
&AclEdit
,
151 void GetLoginOwner(CSSM_ACL_OWNER_PROTOTYPE
&Owner
);
152 void ChangeLoginOwner(const AccessCredentials
&AccessCred
,
153 const CSSM_ACL_OWNER_PROTOTYPE
&NewOwner
);
154 void GetLoginAcl(const CSSM_STRING
*SelectionTag
,
155 uint32
&NumberOfAclInfos
,
156 CSSM_ACL_ENTRY_INFO_PTR
&AclInfos
);
157 void ChangeLoginAcl(const AccessCredentials
&AccessCred
,
158 const CSSM_ACL_EDIT
&AclEdit
);
159 void PassThrough(CSSM_CC_HANDLE CCHandle
,
160 const Context
&Context
,
161 uint32 PassThroughId
,
165 /* Validate requested key attr flags for newly generated keys */
166 void validateKeyAttr(uint32 reqKeyAttr
);
168 SecurityServer::ClientSession mClientSession
;
173 #endif // _H_SSCSPSESSION