]> git.saurik.com Git - apple/security.git/blob - OSX/sec/securityd/SecItemDb.h
Security-58286.41.2.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 //
64 // MARK: backup restore stuff
65 //
66
67 /* Forward declaration of import export SPIs. */
68 enum SecItemFilter {
69 kSecNoItemFilter,
70 kSecSysBoundItemFilter,
71 kSecBackupableItemFilter,
72 };
73
74 CFDictionaryRef SecServerCopyKeychainPlist(SecDbConnectionRef dbt,
75 struct SecurityClient *client,
76 keybag_handle_t src_keybag,
77 keybag_handle_t dest_keybag,
78 enum SecItemFilter filter,
79 CFErrorRef *error);
80 bool SecServerImportKeychainInPlist(SecDbConnectionRef dbt,
81 struct SecurityClient *client,
82 keybag_handle_t src_keybag,
83 keybag_handle_t dest_keybag,
84 CFDictionaryRef keychain,
85 enum SecItemFilter filter,
86 CFErrorRef *error);
87
88 CFStringRef
89 SecServerBackupGetKeybagUUID(CFDictionaryRef keychain, CFErrorRef *error);
90
91
92 #if TARGET_OS_IPHONE
93 bool SecServerDeleteAllForUser(SecDbConnectionRef dbt, CFDataRef musrView, bool keepU, CFErrorRef *error);
94 #endif
95
96 bool kc_transaction(SecDbConnectionRef dbt, CFErrorRef *error, bool(^perform)());
97 bool kc_transaction_type(SecDbConnectionRef dbt, SecDbTransactionType type, CFErrorRef *error, bool(^perform)());
98 bool s3dl_copy_matching(SecDbConnectionRef dbt, Query *q, CFTypeRef *result,
99 CFArrayRef accessGroups, CFErrorRef *error);
100 bool s3dl_query_add(SecDbConnectionRef dbt, Query *q, CFTypeRef *result, CFErrorRef *error);
101 bool s3dl_query_update(SecDbConnectionRef dbt, Query *q,
102 CFDictionaryRef attributesToUpdate, CFArrayRef accessGroups, CFErrorRef *error);
103 bool s3dl_query_delete(SecDbConnectionRef dbt, Query *q, CFArrayRef accessGroups, CFErrorRef *error);
104 bool s3dl_copy_digest(SecDbConnectionRef dbt, Query *q, CFArrayRef *result, CFArrayRef accessGroups, CFErrorRef *error);
105
106 const SecDbAttr *SecDbAttrWithKey(const SecDbClass *c, CFTypeRef key, CFErrorRef *error);
107
108 bool s3dl_dbt_keys_current(SecDbConnectionRef dbt, uint32_t current_generation, CFErrorRef *error);
109 bool s3dl_dbt_update_keys(SecDbConnectionRef dbt, struct SecurityClient *client, CFErrorRef *error);
110
111 // We'd love to take a query here, but switching layers at the callsite means we don't have it
112 bool s3dl_item_make_new_uuid(SecDbItemRef item, bool uuid_from_primary_key, CFErrorRef* error);
113
114 __END_DECLS
115
116 #endif /* _SECURITYD_SECITEMDB_H_ */