Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/ext/libkirk/amctrl.h
3186 views
1
#pragma once
2
#include "kirk_engine.h"
3
4
#ifdef __cplusplus
5
extern "C" {
6
#endif
7
8
typedef struct {
9
int type;
10
u8 key[16];
11
u8 pad[16];
12
int pad_size;
13
} MAC_KEY;
14
15
typedef struct
16
{
17
u32 type;
18
u32 seed;
19
u8 key[16];
20
} CIPHER_KEY;
21
22
typedef struct {
23
u8 vkey[16]; // key to decrypt PGD header
24
u8 dkey[16]; // key to decrypt PGD data
25
26
u32 open_flag;
27
u32 key_index;
28
u32 drm_type;
29
u32 mac_type;
30
u32 cipher_type;
31
32
u32 data_size;
33
u32 align_size;
34
u32 block_size;
35
u32 block_nr;
36
u32 data_offset;
37
u32 table_offset;
38
39
u8 *block_buf;
40
u32 current_block;
41
u32 file_offset;
42
}PGD_DESC;
43
44
45
// type:
46
// 2: use fuse id
47
// 3: use fixed key. MAC need encrypt again
48
int sceDrmBBMacInit(MAC_KEY *mkey, int type);
49
int sceDrmBBMacUpdate(KirkState *kirk, MAC_KEY *mkey, u8 *buf, int size);
50
int sceDrmBBMacFinal(KirkState *kirk, MAC_KEY *mkey, u8 *buf, u8 *vkey);
51
int sceDrmBBMacFinal2(KirkState *kirk, MAC_KEY *mkey, u8 *out, u8 *vkey);
52
int bbmac_getkey(KirkState *kirk, MAC_KEY *mkey, u8 *bbmac, u8 *vkey);
53
54
// type: 1 use fixed key
55
// 2 use fuse id
56
// mode: 1 for encrypt
57
// 2 for decrypt
58
int sceDrmBBCipherInit(KirkState *kirk, CIPHER_KEY *ckey, int type, int mode, u8 *header_key, u8 *version_key, u32 seed);
59
int sceDrmBBCipherUpdate(KirkState *kirk, CIPHER_KEY *ckey, u8 *data, int size);
60
int sceDrmBBCipherFinal(CIPHER_KEY *ckey);
61
62
// npdrm.prx
63
int sceNpDrmGetFixedKey(KirkState *kirk, u8 *key, char *npstr, int type);
64
65
PGD_DESC *pgd_open(KirkState *kirk, u8 *pgd_buf, int pgd_flag, u8 *pgd_vkey);
66
int pgd_decrypt_block(KirkState *kirk, PGD_DESC *pgd, int block);
67
int pgd_close(PGD_DESC *pgd);
68
69
#ifdef __cplusplus
70
}
71
#endif
72
73