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