]> git.saurik.com Git - apple/security.git/blob - OSX/sec/securityd/SecItemSchema.c
Security-57337.40.85.tar.gz
[apple/security.git] / OSX / sec / securityd / SecItemSchema.c
1 /*
2 * Copyright (c) 2006-2014 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /*
25 * SecItemSchema.c - CoreFoundation-based constants and functions for
26 access to Security items (certificates, keys, identities, and
27 passwords.)
28 */
29
30 #include "SecItemSchema.h"
31 #include <securityd/SecDbKeychainItem.h>
32
33 // MARK -
34 // MARK Keychain version 6 schema
35
36 #define __FLAGS(ARG, ...) SECDBFLAGS(__VA_ARGS__)
37 #define SECDBFLAGS(ARG, ...) __FLAGS_##ARG | __FLAGS(__VA_ARGS__)
38
39 #define SecDbFlags(P,L,I,S,A,D,R,C,H,B,Z,E,N,U,V) (__FLAGS_##P|__FLAGS_##L|__FLAGS_##I|__FLAGS_##S|__FLAGS_##A|__FLAGS_##D|__FLAGS_##R|__FLAGS_##C|__FLAGS_##H|__FLAGS_##B|__FLAGS_##Z|__FLAGS_##E|__FLAGS_##N|__FLAGS_##U|__FLAGS_##V)
40
41 #define __FLAGS_ 0
42 #define __FLAGS_P kSecDbPrimaryKeyFlag
43 #define __FLAGS_L kSecDbInFlag
44 #define __FLAGS_I kSecDbIndexFlag
45 #define __FLAGS_S kSecDbSHA1ValueInFlag
46 #define __FLAGS_A kSecDbReturnAttrFlag
47 #define __FLAGS_D kSecDbReturnDataFlag
48 #define __FLAGS_R kSecDbReturnRefFlag
49 #define __FLAGS_C kSecDbInCryptoDataFlag
50 #define __FLAGS_H kSecDbInHashFlag
51 #define __FLAGS_B kSecDbInBackupFlag
52 #define __FLAGS_Z kSecDbDefault0Flag
53 #define __FLAGS_E kSecDbDefaultEmptyFlag
54 #define __FLAGS_N kSecDbNotNullFlag
55 #define __FLAGS_U kSecDbInAuthenticatedDataFlag
56 #define __FLAGS_V0 kSecDbSyncPrimaryKeyV0
57 #define __FLAGS_V2 (kSecDbSyncPrimaryKeyV0 | kSecDbSyncPrimaryKeyV2)
58
59 // ,-------------- P : Part of primary key
60 // / ,------------- L : Stored in local database
61 // / / ,------------ I : Attribute wants an index in the database
62 // / / / ,----------- S : SHA1 hashed attribute value in database (implies L)
63 // / / / / ,---------- A : Returned to client as attribute in queries
64 // / / / / / ,--------- D : Returned to client as data in queries
65 // / / / / / / ,-------- R : Returned to client as ref/persistent ref in queries
66 // / / / / / / / ,------- C : Part of encrypted blob
67 // / / / / / / / / ,------ H : Attribute is part of item SHA1 hash (Implied by C)
68 // / / / / / / / / / ,----- B : Attribute is part of iTunes/iCloud backup bag
69 // / / / / / / / / / / ,---- Z : Attribute has a default value of 0
70 // / / / / / / / / / / / ,--- E : Attribute has a default value of "" or empty data
71 // / / / / / / / / / / / / ,-- N : Attribute must have a value
72 // / / / / / / / / / / / / / ,- U : Attribute is stored in authenticated, but not necessarily encrypted data
73 // / / / / / / / / / / / / / / - S : Sync primpary key version
74 // / / / / / / / / / / / / / / /
75 // | | | | | | | | | | | | | | |
76 // common to all | | | | | | | | | | | | | | |
77 SECDB_ATTR(v6rowid, "rowid", RowId, SecDbFlags( ,L, , , , ,R, , ,B, , , , , ), NULL, NULL);
78 SECDB_ATTR(v6cdat, "cdat", CreationDate, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), SecDbKeychainItemCopyCurrentDate, NULL);
79 SECDB_ATTR(v6mdat, "mdat",ModificationDate,SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), SecDbKeychainItemCopyCurrentDate, NULL);
80 SECDB_ATTR(v6labl, "labl", Blob, SecDbFlags( ,L, ,S,A, , ,C,H, , , , , , ), NULL, NULL);
81 SECDB_ATTR(v6data, "data", EncryptedData, SecDbFlags( ,L, , , , , , , ,B, , , , , ), SecDbKeychainItemCopyEncryptedData, NULL);
82 SECDB_ATTR(v6agrp, "agrp", String, SecDbFlags(P,L, , ,A, , , ,H, , , ,N,U,V0), NULL, NULL);
83 SECDB_ATTR(v6pdmn, "pdmn", Access, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), NULL, NULL);
84 SECDB_ATTR(v6sync, "sync", Sync, SecDbFlags(P,L,I, ,A, , , ,H, ,Z, ,N,U,V0), NULL, NULL);
85 SECDB_ATTR(v6tomb, "tomb", Tomb, SecDbFlags( ,L, , , , , , ,H, ,Z, ,N,U, ), NULL, NULL);
86 SECDB_ATTR(v6sha1, "sha1", SHA1, SecDbFlags( ,L,I, ,A, ,R, , , , , , , , ), SecDbKeychainItemCopySHA1, NULL);
87 SECDB_ATTR(v6accc, "accc", AccessControl, SecDbFlags( , , , ,A, , , , , , , , , , ), NULL, NULL);
88 SECDB_ATTR(v6v_Data, "v_Data", Data, SecDbFlags( , , , , ,D, ,C,H, , , , , , ), NULL, NULL);
89 SECDB_ATTR(v6v_pk, "v_pk", PrimaryKey, SecDbFlags( , , , , , , , , , , , , , , ), SecDbKeychainItemCopyPrimaryKey, NULL);
90 SECDB_ATTR(v7vwht, "vwht", String, SecDbFlags(P,L, , ,A, , , ,H, , , , ,U,V2), NULL, NULL);
91 SECDB_ATTR(v7tkid, "tkid", String, SecDbFlags(P,L, , ,A, , , ,H, , , , ,U,V2), NULL, NULL);
92 SECDB_ATTR(v7utomb, "u_Tomb", UTomb, SecDbFlags( , , , , , , , , , , , , , , ), NULL, NULL);
93 SECDB_ATTR(v8musr, "musr", UUID, SecDbFlags(P,L,I, , , , , , , , , ,N,U, ), NULL, NULL);
94 // genp and inet and keys | | | | | | | | | | | | | | |
95 SECDB_ATTR(v6crtr, "crtr", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), NULL, NULL);
96 SECDB_ATTR(v6alis, "alis", Blob, SecDbFlags( ,L, ,S,A, , ,C,H, , , , , , ), NULL, NULL);
97 // genp and inet | | | | | | | | | | | | | | |
98 SECDB_ATTR(v6desc, "desc", Blob, SecDbFlags( ,L, ,S,A, , ,C,H, , , , , , ), NULL, NULL);
99 SECDB_ATTR(v6icmt, "icmt", Blob, SecDbFlags( ,L, ,S,A, , ,C,H, , , , , , ), NULL, NULL);
100 SECDB_ATTR(v6type, "type", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), NULL, NULL);
101 SECDB_ATTR(v6invi, "invi", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), NULL, NULL);
102 SECDB_ATTR(v6nega, "nega", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), NULL, NULL);
103 SECDB_ATTR(v6cusi, "cusi", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), NULL, NULL);
104 SECDB_ATTR(v6prot, "prot", Blob, SecDbFlags( ,L, ,S,A, , ,C,H, , , , , , ), NULL, NULL);
105 SECDB_ATTR(v6scrp, "scrp", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), NULL, NULL);
106 SECDB_ATTR(v6acct, "acct", Blob, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0), NULL, NULL);
107 // genp only | | | | | | | | | | | | | | |
108 SECDB_ATTR(v6svce, "svce", Blob, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0), NULL, NULL);
109 SECDB_ATTR(v6gena, "gena", Blob, SecDbFlags( ,L, ,S,A, , ,C,H, , , , , , ), NULL, NULL);
110 // inet only | | | | | | | | | | | | | | |
111 SECDB_ATTR(v6sdmn, "sdmn", Blob, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0), NULL, NULL);
112 SECDB_ATTR(v6srvr, "srvr", Blob, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0), NULL, NULL);
113 SECDB_ATTR(v6ptcl, "ptcl", Number, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0), NULL, NULL);
114 SECDB_ATTR(v6atyp, "atyp", Blob, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0), NULL, NULL);
115 SECDB_ATTR(v6port, "port", Number, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0), NULL, NULL);
116 SECDB_ATTR(v6path, "path", Blob, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0), NULL, NULL);
117 // cert only | | | | | | | | | | | | | | |
118 SECDB_ATTR(v6ctyp, "ctyp", Number, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0), NULL, NULL);
119 SECDB_ATTR(v6cenc, "cenc", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), NULL, NULL);
120 SECDB_ATTR(v6subj, "subj", Data, SecDbFlags( ,L,I,S,A, , ,C,H, , , , , , ), NULL, NULL);
121 SECDB_ATTR(v6issr, "issr", Data, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0), NULL, NULL);
122 SECDB_ATTR(v6slnr, "slnr", Data, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0), NULL, NULL);
123 SECDB_ATTR(v6skid, "skid", Data, SecDbFlags( ,L,I,S,A, , ,C,H, , , , , , ), NULL, NULL);
124 SECDB_ATTR(v6pkhh, "pkhh", Data, SecDbFlags( ,L,I, ,A, , ,C,H, , , , , , ), NULL, NULL);
125 // cert attributes that share names with common ones but have different flags
126 SECDB_ATTR(v6certalis, "alis", Blob, SecDbFlags( ,L,I,S,A, , ,C,H, , , , , , ), NULL, NULL);
127 // keys only | | | | | | | | | | | | | | |
128 SECDB_ATTR(v6kcls, "kcls", Number, SecDbFlags(P,L,I,S,A, , ,C,H, ,Z, ,N, ,V0), NULL, NULL);
129 SECDB_ATTR(v6perm, "perm", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), NULL, NULL);
130 SECDB_ATTR(v6priv, "priv", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), NULL, NULL);
131 SECDB_ATTR(v6modi, "modi", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), NULL, NULL);
132 SECDB_ATTR(v6klbl, "klbl", Data, SecDbFlags(P,L,I, ,A, , ,C,H, , ,E,N, ,V0), NULL, NULL);
133 SECDB_ATTR(v6atag, "atag", Blob, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0), NULL, NULL);
134 SECDB_ATTR(v6bsiz, "bsiz", Number, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0), NULL, NULL);
135 SECDB_ATTR(v6esiz, "esiz", Number, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0), NULL, NULL);
136 SECDB_ATTR(v6sdat, "sdat", Date, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0), NULL, NULL);
137 SECDB_ATTR(v6edat, "edat", Date, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0), NULL, NULL);
138 SECDB_ATTR(v6sens, "sens", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), NULL, NULL);
139 SECDB_ATTR(v6asen, "asen", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), NULL, NULL);
140 SECDB_ATTR(v6extr, "extr", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), NULL, NULL);
141 SECDB_ATTR(v6next, "next", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), NULL, NULL);
142 SECDB_ATTR(v6encr, "encr", Number, SecDbFlags( ,L,I, ,A, , ,C,H, , , , , , ), NULL, NULL);
143 SECDB_ATTR(v6decr, "decr", Number, SecDbFlags( ,L,I, ,A, , ,C,H, , , , , , ), NULL, NULL);
144 SECDB_ATTR(v6drve, "drve", Number, SecDbFlags( ,L,I, ,A, , ,C,H, , , , , , ), NULL, NULL);
145 SECDB_ATTR(v6sign, "sign", Number, SecDbFlags( ,L,I, ,A, , ,C,H, , , , , , ), NULL, NULL);
146 SECDB_ATTR(v6vrfy, "vrfy", Number, SecDbFlags( ,L,I, ,A, , ,C,H, , , , , , ), NULL, NULL);
147 SECDB_ATTR(v6snrc, "snrc", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), NULL, NULL);
148 SECDB_ATTR(v6vyrc, "vyrc", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ), NULL, NULL);
149 SECDB_ATTR(v6wrap, "wrap", Number, SecDbFlags( ,L,I, ,A, , ,C,H, , , , , , ), NULL, NULL);
150 SECDB_ATTR(v6unwp, "unwp", Number, SecDbFlags( ,L,I, ,A, , ,C,H, , , , , , ), NULL, NULL);
151 // keys attributes that share names with common ones but have different flags
152 SECDB_ATTR(v6keytype, "type", Number, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0), NULL, NULL);
153 SECDB_ATTR(v6keycrtr, "crtr", Number, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0), NULL, NULL);
154 // | | | | | | | | | | | | | | |
155 SECDB_ATTR(v6version, "version", Number, SecDbFlags(P,L, , , , , , , , , , ,N, , ), NULL, NULL);
156
157 const SecDbClass genp_class = {
158 .name = CFSTR("genp"),
159 .attrs = {
160 &v6rowid,
161 &v6cdat,
162 &v6mdat,
163 &v6desc,
164 &v6icmt,
165 &v6crtr,
166 &v6type,
167 &v6scrp,
168 &v6labl,
169 &v6alis,
170 &v6invi,
171 &v6nega,
172 &v6cusi,
173 &v6prot,
174 &v6acct,
175 &v6svce,
176 &v6gena,
177 &v6data,
178 &v6agrp,
179 &v6pdmn,
180 &v6sync,
181 &v6tomb,
182 &v6sha1,
183 &v7vwht,
184 &v7tkid,
185 &v6v_Data,
186 &v6v_pk,
187 &v6accc,
188 &v7utomb,
189 &v8musr,
190 0
191 },
192 };
193
194 const SecDbClass inet_class = {
195 .name = CFSTR("inet"),
196 .attrs = {
197 &v6rowid,
198 &v6cdat,
199 &v6mdat,
200 &v6desc,
201 &v6icmt,
202 &v6crtr,
203 &v6type,
204 &v6scrp,
205 &v6labl,
206 &v6alis,
207 &v6invi,
208 &v6nega,
209 &v6cusi,
210 &v6prot,
211 &v6acct,
212 &v6sdmn,
213 &v6srvr,
214 &v6ptcl,
215 &v6atyp,
216 &v6port,
217 &v6path,
218 &v6data,
219 &v6agrp,
220 &v6pdmn,
221 &v6sync,
222 &v6tomb,
223 &v6sha1,
224 &v7vwht,
225 &v7tkid,
226 &v6v_Data,
227 &v6v_pk,
228 &v6accc,
229 &v7utomb,
230 &v8musr,
231 0
232 },
233 };
234
235 const SecDbClass cert_class = {
236 .name = CFSTR("cert"),
237 .attrs = {
238 &v6rowid,
239 &v6cdat,
240 &v6mdat,
241 &v6ctyp,
242 &v6cenc,
243 &v6labl,
244 &v6certalis,
245 &v6subj,
246 &v6issr,
247 &v6slnr,
248 &v6skid,
249 &v6pkhh,
250 &v6data,
251 &v6agrp,
252 &v6pdmn,
253 &v6sync,
254 &v6tomb,
255 &v6sha1,
256 &v7vwht,
257 &v7tkid,
258 &v6v_Data,
259 &v6v_pk,
260 &v6accc,
261 &v7utomb,
262 &v8musr,
263 0
264 },
265 };
266
267 const SecDbClass keys_class = {
268 .name = CFSTR("keys"),
269 .attrs = {
270 &v6rowid,
271 &v6cdat,
272 &v6mdat,
273 &v6kcls,
274 &v6labl,
275 &v6alis,
276 &v6perm,
277 &v6priv,
278 &v6modi,
279 &v6klbl,
280 &v6atag,
281 &v6keycrtr,
282 &v6keytype,
283 &v6bsiz,
284 &v6esiz,
285 &v6sdat,
286 &v6edat,
287 &v6sens,
288 &v6asen,
289 &v6extr,
290 &v6next,
291 &v6encr,
292 &v6decr,
293 &v6drve,
294 &v6sign,
295 &v6vrfy,
296 &v6snrc,
297 &v6vyrc,
298 &v6wrap,
299 &v6unwp,
300 &v6data,
301 &v6agrp,
302 &v6pdmn,
303 &v6sync,
304 &v6tomb,
305 &v6sha1,
306 &v7vwht,
307 &v7tkid,
308 &v6v_Data,
309 &v6v_pk,
310 &v6accc,
311 &v7utomb,
312 &v8musr,
313 0
314 }
315 };
316
317 const SecDbClass tversion_class = {
318 .name = CFSTR("tversion"),
319 .attrs = {
320 &v6version,
321 0
322 }
323 };
324
325 /* An identity which is really a cert + a key, so all cert and keys attrs are
326 allowed. */
327 const SecDbClass identity_class = {
328 .name = CFSTR("idnt"),
329 .attrs = {
330 0
331 },
332 };
333
334 /* Version 9 (iOS 9.3 and OSX 10.11.5) database schema
335 * Same contents as v8 tables; table names changed to force upgrade
336 * and correct default values in table. */
337 const SecDbSchema v9_schema = {
338 9,
339 .classes = {
340 &genp_class,
341 &inet_class,
342 &cert_class,
343 &keys_class,
344 &tversion_class,
345 0
346 }
347 };
348
349 // Version 8 (Internal release iOS 9.3 and OSX 10.11.5) database schema
350 const SecDbClass v8genp_class = {
351 .name = CFSTR("genp8"),
352 .attrs = {
353 &v6rowid,
354 &v6cdat,
355 &v6mdat,
356 &v6desc,
357 &v6icmt,
358 &v6crtr,
359 &v6type,
360 &v6scrp,
361 &v6labl,
362 &v6alis,
363 &v6invi,
364 &v6nega,
365 &v6cusi,
366 &v6prot,
367 &v6acct,
368 &v6svce,
369 &v6gena,
370 &v6data,
371 &v6agrp,
372 &v6pdmn,
373 &v6sync,
374 &v6tomb,
375 &v6sha1,
376 &v7vwht,
377 &v7tkid,
378 &v6v_Data,
379 &v6v_pk,
380 &v6accc,
381 &v7utomb,
382 &v8musr,
383 0
384 },
385 };
386
387 const SecDbClass v8inet_class = {
388 .name = CFSTR("inet8"),
389 .attrs = {
390 &v6rowid,
391 &v6cdat,
392 &v6mdat,
393 &v6desc,
394 &v6icmt,
395 &v6crtr,
396 &v6type,
397 &v6scrp,
398 &v6labl,
399 &v6alis,
400 &v6invi,
401 &v6nega,
402 &v6cusi,
403 &v6prot,
404 &v6acct,
405 &v6sdmn,
406 &v6srvr,
407 &v6ptcl,
408 &v6atyp,
409 &v6port,
410 &v6path,
411 &v6data,
412 &v6agrp,
413 &v6pdmn,
414 &v6sync,
415 &v6tomb,
416 &v6sha1,
417 &v7vwht,
418 &v7tkid,
419 &v6v_Data,
420 &v6v_pk,
421 &v6accc,
422 &v7utomb,
423 &v8musr,
424 0
425 },
426 };
427
428 const SecDbClass v8cert_class = {
429 .name = CFSTR("cert8"),
430 .attrs = {
431 &v6rowid,
432 &v6cdat,
433 &v6mdat,
434 &v6ctyp,
435 &v6cenc,
436 &v6labl,
437 &v6certalis,
438 &v6subj,
439 &v6issr,
440 &v6slnr,
441 &v6skid,
442 &v6pkhh,
443 &v6data,
444 &v6agrp,
445 &v6pdmn,
446 &v6sync,
447 &v6tomb,
448 &v6sha1,
449 &v7vwht,
450 &v7tkid,
451 &v6v_Data,
452 &v6v_pk,
453 &v6accc,
454 &v7utomb,
455 &v8musr,
456 0
457 },
458 };
459
460 const SecDbClass v8keys_class = {
461 .name = CFSTR("keys8"),
462 .attrs = {
463 &v6rowid,
464 &v6cdat,
465 &v6mdat,
466 &v6kcls,
467 &v6labl,
468 &v6alis,
469 &v6perm,
470 &v6priv,
471 &v6modi,
472 &v6klbl,
473 &v6atag,
474 &v6keycrtr,
475 &v6keytype,
476 &v6bsiz,
477 &v6esiz,
478 &v6sdat,
479 &v6edat,
480 &v6sens,
481 &v6asen,
482 &v6extr,
483 &v6next,
484 &v6encr,
485 &v6decr,
486 &v6drve,
487 &v6sign,
488 &v6vrfy,
489 &v6snrc,
490 &v6vyrc,
491 &v6wrap,
492 &v6unwp,
493 &v6data,
494 &v6agrp,
495 &v6pdmn,
496 &v6sync,
497 &v6tomb,
498 &v6sha1,
499 &v7vwht,
500 &v7tkid,
501 &v6v_Data,
502 &v6v_pk,
503 &v6accc,
504 &v7utomb,
505 &v8musr,
506 0
507 }
508 };
509
510 const SecDbSchema v8_schema = {
511 8,
512 .classes = {
513 &v8genp_class,
514 &v8inet_class,
515 &v8cert_class,
516 &v8keys_class,
517 &tversion_class,
518 0
519 }
520 };
521
522 // Version 7 (iOS 9 and OSX 10.11) database schema
523 const SecDbClass v7genp_class = {
524 .name = CFSTR("genp7"),
525 .attrs = {
526 &v6rowid,
527 &v6cdat,
528 &v6mdat,
529 &v6desc,
530 &v6icmt,
531 &v6crtr,
532 &v6type,
533 &v6scrp,
534 &v6labl,
535 &v6alis,
536 &v6invi,
537 &v6nega,
538 &v6cusi,
539 &v6prot,
540 &v6acct,
541 &v6svce,
542 &v6gena,
543 &v6data,
544 &v6agrp,
545 &v6pdmn,
546 &v6sync,
547 &v6tomb,
548 &v6sha1,
549 &v7vwht,
550 &v7tkid,
551 &v6v_Data,
552 &v6v_pk,
553 &v6accc,
554 &v7utomb,
555 0
556 },
557 };
558
559 const SecDbClass v7inet_class = {
560 .name = CFSTR("inet7"),
561 .attrs = {
562 &v6rowid,
563 &v6cdat,
564 &v6mdat,
565 &v6desc,
566 &v6icmt,
567 &v6crtr,
568 &v6type,
569 &v6scrp,
570 &v6labl,
571 &v6alis,
572 &v6invi,
573 &v6nega,
574 &v6cusi,
575 &v6prot,
576 &v6acct,
577 &v6sdmn,
578 &v6srvr,
579 &v6ptcl,
580 &v6atyp,
581 &v6port,
582 &v6path,
583 &v6data,
584 &v6agrp,
585 &v6pdmn,
586 &v6sync,
587 &v6tomb,
588 &v6sha1,
589 &v7vwht,
590 &v7tkid,
591 &v6v_Data,
592 &v6v_pk,
593 &v6accc,
594 &v7utomb,
595 0
596 },
597 };
598
599 const SecDbClass v7cert_class = {
600 .name = CFSTR("cert7"),
601 .attrs = {
602 &v6rowid,
603 &v6cdat,
604 &v6mdat,
605 &v6ctyp,
606 &v6cenc,
607 &v6labl,
608 &v6certalis,
609 &v6subj,
610 &v6issr,
611 &v6slnr,
612 &v6skid,
613 &v6pkhh,
614 &v6data,
615 &v6agrp,
616 &v6pdmn,
617 &v6sync,
618 &v6tomb,
619 &v6sha1,
620 &v7vwht,
621 &v7tkid,
622 &v6v_Data,
623 &v6v_pk,
624 &v6accc,
625 &v7utomb,
626 0
627 },
628 };
629
630 const SecDbClass v7keys_class = {
631 .name = CFSTR("keys7"),
632 .attrs = {
633 &v6rowid,
634 &v6cdat,
635 &v6mdat,
636 &v6kcls,
637 &v6labl,
638 &v6alis,
639 &v6perm,
640 &v6priv,
641 &v6modi,
642 &v6klbl,
643 &v6atag,
644 &v6keycrtr,
645 &v6keytype,
646 &v6bsiz,
647 &v6esiz,
648 &v6sdat,
649 &v6edat,
650 &v6sens,
651 &v6asen,
652 &v6extr,
653 &v6next,
654 &v6encr,
655 &v6decr,
656 &v6drve,
657 &v6sign,
658 &v6vrfy,
659 &v6snrc,
660 &v6vyrc,
661 &v6wrap,
662 &v6unwp,
663 &v6data,
664 &v6agrp,
665 &v6pdmn,
666 &v6sync,
667 &v6tomb,
668 &v6sha1,
669 &v7vwht,
670 &v7tkid,
671 &v6v_Data,
672 &v6v_pk,
673 &v6accc,
674 &v7utomb,
675 0
676 }
677 };
678
679
680 const SecDbSchema v7_schema = {
681 7,
682 .classes = {
683 &v7genp_class,
684 &v7inet_class,
685 &v7cert_class,
686 &v7keys_class,
687 &tversion_class,
688 0
689 }
690 };
691
692
693 // Version 6 (iOS 7 and OSX 10.9) database schema
694 static const SecDbClass v6genp_class = {
695 .name = CFSTR("genp6"),
696 .attrs = {
697 &v6rowid,
698 &v6cdat,
699 &v6mdat,
700 &v6desc,
701 &v6icmt,
702 &v6crtr,
703 &v6type,
704 &v6scrp,
705 &v6labl,
706 &v6alis,
707 &v6invi,
708 &v6nega,
709 &v6cusi,
710 &v6prot,
711 &v6acct,
712 &v6svce,
713 &v6gena,
714 &v6data,
715 &v6agrp,
716 &v6pdmn,
717 &v6sync,
718 &v6tomb,
719 &v6sha1,
720 &v6v_Data,
721 &v6v_pk,
722 &v6accc,
723 0
724 },
725 };
726
727 static const SecDbClass v6inet_class = {
728 .name = CFSTR("inet6"),
729 .attrs = {
730 &v6rowid,
731 &v6cdat,
732 &v6mdat,
733 &v6desc,
734 &v6icmt,
735 &v6crtr,
736 &v6type,
737 &v6scrp,
738 &v6labl,
739 &v6alis,
740 &v6invi,
741 &v6nega,
742 &v6cusi,
743 &v6prot,
744 &v6acct,
745 &v6sdmn,
746 &v6srvr,
747 &v6ptcl,
748 &v6atyp,
749 &v6port,
750 &v6path,
751 &v6data,
752 &v6agrp,
753 &v6pdmn,
754 &v6sync,
755 &v6tomb,
756 &v6sha1,
757 &v6v_Data,
758 &v6v_pk,
759 &v6accc,
760 0
761 },
762 };
763
764 static const SecDbClass v6cert_class = {
765 .name = CFSTR("cert6"),
766 .attrs = {
767 &v6rowid,
768 &v6cdat,
769 &v6mdat,
770 &v6ctyp,
771 &v6cenc,
772 &v6labl,
773 &v6certalis,
774 &v6subj,
775 &v6issr,
776 &v6slnr,
777 &v6skid,
778 &v6pkhh,
779 &v6data,
780 &v6agrp,
781 &v6pdmn,
782 &v6sync,
783 &v6tomb,
784 &v6sha1,
785 &v6v_Data,
786 &v6v_pk,
787 &v6accc,
788 0
789 },
790 };
791
792 static const SecDbClass v6keys_class = {
793 .name = CFSTR("keys6"),
794 .attrs = {
795 &v6rowid,
796 &v6cdat,
797 &v6mdat,
798 &v6kcls,
799 &v6labl,
800 &v6alis,
801 &v6perm,
802 &v6priv,
803 &v6modi,
804 &v6klbl,
805 &v6atag,
806 &v6keycrtr,
807 &v6keytype,
808 &v6bsiz,
809 &v6esiz,
810 &v6sdat,
811 &v6edat,
812 &v6sens,
813 &v6asen,
814 &v6extr,
815 &v6next,
816 &v6encr,
817 &v6decr,
818 &v6drve,
819 &v6sign,
820 &v6vrfy,
821 &v6snrc,
822 &v6vyrc,
823 &v6wrap,
824 &v6unwp,
825 &v6data,
826 &v6agrp,
827 &v6pdmn,
828 &v6sync,
829 &v6tomb,
830 &v6sha1,
831 &v6v_Data,
832 &v6v_pk,
833 &v6accc,
834 0
835 }
836 };
837
838 static const SecDbSchema v6_schema = {
839 6,
840 .classes = {
841 &v6genp_class,
842 &v6inet_class,
843 &v6cert_class,
844 &v6keys_class,
845 &tversion_class,
846 0
847 }
848 };
849
850
851 // Version 5 (iOS 5 & iOS 6) database schema.
852 static const SecDbClass v5genp_class = {
853 .name = CFSTR("genp5"),
854 .attrs = {
855 &v6rowid,
856 &v6cdat,
857 &v6mdat,
858 &v6desc,
859 &v6icmt,
860 &v6crtr,
861 &v6type,
862 &v6scrp,
863 &v6labl,
864 &v6alis,
865 &v6invi,
866 &v6nega,
867 &v6cusi,
868 &v6prot,
869 &v6acct,
870 &v6svce,
871 &v6gena,
872 &v6data,
873 &v6agrp,
874 &v6pdmn,
875 &v6v_Data,
876 0
877 },
878 };
879
880 static const SecDbClass v5inet_class = {
881 .name = CFSTR("inet5"),
882 .attrs = {
883 &v6rowid,
884 &v6cdat,
885 &v6mdat,
886 &v6desc,
887 &v6icmt,
888 &v6crtr,
889 &v6type,
890 &v6scrp,
891 &v6labl,
892 &v6alis,
893 &v6invi,
894 &v6nega,
895 &v6cusi,
896 &v6prot,
897 &v6acct,
898 &v6sdmn,
899 &v6srvr,
900 &v6ptcl,
901 &v6atyp,
902 &v6port,
903 &v6path,
904 &v6data,
905 &v6agrp,
906 &v6pdmn,
907 &v6v_Data,
908 0
909 },
910 };
911
912 static const SecDbClass v5cert_class = {
913 .name = CFSTR("cert5"),
914 .attrs = {
915 &v6rowid,
916 &v6cdat,
917 &v6mdat,
918 &v6ctyp,
919 &v6cenc,
920 &v6labl,
921 &v6certalis,
922 &v6subj,
923 &v6issr,
924 &v6slnr,
925 &v6skid,
926 &v6pkhh,
927 &v6data,
928 &v6agrp,
929 &v6pdmn,
930 &v6v_Data,
931 0
932 },
933 };
934
935 static const SecDbClass v5keys_class = {
936 .name = CFSTR("keys5"),
937 .attrs = {
938 &v6rowid,
939 &v6cdat,
940 &v6mdat,
941 &v6kcls,
942 &v6labl,
943 &v6alis,
944 &v6perm,
945 &v6priv,
946 &v6modi,
947 &v6klbl,
948 &v6atag,
949 &v6keycrtr,
950 &v6keytype,
951 &v6bsiz,
952 &v6esiz,
953 &v6sdat,
954 &v6edat,
955 &v6sens,
956 &v6asen,
957 &v6extr,
958 &v6next,
959 &v6encr,
960 &v6decr,
961 &v6drve,
962 &v6sign,
963 &v6vrfy,
964 &v6snrc,
965 &v6vyrc,
966 &v6wrap,
967 &v6unwp,
968 &v6data,
969 &v6agrp,
970 &v6pdmn,
971 &v6v_Data,
972 0
973 }
974 };
975
976 static const SecDbSchema v5_schema = {
977 5,
978 .classes = {
979 &v5genp_class,
980 &v5inet_class,
981 &v5cert_class,
982 &v5keys_class,
983 &tversion_class,
984 0
985 }
986 };
987
988 const SecDbSchema *kc_schemas[] = {
989 &v9_schema,
990 &v8_schema,
991 &v7_schema,
992 &v6_schema,
993 &v5_schema,
994 0
995 };