|
21 | 21 | #include <errno.h> |
22 | 22 |
|
23 | 23 | #include <libfragmentzip/libfragmentzip.h> |
| 24 | + |
24 | 25 | #include "download.h" |
25 | 26 | #include "debug.h" |
26 | 27 | #include "tsschecker.h" |
|
34 | 35 | #define FLAG_SAVE_CRYPTEX_NONCE (1 << 5) |
35 | 36 |
|
36 | 37 | extern int idevicerestore_debug; |
| 38 | +extern unsigned char *base64decode(const char *buf, size_t *size); |
37 | 39 | #define reterror(code,a ...) {error(a); err = code; goto error;} |
38 | 40 |
|
39 | 41 | static struct option longopts[] = { |
@@ -439,20 +441,27 @@ int main(int argc, const char * argv[]) { |
439 | 441 | if (bbinfo->bbsnumSize == 0) { |
440 | 442 | reterror(-8, "[TSSC] this device has no baseband, so it does not make sense to provide BbSNUM.\n"); |
441 | 443 | } |
442 | | - |
443 | | - if ((devVals.bbsnum = (uint8_t *)parseNonce(bbsnum, &devVals.bbsnumSize))) { |
444 | | - info("[TSSC] manually specified BbSNUM to use, parsed \"%s\" to hex:", bbsnum); |
445 | | - unsigned char *tmp = devVals.bbsnum; |
446 | | - for (int i=0; i< devVals.bbsnumSize; i++) info("%02x", *tmp++); |
447 | | - info("\n"); |
448 | | - |
449 | | - if (bbinfo->bbsnumSize != devVals.bbsnumSize) { |
450 | | - reterror(-8, "[TSSC] BbSNUM length for this device should be %d, but you gave one of length %d\n", (int)bbinfo->bbsnumSize, |
451 | | - (int)devVals.bbsnumSize); |
452 | | - } |
453 | | - } else { |
| 444 | + |
| 445 | + devVals.bbsnumSize = 100; |
| 446 | + if(!(devVals.bbsnum = (unsigned char *)base64decode(bbsnum, &devVals.bbsnumSize)) || (devVals.bbsnumSize > bbinfo->bbsnumSize) || !devVals.bbsnumSize || devVals.bbsnumSize == 100) { |
| 447 | + if (!(devVals.bbsnum = (uint8_t *)parseNonce(bbsnum, &devVals.bbsnumSize))) { |
454 | 448 | reterror(-7, "[TSSC] manually specified BbSNUM=%s, but parsing failed\n", bbsnum); |
| 449 | + } |
455 | 450 | } |
| 451 | + |
| 452 | + info("[TSSC] manually specified BbSNUM to use, parsed \"%s\" to hex:", bbsnum); |
| 453 | + unsigned char *tmp = devVals.bbsnum; |
| 454 | + for (int i=0; i< devVals.bbsnumSize; i++) info("%02x", *tmp++); |
| 455 | + info("\n"); |
| 456 | + |
| 457 | + if (bbinfo->bbsnumSize != devVals.bbsnumSize) { |
| 458 | + reterror(-8, "[TSSC] BbSNUM length for this device should be %d, but you gave one of length %d\n", (int)bbinfo->bbsnumSize, |
| 459 | + (int)devVals.bbsnumSize); |
| 460 | + } |
| 461 | + } else { |
| 462 | + if(versVals.basebandMode == kBasebandModeOnlyBaseband || versVals.basebandMode == kBasebandModeWithBaseband) { |
| 463 | + reterror(-7, "[TSSC] No Baseband Serial Number was specified, refusing to save baseband blobs\n\nPlease run ideviceinfo -k \"BasebandSerialNumber\" to get Baseband Serial Number\n"); |
| 464 | + } |
456 | 465 | } |
457 | 466 |
|
458 | 467 | if (!buildmanifest) { //no need to get firmwares/ota json if specifying buildmanifest manually |
|
0 commit comments