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 reply:(void (^)(BOOL listDifferences, NSError * _Nullable error))reply
198 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
199 if (i < NUM_RETRIES && [self.class retryable:error]) {
200 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
203 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
207 }] setAllowedMachineIDsWithContainer:container context:context allowedMachineIDs:allowedMachineIDs reply:reply];
211 - (void)addAllowedMachineIDsWithContainer:(NSString *)container
212 context:(NSString *)context
213 machineIDs:(NSArray<NSString*> *)machineIDs
214 reply:(void (^)(NSError * _Nullable error))reply
220 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
221 if (i < NUM_RETRIES && [self.class retryable:error]) {
222 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
225 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
229 }] addAllowedMachineIDsWithContainer:container
231 machineIDs:machineIDs
236 - (void)removeAllowedMachineIDsWithContainer:(NSString *)container
237 context:(NSString *)context
238 machineIDs:(NSArray<NSString*> *)machineIDs
239 reply:(void (^)(NSError * _Nullable error))reply
245 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
246 if (i < NUM_RETRIES && [self.class retryable:error]) {
247 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
250 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
254 }] removeAllowedMachineIDsWithContainer:container context:context machineIDs:machineIDs reply:reply];
259 - (void)fetchAllowedMachineIDsWithContainer:(nonnull NSString *)container
260 context:(nonnull NSString *)context
261 reply:(nonnull void (^)(NSSet<NSString *> * _Nullable, NSError * _Nullable))reply {
266 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
267 if (i < NUM_RETRIES && [self.class retryable:error]) {
268 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
271 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
275 }] fetchAllowedMachineIDsWithContainer:container context:context reply:reply];
280 - (void)fetchEgoEpochWithContainer:(NSString *)container
281 context:(NSString *)context
282 reply:(void (^)(unsigned long long epoch,
283 NSError * _Nullable error))reply
289 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
290 if (i < NUM_RETRIES && [self.class retryable:error]) {
291 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
294 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
298 }] fetchEgoEpochWithContainer:container context:context reply:reply];
302 - (void)prepareWithContainer:(NSString *)container
303 context:(NSString *)context
304 epoch:(unsigned long long)epoch
305 machineID:(NSString *)machineID
306 bottleSalt:(NSString *)bottleSalt
307 bottleID:(NSString *)bottleID
308 modelID:(NSString *)modelID
309 deviceName:(nullable NSString*)deviceName
310 serialNumber:(NSString *)serialNumber
311 osVersion:(NSString *)osVersion
312 policyVersion:(nullable NSNumber *)policyVersion
313 policySecrets:(nullable NSDictionary<NSString*,NSData*> *)policySecrets
314 signingPrivKeyPersistentRef:(nullable NSData *)spkPr
315 encPrivKeyPersistentRef:(nullable NSData*)epkPr
316 reply:(void (^)(NSString * _Nullable peerID,
317 NSData * _Nullable permanentInfo,
318 NSData * _Nullable permanentInfoSig,
319 NSData * _Nullable stableInfo,
320 NSData * _Nullable stableInfoSig,
321 NSError * _Nullable error))reply
327 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
328 if (i < NUM_RETRIES && [self.class retryable:error]) {
329 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
332 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
333 reply(nil, nil, nil, nil, nil, error);
336 }] prepareWithContainer:container context:context epoch:epoch machineID:machineID bottleSalt:bottleSalt bottleID:bottleID modelID:modelID deviceName:deviceName serialNumber:serialNumber osVersion:osVersion policyVersion:policyVersion policySecrets:policySecrets signingPrivKeyPersistentRef:spkPr encPrivKeyPersistentRef:epkPr reply:reply];
340 - (void)establishWithContainer:(NSString *)container
341 context:(NSString *)context
342 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)viewKeySets
343 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
344 preapprovedKeys:(nullable NSArray<NSData*> *)preapprovedKeys
345 reply:(void (^)(NSString * _Nullable peerID,
346 NSArray<CKRecord*>* _Nullable keyHierarchyRecords,
347 NSError * _Nullable error))reply
353 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
354 if (i < NUM_RETRIES && [self.class retryable:error]) {
355 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
358 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
359 reply(nil, nil, error);
362 }] establishWithContainer:container context:context ckksKeys:viewKeySets tlkShares:tlkShares preapprovedKeys:preapprovedKeys reply:reply];
366 - (void)vouchWithContainer:(NSString *)container
367 context:(NSString *)context
368 peerID:(NSString *)peerID
369 permanentInfo:(NSData *)permanentInfo
370 permanentInfoSig:(NSData *)permanentInfoSig
371 stableInfo:(NSData *)stableInfo
372 stableInfoSig:(NSData *)stableInfoSig
373 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)viewKeySets
374 reply:(void (^)(NSData * _Nullable voucher,
375 NSData * _Nullable voucherSig,
376 NSError * _Nullable error))reply
382 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
383 if (i < NUM_RETRIES && [self.class retryable:error]) {
384 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
387 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
388 reply(nil, nil, error);
391 }] vouchWithContainer:container context:context peerID:peerID permanentInfo:permanentInfo permanentInfoSig:permanentInfoSig stableInfo:stableInfo stableInfoSig:stableInfoSig ckksKeys:viewKeySets reply:reply];
396 - (void)preflightVouchWithBottleWithContainer:(nonnull NSString *)container
397 context:(nonnull NSString *)context
398 bottleID:(nonnull NSString *)bottleID
399 reply:(nonnull void (^)(NSString * _Nullable, NSError * _Nullable))reply {
404 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
405 if (i < NUM_RETRIES && [self.class retryable:error]) {
406 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
409 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
413 }] preflightVouchWithBottleWithContainer:container
420 - (void)vouchWithBottleWithContainer:(NSString *)container
421 context:(NSString *)context
422 bottleID:(NSString*)bottleID
423 entropy:(NSData*)entropy
424 bottleSalt:(NSString*)bottleSalt
425 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
426 reply:(void (^)(NSData * _Nullable voucher,
427 NSData * _Nullable voucherSig,
428 NSError * _Nullable error))reply
434 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
435 if (i < NUM_RETRIES && [self.class retryable:error]) {
436 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
439 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
440 reply(nil, nil, error);
443 }] vouchWithBottleWithContainer:container context:context bottleID:bottleID entropy:entropy bottleSalt:bottleSalt tlkShares:tlkShares reply:reply];
447 - (void)vouchWithRecoveryKeyWithContainer:(NSString *)container
448 context:(NSString *)context
449 recoveryKey:(NSString*)recoveryKey
451 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
452 reply:(void (^)(NSData * _Nullable voucher,
453 NSData * _Nullable voucherSig,
454 NSError * _Nullable error))reply
460 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
461 if (i < NUM_RETRIES && [self.class retryable:error]) {
462 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
465 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
466 reply(nil, nil, error);
469 }] vouchWithRecoveryKeyWithContainer:container context:context recoveryKey:recoveryKey salt:salt tlkShares:tlkShares reply:reply];
473 - (void)joinWithContainer:(NSString *)container
474 context:(NSString *)context
475 voucherData:(NSData *)voucherData
476 voucherSig:(NSData *)voucherSig
477 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)viewKeySets
478 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
479 preapprovedKeys:(NSArray<NSData*> *)preapprovedKeys
480 reply:(void (^)(NSString * _Nullable peerID,
481 NSArray<CKRecord*>* _Nullable keyHierarchyRecords,
482 NSError * _Nullable error))reply
488 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
489 if (i < NUM_RETRIES && [self.class retryable:error]) {
490 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
493 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
494 reply(nil, nil, error);
497 }] joinWithContainer:container context:context voucherData:voucherData voucherSig:voucherSig ckksKeys:viewKeySets tlkShares:tlkShares preapprovedKeys:preapprovedKeys reply:reply];
501 - (void)preflightPreapprovedJoinWithContainer:(NSString *)container
502 context:(NSString *)context
503 reply:(void (^)(BOOL launchOkay,
504 NSError * _Nullable error))reply
510 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
511 if (i < NUM_RETRIES && [self.class retryable:error]) {
512 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
515 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
519 }] preflightPreapprovedJoinWithContainer:container context:context reply:reply];
523 - (void)attemptPreapprovedJoinWithContainer:(NSString *)container
524 context:(NSString *)context
525 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)ckksKeys
526 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
527 preapprovedKeys:(NSArray<NSData*> *)preapprovedKeys
528 reply:(void (^)(NSString * _Nullable peerID,
529 NSArray<CKRecord*>* _Nullable keyHierarchyRecords,
530 NSError * _Nullable error))reply
536 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
537 if (i < NUM_RETRIES && [self.class retryable:error]) {
538 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
541 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
542 reply(nil, nil, error);
545 }] attemptPreapprovedJoinWithContainer:container context:context ckksKeys:ckksKeys tlkShares:tlkShares preapprovedKeys:preapprovedKeys reply:reply];
549 - (void)updateWithContainer:(NSString *)container
550 context:(NSString *)context
551 deviceName:(nullable NSString *)deviceName
552 serialNumber:(nullable NSString *)serialNumber
553 osVersion:(nullable NSString *)osVersion
554 policyVersion:(nullable NSNumber *)policyVersion
555 policySecrets:(nullable NSDictionary<NSString*,NSData*> *)policySecrets
556 reply:(void (^)(TrustedPeersHelperPeerState* _Nullable peerState, NSError * _Nullable error))reply
562 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
563 if (i < NUM_RETRIES && [self.class retryable:error]) {
564 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
567 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
571 }] updateWithContainer:container context:context deviceName:deviceName serialNumber:serialNumber osVersion:osVersion policyVersion:policyVersion policySecrets:policySecrets reply:reply];
575 - (void)setPreapprovedKeysWithContainer:(NSString *)container
576 context:(NSString *)context
577 preapprovedKeys:(NSArray<NSData*> *)preapprovedKeys
578 reply:(void (^)(NSError * _Nullable error))reply
584 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
585 if (i < NUM_RETRIES && [self.class retryable:error]) {
586 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
589 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
593 }] setPreapprovedKeysWithContainer:container context:context preapprovedKeys:preapprovedKeys reply:reply];
597 - (void)updateTLKsWithContainer:(NSString *)container
598 context:(NSString *)context
599 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)ckksKeys
600 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
601 reply:(void (^)(NSArray<CKRecord*>* _Nullable keyHierarchyRecords, NSError * _Nullable error))reply
607 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
608 if (i < NUM_RETRIES && [self.class retryable:error]) {
609 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
612 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
616 }] updateTLKsWithContainer:container context:context ckksKeys:ckksKeys tlkShares:tlkShares reply:reply];
620 - (void)fetchViableBottlesWithContainer:(NSString *)container
621 context:(NSString *)context
622 reply:(void (^)(NSArray<NSString*>* _Nullable sortedBottleIDs, NSArray<NSString*>* _Nullable sortedPartialBottleIDs, NSError* _Nullable error))reply
628 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
629 if (i < NUM_RETRIES && [self.class retryable:error]) {
630 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
633 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
634 reply(nil, nil, error);
637 }] fetchViableBottlesWithContainer:container context:context reply:reply];
641 - (void)fetchEscrowContentsWithContainer:(NSString *)container
642 context:(NSString *)context
643 reply:(void (^)(NSData* _Nullable entropy,
644 NSString* _Nullable bottleID,
645 NSData* _Nullable signingPublicKey,
646 NSError* _Nullable error))reply
652 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
653 if (i < NUM_RETRIES && [self.class retryable:error]) {
654 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
657 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
658 reply(nil, nil, nil, error);
661 }] fetchEscrowContentsWithContainer:container context:context reply:reply];
665 - (void)fetchPolicyDocumentsWithContainer:(NSString*)container
666 context:(NSString*)context
667 keys:(NSDictionary<NSNumber*,NSString*>*)keys
668 reply:(void (^)(NSDictionary<NSNumber*,NSArray<NSString*>*>* _Nullable entries,
669 NSError * _Nullable error))reply
675 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
676 if (i < NUM_RETRIES && [self.class retryable:error]) {
677 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
680 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
684 }] fetchPolicyDocumentsWithContainer:container context:context keys:keys reply:reply];
688 - (void)fetchPolicyWithContainer:(NSString*)container
689 context:(NSString*)context
690 reply:(void (^)(TPPolicy * _Nullable policy,
691 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);
706 }] fetchPolicyWithContainer:container context:context reply:reply];
711 - (void)validatePeersWithContainer:(NSString *)container
712 context:(NSString *)context
713 reply:(void (^)(NSDictionary * _Nullable, NSError * _Nullable))reply
719 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
720 if (i < NUM_RETRIES && [self.class retryable:error]) {
721 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
724 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
728 }] validatePeersWithContainer:container context:context reply:reply];
732 - (void)fetchTrustStateWithContainer:(NSString *)container
733 context:(NSString *)context
734 reply:(void (^)(TrustedPeersHelperPeerState* _Nullable selfPeerState,
735 NSArray<TrustedPeersHelperPeer*>* _Nullable trustedPeers,
736 NSError* _Nullable error))reply
742 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
743 if (i < NUM_RETRIES && [self.class retryable:error]) {
744 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
747 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
748 reply(nil, nil, error);
751 }] fetchTrustStateWithContainer:container context:context reply:reply];
755 - (void)setRecoveryKeyWithContainer:(NSString *)container
756 context:(NSString *)context
757 recoveryKey:(NSString *)recoveryKey
758 salt:(NSString *)salt
759 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)ckksKeys
760 reply:(void (^)(NSError* _Nullable error))reply
766 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
767 if (i < NUM_RETRIES && [self.class retryable:error]) {
768 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
771 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
775 }] setRecoveryKeyWithContainer:container context:context recoveryKey:recoveryKey salt:salt ckksKeys:ckksKeys reply:reply];
779 - (void)reportHealthWithContainer:(NSString *)container
780 context:(NSString *)context
781 stateMachineState:(NSString *)state
782 trustState:(NSString *)trustState
783 reply:(void (^)(NSError* _Nullable error))reply
789 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
790 if (i < NUM_RETRIES && [self.class retryable:error]) {
791 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
794 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
798 }] reportHealthWithContainer:container context:context stateMachineState:state trustState:trustState reply:reply];
802 - (void)pushHealthInquiryWithContainer:(NSString *)container
803 context:(NSString *)context
804 reply:(void (^)(NSError* _Nullable error))reply
810 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
811 if (i < NUM_RETRIES && [self.class retryable:error]) {
812 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
815 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
819 }] pushHealthInquiryWithContainer:container context:context reply:reply];
823 - (void)getViewsWithContainer:(NSString *)container
824 context:(NSString *)context
825 inViews:(NSArray<NSString*>*)inViews
826 reply:(void (^)(NSArray<NSString*>* _Nullable, NSError* _Nullable))reply
832 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
833 if (i < NUM_RETRIES && [self.class retryable:error]) {
834 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
837 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
841 }] getViewsWithContainer:container context:context inViews:inViews reply:reply];
845 - (void)requestHealthCheckWithContainer:(NSString *)container
846 context:(NSString *)context
847 requiresEscrowCheck:(BOOL)requiresEscrowCheck
848 reply:(void (^)(BOOL postRepairCFU, BOOL postEscrowCFU, BOOL resetOctagon, NSError* _Nullable))reply
854 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
855 if (i < NUM_RETRIES && [self.class retryable:error]) {
856 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
859 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
860 reply(NO, NO, NO, error);
863 }] requestHealthCheckWithContainer:container context:context requiresEscrowCheck:requiresEscrowCheck reply:reply];
867 - (void)getSupportAppInfoWithContainer:(NSString *)container
868 context:(NSString *)context
869 reply:(void (^)(NSData * _Nullable, NSError * _Nullable))reply
875 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
876 if (i < NUM_RETRIES && [self.class retryable:error]) {
877 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
880 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
884 }] getSupportAppInfoWithContainer:container context:context reply:reply];