Skip to content

Commit

Permalink
Require libplist 2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nikias committed May 14, 2024
1 parent e6d8c0b commit 653349a
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 72 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fi
LIBIRECOVERY_VERSION=1.2.0
LIBIMOBILEDEVICE_VERSION=1.3.0
LIBUSBMUXD_VERSION=2.0.2
LIBPLIST_VERSION=2.5.0
LIBPLIST_VERSION=2.6.0
LIMD_GLUE_VERSION=1.2.0
LIBZIP_VERSION=1.0
LIBCURL_VERSION=7.0
Expand Down
2 changes: 1 addition & 1 deletion src/ace3.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ int ace3_create_binary(const unsigned char* uarp_fw, size_t uarp_size, uint64_t

plist_t p_im4m = plist_dict_get_item(tss, "USBPortController1,Ticket");
uint64_t im4m_size = 0;
const uint8_t* im4m = plist_get_data_ptr(p_im4m, &im4m_size);
const char* im4m = plist_get_data_ptr(p_im4m, &im4m_size);

struct uarp_header* uarp_hdr = (struct uarp_header*)uarp_fw;
uint32_t uarp_hdr_size = be32toh(uarp_hdr->header_size);
Expand Down
24 changes: 12 additions & 12 deletions src/idevicerestore.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
usbf = plist_copy(usbf);
plist_dict_remove_item(usbf, "Info");
plist_dict_set_item(parameters, "USBPortController1,USBFirmware", usbf);
plist_dict_set_item(parameters, "USBPortController1,Nonce", plist_new_data(pdfu_nonce, pdfu_nsize));
plist_dict_set_item(parameters, "USBPortController1,Nonce", plist_new_data((const char*)pdfu_nonce, pdfu_nsize));

plist_t request = tss_request_new(NULL);
if (request == NULL) {
Expand Down Expand Up @@ -1236,7 +1236,7 @@ int idevicerestore_start(struct idevicerestore_client_t* client)
}

if (client->mode == MODE_RESTORE && client->root_ticket) {
plist_t ap_ticket = plist_new_data(client->root_ticket, client->root_ticket_len);
plist_t ap_ticket = plist_new_data((char*)client->root_ticket, client->root_ticket_len);
if (!ap_ticket) {
error("ERROR: Failed to create ApImg4Ticket node value.\n");
return -1;
Expand Down Expand Up @@ -2263,14 +2263,14 @@ int get_tss_response(struct idevicerestore_client_t* client, plist_t build_ident
plist_t parameters = plist_new_dict();
plist_dict_set_item(parameters, "ApECID", plist_new_uint(client->ecid));
if (client->nonce) {
plist_dict_set_item(parameters, "ApNonce", plist_new_data(client->nonce, client->nonce_size));
plist_dict_set_item(parameters, "ApNonce", plist_new_data((const char*)client->nonce, client->nonce_size));
}
unsigned char* sep_nonce = NULL;
unsigned int sep_nonce_size = 0;
get_sep_nonce(client, &sep_nonce, &sep_nonce_size);

if (sep_nonce) {
plist_dict_set_item(parameters, "ApSepNonce", plist_new_data(sep_nonce, sep_nonce_size));
plist_dict_set_item(parameters, "ApSepNonce", plist_new_data((const char*)sep_nonce, sep_nonce_size));
free(sep_nonce);
}

Expand Down Expand Up @@ -2387,15 +2387,15 @@ int get_recoveryos_root_ticket_tss_response(struct idevicerestore_client_t* clie

/* ApNonce */
if (client->nonce) {
plist_dict_set_item(parameters, "ApNonce", plist_new_data(client->nonce, client->nonce_size));
plist_dict_set_item(parameters, "ApNonce", plist_new_data((const char*)client->nonce, client->nonce_size));
}
unsigned char* sep_nonce = NULL;
unsigned int sep_nonce_size = 0;
get_sep_nonce(client, &sep_nonce, &sep_nonce_size);

/* ApSepNonce */
if (sep_nonce) {
plist_dict_set_item(parameters, "ApSepNonce", plist_new_data(sep_nonce, sep_nonce_size));
plist_dict_set_item(parameters, "ApSepNonce", plist_new_data((const char*)sep_nonce, sep_nonce_size));
free(sep_nonce);
}

Expand Down Expand Up @@ -2496,7 +2496,7 @@ int get_recovery_os_local_policy_tss_response(
uint8_t digest[SHA384_DIGEST_LENGTH];
SHA384(lpol_file, lpol_file_length, digest);
plist_t lpol = plist_new_dict();
plist_dict_set_item(lpol, "Digest", plist_new_data(digest, SHA384_DIGEST_LENGTH));
plist_dict_set_item(lpol, "Digest", plist_new_data((char*)digest, SHA384_DIGEST_LENGTH));
plist_dict_set_item(lpol, "Trusted", plist_new_bool(1));
plist_dict_set_item(parameters, "Ap,LocalPolicy", lpol);

Expand All @@ -2518,7 +2518,7 @@ int get_recovery_os_local_policy_tss_response(
for (i = 0; i < 16; i++) {
vol_uuid[i] = (unsigned char)vuuid[i];
}
plist_dict_set_item(parameters, "Ap,VolumeUUID", plist_new_data(vol_uuid, 16));
plist_dict_set_item(parameters, "Ap,VolumeUUID", plist_new_data((char*)vol_uuid, 16));

/* create basic request */
request = tss_request_new(NULL);
Expand Down Expand Up @@ -2566,14 +2566,14 @@ int get_local_policy_tss_response(struct idevicerestore_client_t* client, plist_
plist_dict_set_item(parameters, "ApECID", plist_new_uint(client->ecid));
plist_dict_set_item(parameters, "Ap,LocalBoot", plist_new_bool(0));
if (client->nonce) {
plist_dict_set_item(parameters, "ApNonce", plist_new_data(client->nonce, client->nonce_size));
plist_dict_set_item(parameters, "ApNonce", plist_new_data((const char*)client->nonce, client->nonce_size));
}
unsigned char* sep_nonce = NULL;
unsigned int sep_nonce_size = 0;
get_sep_nonce(client, &sep_nonce, &sep_nonce_size);

if (sep_nonce) {
plist_dict_set_item(parameters, "ApSepNonce", plist_new_data(sep_nonce, sep_nonce_size));
plist_dict_set_item(parameters, "ApSepNonce", plist_new_data((const char*)sep_nonce, sep_nonce_size));
free(sep_nonce);
}

Expand All @@ -2591,7 +2591,7 @@ int get_local_policy_tss_response(struct idevicerestore_client_t* client, plist_
uint8_t digest[SHA384_DIGEST_LENGTH];
SHA384(lpol_file, lpol_file_length, digest);
plist_t lpol = plist_new_dict();
plist_dict_set_item(lpol, "Digest", plist_new_data(digest, SHA384_DIGEST_LENGTH));
plist_dict_set_item(lpol, "Digest", plist_new_data((char*)digest, SHA384_DIGEST_LENGTH));
plist_dict_set_item(lpol, "Trusted", plist_new_bool(1));
plist_dict_set_item(parameters, "Ap,LocalPolicy", lpol);

Expand All @@ -2603,7 +2603,7 @@ int get_local_policy_tss_response(struct idevicerestore_client_t* client, plist_
// Hash it and add it as Ap,NextStageIM4MHash
uint8_t hash[SHA384_DIGEST_LENGTH];
SHA384(ticket, ticket_length, hash);
plist_dict_set_item(parameters, "Ap,NextStageIM4MHash", plist_new_data(hash, SHA384_DIGEST_LENGTH));
plist_dict_set_item(parameters, "Ap,NextStageIM4MHash", plist_new_data((char*)hash, SHA384_DIGEST_LENGTH));

/* create basic request */
request = tss_request_new(NULL);
Expand Down
18 changes: 7 additions & 11 deletions src/img4.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ int img4_stitch_component(const char* component_name, const unsigned char* compo
return -1;
}
uint64_t ucon_size = 0;
const uint8_t* ucon_data = plist_get_data_ptr(dt, &ucon_size);
const char* ucon_data = plist_get_data_ptr(dt, &ucon_size);
if (!ucon_data) {
error("ERROR: %s: Missing ucon data in %s-TBM dictionary\n", __func__, component_name);
return -1;
Expand All @@ -468,7 +468,7 @@ int img4_stitch_component(const char* component_name, const unsigned char* compo
return -1;
}
uint64_t ucer_size = 0;
const uint8_t* ucer_data = plist_get_data_ptr(dt, &ucer_size);
const char* ucer_data = plist_get_data_ptr(dt, &ucer_size);
if (!ucer_data) {
error("ERROR: %s: Missing ucer data in %s-TBM dictionary\n", __func__, component_name);
return -1;
Expand Down Expand Up @@ -705,13 +705,11 @@ static void _manifest_write_component(unsigned char **p, unsigned int *length, c

node = plist_dict_get_item(comp, "Digest");
if (node) {
uint8_t *digest = NULL;
uint64_t digest_len = 0;
plist_get_data_val(node, &digest, &digest_len);
const char *digest = plist_get_data_ptr(node, &digest_len);
if (digest_len > 0) {
_manifest_write_key_value(&tmp, &tmp_len, "DGST", ASN1_OCTET_STRING, digest, digest_len);
_manifest_write_key_value(&tmp, &tmp_len, "DGST", ASN1_OCTET_STRING, (void*)digest, digest_len);
}
free(digest);
}

node = plist_dict_get_item(comp, "Trusted");
Expand Down Expand Up @@ -740,9 +738,8 @@ static void _manifest_write_component(unsigned char **p, unsigned int *length, c

node = plist_dict_get_item(comp, "TBMDigests");
if (node) {
uint8_t *data = NULL;
uint64_t datalen = 0;
plist_get_data_val(node, &data, &datalen);
const char *data = plist_get_data_ptr(node, &datalen);
const char *tbmtag = NULL;
if (!strcmp(tag, "sepi")) {
tbmtag = "tbms";
Expand All @@ -752,9 +749,8 @@ static void _manifest_write_component(unsigned char **p, unsigned int *length, c
if (!tbmtag) {
error("ERROR: Unexpected TMBDigests for comp '%s'\n", tag);
} else {
_manifest_write_key_value(&tmp, &tmp_len, tbmtag, ASN1_OCTET_STRING, data, datalen);
_manifest_write_key_value(&tmp, &tmp_len, tbmtag, ASN1_OCTET_STRING, (void*)data, datalen);
}
free(data);
}

asn1_write_element_header(ASN1_SET | ASN1_CONSTRUCTED, tmp_len, &inner_start, &inner_length);
Expand Down Expand Up @@ -907,7 +903,7 @@ int img4_create_local_manifest(plist_t request, plist_t build_identity, plist_t*

length += hdr_len;

*manifest = plist_new_data(buf, length);
*manifest = plist_new_data((char*)buf, length);

free(buf);

Expand Down
Loading

0 comments on commit 653349a

Please sign in to comment.