]>
Commit | Line | Data |
---|---|---|
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(CSSM_DL_DB_HANDLE *aDLDbHandle); | |
67 | SSDatabase getDatabase(const Context &context); | |
68 | ||
69 | void makeReferenceKey(SecurityServer::KeyHandle inKeyHandle, | |
70 | CssmKey &outKey, SSDatabase &inSSDatabase, | |
71 | uint32 inKeyAttr, const CssmData *inKeyLabel); | |
72 | SSKey &lookupKey(const CssmKey &inKey); | |
73 | ||
74 | void WrapKey(CSSM_CC_HANDLE CCHandle, | |
75 | const Context &Context, | |
76 | const AccessCredentials &AccessCred, | |
77 | const CssmKey &Key, | |
78 | const CssmData *DescriptiveData, | |
79 | CssmKey &WrappedKey, | |
80 | CSSM_PRIVILEGE Privilege); | |
81 | void UnwrapKey(CSSM_CC_HANDLE CCHandle, | |
82 | const Context &Context, | |
83 | const CssmKey *PublicKey, | |
84 | const CssmKey &WrappedKey, | |
85 | uint32 KeyUsage, | |
86 | uint32 KeyAttr, | |
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, | |
94 | CssmData &Param, | |
95 | uint32 KeyUsage, | |
96 | uint32 KeyAttr, | |
97 | const CssmData *KeyLabel, | |
98 | const CSSM_RESOURCE_CONTROL_CONTEXT *CredAndAclEntry, | |
99 | CssmKey &DerivedKey); | |
100 | void GenerateKey(CSSM_CC_HANDLE ccHandle, | |
101 | const Context &context, | |
102 | uint32 keyUsage, | |
103 | uint32 keyAttr, | |
104 | const CssmData *keyLabel, | |
105 | const CSSM_RESOURCE_CONTROL_CONTEXT *credAndAclEntry, | |
106 | CssmKey &key, | |
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, | |
113 | CssmKey &publicKey, | |
114 | uint32 privateKeyUsage, | |
115 | uint32 privateKeyAttr, | |
116 | const CssmData *privateKeyLabel, | |
117 | const CSSM_RESOURCE_CONTROL_CONTEXT *credAndAclEntry, | |
118 | CssmKey &privateKey, | |
119 | CSSM_PRIVILEGE privilege); | |
120 | void ObtainPrivateKeyFromPublicKey(const CssmKey &PublicKey, | |
121 | CssmKey &PrivateKey); | |
122 | void QueryKeySizeInBits(CSSM_CC_HANDLE CCHandle, | |
123 | const Context &Context, | |
124 | const CssmKey &Key, | |
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); | |
134 | void Logout(); | |
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, | |
143 | const CssmKey &Key, | |
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, | |
151 | const CssmKey &Key); | |
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, | |
163 | const void *InData, | |
164 | void **OutData); | |
165 | private: | |
166 | /* Validate requested key attr flags for newly generated keys */ | |
167 | void validateKeyAttr(uint32 reqKeyAttr); | |
168 | ||
169 | SecurityServer::ClientSession mClientSession; | |
170 | }; | |
171 | ||
172 | ||
173 | #endif // _H_SSCSPSESSION |