]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_cdsa_client/lib/mds_standard.h
Security-57336.1.9.tar.gz
[apple/security.git] / OSX / libsecurity_cdsa_client / lib / mds_standard.h
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 // These are the C++ record types corresponding to standard and Apple-defined
23 // MDS relations. Note that not all standard fields are included; only those
24 // of particular interest to the implementation. Feel free to add field functions
25 // as needed.
26 //
27
28 #ifndef _H_CDSA_CLIENT_MDS_STANDARD
29 #define _H_CDSA_CLIENT_MDS_STANDARD
30
31 #include <security_cdsa_client/mdsclient.h>
32
33
34 namespace Security {
35 namespace MDSClient {
36
37
38 //
39 // The CDSA Common table (one record per module)
40 //
41 class Common : public Record {
42 public:
43 Common();
44 static const CSSM_DB_RECORDTYPE recordType = MDS_CDSADIR_COMMON_RECORDTYPE;
45
46 string moduleID() const;
47 string moduleName() const;
48 string path() const;
49 string description() const;
50 bool dynamic() const;
51 bool singleThreaded() const;
52 CSSM_SERVICE_MASK serviceMask() const;
53
54 public:
55 //
56 // "Link in" a Common into another record, whose attributes()[0] is the ModuleID
57 //
58 class Carrier {
59 public:
60 virtual ~Carrier();
61
62 string moduleName() const { return common().moduleName(); }
63 string path() const { return common().path(); }
64 string description() const { return common().description(); }
65 bool dynamic() const { return common().dynamic(); }
66 bool singleThreaded() const { return common().singleThreaded(); }
67 CSSM_SERVICE_MASK serviceMask() const { return common().serviceMask(); }
68
69 private:
70 mutable RefPointer<Common> mCommon;
71
72 Common &common() const;
73 };
74 };
75
76
77 //
78 // PrimaryRecord shapes the "common head" of all MDS primary relations
79 //
80 class PrimaryRecord : public Record, public Common::Carrier {
81 public:
82 PrimaryRecord(const char * const * names);
83
84 string moduleID() const;
85 uint32 subserviceID() const;
86 string moduleName() const;
87 string productVersion() const;
88 string vendor() const;
89 };
90
91
92 //
93 // The CSP Primary relation
94 //
95 class CSP : public PrimaryRecord {
96 public:
97 CSP();
98 static const CSSM_DB_RECORDTYPE recordType = MDS_CDSADIR_CSP_PRIMARY_RECORDTYPE;
99
100 uint32 cspType() const;
101 CSSM_CSP_FLAGS cspFlags() const;
102 };
103
104
105 //
106 // The CSP Capabilities relation
107 //
108 class CSPCapabilities : public Record, public Common::Carrier {
109 public:
110 CSPCapabilities();
111 static const CSSM_DB_RECORDTYPE recordType = MDS_CDSADIR_CSP_CAPABILITY_RECORDTYPE;
112
113 string moduleID() const;
114 uint32 subserviceID() const;
115 uint32 contextType() const;
116 uint32 algorithm() const;
117 uint32 group() const;
118 uint32 attribute() const;
119 string description() const;
120 };
121
122
123 //
124 // The CSP "smartcard token" relation
125 //
126 class SmartcardInfo : public Record, public Common::Carrier {
127 public:
128 SmartcardInfo();
129 static const CSSM_DB_RECORDTYPE recordType = MDS_CDSADIR_CSP_SC_INFO_RECORDTYPE;
130
131 string moduleID() const;
132 uint32 subserviceID() const;
133 string description() const;
134 string vendor() const;
135 string version() const;
136 string firmware() const;
137 CSSM_SC_FLAGS flags() const;
138 CSSM_SC_FLAGS customFlags() const;
139 string serial() const;
140 };
141
142
143 //
144 // The DL Primary relation
145 //
146 class DL : public PrimaryRecord {
147 public:
148 DL();
149 static const CSSM_DB_RECORDTYPE recordType = MDS_CDSADIR_DL_PRIMARY_RECORDTYPE;
150
151 uint32 dlType() const;
152 uint32 queryLimits() const;
153 };
154
155
156 //
157 // The CL Primary relation
158 //
159 class CL : public PrimaryRecord {
160 public:
161 CL();
162 static const CSSM_DB_RECORDTYPE recordType = MDS_CDSADIR_CL_PRIMARY_RECORDTYPE;
163
164 uint32 certTypeFormat() const;
165 uint32 certType() const { return certTypeFormat() >> 16; }
166 uint32 certEncoding() const { return certTypeFormat() & 0xFFFF; }
167 uint32 crlTypeFormat() const;
168 uint32 crlType() const { return crlTypeFormat() >> 16; }
169 uint32 crlEncoding() const { return crlTypeFormat() & 0xFFFF; }
170 };
171
172
173 //
174 // The TP Primary relation
175 //
176 class TP : public PrimaryRecord {
177 public:
178 TP();
179 static const CSSM_DB_RECORDTYPE recordType = MDS_CDSADIR_TP_PRIMARY_RECORDTYPE;
180
181 uint32 certTypeFormat() const;
182 uint32 certType() const { return certTypeFormat() >> 16; }
183 uint32 certEncoding() const { return certTypeFormat() & 0xFFFF; }
184 };
185
186
187 //
188 // The TP Policy-OIDS relation
189 //
190 class PolicyOids : public Record {
191 public:
192 PolicyOids();
193 static const CSSM_DB_RECORDTYPE recordType = MDS_CDSADIR_TP_OIDS_RECORDTYPE;
194
195 string moduleID() const;
196 uint32 subserviceID() const;
197 CssmData oid() const;
198 CssmData value() const;
199 };
200
201
202 } // end namespace MDSClient
203 } // end namespace Security
204
205 #endif // _H_CDSA_CLIENT_MDS_STANDARD