]> git.saurik.com Git - apple/security.git/blob - OSX/sec/securityd/SecItemSchema.c
Security-58286.51.6.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 #include <keychain/ckks/CKKS.h>
33
34 // MARK -
35 // MARK Keychain version 6 schema
36
37 #define __FLAGS(ARG, ...) SECDBFLAGS(__VA_ARGS__)
38 #define SECDBFLAGS(ARG, ...) __FLAGS_##ARG | __FLAGS(__VA_ARGS__)
39
40 #define SecDbFlags(P,L,I,S,A,D,R,C,H,B,Z,E,N,U,V,Y) (__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|__FLAGS_##Y)
41
42 #define __FLAGS_ 0
43 #define __FLAGS_P kSecDbPrimaryKeyFlag
44 #define __FLAGS_L kSecDbInFlag
45 #define __FLAGS_I kSecDbIndexFlag
46 #define __FLAGS_S kSecDbSHA1ValueInFlag
47 #define __FLAGS_A kSecDbReturnAttrFlag
48 #define __FLAGS_D kSecDbReturnDataFlag
49 #define __FLAGS_R kSecDbReturnRefFlag
50 #define __FLAGS_C kSecDbInCryptoDataFlag
51 #define __FLAGS_H kSecDbInHashFlag
52 #define __FLAGS_B kSecDbInBackupFlag
53 #define __FLAGS_Z kSecDbDefault0Flag
54 #define __FLAGS_E kSecDbDefaultEmptyFlag
55 #define __FLAGS_N kSecDbNotNullFlag
56 #define __FLAGS_U kSecDbInAuthenticatedDataFlag
57 #define __FLAGS_V0 kSecDbSyncPrimaryKeyV0
58 #define __FLAGS_V2 (kSecDbSyncPrimaryKeyV0 | kSecDbSyncPrimaryKeyV2)
59 #define __FLAGS_Y kSecDbSyncFlag
60
61 // ,----------------- P : Part of primary key
62 // / ,---------------- L : Stored in local database
63 // / / ,--------------- I : Attribute wants an index in the database
64 // / / / ,-------------- S : SHA1 hashed attribute value in database (implies L)
65 // / / / / ,------------- A : Returned to client as attribute in queries
66 // / / / / / ,------------ D : Returned to client as data in queries
67 // / / / / / / ,----------- R : Returned to client as ref/persistent ref in queries
68 // / / / / / / / ,---------- C : Part of encrypted blob
69 // / / / / / / / / ,--------- H : Attribute is part of item SHA1 hash (Implied by C)
70 // / / / / / / / / / ,-------- B : Attribute is part of iTunes/iCloud backup bag
71 // / / / / / / / / / / ,------- Z : Attribute has a default value of 0
72 // / / / / / / / / / / / ,------ E : Attribute has a default value of "" or empty data
73 // / / / / / / / / / / / / ,----- N : Attribute must have a value
74 // / / / / / / / / / / / / / ,---- U : Attribute is stored in authenticated, but not necessarily encrypted data
75 // / / / / / / / / / / / / / / ,--- V0: Sync primary key version
76 // / / / / / / / / / / / / / / / ,- Y : Attribute should be synced
77 // | | | | | | | | | | | | | | | |
78 // common to all | | | | | | | | | | | | | | | |
79 SECDB_ATTR(v6rowid, "rowid", RowId, SecDbFlags( ,L, , , , ,R, , ,B, , , , , , ), NULL, NULL);
80 SECDB_ATTR(v6cdat, "cdat", CreationDate, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), SecDbKeychainItemCopyCurrentDate, NULL);
81 SECDB_ATTR(v6mdat, "mdat",ModificationDate,SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), SecDbKeychainItemCopyCurrentDate, NULL);
82 SECDB_ATTR(v6labl, "labl", Blob, SecDbFlags( ,L, ,S,A, , ,C,H, , , , , , ,Y), NULL, NULL);
83 SECDB_ATTR(v6data, "data", EncryptedData, SecDbFlags( ,L, , , , , , , ,B, , , , , , ), SecDbKeychainItemCopyEncryptedData, NULL);
84 SECDB_ATTR(v6agrp, "agrp", String, SecDbFlags(P,L, , ,A, , , ,H, , , ,N,U,V0,Y), NULL, NULL);
85 SECDB_ATTR(v6pdmn, "pdmn", Access, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
86 SECDB_ATTR(v6sync, "sync", Sync, SecDbFlags(P,L,I, ,A, , , ,H, ,Z, ,N,U,V0, ), NULL, NULL);
87 SECDB_ATTR(v6tomb, "tomb", Tomb, SecDbFlags( ,L, , , , , , ,H, ,Z, ,N,U, ,Y), NULL, NULL);
88 SECDB_ATTR(v6sha1, "sha1", SHA1, SecDbFlags( ,L,I, ,A, ,R, , , , , , , , ,Y), SecDbKeychainItemCopySHA1, NULL);
89 SECDB_ATTR(v6accc, "accc", AccessControl, SecDbFlags( , , , ,A, , , , , , , , , , , ), NULL, NULL);
90 SECDB_ATTR(v6v_Data, "v_Data", Data, SecDbFlags( , , , , ,D, ,C,H, , , , , , ,Y), NULL, NULL);
91 SECDB_ATTR(v6v_pk, "v_pk", PrimaryKey, SecDbFlags( , , , , , , , , , , , , , , , ), SecDbKeychainItemCopyPrimaryKey, NULL);
92 SECDB_ATTR(v7vwht, "vwht", String, SecDbFlags(P,L, , ,A, , , ,H, , , , ,U,V2,Y), NULL, NULL);
93 SECDB_ATTR(v7tkid, "tkid", String, SecDbFlags(P,L, , ,A, , , ,H, , , , ,U,V2,Y), NULL, NULL);
94 SECDB_ATTR(v7utomb, "u_Tomb", UTomb, SecDbFlags( , , , , , , , , , , , , , , , ), NULL, NULL);
95 SECDB_ATTR(v8musr, "musr", UUID, SecDbFlags(P,L,I, , , , , , , , , ,N,U, ,Y), NULL, NULL);
96 // genp and inet and keys | | | | | | | | | | | | | | | |
97 SECDB_ATTR(v6crtr, "crtr", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
98 SECDB_ATTR(v6alis, "alis", Blob, SecDbFlags( ,L, ,S,A, , ,C,H, , , , , , ,Y), NULL, NULL);
99 // genp and inet | | | | | | | | | | | | | | | |
100 SECDB_ATTR(v6desc, "desc", Blob, SecDbFlags( ,L, ,S,A, , ,C,H, , , , , , ,Y), NULL, NULL);
101 SECDB_ATTR(v6icmt, "icmt", Blob, SecDbFlags( ,L, ,S,A, , ,C,H, , , , , , ,Y), NULL, NULL);
102 SECDB_ATTR(v6type, "type", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
103 SECDB_ATTR(v6invi, "invi", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
104 SECDB_ATTR(v6nega, "nega", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
105 SECDB_ATTR(v6cusi, "cusi", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
106 SECDB_ATTR(v6prot, "prot", Blob, SecDbFlags( ,L, ,S,A, , ,C,H, , , , , , ,Y), NULL, NULL);
107 SECDB_ATTR(v6scrp, "scrp", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
108 SECDB_ATTR(v6acct, "acct", Blob, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0,Y), NULL, NULL);
109 // genp only | | | | | | | | | | | | | | | |
110 SECDB_ATTR(v6svce, "svce", Blob, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0,Y), NULL, NULL);
111 SECDB_ATTR(v6gena, "gena", Blob, SecDbFlags( ,L, ,S,A, , ,C,H, , , , , , ,Y), NULL, NULL);
112 // inet only | | | | | | | | | | | | | | | |
113 SECDB_ATTR(v6sdmn, "sdmn", Blob, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0,Y), NULL, NULL);
114 SECDB_ATTR(v6srvr, "srvr", Blob, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0,Y), NULL, NULL);
115 SECDB_ATTR(v6ptcl, "ptcl", Number, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0,Y), NULL, NULL);
116 SECDB_ATTR(v6atyp, "atyp", Blob, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0,Y), NULL, NULL);
117 SECDB_ATTR(v6port, "port", Number, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0,Y), NULL, NULL);
118 SECDB_ATTR(v6path, "path", Blob, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0,Y), NULL, NULL);
119 // cert only | | | | | | | | | | | | | | | |
120 SECDB_ATTR(v6ctyp, "ctyp", Number, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0,Y), NULL, NULL);
121 SECDB_ATTR(v6cenc, "cenc", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
122 SECDB_ATTR(v6subj, "subj", Data, SecDbFlags( ,L,I,S,A, , ,C,H, , , , , , ,Y), NULL, NULL);
123 SECDB_ATTR(v6issr, "issr", Data, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0,Y), NULL, NULL);
124 SECDB_ATTR(v6slnr, "slnr", Data, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0,Y), NULL, NULL);
125 SECDB_ATTR(v6skid, "skid", Data, SecDbFlags( ,L,I,S,A, , ,C,H, , , , , , ,Y), NULL, NULL);
126 SECDB_ATTR(v6pkhh, "pkhh", Data, SecDbFlags( ,L,I, ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
127 // cert attributes that share names with common ones but have different flags
128 SECDB_ATTR(v6certalis, "alis", Blob, SecDbFlags( ,L,I,S,A, , ,C,H, , , , , , ,Y), NULL, NULL);
129 // keys only | | | | | | | | | | | | | | | |
130 SECDB_ATTR(v6kcls, "kcls", Number, SecDbFlags(P,L,I,S,A, , ,C,H, ,Z, ,N, ,V0,Y), NULL, NULL);
131 SECDB_ATTR(v6perm, "perm", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
132 SECDB_ATTR(v6priv, "priv", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
133 SECDB_ATTR(v6modi, "modi", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
134 SECDB_ATTR(v6klbl, "klbl", Data, SecDbFlags(P,L,I, ,A, , ,C,H, , ,E,N, ,V0,Y), NULL, NULL);
135 SECDB_ATTR(v6atag, "atag", Blob, SecDbFlags(P,L, ,S,A, , ,C,H, , ,E,N, ,V0,Y), NULL, NULL);
136 SECDB_ATTR(v6bsiz, "bsiz", Number, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0,Y), NULL, NULL);
137 SECDB_ATTR(v6esiz, "esiz", Number, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0,Y), NULL, NULL);
138 SECDB_ATTR(v6sdat, "sdat", Date, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0,Y), NULL, NULL);
139 SECDB_ATTR(v6edat, "edat", Date, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0,Y), NULL, NULL);
140 SECDB_ATTR(v6sens, "sens", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
141 SECDB_ATTR(v6asen, "asen", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
142 SECDB_ATTR(v6extr, "extr", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
143 SECDB_ATTR(v6next, "next", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
144 SECDB_ATTR(v6encr, "encr", Number, SecDbFlags( ,L,I, ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
145 SECDB_ATTR(v6decr, "decr", Number, SecDbFlags( ,L,I, ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
146 SECDB_ATTR(v6drve, "drve", Number, SecDbFlags( ,L,I, ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
147 SECDB_ATTR(v6sign, "sign", Number, SecDbFlags( ,L,I, ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
148 SECDB_ATTR(v6vrfy, "vrfy", Number, SecDbFlags( ,L,I, ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
149 SECDB_ATTR(v6snrc, "snrc", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
150 SECDB_ATTR(v6vyrc, "vyrc", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
151 SECDB_ATTR(v6wrap, "wrap", Number, SecDbFlags( ,L,I, ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
152 SECDB_ATTR(v6unwp, "unwp", Number, SecDbFlags( ,L,I, ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
153 // keys attributes that share names with common ones but have different flags
154 SECDB_ATTR(v6keytype, "type", Number, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0,Y), NULL, NULL);
155 SECDB_ATTR(v6keycrtr, "crtr", Number, SecDbFlags(P,L, , ,A, , ,C,H, ,Z, ,N, ,V0,Y), NULL, NULL);
156 // | | | | | | | | | | | | | | |
157 SECDB_ATTR(v6version, "version", Number, SecDbFlags(P,L, , , , , , , , , , ,N, , ,Y), NULL, NULL);
158 SECDB_ATTR(v91minor, "minor", Number, SecDbFlags( ,L, , , , , , , , ,Z, ,N, , ,Y), NULL, NULL);
159
160 SECDB_ATTR(v10_1pcsservice, "pcss", Number, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
161 SECDB_ATTR(v10_1pcspublickey, "pcsk", Blob, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
162 SECDB_ATTR(v10_1pcspublicidentity,"pcsi", Blob, SecDbFlags( ,L, , ,A, , ,C,H, , , , , , ,Y), NULL, NULL);
163
164 SECDB_ATTR(v10itemuuid, "UUID", String, SecDbFlags( ,L, , , , , , , , , , , ,U, , ), NULL, NULL);
165 SECDB_ATTR(v10syncuuid, "UUID", String, SecDbFlags(P,L, , , , , , , , , , , ,U, , ), NULL, NULL);
166 SECDB_ATTR(v10parentKeyUUID, "parentKeyUUID", String, SecDbFlags( ,L, , , , , , , , , , ,N, , , ), NULL, NULL);
167 SECDB_ATTR(v10currentKeyUUID,"currentKeyUUID",String, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
168 SECDB_ATTR(v10wrappedkey, "wrappedkey", Blob, SecDbFlags( ,L, , , , , , , , , , ,N, , , ), NULL, NULL);
169 SECDB_ATTR(v10encrypteditem, "encitem", Blob, SecDbFlags( ,L, , , , , , , , , , ,N, , , ), NULL, NULL);
170 SECDB_ATTR(v10gencount, "gencount", Number, SecDbFlags( ,L, , , , , , , , ,Z, ,N, , , ), NULL, NULL);
171 SECDB_ATTR(v10action, "action", String, SecDbFlags( ,L, , , , , , , , , , ,N, , , ), NULL, NULL);
172 SECDB_ATTR(v10state, "state", String, SecDbFlags(P,L, , , , , , , , , , ,N, , , ), NULL, NULL);
173 SECDB_ATTR(v10waituntiltime, "waituntil", String, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
174 SECDB_ATTR(v10encodedCKRecord, "ckrecord", Blob, SecDbFlags( ,L, , , , , , , , , , ,N, , , ), NULL, NULL);
175 SECDB_ATTR(v10_1wasCurrent, "wascurrent", Number, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
176 SECDB_ATTR(v10accessgroup, "accessgroup", String, SecDbFlags( ,L, , , , , , , , , , ,N, , , ), NULL, NULL);
177 SECDB_ATTR(v10keyclass, "keyclass", String, SecDbFlags(P,L, , , , , , , , , , ,N, , , ), NULL, NULL);
178 SECDB_ATTR(v10currentkey, "currentkey", Number, SecDbFlags( ,L, , , , , , , , , , ,N, , , ), NULL, NULL);
179 SECDB_ATTR(v10ckzone, "ckzone", String, SecDbFlags(P,L, , , , , , , , , , ,N,U, , ), NULL, NULL);
180 SECDB_ATTR(v10ckzonecreated, "ckzonecreated", Number, SecDbFlags( ,L, , , , , , , , ,Z, , ,N, , ), NULL, NULL);
181 SECDB_ATTR(v10ckzonesubscribed,"ckzonesubscribed", Number, SecDbFlags( ,L, , , , , , , , ,Z, ,N, , , ), NULL, NULL);
182 SECDB_ATTR(v10ratelimiter, "ratelimiter", Blob, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
183 SECDB_ATTR(v10changetoken, "changetoken", String, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
184 SECDB_ATTR(v10lastfetchtime, "lastfetch", String, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
185 SECDB_ATTR(v10itempersistentref,"persistref", UUID, SecDbFlags( ,L, , , , , , , , , , ,N, , , ), NULL, NULL);
186 SECDB_ATTR(v10sysbound, "sysb", Number, SecDbFlags( ,L, , ,A, , ,C,H, ,Z, , , , , ), NULL, NULL);
187 SECDB_ATTR(v10encryptionver, "encver", Number, SecDbFlags( ,L, , , , , , , , ,Z, ,N,U, , ), NULL, NULL);
188
189 SECDB_ATTR(v10primaryKey, "primaryKey", String, SecDbFlags(P,L, , ,A, , , , , , , ,N,U, , ), NULL, NULL);
190 SECDB_ATTR(v10publickeyHash, "publickeyHash", Blob, SecDbFlags(P,L, , , , , , , , , , ,N,U, , ), NULL, NULL);
191 SECDB_ATTR(v10publickey, "publickey", Blob, SecDbFlags( ,L, , , , , , , , , , ,N, , , ), NULL, NULL);
192 SECDB_ATTR(v10backupData, "backupData", Blob, SecDbFlags( ,L, , , , , , , , , , ,N, , , ), NULL, NULL);
193
194 SECDB_ATTR(v10_1digest, "digest", Blob, SecDbFlags( ,L, , , , , , , , , , ,N,U, , ), NULL, NULL);
195 SECDB_ATTR(v10_1signatures, "signatures", Blob, SecDbFlags( ,L, , , , , , , , , , ,N,U, , ), NULL, NULL);
196 SECDB_ATTR(v10_1signerID, "signerID", String, SecDbFlags( ,L, , , , , , , , , , ,N,U, , ), NULL, NULL);
197 SECDB_ATTR(v10_1leafIDs, "leafIDs", Blob, SecDbFlags( ,L, , , , , , , , , , ,N,U, , ), NULL, NULL);
198 SECDB_ATTR(v10_1peerManIDs, "peerManifests", Blob, SecDbFlags( ,L, , , , , , , , , , ,N,U, , ), NULL, NULL);
199 SECDB_ATTR(v10_1entryDigests,"entryDigests", Blob, SecDbFlags( ,L, , , , , , , , , , ,N,U, , ), NULL, NULL);
200 SECDB_ATTR(v10_2currentItems,"currentItems", Blob, SecDbFlags( ,L, , , , , , , , , , ,N,U, , ), NULL, NULL);
201 SECDB_ATTR(v10_2futureData, "futureData", Blob, SecDbFlags( ,L, , , , , , , , , , ,N, , , ), NULL, NULL);
202 SECDB_ATTR(v10_2schema, "schema", Blob, SecDbFlags( ,L, , , , , , , , , , ,N,U, , ), NULL, NULL);
203 SECDB_ATTR(v10_1encRecord, "ckrecord", Blob, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
204
205 SECDB_ATTR(v10_1keyArchiveHash, "key_archive_hash", String, SecDbFlags(P,L, , , , , , , , , , ,N, , , ), NULL, NULL);
206 SECDB_ATTR(v10_1keyArchive, "key_archive", String, SecDbFlags(P,L, , , , , , , , , , ,N, , , ), NULL, NULL);
207 SECDB_ATTR(v10_1archivedKey, "archived_key", String, SecDbFlags( ,L, , , , , , , , , , ,N, , , ), NULL, NULL);
208 SECDB_ATTR(v10_1keyArchiveName, "keyarchive_name", String, SecDbFlags( ,L, , , , , , , , , , ,N, , , ), NULL, NULL);
209 SECDB_ATTR(v10_1optionalEncodedCKRecord, "ckrecord", String, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
210 SECDB_ATTR(v10_1archiveEscrowID,"archive_escrowid", String, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
211
212 SECDB_ATTR(v10_1itempersistentref,"persistref", UUID, SecDbFlags( ,L,I, , , , , , , , , ,N,U, , ), NULL, NULL);
213
214 SECDB_ATTR(v10_1currentItemUUID,"currentItemUUID",String, SecDbFlags(P,L, , , , , , , , , , , , , , ), NULL, NULL);
215 SECDB_ATTR(v10_4currentItemUUID,"currentItemUUID",String, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
216 SECDB_ATTR(v10_1currentPtrIdentifier,"identifier",String, SecDbFlags(P,L, , , , , , , , , , , , , , ), NULL, NULL);
217
218 SECDB_ATTR(v10_2device, "device", String, SecDbFlags(P,L, , , , , , , , , , , , , , ), NULL, NULL);
219 SECDB_ATTR(v10_2peerid, "peerid", String, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
220 SECDB_ATTR(v10_2circleStatus,"circlestatus", String, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
221 SECDB_ATTR(v10_2keyState, "keystate", String, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
222 SECDB_ATTR(v10_2currentTLK, "currentTLK", String, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
223 SECDB_ATTR(v10_2currentClassA,"currentClassA",String, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
224 SECDB_ATTR(v10_2currentClassC,"currentClassC",String, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
225
226 SECDB_ATTR(v10_4lastFixup, "lastfixup", Number, SecDbFlags( ,L, , , , , , , , ,Z, , ,N, , ), NULL, NULL);
227
228 SECDB_ATTR(v10_5senderPeerID,"senderpeerid", String, SecDbFlags(P,L, , , , , , , , , , , , , , ), NULL, NULL);
229 SECDB_ATTR(v10_5recvPeerID, "recvpeerid", String, SecDbFlags(P,L, , , , , , , , , , , , , , ), NULL, NULL);
230 SECDB_ATTR(v10_5recvPubKey, "recvpubenckey", Blob, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
231 SECDB_ATTR(v10_5curve, "curve", Number, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
232 SECDB_ATTR(v10_5poisoned, "poisoned", Number, SecDbFlags( ,L, , , , , , , , ,Z, ,N, , , ), NULL, NULL);
233 SECDB_ATTR(v10_5epoch, "epoch", Number, SecDbFlags( ,L, , , , , , , , ,Z, ,N, , , ), NULL, NULL);
234 SECDB_ATTR(v10_5signature, "signature", Blob, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
235 SECDB_ATTR(v10_5version, "version", Number, SecDbFlags( ,L, , , , , , , , ,Z, ,N,U, , ), NULL, NULL);
236
237 SECDB_ATTR(v11_1osversion, "osversion", String, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
238 SECDB_ATTR(v11_1lastunlock, "lastunlock", String, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
239
240 SECDB_ATTR(v11_2actualKeyclass, "actualKeyclass", String, SecDbFlags( ,L, , , , , , , , , , , , , , ), NULL, NULL);
241
242 const SecDbClass v11_2_metadatakeys_class = {
243 .name = CFSTR("metadatakeys"),
244 .itemclass = false,
245 .attrs = {
246 &v10keyclass,
247 &v11_2actualKeyclass,
248 &v6data,
249 0
250 }
251 };
252
253 const SecDbClass v11_1_ckdevicestate_class = {
254 .name = CFSTR("ckdevicestate"),
255 .itemclass = false,
256 .attrs = {
257 &v10ckzone,
258 &v10_2device,
259 &v11_1osversion,
260 &v11_1lastunlock,
261 &v10_2peerid,
262 &v10_2circleStatus,
263 &v10_2keyState,
264 &v10_2currentTLK,
265 &v10_2currentClassA,
266 &v10_2currentClassC,
267 &v10_1encRecord,
268 0
269 }
270 };
271
272 const SecDbClass v11_metadatakeys_class = {
273 .name = CFSTR("metadatakeys"),
274 .itemclass = false,
275 .attrs = {
276 &v10keyclass,
277 &v6data,
278 0
279 }
280 };
281
282 const SecDbClass v10_5_tlkshare_class = {
283 .name = CFSTR("tlkshare"),
284 .itemclass = false,
285 .attrs = {
286 &v10ckzone,
287 &v10syncuuid,
288 &v10_5senderPeerID,
289 &v10_5recvPeerID,
290 &v10_5recvPubKey,
291 &v10_5curve,
292 &v10_5poisoned,
293 &v10_5epoch,
294 &v10wrappedkey,
295 &v10_5signature,
296 &v10_1encRecord,
297 &v10_5version,
298 0
299 }
300 };
301
302
303 const SecDbClass v10_4_current_item_class = {
304 .name = CFSTR("currentitems"),
305 .itemclass = false,
306 .attrs = {
307 &v10ckzone,
308 &v10_1currentPtrIdentifier,
309 &v10_4currentItemUUID,
310 &v10state,
311 &v10encodedCKRecord,
312 0
313 }
314 };
315
316 const SecDbClass v10_4_ckstate_class = {
317 .name = CFSTR("ckstate"),
318 .itemclass = false,
319 .attrs = {
320 &v10ckzone,
321 &v10ckzonecreated,
322 &v10ckzonesubscribed,
323 &v10lastfetchtime,
324 &v10changetoken,
325 &v10ratelimiter,
326 &v10_4lastFixup,
327 0
328 }
329 };
330
331 const SecDbClass v10_3_ckdevicestate_class = {
332 .name = CFSTR("ckdevicestate"),
333 .itemclass = false,
334 .attrs = {
335 &v10ckzone,
336 &v10_2device,
337 &v10_2peerid,
338 &v10_2circleStatus,
339 &v10_2keyState,
340 &v10_2currentTLK,
341 &v10_2currentClassA,
342 &v10_2currentClassC,
343 &v10_1encRecord,
344 0
345 }
346 };
347
348 const SecDbClass v10_2_ckmanifest_class = {
349 .name = CFSTR("ckmanifest"),
350 .itemclass = false,
351 .attrs = {
352 &v10ckzone,
353 &v10gencount,
354 &v10_1digest,
355 &v10_1signatures,
356 &v10_1signerID,
357 &v10_1leafIDs,
358 &v10_1peerManIDs,
359 &v10_2currentItems,
360 &v10_2futureData,
361 &v10_2schema,
362 &v10_1encRecord,
363 0
364 }
365 };
366
367 const SecDbClass v10_2_pending_manifest_class = {
368 .name = CFSTR("pending_manifest"),
369 .itemclass = false,
370 .attrs = {
371 &v10ckzone,
372 &v10gencount,
373 &v10_1digest,
374 &v10_1signatures,
375 &v10_1signerID,
376 &v10_1leafIDs,
377 &v10_1peerManIDs,
378 &v10_2currentItems,
379 &v10_2futureData,
380 &v10_2schema,
381 &v10_1encRecord,
382 0
383 }
384 };
385
386 const SecDbClass v10_1_ckmanifest_class = {
387 .name = CFSTR("ckmanifest"),
388 .itemclass = false,
389 .attrs = {
390 &v10ckzone,
391 &v10gencount,
392 &v10_1digest,
393 &v10_1signatures,
394 &v10_1signerID,
395 &v10_1leafIDs,
396 &v10_1peerManIDs,
397 &v10_1encRecord,
398 0
399 }
400 };
401
402 const SecDbClass v10_1_pending_manifest_class = {
403 .name = CFSTR("pending_manifest"),
404 .itemclass = false,
405 .attrs = {
406 &v10ckzone,
407 &v10gencount,
408 &v10_1digest,
409 &v10_1signatures,
410 &v10_1signerID,
411 &v10_1leafIDs,
412 &v10_1peerManIDs,
413 &v10_1encRecord,
414 0
415 }
416 };
417
418 const SecDbClass v10_1_ckmanifest_leaf_class = {
419 .name = CFSTR("ckmanifest_leaf"),
420 .itemclass = false,
421 .attrs = {
422 &v10ckzone,
423 &v10syncuuid,
424 &v10_1digest,
425 &v10_1entryDigests,
426 &v10_1encRecord,
427 0
428 }
429 };
430
431 const SecDbClass v10_1_pending_manifest_leaf_class = {
432 .name = CFSTR("pending_manifest_leaf"),
433 .itemclass = false,
434 .attrs = {
435 &v10ckzone,
436 &v10syncuuid,
437 &v10_1digest,
438 &v10_1entryDigests,
439 &v10_1encRecord,
440 0
441 }
442 };
443
444 const SecDbClass v10_1_genp_class = {
445 .name = CFSTR("genp"),
446 .itemclass = true,
447 .attrs = {
448 &v6rowid,
449 &v6cdat,
450 &v6mdat,
451 &v6desc,
452 &v6icmt,
453 &v6crtr,
454 &v6type,
455 &v6scrp,
456 &v6labl,
457 &v6alis,
458 &v6invi,
459 &v6nega,
460 &v6cusi,
461 &v6prot,
462 &v6acct,
463 &v6svce,
464 &v6gena,
465 &v6data,
466 &v6agrp,
467 &v6pdmn,
468 &v6sync,
469 &v6tomb,
470 &v6sha1,
471 &v7vwht,
472 &v7tkid,
473 &v6v_Data,
474 &v6v_pk,
475 &v6accc,
476 &v7utomb,
477 &v8musr,
478 &v10itemuuid,
479 &v10sysbound,
480 &v10_1pcsservice,
481 &v10_1pcspublickey,
482 &v10_1pcspublicidentity,
483 &v10_1itempersistentref,
484 0
485 },
486 };
487
488 const SecDbClass v10_1_inet_class = {
489 .name = CFSTR("inet"),
490 .itemclass = true,
491 .attrs = {
492 &v6rowid,
493 &v6cdat,
494 &v6mdat,
495 &v6desc,
496 &v6icmt,
497 &v6crtr,
498 &v6type,
499 &v6scrp,
500 &v6labl,
501 &v6alis,
502 &v6invi,
503 &v6nega,
504 &v6cusi,
505 &v6prot,
506 &v6acct,
507 &v6sdmn,
508 &v6srvr,
509 &v6ptcl,
510 &v6atyp,
511 &v6port,
512 &v6path,
513 &v6data,
514 &v6agrp,
515 &v6pdmn,
516 &v6sync,
517 &v6tomb,
518 &v6sha1,
519 &v7vwht,
520 &v7tkid,
521 &v6v_Data,
522 &v6v_pk,
523 &v6accc,
524 &v7utomb,
525 &v8musr,
526 &v10itemuuid,
527 &v10sysbound,
528 &v10_1pcsservice,
529 &v10_1pcspublickey,
530 &v10_1pcspublicidentity,
531 &v10_1itempersistentref,
532 0
533 },
534 };
535
536 const SecDbClass v10_1_cert_class = {
537 .name = CFSTR("cert"),
538 .itemclass = true,
539 .attrs = {
540 &v6rowid,
541 &v6cdat,
542 &v6mdat,
543 &v6ctyp,
544 &v6cenc,
545 &v6labl,
546 &v6certalis,
547 &v6subj,
548 &v6issr,
549 &v6slnr,
550 &v6skid,
551 &v6pkhh,
552 &v6data,
553 &v6agrp,
554 &v6pdmn,
555 &v6sync,
556 &v6tomb,
557 &v6sha1,
558 &v7vwht,
559 &v7tkid,
560 &v6v_Data,
561 &v6v_pk,
562 &v6accc,
563 &v7utomb,
564 &v8musr,
565 &v10itemuuid,
566 &v10sysbound,
567 &v10_1pcsservice,
568 &v10_1pcspublickey,
569 &v10_1pcspublicidentity,
570 &v10_1itempersistentref,
571 0
572 },
573 };
574
575 const SecDbClass v10_1_keys_class = {
576 .name = CFSTR("keys"),
577 .itemclass = true,
578 .attrs = {
579 &v6rowid,
580 &v6cdat,
581 &v6mdat,
582 &v6kcls,
583 &v6labl,
584 &v6alis,
585 &v6perm,
586 &v6priv,
587 &v6modi,
588 &v6klbl,
589 &v6atag,
590 &v6keycrtr,
591 &v6keytype,
592 &v6bsiz,
593 &v6esiz,
594 &v6sdat,
595 &v6edat,
596 &v6sens,
597 &v6asen,
598 &v6extr,
599 &v6next,
600 &v6encr,
601 &v6decr,
602 &v6drve,
603 &v6sign,
604 &v6vrfy,
605 &v6snrc,
606 &v6vyrc,
607 &v6wrap,
608 &v6unwp,
609 &v6data,
610 &v6agrp,
611 &v6pdmn,
612 &v6sync,
613 &v6tomb,
614 &v6sha1,
615 &v7vwht,
616 &v7tkid,
617 &v6v_Data,
618 &v6v_pk,
619 &v6accc,
620 &v7utomb,
621 &v8musr,
622 &v10itemuuid,
623 &v10sysbound,
624 &v10_1pcsservice,
625 &v10_1pcspublickey,
626 &v10_1pcspublicidentity,
627 &v10_1itempersistentref,
628 0
629 }
630 };
631
632 const SecDbClass v10_0_tversion_class = {
633 .name = CFSTR("tversion"),
634 .itemclass = false,
635 .attrs = {
636 &v6rowid,
637 &v6version,
638 &v91minor,
639 0
640 }
641 };
642
643 const SecDbClass v10_2_outgoing_queue_class = {
644 .name = CFSTR("outgoingqueue"),
645 .itemclass = false,
646 .attrs = {
647 &v10ckzone,
648 &v10syncuuid,
649 &v10parentKeyUUID,
650 &v10action,
651 &v10state,
652 &v10waituntiltime,
653 &v10accessgroup,
654 &v10gencount,
655 &v10wrappedkey,
656 &v10encrypteditem,
657 &v10encryptionver,
658 &v10_1optionalEncodedCKRecord,
659 &v10_1pcsservice,
660 &v10_1pcspublickey,
661 &v10_1pcspublicidentity,
662 0
663 }
664 };
665
666 const SecDbClass v10_2_incoming_queue_class = {
667 .name = CFSTR("incomingqueue"),
668 .itemclass = false,
669 .attrs = {
670 &v10ckzone,
671 &v10syncuuid,
672 &v10parentKeyUUID,
673 &v10action,
674 &v10state,
675 &v10gencount,
676 &v10wrappedkey,
677 &v10encrypteditem,
678 &v10encryptionver,
679 &v10_1optionalEncodedCKRecord,
680 &v10_1pcsservice,
681 &v10_1pcspublickey,
682 &v10_1pcspublicidentity,
683 0
684 }
685 };
686
687
688 const SecDbClass v10_1_outgoing_queue_class = {
689 .name = CFSTR("outgoingqueue"),
690 .itemclass = false,
691 .attrs = {
692 &v10ckzone,
693 &v10syncuuid,
694 &v10parentKeyUUID,
695 &v10action,
696 &v10state,
697 &v10waituntiltime,
698 &v10accessgroup,
699 &v10gencount,
700 &v10wrappedkey,
701 &v10encrypteditem,
702 &v10encryptionver,
703 &v10_1pcsservice,
704 &v10_1pcspublickey,
705 &v10_1pcspublicidentity,
706 0
707 }
708 };
709
710 const SecDbClass v10_1_incoming_queue_class = {
711 .name = CFSTR("incomingqueue"),
712 .itemclass = false,
713 .attrs = {
714 &v10ckzone,
715 &v10syncuuid,
716 &v10parentKeyUUID,
717 &v10action,
718 &v10state,
719 &v10gencount,
720 &v10wrappedkey,
721 &v10encrypteditem,
722 &v10encryptionver,
723 &v10_1pcsservice,
724 &v10_1pcspublickey,
725 &v10_1pcspublicidentity,
726 0
727 }
728 };
729
730
731 const SecDbClass v10_0_outgoing_queue_class = {
732 .name = CFSTR("outgoingqueue"),
733 .itemclass = false,
734 .attrs = {
735 &v10ckzone,
736 &v10syncuuid,
737 &v10parentKeyUUID,
738 &v10action,
739 &v10state,
740 &v10waituntiltime,
741 &v10accessgroup,
742 &v10gencount,
743 &v10wrappedkey,
744 &v10encrypteditem,
745 &v10encryptionver,
746 0
747 }
748 };
749
750 const SecDbClass v10_0_incoming_queue_class = {
751 .name = CFSTR("incomingqueue"),
752 .itemclass = false,
753 .attrs = {
754 &v10ckzone,
755 &v10syncuuid,
756 &v10parentKeyUUID,
757 &v10action,
758 &v10state,
759 &v10gencount,
760 &v10wrappedkey,
761 &v10encrypteditem,
762 &v10encryptionver,
763 0
764 }
765 };
766
767 const SecDbClass v10_0_sync_key_class = {
768 .name = CFSTR("synckeys"),
769 .itemclass = false,
770 .attrs = {
771 &v10ckzone,
772 &v10syncuuid,
773 &v10keyclass,
774 &v10currentkey,
775 &v10parentKeyUUID,
776 &v10state,
777 &v10wrappedkey,
778 &v10encodedCKRecord,
779 0
780 }
781 };
782
783 // Stores the "Current Key" records, and parentKeyUUID refers to items in the synckeys table
784 // Wouldn't foreign keys be nice?
785 const SecDbClass v10_0_current_key_class = {
786 .name = CFSTR("currentkeys"),
787 .itemclass = false,
788 .attrs = {
789 &v10ckzone,
790 &v10keyclass,
791 &v10currentKeyUUID,
792 &v10encodedCKRecord,
793 0
794 }
795 };
796
797 const SecDbClass v10_1_current_item_class = {
798 .name = CFSTR("currentitems"),
799 .itemclass = false,
800 .attrs = {
801 &v10ckzone,
802 &v10_1currentPtrIdentifier,
803 &v10_1currentItemUUID,
804 &v10state,
805 &v10encodedCKRecord,
806 0
807 }
808 };
809
810 const SecDbClass v10_1_ckmirror_class = {
811 .name = CFSTR("ckmirror"),
812 .itemclass = false,
813 .attrs = {
814 &v10ckzone,
815 &v10syncuuid,
816 &v10parentKeyUUID,
817 &v10gencount,
818 &v10wrappedkey,
819 &v10encrypteditem,
820 &v10encodedCKRecord,
821 &v10encryptionver,
822 &v10_1wasCurrent,
823 &v10_1pcsservice,
824 &v10_1pcspublickey,
825 &v10_1pcspublicidentity,
826 0
827 }
828 };
829
830 const SecDbClass v10_0_ckmirror_class = {
831 .name = CFSTR("ckmirror"),
832 .itemclass = false,
833 .attrs = {
834 &v10ckzone,
835 &v10syncuuid,
836 &v10parentKeyUUID,
837 &v10gencount,
838 &v10wrappedkey,
839 &v10encrypteditem,
840 &v10encodedCKRecord,
841 &v10encryptionver,
842 0
843 }
844 };
845
846 const SecDbClass v10_0_ckstate_class = {
847 .name = CFSTR("ckstate"),
848 .itemclass = false,
849 .attrs = {
850 &v10ckzone,
851 &v10ckzonecreated,
852 &v10ckzonesubscribed,
853 &v10lastfetchtime,
854 &v10changetoken,
855 &v10ratelimiter,
856 0
857 }
858 };
859
860 /* Backup table */
861 /* Primary keys: v10primaryKey, v8musr */
862 const SecDbClass v10_0_item_backup_class = {
863 .name = CFSTR("item_backup"),
864 .itemclass = false,
865 .attrs = {
866 &v6rowid,
867 &v10primaryKey, // Primary key of the original item, from v6v_pk
868 &v8musr, //
869 &v6sha1, // Hash of the original item
870 &v10backupData, // Data wrapped to backup keybag
871 &v6pkhh, // Hash of the public key of the backup bag [v10publickeyHash]
872 0
873 }
874 };
875
876 /* Backup Keybag table */
877 /* Primary keys: v10publickeyHash, v8musr */
878 const SecDbClass v10_0_backup_keybag_class = {
879 .name = CFSTR("backup_keybag"),
880 .itemclass = false,
881 .attrs = {
882 &v6rowid,
883 &v10publickeyHash, // Hash of the public key of the backup bag
884 &v8musr, //
885 &v10publickey, // Public key for the asymmetric backup bag
886 &v6agrp, // Used for backup agent
887 0
888 }
889 };
890
891 const SecDbClass v10_1_backup_keyarchive_class = {
892 .name = CFSTR("backup_keyarchive"),
893 .itemclass = false,
894 .attrs = {
895 &v10_1keyArchiveHash, // Hash of the key archive
896 &v8musr, //
897 &v10_1keyArchive, // Serialised key archive
898 &v10ckzone,
899 &v10_1optionalEncodedCKRecord,
900 &v10_1archiveEscrowID,
901 0
902 }
903 };
904
905 const SecDbClass v10_1_current_archived_keys_class = {
906 .name = CFSTR("archived_key_backup"),
907 .itemclass = false,
908 .attrs = {
909 &v6pdmn,
910 &v10syncuuid,
911 &v8musr,
912 &v6agrp,
913 &v10_1keyArchiveHash,
914 &v10_1archivedKey,
915 &v10ckzone,
916 &v10_1optionalEncodedCKRecord,
917 &v10_1archiveEscrowID,
918 0
919 }
920 };
921
922 const SecDbClass v10_1_current_keyarchive_class = {
923 .name = CFSTR("currentkeyarchives"),
924 .itemclass = false,
925 .attrs = {
926 &v10_1keyArchiveHash,
927 &v10_1keyArchiveName,
928 0
929 }
930 };
931
932 /* An identity which is really a cert + a key, so all cert and keys attrs are
933 allowed. */
934 const SecDbClass v_identity_class = {
935 .name = CFSTR("idnt"),
936 .itemclass = true,
937 .attrs = {
938 0
939 },
940 };
941
942 /*
943 * Version 11.2
944 */
945 const SecDbSchema v11_2_schema = {
946 .majorVersion = 11,
947 .minorVersion = 2,
948 .classes = {
949 &v10_1_genp_class,
950 &v10_1_inet_class,
951 &v10_1_cert_class,
952 &v10_1_keys_class,
953 &v10_0_tversion_class,
954 &v10_2_outgoing_queue_class,
955 &v10_2_incoming_queue_class,
956 &v10_0_sync_key_class,
957 &v10_1_ckmirror_class,
958 &v10_0_current_key_class,
959 &v10_4_ckstate_class,
960 &v10_0_item_backup_class,
961 &v10_0_backup_keybag_class,
962 &v10_2_ckmanifest_class,
963 &v10_2_pending_manifest_class,
964 &v10_1_ckmanifest_leaf_class,
965 &v10_1_backup_keyarchive_class,
966 &v10_1_current_keyarchive_class,
967 &v10_1_current_archived_keys_class,
968 &v10_1_pending_manifest_leaf_class,
969 &v10_4_current_item_class,
970 &v11_1_ckdevicestate_class,
971 &v10_5_tlkshare_class,
972 &v11_2_metadatakeys_class,
973 0
974 }
975 };
976
977 /*
978 * Version 11.1
979 */
980 const SecDbSchema v11_1_schema = {
981 .majorVersion = 11,
982 .minorVersion = 1,
983 .classes = {
984 &v10_1_genp_class,
985 &v10_1_inet_class,
986 &v10_1_cert_class,
987 &v10_1_keys_class,
988 &v10_0_tversion_class,
989 &v10_2_outgoing_queue_class,
990 &v10_2_incoming_queue_class,
991 &v10_0_sync_key_class,
992 &v10_1_ckmirror_class,
993 &v10_0_current_key_class,
994 &v10_4_ckstate_class,
995 &v10_0_item_backup_class,
996 &v10_0_backup_keybag_class,
997 &v10_2_ckmanifest_class,
998 &v10_2_pending_manifest_class,
999 &v10_1_ckmanifest_leaf_class,
1000 &v10_1_backup_keyarchive_class,
1001 &v10_1_current_keyarchive_class,
1002 &v10_1_current_archived_keys_class,
1003 &v10_1_pending_manifest_leaf_class,
1004 &v10_4_current_item_class,
1005 &v11_1_ckdevicestate_class,
1006 &v10_5_tlkshare_class,
1007 &v11_metadatakeys_class,
1008 0
1009 }
1010 };
1011
1012 /*
1013 * Version 11
1014 */
1015 const SecDbSchema v11_schema = {
1016 .majorVersion = 11,
1017 .minorVersion = 0,
1018 .classes = {
1019 &v10_1_genp_class,
1020 &v10_1_inet_class,
1021 &v10_1_cert_class,
1022 &v10_1_keys_class,
1023 &v10_0_tversion_class,
1024 &v10_2_outgoing_queue_class,
1025 &v10_2_incoming_queue_class,
1026 &v10_0_sync_key_class,
1027 &v10_1_ckmirror_class,
1028 &v10_0_current_key_class,
1029 &v10_4_ckstate_class,
1030 &v10_0_item_backup_class,
1031 &v10_0_backup_keybag_class,
1032 &v10_2_ckmanifest_class,
1033 &v10_2_pending_manifest_class,
1034 &v10_1_ckmanifest_leaf_class,
1035 &v10_1_backup_keyarchive_class,
1036 &v10_1_current_keyarchive_class,
1037 &v10_1_current_archived_keys_class,
1038 &v10_1_pending_manifest_leaf_class,
1039 &v10_4_current_item_class,
1040 &v10_3_ckdevicestate_class,
1041 &v10_5_tlkshare_class,
1042 &v11_metadatakeys_class,
1043 0
1044 }
1045 };
1046
1047
1048 /*
1049 * Version 10.5
1050 */
1051 const SecDbSchema v10_5_schema = {
1052 .majorVersion = 10,
1053 .minorVersion = 5,
1054 .classes = {
1055 &v10_1_genp_class,
1056 &v10_1_inet_class,
1057 &v10_1_cert_class,
1058 &v10_1_keys_class,
1059 &v10_0_tversion_class,
1060 &v10_2_outgoing_queue_class,
1061 &v10_2_incoming_queue_class,
1062 &v10_0_sync_key_class,
1063 &v10_1_ckmirror_class,
1064 &v10_0_current_key_class,
1065 &v10_4_ckstate_class,
1066 &v10_0_item_backup_class,
1067 &v10_0_backup_keybag_class,
1068 &v10_2_ckmanifest_class,
1069 &v10_2_pending_manifest_class,
1070 &v10_1_ckmanifest_leaf_class,
1071 &v10_1_backup_keyarchive_class,
1072 &v10_1_current_keyarchive_class,
1073 &v10_1_current_archived_keys_class,
1074 &v10_1_pending_manifest_leaf_class,
1075 &v10_4_current_item_class,
1076 &v10_3_ckdevicestate_class,
1077 &v10_5_tlkshare_class,
1078 0
1079 }
1080 };
1081
1082 /*
1083 * Version 10.4
1084 */
1085 const SecDbSchema v10_4_schema = {
1086 .majorVersion = 10,
1087 .minorVersion = 4,
1088 .classes = {
1089 &v10_1_genp_class,
1090 &v10_1_inet_class,
1091 &v10_1_cert_class,
1092 &v10_1_keys_class,
1093 &v10_0_tversion_class,
1094 &v10_2_outgoing_queue_class,
1095 &v10_2_incoming_queue_class,
1096 &v10_0_sync_key_class,
1097 &v10_1_ckmirror_class,
1098 &v10_0_current_key_class,
1099 &v10_4_ckstate_class,
1100 &v10_0_item_backup_class,
1101 &v10_0_backup_keybag_class,
1102 &v10_2_ckmanifest_class,
1103 &v10_2_pending_manifest_class,
1104 &v10_1_ckmanifest_leaf_class,
1105 &v10_1_backup_keyarchive_class,
1106 &v10_1_current_keyarchive_class,
1107 &v10_1_current_archived_keys_class,
1108 &v10_1_pending_manifest_leaf_class,
1109 &v10_4_current_item_class,
1110 &v10_3_ckdevicestate_class,
1111 0
1112 }
1113 };
1114
1115 /*
1116 * Version 10.3
1117 */
1118 const SecDbSchema v10_3_schema = {
1119 .majorVersion = 10,
1120 .minorVersion = 3,
1121 .classes = {
1122 &v10_1_genp_class,
1123 &v10_1_inet_class,
1124 &v10_1_cert_class,
1125 &v10_1_keys_class,
1126 &v10_0_tversion_class,
1127 &v10_2_outgoing_queue_class,
1128 &v10_2_incoming_queue_class,
1129 &v10_0_sync_key_class,
1130 &v10_1_ckmirror_class,
1131 &v10_0_current_key_class,
1132 &v10_0_ckstate_class,
1133 &v10_0_item_backup_class,
1134 &v10_0_backup_keybag_class,
1135 &v10_2_ckmanifest_class,
1136 &v10_2_pending_manifest_class,
1137 &v10_1_ckmanifest_leaf_class,
1138 &v10_1_backup_keyarchive_class,
1139 &v10_1_current_keyarchive_class,
1140 &v10_1_current_archived_keys_class,
1141 &v10_1_pending_manifest_leaf_class,
1142 &v10_1_current_item_class,
1143 &v10_3_ckdevicestate_class,
1144 0
1145 }
1146 };
1147
1148 /*
1149 * Version 10.2
1150 */
1151 const SecDbSchema v10_2_schema = {
1152 .majorVersion = 10,
1153 .minorVersion = 2,
1154 .classes = {
1155 &v10_1_genp_class,
1156 &v10_1_inet_class,
1157 &v10_1_cert_class,
1158 &v10_1_keys_class,
1159 &v10_0_tversion_class,
1160 &v10_2_outgoing_queue_class,
1161 &v10_2_incoming_queue_class,
1162 &v10_0_sync_key_class,
1163 &v10_1_ckmirror_class,
1164 &v10_0_current_key_class,
1165 &v10_0_ckstate_class,
1166 &v10_0_item_backup_class,
1167 &v10_0_backup_keybag_class,
1168 &v10_2_ckmanifest_class,
1169 &v10_2_pending_manifest_class,
1170 &v10_1_ckmanifest_leaf_class,
1171 &v10_1_backup_keyarchive_class,
1172 &v10_1_current_keyarchive_class,
1173 &v10_1_current_archived_keys_class,
1174 &v10_1_pending_manifest_leaf_class,
1175 &v10_1_current_item_class,
1176 0
1177 }
1178 };
1179
1180 /*
1181 * Version 10.1
1182 */
1183 const SecDbSchema v10_1_schema = {
1184 .majorVersion = 10,
1185 .minorVersion = 1,
1186 .classes = {
1187 &v10_1_genp_class,
1188 &v10_1_inet_class,
1189 &v10_1_cert_class,
1190 &v10_1_keys_class,
1191 &v10_0_tversion_class,
1192 &v10_1_outgoing_queue_class,
1193 &v10_1_incoming_queue_class,
1194 &v10_0_sync_key_class,
1195 &v10_1_ckmirror_class,
1196 &v10_0_current_key_class,
1197 &v10_0_ckstate_class,
1198 &v10_0_item_backup_class,
1199 &v10_0_backup_keybag_class,
1200 &v10_1_ckmanifest_class,
1201 &v10_1_pending_manifest_class,
1202 &v10_1_ckmanifest_leaf_class,
1203 &v10_1_backup_keyarchive_class,
1204 &v10_1_current_keyarchive_class,
1205 &v10_1_current_archived_keys_class,
1206 &v10_1_pending_manifest_leaf_class,
1207 &v10_1_current_item_class,
1208 0
1209 }
1210 };
1211
1212 /*
1213 * Version 10.0
1214 */
1215
1216 const SecDbClass v10_0_genp_class = {
1217 .name = CFSTR("genp"),
1218 .itemclass = true,
1219 .attrs = {
1220 &v6rowid,
1221 &v6cdat,
1222 &v6mdat,
1223 &v6desc,
1224 &v6icmt,
1225 &v6crtr,
1226 &v6type,
1227 &v6scrp,
1228 &v6labl,
1229 &v6alis,
1230 &v6invi,
1231 &v6nega,
1232 &v6cusi,
1233 &v6prot,
1234 &v6acct,
1235 &v6svce,
1236 &v6gena,
1237 &v6data,
1238 &v6agrp,
1239 &v6pdmn,
1240 &v6sync,
1241 &v6tomb,
1242 &v6sha1,
1243 &v7vwht,
1244 &v7tkid,
1245 &v6v_Data,
1246 &v6v_pk,
1247 &v6accc,
1248 &v7utomb,
1249 &v8musr,
1250 &v10itemuuid,
1251 &v10itempersistentref,
1252 &v10sysbound,
1253 0
1254 },
1255 };
1256
1257 const SecDbClass v10_0_inet_class = {
1258 .name = CFSTR("inet"),
1259 .itemclass = true,
1260 .attrs = {
1261 &v6rowid,
1262 &v6cdat,
1263 &v6mdat,
1264 &v6desc,
1265 &v6icmt,
1266 &v6crtr,
1267 &v6type,
1268 &v6scrp,
1269 &v6labl,
1270 &v6alis,
1271 &v6invi,
1272 &v6nega,
1273 &v6cusi,
1274 &v6prot,
1275 &v6acct,
1276 &v6sdmn,
1277 &v6srvr,
1278 &v6ptcl,
1279 &v6atyp,
1280 &v6port,
1281 &v6path,
1282 &v6data,
1283 &v6agrp,
1284 &v6pdmn,
1285 &v6sync,
1286 &v6tomb,
1287 &v6sha1,
1288 &v7vwht,
1289 &v7tkid,
1290 &v6v_Data,
1291 &v6v_pk,
1292 &v6accc,
1293 &v7utomb,
1294 &v8musr,
1295 &v10itemuuid,
1296 &v10itempersistentref,
1297 &v10sysbound,
1298 0
1299 },
1300 };
1301
1302 const SecDbClass v10_0_cert_class = {
1303 .name = CFSTR("cert"),
1304 .itemclass = true,
1305 .attrs = {
1306 &v6rowid,
1307 &v6cdat,
1308 &v6mdat,
1309 &v6ctyp,
1310 &v6cenc,
1311 &v6labl,
1312 &v6certalis,
1313 &v6subj,
1314 &v6issr,
1315 &v6slnr,
1316 &v6skid,
1317 &v6pkhh,
1318 &v6data,
1319 &v6agrp,
1320 &v6pdmn,
1321 &v6sync,
1322 &v6tomb,
1323 &v6sha1,
1324 &v7vwht,
1325 &v7tkid,
1326 &v6v_Data,
1327 &v6v_pk,
1328 &v6accc,
1329 &v7utomb,
1330 &v8musr,
1331 &v10itemuuid,
1332 &v10itempersistentref,
1333 &v10sysbound,
1334 0
1335 },
1336 };
1337
1338 const SecDbClass v10_0_keys_class = {
1339 .name = CFSTR("keys"),
1340 .itemclass = true,
1341 .attrs = {
1342 &v6rowid,
1343 &v6cdat,
1344 &v6mdat,
1345 &v6kcls,
1346 &v6labl,
1347 &v6alis,
1348 &v6perm,
1349 &v6priv,
1350 &v6modi,
1351 &v6klbl,
1352 &v6atag,
1353 &v6keycrtr,
1354 &v6keytype,
1355 &v6bsiz,
1356 &v6esiz,
1357 &v6sdat,
1358 &v6edat,
1359 &v6sens,
1360 &v6asen,
1361 &v6extr,
1362 &v6next,
1363 &v6encr,
1364 &v6decr,
1365 &v6drve,
1366 &v6sign,
1367 &v6vrfy,
1368 &v6snrc,
1369 &v6vyrc,
1370 &v6wrap,
1371 &v6unwp,
1372 &v6data,
1373 &v6agrp,
1374 &v6pdmn,
1375 &v6sync,
1376 &v6tomb,
1377 &v6sha1,
1378 &v7vwht,
1379 &v7tkid,
1380 &v6v_Data,
1381 &v6v_pk,
1382 &v6accc,
1383 &v7utomb,
1384 &v8musr,
1385 &v10itemuuid,
1386 &v10itempersistentref,
1387 &v10sysbound,
1388 0
1389 }
1390 };
1391
1392 const SecDbSchema v10_0_schema = {
1393 .majorVersion = 10,
1394 .minorVersion = 0,
1395 .classes = {
1396 &v10_0_genp_class,
1397 &v10_0_inet_class,
1398 &v10_0_cert_class,
1399 &v10_0_keys_class,
1400 &v10_0_tversion_class,
1401 &v10_0_outgoing_queue_class,
1402 &v10_0_incoming_queue_class,
1403 &v10_0_sync_key_class,
1404 &v10_0_ckmirror_class,
1405 &v10_0_current_key_class,
1406 &v10_0_ckstate_class,
1407 &v10_0_item_backup_class,
1408 &v10_0_backup_keybag_class,
1409 0
1410 }
1411 };
1412
1413 const SecDbClass v9_1_tversion_class = {
1414 .name = CFSTR("tversion91"),
1415 .itemclass = false,
1416 .attrs = {
1417 &v6rowid,
1418 &v6version,
1419 &v91minor,
1420 0
1421 }
1422 };
1423
1424 const SecDbClass v9_1_genp_class = {
1425 .name = CFSTR("genp91"),
1426 .itemclass = true,
1427 .attrs = {
1428 &v6rowid,
1429 &v6cdat,
1430 &v6mdat,
1431 &v6desc,
1432 &v6icmt,
1433 &v6crtr,
1434 &v6type,
1435 &v6scrp,
1436 &v6labl,
1437 &v6alis,
1438 &v6invi,
1439 &v6nega,
1440 &v6cusi,
1441 &v6prot,
1442 &v6acct,
1443 &v6svce,
1444 &v6gena,
1445 &v6data,
1446 &v6agrp,
1447 &v6pdmn,
1448 &v6sync,
1449 &v6tomb,
1450 &v6sha1,
1451 &v7vwht,
1452 &v7tkid,
1453 &v6v_Data,
1454 &v6v_pk,
1455 &v6accc,
1456 &v7utomb,
1457 &v8musr,
1458 0
1459 },
1460 };
1461
1462 const SecDbClass v9_1_inet_class = {
1463 .name = CFSTR("inet91"),
1464 .itemclass = true,
1465 .attrs = {
1466 &v6rowid,
1467 &v6cdat,
1468 &v6mdat,
1469 &v6desc,
1470 &v6icmt,
1471 &v6crtr,
1472 &v6type,
1473 &v6scrp,
1474 &v6labl,
1475 &v6alis,
1476 &v6invi,
1477 &v6nega,
1478 &v6cusi,
1479 &v6prot,
1480 &v6acct,
1481 &v6sdmn,
1482 &v6srvr,
1483 &v6ptcl,
1484 &v6atyp,
1485 &v6port,
1486 &v6path,
1487 &v6data,
1488 &v6agrp,
1489 &v6pdmn,
1490 &v6sync,
1491 &v6tomb,
1492 &v6sha1,
1493 &v7vwht,
1494 &v7tkid,
1495 &v6v_Data,
1496 &v6v_pk,
1497 &v6accc,
1498 &v7utomb,
1499 &v8musr,
1500 0
1501 },
1502 };
1503
1504 const SecDbClass v9_1_cert_class = {
1505 .name = CFSTR("cert91"),
1506 .itemclass = true,
1507 .attrs = {
1508 &v6rowid,
1509 &v6cdat,
1510 &v6mdat,
1511 &v6ctyp,
1512 &v6cenc,
1513 &v6labl,
1514 &v6certalis,
1515 &v6subj,
1516 &v6issr,
1517 &v6slnr,
1518 &v6skid,
1519 &v6pkhh,
1520 &v6data,
1521 &v6agrp,
1522 &v6pdmn,
1523 &v6sync,
1524 &v6tomb,
1525 &v6sha1,
1526 &v7vwht,
1527 &v7tkid,
1528 &v6v_Data,
1529 &v6v_pk,
1530 &v6accc,
1531 &v7utomb,
1532 &v8musr,
1533 0
1534 },
1535 };
1536
1537 const SecDbClass v9_1_keys_class = {
1538 .name = CFSTR("keys91"),
1539 .itemclass = true,
1540 .attrs = {
1541 &v6rowid,
1542 &v6cdat,
1543 &v6mdat,
1544 &v6kcls,
1545 &v6labl,
1546 &v6alis,
1547 &v6perm,
1548 &v6priv,
1549 &v6modi,
1550 &v6klbl,
1551 &v6atag,
1552 &v6keycrtr,
1553 &v6keytype,
1554 &v6bsiz,
1555 &v6esiz,
1556 &v6sdat,
1557 &v6edat,
1558 &v6sens,
1559 &v6asen,
1560 &v6extr,
1561 &v6next,
1562 &v6encr,
1563 &v6decr,
1564 &v6drve,
1565 &v6sign,
1566 &v6vrfy,
1567 &v6snrc,
1568 &v6vyrc,
1569 &v6wrap,
1570 &v6unwp,
1571 &v6data,
1572 &v6agrp,
1573 &v6pdmn,
1574 &v6sync,
1575 &v6tomb,
1576 &v6sha1,
1577 &v7vwht,
1578 &v7tkid,
1579 &v6v_Data,
1580 &v6v_pk,
1581 &v6accc,
1582 &v7utomb,
1583 &v8musr,
1584 0
1585 }
1586 };
1587
1588 /*
1589 * Version 9.1 (iOS 10.0 and OSX 10.11.8/10.12 addded minor version.
1590 */
1591 const SecDbSchema v9_1_schema = {
1592 .majorVersion = 9,
1593 .minorVersion = 1,
1594 .classes = {
1595 &v9_1_genp_class,
1596 &v9_1_inet_class,
1597 &v9_1_cert_class,
1598 &v9_1_keys_class,
1599 &v9_1_tversion_class,
1600 0
1601 }
1602 };
1603
1604 const SecDbClass v9genp_class = {
1605 .name = CFSTR("genp9"),
1606 .itemclass = true,
1607 .attrs = {
1608 &v6rowid,
1609 &v6cdat,
1610 &v6mdat,
1611 &v6desc,
1612 &v6icmt,
1613 &v6crtr,
1614 &v6type,
1615 &v6scrp,
1616 &v6labl,
1617 &v6alis,
1618 &v6invi,
1619 &v6nega,
1620 &v6cusi,
1621 &v6prot,
1622 &v6acct,
1623 &v6svce,
1624 &v6gena,
1625 &v6data,
1626 &v6agrp,
1627 &v6pdmn,
1628 &v6sync,
1629 &v6tomb,
1630 &v6sha1,
1631 &v7vwht,
1632 &v7tkid,
1633 &v6v_Data,
1634 &v6v_pk,
1635 &v6accc,
1636 &v7utomb,
1637 &v8musr,
1638 0
1639 },
1640 };
1641
1642 const SecDbClass v9inet_class = {
1643 .name = CFSTR("inet9"),
1644 .itemclass = true,
1645 .attrs = {
1646 &v6rowid,
1647 &v6cdat,
1648 &v6mdat,
1649 &v6desc,
1650 &v6icmt,
1651 &v6crtr,
1652 &v6type,
1653 &v6scrp,
1654 &v6labl,
1655 &v6alis,
1656 &v6invi,
1657 &v6nega,
1658 &v6cusi,
1659 &v6prot,
1660 &v6acct,
1661 &v6sdmn,
1662 &v6srvr,
1663 &v6ptcl,
1664 &v6atyp,
1665 &v6port,
1666 &v6path,
1667 &v6data,
1668 &v6agrp,
1669 &v6pdmn,
1670 &v6sync,
1671 &v6tomb,
1672 &v6sha1,
1673 &v7vwht,
1674 &v7tkid,
1675 &v6v_Data,
1676 &v6v_pk,
1677 &v6accc,
1678 &v7utomb,
1679 &v8musr,
1680 0
1681 },
1682 };
1683
1684 const SecDbClass v9cert_class = {
1685 .name = CFSTR("cert9"),
1686 .itemclass = true,
1687 .attrs = {
1688 &v6rowid,
1689 &v6cdat,
1690 &v6mdat,
1691 &v6ctyp,
1692 &v6cenc,
1693 &v6labl,
1694 &v6certalis,
1695 &v6subj,
1696 &v6issr,
1697 &v6slnr,
1698 &v6skid,
1699 &v6pkhh,
1700 &v6data,
1701 &v6agrp,
1702 &v6pdmn,
1703 &v6sync,
1704 &v6tomb,
1705 &v6sha1,
1706 &v7vwht,
1707 &v7tkid,
1708 &v6v_Data,
1709 &v6v_pk,
1710 &v6accc,
1711 &v7utomb,
1712 &v8musr,
1713 0
1714 },
1715 };
1716
1717 const SecDbClass v9keys_class = {
1718 .name = CFSTR("keys9"),
1719 .itemclass = true,
1720 .attrs = {
1721 &v6rowid,
1722 &v6cdat,
1723 &v6mdat,
1724 &v6kcls,
1725 &v6labl,
1726 &v6alis,
1727 &v6perm,
1728 &v6priv,
1729 &v6modi,
1730 &v6klbl,
1731 &v6atag,
1732 &v6keycrtr,
1733 &v6keytype,
1734 &v6bsiz,
1735 &v6esiz,
1736 &v6sdat,
1737 &v6edat,
1738 &v6sens,
1739 &v6asen,
1740 &v6extr,
1741 &v6next,
1742 &v6encr,
1743 &v6decr,
1744 &v6drve,
1745 &v6sign,
1746 &v6vrfy,
1747 &v6snrc,
1748 &v6vyrc,
1749 &v6wrap,
1750 &v6unwp,
1751 &v6data,
1752 &v6agrp,
1753 &v6pdmn,
1754 &v6sync,
1755 &v6tomb,
1756 &v6sha1,
1757 &v7vwht,
1758 &v7tkid,
1759 &v6v_Data,
1760 &v6v_pk,
1761 &v6accc,
1762 &v7utomb,
1763 &v8musr,
1764 0
1765 }
1766 };
1767
1768 const SecDbClass v5tversion_class = {
1769 .name = CFSTR("tversion5"),
1770 .itemclass = false,
1771 .attrs = {
1772 &v6version,
1773 0
1774 }
1775 };
1776
1777 /* Version 9 (iOS 9.3 and OSX 10.11.5) database schema
1778 * Same contents as v8 tables; table names changed to force upgrade
1779 * and correct default values in table.
1780 */
1781 const SecDbSchema v9_schema = {
1782 .majorVersion = 9,
1783 .classes = {
1784 &v9genp_class,
1785 &v9inet_class,
1786 &v9cert_class,
1787 &v9keys_class,
1788 &v5tversion_class,
1789 0
1790 }
1791 };
1792
1793 // Version 8 (Internal release iOS 9.3 and OSX 10.11.5) database schema
1794 const SecDbClass v8genp_class = {
1795 .name = CFSTR("genp8"),
1796 .itemclass = true,
1797 .attrs = {
1798 &v6rowid,
1799 &v6cdat,
1800 &v6mdat,
1801 &v6desc,
1802 &v6icmt,
1803 &v6crtr,
1804 &v6type,
1805 &v6scrp,
1806 &v6labl,
1807 &v6alis,
1808 &v6invi,
1809 &v6nega,
1810 &v6cusi,
1811 &v6prot,
1812 &v6acct,
1813 &v6svce,
1814 &v6gena,
1815 &v6data,
1816 &v6agrp,
1817 &v6pdmn,
1818 &v6sync,
1819 &v6tomb,
1820 &v6sha1,
1821 &v7vwht,
1822 &v7tkid,
1823 &v6v_Data,
1824 &v6v_pk,
1825 &v6accc,
1826 &v7utomb,
1827 &v8musr,
1828 0
1829 },
1830 };
1831
1832 const SecDbClass v8inet_class = {
1833 .name = CFSTR("inet8"),
1834 .itemclass = true,
1835 .attrs = {
1836 &v6rowid,
1837 &v6cdat,
1838 &v6mdat,
1839 &v6desc,
1840 &v6icmt,
1841 &v6crtr,
1842 &v6type,
1843 &v6scrp,
1844 &v6labl,
1845 &v6alis,
1846 &v6invi,
1847 &v6nega,
1848 &v6cusi,
1849 &v6prot,
1850 &v6acct,
1851 &v6sdmn,
1852 &v6srvr,
1853 &v6ptcl,
1854 &v6atyp,
1855 &v6port,
1856 &v6path,
1857 &v6data,
1858 &v6agrp,
1859 &v6pdmn,
1860 &v6sync,
1861 &v6tomb,
1862 &v6sha1,
1863 &v7vwht,
1864 &v7tkid,
1865 &v6v_Data,
1866 &v6v_pk,
1867 &v6accc,
1868 &v7utomb,
1869 &v8musr,
1870 0
1871 },
1872 };
1873
1874 const SecDbClass v8cert_class = {
1875 .name = CFSTR("cert8"),
1876 .itemclass = true,
1877 .attrs = {
1878 &v6rowid,
1879 &v6cdat,
1880 &v6mdat,
1881 &v6ctyp,
1882 &v6cenc,
1883 &v6labl,
1884 &v6certalis,
1885 &v6subj,
1886 &v6issr,
1887 &v6slnr,
1888 &v6skid,
1889 &v6pkhh,
1890 &v6data,
1891 &v6agrp,
1892 &v6pdmn,
1893 &v6sync,
1894 &v6tomb,
1895 &v6sha1,
1896 &v7vwht,
1897 &v7tkid,
1898 &v6v_Data,
1899 &v6v_pk,
1900 &v6accc,
1901 &v7utomb,
1902 &v8musr,
1903 0
1904 },
1905 };
1906
1907 const SecDbClass v8keys_class = {
1908 .name = CFSTR("keys8"),
1909 .itemclass = true,
1910 .attrs = {
1911 &v6rowid,
1912 &v6cdat,
1913 &v6mdat,
1914 &v6kcls,
1915 &v6labl,
1916 &v6alis,
1917 &v6perm,
1918 &v6priv,
1919 &v6modi,
1920 &v6klbl,
1921 &v6atag,
1922 &v6keycrtr,
1923 &v6keytype,
1924 &v6bsiz,
1925 &v6esiz,
1926 &v6sdat,
1927 &v6edat,
1928 &v6sens,
1929 &v6asen,
1930 &v6extr,
1931 &v6next,
1932 &v6encr,
1933 &v6decr,
1934 &v6drve,
1935 &v6sign,
1936 &v6vrfy,
1937 &v6snrc,
1938 &v6vyrc,
1939 &v6wrap,
1940 &v6unwp,
1941 &v6data,
1942 &v6agrp,
1943 &v6pdmn,
1944 &v6sync,
1945 &v6tomb,
1946 &v6sha1,
1947 &v7vwht,
1948 &v7tkid,
1949 &v6v_Data,
1950 &v6v_pk,
1951 &v6accc,
1952 &v7utomb,
1953 &v8musr,
1954 0
1955 }
1956 };
1957
1958 const SecDbSchema v8_schema = {
1959 .majorVersion = 8,
1960 .classes = {
1961 &v8genp_class,
1962 &v8inet_class,
1963 &v8cert_class,
1964 &v8keys_class,
1965 &v5tversion_class,
1966 0
1967 }
1968 };
1969
1970 // Version 7 (iOS 9 and OSX 10.11) database schema
1971 const SecDbClass v7genp_class = {
1972 .name = CFSTR("genp7"),
1973 .itemclass = true,
1974 .attrs = {
1975 &v6rowid,
1976 &v6cdat,
1977 &v6mdat,
1978 &v6desc,
1979 &v6icmt,
1980 &v6crtr,
1981 &v6type,
1982 &v6scrp,
1983 &v6labl,
1984 &v6alis,
1985 &v6invi,
1986 &v6nega,
1987 &v6cusi,
1988 &v6prot,
1989 &v6acct,
1990 &v6svce,
1991 &v6gena,
1992 &v6data,
1993 &v6agrp,
1994 &v6pdmn,
1995 &v6sync,
1996 &v6tomb,
1997 &v6sha1,
1998 &v7vwht,
1999 &v7tkid,
2000 &v6v_Data,
2001 &v6v_pk,
2002 &v6accc,
2003 &v7utomb,
2004 0
2005 },
2006 };
2007
2008 const SecDbClass v7inet_class = {
2009 .name = CFSTR("inet7"),
2010 .itemclass = true,
2011 .attrs = {
2012 &v6rowid,
2013 &v6cdat,
2014 &v6mdat,
2015 &v6desc,
2016 &v6icmt,
2017 &v6crtr,
2018 &v6type,
2019 &v6scrp,
2020 &v6labl,
2021 &v6alis,
2022 &v6invi,
2023 &v6nega,
2024 &v6cusi,
2025 &v6prot,
2026 &v6acct,
2027 &v6sdmn,
2028 &v6srvr,
2029 &v6ptcl,
2030 &v6atyp,
2031 &v6port,
2032 &v6path,
2033 &v6data,
2034 &v6agrp,
2035 &v6pdmn,
2036 &v6sync,
2037 &v6tomb,
2038 &v6sha1,
2039 &v7vwht,
2040 &v7tkid,
2041 &v6v_Data,
2042 &v6v_pk,
2043 &v6accc,
2044 &v7utomb,
2045 0
2046 },
2047 };
2048
2049 const SecDbClass v7cert_class = {
2050 .name = CFSTR("cert7"),
2051 .itemclass = true,
2052 .attrs = {
2053 &v6rowid,
2054 &v6cdat,
2055 &v6mdat,
2056 &v6ctyp,
2057 &v6cenc,
2058 &v6labl,
2059 &v6certalis,
2060 &v6subj,
2061 &v6issr,
2062 &v6slnr,
2063 &v6skid,
2064 &v6pkhh,
2065 &v6data,
2066 &v6agrp,
2067 &v6pdmn,
2068 &v6sync,
2069 &v6tomb,
2070 &v6sha1,
2071 &v7vwht,
2072 &v7tkid,
2073 &v6v_Data,
2074 &v6v_pk,
2075 &v6accc,
2076 &v7utomb,
2077 0
2078 },
2079 };
2080
2081 const SecDbClass v7keys_class = {
2082 .name = CFSTR("keys7"),
2083 .itemclass = true,
2084 .attrs = {
2085 &v6rowid,
2086 &v6cdat,
2087 &v6mdat,
2088 &v6kcls,
2089 &v6labl,
2090 &v6alis,
2091 &v6perm,
2092 &v6priv,
2093 &v6modi,
2094 &v6klbl,
2095 &v6atag,
2096 &v6keycrtr,
2097 &v6keytype,
2098 &v6bsiz,
2099 &v6esiz,
2100 &v6sdat,
2101 &v6edat,
2102 &v6sens,
2103 &v6asen,
2104 &v6extr,
2105 &v6next,
2106 &v6encr,
2107 &v6decr,
2108 &v6drve,
2109 &v6sign,
2110 &v6vrfy,
2111 &v6snrc,
2112 &v6vyrc,
2113 &v6wrap,
2114 &v6unwp,
2115 &v6data,
2116 &v6agrp,
2117 &v6pdmn,
2118 &v6sync,
2119 &v6tomb,
2120 &v6sha1,
2121 &v7vwht,
2122 &v7tkid,
2123 &v6v_Data,
2124 &v6v_pk,
2125 &v6accc,
2126 &v7utomb,
2127 0
2128 }
2129 };
2130
2131
2132 const SecDbSchema v7_schema = {
2133 .majorVersion = 7,
2134 .classes = {
2135 &v7genp_class,
2136 &v7inet_class,
2137 &v7cert_class,
2138 &v7keys_class,
2139 &v5tversion_class,
2140 0
2141 }
2142 };
2143
2144
2145 // Version 6 (iOS 7 and OSX 10.9) database schema
2146 static const SecDbClass v6genp_class = {
2147 .name = CFSTR("genp6"),
2148 .itemclass = true,
2149 .attrs = {
2150 &v6rowid,
2151 &v6cdat,
2152 &v6mdat,
2153 &v6desc,
2154 &v6icmt,
2155 &v6crtr,
2156 &v6type,
2157 &v6scrp,
2158 &v6labl,
2159 &v6alis,
2160 &v6invi,
2161 &v6nega,
2162 &v6cusi,
2163 &v6prot,
2164 &v6acct,
2165 &v6svce,
2166 &v6gena,
2167 &v6data,
2168 &v6agrp,
2169 &v6pdmn,
2170 &v6sync,
2171 &v6tomb,
2172 &v6sha1,
2173 &v6v_Data,
2174 &v6v_pk,
2175 &v6accc,
2176 0
2177 },
2178 };
2179
2180 static const SecDbClass v6inet_class = {
2181 .name = CFSTR("inet6"),
2182 .itemclass = true,
2183 .attrs = {
2184 &v6rowid,
2185 &v6cdat,
2186 &v6mdat,
2187 &v6desc,
2188 &v6icmt,
2189 &v6crtr,
2190 &v6type,
2191 &v6scrp,
2192 &v6labl,
2193 &v6alis,
2194 &v6invi,
2195 &v6nega,
2196 &v6cusi,
2197 &v6prot,
2198 &v6acct,
2199 &v6sdmn,
2200 &v6srvr,
2201 &v6ptcl,
2202 &v6atyp,
2203 &v6port,
2204 &v6path,
2205 &v6data,
2206 &v6agrp,
2207 &v6pdmn,
2208 &v6sync,
2209 &v6tomb,
2210 &v6sha1,
2211 &v6v_Data,
2212 &v6v_pk,
2213 &v6accc,
2214 0
2215 },
2216 };
2217
2218 static const SecDbClass v6cert_class = {
2219 .name = CFSTR("cert6"),
2220 .itemclass = true,
2221 .attrs = {
2222 &v6rowid,
2223 &v6cdat,
2224 &v6mdat,
2225 &v6ctyp,
2226 &v6cenc,
2227 &v6labl,
2228 &v6certalis,
2229 &v6subj,
2230 &v6issr,
2231 &v6slnr,
2232 &v6skid,
2233 &v6pkhh,
2234 &v6data,
2235 &v6agrp,
2236 &v6pdmn,
2237 &v6sync,
2238 &v6tomb,
2239 &v6sha1,
2240 &v6v_Data,
2241 &v6v_pk,
2242 &v6accc,
2243 0
2244 },
2245 };
2246
2247 static const SecDbClass v6keys_class = {
2248 .name = CFSTR("keys6"),
2249 .itemclass = true,
2250 .attrs = {
2251 &v6rowid,
2252 &v6cdat,
2253 &v6mdat,
2254 &v6kcls,
2255 &v6labl,
2256 &v6alis,
2257 &v6perm,
2258 &v6priv,
2259 &v6modi,
2260 &v6klbl,
2261 &v6atag,
2262 &v6keycrtr,
2263 &v6keytype,
2264 &v6bsiz,
2265 &v6esiz,
2266 &v6sdat,
2267 &v6edat,
2268 &v6sens,
2269 &v6asen,
2270 &v6extr,
2271 &v6next,
2272 &v6encr,
2273 &v6decr,
2274 &v6drve,
2275 &v6sign,
2276 &v6vrfy,
2277 &v6snrc,
2278 &v6vyrc,
2279 &v6wrap,
2280 &v6unwp,
2281 &v6data,
2282 &v6agrp,
2283 &v6pdmn,
2284 &v6sync,
2285 &v6tomb,
2286 &v6sha1,
2287 &v6v_Data,
2288 &v6v_pk,
2289 &v6accc,
2290 0
2291 }
2292 };
2293
2294 static const SecDbSchema v6_schema = {
2295 .majorVersion = 6,
2296 .classes = {
2297 &v6genp_class,
2298 &v6inet_class,
2299 &v6cert_class,
2300 &v6keys_class,
2301 &v5tversion_class,
2302 0
2303 }
2304 };
2305
2306
2307 // Version 5 (iOS 5 & iOS 6) database schema.
2308 static const SecDbClass v5genp_class = {
2309 .name = CFSTR("genp5"),
2310 .itemclass = true,
2311 .attrs = {
2312 &v6rowid,
2313 &v6cdat,
2314 &v6mdat,
2315 &v6desc,
2316 &v6icmt,
2317 &v6crtr,
2318 &v6type,
2319 &v6scrp,
2320 &v6labl,
2321 &v6alis,
2322 &v6invi,
2323 &v6nega,
2324 &v6cusi,
2325 &v6prot,
2326 &v6acct,
2327 &v6svce,
2328 &v6gena,
2329 &v6data,
2330 &v6agrp,
2331 &v6pdmn,
2332 &v6v_Data,
2333 0
2334 },
2335 };
2336
2337 static const SecDbClass v5inet_class = {
2338 .name = CFSTR("inet5"),
2339 .itemclass = true,
2340 .attrs = {
2341 &v6rowid,
2342 &v6cdat,
2343 &v6mdat,
2344 &v6desc,
2345 &v6icmt,
2346 &v6crtr,
2347 &v6type,
2348 &v6scrp,
2349 &v6labl,
2350 &v6alis,
2351 &v6invi,
2352 &v6nega,
2353 &v6cusi,
2354 &v6prot,
2355 &v6acct,
2356 &v6sdmn,
2357 &v6srvr,
2358 &v6ptcl,
2359 &v6atyp,
2360 &v6port,
2361 &v6path,
2362 &v6data,
2363 &v6agrp,
2364 &v6pdmn,
2365 &v6v_Data,
2366 0
2367 },
2368 };
2369
2370 static const SecDbClass v5cert_class = {
2371 .name = CFSTR("cert5"),
2372 .itemclass = true,
2373 .attrs = {
2374 &v6rowid,
2375 &v6cdat,
2376 &v6mdat,
2377 &v6ctyp,
2378 &v6cenc,
2379 &v6labl,
2380 &v6certalis,
2381 &v6subj,
2382 &v6issr,
2383 &v6slnr,
2384 &v6skid,
2385 &v6pkhh,
2386 &v6data,
2387 &v6agrp,
2388 &v6pdmn,
2389 &v6v_Data,
2390 0
2391 },
2392 };
2393
2394 static const SecDbClass v5keys_class = {
2395 .name = CFSTR("keys5"),
2396 .itemclass = true,
2397 .attrs = {
2398 &v6rowid,
2399 &v6cdat,
2400 &v6mdat,
2401 &v6kcls,
2402 &v6labl,
2403 &v6alis,
2404 &v6perm,
2405 &v6priv,
2406 &v6modi,
2407 &v6klbl,
2408 &v6atag,
2409 &v6keycrtr,
2410 &v6keytype,
2411 &v6bsiz,
2412 &v6esiz,
2413 &v6sdat,
2414 &v6edat,
2415 &v6sens,
2416 &v6asen,
2417 &v6extr,
2418 &v6next,
2419 &v6encr,
2420 &v6decr,
2421 &v6drve,
2422 &v6sign,
2423 &v6vrfy,
2424 &v6snrc,
2425 &v6vyrc,
2426 &v6wrap,
2427 &v6unwp,
2428 &v6data,
2429 &v6agrp,
2430 &v6pdmn,
2431 &v6v_Data,
2432 0
2433 }
2434 };
2435
2436 static const SecDbSchema v5_schema = {
2437 .majorVersion = 5,
2438 .classes = {
2439 &v5genp_class,
2440 &v5inet_class,
2441 &v5cert_class,
2442 &v5keys_class,
2443 &v5tversion_class,
2444 0
2445 }
2446 };
2447
2448 SecDbSchema const * const * kc_schemas = NULL;
2449
2450 const SecDbSchema *v10_kc_schemas[] = {
2451 &v11_2_schema,
2452 &v11_1_schema,
2453 &v11_schema,
2454 &v10_5_schema,
2455 &v10_4_schema,
2456 &v10_3_schema,
2457 &v10_2_schema,
2458 &v10_1_schema,
2459 &v10_0_schema,
2460 &v9_1_schema,
2461 &v9_schema,
2462 &v8_schema,
2463 &v7_schema,
2464 &v6_schema,
2465 &v5_schema,
2466 0
2467 };
2468
2469 const SecDbSchema * const * all_schemas() {
2470 return v10_kc_schemas;
2471 }
2472
2473 const SecDbSchema* current_schema() {
2474 // For now, the current schema is the first in the list.
2475 return all_schemas()[0];
2476 }
2477
2478 // class accessors for current schema.
2479 static const SecDbClass* find_class(const SecDbSchema* schema, CFStringRef class_name) {
2480 for (const SecDbClass * const *pclass = schema->classes; *pclass; ++pclass) {
2481 if( CFEqualSafe((*pclass)->name, class_name) ) {
2482 return *pclass;
2483 }
2484 }
2485 return NULL;
2486 }
2487
2488 const SecDbClass* genp_class() {
2489 static const SecDbClass* genp = NULL;
2490 static dispatch_once_t onceToken;
2491 dispatch_once(&onceToken, ^{
2492 genp = find_class(current_schema(), CFSTR("genp"));
2493 });
2494 return genp;
2495 }
2496 const SecDbClass* inet_class() {
2497 static const SecDbClass* inet = NULL;
2498 static dispatch_once_t onceToken;
2499 dispatch_once(&onceToken, ^{
2500 inet = find_class(current_schema(), CFSTR("inet"));
2501 });
2502 return inet;
2503 }
2504 const SecDbClass* cert_class() {
2505 static const SecDbClass* cert = NULL;
2506 static dispatch_once_t onceToken;
2507 dispatch_once(&onceToken, ^{
2508 cert = find_class(current_schema(), CFSTR("cert"));
2509 });
2510 return cert;
2511 }
2512 const SecDbClass* keys_class() {
2513 static const SecDbClass* keys = NULL;
2514 static dispatch_once_t onceToken;
2515 dispatch_once(&onceToken, ^{
2516 keys = find_class(current_schema(), CFSTR("keys"));
2517 });
2518 return keys;
2519 }
2520
2521 // Not really a class per-se
2522 const SecDbClass* identity_class() {
2523 return &v_identity_class;
2524 }
2525
2526 // Class with 1 element in it which is the database version->
2527 const SecDbClass* tversion_class() {
2528 static const SecDbClass* tversion = NULL;
2529 static dispatch_once_t onceToken;
2530 dispatch_once(&onceToken, ^{
2531 tversion = find_class(current_schema(), CFSTR("tversion"));
2532 });
2533 return tversion;
2534 }
2535
2536