2 * Copyright (c) 2012-2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
27 The functions provided in SOSCircle.h provide an interface to a
28 secure object syncing circle for a single class
34 #include <Security/Security.h>
35 #include <SecureObjectSync/SOSFullPeerInfo.h>
36 #include <SecureObjectSync/SOSPeerInfo.h>
37 #include <SecureObjectSync/SOSPeer.h>
41 typedef struct __OpaqueSOSCircle
*SOSCircleRef
;
43 CFTypeID
SOSCircleGetTypeID();
45 SOSCircleRef
SOSCircleCreate(CFAllocatorRef allocator
, CFStringRef circleName
, CFErrorRef
*error
);
46 SOSCircleRef
SOSCircleCreateFromDER(CFAllocatorRef allocator
, CFErrorRef
* error
,
47 const uint8_t** der_p
, const uint8_t *der_end
);
48 SOSCircleRef
SOSCircleCreateFromData(CFAllocatorRef allocator
, CFDataRef circleData
, CFErrorRef
*error
);
49 SOSCircleRef
SOSCircleCopyCircle(CFAllocatorRef allocator
, SOSCircleRef otherCircle
, CFErrorRef
*error
);
51 bool SOSCircleSign(SOSCircleRef circle
, SecKeyRef privkey
, CFErrorRef
*error
);
52 bool SOSCircleVerifySignatureExists(SOSCircleRef circle
, SecKeyRef pubKey
, CFErrorRef
*error
);
53 bool SOSCircleVerify(SOSCircleRef circle
, SecKeyRef pubkey
, CFErrorRef
*error
);
55 bool SOSCircleVerifyPeerSigned(SOSCircleRef circle
, SOSPeerInfoRef peer
, CFErrorRef
*error
);
57 bool SOSCircleGenerationSign(SOSCircleRef circle
, SecKeyRef user_approver
, SOSFullPeerInfoRef peerinfo
, CFErrorRef
*error
);
58 bool SOSCircleGenerationUpdate(SOSCircleRef circle
, SecKeyRef user_approver
, SOSFullPeerInfoRef peerinfo
, CFErrorRef
*error
);
60 size_t SOSCircleGetDEREncodedSize(SOSCircleRef cir
, CFErrorRef
*error
);
61 uint8_t* SOSCircleEncodeToDER(SOSCircleRef cir
, CFErrorRef
* error
, const uint8_t* der
, uint8_t* der_end
);
62 CFDataRef
SOSCircleCopyEncodedData(SOSCircleRef circle
, CFAllocatorRef allocator
, CFErrorRef
*error
);
64 int SOSCircleCountApplicants(SOSCircleRef circle
);
65 bool SOSCircleHasApplicant(SOSCircleRef circle
, SOSPeerInfoRef peerInfo
, CFErrorRef
*error
);
66 CFMutableSetRef
SOSCircleCopyApplicants(SOSCircleRef c
, CFAllocatorRef allocator
);
67 void SOSCircleForEachApplicant(SOSCircleRef circle
, void (^action
)(SOSPeerInfoRef peer
));
69 int SOSCircleCountRejectedApplicants(SOSCircleRef circle
);
70 bool SOSCircleHasRejectedApplicant(SOSCircleRef circle
, SOSPeerInfoRef peerInfo
, CFErrorRef
*error
);
71 SOSPeerInfoRef
SOSCircleCopyRejectedApplicant(SOSCircleRef circle
, SOSPeerInfoRef peerInfo
, CFErrorRef
*error
);
72 CFMutableArrayRef
SOSCircleCopyRejectedApplicants(SOSCircleRef c
, CFAllocatorRef allocator
);
74 CFStringRef
SOSCircleGetName(SOSCircleRef circle
);
75 const char *SOSCircleGetNameC(SOSCircleRef circle
);
77 void SOSCircleGenerationSetValue(SOSCircleRef circle
, int64_t value
);
78 CFNumberRef
SOSCircleGetGeneration(SOSCircleRef circle
);
79 int64_t SOSCircleGetGenerationSint(SOSCircleRef circle
);
80 void SOSCircleGenerationIncrement(SOSCircleRef circle
);
82 CFMutableSetRef
SOSCircleCopyPeers(SOSCircleRef circle
, CFAllocatorRef allocator
);
83 bool SOSCircleAppendConcurringPeers(SOSCircleRef circle
, CFMutableArrayRef appendHere
, CFErrorRef
*error
);
84 CFMutableArrayRef
SOSCircleCopyConcurringPeers(SOSCircleRef circle
, CFErrorRef
* error
);
85 SOSPeerInfoRef
SOSCircleCopyPeerWithID(SOSCircleRef circle
, CFStringRef peerid
, CFErrorRef
*error
);
87 int SOSCircleCountPeers(SOSCircleRef circle
);
88 int SOSCircleCountActivePeers(SOSCircleRef circle
);
89 int SOSCircleCountActiveValidPeers(SOSCircleRef circle
, SecKeyRef pubkey
);
90 int SOSCircleCountRetiredPeers(SOSCircleRef circle
);
92 void SOSCircleForEachPeer(SOSCircleRef circle
, void (^action
)(SOSPeerInfoRef peer
));
93 void SOSCircleForEachRetiredPeer(SOSCircleRef circle
, void (^action
)(SOSPeerInfoRef peer
));
94 void SOSCircleForEachActivePeer(SOSCircleRef circle
, void (^action
)(SOSPeerInfoRef peer
));
95 void SOSCircleForEachActiveValidPeer(SOSCircleRef circle
, SecKeyRef user_public_key
, void (^action
)(SOSPeerInfoRef peer
));
97 bool SOSCircleHasPeerWithID(SOSCircleRef circle
, CFStringRef peerid
, CFErrorRef
*error
);
98 bool SOSCircleHasPeer(SOSCircleRef circle
, SOSPeerInfoRef peerInfo
, CFErrorRef
*error
);
99 bool SOSCircleHasActivePeerWithID(SOSCircleRef circle
, CFStringRef peerid
, CFErrorRef
*error
);
100 bool SOSCircleHasActivePeer(SOSCircleRef circle
, SOSPeerInfoRef peerInfo
, CFErrorRef
*error
);
101 bool SOSCircleHasActiveValidPeerWithID(SOSCircleRef circle
, CFStringRef peerid
, SecKeyRef user_public_key
, CFErrorRef
*error
);
102 bool SOSCircleHasActiveValidPeer(SOSCircleRef circle
, SOSPeerInfoRef peerInfo
, SecKeyRef user_public_key
, CFErrorRef
*error
);
104 bool SOSCircleResetToOffering(SOSCircleRef circle
, SecKeyRef user_privkey
, SOSFullPeerInfoRef requestor
, CFErrorRef
*error
);
105 bool SOSCircleResetToEmpty(SOSCircleRef circle
, CFErrorRef
*error
);
106 bool SOSCircleRequestAdmission(SOSCircleRef circle
, SecKeyRef user_privkey
, SOSFullPeerInfoRef requestor
, CFErrorRef
*error
);
107 bool SOSCircleRequestReadmission(SOSCircleRef circle
, SecKeyRef user_pubkey
, SOSFullPeerInfoRef requestor
, CFErrorRef
*error
);
109 bool SOSCircleAcceptRequest(SOSCircleRef circle
, SecKeyRef user_privkey
, SOSFullPeerInfoRef device_approver
, SOSPeerInfoRef peerInfo
, CFErrorRef
*error
);
110 bool SOSCircleRejectRequest(SOSCircleRef circle
, SOSFullPeerInfoRef device_approver
, SOSPeerInfoRef peerInfo
, CFErrorRef
*error
);
111 bool SOSCircleWithdrawRequest(SOSCircleRef circle
, SOSPeerInfoRef peerInfo
, CFErrorRef
*error
);
112 bool SOSCircleRemoveRejectedPeer(SOSCircleRef circle
, SOSPeerInfoRef peerInfo
, CFErrorRef
*error
);
113 bool SOSCirclePeerSigUpdate(SOSCircleRef circle
, SecKeyRef userPrivKey
, SOSFullPeerInfoRef fpi
,
116 // Update a peer's meta information.
117 // No resigning of the circle is done, only updates to their own self signed description.
119 bool SOSCircleUpdatePeerInfo(SOSCircleRef circle
, SOSPeerInfoRef replacement_peer_info
);
121 bool SOSCircleRemovePeer(SOSCircleRef circle
, SecKeyRef user_privkey
, SOSFullPeerInfoRef device_approver
, SOSPeerInfoRef peerInfo
, CFErrorRef
*error
);
123 bool SOSCircleRemoveRetired(SOSCircleRef circle
, CFErrorRef
*error
);
125 bool SOSCircleAcceptRequests(SOSCircleRef circle
, SecKeyRef user_privkey
, SOSFullPeerInfoRef device_approver
, CFErrorRef
*error
);
127 // Stuff above this line is really SOSCircleInfo below the line is the active SOSCircle functionality
129 SOSFullPeerInfoRef
SOSCircleGetiCloudFullPeerInfoRef(SOSCircleRef circle
);
131 bool SOSCircleConcordanceSign(SOSCircleRef circle
, SOSFullPeerInfoRef peerinfo
, CFErrorRef
*error
);
134 kSOSConcordanceTrusted
= 0,
135 kSOSConcordanceGenOld
= 1, // kSOSErrorReplay
136 kSOSConcordanceNoUserSig
= 2, // kSOSErrorBadSignature
137 kSOSConcordanceNoUserKey
= 3, // kSOSErrorNoKey
138 kSOSConcordanceNoPeer
= 4, // kSOSErrorPeerNotFound
139 kSOSConcordanceBadUserSig
= 5, // kSOSErrorBadSignature
140 kSOSConcordanceBadPeerSig
= 6, // kSOSErrorBadSignature
141 kSOSConcordanceNoPeerSig
= 7,
142 kSOSConcordanceWeSigned
= 8,
144 typedef uint32_t SOSConcordanceStatus
;
146 bool SOSCircleSharedTrustedPeers(SOSCircleRef current
, SOSCircleRef proposed
, SOSPeerInfoRef me
);
148 SOSConcordanceStatus
SOSCircleConcordanceTrust(SOSCircleRef known_circle
, SOSCircleRef proposed_circle
,
149 SecKeyRef known_pubkey
, SecKeyRef user_pubkey
,
150 SOSPeerInfoRef exclude
, CFErrorRef
*error
);
155 CFDataRef
SOSCircleCreateIncompatibleCircleDER(CFErrorRef
* error
);
159 #endif /* !_SOSCIRCLE_H_ */