]> git.saurik.com Git - apple/security.git/blob - keychain/SecureObjectSync/SOSAccountCircles.m
Security-59306.11.20.tar.gz
[apple/security.git] / keychain / SecureObjectSync / SOSAccountCircles.m
1 //
2 // SOSAccountCircles.c
3 // sec
4 //
5
6 #include "keychain/SecureObjectSync/SOSAccountPriv.h"
7 #import "keychain/SecureObjectSync/SOSTransport.h"
8 #import "keychain/SecureObjectSync/SOSTransportKeyParameter.h"
9 #import "keychain/SecureObjectSync/SOSTransportMessageKVS.h"
10 #import "keychain/SecureObjectSync/SOSTransportCircleKVS.h"
11 #import "keychain/SecureObjectSync/SOSTransportCircleCK.h"
12 #import "keychain/SecureObjectSync/SOSAccountTrust.h"
13 #import "keychain/SecureObjectSync/SOSAccountTrustClassic.h"
14
15 #include "keychain/SecureObjectSync/SOSPeerInfoCollections.h"
16 #include "SOSCloudKeychainClient.h"
17
18 //
19 // MARK: Circle management
20 //
21
22
23 SOSCircleRef CF_RETURNS_RETAINED SOSAccountEnsureCircle(SOSAccount* a, CFStringRef name, CFErrorRef *error)
24 {
25 CFErrorRef localError = NULL;
26 SOSAccountTrustClassic *trust = a.trust;
27 SOSCircleRef circle = trust.trustedCircle;
28
29 if (circle == NULL) {
30 circle = SOSCircleCreate(NULL, name, NULL);
31 a.key_interests_need_updating = true;
32 [trust setTrustedCircle:circle];
33 } else {
34 CFRetainSafe(circle);
35 }
36
37 require_action_quiet(circle || !isSOSErrorCoded(localError, kSOSErrorIncompatibleCircle), fail,
38 if (error) { *error = localError; localError = NULL; });
39
40 fail:
41 CFReleaseNull(localError);
42 return circle;
43 }
44