diff --git a/.gitignore b/.gitignore index cfc0ab5..ee5517a 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,4 @@ swig/* xcuserdata !tsschecker/*.h !tsschecker/*.c +*.zst diff --git a/tsschecker/tss.c b/tsschecker/tss.c index 8611b37..a1d3bf5 100644 --- a/tsschecker/tss.c +++ b/tsschecker/tss.c @@ -55,10 +55,10 @@ char* ecid_to_string(uint64_t ecid) return ecid_string; } -plist_t tss_request_new(plist_t overrides) { +plist_t tss_request_new(plist_t overrides) +{ plist_t request = plist_new_dict(); - plist_dict_set_item(request, "@Locality", plist_new_string("en_US")); plist_dict_set_item(request, "@HostPlatformInfo", #ifdef WIN32 plist_new_string("windows") @@ -210,6 +210,7 @@ int tss_parameters_add_from_manifest(plist_t parameters, plist_t build_identity, _plist_dict_copy_uint(parameters, build_identity, "eUICC,ChipID", NULL); + _plist_dict_copy_uint(parameters, build_identity, "NeRDEpoch", NULL); _plist_dict_copy_data(parameters, build_identity, "PearlCertificationRootPub", NULL); _plist_dict_copy_uint(parameters, build_identity, "Timer,BoardID,1", NULL); @@ -238,6 +239,11 @@ int tss_parameters_add_from_manifest(plist_t parameters, plist_t build_identity, _plist_dict_copy_item(parameters, build_identity, "Cryptex1,MobileAssetBrainVolume", NULL); _plist_dict_copy_item(parameters, build_identity, "Cryptex1,MobileAssetBrainTrustCache", NULL); + node = plist_dict_get_item(build_identity, "Info"); + if (node) { + _plist_dict_copy_bool(parameters, node, "RequiresUIDMode", NULL); + } + if (include_manifest) { /* add build identity manifest dictionary */ node = plist_dict_get_item(build_identity, "Manifest"); @@ -257,6 +263,7 @@ int tss_request_add_ap_img4_tags(plist_t request, plist_t parameters) tsserror("ERROR: Missing required AP parameters\n"); return -1; } + _plist_dict_copy_string(request, parameters, "Ap,OSLongVersion", NULL); if (_plist_dict_copy_data(request, parameters, "ApNonce", NULL) < 0) { @@ -282,8 +289,16 @@ int tss_request_add_ap_img4_tags(plist_t request, plist_t parameters) } _plist_dict_copy_data(request, parameters, "SepNonce", "ApSepNonce"); + _plist_dict_copy_uint(request, parameters, "NeRDEpoch", NULL); _plist_dict_copy_data(request, parameters, "PearlCertificationRootPub", NULL); + if (plist_dict_get_item(parameters, "UID_MODE")) { + _plist_dict_copy_item(request, parameters, "UID_MODE", NULL); + } else if (_plist_dict_get_bool(parameters, "RequiresUIDMode")) { + // The logic here is missing why this value is expected to be 'false' + plist_dict_set_item(request, "UID_MODE", plist_new_bool(0)); + } + return 0; } @@ -615,7 +630,7 @@ int tss_request_add_ap_tags(plist_t request, plist_t parameters, plist_t overrid return -1; } - /* do not populate BasebandFirmware, only in baseband request */ + /* do not populate BaseBandFirmware, only in basebaseband request */ if ((strcmp(key, "BasebandFirmware") == 0)) { continue; } @@ -659,6 +674,12 @@ int tss_request_add_ap_tags(plist_t request, plist_t parameters, plist_t overrid } } + /* skip components with IsFTAB:true */ + if (_plist_dict_get_bool(info_dict, "IsFTAB")) { + debug("DEBUG: %s: Skipping FTAB component '%s'\n", __func__, key); + continue; + } + /* copy this entry */ plist_t tss_entry = plist_copy(manifest_entry); @@ -1065,10 +1086,29 @@ int tss_request_add_vinyl_tags(plist_t request, plist_t parameters, plist_t over plist_dict_set_item(request, "@BBTicket", plist_new_bool(1)); plist_dict_set_item(request, "@eUICC,Ticket", plist_new_bool(1)); + _plist_dict_copy_bool(request, parameters, "eUICC,ApProductionMode", "ApProductionMode"); _plist_dict_copy_uint(request, parameters, "eUICC,ChipID", NULL); _plist_dict_copy_data(request, parameters, "eUICC,EID", NULL); _plist_dict_copy_data(request, parameters, "eUICC,RootKeyIdentifier", NULL); + if (!plist_dict_get_item(request, "eUICC,Gold")) { + plist_t n = plist_access_path(parameters, 2, "Manifest", "eUICC,Gold"); + if (n) { + plist_t p = plist_new_dict(); + _plist_dict_copy_data(p, n, "Digest", NULL); + plist_dict_set_item(request, "eUICC,Gold", p); + } + } + + if (!plist_dict_get_item(request, "eUICC,Main")) { + plist_t n = plist_access_path(parameters, 2, "Manifest", "eUICC,Main"); + if (n) { + plist_t p = plist_new_dict(); + _plist_dict_copy_data(p, n, "Digest", NULL); + plist_dict_set_item(request, "eUICC,Main", p); + } + } + /* set Nonce for eUICC,Gold component */ node = plist_dict_get_item(parameters, "EUICCGoldNonce"); if (node) { @@ -1372,6 +1412,44 @@ int tss_request_add_timer_tags(plist_t request, plist_t parameters, plist_t over return 0; } +int tss_request_add_cryptex_tags(plist_t request, plist_t parameters, plist_t overrides) +{ + tss_request_add_common_tags(request, parameters, NULL); + + if (plist_dict_get_item(parameters, "Ap,LocalPolicy")) { + /* Cryptex1LocalPolicy */ + tss_request_add_local_policy_tags(request, parameters); + _plist_dict_copy_data(request, parameters, "Ap,NextStageCryptex1IM4MHash", NULL); + } else { + /* Cryptex1 */ + plist_dict_set_item(request, "@Cryptex1,Ticket", plist_new_bool(1)); + + _plist_dict_copy_bool(request, parameters, "ApSecurityMode", NULL); + _plist_dict_copy_bool(request, parameters, "ApProductionMode", NULL); + + plist_dict_iter iter = NULL; + plist_dict_new_iter(parameters, &iter); + plist_t value = NULL; + while (1) { + char *key = NULL; + plist_dict_next_item(parameters, iter, &key, &value); + if (key == NULL) + break; + if (strncmp(key, "Cryptex1", 8) == 0) { + plist_dict_set_item(request, key, plist_copy(value)); + } + free(key); + } + } + + /* apply overrides */ + if (overrides) { + plist_dict_merge(&request, overrides); + } + + return 0; +} + static size_t tss_write_callback(char* data, size_t size, size_t nmemb, tss_response* response) { size_t total = size * nmemb; @@ -1385,7 +1463,8 @@ static size_t tss_write_callback(char* data, size_t size, size_t nmemb, tss_resp return total; } -plist_t tss_request_send(plist_t tss_request, const char* server_url_string) { +plist_t tss_request_send(plist_t tss_request, const char* server_url_string) +{ if (idevicerestore_debug) { debug_plist(tss_request); } @@ -1493,10 +1572,6 @@ plist_t tss_request_send(plist_t tss_request, const char* server_url_string) { } else if (status_code == 126) { // An internal error occured, most likely the request was malformed break; - /* FIXME: fully fix 128 error; now it's ignored */ - } else if (status_code == 128) { - // Error that occurs when TSS request on certain devices - break; } else { tsserror("ERROR: tss_send_request: Unhandled status code %d\n", status_code); } diff --git a/tsschecker/tss.h b/tsschecker/tss.h index 585905f..693c279 100644 --- a/tsschecker/tss.h +++ b/tsschecker/tss.h @@ -39,11 +39,12 @@ extern int print_tss_request; int tss_parameters_add_from_manifest(plist_t parameters, plist_t build_identity, bool include_manifest); /* request */ -plist_t tss_request_new_ota(plist_t overrides); plist_t tss_request_new(plist_t overrides); +int tss_request_add_local_policy_tags(plist_t request, plist_t parameters); int tss_request_add_common_tags(plist_t request, plist_t parameters, plist_t overrides); int tss_request_add_ap_tags(plist_t request, plist_t parameters, plist_t overrides); +int tss_request_add_ap_recovery_tags(plist_t request, plist_t parameters, plist_t overrides); int tss_request_add_baseband_tags(plist_t request, plist_t parameters, plist_t overrides); int tss_request_add_se_tags(plist_t request, plist_t parameters, plist_t overrides); int tss_request_add_savage_tags(plist_t request, plist_t parameters, plist_t overrides, char **component_name); @@ -51,6 +52,9 @@ int tss_request_add_yonkers_tags(plist_t request, plist_t parameters, plist_t ov int tss_request_add_vinyl_tags(plist_t request, plist_t parameters, plist_t overrides); int tss_request_add_rose_tags(plist_t request, plist_t parameters, plist_t overrides); int tss_request_add_veridian_tags(plist_t request, plist_t parameters, plist_t overrides); +int tss_request_add_tcon_tags(plist_t request, plist_t parameters, plist_t overrides); +int tss_request_add_timer_tags(plist_t request, plist_t parameters, plist_t overrides); +int tss_request_add_cryptex_tags(plist_t request, plist_t parameters, plist_t overrides); int tss_request_add_ap_img4_tags(plist_t request, plist_t parameters); int tss_request_add_ap_img3_tags(plist_t request, plist_t parameters);