diff options
author | Nikias Bassen | 2012-02-02 20:33:33 +0100 |
---|---|---|
committer | Nikias Bassen | 2012-02-02 20:33:33 +0100 |
commit | dbd691eea29cf6682c342186a41b534b2b3d2167 (patch) | |
tree | ec833c40d60f6a36162b709c1edd0194658971fa /src/recovery.c | |
parent | 3d8db8c1a81f88166295399082d481fb1f1ecd6c (diff) | |
download | idevicerestore-dbd691eea29cf6682c342186a41b534b2b3d2167.tar.gz idevicerestore-dbd691eea29cf6682c342186a41b534b2b3d2167.tar.bz2 |
recovery: send APTicket for iOS >= 5 in recovery_enter_restore
Diffstat (limited to 'src/recovery.c')
-rw-r--r-- | src/recovery.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/recovery.c b/src/recovery.c index 7f89afa..9f1b2d9 100644 --- a/src/recovery.c +++ b/src/recovery.c @@ -144,6 +144,14 @@ int recovery_enter_restore(struct idevicerestore_client_t* client, plist_t build } } + if ((client->build[0] > '8') && !(client->flags & FLAG_CUSTOM)) { + /* send ApTicket */ + if (recovery_send_ticket(client) < 0) { + error("ERROR: Unable to send APTicket\n"); + return -1; + } + } + irecv_send_command(client->recovery->client, "getenv build-version"); irecv_send_command(client->recovery->client, "getenv build-style"); irecv_send_command(client->recovery->client, "getenv radio-error"); @@ -179,6 +187,37 @@ int recovery_enter_restore(struct idevicerestore_client_t* client, plist_t build return 0; } +int recovery_send_ticket(struct idevicerestore_client_t* client) +{ + if (!client->tss) { + error("ERROR: ApTicket requested but no TSS present\n"); + return -1; + } + + unsigned char* data = NULL; + uint32_t size = 0; + if (tss_get_ticket(client->tss, &data, &size) < 0) { + error("ERROR: Unable to get ApTicket from TSS request\n"); return -1; + } + + info("Sending APTicket (%d bytes)\n", size); + irecv_error_t error = irecv_send_buffer(client->recovery->client, data, size, 0); + if (error != IRECV_E_SUCCESS) { + error("ERROR: Unable to send APTicket: %s\n", irecv_strerror(error)); + free(data); + return -1; + } + free(data); + + error = irecv_send_command(client->recovery->client, "ticket"); + if (error != IRECV_E_SUCCESS) { + error("ERROR: Unable to send ticket command\n"); + return -1; + } + + return 0; +} + int recovery_send_component(struct idevicerestore_client_t* client, plist_t build_identity, const char* component) { uint32_t size = 0; char* data = NULL; |