]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_cdsa_client/lib/mds_standard.cpp
Security-57740.1.18.tar.gz
[apple/security.git] / OSX / libsecurity_cdsa_client / lib / mds_standard.cpp
1 /*
2 * Copyright (c) 2000-2004,2011,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 // mds_standard - standard-defined MDS record types
21 //
22 #include <security_cdsa_client/mds_standard.h>
23 #include <security_cdsa_client/dlquery.h>
24
25
26 namespace Security {
27 namespace MDSClient {
28
29
30 //
31 // CDSA Common relation (one record per module)
32 //
33 static const char * const commonAttributes[] = {
34 "ModuleID",
35 "ModuleName",
36 "Path",
37 "Desc",
38 "DynamicFlag",
39 "MultiThreadFlag",
40 "ServiceMask",
41 NULL
42 };
43 Common::Common() : Record(commonAttributes) { }
44
45 string Common::moduleID() const { return mAttributes[0]; }
46 string Common::moduleName() const { return mAttributes[1]; }
47 string Common::path() const { return mAttributes[2]; }
48 string Common::description() const { return mAttributes[3]; }
49 bool Common::dynamic() const { return mAttributes[4]; }
50 bool Common::singleThreaded() const { return !mAttributes[5]; }
51 CSSM_SERVICE_MASK Common::serviceMask() const { return mAttributes[6]; }
52
53
54 //
55 // Common::Carrier draws in the Common fields for anything with
56 // a ModuleID attribute (which must be the first attribute listed)
57 //
58 Common::Carrier::~Carrier() { }
59
60 Common &Common::Carrier::common() const
61 {
62 if (!mCommon) {
63 const CssmDbRecordAttributeData &attrs
64 = dynamic_cast<const Record *>(this)->attributes();
65 RefPointer<Common> rpc;
66 rpc = Table<Common>(mds()).fetch(
67 Attribute("ModuleID") == string(attrs[0]),
68 CSSMERR_DL_ENDOFDATA);
69 mCommon = rpc;
70 }
71 return *mCommon;
72 }
73
74
75 //
76 // Attributes that are common to all primary relations
77 //
78 static const char * const primaryAttributes[] = {
79 "ModuleID",
80 "SSID",
81 "ModuleName",
82 "ProductVersion",
83 "Vendor",
84 NULL
85 };
86 PrimaryRecord::PrimaryRecord(const char * const * names)
87 : Record(primaryAttributes)
88 {
89 addAttributes(names);
90 }
91
92 string PrimaryRecord::moduleID() const { return mAttributes[0]; }
93 uint32 PrimaryRecord::subserviceID() const { return mAttributes[1]; }
94 string PrimaryRecord::moduleName() const { return mAttributes[2]; }
95 string PrimaryRecord::productVersion() const { return mAttributes[3]; }
96 string PrimaryRecord::vendor() const { return mAttributes[4]; }
97
98
99 //
100 // CSP Primary relation (one record per CSP SSID)
101 //
102 static const char * const cspAttributes[] = {
103 // up to Vendor is handled by PrimaryRecord
104 "CspType",
105 "CspFlags",
106 NULL
107 };
108 CSP::CSP() : PrimaryRecord(cspAttributes) { }
109
110 uint32 CSP::cspType() const { return mAttributes[5]; }
111 CSSM_CSP_FLAGS CSP::cspFlags() const { return mAttributes[6]; }
112
113
114 //
115 // CSP capabilities relation
116 //
117 static const char * const capAttributes[] = {
118 "ModuleID",
119 "SSID",
120 "ContextType",
121 "AlgType",
122 "GroupId",
123 "AttributeType",
124 "Description",
125 NULL
126 };
127 CSPCapabilities::CSPCapabilities() : Record(capAttributes) { }
128
129 string CSPCapabilities::moduleID() const { return mAttributes[0]; }
130 uint32 CSPCapabilities::subserviceID() const { return mAttributes[1]; }
131 uint32 CSPCapabilities::contextType() const { return mAttributes[2]; }
132 uint32 CSPCapabilities::algorithm() const { return mAttributes[3]; }
133 uint32 CSPCapabilities::group() const { return mAttributes[4]; }
134 uint32 CSPCapabilities::attribute() const { return mAttributes[5]; }
135 string CSPCapabilities::description() const { return mAttributes[6]; }
136
137
138 //
139 // CSP SmartcardInfo relation (one record per smartcard token present)
140 //
141 static const char * const scAttributes[] = {
142 "ModuleID",
143 "SSID",
144 "ScDesc",
145 "ScVendor",
146 "ScVersion",
147 "ScFirmwareVersion",
148 "ScFlags",
149 "ScCustomFlags",
150 "ScSerialNumber",
151 NULL
152 };
153 SmartcardInfo::SmartcardInfo() : Record(scAttributes) { }
154
155 string SmartcardInfo::moduleID() const { return mAttributes[0]; }
156 uint32 SmartcardInfo::subserviceID() const { return mAttributes[1]; }
157 string SmartcardInfo::description() const { return mAttributes[2]; }
158 string SmartcardInfo::vendor() const { return mAttributes[3]; }
159 string SmartcardInfo::version() const { return mAttributes[4]; }
160 string SmartcardInfo::firmware() const { return mAttributes[5]; }
161 CSSM_SC_FLAGS SmartcardInfo::flags() const { return mAttributes[6]; }
162 CSSM_SC_FLAGS SmartcardInfo::customFlags() const { return mAttributes[7]; }
163 string SmartcardInfo::serial() const { return mAttributes[8]; }
164
165
166 //
167 // DL Primary relation (one record per DL SSID)
168 //
169 static const char * const dlAttributes[] = {
170 // up to Vendor is handled by PrimaryRecord
171 "DLType",
172 "QueryLimitsFlag",
173 NULL
174 };
175 DL::DL() : PrimaryRecord(dlAttributes) { }
176
177 uint32 DL::dlType() const { return mAttributes[5]; }
178 uint32 DL::queryLimits() const { return mAttributes[6]; }
179
180
181 //
182 // CL Primary relation (one record per CL SSID)
183 //
184 static const char * const clAttributes[] = {
185 // up to Vendor is handled by PrimaryRecord
186 "CertTypeFormat",
187 "CrlTypeFormat",
188 NULL
189 };
190 CL::CL() : PrimaryRecord(clAttributes) { }
191
192 uint32 CL::certTypeFormat() const { return mAttributes[5]; }
193 uint32 CL::crlTypeFormat() const { return mAttributes[6]; }
194
195
196 //
197 // TP Primary relation (one record per TP SSID)
198 //
199 static const char * const tpAttributes[] = {
200 // up to Vendor is handled by PrimaryRecord
201 "CertTypeFormat",
202 NULL
203 };
204 TP::TP() : PrimaryRecord(tpAttributes) { }
205
206 uint32 TP::certTypeFormat() const { return mAttributes[5]; }
207
208
209 //
210 // TP Policy-OIDS relation (one record per supported policy and TP)
211 //
212 static const char * const policyAttributes[] = {
213 "ModuleID",
214 "SSID",
215 "OID",
216 "Value",
217 NULL
218 };
219 PolicyOids::PolicyOids() : Record(policyAttributes) { }
220
221 string PolicyOids::moduleID() const { return mAttributes[0]; }
222 uint32 PolicyOids::subserviceID() const { return mAttributes[1]; }
223 CssmData PolicyOids::oid() const { return mAttributes[2]; }
224 CssmData PolicyOids::value() const { return mAttributes[3]; }
225
226
227 } // end namespace MDSClient
228 } // end namespace Security