summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lockdown.c35
-rw-r--r--src/lockdown.h1
-rw-r--r--src/main.c6
3 files changed, 37 insertions, 5 deletions
diff --git a/src/lockdown.c b/src/lockdown.c
index def62ea..6ba7e18 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -214,13 +214,16 @@ int lockdownd_hello(lockdownd_client *control) {
214 free_dictionary(dictionary); 214 free_dictionary(dictionary);
215 return 0; 215 return 0;
216} 216}
217/** Askes for the device's public key. Part of the lockdownd handshake. 217
218/** Generic function to handle simple (key, value) requests.
218 * 219 *
219 * @note You most likely want lockdownd_init unless you are doing something special. 220 * @param control an initialized lockdownd client.
221 * @param key the key to request
222 * @param value a pointer to the requested value
220 * 223 *
221 * @return 1 on success and 0 on failure. 224 * @return 1 on success and 0 on failure.
222 */ 225 */
223int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key) 226int lockdownd_generic_get_value(lockdownd_client *control, char *req_key, char **value)
224{ 227{
225 xmlDocPtr plist = new_plist(); 228 xmlDocPtr plist = new_plist();
226 xmlNode *dict = NULL; 229 xmlNode *dict = NULL;
@@ -232,7 +235,7 @@ int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key
232 235
233 /* Setup DevicePublicKey request plist */ 236 /* Setup DevicePublicKey request plist */
234 dict = add_child_to_plist(plist, "dict", "\n", NULL, 0); 237 dict = add_child_to_plist(plist, "dict", "\n", NULL, 0);
235 key = add_key_str_dict_element(plist, dict, "Key", "DevicePublicKey", 1); 238 key = add_key_str_dict_element(plist, dict, "Key", req_key, 1);
236 key = add_key_str_dict_element(plist, dict, "Request", "GetValue", 1); 239 key = add_key_str_dict_element(plist, dict, "Request", "GetValue", 1);
237 xmlDocDumpMemory(plist, (xmlChar**)&XML_content, &length); 240 xmlDocDumpMemory(plist, (xmlChar**)&XML_content, &length);
238 241
@@ -264,7 +267,7 @@ int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key
264 success = 1; 267 success = 1;
265 } 268 }
266 if (!strcmp(dictionary[i], "Value")) { 269 if (!strcmp(dictionary[i], "Value")) {
267 *public_key = strdup(dictionary[i+1]); 270 *value = strdup(dictionary[i+1]);
268 } 271 }
269 } 272 }
270 273
@@ -275,6 +278,28 @@ int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key
275 return success; 278 return success;
276} 279}
277 280
281/** Askes for the device's unique id. Part of the lockdownd handshake.
282 *
283 * @note You most likely want lockdownd_init unless you are doing something special.
284 *
285 * @return 1 on success and 0 on failure.
286 */
287int lockdownd_get_device_uid(lockdownd_client *control, char **uid)
288{
289 return lockdownd_generic_get_value(control, "UniqueDeviceID", uid);
290}
291
292/** Askes for the device's public key. Part of the lockdownd handshake.
293 *
294 * @note You most likely want lockdownd_init unless you are doing something special.
295 *
296 * @return 1 on success and 0 on failure.
297 */
298int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key)
299{
300 return lockdownd_generic_get_value(control, "DevicePublicKey", public_key);
301}
302
278/** Completes the entire lockdownd handshake. 303/** Completes the entire lockdownd handshake.
279 * 304 *
280 * @param phone The iPhone 305 * @param phone The iPhone
diff --git a/src/lockdown.h b/src/lockdown.h
index 6b27900..df70bbd 100644
--- a/src/lockdown.h
+++ b/src/lockdown.h
@@ -41,6 +41,7 @@ char *lockdownd_generate_hostid();
41 41
42lockdownd_client *new_lockdownd_client(iPhone *phone); 42lockdownd_client *new_lockdownd_client(iPhone *phone);
43int lockdownd_hello(lockdownd_client *control); 43int lockdownd_hello(lockdownd_client *control);
44int lockdownd_get_device_uid(lockdownd_client *control, char **uid);
44int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key); 45int lockdownd_get_device_public_key(lockdownd_client *control, char **public_key);
45int lockdownd_gen_pair_cert(char *public_key_b64, char **device_cert_b64, char **host_cert_b64, char **root_cert_b64); 46int lockdownd_gen_pair_cert(char *public_key_b64, char **device_cert_b64, char **host_cert_b64, char **root_cert_b64);
46int lockdownd_pair_device(lockdownd_client *control, char *public_key, char *host_id); 47int lockdownd_pair_device(lockdownd_client *control, char *public_key, char *host_id);
diff --git a/src/main.c b/src/main.c
index 42600c3..78c62f7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -57,6 +57,12 @@ int main(int argc, char *argv[]) {
57 return -1; 57 return -1;
58 } 58 }
59 59
60 char *uid = NULL;
61 if (lockdownd_get_device_uid(control, &uid)) {
62 printf("DeviceUniqueID : %s\n", uid);
63 free(uid);
64 }
65
60 port = lockdownd_start_service(control, "com.apple.afc"); 66 port = lockdownd_start_service(control, "com.apple.afc");
61 67
62 if (port) { 68 if (port) {