]> git.saurik.com Git - apple/security.git/blob - KVSKeychainSyncingProxy/CKDSecuritydAccount.m
Security-58286.1.32.tar.gz
[apple/security.git] / KVSKeychainSyncingProxy / CKDSecuritydAccount.m
1 //
2 // CKDSecuritydAccount+CKDSecuritydAccount_m.m
3 // Security
4 //
5 //
6
7 #import "Foundation/Foundation.h"
8 #import "CKDSecuritydAccount.h"
9
10 #include <Security/SecureObjectSync/SOSCloudCircleInternal.h>
11 #include <Security/SecItemPriv.h>
12
13 @implementation CKDSecuritydAccount
14
15 + (instancetype) securitydAccount
16 {
17 return [[CKDSecuritydAccount alloc] init];
18 }
19
20 - (NSSet*) keysChanged: (NSDictionary<NSString*, NSObject*>*)keyValues error: (NSError**) error
21 {
22 CFErrorRef cf_error = NULL;
23 NSArray* handled = (__bridge_transfer NSArray*) _SecKeychainSyncUpdateMessage((__bridge CFDictionaryRef)keyValues, &cf_error);
24 NSError *updateError = (__bridge_transfer NSError*)cf_error;
25 if (error)
26 *error = updateError;
27
28 return [NSSet setWithArray:handled];
29 }
30
31 - (bool) ensurePeerRegistration: (NSError**) error
32 {
33 CFErrorRef localError = NULL;
34 bool result = SOSCCProcessEnsurePeerRegistration(error ? &localError : NULL);
35
36 if (error && localError) {
37 *error = (__bridge_transfer NSError*) localError;
38 }
39
40 return result;
41 }
42
43 - (NSSet<NSString*>*) syncWithPeers: (NSSet<NSString*>*) peerIDs backups: (NSSet<NSString*>*) backupPeerIDs error: (NSError**) error
44 {
45 CFErrorRef localError = NULL;
46 CFSetRef handledPeers = SOSCCProcessSyncWithPeers((__bridge CFSetRef) peerIDs, (__bridge CFSetRef) backupPeerIDs, &localError);
47
48 if (error && localError) {
49 *error = (__bridge_transfer NSError*) localError;
50 }
51
52 return (__bridge_transfer NSSet<NSString*>*) handledPeers;
53 }
54
55 - (SyncWithAllPeersReason) syncWithAllPeers: (NSError**) error
56 {
57 CFErrorRef localError = NULL;
58 SyncWithAllPeersReason result = SOSCCProcessSyncWithAllPeers(error ? &localError : NULL);
59
60 if (error && localError) {
61 *error = (__bridge_transfer NSError*) localError;
62 }
63
64 return result;
65 }
66
67 @end