Skip to content

Commit 78e8add

Browse files
authored
Add Spring 2025 and fix multiple devices (#55)
* Fix M2 iPad Air, first-generation Watch, macOS OTAs, and add Spring 2025 devices
1 parent 6f8b154 commit 78e8add

File tree

1 file changed

+31
-21
lines changed

1 file changed

+31
-21
lines changed

tsschecker/tsschecker.c

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static struct bbdevice bbdevices[] = {
151151
{"Mac14,9", 0, 0}, // MacBook Pro (14-inch, M2 Pro, 2023)
152152
{"Mac14,10", 0, 0}, // MacBook Pro (16-inch, M2 Pro, 2023)
153153
{"Mac14,12", 0, 0}, // Mac mini (M2 Pro, 2023)
154-
{"Mac14,13", 0, 0}, // Mac Studio (M2 Pro, 2023)
154+
{"Mac14,13", 0, 0}, // Mac Studio (M2 Max, 2023)
155155
{"Mac14,14", 0, 0}, // Mac Studio (M2 Ultra, 2023)
156156
{"Mac14,15", 0, 0}, // MacBook Air (15-inch, M2, 2023)
157157
{"Mac15,3", 0, 0}, // MacBook Pro (14-inch, M3, Nov 2023)
@@ -275,7 +275,7 @@ static struct bbdevice bbdevices[] = {
275275
{"iPad1,1", 0, 0}, // iPad (1st gen)
276276
{"iPad2,1", 0, 0}, // iPad 2 Wi-Fi
277277
{"iPad2,2", 257, 12}, // iPad 2 GSM
278-
{"iPad2,3", 257, 12}, // iPad 2 CDMA
278+
{"iPad2,3", 2, 4}, // iPad 2 CDMA
279279
{"iPad2,4", 0, 0}, // iPad 2 Wi-Fi (2012, Rev A)
280280
{"iPad3,1", 0, 0}, // iPad (3rd gen, Wi-Fi)
281281
{"iPad3,2", 4, 4}, // iPad (3rd gen, CDMA)
@@ -330,14 +330,14 @@ static struct bbdevice bbdevices[] = {
330330
{"iPad13,16", 0, 0}, // iPad Air (5th gen, Wi-Fi)
331331
{"iPad13,17", 495958265, 4}, // iPad Air (5th gen, Cellular)
332332
{"iPad14,8", 0, 0}, // iPad Air (11-inch, M2, Wi-Fi)
333-
{"iPad14,9", 495958265, 4}, // iPad Air (11-inch, M2, Cellular)
333+
{"iPad14,9", 3452763205, 4}, // iPad Air (11-inch, M2, Cellular)
334334
{"iPad14,10", 0, 0}, // iPad Air (13-inch, M2, Wi-Fi)
335-
{"iPad14,11", 495958265, 4}, // iPad Air (13-inch, M2, Cellular)
335+
{"iPad14,11", 3452763205, 4}, // iPad Air (13-inch, M2, Cellular)
336336
{"iPad15,3", 0, 0}, // iPad Air (11-inch, M3, Wi-Fi)
337337
{"iPad15,4", 3452763205, 4}, // iPad Air (11-inch, M3, Cellular)
338338
{"iPad15,5", 0, 0}, // iPad Air (13-inch, M3, Wi-Fi)
339339
{"iPad15,6", 3452763205, 4}, // iPad Air (13-inch, M3, Cellular)
340-
340+
341341
// iPad Pros
342342
{"iPad6,3", 0, 0}, // iPad Pro (9.7-inch, Wi-Fi)
343343
{"iPad6,4", 3840149528, 4}, // iPad Pro (9.7-inch, Cellular)
@@ -988,15 +988,15 @@ void getRandNum(char *dst, size_t size, int base){
988988
}
989989

990990
#pragma mark tss functions
991-
int tss_populate_devicevals(plist_t tssreq, uint64_t ecid, char *nonce, size_t nonce_size, char *sep_nonce, size_t sep_nonce_size, int image4supported){
991+
int tss_populate_devicevals(plist_t tssreq, uint64_t ecid, char *nonce, size_t nonce_size, char *sep_nonce, size_t sep_nonce_size, int image4supported, int has_sep){
992992
plist_dict_set_item(tssreq, "ApECID", plist_new_uint(ecid)); //0000000000000000
993993
if (nonce) {
994994
plist_dict_set_item(tssreq, "ApNonce", plist_new_data((const char*)nonce, (int)nonce_size));//aa aa aa aa bb cc dd ee ff 00 11 22 33 44 55 66 77 88 99 aa
995995
} else {
996996
plist_dict_set_item(tssreq, "ApNonce", plist_new_data(NULL, 0));
997997
}
998998

999-
if (sep_nonce) {//aa aa aa aa bb cc dd ee ff 00 11 22 33 44 55 66 77 88 99 aa
999+
if (has_sep && sep_nonce) {//aa aa aa aa bb cc dd ee ff 00 11 22 33 44 55 66 77 88 99 aa
10001000
plist_dict_set_item(tssreq, "ApSepNonce", plist_new_data(sep_nonce, sep_nonce_size));
10011001
}
10021002

@@ -1080,6 +1080,9 @@ int tss_request_add_custom_cryptex_tags(plist_t request, plist_t parameters)
10801080
if ((strstr(key, "Cryptex") == 0)) {
10811081
continue;
10821082
}
1083+
if ((strstr(key, "Rap") == 0)) {
1084+
continue;
1085+
}
10831086

10841087
plist_t info_dict = plist_dict_get_item(manifest_entry, "Info");
10851088
if (!info_dict) {
@@ -1234,7 +1237,7 @@ int parseHex(const char *nonce, size_t *parsedLen, char *ret, size_t *retSize){
12341237
return 0;
12351238
}
12361239

1237-
int tss_populate_random(plist_t tssreq, int is64bit, t_devicevals *devVals){
1240+
int tss_populate_random(plist_t tssreq, int is64bit, int hasSEP, t_devicevals *devVals){
12381241
size_t nonceLen = 32; //valid for all devices with KTRR
12391242
if (!devVals->deviceModel)
12401243
return error("[TSSR] internal error: devVals->deviceModel is missing\n"),-1;
@@ -1320,23 +1323,25 @@ int tss_populate_random(plist_t tssreq, int is64bit, t_devicevals *devVals){
13201323
}
13211324
}
13221325

1323-
if (devVals->sepnonce){
1324-
if (devVals->parsedSepnonceLen != NONCELEN_SEP)
1325-
return error("[TSSR] parsed SEPNoncelen != requiredSEPNoncelen (%u != %u)",(unsigned int)devVals->parsedSepnonceLen,(unsigned int)NONCELEN_SEP),-1;
1326-
}else{
1327-
devVals->sepnonce = (char*)calloc(1, (devVals->parsedSepnonceLen = NONCELEN_SEP) +1);
1328-
getRandNum(devVals->sepnonce, devVals->parsedSepnonceLen, 256);
1326+
if (hasSEP) {
1327+
if (devVals->sepnonce){
1328+
if (devVals->parsedSepnonceLen != NONCELEN_SEP)
1329+
return error("[TSSR] parsed SEPNoncelen != requiredSEPNoncelen (%u != %u)",(unsigned int)devVals->parsedSepnonceLen,(unsigned int)NONCELEN_SEP),-1;
1330+
}else{
1331+
devVals->sepnonce = (char*)calloc(1, (devVals->parsedSepnonceLen = NONCELEN_SEP) +1);
1332+
getRandNum(devVals->sepnonce, devVals->parsedSepnonceLen, 256);
1333+
}
1334+
if (devVals->apnonce) devVals->apnonce[nonceLen] = '\0';
1335+
devVals->sepnonce[NONCELEN_SEP] = '\0';
13291336
}
1330-
if (devVals->apnonce) devVals->apnonce[nonceLen] = '\0';
1331-
devVals->sepnonce[NONCELEN_SEP] = '\0';
13321337

13331338
#ifndef TSSCHECKER_NOMAIN
13341339
debug("[TSSR] ecid=%llu\n",devVals->ecid);
13351340
debug("[TSSR] ApNonce=%s\n",devVals->apnonce);
13361341
debug("[TSSR] SepNonce=%s\n",devVals->sepnonce);
13371342
#endif
13381343

1339-
int rt = tss_populate_devicevals(tssreq, devVals->ecid, devVals->apnonce, devVals->parsedApnonceLen, devVals->sepnonce, devVals->parsedSepnonceLen, is64bit);
1344+
int rt = tss_populate_devicevals(tssreq, devVals->ecid, devVals->apnonce, devVals->parsedApnonceLen, devVals->sepnonce, devVals->parsedSepnonceLen, is64bit, hasSEP);
13401345
return rt;
13411346
}
13421347

@@ -1370,12 +1375,17 @@ int tssrequest(plist_t *tssreqret, char *buildManifest, t_devicevals *devVals, t
13701375
}
13711376
plist_t sep = plist_dict_get_item(manifestdict, "SEP");
13721377
plist_t virt = plist_dict_get_item(infodict, "VirtualMachineMinHostOS");
1373-
int is64Bit = !(!sep || plist_get_node_type(sep) != PLIST_DICT);
1378+
// macOS OTAs don't include SEP definition; hardcode them as having SEP
1379+
int hasSEP = (!(!sep || plist_get_node_type(sep) != PLIST_DICT)
1380+
|| strncasecmp(devVals->deviceModel, "Mac", strlen("Mac")) == 0
1381+
|| strncasecmp(devVals->deviceModel, "iMac", strlen("iMac")) == 0);
13741382
if(virt) {
1375-
is64Bit = plist_get_node_type(virt) == PLIST_STRING;
1383+
hasSEP = plist_get_node_type(virt) == PLIST_STRING;
13761384
}
1385+
// first-generation Apple Watch doesn't have SEP but *does* use img4
1386+
int isImg4 = (hasSEP || strncasecmp(devVals->deviceModel, "Watch1,", strlen("Watch1,")) == 0);
13771387

1378-
if (tss_populate_random(tssparameter,is64Bit,devVals))
1388+
if (tss_populate_random(tssparameter,isImg4, hasSEP, devVals))
13791389
reterror("[TSSR] failed to populate tss request\n");
13801390

13811391
tss_parameters_add_from_manifest(tssparameter, id0, true);
@@ -1387,7 +1397,7 @@ int tssrequest(plist_t *tssreqret, char *buildManifest, t_devicevals *devVals, t
13871397
reterror("[TSSR] ERROR: Unable to add common tags to TSS request\n");
13881398
}
13891399

1390-
if (is64Bit) {
1400+
if (isImg4) {
13911401
if (tss_request_add_ap_img4_tags(tssreq, tssparameter) < 0) {
13921402
reterror("[TSSR] ERROR: Unable to add img4 tags to TSS request\n");
13931403
}

0 commit comments

Comments
 (0)