2 * Copyright (c) 2006-2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
25 * SecItemSchema.c - CoreFoundation-based constants and functions for
26 access to Security items (certificates, keys, identities, and
30 #include "SecItemSchema.h"
31 #include "keychain/securityd/SecDbKeychainItem.h"
32 #include <keychain/ckks/CKKS.h>
33 #include "CheckV12DevEnabled.h"
36 // MARK Keychain version 6 schema
38 #define __FLAGS(ARG, ...) SECDBFLAGS(__VA_ARGS__)
39 #define SECDBFLAGS(ARG, ...) __FLAGS_##ARG | __FLAGS(__VA_ARGS__)
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)
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 #define __FLAGS_X kSecDbSyncFlag | kSecDbSyncSOSCannotSyncFlag
63 // ,----------------- P : Part of primary key
64 // / ,---------------- L : Stored in local database
65 // / / ,--------------- I : Attribute wants an index in the database
66 // / / / ,-------------- S : SHA1 hashed attribute value in database (implies L)
67 // / / / / ,------------- A : Returned to client as attribute in queries (implied by C)
68 // / / / / / ,------------ D : Returned to client as data in queries (implied by C)
69 // / / / / / / ,----------- R : Returned to client as ref/persistent ref in queries
70 // / / / / / / / ,---------- C : Part of encrypted blob
71 // / / / / / / / / ,--------- H : Attribute is part of item SHA1 hash
72 // / / / / / / / / / ,-------- B : Attribute is part of iTunes/iCloud backup bag
73 // / / / / / / / / / / ,------- Z : Attribute has a default value of 0
74 // / / / / / / / / / / / ,------ E : Attribute has a default value of "" or empty data
75 // / / / / / / / / / / / / ,----- N : Attribute must have a value
76 // / / / / / / / / / / / / / ,---- U : Attribute is stored in authenticated, but not necessarily encrypted data
77 // / / / / / / / / / / / / / / ,--- V0: Sync primary key version
78 // / / / / / / / / / / / / / / / ,- Y : Attribute should be synced, or
79 // | | | | | | | | | | | | | | | | X : Attribute should be synced in CKKS, and ignored in SOS
80 // | | | | | | | | | | | | | | | |
81 // common to all | | | | | | | | | | | | | | | |
82 SECDB_ATTR(v6rowid
, "rowid", RowId
, SecDbFlags( ,L
, , , , ,R
, , ,B
, , , , , , ), NULL
, NULL
);
83 SECDB_ATTR(v6cdat
, "cdat", CreationDate
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), SecDbKeychainItemCopyCurrentDate
, NULL
);
84 SECDB_ATTR(v6mdat
, "mdat",ModificationDate
,SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), SecDbKeychainItemCopyCurrentDate
, NULL
);
85 SECDB_ATTR(v6labl
, "labl", Blob
, SecDbFlags( ,L
, ,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
86 SECDB_ATTR(v6data
, "data", EncryptedData
, SecDbFlags( ,L
, , , , , , , ,B
, , , , , , ), SecDbKeychainItemCopyEncryptedData
, NULL
);
87 SECDB_ATTR(v6agrp
, "agrp", String
, SecDbFlags(P
,L
, , ,A
, , , ,H
, , , ,N
,U
,V0
,Y
), NULL
, NULL
);
88 SECDB_ATTR(v6pdmn
, "pdmn", Access
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
89 SECDB_ATTR(v6sync
, "sync", Sync
, SecDbFlags(P
,L
, , ,A
, , , ,H
, ,Z
, ,N
,U
,V0
, ), NULL
, NULL
);
90 SECDB_ATTR(v6tomb
, "tomb", Tomb
, SecDbFlags( ,L
, , , , , , ,H
, ,Z
, ,N
,U
, ,Y
), NULL
, NULL
);
91 SECDB_ATTR(v6sha1
, "sha1", SHA1
, SecDbFlags( ,L
,I
, ,A
, ,R
, , , , , , , , ,Y
), SecDbKeychainItemCopySHA1
, NULL
);
92 SECDB_ATTR(v6accc
, "accc", AccessControl
, SecDbFlags( , , , ,A
, , , , , , , , , , , ), NULL
, NULL
);
93 SECDB_ATTR(v6v_Data
, "v_Data", Data
, SecDbFlags( , , , , ,D
, ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
94 SECDB_ATTR(v6v_pk
, "v_pk", PrimaryKey
, SecDbFlags( , , , , , , , , , , , , , , , ), SecDbKeychainItemCopyPrimaryKey
, NULL
);
95 SECDB_ATTR(v7vwht
, "vwht", String
, SecDbFlags(P
,L
,I
, ,A
, , , ,H
, , , , ,U
,V2
,Y
), NULL
, NULL
);
96 SECDB_ATTR(v7tkid
, "tkid", String
, SecDbFlags(P
,L
,I
, ,A
, , , ,H
, , , , ,U
,V2
,Y
), NULL
, NULL
);
97 SECDB_ATTR(v7utomb
, "u_Tomb", UTomb
, SecDbFlags( , , , , , , , , , , , , , , , ), NULL
, NULL
);
98 SECDB_ATTR(v8musr
, "musr", UUID
, SecDbFlags(P
,L
, , , , , , , , , , ,N
,U
, ,Y
), NULL
, NULL
);
99 SECDB_ATTR(v11_7appclip
, "clip", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, ,N
, , , ), NULL
, NULL
);
100 // genp and inet and keys | | | | | | | | | | | | | | | |
101 SECDB_ATTR(v6crtr
, "crtr", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
102 SECDB_ATTR(v6alis
, "alis", Blob
, SecDbFlags( ,L
, ,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
103 // genp and inet | | | | | | | | | | | | | | | |
104 SECDB_ATTR(v6desc
, "desc", Blob
, SecDbFlags( ,L
, ,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
105 SECDB_ATTR(v6icmt
, "icmt", Blob
, SecDbFlags( ,L
, ,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
106 SECDB_ATTR(v6type
, "type", Number
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
107 SECDB_ATTR(v6invi
, "invi", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
108 SECDB_ATTR(v6nega
, "nega", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
109 SECDB_ATTR(v6cusi
, "cusi", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
110 SECDB_ATTR(v6prot
, "prot", Blob
, SecDbFlags( ,L
, ,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
111 SECDB_ATTR(v6scrp
, "scrp", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
112 SECDB_ATTR(v6acct
, "acct", Blob
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
113 // genp only | | | | | | | | | | | | | | | |
114 SECDB_ATTR(v6svce
, "svce", Blob
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
115 SECDB_ATTR(v6gena
, "gena", Blob
, SecDbFlags( ,L
, ,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
116 // inet only | | | | | | | | | | | | | | | |
117 SECDB_ATTR(v6sdmn
, "sdmn", Blob
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
118 SECDB_ATTR(v6srvr
, "srvr", Blob
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
119 SECDB_ATTR(v6ptcl
, "ptcl", Number
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
120 SECDB_ATTR(v6atyp
, "atyp", Blob
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
121 SECDB_ATTR(v6port
, "port", Number
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
122 SECDB_ATTR(v6path
, "path", Blob
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
123 // cert only | | | | | | | | | | | | | | | |
124 SECDB_ATTR(v6ctyp
, "ctyp", Number
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
125 SECDB_ATTR(v6cenc
, "cenc", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
126 SECDB_ATTR(v6subj
, "subj", Data
, SecDbFlags( ,L
,I
,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
127 SECDB_ATTR(v6issr
, "issr", Data
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
128 SECDB_ATTR(v6slnr
, "slnr", Data
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
129 SECDB_ATTR(v6skid
, "skid", Data
, SecDbFlags( ,L
,I
,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
130 SECDB_ATTR(v6pkhh
, "pkhh", Data
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
131 // cert attributes that share names with common ones but have different flags
132 SECDB_ATTR(v6certalis
, "alis", Blob
, SecDbFlags( ,L
,I
,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
133 // keys only | | | | | | | | | | | | | | | |
134 SECDB_ATTR(v6kcls
, "kcls", Number
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
135 SECDB_ATTR(v6perm
, "perm", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
136 SECDB_ATTR(v6priv
, "priv", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
137 SECDB_ATTR(v6modi
, "modi", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
138 SECDB_ATTR(v6klbl
, "klbl", Data
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
139 SECDB_ATTR(v6atag
, "atag", Blob
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
140 SECDB_ATTR(v6bsiz
, "bsiz", Number
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
141 SECDB_ATTR(v6esiz
, "esiz", Number
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
142 SECDB_ATTR(v6sdat
, "sdat", Date
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
143 SECDB_ATTR(v6edat
, "edat", Date
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
144 SECDB_ATTR(v6sens
, "sens", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
145 SECDB_ATTR(v6asen
, "asen", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
146 SECDB_ATTR(v6extr
, "extr", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
147 SECDB_ATTR(v6next
, "next", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
148 SECDB_ATTR(v6encr
, "encr", Number
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
149 SECDB_ATTR(v6decr
, "decr", Number
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
150 SECDB_ATTR(v6drve
, "drve", Number
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
151 SECDB_ATTR(v6sign
, "sign", Number
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
152 SECDB_ATTR(v6vrfy
, "vrfy", Number
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
153 SECDB_ATTR(v6snrc
, "snrc", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
154 SECDB_ATTR(v6vyrc
, "vyrc", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
155 SECDB_ATTR(v6wrap
, "wrap", Number
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
156 SECDB_ATTR(v6unwp
, "unwp", Number
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
157 // keys attributes that share names with common ones but have different flags
158 SECDB_ATTR(v6keytype
, "type", Number
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
159 SECDB_ATTR(v6keycrtr
, "crtr", Number
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
160 // | | | | | | | | | | | | | | |
161 SECDB_ATTR(v6version
, "version", Number
, SecDbFlags(P
,L
,I
, , , , , , , , , ,N
, , ,Y
), NULL
, NULL
);
162 SECDB_ATTR(v91minor
, "minor", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, ,N
, , ,Y
), NULL
, NULL
);
164 SECDB_ATTR(v10_1pcsservice
, "pcss", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
165 SECDB_ATTR(v10_1pcspublickey
, "pcsk", Blob
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
166 SECDB_ATTR(v10_1pcspublicidentity
,"pcsi", Blob
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
168 SECDB_ATTR(v10itemuuid
, "UUID", String
, SecDbFlags( ,L
,I
, , , , , , , , , , ,U
, , ), NULL
, NULL
);
169 SECDB_ATTR(v10syncuuid
, "UUID", String
, SecDbFlags(P
,L
,I
, , , , , , , , , , ,U
, , ), NULL
, NULL
);
170 SECDB_ATTR(v10parentKeyUUID
, "parentKeyUUID", String
, SecDbFlags( ,L
,I
, , , , , , , , , ,N
, , , ), NULL
, NULL
);
171 SECDB_ATTR(v10currentKeyUUID
,"currentKeyUUID",String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
172 SECDB_ATTR(v10wrappedkey
, "wrappedkey", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
173 SECDB_ATTR(v10encrypteditem
, "encitem", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
174 SECDB_ATTR(v10gencount
, "gencount", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, ,N
, , , ), NULL
, NULL
);
175 SECDB_ATTR(v10action
, "action", String
, SecDbFlags( ,L
,I
, , , , , , , , , ,N
, , , ), NULL
, NULL
);
176 SECDB_ATTR(v10state
, "state", String
, SecDbFlags(P
,L
,I
, , , , , , , , , ,N
, , , ), NULL
, NULL
);
177 SECDB_ATTR(v10waituntiltime
, "waituntil", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
178 SECDB_ATTR(v10encodedCKRecord
, "ckrecord", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
179 SECDB_ATTR(v10_1wasCurrent
, "wascurrent", Number
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
180 SECDB_ATTR(v10accessgroup
, "accessgroup", String
, SecDbFlags( ,L
,I
, , , , , , , , , ,N
, , , ), NULL
, NULL
);
181 SECDB_ATTR(v10keyclass
, "keyclass", String
, SecDbFlags(P
,L
,I
, , , , , , , , , ,N
, , , ), NULL
, NULL
);
182 SECDB_ATTR(v10currentkey
, "currentkey", Number
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
183 SECDB_ATTR(v10ckzone
, "ckzone", String
, SecDbFlags(P
,L
,I
, , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
184 SECDB_ATTR(v10ckzonecreated
, "ckzonecreated", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, , ,N
, , ), NULL
, NULL
);
185 SECDB_ATTR(v10ckzonesubscribed
,"ckzonesubscribed", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, ,N
, , , ), NULL
, NULL
);
186 SECDB_ATTR(v10ratelimiter
, "ratelimiter", Blob
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
187 SECDB_ATTR(v10changetoken
, "changetoken", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
188 SECDB_ATTR(v10lastfetchtime
, "lastfetch", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
189 SECDB_ATTR(v10itempersistentref
,"persistref", UUID
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
190 SECDB_ATTR(v10sysbound
, "sysb", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, ,Z
, , , , , ), NULL
, NULL
);
191 SECDB_ATTR(v10encryptionver
, "encver", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, ,N
,U
, , ), NULL
, NULL
);
193 SECDB_ATTR(v10primaryKey
, "primaryKey", String
, SecDbFlags(P
,L
,I
, ,A
, , , , , , , ,N
,U
, , ), NULL
, NULL
);
194 SECDB_ATTR(v10publickeyHash
, "publickeyHash", Blob
, SecDbFlags(P
,L
,I
, , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
195 SECDB_ATTR(v10publickey
, "publickey", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
196 SECDB_ATTR(v10backupData
, "backupData", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
198 SECDB_ATTR(v10_1digest
, "digest", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
199 SECDB_ATTR(v10_1signatures
, "signatures", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
200 SECDB_ATTR(v10_1signerID
, "signerID", String
, SecDbFlags( ,L
, , , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
201 SECDB_ATTR(v10_1leafIDs
, "leafIDs", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
202 SECDB_ATTR(v10_1peerManIDs
, "peerManifests", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
203 SECDB_ATTR(v10_1entryDigests
,"entryDigests", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
204 SECDB_ATTR(v10_2currentItems
,"currentItems", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
205 SECDB_ATTR(v10_2futureData
, "futureData", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
206 SECDB_ATTR(v10_2schema
, "schema", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
207 SECDB_ATTR(v10_1encRecord
, "ckrecord", Blob
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
209 SECDB_ATTR(v10_1keyArchiveHash
, "key_archive_hash", String
, SecDbFlags(P
,L
,I
, , , , , , , , , ,N
, , , ), NULL
, NULL
);
210 SECDB_ATTR(v10_1keyArchive
, "key_archive", String
, SecDbFlags(P
,L
,I
, , , , , , , , , ,N
, , , ), NULL
, NULL
);
211 SECDB_ATTR(v10_1archivedKey
, "archived_key", String
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
212 SECDB_ATTR(v10_1keyArchiveName
, "keyarchive_name", String
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
213 SECDB_ATTR(v10_1optionalEncodedCKRecord
, "ckrecord", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
214 SECDB_ATTR(v10_1archiveEscrowID
,"archive_escrowid", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
216 SECDB_ATTR(v10_1itempersistentref
,"persistref", UUID
, SecDbFlags( ,L
,I
, , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
218 SECDB_ATTR(v10_1currentItemUUID
,"currentItemUUID",String
, SecDbFlags(P
,L
,I
, , , , , , , , , , , , , ), NULL
, NULL
);
219 SECDB_ATTR(v10_4currentItemUUID
,"currentItemUUID",String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
220 SECDB_ATTR(v10_1currentPtrIdentifier
,"identifier",String
, SecDbFlags(P
,L
,I
, , , , , , , , , , , , , ), NULL
, NULL
);
222 SECDB_ATTR(v10_2device
, "device", String
, SecDbFlags(P
,L
,I
, , , , , , , , , , , , , ), NULL
, NULL
);
223 SECDB_ATTR(v10_2peerid
, "peerid", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
224 SECDB_ATTR(v10_2circleStatus
,"circlestatus", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
225 SECDB_ATTR(v10_2keyState
, "keystate", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
226 SECDB_ATTR(v10_2currentTLK
, "currentTLK", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
227 SECDB_ATTR(v10_2currentClassA
,"currentClassA",String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
228 SECDB_ATTR(v10_2currentClassC
,"currentClassC",String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
230 SECDB_ATTR(v10_4lastFixup
, "lastfixup", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, , ,N
, , ), NULL
, NULL
);
232 SECDB_ATTR(v10_5senderPeerID
,"senderpeerid", String
, SecDbFlags(P
,L
,I
, , , , , , , , , , , , , ), NULL
, NULL
);
233 SECDB_ATTR(v10_5recvPeerID
, "recvpeerid", String
, SecDbFlags(P
,L
,I
, , , , , , , , , , , , , ), NULL
, NULL
);
234 SECDB_ATTR(v10_5recvPubKey
, "recvpubenckey", Blob
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
235 SECDB_ATTR(v10_5curve
, "curve", Number
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
236 SECDB_ATTR(v10_5poisoned
, "poisoned", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, ,N
, , , ), NULL
, NULL
);
237 SECDB_ATTR(v10_5epoch
, "epoch", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, ,N
, , , ), NULL
, NULL
);
238 SECDB_ATTR(v10_5signature
, "signature", Blob
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
239 SECDB_ATTR(v10_5version
, "version", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, ,N
,U
, , ), NULL
, NULL
);
241 SECDB_ATTR(v11_1osversion
, "osversion", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
242 SECDB_ATTR(v11_1lastunlock
, "lastunlock", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
244 SECDB_ATTR(v11_2actualKeyclass
, "actualKeyclass", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
246 SECDB_ATTR(v11_5octagonpeerid
, "octagonpeerid", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
247 SECDB_ATTR(v11_5octagonStatus
, "octagonstatus", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
249 SECDB_ATTR(v11_6moreComing
, "morecoming", Number
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
251 SECDB_ATTR(v11_8_bin_notes
, "binn", Data
, SecDbFlags( , , , , ,D
, ,C
, , , , , , , ,X
), NULL
, NULL
);
252 SECDB_ATTR(v11_8_bin_history
, "bini", Data
, SecDbFlags( , , , , ,D
, ,C
, , , , , , , ,X
), NULL
, NULL
);
253 SECDB_ATTR(v11_8_bin_client0
, "bin0", Data
, SecDbFlags( , , , , ,D
, ,C
, , , , , , , ,X
), NULL
, NULL
);
254 SECDB_ATTR(v11_8_bin_client1
, "bin1", Data
, SecDbFlags( , , , , ,D
, ,C
, , , , , , , ,X
), NULL
, NULL
);
255 SECDB_ATTR(v11_8_bin_client2
, "bin2", Data
, SecDbFlags( , , , , ,D
, ,C
, , , , , , , ,X
), NULL
, NULL
);
256 SECDB_ATTR(v11_8_bin_client3
, "bin3", Data
, SecDbFlags( , , , , ,D
, ,C
, , , , , , , ,X
), NULL
, NULL
);
258 SECDB_ATTR(v11_9_lastscan
, "lastscan", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
259 SECDB_ATTR(v11_9_extra
, "extra", Blob
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
261 SECDB_ATTR(v12_backupUUIDPrimary
, "backupUUID", UUID
, SecDbFlags(P
,L
,I
, , , , , , , , , ,N
, , , ), NULL
, NULL
);
262 SECDB_ATTR(v12_backupUUID
, "backupUUID", UUID
, SecDbFlags( ,L
,I
, , , , , , , , ,E
, , , , ), NULL
, NULL
);
263 SECDB_ATTR(v12_backupBag
, "backupbag", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
264 SECDB_ATTR(v12_defaultValue
, "defaultvalue", Number
, SecDbFlags( ,L
,I
, , , , , , , ,Z
, , , , , ), NULL
, NULL
);
265 SECDB_ATTR(v12_keyClassSigningKey
, "signingkey", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
266 SECDB_ATTR(v12_recoveryType
, "recoverytype", String
, SecDbFlags(P
,L
,I
, , , , , , , , , ,N
, , , ), NULL
, NULL
);
267 SECDB_ATTR(v12_recoverySet
, "recoveryset", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
268 SECDB_ATTR(v12_metadatakeydata
, "metadatakeydata", Blob
, SecDbFlags( ,L
, , , , , , , , , ,E
, , , , ), NULL
, NULL
);
270 const SecDbClass v12_backupbags_class
= {
271 .name
= CFSTR("backupbags"),
274 &v12_backupUUIDPrimary
, // primary
281 const SecDbClass v12_backupkeyclasssigningkeys_class
= {
282 .name
= CFSTR("backupkeyclasssigningkeys"),
285 &v10keyclass
, // primary
286 &v12_backupUUIDPrimary
, // primary
287 &v12_keyClassSigningKey
,
292 const SecDbClass v12_backuprecoverysets_class
= {
293 .name
= CFSTR("backuprecoverysets"),
296 &v12_backupUUIDPrimary
, // primary
297 &v12_recoveryType
, // primary
303 const SecDbClass v12_metadatakeys_class
= {
304 .name
= CFSTR("metadatakeys"),
308 &v11_2actualKeyclass
,
310 &v12_metadatakeydata
,
315 const SecDbClass v12_genp_class
= {
316 .name
= CFSTR("genp"),
353 &v10_1pcspublicidentity
,
354 &v10_1itempersistentref
,
361 const SecDbClass v12_inet_class
= {
362 .name
= CFSTR("inet"),
403 &v10_1pcspublicidentity
,
404 &v10_1itempersistentref
,
417 const SecDbClass v12_cert_class
= {
418 .name
= CFSTR("cert"),
450 &v10_1pcspublicidentity
,
451 &v10_1itempersistentref
,
458 const SecDbClass v12_keys_class
= {
459 .name
= CFSTR("keys"),
509 &v10_1pcspublicidentity
,
510 &v10_1itempersistentref
,
517 const SecDbClass v11_9_ckstate_class
= {
518 .name
= CFSTR("ckstate"),
523 &v10ckzonesubscribed
,
535 const SecDbClass v11_8_inet_class
= {
536 .name
= CFSTR("inet"),
577 &v10_1pcspublicidentity
,
578 &v10_1itempersistentref
,
590 const SecDbClass v11_7_genp_class
= {
591 .name
= CFSTR("genp"),
628 &v10_1pcspublicidentity
,
629 &v10_1itempersistentref
,
635 const SecDbClass v11_7_inet_class
= {
636 .name
= CFSTR("inet"),
677 &v10_1pcspublicidentity
,
678 &v10_1itempersistentref
,
684 const SecDbClass v11_7_cert_class
= {
685 .name
= CFSTR("cert"),
717 &v10_1pcspublicidentity
,
718 &v10_1itempersistentref
,
724 const SecDbClass v11_7_keys_class
= {
725 .name
= CFSTR("keys"),
775 &v10_1pcspublicidentity
,
776 &v10_1itempersistentref
,
782 const SecDbClass v11_6_ckstate_class
= {
783 .name
= CFSTR("ckstate"),
788 &v10ckzonesubscribed
,
798 const SecDbClass v11_5_ckdevicestate_class
= {
799 .name
= CFSTR("ckdevicestate"),
819 const SecDbClass v11_2_metadatakeys_class
= {
820 .name
= CFSTR("metadatakeys"),
824 &v11_2actualKeyclass
,
830 const SecDbClass v11_1_ckdevicestate_class
= {
831 .name
= CFSTR("ckdevicestate"),
849 const SecDbClass v11_metadatakeys_class
= {
850 .name
= CFSTR("metadatakeys"),
859 const SecDbClass v10_5_tlkshare_class
= {
860 .name
= CFSTR("tlkshare"),
880 const SecDbClass v10_4_current_item_class
= {
881 .name
= CFSTR("currentitems"),
885 &v10_1currentPtrIdentifier
,
886 &v10_4currentItemUUID
,
893 const SecDbClass v10_4_ckstate_class
= {
894 .name
= CFSTR("ckstate"),
899 &v10ckzonesubscribed
,
908 const SecDbClass v10_3_ckdevicestate_class
= {
909 .name
= CFSTR("ckdevicestate"),
925 const SecDbClass v10_2_ckmanifest_class
= {
926 .name
= CFSTR("ckmanifest"),
944 const SecDbClass v10_2_pending_manifest_class
= {
945 .name
= CFSTR("pending_manifest"),
963 const SecDbClass v10_1_ckmanifest_class
= {
964 .name
= CFSTR("ckmanifest"),
979 const SecDbClass v10_1_pending_manifest_class
= {
980 .name
= CFSTR("pending_manifest"),
995 const SecDbClass v10_1_ckmanifest_leaf_class
= {
996 .name
= CFSTR("ckmanifest_leaf"),
1008 const SecDbClass v10_1_pending_manifest_leaf_class
= {
1009 .name
= CFSTR("pending_manifest_leaf"),
1021 const SecDbClass v10_1_genp_class
= {
1022 .name
= CFSTR("genp"),
1059 &v10_1pcspublicidentity
,
1060 &v10_1itempersistentref
,
1065 const SecDbClass v10_1_inet_class
= {
1066 .name
= CFSTR("inet"),
1107 &v10_1pcspublicidentity
,
1108 &v10_1itempersistentref
,
1113 const SecDbClass v10_1_cert_class
= {
1114 .name
= CFSTR("cert"),
1146 &v10_1pcspublicidentity
,
1147 &v10_1itempersistentref
,
1152 const SecDbClass v10_1_keys_class
= {
1153 .name
= CFSTR("keys"),
1203 &v10_1pcspublicidentity
,
1204 &v10_1itempersistentref
,
1209 const SecDbClass v10_0_tversion_class
= {
1210 .name
= CFSTR("tversion"),
1220 const SecDbClass v10_2_outgoing_queue_class
= {
1221 .name
= CFSTR("outgoingqueue"),
1235 &v10_1optionalEncodedCKRecord
,
1238 &v10_1pcspublicidentity
,
1243 const SecDbClass v10_2_incoming_queue_class
= {
1244 .name
= CFSTR("incomingqueue"),
1256 &v10_1optionalEncodedCKRecord
,
1259 &v10_1pcspublicidentity
,
1265 const SecDbClass v10_1_outgoing_queue_class
= {
1266 .name
= CFSTR("outgoingqueue"),
1282 &v10_1pcspublicidentity
,
1287 const SecDbClass v10_1_incoming_queue_class
= {
1288 .name
= CFSTR("incomingqueue"),
1302 &v10_1pcspublicidentity
,
1308 const SecDbClass v10_0_outgoing_queue_class
= {
1309 .name
= CFSTR("outgoingqueue"),
1327 const SecDbClass v10_0_incoming_queue_class
= {
1328 .name
= CFSTR("incomingqueue"),
1344 const SecDbClass v10_0_sync_key_class
= {
1345 .name
= CFSTR("synckeys"),
1355 &v10encodedCKRecord
,
1360 // Stores the "Current Key" records, and parentKeyUUID refers to items in the synckeys table
1361 // Wouldn't foreign keys be nice?
1362 const SecDbClass v10_0_current_key_class
= {
1363 .name
= CFSTR("currentkeys"),
1369 &v10encodedCKRecord
,
1374 const SecDbClass v10_1_current_item_class
= {
1375 .name
= CFSTR("currentitems"),
1379 &v10_1currentPtrIdentifier
,
1380 &v10_1currentItemUUID
,
1382 &v10encodedCKRecord
,
1387 const SecDbClass v10_1_ckmirror_class
= {
1388 .name
= CFSTR("ckmirror"),
1397 &v10encodedCKRecord
,
1402 &v10_1pcspublicidentity
,
1407 const SecDbClass v10_0_ckmirror_class
= {
1408 .name
= CFSTR("ckmirror"),
1417 &v10encodedCKRecord
,
1423 const SecDbClass v10_0_ckstate_class
= {
1424 .name
= CFSTR("ckstate"),
1429 &v10ckzonesubscribed
,
1438 /* Primary keys: v10primaryKey, v8musr */
1439 /* This table is currently unused */
1440 const SecDbClass v10_0_item_backup_class
= {
1441 .name
= CFSTR("item_backup"),
1445 &v10primaryKey
, // Primary key of the original item, from v6v_pk
1447 &v6sha1
, // Hash of the original item
1448 &v10backupData
, // Data wrapped to backup keybag
1449 &v6pkhh
, // Hash of the public key of the backup bag [v10publickeyHash]
1454 /* Backup Keybag table */
1455 /* Primary keys: v10publickeyHash, v8musr */
1456 /* This table is currently unused */
1457 const SecDbClass v10_0_backup_keybag_class
= {
1458 .name
= CFSTR("backup_keybag"),
1462 &v10publickeyHash
, // Hash of the public key of the backup bag
1464 &v10publickey
, // Public key for the asymmetric backup bag
1465 &v6agrp
, // Used for backup agent
1470 const SecDbClass v10_1_backup_keyarchive_class
= {
1471 .name
= CFSTR("backup_keyarchive"),
1474 &v10_1keyArchiveHash
, // Hash of the key archive
1476 &v10_1keyArchive
, // Serialised key archive
1478 &v10_1optionalEncodedCKRecord
,
1479 &v10_1archiveEscrowID
,
1484 const SecDbClass v10_1_current_archived_keys_class
= {
1485 .name
= CFSTR("archived_key_backup"),
1492 &v10_1keyArchiveHash
,
1495 &v10_1optionalEncodedCKRecord
,
1496 &v10_1archiveEscrowID
,
1501 const SecDbClass v10_1_current_keyarchive_class
= {
1502 .name
= CFSTR("currentkeyarchives"),
1505 &v10_1keyArchiveHash
,
1506 &v10_1keyArchiveName
,
1511 /* An identity which is really a cert + a key, so all cert and keys attrs are
1513 const SecDbClass v_identity_class
= {
1514 .name
= CFSTR("idnt"),
1523 * Add backup/restore mechanism
1525 const SecDbSchema v12_0_schema
= {
1533 &v10_0_tversion_class
,
1534 &v10_2_outgoing_queue_class
,
1535 &v10_2_incoming_queue_class
,
1536 &v10_0_sync_key_class
,
1537 &v10_1_ckmirror_class
,
1538 &v10_0_current_key_class
,
1539 &v11_9_ckstate_class
,
1540 &v10_0_item_backup_class
,
1541 &v10_0_backup_keybag_class
,
1542 &v10_2_ckmanifest_class
,
1543 &v10_2_pending_manifest_class
,
1544 &v10_1_ckmanifest_leaf_class
,
1545 &v10_1_backup_keyarchive_class
,
1546 &v10_1_current_keyarchive_class
,
1547 &v10_1_current_archived_keys_class
,
1548 &v10_1_pending_manifest_leaf_class
,
1549 &v10_4_current_item_class
,
1550 &v11_5_ckdevicestate_class
,
1551 &v10_5_tlkshare_class
,
1552 &v12_metadatakeys_class
,
1553 &v12_backupbags_class
,
1554 &v12_backupkeyclasssigningkeys_class
,
1555 &v12_backuprecoverysets_class
,
1562 * Add extra columns for CKState
1564 const SecDbSchema v11_9_schema
= {
1572 &v10_0_tversion_class
,
1573 &v10_2_outgoing_queue_class
,
1574 &v10_2_incoming_queue_class
,
1575 &v10_0_sync_key_class
,
1576 &v10_1_ckmirror_class
,
1577 &v10_0_current_key_class
,
1578 &v11_9_ckstate_class
,
1579 &v10_0_item_backup_class
,
1580 &v10_0_backup_keybag_class
,
1581 &v10_2_ckmanifest_class
,
1582 &v10_2_pending_manifest_class
,
1583 &v10_1_ckmanifest_leaf_class
,
1584 &v10_1_backup_keyarchive_class
,
1585 &v10_1_current_keyarchive_class
,
1586 &v10_1_current_archived_keys_class
,
1587 &v10_1_pending_manifest_leaf_class
,
1588 &v10_4_current_item_class
,
1589 &v11_5_ckdevicestate_class
,
1590 &v10_5_tlkshare_class
,
1591 &v11_2_metadatakeys_class
,
1598 * Add extra binary columns to inet
1600 const SecDbSchema v11_8_schema
= {
1608 &v10_0_tversion_class
,
1609 &v10_2_outgoing_queue_class
,
1610 &v10_2_incoming_queue_class
,
1611 &v10_0_sync_key_class
,
1612 &v10_1_ckmirror_class
,
1613 &v10_0_current_key_class
,
1614 &v11_6_ckstate_class
,
1615 &v10_0_item_backup_class
,
1616 &v10_0_backup_keybag_class
,
1617 &v10_2_ckmanifest_class
,
1618 &v10_2_pending_manifest_class
,
1619 &v10_1_ckmanifest_leaf_class
,
1620 &v10_1_backup_keyarchive_class
,
1621 &v10_1_current_keyarchive_class
,
1622 &v10_1_current_archived_keys_class
,
1623 &v10_1_pending_manifest_leaf_class
,
1624 &v10_4_current_item_class
,
1625 &v11_5_ckdevicestate_class
,
1626 &v10_5_tlkshare_class
,
1627 &v11_2_metadatakeys_class
,
1634 * Add 'clip' column to denote item was made by App Clip
1636 const SecDbSchema v11_7_schema
= {
1644 &v10_0_tversion_class
,
1645 &v10_2_outgoing_queue_class
,
1646 &v10_2_incoming_queue_class
,
1647 &v10_0_sync_key_class
,
1648 &v10_1_ckmirror_class
,
1649 &v10_0_current_key_class
,
1650 &v11_6_ckstate_class
,
1651 &v10_0_item_backup_class
,
1652 &v10_0_backup_keybag_class
,
1653 &v10_2_ckmanifest_class
,
1654 &v10_2_pending_manifest_class
,
1655 &v10_1_ckmanifest_leaf_class
,
1656 &v10_1_backup_keyarchive_class
,
1657 &v10_1_current_keyarchive_class
,
1658 &v10_1_current_archived_keys_class
,
1659 &v10_1_pending_manifest_leaf_class
,
1660 &v10_4_current_item_class
,
1661 &v11_5_ckdevicestate_class
,
1662 &v10_5_tlkshare_class
,
1663 &v11_2_metadatakeys_class
,
1669 * Version 11.6 (Add 'moreComing' field to zone state)
1671 const SecDbSchema v11_6_schema
= {
1679 &v10_0_tversion_class
,
1680 &v10_2_outgoing_queue_class
,
1681 &v10_2_incoming_queue_class
,
1682 &v10_0_sync_key_class
,
1683 &v10_1_ckmirror_class
,
1684 &v10_0_current_key_class
,
1685 &v11_6_ckstate_class
,
1686 &v10_0_item_backup_class
,
1687 &v10_0_backup_keybag_class
,
1688 &v10_2_ckmanifest_class
,
1689 &v10_2_pending_manifest_class
,
1690 &v10_1_ckmanifest_leaf_class
,
1691 &v10_1_backup_keyarchive_class
,
1692 &v10_1_current_keyarchive_class
,
1693 &v10_1_current_archived_keys_class
,
1694 &v10_1_pending_manifest_leaf_class
,
1695 &v10_4_current_item_class
,
1696 &v11_5_ckdevicestate_class
,
1697 &v10_5_tlkshare_class
,
1698 &v11_2_metadatakeys_class
,
1704 * Version 11.5 (Add octagon fields to device state)
1706 const SecDbSchema v11_5_schema
= {
1714 &v10_0_tversion_class
,
1715 &v10_2_outgoing_queue_class
,
1716 &v10_2_incoming_queue_class
,
1717 &v10_0_sync_key_class
,
1718 &v10_1_ckmirror_class
,
1719 &v10_0_current_key_class
,
1720 &v10_4_ckstate_class
,
1721 &v10_0_item_backup_class
,
1722 &v10_0_backup_keybag_class
,
1723 &v10_2_ckmanifest_class
,
1724 &v10_2_pending_manifest_class
,
1725 &v10_1_ckmanifest_leaf_class
,
1726 &v10_1_backup_keyarchive_class
,
1727 &v10_1_current_keyarchive_class
,
1728 &v10_1_current_archived_keys_class
,
1729 &v10_1_pending_manifest_leaf_class
,
1730 &v10_4_current_item_class
,
1731 &v11_5_ckdevicestate_class
,
1732 &v10_5_tlkshare_class
,
1733 &v11_2_metadatakeys_class
,
1740 * Version 11.4 (Add some more indexes)
1742 const SecDbSchema v11_4_schema
= {
1750 &v10_0_tversion_class
,
1751 &v10_2_outgoing_queue_class
,
1752 &v10_2_incoming_queue_class
,
1753 &v10_0_sync_key_class
,
1754 &v10_1_ckmirror_class
,
1755 &v10_0_current_key_class
,
1756 &v10_4_ckstate_class
,
1757 &v10_0_item_backup_class
,
1758 &v10_0_backup_keybag_class
,
1759 &v10_2_ckmanifest_class
,
1760 &v10_2_pending_manifest_class
,
1761 &v10_1_ckmanifest_leaf_class
,
1762 &v10_1_backup_keyarchive_class
,
1763 &v10_1_current_keyarchive_class
,
1764 &v10_1_current_archived_keys_class
,
1765 &v10_1_pending_manifest_leaf_class
,
1766 &v10_4_current_item_class
,
1767 &v11_1_ckdevicestate_class
,
1768 &v10_5_tlkshare_class
,
1769 &v11_2_metadatakeys_class
,
1775 * Version 11.3 (no changes, restores the use of indexes in upgrade code. Gotta go fast!)
1777 const SecDbSchema v11_3_schema
= {
1785 &v10_0_tversion_class
,
1786 &v10_2_outgoing_queue_class
,
1787 &v10_2_incoming_queue_class
,
1788 &v10_0_sync_key_class
,
1789 &v10_1_ckmirror_class
,
1790 &v10_0_current_key_class
,
1791 &v10_4_ckstate_class
,
1792 &v10_0_item_backup_class
,
1793 &v10_0_backup_keybag_class
,
1794 &v10_2_ckmanifest_class
,
1795 &v10_2_pending_manifest_class
,
1796 &v10_1_ckmanifest_leaf_class
,
1797 &v10_1_backup_keyarchive_class
,
1798 &v10_1_current_keyarchive_class
,
1799 &v10_1_current_archived_keys_class
,
1800 &v10_1_pending_manifest_leaf_class
,
1801 &v10_4_current_item_class
,
1802 &v11_1_ckdevicestate_class
,
1803 &v10_5_tlkshare_class
,
1804 &v11_2_metadatakeys_class
,
1812 const SecDbSchema v11_2_schema
= {
1820 &v10_0_tversion_class
,
1821 &v10_2_outgoing_queue_class
,
1822 &v10_2_incoming_queue_class
,
1823 &v10_0_sync_key_class
,
1824 &v10_1_ckmirror_class
,
1825 &v10_0_current_key_class
,
1826 &v10_4_ckstate_class
,
1827 &v10_0_item_backup_class
,
1828 &v10_0_backup_keybag_class
,
1829 &v10_2_ckmanifest_class
,
1830 &v10_2_pending_manifest_class
,
1831 &v10_1_ckmanifest_leaf_class
,
1832 &v10_1_backup_keyarchive_class
,
1833 &v10_1_current_keyarchive_class
,
1834 &v10_1_current_archived_keys_class
,
1835 &v10_1_pending_manifest_leaf_class
,
1836 &v10_4_current_item_class
,
1837 &v11_1_ckdevicestate_class
,
1838 &v10_5_tlkshare_class
,
1839 &v11_2_metadatakeys_class
,
1847 const SecDbSchema v11_1_schema
= {
1855 &v10_0_tversion_class
,
1856 &v10_2_outgoing_queue_class
,
1857 &v10_2_incoming_queue_class
,
1858 &v10_0_sync_key_class
,
1859 &v10_1_ckmirror_class
,
1860 &v10_0_current_key_class
,
1861 &v10_4_ckstate_class
,
1862 &v10_0_item_backup_class
,
1863 &v10_0_backup_keybag_class
,
1864 &v10_2_ckmanifest_class
,
1865 &v10_2_pending_manifest_class
,
1866 &v10_1_ckmanifest_leaf_class
,
1867 &v10_1_backup_keyarchive_class
,
1868 &v10_1_current_keyarchive_class
,
1869 &v10_1_current_archived_keys_class
,
1870 &v10_1_pending_manifest_leaf_class
,
1871 &v10_4_current_item_class
,
1872 &v11_1_ckdevicestate_class
,
1873 &v10_5_tlkshare_class
,
1874 &v11_metadatakeys_class
,
1882 const SecDbSchema v11_schema
= {
1890 &v10_0_tversion_class
,
1891 &v10_2_outgoing_queue_class
,
1892 &v10_2_incoming_queue_class
,
1893 &v10_0_sync_key_class
,
1894 &v10_1_ckmirror_class
,
1895 &v10_0_current_key_class
,
1896 &v10_4_ckstate_class
,
1897 &v10_0_item_backup_class
,
1898 &v10_0_backup_keybag_class
,
1899 &v10_2_ckmanifest_class
,
1900 &v10_2_pending_manifest_class
,
1901 &v10_1_ckmanifest_leaf_class
,
1902 &v10_1_backup_keyarchive_class
,
1903 &v10_1_current_keyarchive_class
,
1904 &v10_1_current_archived_keys_class
,
1905 &v10_1_pending_manifest_leaf_class
,
1906 &v10_4_current_item_class
,
1907 &v10_3_ckdevicestate_class
,
1908 &v10_5_tlkshare_class
,
1909 &v11_metadatakeys_class
,
1918 const SecDbSchema v10_5_schema
= {
1926 &v10_0_tversion_class
,
1927 &v10_2_outgoing_queue_class
,
1928 &v10_2_incoming_queue_class
,
1929 &v10_0_sync_key_class
,
1930 &v10_1_ckmirror_class
,
1931 &v10_0_current_key_class
,
1932 &v10_4_ckstate_class
,
1933 &v10_0_item_backup_class
,
1934 &v10_0_backup_keybag_class
,
1935 &v10_2_ckmanifest_class
,
1936 &v10_2_pending_manifest_class
,
1937 &v10_1_ckmanifest_leaf_class
,
1938 &v10_1_backup_keyarchive_class
,
1939 &v10_1_current_keyarchive_class
,
1940 &v10_1_current_archived_keys_class
,
1941 &v10_1_pending_manifest_leaf_class
,
1942 &v10_4_current_item_class
,
1943 &v10_3_ckdevicestate_class
,
1944 &v10_5_tlkshare_class
,
1952 const SecDbSchema v10_4_schema
= {
1960 &v10_0_tversion_class
,
1961 &v10_2_outgoing_queue_class
,
1962 &v10_2_incoming_queue_class
,
1963 &v10_0_sync_key_class
,
1964 &v10_1_ckmirror_class
,
1965 &v10_0_current_key_class
,
1966 &v10_4_ckstate_class
,
1967 &v10_0_item_backup_class
,
1968 &v10_0_backup_keybag_class
,
1969 &v10_2_ckmanifest_class
,
1970 &v10_2_pending_manifest_class
,
1971 &v10_1_ckmanifest_leaf_class
,
1972 &v10_1_backup_keyarchive_class
,
1973 &v10_1_current_keyarchive_class
,
1974 &v10_1_current_archived_keys_class
,
1975 &v10_1_pending_manifest_leaf_class
,
1976 &v10_4_current_item_class
,
1977 &v10_3_ckdevicestate_class
,
1985 const SecDbSchema v10_3_schema
= {
1993 &v10_0_tversion_class
,
1994 &v10_2_outgoing_queue_class
,
1995 &v10_2_incoming_queue_class
,
1996 &v10_0_sync_key_class
,
1997 &v10_1_ckmirror_class
,
1998 &v10_0_current_key_class
,
1999 &v10_0_ckstate_class
,
2000 &v10_0_item_backup_class
,
2001 &v10_0_backup_keybag_class
,
2002 &v10_2_ckmanifest_class
,
2003 &v10_2_pending_manifest_class
,
2004 &v10_1_ckmanifest_leaf_class
,
2005 &v10_1_backup_keyarchive_class
,
2006 &v10_1_current_keyarchive_class
,
2007 &v10_1_current_archived_keys_class
,
2008 &v10_1_pending_manifest_leaf_class
,
2009 &v10_1_current_item_class
,
2010 &v10_3_ckdevicestate_class
,
2018 const SecDbSchema v10_2_schema
= {
2026 &v10_0_tversion_class
,
2027 &v10_2_outgoing_queue_class
,
2028 &v10_2_incoming_queue_class
,
2029 &v10_0_sync_key_class
,
2030 &v10_1_ckmirror_class
,
2031 &v10_0_current_key_class
,
2032 &v10_0_ckstate_class
,
2033 &v10_0_item_backup_class
,
2034 &v10_0_backup_keybag_class
,
2035 &v10_2_ckmanifest_class
,
2036 &v10_2_pending_manifest_class
,
2037 &v10_1_ckmanifest_leaf_class
,
2038 &v10_1_backup_keyarchive_class
,
2039 &v10_1_current_keyarchive_class
,
2040 &v10_1_current_archived_keys_class
,
2041 &v10_1_pending_manifest_leaf_class
,
2042 &v10_1_current_item_class
,
2050 const SecDbSchema v10_1_schema
= {
2058 &v10_0_tversion_class
,
2059 &v10_1_outgoing_queue_class
,
2060 &v10_1_incoming_queue_class
,
2061 &v10_0_sync_key_class
,
2062 &v10_1_ckmirror_class
,
2063 &v10_0_current_key_class
,
2064 &v10_0_ckstate_class
,
2065 &v10_0_item_backup_class
,
2066 &v10_0_backup_keybag_class
,
2067 &v10_1_ckmanifest_class
,
2068 &v10_1_pending_manifest_class
,
2069 &v10_1_ckmanifest_leaf_class
,
2070 &v10_1_backup_keyarchive_class
,
2071 &v10_1_current_keyarchive_class
,
2072 &v10_1_current_archived_keys_class
,
2073 &v10_1_pending_manifest_leaf_class
,
2074 &v10_1_current_item_class
,
2083 const SecDbClass v10_0_genp_class
= {
2084 .name
= CFSTR("genp"),
2118 &v10itempersistentref
,
2124 const SecDbClass v10_0_inet_class
= {
2125 .name
= CFSTR("inet"),
2163 &v10itempersistentref
,
2169 const SecDbClass v10_0_cert_class
= {
2170 .name
= CFSTR("cert"),
2199 &v10itempersistentref
,
2205 const SecDbClass v10_0_keys_class
= {
2206 .name
= CFSTR("keys"),
2253 &v10itempersistentref
,
2259 const SecDbSchema v10_0_schema
= {
2267 &v10_0_tversion_class
,
2268 &v10_0_outgoing_queue_class
,
2269 &v10_0_incoming_queue_class
,
2270 &v10_0_sync_key_class
,
2271 &v10_0_ckmirror_class
,
2272 &v10_0_current_key_class
,
2273 &v10_0_ckstate_class
,
2274 &v10_0_item_backup_class
,
2275 &v10_0_backup_keybag_class
,
2280 const SecDbClass v9_1_tversion_class
= {
2281 .name
= CFSTR("tversion91"),
2291 const SecDbClass v9_1_genp_class
= {
2292 .name
= CFSTR("genp91"),
2329 const SecDbClass v9_1_inet_class
= {
2330 .name
= CFSTR("inet91"),
2371 const SecDbClass v9_1_cert_class
= {
2372 .name
= CFSTR("cert91"),
2404 const SecDbClass v9_1_keys_class
= {
2405 .name
= CFSTR("keys91"),
2456 * Version 9.1 (iOS 10.0 and OSX 10.11.8/10.12 addded minor version.
2458 const SecDbSchema v9_1_schema
= {
2466 &v9_1_tversion_class
,
2471 const SecDbClass v9genp_class
= {
2472 .name
= CFSTR("genp9"),
2509 const SecDbClass v9inet_class
= {
2510 .name
= CFSTR("inet9"),
2551 const SecDbClass v9cert_class
= {
2552 .name
= CFSTR("cert9"),
2584 const SecDbClass v9keys_class
= {
2585 .name
= CFSTR("keys9"),
2635 const SecDbClass v5tversion_class
= {
2636 .name
= CFSTR("tversion5"),
2644 /* Version 9 (iOS 9.3 and OSX 10.11.5) database schema
2645 * Same contents as v8 tables; table names changed to force upgrade
2646 * and correct default values in table.
2648 const SecDbSchema v9_schema
= {
2660 // Version 8 (Internal release iOS 9.3 and OSX 10.11.5) database schema
2661 const SecDbClass v8genp_class
= {
2662 .name
= CFSTR("genp8"),
2699 const SecDbClass v8inet_class
= {
2700 .name
= CFSTR("inet8"),
2741 const SecDbClass v8cert_class
= {
2742 .name
= CFSTR("cert8"),
2774 const SecDbClass v8keys_class
= {
2775 .name
= CFSTR("keys8"),
2825 const SecDbSchema v8_schema
= {
2837 // Version 7 (iOS 9 and OSX 10.11) database schema
2838 const SecDbClass v7genp_class
= {
2839 .name
= CFSTR("genp7"),
2875 const SecDbClass v7inet_class
= {
2876 .name
= CFSTR("inet7"),
2916 const SecDbClass v7cert_class
= {
2917 .name
= CFSTR("cert7"),
2948 const SecDbClass v7keys_class
= {
2949 .name
= CFSTR("keys7"),
2999 const SecDbSchema v7_schema
= {
3012 // Version 6 (iOS 7 and OSX 10.9) database schema
3013 static const SecDbClass v6genp_class
= {
3014 .name
= CFSTR("genp6"),
3047 static const SecDbClass v6inet_class
= {
3048 .name
= CFSTR("inet6"),
3085 static const SecDbClass v6cert_class
= {
3086 .name
= CFSTR("cert6"),
3114 static const SecDbClass v6keys_class
= {
3115 .name
= CFSTR("keys6"),
3161 static const SecDbSchema v6_schema
= {
3174 // Version 5 (iOS 5 & iOS 6) database schema.
3175 static const SecDbClass v5genp_class
= {
3176 .name
= CFSTR("genp5"),
3204 static const SecDbClass v5inet_class
= {
3205 .name
= CFSTR("inet5"),
3237 static const SecDbClass v5cert_class
= {
3238 .name
= CFSTR("cert5"),
3261 static const SecDbClass v5keys_class
= {
3262 .name
= CFSTR("keys5"),
3303 static const SecDbSchema v5_schema
= {
3315 SecDbSchema
const * const * kc_schemas
= NULL
;
3317 const SecDbSchema
*v10_kc_schemas_dev
[] = {
3344 const SecDbSchema
*v10_kc_schemas
[] = {
3370 const SecDbSchema
* const * all_schemas() {
3371 static dispatch_once_t onceToken
;
3372 dispatch_once(&onceToken
, ^{
3373 if (checkV12DevEnabled()) {
3374 secwarning("SecItemSchema: v12 development enabled, returning experimental schema");
3376 secnotice("SecItemSchema", "v12 development disabled, returning production schemas");
3379 if (checkV12DevEnabled() != 0) {
3380 return v10_kc_schemas_dev
;
3382 return v10_kc_schemas
;
3386 const SecDbSchema
* current_schema() {
3387 // For now, the current schema is the first in the list.
3388 return all_schemas()[0];
3391 // class accessors for current schema.
3392 static const SecDbClass
* find_class(const SecDbSchema
* schema
, CFStringRef class_name
) {
3393 for (const SecDbClass
* const *pclass
= schema
->classes
; *pclass
; ++pclass
) {
3394 if( CFEqualSafe((*pclass
)->name
, class_name
) ) {
3401 const SecDbClass
* genp_class() {
3402 static const SecDbClass
* genp
= NULL
;
3403 static dispatch_once_t onceToken
;
3404 dispatch_once(&onceToken
, ^{
3405 genp
= find_class(current_schema(), CFSTR("genp"));
3409 const SecDbClass
* inet_class() {
3410 static const SecDbClass
* inet
= NULL
;
3411 static dispatch_once_t onceToken
;
3412 dispatch_once(&onceToken
, ^{
3413 inet
= find_class(current_schema(), CFSTR("inet"));
3417 const SecDbClass
* cert_class() {
3418 static const SecDbClass
* cert
= NULL
;
3419 static dispatch_once_t onceToken
;
3420 dispatch_once(&onceToken
, ^{
3421 cert
= find_class(current_schema(), CFSTR("cert"));
3425 const SecDbClass
* keys_class() {
3426 static const SecDbClass
* keys
= NULL
;
3427 static dispatch_once_t onceToken
;
3428 dispatch_once(&onceToken
, ^{
3429 keys
= find_class(current_schema(), CFSTR("keys"));
3434 // Not really a class per-se
3435 const SecDbClass
* identity_class() {
3436 return &v_identity_class
;
3439 // Class with 1 element in it which is the database version->
3440 const SecDbClass
* tversion_class() {
3441 static const SecDbClass
* tversion
= NULL
;
3442 static dispatch_once_t onceToken
;
3443 dispatch_once(&onceToken
, ^{
3444 tversion
= find_class(current_schema(), CFSTR("tversion"));