2 * Copyright (c) 2000-2001,2011-2012,2014 Apple 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 <securityd_client/ssclient.h>
28 #include <security_cdsa_client/cspclient.h>
36 class SSCSPSession
: public CSPFullPluginSession
39 SSCSPDLSession
&mSSCSPDLSession
;
40 SSFactory
&mSSFactory
;
41 CssmClient::CSP
&mRawCsp
;
43 SSCSPSession(CSSM_MODULE_HANDLE handle
,
45 const CSSM_VERSION
&version
,
47 CSSM_SERVICE_TYPE subserviceType
,
48 CSSM_ATTACH_FLAGS attachFlags
,
49 const CSSM_UPCALLS
&upcalls
,
50 SSCSPDLSession
&ssCSPDLSession
,
51 CssmClient::CSP
&rawCsp
);
53 SecurityServer::ClientSession
&clientSession()
54 { return mClientSession
; }
56 CSPContext
*contextCreate(CSSM_CC_HANDLE handle
, const Context
&context
);
58 void contextUpdate(CSSM_CC_HANDLE handle
, const Context
&context
,
60 void contextDelete(CSSM_CC_HANDLE handle
, const Context
&context
,
64 void setupContext(CSPContext
* &ctx
, const Context
&context
,
67 SSDatabase
getDatabase(CSSM_DL_DB_HANDLE
*aDLDbHandle
);
68 SSDatabase
getDatabase(const Context
&context
);
70 void makeReferenceKey(SecurityServer::KeyHandle inKeyHandle
,
71 CssmKey
&outKey
, SSDatabase
&inSSDatabase
,
72 uint32 inKeyAttr
, const CssmData
*inKeyLabel
);
73 SSKey
&lookupKey(const CssmKey
&inKey
);
75 void WrapKey(CSSM_CC_HANDLE CCHandle
,
76 const Context
&Context
,
77 const AccessCredentials
&AccessCred
,
79 const CssmData
*DescriptiveData
,
81 CSSM_PRIVILEGE Privilege
);
82 void UnwrapKey(CSSM_CC_HANDLE CCHandle
,
83 const Context
&Context
,
84 const CssmKey
*PublicKey
,
85 const CssmKey
&WrappedKey
,
88 const CssmData
*KeyLabel
,
89 const CSSM_RESOURCE_CONTROL_CONTEXT
*CredAndAclEntry
,
90 CssmKey
&UnwrappedKey
,
91 CssmData
&DescriptiveData
,
92 CSSM_PRIVILEGE Privilege
);
93 void DeriveKey(CSSM_CC_HANDLE CCHandle
,
94 const Context
&Context
,
98 const CssmData
*KeyLabel
,
99 const CSSM_RESOURCE_CONTROL_CONTEXT
*CredAndAclEntry
,
100 CssmKey
&DerivedKey
);
101 void GenerateKey(CSSM_CC_HANDLE ccHandle
,
102 const Context
&context
,
105 const CssmData
*keyLabel
,
106 const CSSM_RESOURCE_CONTROL_CONTEXT
*credAndAclEntry
,
108 CSSM_PRIVILEGE privilege
);
109 void GenerateKeyPair(CSSM_CC_HANDLE ccHandle
,
110 const Context
&context
,
111 uint32 publicKeyUsage
,
112 uint32 publicKeyAttr
,
113 const CssmData
*publicKeyLabel
,
115 uint32 privateKeyUsage
,
116 uint32 privateKeyAttr
,
117 const CssmData
*privateKeyLabel
,
118 const CSSM_RESOURCE_CONTROL_CONTEXT
*credAndAclEntry
,
120 CSSM_PRIVILEGE privilege
);
121 void ObtainPrivateKeyFromPublicKey(const CssmKey
&PublicKey
,
122 CssmKey
&PrivateKey
);
123 void QueryKeySizeInBits(CSSM_CC_HANDLE CCHandle
,
124 const Context
*Context
,
126 CSSM_KEY_SIZE
&KeySize
);
127 void FreeKey(const AccessCredentials
*AccessCred
,
128 CssmKey
&key
, CSSM_BOOL Delete
);
129 void GenerateRandom(CSSM_CC_HANDLE ccHandle
,
130 const Context
&context
,
131 CssmData
&randomNumber
);
132 void Login(const AccessCredentials
&AccessCred
,
133 const CssmData
*LoginName
,
134 const void *Reserved
);
136 void VerifyDevice(const CssmData
&DeviceCert
);
137 void GetOperationalStatistics(CSPOperationalStatistics
&statistics
);
138 void RetrieveCounter(CssmData
&Counter
);
139 void RetrieveUniqueId(CssmData
&UniqueID
);
140 void GetTimeValue(CSSM_ALGORITHMS TimeAlgorithm
, CssmData
&TimeData
);
141 void GetKeyOwner(const CssmKey
&Key
,
142 CSSM_ACL_OWNER_PROTOTYPE
&Owner
);
143 void ChangeKeyOwner(const AccessCredentials
&AccessCred
,
145 const CSSM_ACL_OWNER_PROTOTYPE
&NewOwner
);
146 void GetKeyAcl(const CssmKey
&Key
,
147 const CSSM_STRING
*SelectionTag
,
148 uint32
&NumberOfAclInfos
,
149 CSSM_ACL_ENTRY_INFO_PTR
&AclInfos
);
150 void ChangeKeyAcl(const AccessCredentials
&AccessCred
,
151 const CSSM_ACL_EDIT
&AclEdit
,
153 void GetLoginOwner(CSSM_ACL_OWNER_PROTOTYPE
&Owner
);
154 void ChangeLoginOwner(const AccessCredentials
&AccessCred
,
155 const CSSM_ACL_OWNER_PROTOTYPE
&NewOwner
);
156 void GetLoginAcl(const CSSM_STRING
*SelectionTag
,
157 uint32
&NumberOfAclInfos
,
158 CSSM_ACL_ENTRY_INFO_PTR
&AclInfos
);
159 void ChangeLoginAcl(const AccessCredentials
&AccessCred
,
160 const CSSM_ACL_EDIT
&AclEdit
);
161 void PassThrough(CSSM_CC_HANDLE CCHandle
,
162 const Context
&Context
,
163 uint32 PassThroughId
,
167 /* Validate requested key attr flags for newly generated keys */
168 void validateKeyAttr(uint32 reqKeyAttr
);
170 SecurityServer::ClientSession mClientSession
;
174 #endif // _H_SSCSPSESSION