diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0f09c6225..2ed78b15f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -320,6 +320,7 @@ if (COMPONENT_cli OR COMPONENT_dev_gui_common) add_subdirectory(external/libnetwork) add_subdirectory(libMobileGestalt) add_subdirectory(external/MITKerberosShim) + add_subdirectory(MobileKeyBag) endif() if (COMPONENT_iokitd) diff --git a/src/MobileKeyBag/CMakeLists.txt b/src/MobileKeyBag/CMakeLists.txt new file mode 100644 index 000000000..e9a0648cd --- /dev/null +++ b/src/MobileKeyBag/CMakeLists.txt @@ -0,0 +1,10 @@ +project(MobileKeyBag) + +add_darling_static_library(MobileKeyBag + SOURCES + src/MobileKeyBag.c +) + +target_include_directories(MobileKeyBag PUBLIC + include +) diff --git a/src/MobileKeyBag/include/MobileKeyBag/MobileKeyBag.h b/src/MobileKeyBag/include/MobileKeyBag/MobileKeyBag.h new file mode 100644 index 000000000..ee6148380 --- /dev/null +++ b/src/MobileKeyBag/include/MobileKeyBag/MobileKeyBag.h @@ -0,0 +1,20 @@ +#ifndef _MOBILE_KEY_BAG_H_ +#define _MOBILE_KEY_BAG_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct __MKBKeyBagHandle* MKBKeyBagHandleRef; + +int MKBKeyBagCreateWithData(CFDataRef keybagBlob, MKBKeyBagHandleRef* newHandle); +int MKBKeyBagGetAKSHandle(MKBKeyBagHandleRef keybag, int32_t* handle); +int MKBKeyBagUnlock(MKBKeyBagHandleRef keybag, CFDataRef passcode); + +#ifdef __cplusplus +} +#endif + +#endif // _MOBILE_KEY_BAG_H_ diff --git a/src/MobileKeyBag/src/MobileKeyBag.c b/src/MobileKeyBag/src/MobileKeyBag.c new file mode 100644 index 000000000..6392c6ce3 --- /dev/null +++ b/src/MobileKeyBag/src/MobileKeyBag.c @@ -0,0 +1,17 @@ +#include +#include + +int MKBKeyBagCreateWithData(CFDataRef keybagBlob, MKBKeyBagHandleRef* newHandle) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return -1; +}; + +int MKBKeyBagGetAKSHandle(MKBKeyBagHandleRef keybag, int32_t* handle) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return -1; +}; + +int MKBKeyBagUnlock(MKBKeyBagHandleRef keybag, CFDataRef passcode) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return -1; +}; diff --git a/src/frameworks/CloudKit/include/CloudKit/CKContainer.h b/src/frameworks/CloudKit/include/CloudKit/CKContainer.h index 7de85fd08..54bac64e9 100644 --- a/src/frameworks/CloudKit/include/CloudKit/CKContainer.h +++ b/src/frameworks/CloudKit/include/CloudKit/CKContainer.h @@ -21,4 +21,6 @@ @interface CKContainer : NSObject ++ (instancetype)containerWithIdentifier: (NSString*)identifier; + @end diff --git a/src/frameworks/CloudKit/include/CloudKit/CKContainer_Private.h b/src/frameworks/CloudKit/include/CloudKit/CKContainer_Private.h new file mode 100644 index 000000000..475e37547 --- /dev/null +++ b/src/frameworks/CloudKit/include/CloudKit/CKContainer_Private.h @@ -0,0 +1,28 @@ +/* + * This file is part of Darling. + * + * Copyright (C) 2023 Darling Developers + * + * Darling is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Darling is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Darling. If not, see . + */ + +#import + +typedef void (^CKContainerDeviceIDCompletionHandler)(NSString* deviceID, NSError* error); + +@interface CKContainer (Private) + +- (void)fetchCurrentDeviceIDWithCompletionHandler: (CKContainerDeviceIDCompletionHandler)completionHandler; + +@end diff --git a/src/libacm/acmstub.c b/src/libacm/acmstub.c index 0c309b687..aa81c2519 100644 --- a/src/libacm/acmstub.c +++ b/src/libacm/acmstub.c @@ -3,4 +3,14 @@ ACMContextRef ACMContextCreateWithExternalForm(const void *externalForm, size_t dataLength) { printf("STUB %s\n", __PRETTY_FUNCTION__); return NULL; -} \ No newline at end of file +} + +ACMStatus ACMContextDelete(ACMContextRef context, bool destroyContext) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return -1; +} + +ACMStatus ACMContextRemovePassphraseCredentialsByPurposeAndScope(const ACMContextRef context, ACMPassphrasePurpose purpose, ACMScope scope) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return -1; +} diff --git a/src/libaks/include/libaks.h b/src/libaks/include/libaks.h index 611a6152b..9437bb4ce 100644 --- a/src/libaks/include/libaks.h +++ b/src/libaks/include/libaks.h @@ -4,6 +4,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -63,7 +64,18 @@ enum { // i'm 99.9999999...% sure this is a typo in Security, but whatever #define kSKSReturnNoPermission kAKSReturnNoPermission -typedef int32_t keyclass_t; +typedef enum _aks_keyclass_enum { + key_class_none, + key_class_ak, + key_class_ck, + key_class_dk, + key_class_aku, + key_class_cku, + key_class_dku, + key_class_akpu, // implied to exist by some Security code (`SecDbBackupmanager.m`) + key_class_f, // ditto (`server.c` for `secd` executable) + key_class_last, +} keyclass_t; // i know it's a pointer, but it seems to be used opaquely, so not much more information // oh, it's also a CF type (deduced because it's used with `__bridge_retained` in Objective-C code) @@ -81,16 +93,10 @@ kern_return_t aks_load_bag(const void* data, int length, keybag_handle_t* handle kern_return_t aks_lock_bag(keybag_handle_t handle); typedef enum _aks_key_type_enum { - key_class_none, + key_type_none, // assuming `0` is reserved as `none` key_type_sym, - key_class_ak, - key_class_ck, - key_class_dk, - key_class_aku, - key_class_cku, - key_class_dku, - key_class_akpu, // implied to exist by some Security code (`SecDbBackupmanager.m`) - key_class_last, + key_type_asym_ec_p256, // implied to exist by some Security code (`server.c` for `secd` executable) + key_type_last, // assuming same convention as `_aks_keyclass_enum` } aks_key_type_t; // 4096-bit = 512-byte; i *think* that's the maximum key length? @@ -111,6 +117,7 @@ kern_return_t aks_generation(keybag_handle_t handle, generation_option_t option, const uint8_t * aks_ref_key_get_blob(aks_ref_key_t refkey, size_t *out_blob_len); const uint8_t * aks_ref_key_get_external_data(aks_ref_key_t refkey, size_t *out_external_data_len); +const uint8_t * aks_ref_key_get_public_key(aks_ref_key_t refkey, size_t* out_pub_key_len); int aks_ref_key_create(keybag_handle_t handle, keyclass_t key_class, aks_key_type_t type, const uint8_t *params, size_t params_len, aks_ref_key_t *ot); int aks_ref_key_create_with_blob(keybag_handle_t keybag, const uint8_t *ref_key_blob, size_t ref_key_blob_len, aks_ref_key_t* handle); @@ -125,6 +132,8 @@ kern_return_t aks_unwrap_key(const uint8_t *source, uint32_t textLength, keyclas int aks_operation_optional_params(const uint8_t * access_groups, size_t access_groups_len, const uint8_t * external_data, size_t external_data_len, const void * acm_handle, int acm_handle_len, void ** out_der, size_t * out_der_len); +bool hwaes_key_available(void); + #ifdef __cplusplus } #endif diff --git a/src/libaks/libaks.c b/src/libaks/libaks.c index c0669eb4a..e79de1c72 100644 --- a/src/libaks/libaks.c +++ b/src/libaks/libaks.c @@ -95,3 +95,73 @@ const uint8_t * aks_ref_key_get_external_data(aks_ref_key_t refkey, size_t *out_ printf("STUB %s\n", __PRETTY_FUNCTION__); return NULL; } + +kern_return_t aks_generation(keybag_handle_t handle, generation_option_t option, uint32_t* current) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return kAKSReturnError; +} + +kern_return_t aks_get_bag_uuid(keybag_handle_t handle, uuid_t uuid) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return kAKSReturnError; +} + +kern_return_t aks_lock_bag(keybag_handle_t handle) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return kAKSReturnError; +} + +int aks_operation_optional_params(const uint8_t * access_groups, size_t access_groups_len, const uint8_t * external_data, size_t external_data_len, const void * acm_handle, int acm_handle_len, void ** out_der, size_t * out_der_len) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return kAKSReturnError; +} + +int aks_ref_key_create(keybag_handle_t handle, keyclass_t key_class, aks_key_type_t type, const uint8_t *params, size_t params_len, aks_ref_key_t *ot) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return kAKSReturnError; +} + +int aks_ref_key_create_with_blob(keybag_handle_t keybag, const uint8_t *ref_key_blob, size_t ref_key_blob_len, aks_ref_key_t* handle) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return kAKSReturnError; +} + +int aks_ref_key_encrypt(aks_ref_key_t handle, const uint8_t *der_params, size_t der_params_len, const void *data, size_t data_len, void **out_der, size_t *out_der_len) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return kAKSReturnError; +} + +int aks_ref_key_decrypt(aks_ref_key_t handle, const uint8_t *der_params, size_t der_params_len, const void *data, size_t data_len, void **out_der, size_t *out_der_len) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return kAKSReturnError; +} + +int aks_ref_key_free(aks_ref_key_t* refkey) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return kAKSReturnError; +} + +int aks_ref_key_delete(aks_ref_key_t handle, const uint8_t *der_params, size_t der_params_len) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return kAKSReturnError; +} + +const uint8_t * aks_ref_key_get_public_key(aks_ref_key_t refkey, size_t* out_pub_key_len) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return NULL; +} + +kern_return_t aks_wrap_key(const uint8_t *source, uint32_t textLength, keyclass_t keyclass, keybag_handle_t keybag, uint8_t *data, int *dest_len, keyclass_t *actual_class) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return kAKSReturnError; +} + +kern_return_t aks_unwrap_key(const uint8_t *source, uint32_t textLength, keyclass_t keyclass, keybag_handle_t keybag, uint8_t *data, int *dest_len) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return kAKSReturnError; +} + +bool hwaes_key_available(void) { + printf("STUB %s\n", __PRETTY_FUNCTION__); + return false; +} diff --git a/src/private-frameworks/AuthKit/include/AuthKit/AKAccountManager.h b/src/private-frameworks/AuthKit/include/AuthKit/AKAccountManager.h index 70178f00f..779274fc7 100644 --- a/src/private-frameworks/AuthKit/include/AuthKit/AKAccountManager.h +++ b/src/private-frameworks/AuthKit/include/AuthKit/AKAccountManager.h @@ -17,6 +17,18 @@ You should have received a copy of the GNU General Public License along with Darling. If not, see . */ +#import + +#import + +typedef NS_ENUM(NSUInteger, AKAppleIDSecurityLevel) { + AKAppleIDSecurityLevelHSA2, +}; + @interface AKAccountManager : NSObject +- (NSString*)altDSIDForAccount: (ACAccount*)account; +- (ACAccount*)authKitAccountWithAltDSID: (NSString*)altDSID; +- (AKAppleIDSecurityLevel)securityLevelForAccount: (ACAccount*)account; + @end diff --git a/src/private-frameworks/AuthKit/include/AuthKit/AKAnisetteData.h b/src/private-frameworks/AuthKit/include/AuthKit/AKAnisetteData.h index 63c3ec146..c9418a1ef 100644 --- a/src/private-frameworks/AuthKit/include/AuthKit/AKAnisetteData.h +++ b/src/private-frameworks/AuthKit/include/AuthKit/AKAnisetteData.h @@ -17,6 +17,10 @@ You should have received a copy of the GNU General Public License along with Darling. If not, see . */ +#import + @interface AKAnisetteData : NSObject +@property(readonly) NSString* machineID; + @end diff --git a/src/private-frameworks/AuthKit/include/AuthKit/AKAnisetteProvisioningController.h b/src/private-frameworks/AuthKit/include/AuthKit/AKAnisetteProvisioningController.h index 6db6afc4d..46206f70d 100644 --- a/src/private-frameworks/AuthKit/include/AuthKit/AKAnisetteProvisioningController.h +++ b/src/private-frameworks/AuthKit/include/AuthKit/AKAnisetteProvisioningController.h @@ -17,6 +17,12 @@ You should have received a copy of the GNU General Public License along with Darling. If not, see . */ +#import + +#import + @interface AKAnisetteProvisioningController : NSObject +- (AKAnisetteData*)anisetteDataWithError: (NSError**)error; + @end diff --git a/src/private-frameworks/AuthKit/include/AuthKit/AKAppleIDAuthenticationController.h b/src/private-frameworks/AuthKit/include/AuthKit/AKAppleIDAuthenticationController.h index 25938b76f..ab0f48441 100644 --- a/src/private-frameworks/AuthKit/include/AuthKit/AKAppleIDAuthenticationController.h +++ b/src/private-frameworks/AuthKit/include/AuthKit/AKAppleIDAuthenticationController.h @@ -17,6 +17,13 @@ You should have received a copy of the GNU General Public License along with Darling. If not, see . */ +#import + +#import +#import + @interface AKAppleIDAuthenticationController : NSObject +- (void)fetchDeviceListWithContext: (AKDeviceListRequestContext*)context completion: (void(^)(NSArray*, NSError*))handler; + @end diff --git a/src/private-frameworks/AuthKit/include/AuthKit/AKDeviceListRequestContext.h b/src/private-frameworks/AuthKit/include/AuthKit/AKDeviceListRequestContext.h new file mode 100644 index 000000000..73c2fdfba --- /dev/null +++ b/src/private-frameworks/AuthKit/include/AuthKit/AKDeviceListRequestContext.h @@ -0,0 +1,8 @@ +#import + +@interface AKDeviceListRequestContext : NSObject + +@property(copy) NSArray* services; +@property(copy) NSString* altDSID; + +@end diff --git a/src/private-frameworks/AuthKit/include/AuthKit/AKRemoteDevice.h b/src/private-frameworks/AuthKit/include/AuthKit/AKRemoteDevice.h new file mode 100644 index 000000000..f4cdbd4d2 --- /dev/null +++ b/src/private-frameworks/AuthKit/include/AuthKit/AKRemoteDevice.h @@ -0,0 +1,8 @@ +#import + +@interface AKRemoteDevice : NSObject + +@property(readonly) NSString* machineId; +@property(readonly) NSString* serialNumber; + +@end diff --git a/src/private-frameworks/AuthKit/include/AuthKit/AuthKit.h b/src/private-frameworks/AuthKit/include/AuthKit/AuthKit.h index 8ff6a5903..5a4554f49 100644 --- a/src/private-frameworks/AuthKit/include/AuthKit/AuthKit.h +++ b/src/private-frameworks/AuthKit/include/AuthKit/AuthKit.h @@ -49,3 +49,5 @@ void* _AKTrafficLogSubsystem(void); #import #import #import +#import +#import diff --git a/src/private-frameworks/AuthKit/include/AuthKit/AuthKit_Private.h b/src/private-frameworks/AuthKit/include/AuthKit/AuthKit_Private.h new file mode 100644 index 000000000..6859e1b76 --- /dev/null +++ b/src/private-frameworks/AuthKit/include/AuthKit/AuthKit_Private.h @@ -0,0 +1 @@ +#import diff --git a/src/private-frameworks/AuthKit/src/AKDeviceListRequestContext.m b/src/private-frameworks/AuthKit/src/AKDeviceListRequestContext.m new file mode 100644 index 000000000..758b81f62 --- /dev/null +++ b/src/private-frameworks/AuthKit/src/AKDeviceListRequestContext.m @@ -0,0 +1,13 @@ +#import + +@implementation AKDeviceListRequestContext + +- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector { + return [NSMethodSignature signatureWithObjCTypes: "v@:"]; +} + +- (void)forwardInvocation:(NSInvocation *)anInvocation { + NSLog(@"Stub called: %@ in %@", NSStringFromSelector([anInvocation selector]), [self class]); +} + +@end diff --git a/src/private-frameworks/TrustedPeers/include/TrustedPeers/TPPBPeerStableInfo.h b/src/private-frameworks/TrustedPeers/include/TrustedPeers/TPPBPeerStableInfo.h index b9ac1c8ac..d8d828ea8 100644 --- a/src/private-frameworks/TrustedPeers/include/TrustedPeers/TPPBPeerStableInfo.h +++ b/src/private-frameworks/TrustedPeers/include/TrustedPeers/TPPBPeerStableInfo.h @@ -19,6 +19,10 @@ #include +@class TPPBPeerStableInfo; + +extern TPPBPeerStableInfo* const TPPBPeerStableInfo_UserControllableViewStatus_UNKNOWN; + @interface TPPBPeerStableInfo : NSObject @end diff --git a/src/private-frameworks/TrustedPeers/include/TrustedPeers/TPPolicy.h b/src/private-frameworks/TrustedPeers/include/TrustedPeers/TPPolicy.h index de304f2d6..4daccbabd 100644 --- a/src/private-frameworks/TrustedPeers/include/TrustedPeers/TPPolicy.h +++ b/src/private-frameworks/TrustedPeers/include/TrustedPeers/TPPolicy.h @@ -19,6 +19,18 @@ #include +#import + +@class TPSyncingPolicy; + @interface TPPolicy : NSObject +- (TPSyncingPolicy*)syncingPolicyForModel: (NSString*)model syncUserControllableViews: (TPPBPeerStableInfo*)stableInfo error: (NSError**)error; + +@end + +@interface TPSyncingPolicy : TPPolicy + +- (NSString*)mapDictionaryToView: (NSDictionary*)dictionary; + @end diff --git a/src/private-frameworks/TrustedPeers/include/TrustedPeers/TPPolicyDocument.h b/src/private-frameworks/TrustedPeers/include/TrustedPeers/TPPolicyDocument.h index 2d0f8b46a..c3efbe171 100644 --- a/src/private-frameworks/TrustedPeers/include/TrustedPeers/TPPolicyDocument.h +++ b/src/private-frameworks/TrustedPeers/include/TrustedPeers/TPPolicyDocument.h @@ -19,6 +19,12 @@ #include +#import + @interface TPPolicyDocument : NSObject ++ (instancetype)policyDocWithHash: (NSString*)hash data: (NSData*)data; + +- (TPPolicy*)policyWithSecrets: (NSDictionary*)secrets decrypter: (id)decrypter error: (NSError**)error; + @end diff --git a/src/private-frameworks/TrustedPeers/src/TPPBPeerStableInfo.m b/src/private-frameworks/TrustedPeers/src/TPPBPeerStableInfo.m index 017e6bb59..acf1a06d9 100644 --- a/src/private-frameworks/TrustedPeers/src/TPPBPeerStableInfo.m +++ b/src/private-frameworks/TrustedPeers/src/TPPBPeerStableInfo.m @@ -19,6 +19,8 @@ #import +TPPBPeerStableInfo* const TPPBPeerStableInfo_UserControllableViewStatus_UNKNOWN = nil; + @implementation TPPBPeerStableInfo - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector diff --git a/src/private-frameworks/TrustedPeers/src/TPPolicy.m b/src/private-frameworks/TrustedPeers/src/TPPolicy.m index 794a0ec9e..c30b11ec8 100644 --- a/src/private-frameworks/TrustedPeers/src/TPPolicy.m +++ b/src/private-frameworks/TrustedPeers/src/TPPolicy.m @@ -32,3 +32,17 @@ } @end + +@implementation TPSyncingPolicy + +- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector +{ + return [NSMethodSignature signatureWithObjCTypes: "v@:"]; +} + +- (void)forwardInvocation:(NSInvocation *)anInvocation +{ + NSLog(@"Stub called: %@ in %@", NSStringFromSelector([anInvocation selector]), [self class]); +} + +@end diff --git a/src/private-frameworks/login/functions.c b/src/private-frameworks/login/functions.c index 6b37ae648..5d286d997 100644 --- a/src/private-frameworks/login/functions.c +++ b/src/private-frameworks/login/functions.c @@ -19,6 +19,9 @@ along with Darling. If not, see . #include +// arbitrary guess +const char* kSA_SessionStateChangedNotification = "SA_SessionStateChangedNotification"; + void CFXPCRelease(void) { } void CreateArgumentsForFunction(void) { } void GetSessionAgentClient(void) { } diff --git a/src/private-frameworks/login/include/login/SessionAgentStatusCom.h b/src/private-frameworks/login/include/login/SessionAgentStatusCom.h index 28a9e5856..02d342d65 100644 --- a/src/private-frameworks/login/include/login/SessionAgentStatusCom.h +++ b/src/private-frameworks/login/include/login/SessionAgentStatusCom.h @@ -3,7 +3,10 @@ typedef int SessionAgentState; +extern const char* kSA_SessionStateChangedNotification; + #define kSA_state_desktopshowing 1 +#define kSA_state_loggingout_pointofnoreturn 2 /* arbitrary guess */ SessionAgentState SASSessionStateForUser(int uid); diff --git a/src/softlinking/include/SoftLinking/SoftLinking.h b/src/softlinking/include/SoftLinking/SoftLinking.h index 27235bdda..b4ef222f7 100644 --- a/src/softlinking/include/SoftLinking/SoftLinking.h +++ b/src/softlinking/include/SoftLinking/SoftLinking.h @@ -7,6 +7,7 @@ #import #import #import +#include // certain aspects of this file (such as framework, function, and constant loading) // can be implemented in plain C, but because it can also load Objective-C classes, @@ -67,12 +68,12 @@ #define SOFT_LINK_CONSTANT(_framework, _name, _type) \ static _type get ## _name () { \ - static _type* constant = NULL; \ + static _type const* constant = NULL; \ static dispatch_once_t once_handle; \ dispatch_once(&once_handle, ^{ \ CFBundleRef bundle = softlink_get_cfbundle_ ## _framework (); \ if (bundle) \ - constant = CFBundleGetDataPointerForName(bundle, SOFT_LINK_CFSTRINGIFY(_name)); \ + constant = (_type const*)CFBundleGetDataPointerForName(bundle, SOFT_LINK_CFSTRINGIFY(_name)); \ }); \ /* i'm not sure what to do if the symbol can't be found since