CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

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