]> git.saurik.com Git - apple/security.git/blob - Security/libsecurity_apple_cspdl/lib/SSCSPSession.h
Security-57031.40.6.tar.gz
[apple/security.git] / Security / libsecurity_apple_cspdl / lib / SSCSPSession.h
1 /*
2 * Copyright (c) 2000-2001,2011-2012,2014 Apple 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 <securityd_client/ssclient.h>
28 #include <security_cdsa_client/cspclient.h>
29
30
31 class CSPDLPlugin;
32 class SSFactory;
33 class SSDatabase;
34 class SSKey;
35
36 class SSCSPSession : public CSPFullPluginSession
37 {
38 public:
39 SSCSPDLSession &mSSCSPDLSession;
40 SSFactory &mSSFactory;
41 CssmClient::CSP &mRawCsp;
42
43 SSCSPSession(CSSM_MODULE_HANDLE handle,
44 CSPDLPlugin &plug,
45 const CSSM_VERSION &version,
46 uint32 subserviceId,
47 CSSM_SERVICE_TYPE subserviceType,
48 CSSM_ATTACH_FLAGS attachFlags,
49 const CSSM_UPCALLS &upcalls,
50 SSCSPDLSession &ssCSPDLSession,
51 CssmClient::CSP &rawCsp);
52
53 SecurityServer::ClientSession &clientSession()
54 { return mClientSession; }
55
56 CSPContext *contextCreate(CSSM_CC_HANDLE handle, const Context &context);
57 #if 0
58 void contextUpdate(CSSM_CC_HANDLE handle, const Context &context,
59 PluginContext *ctx);
60 void contextDelete(CSSM_CC_HANDLE handle, const Context &context,
61 PluginContext *ctx);
62 #endif
63
64 void setupContext(CSPContext * &ctx, const Context &context,
65 bool encoding);
66
67 SSDatabase getDatabase(CSSM_DL_DB_HANDLE *aDLDbHandle);
68 SSDatabase getDatabase(const Context &context);
69
70 void makeReferenceKey(SecurityServer::KeyHandle inKeyHandle,
71 CssmKey &outKey, SSDatabase &inSSDatabase,
72 uint32 inKeyAttr, const CssmData *inKeyLabel);
73 SSKey &lookupKey(const CssmKey &inKey);
74
75 void WrapKey(CSSM_CC_HANDLE CCHandle,
76 const Context &Context,
77 const AccessCredentials &AccessCred,
78 const CssmKey &Key,
79 const CssmData *DescriptiveData,
80 CssmKey &WrappedKey,
81 CSSM_PRIVILEGE Privilege);
82 void UnwrapKey(CSSM_CC_HANDLE CCHandle,
83 const Context &Context,
84 const CssmKey *PublicKey,
85 const CssmKey &WrappedKey,
86 uint32 KeyUsage,
87 uint32 KeyAttr,
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,
95 CssmData &Param,
96 uint32 KeyUsage,
97 uint32 KeyAttr,
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,
103 uint32 keyUsage,
104 uint32 keyAttr,
105 const CssmData *keyLabel,
106 const CSSM_RESOURCE_CONTROL_CONTEXT *credAndAclEntry,
107 CssmKey &key,
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,
114 CssmKey &publicKey,
115 uint32 privateKeyUsage,
116 uint32 privateKeyAttr,
117 const CssmData *privateKeyLabel,
118 const CSSM_RESOURCE_CONTROL_CONTEXT *credAndAclEntry,
119 CssmKey &privateKey,
120 CSSM_PRIVILEGE privilege);
121 void ObtainPrivateKeyFromPublicKey(const CssmKey &PublicKey,
122 CssmKey &PrivateKey);
123 void QueryKeySizeInBits(CSSM_CC_HANDLE CCHandle,
124 const Context *Context,
125 const CssmKey *Key,
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);
135 void Logout();
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,
144 const CssmKey &Key,
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,
152 const CssmKey &Key);
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,
164 const void *InData,
165 void **OutData);
166 private:
167 /* Validate requested key attr flags for newly generated keys */
168 void validateKeyAttr(uint32 reqKeyAttr);
169
170 SecurityServer::ClientSession mClientSession;
171 };
172
173
174 #endif // _H_SSCSPSESSION