summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2022-04-12 17:34:32 +0200
committerGravatar Nikias Bassen2022-04-12 17:34:32 +0200
commit8f7afa0c45bc9b70b8f5dd186962f3905903f683 (patch)
treea36b63ca24b48a919604b1ee5791dc3acfabf45a /src
parent71561a452a238eb7fa7aae8f1e2752fb357e4756 (diff)
downloadidevicerestore-8f7afa0c45bc9b70b8f5dd186962f3905903f683.tar.gz
idevicerestore-8f7afa0c45bc9b70b8f5dd186962f3905903f683.tar.bz2
More code improvements using _plist_dict_copy_* helper
Diffstat (limited to 'src')
-rw-r--r--src/idevicerestore.c57
-rw-r--r--src/img4.c2
-rw-r--r--src/restore.c6
3 files changed, 13 insertions, 52 deletions
diff --git a/src/idevicerestore.c b/src/idevicerestore.c
index c25d98e..658566f 100644
--- a/src/idevicerestore.c
+++ b/src/idevicerestore.c
@@ -2220,50 +2220,20 @@ int get_tss_response(struct idevicerestore_client_t* client, plist_t build_ident
plist_t pinfo = NULL;
normal_get_preflight_info(client, &pinfo);
if (pinfo) {
- plist_t node;
- node = plist_dict_get_item(pinfo, "Nonce");
- if (node) {
- plist_dict_set_item(parameters, "BbNonce", plist_copy(node));
- }
- node = plist_dict_get_item(pinfo, "ChipID");
- if (node) {
- plist_dict_set_item(parameters, "BbChipID", plist_copy(node));
- }
- node = plist_dict_get_item(pinfo, "CertID");
- if (node) {
- plist_dict_set_item(parameters, "BbGoldCertId", plist_copy(node));
- }
- node = plist_dict_get_item(pinfo, "ChipSerialNo");
- if (node) {
- plist_dict_set_item(parameters, "BbSNUM", plist_copy(node));
- }
+ _plist_dict_copy_data(parameters, pinfo, "BbNonce", "Nonce");
+ _plist_dict_copy_uint(parameters, pinfo, "BbChipID", "ChipID");
+ _plist_dict_copy_uint(parameters, pinfo, "BbGoldCertId", "CertID");
+ _plist_dict_copy_data(parameters, pinfo, "BbSNUM", "ChipSerialNo");
/* add baseband parameters */
tss_request_add_baseband_tags(request, parameters, NULL);
- node = plist_dict_get_item(pinfo, "EUICCChipID");
- uint64_t euiccchipid = 0;
- if (node && plist_get_node_type(node) == PLIST_UINT) {
- plist_get_uint_val(node, &euiccchipid);
- plist_dict_set_item(parameters, "eUICC,ChipID", plist_copy(node));
- }
- if (euiccchipid >= 5) {
- node = plist_dict_get_item(pinfo, "EUICCCSN");
- if (node) {
- plist_dict_set_item(parameters, "eUICC,EID", plist_copy(node));
- }
- node = plist_dict_get_item(pinfo, "EUICCCertIdentifier");
- if (node) {
- plist_dict_set_item(parameters, "eUICC,RootKeyIdentifier", plist_copy(node));
- }
- node = plist_dict_get_item(pinfo, "EUICCGoldNonce");
- if (node) {
- plist_dict_set_item(parameters, "EUICCGoldNonce", plist_copy(node));
- }
- node = plist_dict_get_item(pinfo, "EUICCMainNonce");
- if (node) {
- plist_dict_set_item(parameters, "EUICCMainNonce", plist_copy(node));
- }
+ _plist_dict_copy_uint(parameters, pinfo, "eUICC,ChipID", "EUICCChipID");
+ if (_plist_dict_get_uint(parameters, "eUICC,ChipID") >= 5) {
+ _plist_dict_copy_data(parameters, pinfo, "eUICC,EID", "EUICCCSN");
+ _plist_dict_copy_data(parameters, pinfo, "eUICC,RootKeyIdentifier", "EUICCCertIdentifier");
+ _plist_dict_copy_data(parameters, pinfo, "EUICCGoldNonce", NULL);
+ _plist_dict_copy_data(parameters, pinfo, "EUICCMainNonce", NULL);
/* add vinyl parameters */
tss_request_add_vinyl_tags(request, parameters, NULL);
@@ -2419,11 +2389,8 @@ int get_recovery_os_local_policy_tss_response(
plist_dict_set_item(lpol, "Trusted", plist_new_bool(1));
plist_dict_set_item(parameters, "Ap,LocalPolicy", lpol);
- plist_t im4m_hash = plist_dict_get_item(args, "Ap,NextStageIM4MHash");
- plist_dict_set_item(parameters, "Ap,NextStageIM4MHash", plist_copy(im4m_hash));
-
- plist_t nonce_hash = plist_dict_get_item(args, "Ap,RecoveryOSPolicyNonceHash");
- plist_dict_set_item(parameters, "Ap,RecoveryOSPolicyNonceHash", plist_copy(nonce_hash));
+ _plist_dict_copy_data(parameters, args, "Ap,NextStageIM4MHash", NULL);
+ _plist_dict_copy_data(parameters, args, "Ap,RecoveryOSPolicyNonceHash", NULL);
plist_t vol_uuid_node = plist_dict_get_item(args, "Ap,VolumeUUID");
char* vol_uuid_str = NULL;
diff --git a/src/img4.c b/src/img4.c
index 4988293..609e80b 100644
--- a/src/img4.c
+++ b/src/img4.c
@@ -627,8 +627,6 @@ int img4_create_local_manifest(plist_t request, plist_t build_identity, plist_t*
unsigned int length = 0;
uint64_t uintval = 0;
unsigned int boolval = 0;
- char *strval = NULL;
- plist_t node = NULL;
unsigned char tmp_[1024];
unsigned char *tmp = &tmp_[0];
diff --git a/src/restore.c b/src/restore.c
index 3942745..257cc38 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -3936,7 +3936,6 @@ int restore_device(struct idevicerestore_client_t* client, plist_t build_identit
plist_dict_set_item(opts, "AutoBootDelay", plist_new_uint(0));
if (client->preflight_info) {
- plist_t node;
plist_t bbus = plist_copy(client->preflight_info);
plist_dict_remove_item(bbus, "FusingStatus");
@@ -3944,10 +3943,7 @@ int restore_device(struct idevicerestore_client_t* client, plist_t build_identit
plist_dict_set_item(opts, "BBUpdaterState", bbus);
- node = plist_dict_get_item(client->preflight_info, "Nonce");
- if (node) {
- plist_dict_set_item(opts, "BasebandNonce", plist_copy(node));
- }
+ _plist_dict_copy_data(opts, client->preflight_info, "BasebandNonce", "Nonce");
}
plist_dict_set_item(opts, "SupportedDataTypes", restore_supported_data_types());