]> git.saurik.com Git - apple/security.git/blob - OSX/sec/SOSCircle/SecureObjectSync/SOSCloudCircle.h
Security-57740.31.2.tar.gz
[apple/security.git] / OSX / sec / SOSCircle / SecureObjectSync / SOSCloudCircle.h
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 // SOSCloudCircle.h
26 //
27
28 #ifndef _SECURITY_SOSCLOUDCIRCLE_H_
29 #define _SECURITY_SOSCLOUDCIRCLE_H_
30
31 #include <CoreFoundation/CoreFoundation.h>
32 #include <CoreFoundation/CFArray.h>
33 #include <CoreFoundation/CFSet.h>
34 #include <CoreFoundation/CFError.h>
35
36 #include <Security/SecureObjectSync/SOSTypes.h>
37 #include <Security/SecureObjectSync/SOSPeerInfo.h>
38
39 __BEGIN_DECLS
40
41
42 //
43 // CFError info for propogated errors
44 //
45
46 extern CFStringRef kSOSErrorDomain;
47
48 enum {
49 kSOSErrorPrivateKeyAbsent = 1,
50 kSOSErrorPublicKeyAbsent = 2,
51
52 kSOSErrorWrongPassword = 3,
53
54 kSOSErrorNotReady = 4, // System not yet ready (before first unlock)
55
56 kSOSErrorIncompatibleCircle = 5, // We saw an incompatible circle out there.
57 kSOSInitialSyncFailed =6, //we timed out when syncing during approving from another device
58 };
59
60 //
61 // Types
62 //
63
64 enum {
65 kSOSCCInCircle = 0,
66 kSOSCCNotInCircle = 1,
67 kSOSCCRequestPending = 2,
68 kSOSCCCircleAbsent = 3,
69 kSOSCCError = -1,
70 };
71
72 typedef int SOSCCStatus;
73
74 extern const char * kSOSCCCircleChangedNotification;
75 extern const char * kSOSCCViewMembershipChangedNotification;
76 extern const char * kSOSCCInitialSyncChangedNotification;
77 extern const char * kSOSCCHoldLockForInitialSync;
78 extern const char * kSOSCCPeerAvailable;
79
80 /*!
81 @function SOSCCSetUserCredentials
82 @abstract Uses the user authentication credential (password) to create an internal EC Key Pair for authenticating Circle changes.
83 @param user_label This string can be used for a label to tag the resulting credential data for persistent storage.
84 @param user_password The user's password that's used as input to generate EC keys for Circle authenticating operations.
85 @param error What went wrong if we returned false.
86 @discussion This call needs to be made whenever a call that updates a Cloud Circle returns an error of kSOSErrorPrivateKeyAbsent (credential timeout) or kSOSErrorPublicKeyAbsent (programmer error).
87
88 Any caller to SetUserCredential is asserting that they know the credential is correct.
89
90 If you are uncertain (unable to verify) use TryUserCredentials, but if you can know it's better
91 to call Set so we can recover from password change.
92 */
93
94 bool SOSCCSetUserCredentials(CFStringRef user_label, CFDataRef user_password, CFErrorRef* error);
95
96
97 /*!
98 @function SOSCCSetUserCredentialsAndDSID
99 @abstract Uses the user authentication credential (password) to create an internal EC Key Pair for authenticating Circle changes. Passes the DSID to ensure user credentials are passed to the correct account.
100 @param user_label This string can be used for a label to tag the resulting credential data for persistent storage.
101 @param user_password The user's password that's used as input to generate EC keys for Circle authenticating operations.
102 @param dsid This is a string of a dsid associated with an account
103 @param error What went wrong if we returned false.
104 @discussion This call needs to be made whenever a call that updates a Cloud Circle returns an error of kSOSErrorPrivateKeyAbsent (credential timeout) or kSOSErrorPublicKeyAbsent (programmer error).
105
106 Any caller to SetUserCredential is asserting that they know the credential is correct.
107
108 If you are uncertain (unable to verify) use TryUserCredentials, but if you can know it's better
109 to call Set so we can recover from password change.
110 */
111
112 bool SOSCCSetUserCredentialsAndDSID(CFStringRef user_label, CFDataRef user_password, CFStringRef dsid, CFErrorRef *error);
113
114 /*!
115 @function SOSCCTryUserCredentials
116 @abstract Uses the user authentication credential (password) to create an internal EC Key Pair for authenticating Circle changes.
117 @param user_label This string can be used for a label to tag the resulting credential data for persistent storage.
118 @param user_password The user's password that's used as input to generate EC keys for Circle authenticating operations.
119 @param error What went wrong if we returned false.
120 @discussion When one of the user credential requiring calls below (almost all) need a credential it will fail with kSOSErrorPrivateKeyAbsent. If you don't have an outside way to confirm correctness of the password we will attempt to use the passed in value and if it doesn't match the public information we currently have we'll fail.
121 */
122
123 bool SOSCCTryUserCredentials(CFStringRef user_label, CFDataRef user_password, CFErrorRef* error);
124
125 /*!
126 @function SOSCCCopyDeviceID
127 @abstract Retrieves this device's IDS device ID
128 @param error What went wrong if we returned false
129 */
130 CFStringRef SOSCCCopyDeviceID(CFErrorRef* error);
131
132 /*!
133 @function SOSCCSetDeviceID
134 @abstract Sets this device's IDS device ID
135 @param IDS The ID to set
136 @param error What went wrong if we returned false
137 */
138 bool SOSCCSetDeviceID(CFStringRef IDS, CFErrorRef* error);
139
140 /*!
141 @function SOSCCRegisterUserCredentials
142 @abstract Deprecated name for SOSCCSetUserCredentials.
143 */
144 bool SOSCCRegisterUserCredentials(CFStringRef user_label, CFDataRef user_password, CFErrorRef *error);
145
146 /*!
147 @function SOSCCWaitForInitialSync
148 @abstract returns true if it waited, false if we didn't due to some error
149 @param error Error ref
150 @return if we waited successfully
151 */
152 bool SOSCCWaitForInitialSync(CFErrorRef* error);
153
154 /*!
155 @function SOSCCCopyYetToSyncViewsList
156 @abstract returns views not yet synced
157 @param error error to fill in if we have one
158 @return List of view names that we haven't synced yet.
159 */
160 CFArrayRef SOSCCCopyYetToSyncViewsList(CFErrorRef* error);
161
162 /*!
163 @function SOSCCCanAuthenticate
164 @abstract Determines whether we currently have valid credentials to authenticate a circle operation.
165 @param error What went wrong if we returned false.
166 */
167
168 bool SOSCCCanAuthenticate(CFErrorRef *error);
169
170 /*!
171 @function SOSCCThisDeviceIsInCircle
172 @abstract Finds and returns if this devices status in the user's circle.
173 @param error What went wrong if we returned kSOSCCError.
174 @result kSOSCCInCircle if we're in the circle.
175 @discussion If we have an error figuring out if we're in the circle we return false and the error.
176 */
177 SOSCCStatus SOSCCThisDeviceIsInCircle(CFErrorRef* error);
178
179 /*!
180 @function SOSCCIsIcloudKeychainSyncing
181 @abstract determines whether baseline keychain syncing is occuring (V0/V2)
182 @result true if we're in the circle. false otherwise.
183 */
184
185 bool SOSCCIsIcloudKeychainSyncing(void);
186
187 /*!
188 @function SOSCCIsSafariSyncing
189 @abstract determines whether Safari keychain item syncing is occuring (kSOSViewAutofillPasswords/kSOSViewSafariCreditCards)
190 @result true if we're in the circle. false otherwise.
191 */
192
193 bool SOSCCIsSafariSyncing(void);
194
195 /*!
196 @function SOSCCIsAppleTVSyncing
197 @abstract determines whether appleTV keychain syncing is occuring (kSOSViewAppleTV)
198 @result true if we're in the circle. false otherwise.
199 */
200
201 bool SOSCCIsAppleTVSyncing(void);
202
203
204 /*!
205 @function SOSCCIsHomeKitSyncing
206 @abstract determines whether homekit keychain syncing is occuring (kSOSViewHomeKit)
207 @result true if we're in the circle. false otherwise.
208 */
209
210 bool SOSCCIsHomeKitSyncing(void);
211
212
213 /*!
214 @function SOSCCIsWiFiSyncing
215 @abstract determines whether homekit keychain syncing is occuring (kSOSViewWiFi)
216 @result true if we're in the circle. false otherwise.
217 */
218
219 bool SOSCCIsWiFiSyncing(void);
220
221 /*!
222 @function SOSCCIsAlwaysOnNoInitialSyncSyncing
223 @abstract determines whether homekit keychain syncing is occuring (kSOSViewHomeKit)
224 @result true if we're in the circle. false otherwise.
225 */
226
227 bool SOSCCIsContinuityUnlockSyncing(void);
228
229 /*!
230 @function SOSCCRequestToJoinCircle
231 @abstract Requests that this device join the circle.
232 @param error What went wrong if we tried to join.
233 @result true if we pushed the request out successfully. False if there was an error.
234 @discussion Requests to join the user's circle or all the pending circles (other than his) if there are multiple pending circles.
235 */
236 bool SOSCCRequestToJoinCircle(CFErrorRef* error);
237
238 /*!
239 @function SOSCCRequestToJoinCircleAfterRestore
240 @abstract Requests that this device join the circle and do the magic just after restore approval.
241 @param error What went wrong if we tried to join.
242 @result true if we joined or pushed a request out. False if we failed to try.
243 @discussion Uses the cloud identity to get in the circle if it can. If it cannot it falls back on simple application.
244 */
245 bool SOSCCRequestToJoinCircleAfterRestore(CFErrorRef* error);
246
247 /*!
248 @function SOSCCRequestEnsureFreshParameters
249 @abstract function to help debug problems with EnsureFreshParameters
250 @param error What went wrong if we tried to refresh parameters
251 @result true if we successfully retrieved fresh parameters. False if we failed.
252 */
253 bool SOSCCRequestEnsureFreshParameters(CFErrorRef* error);
254
255 /*!
256 @function SOSCCAccountSetToNew
257 @abstract reset account to new
258 @param error What went wrong if we tried to refresh parameters
259 @result true if we successfully reset the account object
260 */
261 bool SOSCCAccountSetToNew(CFErrorRef *error);
262
263 /*!
264 @function SOSCCResetToOffering
265 @abstract Resets the cloud to offer this device's circle.
266 @param error What went wrong if we tried to post our circle.
267 @result true if we posted the circle successfully. False if there was an error.
268 */
269 bool SOSCCResetToOffering(CFErrorRef* error);
270
271 /*!
272 @function SOSCCResetToEmpty
273 @abstract Resets the cloud to a completely empty circle.
274 @param error What went wrong if we tried to post our circle.
275 @result true if we posted the circle successfully. False if there was an error.
276 */
277 bool SOSCCResetToEmpty(CFErrorRef* error);
278
279 /*!
280 @function SOSCCRemoveThisDeviceFromCircle
281 @abstract Removes the current device from the circle.
282 @param error What went wrong trying to remove ourselves.
283 @result true if we posted the removal. False if there was an error.
284 @discussion This removes us from the circle.
285 */
286 bool SOSCCRemoveThisDeviceFromCircle(CFErrorRef* error);
287
288 /*!
289 @function SOSCCRemoveThisDeviceFromCircle
290 @abstract Removes a list of peers from the circle.
291 @param peerList List of peers to ensure aren't in the circle
292 @param error What went wrong trying to remove the peers.
293 @result true if we posted a circle with none of the peers listed as members, false if we had an error.
294 @discussion This removes peers in the list from the circle. One likely error is
295 that we don't have the user credentail (need to prompt for password)
296 */
297 bool SOSCCRemovePeersFromCircle(CFArrayRef peerList, CFErrorRef* error);
298
299 /*!
300 @function SOSCCRemoveThisDeviceFromCircle
301 @abstract Removes the current device from the circle.
302 @param error What went wrong trying to remove ourselves.
303 @result true if we posted the removal. False if there was an error.
304 @discussion This removes us from the circle.
305 */
306 bool SOSCCLoggedOutOfAccount(CFErrorRef* error);
307
308 /*!
309 @function SOSCCBailFromCircle_BestEffort
310 @abstract Attempts to publish a retirement ticket for the current device.
311 @param error What went wrong trying to remove ourselves.
312 @result true if we posted the ticket. False if there was an error.
313 @discussion This attempts to post a retirement ticket that should
314 result in other devices removing this device from the circle. It does so
315 with a 5 second timeout. The only use for this call is when doing a device
316 erase.
317 */
318 bool SOSCCBailFromCircle_BestEffort(uint64_t limit_in_seconds, CFErrorRef* error);
319
320 /*!
321 @function SOSCCSignedOut
322 @abstract Attempts to publish a retirement ticket for the current device.
323 @param immediate If we should remove the device immediately or to leave the circle with best effort.
324 @param error What went wrong trying to remove ourselves.
325 @result true if we posted the ticket. False if there was an error.
326 @discussion This attempts to post a retirement ticket that should
327 result in other devices removing this device from the circle. It does so
328 with a 5 second timeout or immediately.
329 */
330 bool SOSCCSignedOut(bool immediate, CFErrorRef* error);
331
332 /*!
333 @function SOSCCCopyApplicantPeerInfo
334 @abstract Get the list of peers wishing admittance.
335 @param error What went wrong.
336 @result Array of PeerInfos for applying peers.
337 */
338 CFArrayRef SOSCCCopyApplicantPeerInfo(CFErrorRef* error);
339
340 /*!
341 @function SOSCCCopyGenerationPeerInfo
342 @abstract Get the list of generation count per circle.
343 @param error What went wrong.
344 @result Array of Circle generation counts.
345 */
346 CFArrayRef SOSCCCopyGenerationPeerInfo(CFErrorRef* error);
347
348 /*!
349 @function SOSCCCopyValidPeerPeerInfo
350 @abstract Get the list of valid peers.
351 @param error What went wrong.
352 @result Array of PeerInfos for applying valid peers.
353 */
354 CFArrayRef SOSCCCopyValidPeerPeerInfo(CFErrorRef* error);
355
356 /*!
357 @function SOSCCValidateUserPublic
358 @abstract Validate whether the account's user public key is trustworthy.
359 @param error What went wrong.
360 @result true if the user public key is trusted, false if not.
361 */
362 bool SOSCCValidateUserPublic(CFErrorRef *error);
363
364 /*!
365 @function SOSCCCopyNotValidPeerPeerInfo
366 @abstract Get the list of not valid peers.
367 @param error What went wrong.
368 @result Array of PeerInfos for non-valid peers.
369 */
370 CFArrayRef SOSCCCopyNotValidPeerPeerInfo(CFErrorRef* error);
371
372 /*!
373 @function SOSCCCopyRetirementPeerInfo
374 @abstract Get the list of retired peers.
375 @param error What went wrong.
376 @result Array of PeerInfos for retired peers.
377 */
378 CFArrayRef SOSCCCopyRetirementPeerInfo(CFErrorRef* error);
379
380 /*!
381 @function SOSCCCopyViewUnawarePeerInfo
382 @abstract Copies all the peers who are in the circle but are unable to handle views.
383 @param error What went wrong.
384 @result Array of peer infos.
385 */
386 CFArrayRef SOSCCCopyViewUnawarePeerInfo(CFErrorRef* error);
387
388 /*!
389 @function SOSCCCopyEngineState
390 @abstract Get the list of peers the engine knows about and their state.
391 @param error What went wrong.
392 @result Array of EnginePeerInfos for connected peers.
393 */
394 CFArrayRef SOSCCCopyEngineState(CFErrorRef* error);
395
396 /*!
397 @function SOSCCAcceptApplicants
398 @abstract Accepts the applicants into the circle (requires that we recently had the user enter the credentials).
399 @param applicants List of applicants to accept.
400 @param error What went wrong if we tried to post our circle.
401 @result true if we accepted the applicants. False if there was an error.
402 */
403 bool SOSCCAcceptApplicants(CFArrayRef applicants, CFErrorRef* error);
404
405 /*!
406 @function SOSCCRejectApplicants
407 @abstract Rejects the applications for admission (requires that we recently had the user enter the credentials).
408 @param applicants List of applicants to reject.
409 @param error What went wrong if we tried to post our circle.
410 @result true if we rejected the applicants. False if there was an error.
411 */
412 bool SOSCCRejectApplicants(CFArrayRef applicants, CFErrorRef *error);
413
414 /*!
415 @function SOSCCCopyPeerPeerInfo
416 @abstract Returns peers in the circle (we may not be in it).
417 @param error What went wrong trying look at the circle.
418 @result Returns a list of peers in the circle currently syncing.
419 @discussion We get the list of all peers syncing in the circle.
420 */
421 CFArrayRef SOSCCCopyPeerPeerInfo(CFErrorRef* error);
422
423 /*!
424 @function SOSCCSetAutoAcceptInfo
425 @abstract Arms auto-acceptance for the HSA2 data given.
426 @param error What went wrong.
427 @result true if the operation succeeded, otherwise false.
428 */
429 bool SOSCCSetAutoAcceptInfo(CFDataRef autoaccept, CFErrorRef *error);
430
431 /*!
432 @function SOSCCCheckPeerAvailability
433 @abstract Prompts IDSKeychainSyncingProxy to query all devices in the circle with the same view.
434 @param error What went wrong.
435 @result true if the operation succeeded, otherwise false.
436 */
437 bool SOSCCCheckPeerAvailability(CFErrorRef *error);
438
439 /*!
440 @function SOSCCGetLastDepartureReason
441 @abstract Returns the code of why you left the circle.
442 @param error What went wrong if we returned kSOSDepartureReasonError.
443 */
444 enum DepartureReason {
445 kSOSDepartureReasonError = 0,
446 kSOSNeverLeftCircle, // We haven't ever left a circle
447 kSOSWithdrewMembership, // SOSCCRemoveThisDeviceFromCircle
448 kSOSMembershipRevoked, // Via reset or remote removal.
449 kSOSLeftUntrustedCircle, // We saw a circle we could no longer trust
450 kSOSNeverAppliedToCircle, // We've never applied to a circle
451 kSOSDiscoveredRetirement, // We discovered that we were retired.
452 kSOSLostPrivateKey, // We lost our private key
453 kSOSPasswordChanged, // We lost our public key, password change?
454 // <-- add additional departure reason codes HERE!
455 kSOSNumDepartureReasons, // ACHTUNG: this *MUST* be the last entry - ALWAYS!
456 };
457
458 enum DepartureReason SOSCCGetLastDepartureReason(CFErrorRef *error);
459
460 /*!
461 @function SOSCCSetLastDepartureReason
462 @abstract Manually set the code of why the circle was left.
463 @param DepartureReason Custom departure reason be be set.
464 @param error What went wrong if we returned false.
465 */
466
467 bool SOSCCSetLastDepartureReason(enum DepartureReason reason, CFErrorRef *error);
468
469 /*!
470 @function SOSCCGetIncompatibilityInfo
471 @abstract Returns the information (string, hopefully URL) that will lead to an explanation of why you have an incompatible circle.
472 @param error What went wrong if we returned NULL.
473 */
474 CFStringRef SOSCCCopyIncompatibilityInfo(CFErrorRef *error);
475
476
477 /*
478 Views
479
480 Initial View List - To be expanded
481
482 For now for any peer joining a circle we only enable:
483 kSOSViewKeychainV0
484 */
485
486 //
487 // -- Views that sync to os in (iOS in (7.1, 8.*) Mac OS in (10.9, 10.10)) peers
488 //
489
490 // kSOSViewKeychainV0 - All items in the original iCloud Keychain are in the views listed below
491 // It is defined by the query:
492 // class in (genp inet keys) and pdmn in (ak,ck,dk,aku,cku,dku) and vwht = NULL and tkid = NULL
493
494 // kSOSViewWiFi - class = genp and pdmn in (ak,ck,dk,aku,cku,dku) and vwht = NULL and agrp = apple and svce = AirPort
495 extern const CFStringRef kSOSViewWiFi;
496
497 // kSOSViewAutofillPasswords - class = inet and pdmn in (ak,ck,dk,aku,cku,dku) and vwht = NULL and agrp = com.apple.cfnetwork
498 extern const CFStringRef kSOSViewAutofillPasswords;
499
500 // kSOSViewSafariCreditCards - class = genp and pdmn in (ak,ck,dk,aku,cku,dku) and vwht = NULL and agrp = com.apple.safari.credit-cards
501 extern const CFStringRef kSOSViewSafariCreditCards;
502
503 // kSOSViewiCloudIdentity - class = keys and pdmn in (ak,ck,dk,aku,cku,dku) and vwht = NULL and agrp = com.apple.security.sos
504 extern const CFStringRef kSOSViewiCloudIdentity;
505 // End of KeychainV0 views
506
507 // kSOSViewBackupBagV0 - class = genp and and pdmn in (ak,ck,dk,aku,cku,dku) and vwht = NULL and agrp = com.apple.sbd
508 // (LEAVE OUT FOR NOW) and svce = SecureBackupService pdmn = ak acct = SecureBackupPublicKeybag
509 extern const CFStringRef kSOSViewBackupBagV0;
510
511 // kSOSViewOtherSyncable - An or of the following 5 queries:
512 // class = cert and pdmn in (ak,ck,dk,aku,cku,dku) and vwht = NULL
513 // class = genp and pdmn in (ak,ck,dk,aku,cku,dku) and vwht = NULL and agrp = "apple" and svce != "AirPort"
514 // class = genp and pdmn in (ak,ck,dk,aku,cku,dku) and vwht = NULL and agrp not in ("apple", "com.apple.safari.credit-cards", "com.apple.sbd")
515 // class = inet and pdmn in (ak,ck,dk,aku,cku,dku) and vwht = NULL and agrp not in ("com.apple.cfnetwork")
516 // class = keys and pdmn in (ak,ck,dk,aku,cku,dku) and vwht = NULL and agrp not in ("com.apple.security.sos")
517 extern const CFStringRef kSOSViewOtherSyncable;
518
519 //
520 // Views below this line all match a kSecAttrSyncViewHint attribute value that matches their name.
521 //
522
523 // PCS (Protected Cloud Storage) Views
524 extern const CFStringRef kSOSViewPCSMasterKey;
525 extern const CFStringRef kSOSViewPCSiCloudDrive;
526 extern const CFStringRef kSOSViewPCSPhotos;
527 extern const CFStringRef kSOSViewPCSCloudKit;
528 extern const CFStringRef kSOSViewPCSEscrow;
529 extern const CFStringRef kSOSViewPCSFDE;
530 extern const CFStringRef kSOSViewPCSMailDrop;
531 extern const CFStringRef kSOSViewPCSiCloudBackup;
532 extern const CFStringRef kSOSViewPCSNotes;
533 extern const CFStringRef kSOSViewPCSiMessage;
534 extern const CFStringRef kSOSViewPCSFeldspar;
535 extern const CFStringRef kSOSViewPCSSharing;
536
537 extern const CFStringRef kSOSViewAppleTV;
538 extern const CFStringRef kSOSViewHomeKit;
539 extern const CFStringRef kSOSViewContinuityUnlock;
540 extern const CFStringRef kSOSViewAccessoryPairing;
541
542 /*!
543 @function SOSCCView
544 @abstract Enable, disable or query status of a View for this peer.
545 @param dataSource The View for which the action should be performed.
546 @param action The action code to take with the View
547 @param error More description of the error if one occurred.
548 @discussion
549 For all actions any error return can fallback to kSOSCCGeneralViewError. This is a catch-all until
550 more code is written and specific additional error returns are identified.
551 For kSOSCCViewEnable actions other possible return codes are:
552 kSOSCCViewMember if the operation was successful and the peer has access to the View
553 kSOSCCViewNotMember if the operation was a successful application to a View, yet the peer must be vetted by another peer.
554 kSOSCCViewNotQualified if the device can't support prerequisite security capabilities
555 kSOSCCNoSuchView if the CFStringRef doesn't match one of the known Views
556
557 For kSOSCCViewDisable actions other possible return codes are:
558 kSOSCCViewNotMember for successfully disabling the View
559 kSOSCCNoSuchView if the CFStringRef doesn't match one of the known Views
560
561 For kSOSCCViewQuery actions other possible return codes are:
562 kSOSCCViewMember or kSOSCCDSNotMember for successful querying of the status for a View for this peer
563 kSOSCCNoSuchView if the CFStringRef doesn't match one of the known Views
564
565 */
566
567 SOSViewResultCode SOSCCView(CFStringRef view, SOSViewActionCode action, CFErrorRef *error);
568
569
570 /*!
571 @function SOSCCViewSet
572 @abstract Enable, disable or query status of a views for this peer.
573 @param dataSource The views (as CFSet) for which the action should be performed.
574 @param action The action code to take with the views
575 @param error More description of the error if one occurred.
576 @discussion
577 This call enables bulk setting of views for a peer. This is done for convenience as well as
578 better performance; it requires less circle changes by grouping all the view enabling/disabling.
579
580 Separate calls to SOSCCView is required to determine resulting view settings.
581 */
582
583 bool SOSCCViewSet(CFSetRef enabledviews, CFSetRef disabledviews);
584
585 /*
586 Security Attributes for PeerInfos
587
588 Initial View List - To be expanded
589 */
590
591 extern const CFStringRef kSOSSecPropertyHasEntropy;
592 extern const CFStringRef kSOSSecPropertyScreenLock;
593 extern const CFStringRef kSOSSecPropertySEP;
594 extern const CFStringRef kSOSSecPropertyIOS;
595
596
597 /*!
598 @function SOSCCSecurityProperty
599 @abstract Enable, disable or query status of a SecurityProperty for this peer.
600 @param property The SecurityProperty for which the action should be performed.
601 @param action The action code to take with the SecurityProperty
602 @param error More description of the error if one occurred.
603 @discussion
604 For all actions any error return can fallback to kSOSCCGeneralSecurityPropertyError.
605 For kSOSCCSecurityPropertyEnable actions other possible return codes are:
606 kSOSCCSecurityPropertyValid if the operation was successful and the peer's SecurityProperty is valid
607 kSOSCCSecurityPropertyNotValid if the operation was unsuccessful
608 kSOSCCSecurityPropertyNotQualified if the device can't support prerequisite security capabilities
609 kSOSCCNoSuchSecurityProperty if the CFStringRef doesn't match one of the known SecurityProperties
610
611 For kSOSCCSecurityPropertyDisable actions other possible return codes are:
612 kSOSCCSecurityPropertyNotMember for successfully disabling the SecurityProperty
613 kSOSCCNoSuchSecurityProperty if the CFStringRef doesn't match one of the known SecurityProperties
614
615 For kSOSCCSecurityPropertyQuery actions other possible return codes are:
616 kSOSCCSecurityPropertyValid or kSOSCCDSNotValidMember for successful querying of the status for a SecurityProperty for this peer
617 kSOSCCNoSuchSecurityProperty if the CFStringRef doesn't match one of the known SecurityProperties
618
619 */
620
621 SOSSecurityPropertyResultCode SOSCCSecurityProperty(CFStringRef property, SOSSecurityPropertyActionCode action, CFErrorRef *error);
622
623 //
624 // Backup APIs
625 //
626
627 /*!
628 @function SOSCCCopyMyPeerWithNewDeviceRecoverySecret
629 @abstract Returns retained peer info for this device
630 @param secret user provided entropy
631 @param error What went wrong trying to register the new secret
632 @result Returns our peer info.
633 @discussion For miCSCs this creates a new wrapping of the view master key in the view bag protected by the secret.
634 */
635 SOSPeerInfoRef SOSCCCopyMyPeerWithNewDeviceRecoverySecret(CFDataRef secret, CFErrorRef *error);
636
637 /*!
638 @function SOSCCRegisterSingleRecoverySecret
639 @param aks_bag
640 @param error What went wrong trying to register the new secret
641 @result true if we saved the bag, false if we had an error
642 @discussion Asserts the keybag for use for backups when having a single secret. All views get backed up with this single bag.
643 */
644 bool SOSCCRegisterSingleRecoverySecret(CFDataRef aks_bag, bool forV0Only, CFErrorRef *error);
645
646
647 /*!
648 @function SOSCCIsThisDeviceLastBackup
649 @param error Why this query can't be accepted.
650 @result true if this is the last backup device, false otherwise.
651 */
652
653 bool SOSCCIsThisDeviceLastBackup(CFErrorRef *error);
654
655 /*!
656 @function SOSCCSetEscrowRecord
657 @param escrow_label Account label
658 @param tries Number of attempts
659 @param error What went wrong trying to set the escrow label
660 @result true if we saved the escrow record, false if we had an error
661 @discussion persist escrow records in the account object or the peer info
662 */
663 bool SOSCCSetEscrowRecord(CFStringRef escrow_label, uint64_t tries, CFErrorRef *error);
664
665 /*!
666 @function SOSCCCopyEscrowRecord
667 @param dsid Account DSID
668 @param escrow_label Account label
669 @param error What went wrong trying to set the escrow label
670 @result dictionary of the escrow record, false if we had an error, dictionary will be of format: [account label: <dictionary>], dictionary will contain (ex): "Burned Recovery Attempt Attestation Date" = "[2015-08-19 15:21]";
671 "Burned Recovery Attempt Count" = 8;
672 @discussion for debugging - retrieve the escrow record
673 */
674 CFDictionaryRef SOSCCCopyEscrowRecord(CFErrorRef *error);
675
676 /*!
677 @function SOSCCCopyApplication
678 @param error What went wrong getting the applicant peerInfo.
679 @result PeerInfoRef that's an applicant peerinfo to be used as the start of an HSA2 piggyback entry.
680 */
681
682 SOSPeerInfoRef SOSCCCopyApplication(CFErrorRef *error);
683
684 /*!
685 @function SOSCCCopyCircleJoiningBlob
686 @param applicant The peerInfo applicant to pre-approve for membership in the circle
687 @param error Why this peerInfo wasn't accepted.
688 @result DER blob containing the gencount and this peerkey signature of the current circle with the applicant as a member at the gencount.
689 */
690 CFDataRef SOSCCCopyCircleJoiningBlob(SOSPeerInfoRef applicant, CFErrorRef *error);
691
692 /*!
693 @function SOSCCJoinWithCircleJoiningBlob
694 @param joiningBlob DER blob to be used to create a suitable circle for this pre-approved peer to join.
695 @param error Why this peerInfo can't be accepted.
696 @result true if this succeeded.
697 */
698
699 bool SOSCCJoinWithCircleJoiningBlob(CFDataRef joiningBlob, CFErrorRef *error);
700
701 /*!
702 @function: bool SOSCCPeersHaveViewsEnabled(CFSetRef viewNames)
703 @param viewNames the collection of views we want to know if other peers have enabled
704 @result CFBooleanTrue if we are in circle and all views are enabled by at least one other peer,
705 CFBooleanFalse if we are in circle and any of the views aren't avaialbe
706 NULL if we have an error.
707 */
708 CFBooleanRef SOSCCPeersHaveViewsEnabled(CFArrayRef viewNames, CFErrorRef *error);
709
710 __END_DECLS
711
712 #endif