2 * Copyright (c) 2004,2011,2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 // SDDLSession.h - CSP session for security server CSP/DL.
28 #ifndef _H_SDCSPSESSION
29 #define _H_SDCSPSESSION
31 #include "SDCSPDLSession.h"
33 #include <securityd_client/ssclient.h>
34 #include <security_cdsa_client/cspclient.h>
41 class SDCSPSession
: public CSPFullPluginSession
44 SDCSPDLSession
&mSDCSPDLSession
;
45 SDFactory
&mSDFactory
;
46 CssmClient::CSP
&mRawCsp
;
48 SDCSPSession(CSSM_MODULE_HANDLE handle
,
50 const CSSM_VERSION
&version
,
52 CSSM_SERVICE_TYPE subserviceType
,
53 CSSM_ATTACH_FLAGS attachFlags
,
54 const CSSM_UPCALLS
&upcalls
,
55 SDCSPDLSession
&ssCSPDLSession
,
56 CssmClient::CSP
&rawCsp
);
58 SecurityServer::ClientSession
&clientSession()
59 { return mClientSession
; }
61 CSPContext
*contextCreate(CSSM_CC_HANDLE handle
, const Context
&context
);
63 void contextUpdate(CSSM_CC_HANDLE handle
, const Context
&context
,
65 void contextDelete(CSSM_CC_HANDLE handle
, const Context
&context
,
69 void setupContext(CSPContext
* &ctx
, const Context
&context
,
72 CSSM_DB_HANDLE
getDatabase(CSSM_DL_DB_HANDLE
*aDLDbHandle
);
73 CSSM_DB_HANDLE
getDatabase(const Context
&context
);
75 void makeReferenceKey(SecurityServer::KeyHandle inKeyHandle
,
76 CssmKey
&outKey
, CSSM_DB_HANDLE inDBHandle
,
77 uint32 inKeyAttr
, const CssmData
*inKeyLabel
);
78 SDKey
&lookupKey(const CssmKey
&inKey
);
80 void WrapKey(CSSM_CC_HANDLE CCHandle
,
81 const Context
&Context
,
82 const AccessCredentials
&AccessCred
,
84 const CssmData
*DescriptiveData
,
86 CSSM_PRIVILEGE Privilege
);
87 void UnwrapKey(CSSM_CC_HANDLE CCHandle
,
88 const Context
&Context
,
89 const CssmKey
*PublicKey
,
90 const CssmKey
&WrappedKey
,
93 const CssmData
*KeyLabel
,
94 const CSSM_RESOURCE_CONTROL_CONTEXT
*CredAndAclEntry
,
95 CssmKey
&UnwrappedKey
,
96 CssmData
&DescriptiveData
,
97 CSSM_PRIVILEGE Privilege
);
98 void DeriveKey(CSSM_CC_HANDLE CCHandle
,
99 const Context
&Context
,
103 const CssmData
*KeyLabel
,
104 const CSSM_RESOURCE_CONTROL_CONTEXT
*CredAndAclEntry
,
105 CssmKey
&DerivedKey
);
106 void GenerateKey(CSSM_CC_HANDLE ccHandle
,
107 const Context
&context
,
110 const CssmData
*keyLabel
,
111 const CSSM_RESOURCE_CONTROL_CONTEXT
*credAndAclEntry
,
113 CSSM_PRIVILEGE privilege
);
114 void GenerateKeyPair(CSSM_CC_HANDLE ccHandle
,
115 const Context
&context
,
116 uint32 publicKeyUsage
,
117 uint32 publicKeyAttr
,
118 const CssmData
*publicKeyLabel
,
120 uint32 privateKeyUsage
,
121 uint32 privateKeyAttr
,
122 const CssmData
*privateKeyLabel
,
123 const CSSM_RESOURCE_CONTROL_CONTEXT
*credAndAclEntry
,
125 CSSM_PRIVILEGE privilege
);
126 void ObtainPrivateKeyFromPublicKey(const CssmKey
&PublicKey
,
127 CssmKey
&PrivateKey
);
128 void QueryKeySizeInBits(CSSM_CC_HANDLE CCHandle
,
129 const Context
&Context
,
131 CSSM_KEY_SIZE
&KeySize
);
132 void FreeKey(const AccessCredentials
*AccessCred
,
133 CssmKey
&key
, CSSM_BOOL Delete
);
134 void GenerateRandom(CSSM_CC_HANDLE ccHandle
,
135 const Context
&context
,
136 CssmData
&randomNumber
);
137 void Login(const AccessCredentials
&AccessCred
,
138 const CssmData
*LoginName
,
139 const void *Reserved
);
141 void VerifyDevice(const CssmData
&DeviceCert
);
142 void GetOperationalStatistics(CSPOperationalStatistics
&statistics
);
143 void RetrieveCounter(CssmData
&Counter
);
144 void RetrieveUniqueId(CssmData
&UniqueID
);
145 void GetTimeValue(CSSM_ALGORITHMS TimeAlgorithm
, CssmData
&TimeData
);
146 void GetKeyOwner(const CssmKey
&Key
,
147 CSSM_ACL_OWNER_PROTOTYPE
&Owner
);
148 void ChangeKeyOwner(const AccessCredentials
&AccessCred
,
150 const CSSM_ACL_OWNER_PROTOTYPE
&NewOwner
);
151 void GetKeyAcl(const CssmKey
&Key
,
152 const CSSM_STRING
*SelectionTag
,
153 uint32
&NumberOfAclInfos
,
154 CSSM_ACL_ENTRY_INFO_PTR
&AclInfos
);
155 void ChangeKeyAcl(const AccessCredentials
&AccessCred
,
156 const CSSM_ACL_EDIT
&AclEdit
,
158 void GetLoginOwner(CSSM_ACL_OWNER_PROTOTYPE
&Owner
);
159 void ChangeLoginOwner(const AccessCredentials
&AccessCred
,
160 const CSSM_ACL_OWNER_PROTOTYPE
&NewOwner
);
161 void GetLoginAcl(const CSSM_STRING
*SelectionTag
,
162 uint32
&NumberOfAclInfos
,
163 CSSM_ACL_ENTRY_INFO_PTR
&AclInfos
);
164 void ChangeLoginAcl(const AccessCredentials
&AccessCred
,
165 const CSSM_ACL_EDIT
&AclEdit
);
166 void PassThrough(CSSM_CC_HANDLE CCHandle
,
167 const Context
&Context
,
168 uint32 PassThroughId
,
172 /* Validate requested key attr flags for newly generated keys */
173 void validateKeyAttr(uint32 reqKeyAttr
);
175 SecurityServer::ClientSession mClientSession
;
179 #endif // _H_SDCSPSESSION