mirror of
https://github.com/tihmstar/futurerestore.git
synced 2024-12-22 17:35:29 +00:00
checking SEP to match sepmanifest
This commit is contained in:
parent
42b37c5c71
commit
7496ed3607
|
@ -56,6 +56,14 @@ extern "C"{
|
|||
#define SEP_TMP_PATH FUTURERESTORE_TMP_PATH"/sep.im4p"
|
||||
#define SEP_MANIFEST_TMP_PATH FUTURERESTORE_TMP_PATH"/sepManifest.plist"
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include <CommonCrypto/CommonDigest.h>
|
||||
# define SHA1(d, n, md) CC_SHA1(d, n, md)
|
||||
# define SHA384(d, n, md) CC_SHA384(d, n, md)
|
||||
#else
|
||||
# include <openssl/sha.h>
|
||||
#endif // __APPLE__
|
||||
|
||||
|
||||
#define reterror(code,msg ...) error(msg),throw int(code)
|
||||
#define safeFree(buf) if (buf) free(buf), buf = NULL
|
||||
|
@ -524,11 +532,24 @@ int futurerestore::doRestore(const char *ipsw){
|
|||
plist_t sep_manifest = plist_dict_get_item(sep_build_identity, "Manifest");
|
||||
plist_t sep_sep = plist_copy(plist_dict_get_item(sep_manifest, "SEP"));
|
||||
plist_dict_set_item(manifest, "SEP", sep_sep);
|
||||
//check SEP
|
||||
unsigned char genHash[48]; //SHA384 digest length
|
||||
ptr_smart<char *>sephash = NULL;
|
||||
uint64_t sephashlen = 0;
|
||||
plist_t digest = plist_dict_get_item(sep_sep, "Digest");
|
||||
if (!digest || plist_get_node_type(digest) != PLIST_DATA)
|
||||
reterror(-66, "ERROR: can't find sep digest\n");
|
||||
|
||||
plist_get_data_val(digest, &sephash, &sephashlen);
|
||||
|
||||
if (sephashlen == 20)
|
||||
SHA1(_client->sepfwdata, (unsigned int)_client->sepfwdatasize, genHash);
|
||||
else
|
||||
SHA384(_client->sepfwdata, (unsigned int)_client->sepfwdatasize, genHash);
|
||||
if (memcmp(genHash, static_cast<const char *>(sephash), sephashlen))
|
||||
reterror(-67, "ERROR: SEP does not match sepmanifest\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* print information about current build identity */
|
||||
build_identity_print_information(build_identity);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
ptr_smart(){_p = NULL;}
|
||||
T operator=(T p){return _p = p;}
|
||||
T *operator&(){return &_p;}
|
||||
explicit operator const char*() const {return _p;}
|
||||
~ptr_smart(){if (_p) (_ptr_free) ? _ptr_free(_p) : free((void*)_p);}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue