2 * Copyright (c) 2019 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@
24 #import "keychain/ot/CuttlefishXPCWrapper.h"
26 @implementation CuttlefishXPCWrapper
27 - (instancetype) initWithCuttlefishXPCConnection: (id<NSXPCProxyCreating>)cuttlefishXPCConnection
29 if ((self = [super init])) {
30 _cuttlefishXPCConnection = cuttlefishXPCConnection;
35 + (bool)retryable:(NSError *_Nonnull)error
37 return error.domain == NSCocoaErrorDomain && error.code == NSXPCConnectionInterrupted;
40 enum {NUM_RETRIES = 5};
42 - (void)pingWithReply:(void (^)(void))reply
48 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
49 if (i < NUM_RETRIES && [self.class retryable:error]) {
50 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
53 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
56 }] pingWithReply:reply];
60 - (void)dumpWithContainer:(NSString *)container
61 context:(NSString *)context
62 reply:(void (^)(NSDictionary * _Nullable, NSError * _Nullable))reply
68 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
69 if (i < NUM_RETRIES && [self.class retryable:error]) {
70 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
73 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
77 }] dumpWithContainer:container context:context reply:reply];
81 - (void)departByDistrustingSelfWithContainer:(NSString *)container
82 context:(NSString *)context
83 reply:(void (^)(NSError * _Nullable))reply
89 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
90 if (i < NUM_RETRIES && [self.class retryable:error]) {
91 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
94 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
98 }] departByDistrustingSelfWithContainer:container context:context reply:reply];
102 - (void)distrustPeerIDsWithContainer:(NSString *)container
103 context:(NSString *)context
104 peerIDs:(NSSet<NSString*>*)peerIDs
105 reply:(void (^)(NSError * _Nullable))reply
111 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
112 if (i < NUM_RETRIES && [self.class retryable:error]) {
113 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
116 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
120 }] distrustPeerIDsWithContainer:container context:context peerIDs:peerIDs reply:reply];
124 - (void)trustStatusWithContainer:(NSString *)container
125 context:(NSString *)context
126 reply:(void (^)(TrustedPeersHelperEgoPeerStatus *status,
127 NSError* _Nullable error))reply
133 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
134 if (i < NUM_RETRIES && [self.class retryable:error]) {
135 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
138 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
142 }] trustStatusWithContainer:container context:context reply:reply];
146 - (void)resetWithContainer:(NSString *)container
147 context:(NSString *)context
148 resetReason:(CuttlefishResetReason)reason
149 reply:(void (^)(NSError * _Nullable error))reply
155 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
156 if (i < NUM_RETRIES && [self.class retryable:error]) {
157 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
160 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
164 }] resetWithContainer:container context:context resetReason:reason reply:reply];
168 - (void)localResetWithContainer:(NSString *)container
169 context:(NSString *)context
170 reply:(void (^)(NSError * _Nullable error))reply
176 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
177 if (i < NUM_RETRIES && [self.class retryable:error]) {
178 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
181 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
185 }] localResetWithContainer:container context:context reply:reply];
189 - (void)setAllowedMachineIDsWithContainer:(NSString *)container
190 context:(NSString *)context
191 allowedMachineIDs:(NSSet<NSString*> *)allowedMachineIDs
192 honorIDMSListChanges:(BOOL)accountIsDemo
193 reply:(void (^)(BOOL listDifferences, NSError * _Nullable error))reply
199 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
200 if (i < NUM_RETRIES && [self.class retryable:error]) {
201 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
204 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
208 }] setAllowedMachineIDsWithContainer:container context:context allowedMachineIDs:allowedMachineIDs honorIDMSListChanges:accountIsDemo reply:reply];
212 - (void)addAllowedMachineIDsWithContainer:(NSString *)container
213 context:(NSString *)context
214 machineIDs:(NSArray<NSString*> *)machineIDs
215 reply:(void (^)(NSError * _Nullable error))reply
221 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
222 if (i < NUM_RETRIES && [self.class retryable:error]) {
223 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
226 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
230 }] addAllowedMachineIDsWithContainer:container
232 machineIDs:machineIDs
237 - (void)removeAllowedMachineIDsWithContainer:(NSString *)container
238 context:(NSString *)context
239 machineIDs:(NSArray<NSString*> *)machineIDs
240 reply:(void (^)(NSError * _Nullable error))reply
246 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
247 if (i < NUM_RETRIES && [self.class retryable:error]) {
248 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
251 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
255 }] removeAllowedMachineIDsWithContainer:container context:context machineIDs:machineIDs reply:reply];
260 - (void)fetchAllowedMachineIDsWithContainer:(nonnull NSString *)container
261 context:(nonnull NSString *)context
262 reply:(nonnull void (^)(NSSet<NSString *> * _Nullable, NSError * _Nullable))reply {
267 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
268 if (i < NUM_RETRIES && [self.class retryable:error]) {
269 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
272 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
276 }] fetchAllowedMachineIDsWithContainer:container context:context reply:reply];
281 - (void)fetchEgoEpochWithContainer:(NSString *)container
282 context:(NSString *)context
283 reply:(void (^)(unsigned long long epoch,
284 NSError * _Nullable error))reply
290 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
291 if (i < NUM_RETRIES && [self.class retryable:error]) {
292 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
295 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
299 }] fetchEgoEpochWithContainer:container context:context reply:reply];
303 - (void)prepareWithContainer:(NSString *)container
304 context:(NSString *)context
305 epoch:(unsigned long long)epoch
306 machineID:(NSString *)machineID
307 bottleSalt:(NSString *)bottleSalt
308 bottleID:(NSString *)bottleID
309 modelID:(NSString *)modelID
310 deviceName:(nullable NSString*)deviceName
311 serialNumber:(NSString *)serialNumber
312 osVersion:(NSString *)osVersion
313 policyVersion:(nullable TPPolicyVersion *)policyVersion
314 policySecrets:(nullable NSDictionary<NSString*,NSData*> *)policySecrets
315 syncUserControllableViews:(TPPBPeerStableInfo_UserControllableViewStatus)syncUserControllableViews
316 signingPrivKeyPersistentRef:(nullable NSData *)spkPr
317 encPrivKeyPersistentRef:(nullable NSData*)epkPr
318 reply:(void (^)(NSString * _Nullable peerID,
319 NSData * _Nullable permanentInfo,
320 NSData * _Nullable permanentInfoSig,
321 NSData * _Nullable stableInfo,
322 NSData * _Nullable stableInfoSig,
323 TPSyncingPolicy* _Nullable syncingPolicy,
324 NSError * _Nullable error))reply
330 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
331 if (i < NUM_RETRIES && [self.class retryable:error]) {
332 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
335 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
336 reply(nil, nil, nil, nil, nil, nil, error);
339 }] prepareWithContainer:container
343 bottleSalt:bottleSalt
346 deviceName:deviceName
347 serialNumber:serialNumber
349 policyVersion:policyVersion
350 policySecrets:policySecrets
351 syncUserControllableViews:syncUserControllableViews
352 signingPrivKeyPersistentRef:spkPr
353 encPrivKeyPersistentRef:epkPr
358 - (void)establishWithContainer:(NSString *)container
359 context:(NSString *)context
360 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)viewKeySets
361 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
362 preapprovedKeys:(nullable NSArray<NSData*> *)preapprovedKeys
363 reply:(void (^)(NSString * _Nullable peerID,
364 NSArray<CKRecord*>* _Nullable keyHierarchyRecords,
365 TPSyncingPolicy* _Nullable syncingPolicy,
366 NSError * _Nullable error))reply
372 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
373 if (i < NUM_RETRIES && [self.class retryable:error]) {
374 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
377 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
378 reply(nil, nil, nil, error);
381 }] establishWithContainer:container context:context ckksKeys:viewKeySets tlkShares:tlkShares preapprovedKeys:preapprovedKeys reply:reply];
385 - (void)vouchWithContainer:(NSString *)container
386 context:(NSString *)context
387 peerID:(NSString *)peerID
388 permanentInfo:(NSData *)permanentInfo
389 permanentInfoSig:(NSData *)permanentInfoSig
390 stableInfo:(NSData *)stableInfo
391 stableInfoSig:(NSData *)stableInfoSig
392 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)viewKeySets
393 reply:(void (^)(NSData * _Nullable voucher,
394 NSData * _Nullable voucherSig,
395 NSError * _Nullable error))reply
401 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
402 if (i < NUM_RETRIES && [self.class retryable:error]) {
403 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
406 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
407 reply(nil, nil, error);
410 }] vouchWithContainer:container context:context peerID:peerID permanentInfo:permanentInfo permanentInfoSig:permanentInfoSig stableInfo:stableInfo stableInfoSig:stableInfoSig ckksKeys:viewKeySets reply:reply];
415 - (void)preflightVouchWithBottleWithContainer:(nonnull NSString *)container
416 context:(nonnull NSString *)context
417 bottleID:(nonnull NSString *)bottleID
418 reply:(nonnull void (^)(NSString * _Nullable,
419 TPSyncingPolicy* _Nullable peerSyncingPolicy,
420 BOOL refetchWasNeeded,
421 NSError * _Nullable))reply {
426 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
427 if (i < NUM_RETRIES && [self.class retryable:error]) {
428 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
431 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
432 reply(nil, nil, false, error);
435 }] preflightVouchWithBottleWithContainer:container
442 - (void)vouchWithBottleWithContainer:(NSString *)container
443 context:(NSString *)context
444 bottleID:(NSString*)bottleID
445 entropy:(NSData*)entropy
446 bottleSalt:(NSString*)bottleSalt
447 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
448 reply:(void (^)(NSData * _Nullable voucher,
449 NSData * _Nullable voucherSig,
450 int64_t uniqueTLKsRecovered,
451 int64_t totalTLKSharesRecovered,
452 NSError * _Nullable error))reply
458 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
459 if (i < NUM_RETRIES && [self.class retryable:error]) {
460 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
463 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
464 reply(nil, nil, 0, 0, error);
467 }] vouchWithBottleWithContainer:container context:context bottleID:bottleID entropy:entropy bottleSalt:bottleSalt tlkShares:tlkShares reply:reply];
471 - (void)preflightVouchWithRecoveryKeyWithContainer:(nonnull NSString *)container
472 context:(nonnull NSString *)context
473 recoveryKey:(NSString*)recoveryKey
475 reply:(nonnull void (^)(NSString * _Nullable,
476 TPSyncingPolicy* _Nullable peerSyncingPolicy,
477 NSError * _Nullable))reply {
482 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
483 if (i < NUM_RETRIES && [self.class retryable:error]) {
484 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
487 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
488 reply(nil, nil, error);
491 }] preflightVouchWithRecoveryKeyWithContainer:container
493 recoveryKey:recoveryKey
499 - (void)vouchWithRecoveryKeyWithContainer:(NSString *)container
500 context:(NSString *)context
501 recoveryKey:(NSString*)recoveryKey
503 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
504 reply:(void (^)(NSData * _Nullable voucher,
505 NSData * _Nullable voucherSig,
506 NSError * _Nullable error))reply
512 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
513 if (i < NUM_RETRIES && [self.class retryable:error]) {
514 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
517 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
518 reply(nil, nil, error);
521 }] vouchWithRecoveryKeyWithContainer:container context:context recoveryKey:recoveryKey salt:salt tlkShares:tlkShares reply:reply];
525 - (void)joinWithContainer:(NSString *)container
526 context:(NSString *)context
527 voucherData:(NSData *)voucherData
528 voucherSig:(NSData *)voucherSig
529 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)viewKeySets
530 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
531 preapprovedKeys:(nullable NSArray<NSData*> *)preapprovedKeys
532 reply:(void (^)(NSString * _Nullable peerID,
533 NSArray<CKRecord*>* _Nullable keyHierarchyRecords,
534 TPSyncingPolicy* _Nullable syncingPolicy,
535 NSError * _Nullable error))reply
541 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
542 if (i < NUM_RETRIES && [self.class retryable:error]) {
543 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
546 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
547 reply(nil, nil, nil, error);
550 }] joinWithContainer:container context:context voucherData:voucherData voucherSig:voucherSig ckksKeys:viewKeySets tlkShares:tlkShares preapprovedKeys:preapprovedKeys reply:reply];
554 - (void)preflightPreapprovedJoinWithContainer:(NSString *)container
555 context:(NSString *)context
556 preapprovedKeys:(nullable NSArray<NSData*> *)preapprovedKeys
557 reply:(void (^)(BOOL launchOkay,
558 NSError * _Nullable error))reply
564 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
565 if (i < NUM_RETRIES && [self.class retryable:error]) {
566 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
569 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
573 }] preflightPreapprovedJoinWithContainer:container context:context preapprovedKeys:preapprovedKeys reply:reply];
577 - (void)attemptPreapprovedJoinWithContainer:(NSString *)container
578 context:(NSString *)context
579 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)ckksKeys
580 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
581 preapprovedKeys:(nullable NSArray<NSData*> *)preapprovedKeys
582 reply:(void (^)(NSString * _Nullable peerID,
583 NSArray<CKRecord*>* _Nullable keyHierarchyRecords,
584 TPSyncingPolicy* _Nullable syncingPolicy,
585 NSError * _Nullable error))reply
591 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
592 if (i < NUM_RETRIES && [self.class retryable:error]) {
593 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
596 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
597 reply(nil, nil, nil, error);
600 }] attemptPreapprovedJoinWithContainer:container
604 preapprovedKeys:preapprovedKeys
609 - (void)updateWithContainer:(NSString *)container
610 context:(NSString *)context
611 deviceName:(nullable NSString *)deviceName
612 serialNumber:(nullable NSString *)serialNumber
613 osVersion:(nullable NSString *)osVersion
614 policyVersion:(nullable NSNumber *)policyVersion
615 policySecrets:(nullable NSDictionary<NSString*,NSData*> *)policySecrets
616 syncUserControllableViews:(nullable NSNumber *)syncUserControllableViews
617 reply:(void (^)(TrustedPeersHelperPeerState* _Nullable peerState, TPSyncingPolicy* _Nullable policy, NSError * _Nullable error))reply
623 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
624 if (i < NUM_RETRIES && [self.class retryable:error]) {
625 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
628 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
629 reply(nil, nil, error);
632 }] updateWithContainer:container
634 deviceName:deviceName
635 serialNumber:serialNumber
637 policyVersion:policyVersion
638 policySecrets:policySecrets
639 syncUserControllableViews:syncUserControllableViews
644 - (void)setPreapprovedKeysWithContainer:(NSString *)container
645 context:(NSString *)context
646 preapprovedKeys:(NSArray<NSData*> *)preapprovedKeys
647 reply:(void (^)(TrustedPeersHelperPeerState* _Nullable peerState, NSError * _Nullable error))reply
653 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
654 if (i < NUM_RETRIES && [self.class retryable:error]) {
655 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
658 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
662 }] setPreapprovedKeysWithContainer:container context:context preapprovedKeys:preapprovedKeys reply:reply];
666 - (void)updateTLKsWithContainer:(NSString *)container
667 context:(NSString *)context
668 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)ckksKeys
669 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
670 reply:(void (^)(NSArray<CKRecord*>* _Nullable keyHierarchyRecords, NSError * _Nullable error))reply
676 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
677 if (i < NUM_RETRIES && [self.class retryable:error]) {
678 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
681 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
685 }] updateTLKsWithContainer:container context:context ckksKeys:ckksKeys tlkShares:tlkShares reply:reply];
689 - (void)fetchViableBottlesWithContainer:(NSString *)container
690 context:(NSString *)context
691 reply:(void (^)(NSArray<NSString*>* _Nullable sortedBottleIDs, NSArray<NSString*>* _Nullable sortedPartialBottleIDs, NSError* _Nullable error))reply
697 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
698 if (i < NUM_RETRIES && [self.class retryable:error]) {
699 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
702 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
703 reply(nil, nil, error);
706 }] fetchViableBottlesWithContainer:container context:context reply:reply];
710 - (void)fetchEscrowContentsWithContainer:(NSString *)container
711 context:(NSString *)context
712 reply:(void (^)(NSData* _Nullable entropy,
713 NSString* _Nullable bottleID,
714 NSData* _Nullable signingPublicKey,
715 NSError* _Nullable error))reply
721 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
722 if (i < NUM_RETRIES && [self.class retryable:error]) {
723 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
726 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
727 reply(nil, nil, nil, error);
730 }] fetchEscrowContentsWithContainer:container context:context reply:reply];
734 - (void)fetchPolicyDocumentsWithContainer:(NSString*)container
735 context:(NSString*)context
736 versions:(NSSet<TPPolicyVersion*>*)versions
737 reply:(void (^)(NSDictionary<TPPolicyVersion*, NSData*>* _Nullable entries,
738 NSError * _Nullable error))reply
744 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
745 if (i < NUM_RETRIES && [self.class retryable:error]) {
746 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
749 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
753 }] fetchPolicyDocumentsWithContainer:container context:context versions:versions reply:reply];
757 - (void)fetchCurrentPolicyWithContainer:(NSString*)container
758 context:(NSString*)context
759 modelIDOverride:(NSString* _Nullable)modelIDOverride
760 reply:(void (^)(TPSyncingPolicy* _Nullable syncingPolicy,
761 TPPBPeerStableInfo_UserControllableViewStatus userControllableViewStatusOfPeers,
762 NSError * _Nullable error))reply
768 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
769 if (i < NUM_RETRIES && [self.class retryable:error]) {
770 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
773 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
775 TPPBPeerStableInfo_UserControllableViewStatus_UNKNOWN,
779 }] fetchCurrentPolicyWithContainer:container context:context modelIDOverride:modelIDOverride reply:reply];
784 - (void)validatePeersWithContainer:(NSString *)container
785 context:(NSString *)context
786 reply:(void (^)(NSDictionary * _Nullable, NSError * _Nullable))reply
792 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
793 if (i < NUM_RETRIES && [self.class retryable:error]) {
794 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
797 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
801 }] validatePeersWithContainer:container context:context reply:reply];
805 - (void)fetchTrustStateWithContainer:(NSString *)container
806 context:(NSString *)context
807 reply:(void (^)(TrustedPeersHelperPeerState* _Nullable selfPeerState,
808 NSArray<TrustedPeersHelperPeer*>* _Nullable trustedPeers,
809 NSError* _Nullable error))reply
815 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
816 if (i < NUM_RETRIES && [self.class retryable:error]) {
817 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
820 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
821 reply(nil, nil, error);
824 }] fetchTrustStateWithContainer:container context:context reply:reply];
828 - (void)setRecoveryKeyWithContainer:(NSString *)container
829 context:(NSString *)context
830 recoveryKey:(NSString *)recoveryKey
831 salt:(NSString *)salt
832 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)ckksKeys
833 reply:(void (^)(NSArray<CKRecord*>* _Nullable keyHierarchyRecords,
834 NSError* _Nullable error))reply
840 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
841 if (i < NUM_RETRIES && [self.class retryable:error]) {
842 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
845 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
849 }] setRecoveryKeyWithContainer:container context:context recoveryKey:recoveryKey salt:salt ckksKeys:ckksKeys reply:reply];
853 - (void)reportHealthWithContainer:(NSString *)container
854 context:(NSString *)context
855 stateMachineState:(NSString *)state
856 trustState:(NSString *)trustState
857 reply:(void (^)(NSError* _Nullable error))reply
863 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
864 if (i < NUM_RETRIES && [self.class retryable:error]) {
865 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
868 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
872 }] reportHealthWithContainer:container context:context stateMachineState:state trustState:trustState reply:reply];
876 - (void)pushHealthInquiryWithContainer:(NSString *)container
877 context:(NSString *)context
878 reply:(void (^)(NSError* _Nullable error))reply
884 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
885 if (i < NUM_RETRIES && [self.class retryable:error]) {
886 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
889 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
893 }] pushHealthInquiryWithContainer:container context:context reply:reply];
897 - (void)requestHealthCheckWithContainer:(NSString *)container
898 context:(NSString *)context
899 requiresEscrowCheck:(BOOL)requiresEscrowCheck
900 reply:(void (^)(BOOL postRepairCFU, BOOL postEscrowCFU, BOOL resetOctagon, BOOL leaveTrust, NSError* _Nullable))reply
906 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
907 if (i < NUM_RETRIES && [self.class retryable:error]) {
908 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
911 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
912 reply(NO, NO, NO, NO, error);
915 }] requestHealthCheckWithContainer:container context:context requiresEscrowCheck:requiresEscrowCheck reply:reply];
919 - (void)getSupportAppInfoWithContainer:(NSString *)container
920 context:(NSString *)context
921 reply:(void (^)(NSData * _Nullable, NSError * _Nullable))reply
927 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
928 if (i < NUM_RETRIES && [self.class retryable:error]) {
929 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
932 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
936 }] getSupportAppInfoWithContainer:container context:context reply:reply];
941 - (void)fetchViableEscrowRecordsWithContainer:(nonnull NSString *)container context:(nonnull NSString *)context forceFetch:(BOOL)forceFetch reply:(nonnull void (^)(NSArray<NSData *> * _Nullable, NSError * _Nullable))reply
947 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
948 if (i < NUM_RETRIES && [self.class retryable:error]) {
949 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
952 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
956 }] fetchViableEscrowRecordsWithContainer:container context:context forceFetch:forceFetch reply:reply];
960 - (void)removeEscrowCacheWithContainer:(nonnull NSString *)container context:(nonnull NSString *)context reply:(nonnull void (^)(NSError * _Nullable))reply {
965 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
966 if (i < NUM_RETRIES && [self.class retryable:error]) {
967 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
970 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
974 }] removeEscrowCacheWithContainer:container context:context reply:reply];