summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2012-02-02 23:22:01 +0100
committerGravatar Nikias Bassen2012-02-02 23:22:01 +0100
commitab63172abb157380107d35ff3871202da3046781 (patch)
tree74207221f5e3d40ac76d1ad9dbb3d041dc309739 /src
parent1fc7fe84bdd7e4daf35ed19e5f7171c48c2d6751 (diff)
downloadidevicerestore-ab63172abb157380107d35ff3871202da3046781.tar.gz
idevicerestore-ab63172abb157380107d35ff3871202da3046781.tar.bz2
main: add check for local .shsh files in get_shsh_blobs()
However this is only done for iOS < 5 or in custom firmware mode.
Diffstat (limited to 'src')
-rw-r--r--src/idevicerestore.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index bfe19c7..f1d441a 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -25,6 +25,7 @@
#include <unistd.h>
#include <getopt.h>
#include <plist/plist.h>
+#include <zlib.h>
#include "dfu.h"
#include "tss.h"
@@ -815,6 +816,43 @@ int get_shsh_blobs(struct idevicerestore_client_t* client, uint64_t ecid, unsign
plist_t response = NULL;
*tss = NULL;
+ if ((client->build[0] <= 8) || (client->flags & FLAG_CUSTOM)) {
+ error("checking for local shsh\n");
+
+ /* first check for local copy */
+ char zfn[512];
+ if (client->version) {
+ sprintf(zfn, "shsh/%lld-%s-%s.shsh", (long long int)client->ecid, client->device->product, client->version);
+ struct stat fst;
+ if (stat(zfn, &fst) == 0) {
+ gzFile zf = gzopen(zfn, "rb");
+ if (zf) {
+ unsigned char bin[65536];
+ int blen = gzread(zf, bin, sizeof(bin));
+ if (blen > 0) {
+ if (memcmp(bin, "bplist00", 8) == 0) {
+ plist_from_bin(bin, blen, tss);
+ } else {
+ plist_from_xml(bin, blen, tss);
+ }
+ }
+ gzclose(zf);
+ }
+ } else {
+ error("no local file %s\n", zfn);
+ }
+ } else {
+ error("No version found?!\n");
+ }
+ }
+
+ if (*tss) {
+ info("Using cached SHSH\n");
+ return 0;
+ } else {
+ info("Trying to fetch new SHSH blob\n");
+ }
+
request = tss_create_request(build_identity, ecid, nonce, nonce_size);
if (request == NULL) {
error("ERROR: Unable to create TSS request\n");