From 7308198824b795d15ea8d2f2b67ab03b8d7bbb57 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 19 Nov 2013 21:39:10 +0100 Subject: add get_sep_nonce helper function --- src/idevicerestore.c | 43 +++++++++++++++++++++++++++++++++++++++++++ src/idevicerestore.h | 1 + 2 files changed, 44 insertions(+) diff --git a/src/idevicerestore.c b/src/idevicerestore.c index a0f5a87..c799bc6 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -1274,6 +1274,49 @@ int get_ap_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, return 0; } +int get_sep_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size) { + *nonce = NULL; + *nonce_size = 0; + + info("Getting SepNonce "); + + switch (client->mode->index) { + case MODE_NORMAL: + info("in normal mode... "); + if (normal_get_sep_nonce(client, nonce, nonce_size) < 0) { + info("failed\n"); + return -1; + } + break; + case MODE_DFU: + info("in dfu mode... "); + if (dfu_get_sep_nonce(client, nonce, nonce_size) < 0) { + info("failed\n"); + return -1; + } + break; + case MODE_RECOVERY: + info("in recovery mode... "); + if (recovery_get_sep_nonce(client, nonce, nonce_size) < 0) { + info("failed\n"); + return -1; + } + break; + + default: + error("ERROR: Device is in an invalid state\n"); + return -1; + } + + int i = 0; + for (i = 0; i < *nonce_size; i++) { + info("%02x ", (*nonce)[i]); + } + info("\n"); + + return 0; +} + plist_t build_manifest_get_build_identity(plist_t build_manifest, uint32_t identity) { // fetch build identities array from BuildManifest plist_t build_identities_array = plist_dict_get_item(build_manifest, "BuildIdentities"); diff --git a/src/idevicerestore.h b/src/idevicerestore.h index f646d4a..742d7f9 100644 --- a/src/idevicerestore.h +++ b/src/idevicerestore.h @@ -77,6 +77,7 @@ const char* check_product_type(struct idevicerestore_client_t* client); int get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid); int is_image4_supported(struct idevicerestore_client_t* client); int get_ap_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size); +int get_sep_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); -- cgit v1.1-32-gdbae