summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2013-11-18 18:17:31 +0100
committerGravatar Martin Szulecki2013-11-18 18:17:31 +0100
commit8407a14a1884c386cf5277dec53ecb067c34fac2 (patch)
tree288b2ffe52f51b878335b2aac3d591329a3abedc
parente12bd5fc5c9b59e01288dbf0e8e1edc32aa03bf0 (diff)
downloadidevicerestore-8407a14a1884c386cf5277dec53ecb067c34fac2.tar.gz
idevicerestore-8407a14a1884c386cf5277dec53ecb067c34fac2.tar.bz2
normal: Split normal_get_nonce() into ApNonce and SEPNonce getters
-rw-r--r--src/idevicerestore.c10
-rw-r--r--src/normal.c17
-rw-r--r--src/normal.h3
3 files changed, 20 insertions, 10 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index 9717676..0cd5a14 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -562,7 +562,7 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
unsigned char* nonce = NULL;
int nonce_size = 0;
int nonce_changed = 0;
- if (get_nonce(client, &nonce, &nonce_size) < 0) {
+ if (get_ap_nonce(client, &nonce, &nonce_size) < 0) {
/* the first nonce request with older firmware releases can fail and it's OK */
info("NOTE: Unable to get nonce from device\n");
}
@@ -811,7 +811,7 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
unsigned char* nonce = NULL;
int nonce_size = 0;
int nonce_changed = 0;
- if (get_nonce(client, &nonce, &nonce_size) < 0) {
+ if (get_ap_nonce(client, &nonce, &nonce_size) < 0) {
error("ERROR: Unable to get nonce from device!\n");
recovery_send_reset(client);
if (delete_fs && filesystem)
@@ -1257,16 +1257,16 @@ int get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid) {
return 0;
}
-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) {
*nonce = NULL;
*nonce_size = 0;
- info("Getting nonce ");
+ info("Getting ApNonce ");
switch (client->mode->index) {
case MODE_NORMAL:
info("in normal mode... ");
- if (normal_get_nonce(client, nonce, nonce_size) < 0) {
+ if (normal_get_ap_nonce(client, nonce, nonce_size) < 0) {
info("failed\n");
return -1;
}
diff --git a/src/normal.c b/src/normal.c
index 2c31b4e..b7f0f45 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -336,7 +336,7 @@ int normal_enter_recovery(struct idevicerestore_client_t* client) {
return 0;
}
-int normal_get_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size) {
+static normal_get_nonce_by_key(struct idevicerestore_client_t* client, const char* key, unsigned char** nonce, int* nonce_size) {
idevice_t device = NULL;
plist_t nonce_node = NULL;
lockdownd_client_t lockdown = NULL;
@@ -355,16 +355,16 @@ int normal_get_nonce(struct idevicerestore_client_t* client, unsigned char** non
return -1;
}
- lockdown_error = lockdownd_get_value(lockdown, NULL, "ApNonce", &nonce_node);
+ lockdown_error = lockdownd_get_value(lockdown, NULL, key, &nonce_node);
if (lockdown_error != LOCKDOWN_E_SUCCESS) {
- error("ERROR: Unable to get ApNonce from lockdownd\n");
+ error("ERROR: Unable to get %s from lockdownd\n", key);
lockdownd_client_free(lockdown);
idevice_free(device);
return -1;
}
if (!nonce_node || plist_get_node_type(nonce_node) != PLIST_DATA) {
- error("ERROR: Unable to get nonce\n");
+ error("ERROR: Unable to get %s\n", key);
lockdownd_client_free(lockdown);
idevice_free(device);
return -1;
@@ -379,9 +379,18 @@ int normal_get_nonce(struct idevicerestore_client_t* client, unsigned char** non
idevice_free(device);
lockdown = NULL;
device = NULL;
+
return 0;
}
+int normal_get_sep_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size) {
+ return normal_get_nonce_by_key(client, "ApNonce", nonce, nonce_size);
+}
+
+int normal_get_ap_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size) {
+ 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;
}
diff --git a/src/normal.h b/src/normal.h
index e210128..cbbac2b 100644
--- a/src/normal.h
+++ b/src/normal.h
@@ -49,7 +49,8 @@ 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_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size);
+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);
#ifdef __cplusplus
}