summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2010-07-14 04:13:37 +0200
committerGravatar Martin Szulecki2010-07-14 04:13:37 +0200
commit50c1616ff66ccb4e674405659cb2e6f8207bc915 (patch)
treee1aaa4a7c9dec9d02fc6956b2c0bc94e7b8b8471 /src
parent38b8439c0b9b4b64aae1c812da322146d0843446 (diff)
downloadidevicerestore-50c1616ff66ccb4e674405659cb2e6f8207bc915.tar.gz
idevicerestore-50c1616ff66ccb4e674405659cb2e6f8207bc915.tar.bz2
Refactor tss request requirements to work with iPhone 3G and iOS 4
This gets rid of the device model checking code and allows devices like the iPhone 3G to get shsh blobs as required by iOS 4. The requirement if the components need to be signed is determined by which kind of manifest filename is within the IPSW.
Diffstat (limited to 'src')
-rw-r--r--src/idevicerestore.c34
-rw-r--r--src/ipsw.c5
-rw-r--r--src/ipsw.h2
-rw-r--r--src/recovery.c3
4 files changed, 27 insertions, 17 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index 50e2783..32dd736 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -64,7 +64,7 @@ int main(int argc, char* argv[]) {
int optindex = 0;
char* ipsw = NULL;
char* uuid = NULL;
- uint64_t ecid = 0;
+ int tss_enabled = 0;
// create an instance of our context
struct idevicerestore_client_t* client = (struct idevicerestore_client_t*) malloc(sizeof(struct idevicerestore_client_t));
@@ -149,7 +149,7 @@ int main(int argc, char* argv[]) {
// extract buildmanifest
plist_t buildmanifest = NULL;
info("Extracting BuildManifest from IPSW\n");
- if (ipsw_extract_build_manifest(ipsw, &buildmanifest) < 0) {
+ if (ipsw_extract_build_manifest(ipsw, &buildmanifest, &tss_enabled) < 0) {
error("ERROR: Unable to extract BuildManifest from %s\n", ipsw);
return -1;
}
@@ -157,9 +157,15 @@ int main(int argc, char* argv[]) {
/* print iOS information from the manifest */
build_manifest_print_information(buildmanifest);
+ if (client->flags & FLAG_CUSTOM) {
+ /* prevent signing custom firmware */
+ tss_enabled = 0;
+ info("Custom firmware requested. Disabled TSS request.\n");
+ }
+
// devices are listed in order from oldest to newest
// so we'll need their ECID
- if (client->device->index > DEVICE_IPOD2G) {
+ if (tss_enabled) {
debug("Getting device's ECID for TSS request\n");
// fetch the device's ECID for the TSS request
if (get_ecid(client, &client->ecid) < 0) {
@@ -194,22 +200,20 @@ int main(int argc, char* argv[]) {
/* print information about current build identity */
build_identity_print_information(build_identity);
- if (client->flags & FLAG_CUSTOM > 0) {
- if (client->device->index > DEVICE_IPOD2G) {
- if (get_shsh_blobs(client, ecid, build_identity, &client->tss) < 0) {
- error("ERROR: Unable to get SHSH blobs for this device\n");
- return -1;
- }
- }
-
- /* verify if we have tss records if required */
- if ((client->device->index > DEVICE_IPOD2G) && (client->tss == NULL)) {
- error("ERROR: Unable to proceed without a tss record.\n");
- plist_free(buildmanifest);
+ if (tss_enabled) {
+ if (get_shsh_blobs(client, client->ecid, build_identity, &client->tss) < 0) {
+ error("ERROR: Unable to get SHSH blobs for this device\n");
return -1;
}
}
+ /* verify if we have tss records if required */
+ if ((tss_enabled) && (client->tss == NULL)) {
+ error("ERROR: Unable to proceed without a tss record.\n");
+ plist_free(buildmanifest);
+ return -1;
+ }
+
// Extract filesystem from IPSW and return its name
char* filesystem = NULL;
if (ipsw_extract_filesystem(client->ipsw, build_identity, &filesystem) < 0) {
diff --git a/src/ipsw.c b/src/ipsw.c
index 9cd7290..d3f8839 100644
--- a/src/ipsw.c
+++ b/src/ipsw.c
@@ -173,10 +173,12 @@ int ipsw_extract_to_memory(const char* ipsw, const char* infile, char** pbuffer,
return 0;
}
-int ipsw_extract_build_manifest(const char* ipsw, plist_t* buildmanifest) {
+int ipsw_extract_build_manifest(const char* ipsw, plist_t* buildmanifest, int *tss_enabled) {
int size = 0;
char* data = NULL;
+ *tss_enabled = 0;
+
/* older devices don't require personalized firmwares and use a BuildManifesto.plist */
if (ipsw_extract_to_memory(ipsw, "BuildManifesto.plist", &data, &size) == 0) {
plist_from_xml(data, size, buildmanifest);
@@ -188,6 +190,7 @@ int ipsw_extract_build_manifest(const char* ipsw, plist_t* buildmanifest) {
/* whereas newer devices do not require personalized firmwares and use a BuildManifest.plist */
if (ipsw_extract_to_memory(ipsw, "BuildManifest.plist", &data, &size) == 0) {
+ *tss_enabled = 1;
plist_from_xml(data, size, buildmanifest);
return 0;
}
diff --git a/src/ipsw.h b/src/ipsw.h
index f1694ef..bd8ffc4 100644
--- a/src/ipsw.h
+++ b/src/ipsw.h
@@ -38,7 +38,7 @@ typedef struct {
} ipsw_file;
int ipsw_extract_to_memory(const char* ipsw, const char* infile, char** pbuffer, uint32_t* psize);
-int ipsw_extract_build_manifest(const char* ipsw, plist_t* buildmanifest);
+int ipsw_extract_build_manifest(const char* ipsw, plist_t* buildmanifest, int *tss_enabled);
void ipsw_free_file(ipsw_file* file);
#ifdef __cplusplus
diff --git a/src/recovery.c b/src/recovery.c
index 015e9ac..28256b5 100644
--- a/src/recovery.c
+++ b/src/recovery.c
@@ -228,6 +228,9 @@ int recovery_send_component(struct idevicerestore_client_t* client, plist_t buil
info("Resetting recovery mode connection...\n");
irecv_reset(client->recovery->client);
+ if (client->tss)
+ info("%s will be signed\n", component);
+
if (ipsw_get_component_by_path(client->ipsw, client->tss, path, &data, &size) < 0) {
error("ERROR: Unable to get component: %s\n", component);
free(path);