This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
/
AppleKeyStore.h
85 lines (72 loc) · 2.42 KB
/
AppleKeyStore.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "IOKit.h"
/*
AppleKeyStore
0 : initUserClient scalarOutSize=1
1 :
2 : AppleKeyStoreKeyBagCreate
3 : AppleKeyStoreKeyBagCopyData inscalars=id structOutSize=0x8000
4 : keybagrelease inscalars":[0]}
5 : AppleKeyStoreKeyBagSetSystem
6 : AppleKeyStoreKeyBagCreateWithData
7 : getlockstate "inscalars":[0], "scalarOutSize":1}
8 : AppleKeyStoreLockDevice
9 : AppleKeyStoreUnlockDevice instruct
10: AppleKeyStoreKeyWrap
11: AppleKeyStoreKeyUnwrap
12: AppleKeyStoreKeyBagUnlock
13: AppleKeyStoreKeyBagLock
14: AppleKeyStoreKeyBagGetSystem scalarOutSize=1
15: AppleKeyStoreKeyBagChangeSecret
17: AppleKeyStoreGetDeviceLockState scalarOutSize=1
18: AppleKeyStoreRecoverWithEscrowBag
19: AppleKeyStoreOblitClassD
*/
#define kAppleKeyStoreInitUserClient 0
#define kAppleKeyStoreKeyBagSetSystem 5
#define kAppleKeyStoreKeyBagCreateWithData 6
#define kAppleKeyStoreUnlockDevice 9
#define MAX_CLASS_KEYS 20
struct KeyBagBlobItem
{
unsigned int tag;
unsigned int len;
union
{
unsigned int intvalue;
unsigned char bytes[1];
} data;
};
typedef struct ClassKey
{
unsigned char uuid[16];
unsigned int clas;
unsigned int wrap;
unsigned char wpky[40];
} ClassKey;
typedef struct KeyBag
{
unsigned int version;
unsigned int type;
unsigned char uuid[16];
unsigned char hmck[40];
unsigned char salt[20];
unsigned int iter;
unsigned int numKeys;
struct ClassKey keys[MAX_CLASS_KEYS];
} KeyBag;
int AppleKeyStoreKeyBagInit();
CFDictionaryRef AppleKeyStore_loadKeyBag(const char* folder, const char* filename);
int AppleKeyStoreKeyBagCreateWithData(CFDataRef data, uint64_t* keybagId);
int AppleKeyStoreKeyBagSetSystem(uint64_t keybagId);
int AppleKeyStoreUnlockDevice(io_connect_t conn, CFDataRef passcode);
KeyBag* AppleKeyStore_parseBinaryKeyBag(CFDataRef kb);
void AppleKeyStore_printKeyBag(KeyBag* kb);
int AppleKeyStore_getPasscodeKey(KeyBag* keybag,
const char* passcode,
size_t passcodeLen,
uint8_t* passcodeKey);
int AppleKeyStore_unlockKeybagFromUserland(KeyBag* kb,
const char* passcode,
size_t passcodeLen,
uint8_t* key835);
CFMutableDictionaryRef AppleKeyStore_getClassKeys(KeyBag*);