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 <securityd/SecDbKeychainItem.h>
32 #include <keychain/ckks/CKKS.h>
35 // MARK Keychain version 6 schema
37 #define __FLAGS(ARG, ...) SECDBFLAGS(__VA_ARGS__)
38 #define SECDBFLAGS(ARG, ...) __FLAGS_##ARG | __FLAGS(__VA_ARGS__)
40 #define SecDbFlags(P,L,I,S,A,D,R,C,H,B,Z,E,N,U,V,Y) (__FLAGS_##P|__FLAGS_##L|__FLAGS_##I|__FLAGS_##S|__FLAGS_##A|__FLAGS_##D|__FLAGS_##R|__FLAGS_##C|__FLAGS_##H|__FLAGS_##B|__FLAGS_##Z|__FLAGS_##E|__FLAGS_##N|__FLAGS_##U|__FLAGS_##V|__FLAGS_##Y)
43 #define __FLAGS_P kSecDbPrimaryKeyFlag
44 #define __FLAGS_L kSecDbInFlag
45 #define __FLAGS_I kSecDbIndexFlag
46 #define __FLAGS_S kSecDbSHA1ValueInFlag
47 #define __FLAGS_A kSecDbReturnAttrFlag
48 #define __FLAGS_D kSecDbReturnDataFlag
49 #define __FLAGS_R kSecDbReturnRefFlag
50 #define __FLAGS_C kSecDbInCryptoDataFlag
51 #define __FLAGS_H kSecDbInHashFlag
52 #define __FLAGS_B kSecDbInBackupFlag
53 #define __FLAGS_Z kSecDbDefault0Flag
54 #define __FLAGS_E kSecDbDefaultEmptyFlag
55 #define __FLAGS_N kSecDbNotNullFlag
56 #define __FLAGS_U kSecDbInAuthenticatedDataFlag
57 #define __FLAGS_V0 kSecDbSyncPrimaryKeyV0
58 #define __FLAGS_V2 (kSecDbSyncPrimaryKeyV0 | kSecDbSyncPrimaryKeyV2)
59 #define __FLAGS_Y kSecDbSyncFlag
61 // ,----------------- P : Part of primary key
62 // / ,---------------- L : Stored in local database
63 // / / ,--------------- I : Attribute wants an index in the database
64 // / / / ,-------------- S : SHA1 hashed attribute value in database (implies L)
65 // / / / / ,------------- A : Returned to client as attribute in queries
66 // / / / / / ,------------ D : Returned to client as data in queries
67 // / / / / / / ,----------- R : Returned to client as ref/persistent ref in queries
68 // / / / / / / / ,---------- C : Part of encrypted blob
69 // / / / / / / / / ,--------- H : Attribute is part of item SHA1 hash (Implied by C)
70 // / / / / / / / / / ,-------- B : Attribute is part of iTunes/iCloud backup bag
71 // / / / / / / / / / / ,------- Z : Attribute has a default value of 0
72 // / / / / / / / / / / / ,------ E : Attribute has a default value of "" or empty data
73 // / / / / / / / / / / / / ,----- N : Attribute must have a value
74 // / / / / / / / / / / / / / ,---- U : Attribute is stored in authenticated, but not necessarily encrypted data
75 // / / / / / / / / / / / / / / ,--- V0: Sync primary key version
76 // / / / / / / / / / / / / / / / ,- Y : Attribute should be synced
77 // | | | | | | | | | | | | | | | |
78 // common to all | | | | | | | | | | | | | | | |
79 SECDB_ATTR(v6rowid
, "rowid", RowId
, SecDbFlags( ,L
, , , , ,R
, , ,B
, , , , , , ), NULL
, NULL
);
80 SECDB_ATTR(v6cdat
, "cdat", CreationDate
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), SecDbKeychainItemCopyCurrentDate
, NULL
);
81 SECDB_ATTR(v6mdat
, "mdat",ModificationDate
,SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), SecDbKeychainItemCopyCurrentDate
, NULL
);
82 SECDB_ATTR(v6labl
, "labl", Blob
, SecDbFlags( ,L
, ,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
83 SECDB_ATTR(v6data
, "data", EncryptedData
, SecDbFlags( ,L
, , , , , , , ,B
, , , , , , ), SecDbKeychainItemCopyEncryptedData
, NULL
);
84 SECDB_ATTR(v6agrp
, "agrp", String
, SecDbFlags(P
,L
,I
, ,A
, , , ,H
, , , ,N
,U
,V0
,Y
), NULL
, NULL
);
85 SECDB_ATTR(v6pdmn
, "pdmn", Access
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
86 SECDB_ATTR(v6sync
, "sync", Sync
, SecDbFlags(P
,L
,I
, ,A
, , , ,H
, ,Z
, ,N
,U
,V0
, ), NULL
, NULL
);
87 SECDB_ATTR(v6tomb
, "tomb", Tomb
, SecDbFlags( ,L
, , , , , , ,H
, ,Z
, ,N
,U
, ,Y
), NULL
, NULL
);
88 SECDB_ATTR(v6sha1
, "sha1", SHA1
, SecDbFlags( ,L
,I
, ,A
, ,R
, , , , , , , , ,Y
), SecDbKeychainItemCopySHA1
, NULL
);
89 SECDB_ATTR(v6accc
, "accc", AccessControl
, SecDbFlags( , , , ,A
, , , , , , , , , , , ), NULL
, NULL
);
90 SECDB_ATTR(v6v_Data
, "v_Data", Data
, SecDbFlags( , , , , ,D
, ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
91 SECDB_ATTR(v6v_pk
, "v_pk", PrimaryKey
, SecDbFlags( , , , , , , , , , , , , , , , ), SecDbKeychainItemCopyPrimaryKey
, NULL
);
92 SECDB_ATTR(v7vwht
, "vwht", String
, SecDbFlags(P
,L
,I
, ,A
, , , ,H
, , , , ,U
,V2
,Y
), NULL
, NULL
);
93 SECDB_ATTR(v7tkid
, "tkid", String
, SecDbFlags(P
,L
,I
, ,A
, , , ,H
, , , , ,U
,V2
,Y
), NULL
, NULL
);
94 SECDB_ATTR(v7utomb
, "u_Tomb", UTomb
, SecDbFlags( , , , , , , , , , , , , , , , ), NULL
, NULL
);
95 SECDB_ATTR(v8musr
, "musr", UUID
, SecDbFlags(P
,L
,I
, , , , , , , , , ,N
,U
, ,Y
), NULL
, NULL
);
96 // genp and inet and keys | | | | | | | | | | | | | | | |
97 SECDB_ATTR(v6crtr
, "crtr", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
98 SECDB_ATTR(v6alis
, "alis", Blob
, SecDbFlags( ,L
, ,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
99 // genp and inet | | | | | | | | | | | | | | | |
100 SECDB_ATTR(v6desc
, "desc", Blob
, SecDbFlags( ,L
, ,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
101 SECDB_ATTR(v6icmt
, "icmt", Blob
, SecDbFlags( ,L
, ,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
102 SECDB_ATTR(v6type
, "type", Number
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
103 SECDB_ATTR(v6invi
, "invi", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
104 SECDB_ATTR(v6nega
, "nega", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
105 SECDB_ATTR(v6cusi
, "cusi", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
106 SECDB_ATTR(v6prot
, "prot", Blob
, SecDbFlags( ,L
, ,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
107 SECDB_ATTR(v6scrp
, "scrp", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
108 SECDB_ATTR(v6acct
, "acct", Blob
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
109 // genp only | | | | | | | | | | | | | | | |
110 SECDB_ATTR(v6svce
, "svce", Blob
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
111 SECDB_ATTR(v6gena
, "gena", Blob
, SecDbFlags( ,L
, ,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
112 // inet only | | | | | | | | | | | | | | | |
113 SECDB_ATTR(v6sdmn
, "sdmn", Blob
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
114 SECDB_ATTR(v6srvr
, "srvr", Blob
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
115 SECDB_ATTR(v6ptcl
, "ptcl", Number
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
116 SECDB_ATTR(v6atyp
, "atyp", Blob
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
117 SECDB_ATTR(v6port
, "port", Number
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
118 SECDB_ATTR(v6path
, "path", Blob
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
119 // cert only | | | | | | | | | | | | | | | |
120 SECDB_ATTR(v6ctyp
, "ctyp", Number
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
121 SECDB_ATTR(v6cenc
, "cenc", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
122 SECDB_ATTR(v6subj
, "subj", Data
, SecDbFlags( ,L
,I
,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
123 SECDB_ATTR(v6issr
, "issr", Data
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
124 SECDB_ATTR(v6slnr
, "slnr", Data
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
125 SECDB_ATTR(v6skid
, "skid", Data
, SecDbFlags( ,L
,I
,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
126 SECDB_ATTR(v6pkhh
, "pkhh", Data
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
127 // cert attributes that share names with common ones but have different flags
128 SECDB_ATTR(v6certalis
, "alis", Blob
, SecDbFlags( ,L
,I
,S
,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
129 // keys only | | | | | | | | | | | | | | | |
130 SECDB_ATTR(v6kcls
, "kcls", Number
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
131 SECDB_ATTR(v6perm
, "perm", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
132 SECDB_ATTR(v6priv
, "priv", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
133 SECDB_ATTR(v6modi
, "modi", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
134 SECDB_ATTR(v6klbl
, "klbl", Data
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
135 SECDB_ATTR(v6atag
, "atag", Blob
, SecDbFlags(P
,L
,I
,S
,A
, , ,C
,H
, , ,E
,N
, ,V0
,Y
), NULL
, NULL
);
136 SECDB_ATTR(v6bsiz
, "bsiz", Number
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
137 SECDB_ATTR(v6esiz
, "esiz", Number
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
138 SECDB_ATTR(v6sdat
, "sdat", Date
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
139 SECDB_ATTR(v6edat
, "edat", Date
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
140 SECDB_ATTR(v6sens
, "sens", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
141 SECDB_ATTR(v6asen
, "asen", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
142 SECDB_ATTR(v6extr
, "extr", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
143 SECDB_ATTR(v6next
, "next", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
144 SECDB_ATTR(v6encr
, "encr", Number
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
145 SECDB_ATTR(v6decr
, "decr", Number
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
146 SECDB_ATTR(v6drve
, "drve", Number
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
147 SECDB_ATTR(v6sign
, "sign", Number
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
148 SECDB_ATTR(v6vrfy
, "vrfy", Number
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
149 SECDB_ATTR(v6snrc
, "snrc", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
150 SECDB_ATTR(v6vyrc
, "vyrc", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
151 SECDB_ATTR(v6wrap
, "wrap", Number
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
152 SECDB_ATTR(v6unwp
, "unwp", Number
, SecDbFlags( ,L
,I
, ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
153 // keys attributes that share names with common ones but have different flags
154 SECDB_ATTR(v6keytype
, "type", Number
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
155 SECDB_ATTR(v6keycrtr
, "crtr", Number
, SecDbFlags(P
,L
,I
, ,A
, , ,C
,H
, ,Z
, ,N
, ,V0
,Y
), NULL
, NULL
);
156 // | | | | | | | | | | | | | | |
157 SECDB_ATTR(v6version
, "version", Number
, SecDbFlags(P
,L
,I
, , , , , , , , , ,N
, , ,Y
), NULL
, NULL
);
158 SECDB_ATTR(v91minor
, "minor", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, ,N
, , ,Y
), NULL
, NULL
);
160 SECDB_ATTR(v10_1pcsservice
, "pcss", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
161 SECDB_ATTR(v10_1pcspublickey
, "pcsk", Blob
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
162 SECDB_ATTR(v10_1pcspublicidentity
,"pcsi", Blob
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, , , , , , ,Y
), NULL
, NULL
);
164 SECDB_ATTR(v10itemuuid
, "UUID", String
, SecDbFlags( ,L
,I
, , , , , , , , , , ,U
, , ), NULL
, NULL
);
165 SECDB_ATTR(v10syncuuid
, "UUID", String
, SecDbFlags(P
,L
,I
, , , , , , , , , , ,U
, , ), NULL
, NULL
);
166 SECDB_ATTR(v10parentKeyUUID
, "parentKeyUUID", String
, SecDbFlags( ,L
,I
, , , , , , , , , ,N
, , , ), NULL
, NULL
);
167 SECDB_ATTR(v10currentKeyUUID
,"currentKeyUUID",String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
168 SECDB_ATTR(v10wrappedkey
, "wrappedkey", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
169 SECDB_ATTR(v10encrypteditem
, "encitem", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
170 SECDB_ATTR(v10gencount
, "gencount", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, ,N
, , , ), NULL
, NULL
);
171 SECDB_ATTR(v10action
, "action", String
, SecDbFlags( ,L
,I
, , , , , , , , , ,N
, , , ), NULL
, NULL
);
172 SECDB_ATTR(v10state
, "state", String
, SecDbFlags(P
,L
,I
, , , , , , , , , ,N
, , , ), NULL
, NULL
);
173 SECDB_ATTR(v10waituntiltime
, "waituntil", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
174 SECDB_ATTR(v10encodedCKRecord
, "ckrecord", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
175 SECDB_ATTR(v10_1wasCurrent
, "wascurrent", Number
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
176 SECDB_ATTR(v10accessgroup
, "accessgroup", String
, SecDbFlags( ,L
,I
, , , , , , , , , ,N
, , , ), NULL
, NULL
);
177 SECDB_ATTR(v10keyclass
, "keyclass", String
, SecDbFlags(P
,L
,I
, , , , , , , , , ,N
, , , ), NULL
, NULL
);
178 SECDB_ATTR(v10currentkey
, "currentkey", Number
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
179 SECDB_ATTR(v10ckzone
, "ckzone", String
, SecDbFlags(P
,L
,I
, , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
180 SECDB_ATTR(v10ckzonecreated
, "ckzonecreated", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, , ,N
, , ), NULL
, NULL
);
181 SECDB_ATTR(v10ckzonesubscribed
,"ckzonesubscribed", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, ,N
, , , ), NULL
, NULL
);
182 SECDB_ATTR(v10ratelimiter
, "ratelimiter", Blob
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
183 SECDB_ATTR(v10changetoken
, "changetoken", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
184 SECDB_ATTR(v10lastfetchtime
, "lastfetch", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
185 SECDB_ATTR(v10itempersistentref
,"persistref", UUID
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
186 SECDB_ATTR(v10sysbound
, "sysb", Number
, SecDbFlags( ,L
, , ,A
, , ,C
,H
, ,Z
, , , , , ), NULL
, NULL
);
187 SECDB_ATTR(v10encryptionver
, "encver", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, ,N
,U
, , ), NULL
, NULL
);
189 SECDB_ATTR(v10primaryKey
, "primaryKey", String
, SecDbFlags(P
,L
,I
, ,A
, , , , , , , ,N
,U
, , ), NULL
, NULL
);
190 SECDB_ATTR(v10publickeyHash
, "publickeyHash", Blob
, SecDbFlags(P
,L
,I
, , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
191 SECDB_ATTR(v10publickey
, "publickey", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
192 SECDB_ATTR(v10backupData
, "backupData", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
194 SECDB_ATTR(v10_1digest
, "digest", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
195 SECDB_ATTR(v10_1signatures
, "signatures", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
196 SECDB_ATTR(v10_1signerID
, "signerID", String
, SecDbFlags( ,L
, , , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
197 SECDB_ATTR(v10_1leafIDs
, "leafIDs", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
198 SECDB_ATTR(v10_1peerManIDs
, "peerManifests", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
199 SECDB_ATTR(v10_1entryDigests
,"entryDigests", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
200 SECDB_ATTR(v10_2currentItems
,"currentItems", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
201 SECDB_ATTR(v10_2futureData
, "futureData", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
202 SECDB_ATTR(v10_2schema
, "schema", Blob
, SecDbFlags( ,L
, , , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
203 SECDB_ATTR(v10_1encRecord
, "ckrecord", Blob
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
205 SECDB_ATTR(v10_1keyArchiveHash
, "key_archive_hash", String
, SecDbFlags(P
,L
,I
, , , , , , , , , ,N
, , , ), NULL
, NULL
);
206 SECDB_ATTR(v10_1keyArchive
, "key_archive", String
, SecDbFlags(P
,L
,I
, , , , , , , , , ,N
, , , ), NULL
, NULL
);
207 SECDB_ATTR(v10_1archivedKey
, "archived_key", String
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
208 SECDB_ATTR(v10_1keyArchiveName
, "keyarchive_name", String
, SecDbFlags( ,L
, , , , , , , , , , ,N
, , , ), NULL
, NULL
);
209 SECDB_ATTR(v10_1optionalEncodedCKRecord
, "ckrecord", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
210 SECDB_ATTR(v10_1archiveEscrowID
,"archive_escrowid", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
212 SECDB_ATTR(v10_1itempersistentref
,"persistref", UUID
, SecDbFlags( ,L
,I
, , , , , , , , , ,N
,U
, , ), NULL
, NULL
);
214 SECDB_ATTR(v10_1currentItemUUID
,"currentItemUUID",String
, SecDbFlags(P
,L
,I
, , , , , , , , , , , , , ), NULL
, NULL
);
215 SECDB_ATTR(v10_4currentItemUUID
,"currentItemUUID",String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
216 SECDB_ATTR(v10_1currentPtrIdentifier
,"identifier",String
, SecDbFlags(P
,L
,I
, , , , , , , , , , , , , ), NULL
, NULL
);
218 SECDB_ATTR(v10_2device
, "device", String
, SecDbFlags(P
,L
,I
, , , , , , , , , , , , , ), NULL
, NULL
);
219 SECDB_ATTR(v10_2peerid
, "peerid", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
220 SECDB_ATTR(v10_2circleStatus
,"circlestatus", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
221 SECDB_ATTR(v10_2keyState
, "keystate", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
222 SECDB_ATTR(v10_2currentTLK
, "currentTLK", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
223 SECDB_ATTR(v10_2currentClassA
,"currentClassA",String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
224 SECDB_ATTR(v10_2currentClassC
,"currentClassC",String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
226 SECDB_ATTR(v10_4lastFixup
, "lastfixup", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, , ,N
, , ), NULL
, NULL
);
228 SECDB_ATTR(v10_5senderPeerID
,"senderpeerid", String
, SecDbFlags(P
,L
,I
, , , , , , , , , , , , , ), NULL
, NULL
);
229 SECDB_ATTR(v10_5recvPeerID
, "recvpeerid", String
, SecDbFlags(P
,L
,I
, , , , , , , , , , , , , ), NULL
, NULL
);
230 SECDB_ATTR(v10_5recvPubKey
, "recvpubenckey", Blob
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
231 SECDB_ATTR(v10_5curve
, "curve", Number
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
232 SECDB_ATTR(v10_5poisoned
, "poisoned", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, ,N
, , , ), NULL
, NULL
);
233 SECDB_ATTR(v10_5epoch
, "epoch", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, ,N
, , , ), NULL
, NULL
);
234 SECDB_ATTR(v10_5signature
, "signature", Blob
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
235 SECDB_ATTR(v10_5version
, "version", Number
, SecDbFlags( ,L
, , , , , , , , ,Z
, ,N
,U
, , ), NULL
, NULL
);
237 SECDB_ATTR(v11_1osversion
, "osversion", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
238 SECDB_ATTR(v11_1lastunlock
, "lastunlock", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
240 SECDB_ATTR(v11_2actualKeyclass
, "actualKeyclass", String
, SecDbFlags( ,L
, , , , , , , , , , , , , , ), NULL
, NULL
);
242 const SecDbClass v11_2_metadatakeys_class
= {
243 .name
= CFSTR("metadatakeys"),
247 &v11_2actualKeyclass
,
253 const SecDbClass v11_1_ckdevicestate_class
= {
254 .name
= CFSTR("ckdevicestate"),
272 const SecDbClass v11_metadatakeys_class
= {
273 .name
= CFSTR("metadatakeys"),
282 const SecDbClass v10_5_tlkshare_class
= {
283 .name
= CFSTR("tlkshare"),
303 const SecDbClass v10_4_current_item_class
= {
304 .name
= CFSTR("currentitems"),
308 &v10_1currentPtrIdentifier
,
309 &v10_4currentItemUUID
,
316 const SecDbClass v10_4_ckstate_class
= {
317 .name
= CFSTR("ckstate"),
322 &v10ckzonesubscribed
,
331 const SecDbClass v10_3_ckdevicestate_class
= {
332 .name
= CFSTR("ckdevicestate"),
348 const SecDbClass v10_2_ckmanifest_class
= {
349 .name
= CFSTR("ckmanifest"),
367 const SecDbClass v10_2_pending_manifest_class
= {
368 .name
= CFSTR("pending_manifest"),
386 const SecDbClass v10_1_ckmanifest_class
= {
387 .name
= CFSTR("ckmanifest"),
402 const SecDbClass v10_1_pending_manifest_class
= {
403 .name
= CFSTR("pending_manifest"),
418 const SecDbClass v10_1_ckmanifest_leaf_class
= {
419 .name
= CFSTR("ckmanifest_leaf"),
431 const SecDbClass v10_1_pending_manifest_leaf_class
= {
432 .name
= CFSTR("pending_manifest_leaf"),
444 const SecDbClass v10_1_genp_class
= {
445 .name
= CFSTR("genp"),
482 &v10_1pcspublicidentity
,
483 &v10_1itempersistentref
,
488 const SecDbClass v10_1_inet_class
= {
489 .name
= CFSTR("inet"),
530 &v10_1pcspublicidentity
,
531 &v10_1itempersistentref
,
536 const SecDbClass v10_1_cert_class
= {
537 .name
= CFSTR("cert"),
569 &v10_1pcspublicidentity
,
570 &v10_1itempersistentref
,
575 const SecDbClass v10_1_keys_class
= {
576 .name
= CFSTR("keys"),
626 &v10_1pcspublicidentity
,
627 &v10_1itempersistentref
,
632 const SecDbClass v10_0_tversion_class
= {
633 .name
= CFSTR("tversion"),
643 const SecDbClass v10_2_outgoing_queue_class
= {
644 .name
= CFSTR("outgoingqueue"),
658 &v10_1optionalEncodedCKRecord
,
661 &v10_1pcspublicidentity
,
666 const SecDbClass v10_2_incoming_queue_class
= {
667 .name
= CFSTR("incomingqueue"),
679 &v10_1optionalEncodedCKRecord
,
682 &v10_1pcspublicidentity
,
688 const SecDbClass v10_1_outgoing_queue_class
= {
689 .name
= CFSTR("outgoingqueue"),
705 &v10_1pcspublicidentity
,
710 const SecDbClass v10_1_incoming_queue_class
= {
711 .name
= CFSTR("incomingqueue"),
725 &v10_1pcspublicidentity
,
731 const SecDbClass v10_0_outgoing_queue_class
= {
732 .name
= CFSTR("outgoingqueue"),
750 const SecDbClass v10_0_incoming_queue_class
= {
751 .name
= CFSTR("incomingqueue"),
767 const SecDbClass v10_0_sync_key_class
= {
768 .name
= CFSTR("synckeys"),
783 // Stores the "Current Key" records, and parentKeyUUID refers to items in the synckeys table
784 // Wouldn't foreign keys be nice?
785 const SecDbClass v10_0_current_key_class
= {
786 .name
= CFSTR("currentkeys"),
797 const SecDbClass v10_1_current_item_class
= {
798 .name
= CFSTR("currentitems"),
802 &v10_1currentPtrIdentifier
,
803 &v10_1currentItemUUID
,
810 const SecDbClass v10_1_ckmirror_class
= {
811 .name
= CFSTR("ckmirror"),
825 &v10_1pcspublicidentity
,
830 const SecDbClass v10_0_ckmirror_class
= {
831 .name
= CFSTR("ckmirror"),
846 const SecDbClass v10_0_ckstate_class
= {
847 .name
= CFSTR("ckstate"),
852 &v10ckzonesubscribed
,
861 /* Primary keys: v10primaryKey, v8musr */
862 const SecDbClass v10_0_item_backup_class
= {
863 .name
= CFSTR("item_backup"),
867 &v10primaryKey
, // Primary key of the original item, from v6v_pk
869 &v6sha1
, // Hash of the original item
870 &v10backupData
, // Data wrapped to backup keybag
871 &v6pkhh
, // Hash of the public key of the backup bag [v10publickeyHash]
876 /* Backup Keybag table */
877 /* Primary keys: v10publickeyHash, v8musr */
878 const SecDbClass v10_0_backup_keybag_class
= {
879 .name
= CFSTR("backup_keybag"),
883 &v10publickeyHash
, // Hash of the public key of the backup bag
885 &v10publickey
, // Public key for the asymmetric backup bag
886 &v6agrp
, // Used for backup agent
891 const SecDbClass v10_1_backup_keyarchive_class
= {
892 .name
= CFSTR("backup_keyarchive"),
895 &v10_1keyArchiveHash
, // Hash of the key archive
897 &v10_1keyArchive
, // Serialised key archive
899 &v10_1optionalEncodedCKRecord
,
900 &v10_1archiveEscrowID
,
905 const SecDbClass v10_1_current_archived_keys_class
= {
906 .name
= CFSTR("archived_key_backup"),
913 &v10_1keyArchiveHash
,
916 &v10_1optionalEncodedCKRecord
,
917 &v10_1archiveEscrowID
,
922 const SecDbClass v10_1_current_keyarchive_class
= {
923 .name
= CFSTR("currentkeyarchives"),
926 &v10_1keyArchiveHash
,
927 &v10_1keyArchiveName
,
932 /* An identity which is really a cert + a key, so all cert and keys attrs are
934 const SecDbClass v_identity_class
= {
935 .name
= CFSTR("idnt"),
943 * Version 11.4 (Add some more indexes)
945 const SecDbSchema v11_4_schema
= {
953 &v10_0_tversion_class
,
954 &v10_2_outgoing_queue_class
,
955 &v10_2_incoming_queue_class
,
956 &v10_0_sync_key_class
,
957 &v10_1_ckmirror_class
,
958 &v10_0_current_key_class
,
959 &v10_4_ckstate_class
,
960 &v10_0_item_backup_class
,
961 &v10_0_backup_keybag_class
,
962 &v10_2_ckmanifest_class
,
963 &v10_2_pending_manifest_class
,
964 &v10_1_ckmanifest_leaf_class
,
965 &v10_1_backup_keyarchive_class
,
966 &v10_1_current_keyarchive_class
,
967 &v10_1_current_archived_keys_class
,
968 &v10_1_pending_manifest_leaf_class
,
969 &v10_4_current_item_class
,
970 &v11_1_ckdevicestate_class
,
971 &v10_5_tlkshare_class
,
972 &v11_2_metadatakeys_class
,
978 * Version 11.3 (no changes, restores the use of indexes in upgrade code. Gotta go fast!)
980 const SecDbSchema v11_3_schema
= {
988 &v10_0_tversion_class
,
989 &v10_2_outgoing_queue_class
,
990 &v10_2_incoming_queue_class
,
991 &v10_0_sync_key_class
,
992 &v10_1_ckmirror_class
,
993 &v10_0_current_key_class
,
994 &v10_4_ckstate_class
,
995 &v10_0_item_backup_class
,
996 &v10_0_backup_keybag_class
,
997 &v10_2_ckmanifest_class
,
998 &v10_2_pending_manifest_class
,
999 &v10_1_ckmanifest_leaf_class
,
1000 &v10_1_backup_keyarchive_class
,
1001 &v10_1_current_keyarchive_class
,
1002 &v10_1_current_archived_keys_class
,
1003 &v10_1_pending_manifest_leaf_class
,
1004 &v10_4_current_item_class
,
1005 &v11_1_ckdevicestate_class
,
1006 &v10_5_tlkshare_class
,
1007 &v11_2_metadatakeys_class
,
1015 const SecDbSchema v11_2_schema
= {
1023 &v10_0_tversion_class
,
1024 &v10_2_outgoing_queue_class
,
1025 &v10_2_incoming_queue_class
,
1026 &v10_0_sync_key_class
,
1027 &v10_1_ckmirror_class
,
1028 &v10_0_current_key_class
,
1029 &v10_4_ckstate_class
,
1030 &v10_0_item_backup_class
,
1031 &v10_0_backup_keybag_class
,
1032 &v10_2_ckmanifest_class
,
1033 &v10_2_pending_manifest_class
,
1034 &v10_1_ckmanifest_leaf_class
,
1035 &v10_1_backup_keyarchive_class
,
1036 &v10_1_current_keyarchive_class
,
1037 &v10_1_current_archived_keys_class
,
1038 &v10_1_pending_manifest_leaf_class
,
1039 &v10_4_current_item_class
,
1040 &v11_1_ckdevicestate_class
,
1041 &v10_5_tlkshare_class
,
1042 &v11_2_metadatakeys_class
,
1050 const SecDbSchema v11_1_schema
= {
1058 &v10_0_tversion_class
,
1059 &v10_2_outgoing_queue_class
,
1060 &v10_2_incoming_queue_class
,
1061 &v10_0_sync_key_class
,
1062 &v10_1_ckmirror_class
,
1063 &v10_0_current_key_class
,
1064 &v10_4_ckstate_class
,
1065 &v10_0_item_backup_class
,
1066 &v10_0_backup_keybag_class
,
1067 &v10_2_ckmanifest_class
,
1068 &v10_2_pending_manifest_class
,
1069 &v10_1_ckmanifest_leaf_class
,
1070 &v10_1_backup_keyarchive_class
,
1071 &v10_1_current_keyarchive_class
,
1072 &v10_1_current_archived_keys_class
,
1073 &v10_1_pending_manifest_leaf_class
,
1074 &v10_4_current_item_class
,
1075 &v11_1_ckdevicestate_class
,
1076 &v10_5_tlkshare_class
,
1077 &v11_metadatakeys_class
,
1085 const SecDbSchema v11_schema
= {
1093 &v10_0_tversion_class
,
1094 &v10_2_outgoing_queue_class
,
1095 &v10_2_incoming_queue_class
,
1096 &v10_0_sync_key_class
,
1097 &v10_1_ckmirror_class
,
1098 &v10_0_current_key_class
,
1099 &v10_4_ckstate_class
,
1100 &v10_0_item_backup_class
,
1101 &v10_0_backup_keybag_class
,
1102 &v10_2_ckmanifest_class
,
1103 &v10_2_pending_manifest_class
,
1104 &v10_1_ckmanifest_leaf_class
,
1105 &v10_1_backup_keyarchive_class
,
1106 &v10_1_current_keyarchive_class
,
1107 &v10_1_current_archived_keys_class
,
1108 &v10_1_pending_manifest_leaf_class
,
1109 &v10_4_current_item_class
,
1110 &v10_3_ckdevicestate_class
,
1111 &v10_5_tlkshare_class
,
1112 &v11_metadatakeys_class
,
1121 const SecDbSchema v10_5_schema
= {
1129 &v10_0_tversion_class
,
1130 &v10_2_outgoing_queue_class
,
1131 &v10_2_incoming_queue_class
,
1132 &v10_0_sync_key_class
,
1133 &v10_1_ckmirror_class
,
1134 &v10_0_current_key_class
,
1135 &v10_4_ckstate_class
,
1136 &v10_0_item_backup_class
,
1137 &v10_0_backup_keybag_class
,
1138 &v10_2_ckmanifest_class
,
1139 &v10_2_pending_manifest_class
,
1140 &v10_1_ckmanifest_leaf_class
,
1141 &v10_1_backup_keyarchive_class
,
1142 &v10_1_current_keyarchive_class
,
1143 &v10_1_current_archived_keys_class
,
1144 &v10_1_pending_manifest_leaf_class
,
1145 &v10_4_current_item_class
,
1146 &v10_3_ckdevicestate_class
,
1147 &v10_5_tlkshare_class
,
1155 const SecDbSchema v10_4_schema
= {
1163 &v10_0_tversion_class
,
1164 &v10_2_outgoing_queue_class
,
1165 &v10_2_incoming_queue_class
,
1166 &v10_0_sync_key_class
,
1167 &v10_1_ckmirror_class
,
1168 &v10_0_current_key_class
,
1169 &v10_4_ckstate_class
,
1170 &v10_0_item_backup_class
,
1171 &v10_0_backup_keybag_class
,
1172 &v10_2_ckmanifest_class
,
1173 &v10_2_pending_manifest_class
,
1174 &v10_1_ckmanifest_leaf_class
,
1175 &v10_1_backup_keyarchive_class
,
1176 &v10_1_current_keyarchive_class
,
1177 &v10_1_current_archived_keys_class
,
1178 &v10_1_pending_manifest_leaf_class
,
1179 &v10_4_current_item_class
,
1180 &v10_3_ckdevicestate_class
,
1188 const SecDbSchema v10_3_schema
= {
1196 &v10_0_tversion_class
,
1197 &v10_2_outgoing_queue_class
,
1198 &v10_2_incoming_queue_class
,
1199 &v10_0_sync_key_class
,
1200 &v10_1_ckmirror_class
,
1201 &v10_0_current_key_class
,
1202 &v10_0_ckstate_class
,
1203 &v10_0_item_backup_class
,
1204 &v10_0_backup_keybag_class
,
1205 &v10_2_ckmanifest_class
,
1206 &v10_2_pending_manifest_class
,
1207 &v10_1_ckmanifest_leaf_class
,
1208 &v10_1_backup_keyarchive_class
,
1209 &v10_1_current_keyarchive_class
,
1210 &v10_1_current_archived_keys_class
,
1211 &v10_1_pending_manifest_leaf_class
,
1212 &v10_1_current_item_class
,
1213 &v10_3_ckdevicestate_class
,
1221 const SecDbSchema v10_2_schema
= {
1229 &v10_0_tversion_class
,
1230 &v10_2_outgoing_queue_class
,
1231 &v10_2_incoming_queue_class
,
1232 &v10_0_sync_key_class
,
1233 &v10_1_ckmirror_class
,
1234 &v10_0_current_key_class
,
1235 &v10_0_ckstate_class
,
1236 &v10_0_item_backup_class
,
1237 &v10_0_backup_keybag_class
,
1238 &v10_2_ckmanifest_class
,
1239 &v10_2_pending_manifest_class
,
1240 &v10_1_ckmanifest_leaf_class
,
1241 &v10_1_backup_keyarchive_class
,
1242 &v10_1_current_keyarchive_class
,
1243 &v10_1_current_archived_keys_class
,
1244 &v10_1_pending_manifest_leaf_class
,
1245 &v10_1_current_item_class
,
1253 const SecDbSchema v10_1_schema
= {
1261 &v10_0_tversion_class
,
1262 &v10_1_outgoing_queue_class
,
1263 &v10_1_incoming_queue_class
,
1264 &v10_0_sync_key_class
,
1265 &v10_1_ckmirror_class
,
1266 &v10_0_current_key_class
,
1267 &v10_0_ckstate_class
,
1268 &v10_0_item_backup_class
,
1269 &v10_0_backup_keybag_class
,
1270 &v10_1_ckmanifest_class
,
1271 &v10_1_pending_manifest_class
,
1272 &v10_1_ckmanifest_leaf_class
,
1273 &v10_1_backup_keyarchive_class
,
1274 &v10_1_current_keyarchive_class
,
1275 &v10_1_current_archived_keys_class
,
1276 &v10_1_pending_manifest_leaf_class
,
1277 &v10_1_current_item_class
,
1286 const SecDbClass v10_0_genp_class
= {
1287 .name
= CFSTR("genp"),
1321 &v10itempersistentref
,
1327 const SecDbClass v10_0_inet_class
= {
1328 .name
= CFSTR("inet"),
1366 &v10itempersistentref
,
1372 const SecDbClass v10_0_cert_class
= {
1373 .name
= CFSTR("cert"),
1402 &v10itempersistentref
,
1408 const SecDbClass v10_0_keys_class
= {
1409 .name
= CFSTR("keys"),
1456 &v10itempersistentref
,
1462 const SecDbSchema v10_0_schema
= {
1470 &v10_0_tversion_class
,
1471 &v10_0_outgoing_queue_class
,
1472 &v10_0_incoming_queue_class
,
1473 &v10_0_sync_key_class
,
1474 &v10_0_ckmirror_class
,
1475 &v10_0_current_key_class
,
1476 &v10_0_ckstate_class
,
1477 &v10_0_item_backup_class
,
1478 &v10_0_backup_keybag_class
,
1483 const SecDbClass v9_1_tversion_class
= {
1484 .name
= CFSTR("tversion91"),
1494 const SecDbClass v9_1_genp_class
= {
1495 .name
= CFSTR("genp91"),
1532 const SecDbClass v9_1_inet_class
= {
1533 .name
= CFSTR("inet91"),
1574 const SecDbClass v9_1_cert_class
= {
1575 .name
= CFSTR("cert91"),
1607 const SecDbClass v9_1_keys_class
= {
1608 .name
= CFSTR("keys91"),
1659 * Version 9.1 (iOS 10.0 and OSX 10.11.8/10.12 addded minor version.
1661 const SecDbSchema v9_1_schema
= {
1669 &v9_1_tversion_class
,
1674 const SecDbClass v9genp_class
= {
1675 .name
= CFSTR("genp9"),
1712 const SecDbClass v9inet_class
= {
1713 .name
= CFSTR("inet9"),
1754 const SecDbClass v9cert_class
= {
1755 .name
= CFSTR("cert9"),
1787 const SecDbClass v9keys_class
= {
1788 .name
= CFSTR("keys9"),
1838 const SecDbClass v5tversion_class
= {
1839 .name
= CFSTR("tversion5"),
1847 /* Version 9 (iOS 9.3 and OSX 10.11.5) database schema
1848 * Same contents as v8 tables; table names changed to force upgrade
1849 * and correct default values in table.
1851 const SecDbSchema v9_schema
= {
1863 // Version 8 (Internal release iOS 9.3 and OSX 10.11.5) database schema
1864 const SecDbClass v8genp_class
= {
1865 .name
= CFSTR("genp8"),
1902 const SecDbClass v8inet_class
= {
1903 .name
= CFSTR("inet8"),
1944 const SecDbClass v8cert_class
= {
1945 .name
= CFSTR("cert8"),
1977 const SecDbClass v8keys_class
= {
1978 .name
= CFSTR("keys8"),
2028 const SecDbSchema v8_schema
= {
2040 // Version 7 (iOS 9 and OSX 10.11) database schema
2041 const SecDbClass v7genp_class
= {
2042 .name
= CFSTR("genp7"),
2078 const SecDbClass v7inet_class
= {
2079 .name
= CFSTR("inet7"),
2119 const SecDbClass v7cert_class
= {
2120 .name
= CFSTR("cert7"),
2151 const SecDbClass v7keys_class
= {
2152 .name
= CFSTR("keys7"),
2202 const SecDbSchema v7_schema
= {
2215 // Version 6 (iOS 7 and OSX 10.9) database schema
2216 static const SecDbClass v6genp_class
= {
2217 .name
= CFSTR("genp6"),
2250 static const SecDbClass v6inet_class
= {
2251 .name
= CFSTR("inet6"),
2288 static const SecDbClass v6cert_class
= {
2289 .name
= CFSTR("cert6"),
2317 static const SecDbClass v6keys_class
= {
2318 .name
= CFSTR("keys6"),
2364 static const SecDbSchema v6_schema
= {
2377 // Version 5 (iOS 5 & iOS 6) database schema.
2378 static const SecDbClass v5genp_class
= {
2379 .name
= CFSTR("genp5"),
2407 static const SecDbClass v5inet_class
= {
2408 .name
= CFSTR("inet5"),
2440 static const SecDbClass v5cert_class
= {
2441 .name
= CFSTR("cert5"),
2464 static const SecDbClass v5keys_class
= {
2465 .name
= CFSTR("keys5"),
2506 static const SecDbSchema v5_schema
= {
2518 SecDbSchema
const * const * kc_schemas
= NULL
;
2520 const SecDbSchema
*v10_kc_schemas
[] = {
2541 const SecDbSchema
* const * all_schemas() {
2542 return v10_kc_schemas
;
2545 const SecDbSchema
* current_schema() {
2546 // For now, the current schema is the first in the list.
2547 return all_schemas()[0];
2550 // class accessors for current schema.
2551 static const SecDbClass
* find_class(const SecDbSchema
* schema
, CFStringRef class_name
) {
2552 for (const SecDbClass
* const *pclass
= schema
->classes
; *pclass
; ++pclass
) {
2553 if( CFEqualSafe((*pclass
)->name
, class_name
) ) {
2560 const SecDbClass
* genp_class() {
2561 static const SecDbClass
* genp
= NULL
;
2562 static dispatch_once_t onceToken
;
2563 dispatch_once(&onceToken
, ^{
2564 genp
= find_class(current_schema(), CFSTR("genp"));
2568 const SecDbClass
* inet_class() {
2569 static const SecDbClass
* inet
= NULL
;
2570 static dispatch_once_t onceToken
;
2571 dispatch_once(&onceToken
, ^{
2572 inet
= find_class(current_schema(), CFSTR("inet"));
2576 const SecDbClass
* cert_class() {
2577 static const SecDbClass
* cert
= NULL
;
2578 static dispatch_once_t onceToken
;
2579 dispatch_once(&onceToken
, ^{
2580 cert
= find_class(current_schema(), CFSTR("cert"));
2584 const SecDbClass
* keys_class() {
2585 static const SecDbClass
* keys
= NULL
;
2586 static dispatch_once_t onceToken
;
2587 dispatch_once(&onceToken
, ^{
2588 keys
= find_class(current_schema(), CFSTR("keys"));
2593 // Not really a class per-se
2594 const SecDbClass
* identity_class() {
2595 return &v_identity_class
;
2598 // Class with 1 element in it which is the database version->
2599 const SecDbClass
* tversion_class() {
2600 static const SecDbClass
* tversion
= NULL
;
2601 static dispatch_once_t onceToken
;
2602 dispatch_once(&onceToken
, ^{
2603 tversion
= find_class(current_schema(), CFSTR("tversion"));