]>
Commit | Line | Data |
---|---|---|
5c19dc3a A |
1 | /* |
2 | * Copyright (c) 2012-2014 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 | /*! | |
26 | @header SOSPeer | |
27 | The functions provided in SOSPeer provide an interface to a | |
28 | secure object syncing peer in a circle | |
29 | */ | |
30 | ||
31 | #ifndef _SOSPEER_H_ | |
32 | #define _SOSPEER_H_ | |
33 | ||
34 | #include <Security/SecureObjectSync/SOSCoder.h> | |
35 | #include <Security/SecureObjectSync/SOSDataSource.h> // For SOSEngineRef | |
36 | #include <utilities/SecAKSWrappers.h> // TODO: Layer violation -> move to datasource or make schema based | |
37 | ||
38 | __BEGIN_DECLS | |
39 | ||
40 | // PeerMetaRef are used to paas info about peers between accout and engine as well as to serialize in the peerstate. | |
41 | typedef CFTypeRef SOSPeerMetaRef; | |
42 | ||
43 | ||
44 | // peerID is not optional everything else is. | |
45 | SOSPeerMetaRef SOSPeerMetaCreateWithComponents(CFStringRef peerID, CFSetRef views, CFDataRef keybag); | |
46 | ||
47 | // peerID and state are both required. State is excepted to contain the set of views for this peer. | |
48 | SOSPeerMetaRef SOSPeerMetaCreateWithState(CFStringRef peerID, CFDictionaryRef state); | |
49 | ||
50 | CFTypeRef SOSPeerOrStateSetViewsKeyBagAndCreateCopy(CFTypeRef peerOrState, CFSetRef views, CFDataRef keyBag); | |
51 | CFTypeRef SOSPeerOrStateSetViewsAndCopyState(CFTypeRef peerOrState, CFSetRef views); | |
52 | bool SOSPeerMapEntryIsBackup(const void *mapEntry); | |
53 | ||
54 | // peerID will always be returned, views, and publicKey might not be. | |
55 | CFStringRef SOSPeerMetaGetComponents(SOSPeerMetaRef peerMeta, CFSetRef *views, CFDataRef *keybag, CFErrorRef *error); | |
56 | ||
57 | ||
58 | typedef struct __OpaqueSOSPeer *SOSPeerRef; | |
59 | ||
60 | CFTypeID SOSPeerGetTypeID(void); | |
61 | ||
62 | void SOSPeerMarkDigestsInUse(SOSPeerRef peer, struct SOSDigestVector *mdInUse); | |
63 | void SOSPeerAddManifestsInUse(SOSPeerRef peer, CFMutableDictionaryRef mfc); | |
64 | bool SOSPeerDidReceiveRemovalsAndAdditions(SOSPeerRef peer, SOSManifestRef absentFromRemote, SOSManifestRef additionsFromRemote, | |
65 | SOSManifestRef unwantedFromRemote, SOSManifestRef local, CFErrorRef *error); | |
66 | bool SOSPeerDataSourceWillCommit(SOSPeerRef peer, SOSDataSourceTransactionSource source, SOSManifestRef removals, SOSManifestRef additions, CFErrorRef *error); | |
67 | bool SOSPeerDataSourceWillChange(SOSPeerRef peer, SOSDataSourceRef dataSource, SOSDataSourceTransactionSource source, CFArrayRef changes, CFErrorRef *error); | |
68 | bool SOSPeerWriteAddEvent(FILE *journalFile, keybag_handle_t kbhandle, SOSDataSourceRef dataSource, SOSObjectRef object, CFErrorRef *error); | |
69 | ||
70 | // Create a peer from an archived state. | |
71 | SOSPeerRef SOSPeerCreateWithState(SOSEngineRef engine, CFStringRef peer_id, CFDictionaryRef state, CFErrorRef *error); | |
72 | ||
73 | // Return encoded peerState dictionary | |
74 | CFDictionaryRef SOSPeerCopyState(SOSPeerRef peer, CFErrorRef *error); | |
75 | ||
76 | // (Re)initialize from a peerState dictionary | |
77 | bool SOSPeerSetState(SOSPeerRef peer, SOSEngineRef engine, CFDictionaryRef state, CFErrorRef *error); | |
78 | ||
79 | // | |
80 | // | |
81 | // | |
82 | ||
83 | CFIndex SOSPeerGetVersion(SOSPeerRef peer); | |
84 | CFStringRef SOSPeerGetID(SOSPeerRef peer); | |
85 | bool SOSPeersEqual(SOSPeerRef peerA, SOSPeerRef peerB); | |
86 | ||
5c19dc3a A |
87 | uint64_t SOSPeerNextSequenceNumber(SOSPeerRef peer); |
88 | uint64_t SOSPeerGetMessageVersion(SOSPeerRef peer); | |
89 | ||
90 | // | |
91 | // MARK: State tracking helpers | |
92 | // | |
93 | ||
94 | // Return true if the peer needs saving. | |
95 | bool SOSPeerDidConnect(SOSPeerRef peer); | |
96 | bool SOSPeerMustSendMessage(SOSPeerRef peer); | |
97 | void SOSPeerSetMustSendMessage(SOSPeerRef peer, bool must); | |
98 | ||
99 | bool SOSPeerSendObjects(SOSPeerRef peer); | |
100 | void SOSPeerSetSendObjects(SOSPeerRef peer, bool sendObjects); | |
101 | ||
102 | SOSManifestRef SOSPeerGetProposedManifest(SOSPeerRef peer); | |
103 | SOSManifestRef SOSPeerGetConfirmedManifest(SOSPeerRef peer); | |
104 | void SOSPeerSetConfirmedManifest(SOSPeerRef peer, SOSManifestRef confirmed); | |
105 | void SOSPeerAddProposedManifest(SOSPeerRef peer, SOSManifestRef pending); | |
106 | void SOSPeerSetProposedManifest(SOSPeerRef peer, SOSManifestRef pending); | |
107 | void SOSPeerAddLocalManifest(SOSPeerRef peer, SOSManifestRef local); | |
108 | SOSManifestRef SOSPeerGetPendingObjects(SOSPeerRef peer); | |
109 | void SOSPeerSetPendingObjects(SOSPeerRef peer, SOSManifestRef pendingObjects); | |
110 | SOSManifestRef SOSPeerGetUnwantedManifest(SOSPeerRef peer); | |
111 | void SOSPeerSetUnwantedManifest(SOSPeerRef peer, SOSManifestRef unwantedManifest); | |
112 | ||
113 | SOSManifestRef SOSPeerCopyManifestForDigest(SOSPeerRef peer, CFDataRef digest); | |
114 | ||
115 | CFSetRef SOSPeerGetViewNameSet(SOSPeerRef peer); | |
116 | void SOSPeerSetViewNameSet(SOSPeerRef peer, CFSetRef views); | |
117 | ||
118 | CFDataRef SOSPeerGetKeyBag(SOSPeerRef peer); | |
119 | void SOSPeerKeyBagDidChange(SOSPeerRef peer); | |
120 | void SOSPeerSetKeyBag(SOSPeerRef peer, CFDataRef keyBag); | |
121 | // Write a reset event to the journal if mustSendMessage is true. | |
122 | bool SOSPeerWritePendingReset(SOSPeerRef peer, CFErrorRef *error); | |
123 | ||
124 | // | |
125 | // MARK: Backup Peers | |
126 | // | |
127 | ||
128 | // TODO: Layer violation -> move to datasource or make schema based | |
129 | bool SOSPeerAppendToJournal(SOSPeerRef peer, CFErrorRef *error, void(^with)(FILE *journalFile, keybag_handle_t kbhandle)); | |
130 | int SOSPeerHandoffFD(SOSPeerRef peer, CFErrorRef *error); | |
131 | ||
132 | void SOSBackupPeerPostNotification(const char *reason); | |
133 | ||
134 | __END_DECLS | |
135 | ||
136 | #endif /* !_SOSPEER_H_ */ |