5 // Created by Chris Suter on 8/21/15.
9 #import <TargetConditionals.h>
11 #if TARGET_OS_EMBEDDED
14 #import <MobileKeyBag/MobileKeyBag.h>
15 #import <Foundation/Foundation.h>
20 #import "test-utils.h"
24 #define TEST_FILE "/tmp/transcode-test.file"
26 int run_transcode(__unused test_ctx_t *ctx)
28 // The root file system needs to be HFS
31 assert(statfs("/tmp", &sfs) == 0);
32 if (strcmp(sfs.f_fstypename, "hfs")) {
33 printf("transcode needs hfs as root file system.\n");
37 MKBKeyBagHandleRef handle;
40 assert_no_err(MKBKeyBagCreateOTABackup(NULL, &handle));
41 assert_no_err(MKBKeyBagCopyData(handle, &data));
42 assert_no_err(MKBKeyBagRegisterOTABackup(data, NULL));
45 int fd = open_dprotected_np(TEST_FILE, O_RDWR | O_CREAT,
48 assert_with_errno(fd >= 0);
50 char *key = malloc(1024);
51 int res = fcntl(fd, F_TRANSCODEKEY, key);
53 assert_with_errno(res != -1);
55 // Keys should be at least 16 bytes
58 assert_no_err(unlink(TEST_FILE));
60 assert_no_err(MKBKeyBagRegisterOTABackup(NULL, NULL));
61 assert_no_err(MKBKeyBagRelease(handle));