]> git.saurik.com Git - apple/security.git/blob - OSX/sec/SOSCircle/SecureObjectSync/SOSRingTypes.h
cb9e46d32bd5359e17d268bff89f3fc6e64f113c
[apple/security.git] / OSX / sec / SOSCircle / SecureObjectSync / SOSRingTypes.h
1 /*
2 * Copyright (c) 2015-2016 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 //
25 // SOSRingTypes.h
26 //
27
28 #ifndef _sec_SOSRingTypes_
29 #define _sec_SOSRingTypes_
30
31
32 #include <CoreFoundation/CFRuntime.h>
33 #include <CoreFoundation/CoreFoundation.h>
34 #include <Security/SecureObjectSync/SOSAccount.h>
35 #include <Security/SecureObjectSync/SOSRingUtils.h>
36
37 typedef struct ringfuncs_t {
38 char *typeName;
39 int version;
40 SOSRingRef (*sosRingCreate)(CFStringRef name, CFStringRef myPeerID, CFErrorRef *error);
41 bool (*sosRingResetToEmpty)(SOSRingRef ring, CFStringRef myPeerID, CFErrorRef *error);
42 bool (*sosRingResetToOffering)(SOSRingRef ring, SecKeyRef user_privkey, SOSFullPeerInfoRef requestor, CFErrorRef *error);
43 SOSRingStatus (*sosRingDeviceIsInRing)(SOSRingRef ring, CFStringRef peerID);
44 bool (*sosRingApply)(SOSRingRef ring, SecKeyRef user_pubkey, SOSFullPeerInfoRef requestor, CFErrorRef *error);
45 bool (*sosRingWithdraw)(SOSRingRef ring, SecKeyRef user_privkey, SOSFullPeerInfoRef requestor, CFErrorRef *error);
46 bool (*sosRingGenerationSign)(SOSRingRef ring, SecKeyRef user_privkey, SOSFullPeerInfoRef requestor, CFErrorRef *error);
47 bool (*sosRingConcordanceSign)(SOSRingRef ring, SOSFullPeerInfoRef requestor, CFErrorRef *error);
48 SOSConcordanceStatus (*sosRingConcordanceTrust)(SOSFullPeerInfoRef me, CFSetRef peers,
49 SOSRingRef knownRing, SOSRingRef proposedRing,
50 SecKeyRef knownPubkey, SecKeyRef userPubkey,
51 CFStringRef excludePeerID, CFErrorRef *error);
52 bool (*sosRingAccept)(SOSRingRef ring, SecKeyRef user_privkey, SOSFullPeerInfoRef requestor, CFErrorRef *error);
53 bool (*sosRingReject)(SOSRingRef ring, SecKeyRef user_privkey, SOSFullPeerInfoRef requestor, CFErrorRef *error);
54 bool (*sosRingSetPayload)(SOSRingRef ring, SecKeyRef user_privkey, CFDataRef payload, SOSFullPeerInfoRef requestor, CFErrorRef *error);
55 CFDataRef (*sosRingGetPayload)(SOSRingRef ring, CFErrorRef *error);
56 } ringFuncStruct, *ringFuncs;
57
58 // ViewRequirements
59 bool SOSRingRequirementKnown(SOSAccountRef account, CFStringRef name, CFErrorRef *error);
60 bool SOSRingRequirementCreate(SOSAccountRef account, CFStringRef name, SOSRingType type, CFErrorRef *error);
61
62 // Admins
63 bool SOSRingRequirementResetToOffering(SOSAccountRef account, CFStringRef name, CFErrorRef* error);
64 bool SOSRingRequirementResetToEmpty(SOSAccountRef account, CFStringRef name, CFErrorRef* error);
65
66 // Clients
67 bool SOSRingRequirementRequestToJoin(SOSAccountRef account, CFStringRef name, CFErrorRef* error);
68 bool SOSRingRequirementRemoveThisDevice(SOSAccountRef account, CFStringRef name, CFErrorRef* error);
69
70 // Approvers
71 CFArrayRef SOSRingRequirementGetApplicants(SOSAccountRef account, CFStringRef name, CFErrorRef* error);
72 bool SOSRingRequirementAcceptApplicants(SOSAccountRef account, CFStringRef name, CFArrayRef applicants, CFErrorRef* error);
73 bool SOSRingRequirementRejectApplicants(SOSAccountRef account, CFStringRef name, CFArrayRef applicants, CFErrorRef *error);
74
75 static inline SOSRingRef SOSRingCreate_ForType(CFStringRef name, SOSRingType type, CFStringRef myPeerID, CFErrorRef *error) {
76 SOSRingRef retval = NULL;
77 retval = SOSRingCreate_Internal(name, type, error);
78 if(!retval) return NULL;
79 SOSRingSetLastModifier(retval, myPeerID);
80 return retval;
81 }
82
83 #endif /* defined(_sec_SOSRingTypes_) */