forked from naehrwert/scetool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
keys.h
133 lines (112 loc) · 2.27 KB
/
keys.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
* Copyright (c) 2011-2013 by naehrwert
* This file is released under the GPLv2.
*/
#ifndef _KEYS_H_
#define _KEYS_H_
#include "types.h"
#include "sce.h"
#define KEYBITS(klen) BYTES2BITS(klen)
#define KEYTYPE_SELF 1
#define KEYTYPE_RVK 2
#define KEYTYPE_PKG 3
#define KEYTYPE_SPP 4
#define KEYTYPE_OTHER 5
/*! Flag to use VSH curve. */
#define USE_VSH_CURVE 0x40
/*! Length of whole curves file. */
#define CURVES_LENGTH 0x1E40
#define CTYPE_MIN 0
#define CTYPE_MAX 63
/*! Length of the whole VSH curves file. */
#define VSH_CURVES_LENGTH 0x168
#define VSH_CTYPE_MIN 0
#define VSH_CTYPE_MAX 2
/*! Length of the idps, act.dat, .rif and .rap files. */
#define IDPS_LENGTH 0x10
#define ACT_DAT_LENGTH 0x1038
#define RIF_LENGTH 0x98
#define RAP_LENGTH 0x10
/*! IDPS, RIF, act.dat key lengths. */
#define IDPS_KEYBITS 128
#define ACT_DAT_KEYBITS 128
#define RIF_KEYBITS 128
#define RAP_KEYBITS 128
/*! Keyset. */
typedef struct _keyset
{
/*! Name. */
s8 *name;
/*! Type. */
u32 type;
/*! Key revision. */
u16 key_revision;
/*! Version. */
u64 version;
/*! SELF type. */
u32 self_type;
/*! Key length. */
u32 erklen;
/*! Key. */
u8 *erk;
/*! IV length. */
u32 rivlen;
/*! IV. */
u8 *riv;
/*! Pub. */
u8 *pub;
/*! Priv. */
u8 *priv;
/*! Curve type. */
u8 ctype;
} keyset_t;
/*! Curve entry. */
typedef struct _curve
{
u8 p[20];
u8 a[20];
u8 b[20];
u8 N[21];
u8 Gx[20];
u8 Gy[20];
} curve_t;
/*! VSH Curve entry. */
typedef struct _vsh_curve
{
u8 a[20];
u8 b[20];
u8 N[20];
u8 p[20];
u8 Gx[20];
u8 Gy[20];
} vsh_curve_t;
/*! act.dat. */
typedef struct _act_dat
{
u8 account_info[16];
u8 primary_key_table[2048];
u8 secondary_key_table[2048];
u8 signature[40];
} act_dat_t;
/*! RIF. */
typedef struct _rif
{
u8 account_info[16];
u8 content_id[48];
u8 act_key_index[16];
u8 klicensee[16];
u64 timestamp;
u64 zero;
u8 signature[40];
} rif_t;
void _print_key_list(FILE *fp);
BOOL keys_load(const s8 *kfile);
keyset_t *keyset_find(sce_buffer_ctxt_t *ctxt);
keyset_t *keyset_find_by_name(const s8 *name);
BOOL curves_load(const s8 *cfile);
curve_t *curve_find(u8 ctype);
BOOL vsh_curves_load(const s8 *cfile);
curve_t *vsh_curve_find(u8 ctype);
BOOL klicensee_by_content_id(const s8 *content_id, u8 *klicensee);
keyset_t *keyset_from_buffer(u8 *keyset);
#endif