]> git.saurik.com Git - apple/security.git/blob - OSX/sec/securityd/SecItemDb.h
Security-59306.11.20.tar.gz
[apple/security.git] / OSX / sec / securityd / SecItemDb.h
1 /*
2 * Copyright (c) 2013-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 @header SecItemDb.h - A Database full of SecDbItems.
26 */
27
28 #ifndef _SECURITYD_SECITEMDB_H_
29 #define _SECURITYD_SECITEMDB_H_
30
31 #include <securityd/SecDbQuery.h>
32
33 struct SecurityClient;
34
35 __BEGIN_DECLS
36
37 bool SecItemDbCreateSchema(SecDbConnectionRef dbt, const SecDbSchema *schema, CFArrayRef classIndexesForNewTables, bool includeVersion, CFErrorRef *error);
38
39 bool SecItemDbDeleteSchema(SecDbConnectionRef dbt, const SecDbSchema *schema, CFErrorRef *error);
40
41 CFTypeRef SecDbItemCopyResult(SecDbItemRef item, ReturnTypeMask return_type, CFErrorRef *error);
42
43 bool SecDbItemSelect(SecDbQueryRef query, SecDbConnectionRef dbconn, CFErrorRef *error,
44 bool (^return_attr)(const SecDbAttr *attr),
45 bool (^use_attr_in_where)(const SecDbAttr *attr),
46 bool (^add_where_sql)(CFMutableStringRef sql, bool *needWhere),
47 bool (^bind_added_where)(sqlite3_stmt *stmt, int col),
48 void (^handle_row)(SecDbItemRef item, bool *stop));
49
50 CFStringRef SecDbItemCopySelectSQL(SecDbQueryRef query,
51 bool (^return_attr)(const SecDbAttr *attr),
52 bool (^use_attr_in_where)(const SecDbAttr *attr),
53 bool (^add_where_sql)(CFMutableStringRef sql, bool *needWhere));
54 bool SecDbItemSelectBind(SecDbQueryRef query, sqlite3_stmt *stmt, CFErrorRef *error,
55 bool (^use_attr_in_where)(const SecDbAttr *attr),
56 bool (^bind_added_where)(sqlite3_stmt *stmt, int col));
57
58 bool SecDbItemQuery(SecDbQueryRef query, CFArrayRef accessGroups, SecDbConnectionRef dbconn, CFErrorRef *error,
59 void (^handle_row)(SecDbItemRef item, bool *stop));
60
61 void query_pre_add(Query *q, bool force_date);
62
63 bool SecItemIsSystemBound(CFDictionaryRef item, const SecDbClass *cls, bool multiUser);
64
65 //
66 // MARK: backup restore stuff
67 //
68
69 /* Forward declaration of import export SPIs. */
70 enum SecItemFilter {
71 kSecNoItemFilter,
72 kSecSysBoundItemFilter,
73 kSecBackupableItemFilter,
74 };
75
76 CFDictionaryRef SecServerCopyKeychainPlist(SecDbConnectionRef dbt,
77 struct SecurityClient *client,
78 keybag_handle_t src_keybag,
79 keybag_handle_t dest_keybag,
80 enum SecItemFilter filter,
81 CFErrorRef *error);
82 bool SecServerImportKeychainInPlist(SecDbConnectionRef dbt,
83 struct SecurityClient *client,
84 keybag_handle_t src_keybag,
85 keybag_handle_t dest_keybag,
86 CFDictionaryRef keychain,
87 enum SecItemFilter filter,
88 bool removeKeychainContent,
89 CFErrorRef *error);
90
91 CFStringRef
92 SecServerBackupGetKeybagUUID(CFDictionaryRef keychain, CFErrorRef *error);
93
94
95 #if TARGET_OS_IPHONE
96 bool SecServerDeleteAllForUser(SecDbConnectionRef dbt, CFDataRef musrView, bool keepU, CFErrorRef *error);
97 #endif
98
99 bool kc_transaction(SecDbConnectionRef dbt, CFErrorRef *error, bool(^perform)(void));
100 bool kc_transaction_type(SecDbConnectionRef dbt, SecDbTransactionType type, CFErrorRef *error, bool(^perform)(void));
101 bool s3dl_copy_matching(SecDbConnectionRef dbt, Query *q, CFTypeRef *result,
102 CFArrayRef accessGroups, CFErrorRef *error);
103 bool s3dl_query_add(SecDbConnectionRef dbt, Query *q, CFTypeRef *result, CFErrorRef *error);
104 bool s3dl_query_update(SecDbConnectionRef dbt, Query *q,
105 CFDictionaryRef attributesToUpdate, CFArrayRef accessGroups, CFErrorRef *error);
106 bool s3dl_query_delete(SecDbConnectionRef dbt, Query *q, CFArrayRef accessGroups, CFErrorRef *error);
107 bool s3dl_copy_digest(SecDbConnectionRef dbt, Query *q, CFArrayRef *result, CFArrayRef accessGroups, CFErrorRef *error);
108
109 const SecDbAttr *SecDbAttrWithKey(const SecDbClass *c, CFTypeRef key, CFErrorRef *error);
110
111 bool s3dl_dbt_keys_current(SecDbConnectionRef dbt, uint32_t current_generation, CFErrorRef *error);
112 bool s3dl_dbt_update_keys(SecDbConnectionRef dbt, struct SecurityClient *client, CFErrorRef *error);
113
114 // We'd love to take a query here, but switching layers at the callsite means we don't have it
115 bool s3dl_item_make_new_uuid(SecDbItemRef item, bool uuid_from_primary_key, CFErrorRef* error);
116
117 __END_DECLS
118
119 #endif /* _SECURITYD_SECITEMDB_H_ */