]> git.saurik.com Git - apple/security.git/blob - AppleCSPDL/SSCSPSession.h
Security-54.1.tar.gz
[apple/security.git] / AppleCSPDL / SSCSPSession.h
1 /*
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
3 *
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
8 * using this file.
9 *
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.
16 */
17
18
19 //
20 // SSDLSession.h - CSP session for security server CSP/DL.
21 //
22 #ifndef _H_SSCSPSESSION
23 #define _H_SSCSPSESSION
24
25 #include "SSCSPDLSession.h"
26
27 #include <Security/SecurityServerClient.h>
28
29
30 class CSPDLPlugin;
31 class SSFactory;
32 class SSDatabase;
33 class SSKey;
34
35 class SSCSPSession : public CSPFullPluginSession
36 {
37 public:
38 SSCSPDLSession &mSSCSPDLSession;
39 SSFactory &mSSFactory;
40 CssmClient::CSP &mRawCsp;
41
42 SSCSPSession(CSSM_MODULE_HANDLE handle,
43 CSPDLPlugin &plug,
44 const CSSM_VERSION &version,
45 uint32 subserviceId,
46 CSSM_SERVICE_TYPE subserviceType,
47 CSSM_ATTACH_FLAGS attachFlags,
48 const CSSM_UPCALLS &upcalls,
49 SSCSPDLSession &ssCSPDLSession,
50 CssmClient::CSP &rawCsp);
51
52 SecurityServer::ClientSession &clientSession()
53 { return mClientSession; }
54
55 CSPContext *contextCreate(CSSM_CC_HANDLE handle, const Context &context);
56 #if 0
57 void contextUpdate(CSSM_CC_HANDLE handle, const Context &context,
58 PluginContext *ctx);
59 void contextDelete(CSSM_CC_HANDLE handle, const Context &context,
60 PluginContext *ctx);
61 #endif
62
63 void setupContext(CSPContext * &ctx, const Context &context,
64 bool encoding);
65
66 SSDatabase getDatabase(const Context &context);
67
68 void makeReferenceKey(SecurityServer::KeyHandle inKeyHandle,
69 CssmKey &outKey, SSDatabase &inSSDatabase,
70 uint32 inKeyAttr, const CssmData *inKeyLabel);
71 SSKey &lookupKey(const CssmKey &inKey);
72
73 void WrapKey(CSSM_CC_HANDLE CCHandle,
74 const Context &Context,
75 const AccessCredentials &AccessCred,
76 const CssmKey &Key,
77 const CssmData *DescriptiveData,
78 CssmKey &WrappedKey,
79 CSSM_PRIVILEGE Privilege);
80 void UnwrapKey(CSSM_CC_HANDLE CCHandle,
81 const Context &Context,
82 const CssmKey *PublicKey,
83 const CssmKey &WrappedKey,
84 uint32 KeyUsage,
85 uint32 KeyAttr,
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,
93 CssmData &Param,
94 uint32 KeyUsage,
95 uint32 KeyAttr,
96 const CssmData *KeyLabel,
97 const CSSM_RESOURCE_CONTROL_CONTEXT *CredAndAclEntry,
98 CssmKey &DerivedKey);
99 void GenerateKey(CSSM_CC_HANDLE ccHandle,
100 const Context &context,
101 uint32 keyUsage,
102 uint32 keyAttr,
103 const CssmData *keyLabel,
104 const CSSM_RESOURCE_CONTROL_CONTEXT *credAndAclEntry,
105 CssmKey &key,
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,
112 CssmKey &publicKey,
113 uint32 privateKeyUsage,
114 uint32 privateKeyAttr,
115 const CssmData *privateKeyLabel,
116 const CSSM_RESOURCE_CONTROL_CONTEXT *credAndAclEntry,
117 CssmKey &privateKey,
118 CSSM_PRIVILEGE privilege);
119 void ObtainPrivateKeyFromPublicKey(const CssmKey &PublicKey,
120 CssmKey &PrivateKey);
121 void QueryKeySizeInBits(CSSM_CC_HANDLE CCHandle,
122 const Context &Context,
123 const CssmKey &Key,
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);
133 void Logout();
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,
142 const CssmKey &Key,
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,
150 const CssmKey &Key);
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,
162 const void *InData,
163 void **OutData);
164 private:
165 /* Validate requested key attr flags for newly generated keys */
166 void validateKeyAttr(uint32 reqKeyAttr);
167
168 SecurityServer::ClientSession mClientSession;
169
170 };
171
172
173 #endif // _H_SSCSPSESSION