]> git.saurik.com Git - apple/security.git/blob - OSX/sec/SOSCircle/SecureObjectSync/SOSRing.h
Security-58286.60.28.tar.gz
[apple/security.git] / OSX / sec / SOSCircle / SecureObjectSync / SOSRing.h
1 //
2 // SOSRing.h
3 // sec
4 //
5 // Created by Richard Murphy on 3/3/15.
6 //
7 //
8
9 #ifndef _sec_SOSRing_
10 #define _sec_SOSRing_
11
12 #include <CoreFoundation/CoreFoundation.h>
13 #include <Security/SecureObjectSync/SOSCloudCircle.h>
14 #include <Security/SecureObjectSync/SOSGenCount.h>
15 #include <Security/SecureObjectSync/SOSFullPeerInfo.h>
16 #include <Security/SecureObjectSync/SOSConcordanceTrust.h>
17 #include <Security/SecureObjectSync/SOSBackupSliceKeyBag.h>
18 #include <Security/SecKey.h>
19
20 typedef struct __OpaqueSOSRing *SOSRingRef;
21
22 enum {
23 kSOSRingMember = 0,
24 kSOSRingNotInRing = 1,
25 kSOSRingApplicant = 2,
26 kSOSRingReject = 3,
27 kSOSRingRetired = 4,
28 kSOSRingError = 99,
29 };
30 typedef int SOSRingStatus;
31
32 enum {
33 kSOSRingBase = 0,
34 kSOSRingBackup = 1,
35 kSOSRingPeerKeyed = 2,
36 kSOSRingEntropyKeyed = 3,
37 kSOSRingPKKeyed = 4,
38 kSOSRingRecovery = 5,
39 kSOSRingTypeCount = 6,
40 kSOSRingTypeError = 0xfbad,
41 };
42 typedef uint32_t SOSRingType;
43
44 CFTypeID SOSRingGetTypeID(void);
45
46 SOSRingRef SOSRingCreate(CFStringRef name, CFStringRef myPeerID, SOSRingType type, CFErrorRef *error);
47 bool SOSRingResetToEmpty(SOSRingRef ring, CFStringRef myPeerID, CFErrorRef *error);
48 bool SOSRingResetToOffering(SOSRingRef ring, __unused SecKeyRef user_privkey, SOSFullPeerInfoRef requestor, CFErrorRef *error);
49 SOSRingStatus SOSRingDeviceIsInRing(SOSRingRef ring, CFStringRef peerID);
50 bool SOSRingApply(SOSRingRef ring, SecKeyRef user_pubkey, SOSFullPeerInfoRef requestor, CFErrorRef *error);
51 bool SOSRingWithdraw(SOSRingRef ring, SecKeyRef user_privkey, SOSFullPeerInfoRef requestor, CFErrorRef *error);
52 bool SOSRingGenerationSign(SOSRingRef ring, SecKeyRef user_privkey, SOSFullPeerInfoRef requestor, CFErrorRef *error);
53 bool SOSRingConcordanceSign(SOSRingRef ring, SOSFullPeerInfoRef requestor, CFErrorRef *error);
54 SOSConcordanceStatus SOSRingConcordanceTrust(SOSFullPeerInfoRef me, CFSetRef peers,
55 SOSRingRef knownRing, SOSRingRef proposedRing,
56 SecKeyRef knownPubkey, SecKeyRef userPubkey,
57 CFStringRef excludePeerID, CFErrorRef *error);
58 bool SOSRingAccept(SOSRingRef ring, SecKeyRef user_privkey, SOSFullPeerInfoRef requestor, CFErrorRef *error);
59 bool SOSRingReject(SOSRingRef ring, SecKeyRef user_privkey, SOSFullPeerInfoRef requestor, CFErrorRef *error);
60 bool SOSRingSetPayload(SOSRingRef ring, SecKeyRef user_privkey, CFDataRef payload, SOSFullPeerInfoRef requestor, CFErrorRef *error);
61 CFDataRef SOSRingGetPayload(SOSRingRef ring, CFErrorRef *error);
62 CFSetRef SOSRingGetBackupViewset(SOSRingRef ring, CFErrorRef *error);
63
64 bool SOSRingSetBackupKeyBag(SOSRingRef ring, SOSFullPeerInfoRef fpi, CFSetRef viewSet, SOSBackupSliceKeyBagRef bskb, CFErrorRef *error);
65
66 SOSBackupSliceKeyBagRef SOSRingCopyBackupSliceKeyBag(SOSRingRef ring, CFErrorRef *error);
67
68 bool SOSRingPeerTrusted(SOSRingRef ring, SOSFullPeerInfoRef requestor, CFErrorRef *error);
69 bool SOSRingPKTrusted(SOSRingRef ring, SecKeyRef pubkey, CFErrorRef *error);
70
71 CFDataRef SOSRingCopyEncodedData(SOSRingRef ring, CFErrorRef *error);
72 SOSRingRef SOSRingCreateFromData(CFErrorRef* error, CFDataRef ring_data);
73
74 CFStringRef SOSRingGetName(SOSRingRef ring);
75 uint32_t SOSRingGetType(SOSRingRef ring);
76 SOSGenCountRef SOSRingGetGeneration(SOSRingRef ring);
77 uint32_t SOSRingGetVersion(SOSRingRef ring);
78 CFStringRef SOSRingGetIdentifier(SOSRingRef ring);
79 CFStringRef SOSRingGetLastModifier(SOSRingRef ring);
80
81 CFMutableSetRef SOSRingGetApplicants(SOSRingRef ring);
82
83 static inline bool isSOSRing(CFTypeRef object) {
84 return object && (CFGetTypeID(object) == SOSRingGetTypeID());
85 }
86
87 bool SOSBackupRingSetViews(SOSRingRef ring, SOSFullPeerInfoRef requestor, CFSetRef viewSet, CFErrorRef *error);
88 CFSetRef SOSBackupRingGetViews(SOSRingRef ring, CFErrorRef *error);
89
90 #endif /* defined(_sec_SOSRing_) */