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];
258 - (void)fetchEgoEpochWithContainer:(NSString *)container
259 context:(NSString *)context
260 reply:(void (^)(unsigned long long epoch,
261 NSError * _Nullable error))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 }] fetchEgoEpochWithContainer:container context:context reply:reply];
280 - (void)prepareWithContainer:(NSString *)container
281 context:(NSString *)context
282 epoch:(unsigned long long)epoch
283 machineID:(NSString *)machineID
284 bottleSalt:(NSString *)bottleSalt
285 bottleID:(NSString *)bottleID
286 modelID:(NSString *)modelID
287 deviceName:(nullable NSString*)deviceName
288 serialNumber:(NSString *)serialNumber
289 osVersion:(NSString *)osVersion
290 policyVersion:(nullable NSNumber *)policyVersion
291 policySecrets:(nullable NSDictionary<NSString*,NSData*> *)policySecrets
292 signingPrivKeyPersistentRef:(nullable NSData *)spkPr
293 encPrivKeyPersistentRef:(nullable NSData*)epkPr
294 reply:(void (^)(NSString * _Nullable peerID,
295 NSData * _Nullable permanentInfo,
296 NSData * _Nullable permanentInfoSig,
297 NSData * _Nullable stableInfo,
298 NSData * _Nullable stableInfoSig,
299 NSError * _Nullable error))reply
305 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
306 if (i < NUM_RETRIES && [self.class retryable:error]) {
307 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
310 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
311 reply(nil, nil, nil, nil, nil, error);
314 }] 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];
318 - (void)establishWithContainer:(NSString *)container
319 context:(NSString *)context
320 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)viewKeySets
321 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
322 preapprovedKeys:(nullable NSArray<NSData*> *)preapprovedKeys
323 reply:(void (^)(NSString * _Nullable peerID,
324 NSArray<CKRecord*>* _Nullable keyHierarchyRecords,
325 NSError * _Nullable error))reply
331 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
332 if (i < NUM_RETRIES && [self.class retryable:error]) {
333 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
336 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
337 reply(nil, nil, error);
340 }] establishWithContainer:container context:context ckksKeys:viewKeySets tlkShares:tlkShares preapprovedKeys:preapprovedKeys reply:reply];
344 - (void)vouchWithContainer:(NSString *)container
345 context:(NSString *)context
346 peerID:(NSString *)peerID
347 permanentInfo:(NSData *)permanentInfo
348 permanentInfoSig:(NSData *)permanentInfoSig
349 stableInfo:(NSData *)stableInfo
350 stableInfoSig:(NSData *)stableInfoSig
351 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)viewKeySets
352 reply:(void (^)(NSData * _Nullable voucher,
353 NSData * _Nullable voucherSig,
354 NSError * _Nullable error))reply
360 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
361 if (i < NUM_RETRIES && [self.class retryable:error]) {
362 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
365 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
366 reply(nil, nil, error);
369 }] vouchWithContainer:container context:context peerID:peerID permanentInfo:permanentInfo permanentInfoSig:permanentInfoSig stableInfo:stableInfo stableInfoSig:stableInfoSig ckksKeys:viewKeySets reply:reply];
374 - (void)preflightVouchWithBottleWithContainer:(nonnull NSString *)container
375 context:(nonnull NSString *)context
376 bottleID:(nonnull NSString *)bottleID
377 reply:(nonnull void (^)(NSString * _Nullable, NSError * _Nullable))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);
391 }] preflightVouchWithBottleWithContainer:container
398 - (void)vouchWithBottleWithContainer:(NSString *)container
399 context:(NSString *)context
400 bottleID:(NSString*)bottleID
401 entropy:(NSData*)entropy
402 bottleSalt:(NSString*)bottleSalt
403 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
404 reply:(void (^)(NSData * _Nullable voucher,
405 NSData * _Nullable voucherSig,
406 NSError * _Nullable error))reply
412 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
413 if (i < NUM_RETRIES && [self.class retryable:error]) {
414 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
417 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
418 reply(nil, nil, error);
421 }] vouchWithBottleWithContainer:container context:context bottleID:bottleID entropy:entropy bottleSalt:bottleSalt tlkShares:tlkShares reply:reply];
425 - (void)vouchWithRecoveryKeyWithContainer:(NSString *)container
426 context:(NSString *)context
427 recoveryKey:(NSString*)recoveryKey
429 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
430 reply:(void (^)(NSData * _Nullable voucher,
431 NSData * _Nullable voucherSig,
432 NSError * _Nullable error))reply
438 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
439 if (i < NUM_RETRIES && [self.class retryable:error]) {
440 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
443 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
444 reply(nil, nil, error);
447 }] vouchWithRecoveryKeyWithContainer:container context:context recoveryKey:recoveryKey salt:salt tlkShares:tlkShares reply:reply];
451 - (void)joinWithContainer:(NSString *)container
452 context:(NSString *)context
453 voucherData:(NSData *)voucherData
454 voucherSig:(NSData *)voucherSig
455 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)viewKeySets
456 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
457 preapprovedKeys:(NSArray<NSData*> *)preapprovedKeys
458 reply:(void (^)(NSString * _Nullable peerID,
459 NSArray<CKRecord*>* _Nullable keyHierarchyRecords,
460 NSError * _Nullable error))reply
466 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
467 if (i < NUM_RETRIES && [self.class retryable:error]) {
468 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
471 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
472 reply(nil, nil, error);
475 }] joinWithContainer:container context:context voucherData:voucherData voucherSig:voucherSig ckksKeys:viewKeySets tlkShares:tlkShares preapprovedKeys:preapprovedKeys reply:reply];
479 - (void)preflightPreapprovedJoinWithContainer:(NSString *)container
480 context:(NSString *)context
481 reply:(void (^)(BOOL launchOkay,
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);
497 }] preflightPreapprovedJoinWithContainer:container context:context reply:reply];
501 - (void)attemptPreapprovedJoinWithContainer:(NSString *)container
502 context:(NSString *)context
503 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)ckksKeys
504 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
505 preapprovedKeys:(NSArray<NSData*> *)preapprovedKeys
506 reply:(void (^)(NSString * _Nullable peerID,
507 NSArray<CKRecord*>* _Nullable keyHierarchyRecords,
508 NSError * _Nullable error))reply
514 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
515 if (i < NUM_RETRIES && [self.class retryable:error]) {
516 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
519 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
520 reply(nil, nil, error);
523 }] attemptPreapprovedJoinWithContainer:container context:context ckksKeys:ckksKeys tlkShares:tlkShares preapprovedKeys:preapprovedKeys reply:reply];
527 - (void)updateWithContainer:(NSString *)container
528 context:(NSString *)context
529 deviceName:(nullable NSString *)deviceName
530 serialNumber:(nullable NSString *)serialNumber
531 osVersion:(nullable NSString *)osVersion
532 policyVersion:(nullable NSNumber *)policyVersion
533 policySecrets:(nullable NSDictionary<NSString*,NSData*> *)policySecrets
534 reply:(void (^)(TrustedPeersHelperPeerState* _Nullable peerState, NSError * _Nullable error))reply
540 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
541 if (i < NUM_RETRIES && [self.class retryable:error]) {
542 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
545 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
549 }] updateWithContainer:container context:context deviceName:deviceName serialNumber:serialNumber osVersion:osVersion policyVersion:policyVersion policySecrets:policySecrets reply:reply];
553 - (void)setPreapprovedKeysWithContainer:(NSString *)container
554 context:(NSString *)context
555 preapprovedKeys:(NSArray<NSData*> *)preapprovedKeys
556 reply:(void (^)(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 }] setPreapprovedKeysWithContainer:container context:context preapprovedKeys:preapprovedKeys reply:reply];
575 - (void)updateTLKsWithContainer:(NSString *)container
576 context:(NSString *)context
577 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)ckksKeys
578 tlkShares:(NSArray<CKKSTLKShare*> *)tlkShares
579 reply:(void (^)(NSArray<CKRecord*>* _Nullable keyHierarchyRecords, NSError * _Nullable error))reply
585 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
586 if (i < NUM_RETRIES && [self.class retryable:error]) {
587 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
590 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
594 }] updateTLKsWithContainer:container context:context ckksKeys:ckksKeys tlkShares:tlkShares reply:reply];
598 - (void)fetchViableBottlesWithContainer:(NSString *)container
599 context:(NSString *)context
600 reply:(void (^)(NSArray<NSString*>* _Nullable sortedBottleIDs, NSArray<NSString*>* _Nullable sortedPartialBottleIDs, NSError* _Nullable error))reply
606 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
607 if (i < NUM_RETRIES && [self.class retryable:error]) {
608 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
611 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
612 reply(nil, nil, error);
615 }] fetchViableBottlesWithContainer:container context:context reply:reply];
619 - (void)fetchEscrowContentsWithContainer:(NSString *)container
620 context:(NSString *)context
621 reply:(void (^)(NSData* _Nullable entropy,
622 NSString* _Nullable bottleID,
623 NSData* _Nullable signingPublicKey,
624 NSError* _Nullable error))reply
630 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
631 if (i < NUM_RETRIES && [self.class retryable:error]) {
632 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
635 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
636 reply(nil, nil, nil, error);
639 }] fetchEscrowContentsWithContainer:container context:context reply:reply];
643 - (void)fetchPolicyDocumentsWithContainer:(NSString*)container
644 context:(NSString*)context
645 keys:(NSDictionary<NSNumber*,NSString*>*)keys
646 reply:(void (^)(NSDictionary<NSNumber*,NSArray<NSString*>*>* _Nullable entries,
647 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 }] fetchPolicyDocumentsWithContainer:container context:context keys:keys reply:reply];
666 - (void)fetchPolicyWithContainer:(NSString*)container
667 context:(NSString*)context
668 reply:(void (^)(TPPolicy * _Nullable policy,
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 }] fetchPolicyWithContainer:container context:context reply:reply];
689 - (void)validatePeersWithContainer:(NSString *)container
690 context:(NSString *)context
691 reply:(void (^)(NSDictionary * _Nullable, NSError * _Nullable))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 }] validatePeersWithContainer:container context:context reply:reply];
710 - (void)fetchTrustStateWithContainer:(NSString *)container
711 context:(NSString *)context
712 reply:(void (^)(TrustedPeersHelperPeerState* _Nullable selfPeerState,
713 NSArray<TrustedPeersHelperPeer*>* _Nullable trustedPeers,
714 NSError* _Nullable error))reply
720 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
721 if (i < NUM_RETRIES && [self.class retryable:error]) {
722 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
725 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
726 reply(nil, nil, error);
729 }] fetchTrustStateWithContainer:container context:context reply:reply];
733 - (void)setRecoveryKeyWithContainer:(NSString *)container
734 context:(NSString *)context
735 recoveryKey:(NSString *)recoveryKey
736 salt:(NSString *)salt
737 ckksKeys:(NSArray<CKKSKeychainBackedKeySet*> *)ckksKeys
738 reply:(void (^)(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 }] setRecoveryKeyWithContainer:container context:context recoveryKey:recoveryKey salt:salt ckksKeys:ckksKeys reply:reply];
757 - (void)reportHealthWithContainer:(NSString *)container
758 context:(NSString *)context
759 stateMachineState:(NSString *)state
760 trustState:(NSString *)trustState
761 reply:(void (^)(NSError* _Nullable error))reply
767 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
768 if (i < NUM_RETRIES && [self.class retryable:error]) {
769 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
772 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
776 }] reportHealthWithContainer:container context:context stateMachineState:state trustState:trustState reply:reply];
780 - (void)pushHealthInquiryWithContainer:(NSString *)container
781 context:(NSString *)context
782 reply:(void (^)(NSError* _Nullable error))reply
788 [[self.cuttlefishXPCConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError *_Nonnull error) {
789 if (i < NUM_RETRIES && [self.class retryable:error]) {
790 secnotice("octagon", "retrying cuttlefish XPC, (%d, %@)", i, error);
793 secerror("octagon: Can't talk with TrustedPeersHelper: %@", error);
797 }] pushHealthInquiryWithContainer:container context:context reply:reply];
801 - (void)getViewsWithContainer:(NSString *)container
802 context:(NSString *)context
803 inViews:(NSArray<NSString*>*)inViews
804 reply:(void (^)(NSArray<NSString*>* _Nullable, NSError* _Nullable))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 }] getViewsWithContainer:container context:context inViews:inViews reply:reply];
823 - (void)requestHealthCheckWithContainer:(NSString *)container
824 context:(NSString *)context
825 requiresEscrowCheck:(BOOL)requiresEscrowCheck
826 reply:(void (^)(BOOL postRepairCFU, BOOL postEscrowCFU, BOOL resetOctagon, 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);
838 reply(NO, NO, NO, error);
841 }] requestHealthCheckWithContainer:container context:context requiresEscrowCheck:requiresEscrowCheck reply:reply];