]> git.saurik.com Git - apple/security.git/blob - OSX/sec/SOSCircle/SecureObjectSync/SOSAccountRingUpdate.m
Security-58286.41.2.tar.gz
[apple/security.git] / OSX / sec / SOSCircle / SecureObjectSync / SOSAccountRingUpdate.m
1 //
2 // SOSAccountRingUpdate.c
3 // sec
4 //
5 //
6
7 #include <stdio.h>
8
9 #include "SOSAccountPriv.h"
10 #include <Security/SecureObjectSync/SOSTransportCircleKVS.h>
11 #include <Security/SecureObjectSync/SOSTransport.h>
12 #include <Security/SecureObjectSync/SOSViews.h>
13 #include <Security/SecureObjectSync/SOSRing.h>
14 #include <Security/SecureObjectSync/SOSRingUtils.h>
15 #include <Security/SecureObjectSync/SOSPeerInfoCollections.h>
16 #import <Security/SecureObjectSync/SOSAccountTrust.h>
17
18 static const char * __unused concordstring[] = {
19 "kSOSConcordanceTrusted",
20 "kSOSConcordanceGenOld", // kSOSErrorReplay
21 "kSOSConcordanceNoUserSig", // kSOSErrorBadSignature
22 "kSOSConcordanceNoUserKey", // kSOSErrorNoKey
23 "kSOSConcordanceNoPeer", // kSOSErrorPeerNotFound
24 "kSOSConcordanceBadUserSig", // kSOSErrorBadSignature
25 "kSOSConcordanceBadPeerSig", // kSOSErrorBadSignature
26 "kSOSConcordanceNoPeerSig",
27 "kSOSConcordanceWeSigned",
28 "kSOSConcordanceInvalidMembership",
29 "kSOSConcordanceMissingMe",
30 "kSOSConcordanceImNotWorthy",
31 };
32
33
34 bool SOSAccountIsPeerRetired(SOSAccount* account, CFSetRef peers){
35 CFMutableArrayRef peerInfos = CFArrayCreateMutableForCFTypes(kCFAllocatorDefault);
36 bool result = false;
37
38 CFSetForEach(peers, ^(const void *value) {
39 SOSPeerInfoRef peer = (SOSPeerInfoRef)value;
40 if(SOSPeerInfoIsRetirementTicket(peer))
41 CFArrayAppendValue(peerInfos, peer);
42 });
43 if(CFArrayGetCount(peerInfos) > 0){
44 if(!SOSAccountRemoveBackupPeers(account, peerInfos, NULL))
45 secerror("Could not remove peers: %@, from the backup", peerInfos);
46 else
47 return true;
48 }
49 else
50 result = true;
51
52 CFReleaseNull(peerInfos);
53
54 return result;
55 }