5 // Created by Richard Murphy on 3/3/15.
12 #include <CoreFoundation/CoreFoundation.h>
13 #include <Security/SecureObjectSync/SOSCloudCircle.h>
14 #include "keychain/SecureObjectSync/SOSGenCount.h"
15 #include "keychain/SecureObjectSync/SOSFullPeerInfo.h"
16 #include "keychain/SecureObjectSync/SOSConcordanceTrust.h"
17 #include <Security/SecureObjectSync/SOSBackupSliceKeyBag.h>
18 #include <Security/SecKey.h>
20 typedef struct __OpaqueSOSRing
*SOSRingRef
;
24 kSOSRingNotInRing
= 1,
25 kSOSRingApplicant
= 2,
30 typedef int SOSRingStatus
;
35 kSOSRingPeerKeyed
= 2,
36 kSOSRingEntropyKeyed
= 3,
39 kSOSRingTypeCount
= 6,
40 kSOSRingTypeError
= 0xfbad,
42 typedef uint32_t SOSRingType
;
44 CFTypeID
SOSRingGetTypeID(void);
46 SOSRingRef
SOSRingCreate(CFStringRef name
, CFStringRef myPeerID
, SOSRingType type
, CFErrorRef
*error
);
47 bool SOSRingResetToEmpty(SOSRingRef ring
, CFStringRef myPeerID
, CFErrorRef
*error
);
48 bool SOSRingGenerationSign(SOSRingRef ring
, SecKeyRef user_privkey
, SOSFullPeerInfoRef requestor
, CFErrorRef
*error
);
49 bool SOSRingConcordanceSign(SOSRingRef ring
, SOSFullPeerInfoRef requestor
, CFErrorRef
*error
);
50 SOSConcordanceStatus
SOSRingConcordanceTrust(SOSFullPeerInfoRef me
, CFSetRef peers
,
51 SOSRingRef knownRing
, SOSRingRef proposedRing
,
52 SecKeyRef knownPubkey
, SecKeyRef userPubkey
,
53 CFStringRef excludePeerID
, CFErrorRef
*error
);
54 bool SOSRingAccept(SOSRingRef ring
, SecKeyRef user_privkey
, SOSFullPeerInfoRef requestor
, CFErrorRef
*error
);
55 bool SOSRingReject(SOSRingRef ring
, SecKeyRef user_privkey
, SOSFullPeerInfoRef requestor
, CFErrorRef
*error
);
56 bool SOSRingSetPayload(SOSRingRef ring
, SecKeyRef user_privkey
, CFDataRef payload
, SOSFullPeerInfoRef requestor
, CFErrorRef
*error
);
57 CFDataRef
SOSRingGetPayload(SOSRingRef ring
, CFErrorRef
*error
);
58 CFSetRef
SOSRingGetBackupViewset(SOSRingRef ring
, CFErrorRef
*error
);
59 CFStringRef
SOSRingGetBackupView(SOSRingRef ring
, CFErrorRef
*error
);
61 bool SOSRingSetBackupKeyBag(SOSRingRef ring
, SOSFullPeerInfoRef fpi
, CFSetRef viewSet
, SOSBackupSliceKeyBagRef bskb
, CFErrorRef
*error
);
63 SOSBackupSliceKeyBagRef
SOSRingCopyBackupSliceKeyBag(SOSRingRef ring
, CFErrorRef
*error
);
65 bool SOSRingPeerTrusted(SOSRingRef ring
, SOSFullPeerInfoRef requestor
, CFErrorRef
*error
);
66 bool SOSRingPKTrusted(SOSRingRef ring
, SecKeyRef pubkey
, CFErrorRef
*error
);
68 CFDataRef
SOSRingCopyEncodedData(SOSRingRef ring
, CFErrorRef
*error
);
69 SOSRingRef
SOSRingCreateFromData(CFErrorRef
* error
, CFDataRef ring_data
);
71 CFStringRef
SOSRingGetName(SOSRingRef ring
);
72 uint32_t SOSRingGetType(SOSRingRef ring
);
73 SOSGenCountRef
SOSRingGetGeneration(SOSRingRef ring
);
74 uint32_t SOSRingGetVersion(SOSRingRef ring
);
75 CFStringRef
SOSRingGetIdentifier(SOSRingRef ring
);
76 CFStringRef
SOSRingGetLastModifier(SOSRingRef ring
);
78 CFMutableSetRef
SOSRingGetApplicants(SOSRingRef ring
);
80 static inline bool isSOSRing(CFTypeRef object
) {
81 return object
&& (CFGetTypeID(object
) == SOSRingGetTypeID());
84 bool SOSBackupRingSetViews(SOSRingRef ring
, SOSFullPeerInfoRef requestor
, CFSetRef viewSet
, CFErrorRef
*error
);
85 CFSetRef
SOSBackupRingGetViews(SOSRingRef ring
, CFErrorRef
*error
);
87 #endif /* defined(_sec_SOSRing_) */