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 TPPolicy *)policyVersion
314 policySecrets:(nullable NSDictionary<NSString*,NSData*> *)policySecrets
315 signingPrivKeyPersistentRef:(nullable NSData *)spkPr
316 encPrivKeyPersistentRef:(nullable NSData*)epkPr
317 reply:(void (^)(NSString * _Nullable peerID,
318 NSData * _Nullable permanentInfo,
319 NSData * _Nullable permanentInfoSig,
320 NSData * _Nullable stableInfo,
321 NSData * _Nullable stableInfoSig,
322 NSSet<NSString*>* syncingViews,
323 TPPolicy* _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, nil, error);
339 }] prepareWithContainer:container
343 bottleSalt:bottleSalt
346 deviceName:deviceName
347 serialNumber:serialNumber
349 policyVersion:policyVersion
350 policySecrets:policySecrets
351 signingPrivKeyPersistentRef:spkPr
352 encPrivKeyPersistentRef:epkPr
357 - (void)establishWithContainer:(NSString *)container
358 context:(NSString *)context
359 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)viewKeySets
360 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
361 preapprovedKeys:(nullable NSArray<NSData*> *)preapprovedKeys
362 reply:(void (^)(NSString * _Nullable peerID,
363 NSArray<CKRecord*>* _Nullable keyHierarchyRecords,
364 NSError * _Nullable error))reply
370 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
371 if (i < NUM_RETRIES && [self.class retryable:error]) {
372 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
375 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
376 reply(nil, nil, error);
379 }] establishWithContainer:container context:context ckksKeys:viewKeySets tlkShares:tlkShares preapprovedKeys:preapprovedKeys reply:reply];
383 - (void)vouchWithContainer:(NSString *)container
384 context:(NSString *)context
385 peerID:(NSString *)peerID
386 permanentInfo:(NSData *)permanentInfo
387 permanentInfoSig:(NSData *)permanentInfoSig
388 stableInfo:(NSData *)stableInfo
389 stableInfoSig:(NSData *)stableInfoSig
390 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)viewKeySets
391 reply:(void (^)(NSData * _Nullable voucher,
392 NSData * _Nullable voucherSig,
393 NSError * _Nullable error))reply
399 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
400 if (i < NUM_RETRIES && [self.class retryable:error]) {
401 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
404 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
405 reply(nil, nil, error);
408 }] vouchWithContainer:container context:context peerID:peerID permanentInfo:permanentInfo permanentInfoSig:permanentInfoSig stableInfo:stableInfo stableInfoSig:stableInfoSig ckksKeys:viewKeySets reply:reply];
413 - (void)preflightVouchWithBottleWithContainer:(nonnull NSString *)container
414 context:(nonnull NSString *)context
415 bottleID:(nonnull NSString *)bottleID
416 reply:(nonnull void (^)(NSString * _Nullable,
417 NSSet<NSString*>* _Nullable peerSyncingViewList,
418 TPPolicy * _Nullable peerSyncingPolicy,
419 NSError * _Nullable))reply {
424 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
425 if (i < NUM_RETRIES && [self.class retryable:error]) {
426 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
429 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
430 reply(nil, nil, nil, error);
433 }] preflightVouchWithBottleWithContainer:container
440 - (void)vouchWithBottleWithContainer:(NSString *)container
441 context:(NSString *)context
442 bottleID:(NSString*)bottleID
443 entropy:(NSData*)entropy
444 bottleSalt:(NSString*)bottleSalt
445 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
446 reply:(void (^)(NSData * _Nullable voucher,
447 NSData * _Nullable voucherSig,
448 int64_t uniqueTLKsRecovered,
449 int64_t totalTLKSharesRecovered,
450 NSError * _Nullable error))reply
456 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
457 if (i < NUM_RETRIES && [self.class retryable:error]) {
458 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
461 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
462 reply(nil, nil, 0, 0, error);
465 }] vouchWithBottleWithContainer:container context:context bottleID:bottleID entropy:entropy bottleSalt:bottleSalt tlkShares:tlkShares reply:reply];
469 - (void)preflightVouchWithRecoveryKeyWithContainer:(nonnull NSString *)container
470 context:(nonnull NSString *)context
471 recoveryKey:(NSString*)recoveryKey
473 reply:(nonnull void (^)(NSString * _Nullable,
474 NSSet<NSString*>* _Nullable peerSyncingViewList,
475 TPPolicy * _Nullable peerSyncingPolicy,
476 NSError * _Nullable))reply {
481 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
482 if (i < NUM_RETRIES && [self.class retryable:error]) {
483 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
486 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
487 reply(nil, nil, nil, error);
490 }] preflightVouchWithRecoveryKeyWithContainer:container
492 recoveryKey:recoveryKey
498 - (void)vouchWithRecoveryKeyWithContainer:(NSString *)container
499 context:(NSString *)context
500 recoveryKey:(NSString*)recoveryKey
502 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
503 reply:(void (^)(NSData * _Nullable voucher,
504 NSData * _Nullable voucherSig,
505 NSError * _Nullable error))reply
511 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
512 if (i < NUM_RETRIES && [self.class retryable:error]) {
513 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
516 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
517 reply(nil, nil, error);
520 }] vouchWithRecoveryKeyWithContainer:container context:context recoveryKey:recoveryKey salt:salt tlkShares:tlkShares reply:reply];
524 - (void)joinWithContainer:(NSString *)container
525 context:(NSString *)context
526 voucherData:(NSData *)voucherData
527 voucherSig:(NSData *)voucherSig
528 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)viewKeySets
529 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
530 preapprovedKeys:(NSArray<NSData*> *)preapprovedKeys
531 reply:(void (^)(NSString * _Nullable peerID,
532 NSArray<CKRecord*>* _Nullable keyHierarchyRecords,
533 NSSet<NSString*>* _Nullable viewSet,
534 TPPolicy* _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, 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 reply:(void (^)(BOOL launchOkay,
557 NSError * _Nullable error))reply
563 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
564 if (i < NUM_RETRIES && [self.class retryable:error]) {
565 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
568 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
572 }] preflightPreapprovedJoinWithContainer:container context:context reply:reply];
576 - (void)attemptPreapprovedJoinWithContainer:(NSString *)container
577 context:(NSString *)context
578 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)ckksKeys
579 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
580 preapprovedKeys:(NSArray<NSData*> *)preapprovedKeys
581 reply:(void (^)(NSString * _Nullable peerID,
582 NSArray<CKRecord*>* _Nullable keyHierarchyRecords,
583 NSSet<NSString*>* _Nullable syncingViewList,
584 TPPolicy* _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, nil, error);
600 }] attemptPreapprovedJoinWithContainer:container context:context ckksKeys:ckksKeys tlkShares:tlkShares preapprovedKeys:preapprovedKeys reply:reply];
604 - (void)updateWithContainer:(NSString *)container
605 context:(NSString *)context
606 deviceName:(nullable NSString *)deviceName
607 serialNumber:(nullable NSString *)serialNumber
608 osVersion:(nullable NSString *)osVersion
609 policyVersion:(nullable NSNumber *)policyVersion
610 policySecrets:(nullable NSDictionary<NSString*,NSData*> *)policySecrets
611 reply:(void (^)(TrustedPeersHelperPeerState* _Nullable peerState, NSError * _Nullable error))reply
617 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
618 if (i < NUM_RETRIES && [self.class retryable:error]) {
619 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
622 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
626 }] updateWithContainer:container context:context deviceName:deviceName serialNumber:serialNumber osVersion:osVersion policyVersion:policyVersion policySecrets:policySecrets reply:reply];
630 - (void)setPreapprovedKeysWithContainer:(NSString *)container
631 context:(NSString *)context
632 preapprovedKeys:(NSArray<NSData*> *)preapprovedKeys
633 reply:(void (^)(TrustedPeersHelperPeerState* _Nullable peerState, NSError * _Nullable error))reply
639 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
640 if (i < NUM_RETRIES && [self.class retryable:error]) {
641 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
644 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
648 }] setPreapprovedKeysWithContainer:container context:context preapprovedKeys:preapprovedKeys reply:reply];
652 - (void)updateTLKsWithContainer:(NSString *)container
653 context:(NSString *)context
654 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)ckksKeys
655 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
656 reply:(void (^)(NSArray<CKRecord*>* _Nullable keyHierarchyRecords, NSError * _Nullable error))reply
662 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
663 if (i < NUM_RETRIES && [self.class retryable:error]) {
664 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
667 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
671 }] updateTLKsWithContainer:container context:context ckksKeys:ckksKeys tlkShares:tlkShares reply:reply];
675 - (void)fetchViableBottlesWithContainer:(NSString *)container
676 context:(NSString *)context
677 reply:(void (^)(NSArray<NSString*>* _Nullable sortedBottleIDs, NSArray<NSString*>* _Nullable sortedPartialBottleIDs, NSError* _Nullable error))reply
683 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
684 if (i < NUM_RETRIES && [self.class retryable:error]) {
685 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
688 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
689 reply(nil, nil, error);
692 }] fetchViableBottlesWithContainer:container context:context reply:reply];
696 - (void)fetchEscrowContentsWithContainer:(NSString *)container
697 context:(NSString *)context
698 reply:(void (^)(NSData* _Nullable entropy,
699 NSString* _Nullable bottleID,
700 NSData* _Nullable signingPublicKey,
701 NSError* _Nullable error))reply
707 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
708 if (i < NUM_RETRIES && [self.class retryable:error]) {
709 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
712 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
713 reply(nil, nil, nil, error);
716 }] fetchEscrowContentsWithContainer:container context:context reply:reply];
720 - (void)fetchPolicyDocumentsWithContainer:(NSString*)container
721 context:(NSString*)context
722 versions:(NSSet<TPPolicyVersion*>*)versions
723 reply:(void (^)(NSDictionary<TPPolicyVersion*, NSData*>* _Nullable entries,
724 NSError * _Nullable error))reply
730 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
731 if (i < NUM_RETRIES && [self.class retryable:error]) {
732 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
735 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
739 }] fetchPolicyDocumentsWithContainer:container context:context versions:versions reply:reply];
743 - (void)fetchCurrentPolicyWithContainer:(NSString*)container
744 context:(NSString*)context
745 reply:(void (^)(NSSet<NSString*>* _Nullable viewList,
746 TPPolicy * _Nullable policy,
747 NSError * _Nullable error))reply
753 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
754 if (i < NUM_RETRIES && [self.class retryable:error]) {
755 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
758 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
759 reply(nil, nil, error);
762 }] fetchCurrentPolicyWithContainer:container context:context reply:reply];
767 - (void)validatePeersWithContainer:(NSString *)container
768 context:(NSString *)context
769 reply:(void (^)(NSDictionary * _Nullable, NSError * _Nullable))reply
775 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
776 if (i < NUM_RETRIES && [self.class retryable:error]) {
777 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
780 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
784 }] validatePeersWithContainer:container context:context reply:reply];
788 - (void)fetchTrustStateWithContainer:(NSString *)container
789 context:(NSString *)context
790 reply:(void (^)(TrustedPeersHelperPeerState* _Nullable selfPeerState,
791 NSArray<TrustedPeersHelperPeer*>* _Nullable trustedPeers,
792 NSError* _Nullable error))reply
798 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
799 if (i < NUM_RETRIES && [self.class retryable:error]) {
800 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
803 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
804 reply(nil, nil, error);
807 }] fetchTrustStateWithContainer:container context:context reply:reply];
811 - (void)setRecoveryKeyWithContainer:(NSString *)container
812 context:(NSString *)context
813 recoveryKey:(NSString *)recoveryKey
814 salt:(NSString *)salt
815 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)ckksKeys
816 reply:(void (^)(NSError* _Nullable error))reply
822 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
823 if (i < NUM_RETRIES && [self.class retryable:error]) {
824 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
827 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
831 }] setRecoveryKeyWithContainer:container context:context recoveryKey:recoveryKey salt:salt ckksKeys:ckksKeys reply:reply];
835 - (void)reportHealthWithContainer:(NSString *)container
836 context:(NSString *)context
837 stateMachineState:(NSString *)state
838 trustState:(NSString *)trustState
839 reply:(void (^)(NSError* _Nullable error))reply
845 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
846 if (i < NUM_RETRIES && [self.class retryable:error]) {
847 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
850 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
854 }] reportHealthWithContainer:container context:context stateMachineState:state trustState:trustState reply:reply];
858 - (void)pushHealthInquiryWithContainer:(NSString *)container
859 context:(NSString *)context
860 reply:(void (^)(NSError* _Nullable error))reply
866 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
867 if (i < NUM_RETRIES && [self.class retryable:error]) {
868 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
871 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
875 }] pushHealthInquiryWithContainer:container context:context reply:reply];
879 - (void)requestHealthCheckWithContainer:(NSString *)container
880 context:(NSString *)context
881 requiresEscrowCheck:(BOOL)requiresEscrowCheck
882 reply:(void (^)(BOOL postRepairCFU, BOOL postEscrowCFU, BOOL resetOctagon, BOOL leaveTrust, NSError* _Nullable))reply
888 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
889 if (i < NUM_RETRIES && [self.class retryable:error]) {
890 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
893 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
894 reply(NO, NO, NO, NO, error);
897 }] requestHealthCheckWithContainer:container context:context requiresEscrowCheck:requiresEscrowCheck reply:reply];
901 - (void)getSupportAppInfoWithContainer:(NSString *)container
902 context:(NSString *)context
903 reply:(void (^)(NSData * _Nullable, NSError * _Nullable))reply
909 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
910 if (i < NUM_RETRIES && [self.class retryable:error]) {
911 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
914 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
918 }] getSupportAppInfoWithContainer:container context:context reply:reply];