summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-11-19 21:37:42 +0100
committerGravatar Nikias Bassen2013-11-19 21:37:42 +0100
commitaee53bef0385841109432948dbf814907a7d2dca (patch)
tree456df2f3f4ca8dda60ca93e36eeb75a7dfa8a658
parent38e6975e2131b526d402c6f95cf4ba4acfbd997c (diff)
downloadidevicerestore-aee53bef0385841109432948dbf814907a7d2dca.tar.gz
idevicerestore-aee53bef0385841109432948dbf814907a7d2dca.tar.bz2
removed unused get_cpid/get_bdid and adapted for latest libirecovery changes
-rw-r--r--src/dfu.c33
-rw-r--r--src/idevicerestore.c50
-rw-r--r--src/idevicerestore.h4
-rw-r--r--src/normal.c8
-rw-r--r--src/normal.h2
-rw-r--r--src/recovery.c60
-rw-r--r--src/recovery.h2
7 files changed, 50 insertions, 109 deletions
diff --git a/src/dfu.c b/src/dfu.c
index 5cea9ad..df9379e 100644
--- a/src/dfu.c
+++ b/src/dfu.c
@@ -231,11 +231,13 @@ int dfu_get_cpid(struct idevicerestore_client_t* client, unsigned int* cpid) {
}
}
- dfu_error = irecv_get_cpid(client->dfu->client, cpid);
- if (dfu_error != IRECV_E_SUCCESS) {
+ const struct irecv_device_info *device_info = irecv_get_device_info(client->dfu->client);
+ if (!device_info) {
return -1;
}
+ *cpid = device_info->cpid;
+
return 0;
}
@@ -248,11 +250,21 @@ int dfu_get_ap_nonce(struct idevicerestore_client_t* client, unsigned char** non
}
}
- dfu_error = irecv_get_nonce_with_tag(client->dfu->client, "NONC", nonce, nonce_size);
- if (dfu_error != IRECV_E_SUCCESS) {
+
+ const struct irecv_device_info *device_info = irecv_get_device_info(client->dfu->client);
+ if (!device_info) {
return -1;
}
+ if (device_info->ap_nonce && device_info->ap_nonce_size > 0) {
+ *nonce = (unsigned char*)malloc(device_info->ap_nonce_size);
+ if (!*nonce) {
+ return -1;
+ }
+ *nonce_size = device_info->ap_nonce_size;
+ memcpy(*nonce, device_info->ap_nonce, *nonce_size);
+ }
+
return 0;
}
@@ -265,11 +277,20 @@ int dfu_get_sep_nonce(struct idevicerestore_client_t* client, unsigned char** no
}
}
- dfu_error = irecv_get_nonce_with_tag(client->dfu->client, "SNON", nonce, nonce_size);
- if (dfu_error != IRECV_E_SUCCESS) {
+ const struct irecv_device_info *device_info = irecv_get_device_info(client->dfu->client);
+ if (!device_info) {
return -1;
}
+ if (device_info->sep_nonce && device_info->sep_nonce_size > 0) {
+ *nonce = (unsigned char*)malloc(device_info->sep_nonce_size);
+ if (!*nonce) {
+ return -1;
+ }
+ *nonce_size = device_info->sep_nonce_size;
+ memcpy(*nonce, device_info->sep_nonce, *nonce_size);
+ }
+
return 0;
}
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index 9bf37e0..e9580bd 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -1182,56 +1182,6 @@ const char* check_product_type(struct idevicerestore_client_t* client) {
return product_type;
}
-int get_bdid(struct idevicerestore_client_t* client, uint32_t* bdid) {
- switch (client->mode->index) {
- case MODE_NORMAL:
- if (normal_get_bdid(client, bdid) < 0) {
- *bdid = 0;
- return -1;
- }
- break;
-
- case MODE_DFU:
- case MODE_RECOVERY:
- if (recovery_get_bdid(client, bdid) < 0) {
- *bdid = 0;
- return -1;
- }
- break;
-
- default:
- error("ERROR: Device is in an invalid state\n");
- return -1;
- }
-
- return 0;
-}
-
-int get_cpid(struct idevicerestore_client_t* client, uint32_t* cpid) {
- switch (client->mode->index) {
- case MODE_NORMAL:
- if (normal_get_cpid(client, cpid) < 0) {
- client->device->chip_id = -1;
- return -1;
- }
- break;
-
- case MODE_DFU:
- case MODE_RECOVERY:
- if (recovery_get_cpid(client, cpid) < 0) {
- client->device->chip_id = -1;
- return -1;
- }
- break;
-
- default:
- error("ERROR: Device is in an invalid state\n");
- return -1;
- }
-
- return 0;
-}
-
int get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid) {
switch (client->mode->index) {
case MODE_NORMAL:
diff --git a/src/idevicerestore.h b/src/idevicerestore.h
index e289ed0..c7ac7f9 100644
--- a/src/idevicerestore.h
+++ b/src/idevicerestore.h
@@ -75,9 +75,7 @@ void usage(int argc, char* argv[]);
int check_mode(struct idevicerestore_client_t* client);
const char* check_product_type(struct idevicerestore_client_t* client);
int get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid);
-int get_bdid(struct idevicerestore_client_t* client, uint32_t* bdid);
-int get_cpid(struct idevicerestore_client_t* client, uint32_t* cpid);
-int get_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size);
+int get_ap_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size);
int get_shsh_blobs(struct idevicerestore_client_t* client, plist_t build_identity, plist_t* tss);
void fixup_tss(plist_t tss);
int build_manifest_get_identity_count(plist_t build_manifest);
diff --git a/src/normal.c b/src/normal.c
index 64c6526..15bbc01 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -391,14 +391,6 @@ int normal_get_ap_nonce(struct idevicerestore_client_t* client, unsigned char**
return normal_get_nonce_by_key(client, "SEPNonce", nonce, nonce_size);
}
-int normal_get_cpid(struct idevicerestore_client_t* client, uint32_t* cpid) {
- return 0;
-}
-
-int normal_get_bdid(struct idevicerestore_client_t* client, uint32_t* bdid) {
- return 0;
-}
-
int normal_get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid) {
idevice_t device = NULL;
plist_t unique_chip_node = NULL;
diff --git a/src/normal.h b/src/normal.h
index cbbac2b..892747a 100644
--- a/src/normal.h
+++ b/src/normal.h
@@ -46,8 +46,6 @@ int normal_client_new(struct idevicerestore_client_t* client);
void normal_client_free(struct idevicerestore_client_t* client);
int normal_open_with_timeout(struct idevicerestore_client_t* client);
int normal_enter_recovery(struct idevicerestore_client_t* client);
-int normal_get_cpid(struct idevicerestore_client_t* client, uint32_t* cpid);
-int normal_get_bdid(struct idevicerestore_client_t* client, uint32_t* bdid);
int normal_get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid);
int normal_get_ap_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size);
int normal_get_sep_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size);
diff --git a/src/recovery.c b/src/recovery.c
index 42bb234..f2104b7 100644
--- a/src/recovery.c
+++ b/src/recovery.c
@@ -86,11 +86,9 @@ int recovery_client_new(struct idevicerestore_client_t* client) {
}
if (client->srnm == NULL) {
- char snbuf[256];
- snbuf[0] = '\0';
- irecv_get_srnm(recovery, snbuf);
- if (snbuf[0] != '\0') {
- client->srnm = strdup(snbuf);
+ const struct irecv_device_info *device_info = irecv_get_device_info(recovery);
+ if (device_info && device_info->srnm) {
+ client->srnm = strdup(device_info->srnm);
info("INFO: device serial number is %s\n", client->srnm);
}
}
@@ -453,11 +451,13 @@ int recovery_get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid) {
}
}
- recovery_error = irecv_get_ecid(client->recovery->client, (long long unsigned int*)ecid);
- if (recovery_error != IRECV_E_SUCCESS) {
+ const struct irecv_device_info *device_info = irecv_get_device_info(client->recovery->client);
+ if (!device_info) {
return -1;
}
+ *ecid = device_info->ecid;
+
return 0;
}
@@ -470,32 +470,24 @@ int recovery_get_ap_nonce(struct idevicerestore_client_t* client, unsigned char*
}
}
- recovery_error = irecv_get_nonce_with_tag(client->recovery->client, "NONC", nonce, nonce_size);
- if (recovery_error != IRECV_E_SUCCESS) {
+ const struct irecv_device_info *device_info = irecv_get_device_info(client->recovery->client);
+ if (!device_info) {
return -1;
}
- return 0;
-}
-
-int recovery_get_sep_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size) {
- irecv_error_t recovery_error = IRECV_E_SUCCESS;
-
- if(client->recovery == NULL) {
- if (recovery_client_new(client) < 0) {
+ if (device_info->ap_nonce && device_info->ap_nonce_size > 0) {
+ *nonce = (unsigned char*)malloc(device_info->ap_nonce_size);
+ if (!*nonce) {
return -1;
}
- }
-
- recovery_error = irecv_get_nonce_with_tag(client->recovery->client, "SNON", nonce, nonce_size);
- if (recovery_error != IRECV_E_SUCCESS) {
- return -1;
+ *nonce_size = device_info->ap_nonce_size;
+ memcpy(*nonce, device_info->ap_nonce, *nonce_size);
}
return 0;
}
-int recovery_get_cpid(struct idevicerestore_client_t* client, uint32_t* cpid) {
+int recovery_get_sep_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size) {
irecv_error_t recovery_error = IRECV_E_SUCCESS;
if(client->recovery == NULL) {
@@ -504,26 +496,18 @@ int recovery_get_cpid(struct idevicerestore_client_t* client, uint32_t* cpid) {
}
}
- recovery_error = irecv_get_cpid(client->recovery->client, cpid);
- if (recovery_error != IRECV_E_SUCCESS) {
+ const struct irecv_device_info *device_info = irecv_get_device_info(client->recovery->client);
+ if (!device_info) {
return -1;
}
- return 0;
-}
-
-int recovery_get_bdid(struct idevicerestore_client_t* client, uint32_t* bdid) {
- irecv_error_t recovery_error = IRECV_E_SUCCESS;
-
- if(client->recovery == NULL) {
- if (recovery_client_new(client) < 0) {
+ if (device_info->sep_nonce && device_info->sep_nonce_size > 0) {
+ *nonce = (unsigned char*)malloc(device_info->sep_nonce_size);
+ if (!*nonce) {
return -1;
}
- }
-
- recovery_error = irecv_get_bdid(client->recovery->client, bdid);
- if (recovery_error != IRECV_E_SUCCESS) {
- return -1;
+ *nonce_size = device_info->sep_nonce_size;
+ memcpy(*nonce, device_info->sep_nonce, *nonce_size);
}
return 0;
diff --git a/src/recovery.h b/src/recovery.h
index d1fd71e..8deb438 100644
--- a/src/recovery.h
+++ b/src/recovery.h
@@ -56,8 +56,6 @@ int recovery_set_autoboot(struct idevicerestore_client_t* client, int enable);
int recovery_get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid);
int recovery_get_ap_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size);
int recovery_get_sep_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size);
-int recovery_get_cpid(struct idevicerestore_client_t* client, uint32_t* cpid);
-int recovery_get_bdid(struct idevicerestore_client_t* client, uint32_t* bdid);
#ifdef __cplusplus