Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/nyx/nyx_gui/hos/hos.h
1476 views
1
/*
2
* Copyright (c) 2018 naehrwert
3
* Copyright (c) 2018-2024 CTCaer
4
*
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms and conditions of the GNU General Public License,
7
* version 2, as published by the Free Software Foundation.
8
*
9
* This program is distributed in the hope it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef _HOS_H_
19
#define _HOS_H_
20
21
#include <bdk.h>
22
23
#include "pkg1.h"
24
#include "pkg2.h"
25
26
#include <assert.h>
27
28
//!TODO: Update on mkey changes.
29
enum {
30
HOS_KB_VERSION_100 = 0,
31
HOS_KB_VERSION_300 = 1,
32
HOS_KB_VERSION_301 = 2,
33
HOS_KB_VERSION_400 = 3,
34
HOS_KB_VERSION_500 = 4,
35
HOS_KB_VERSION_600 = 5,
36
HOS_KB_VERSION_620 = 6,
37
HOS_KB_VERSION_700 = 7,
38
HOS_KB_VERSION_810 = 8,
39
HOS_KB_VERSION_900 = 9,
40
HOS_KB_VERSION_910 = 10,
41
HOS_KB_VERSION_1210 = 11,
42
HOS_KB_VERSION_1300 = 12,
43
HOS_KB_VERSION_1400 = 13,
44
HOS_KB_VERSION_1500 = 14,
45
HOS_KB_VERSION_1600 = 15,
46
HOS_KB_VERSION_1700 = 16,
47
HOS_KB_VERSION_1800 = 17,
48
HOS_KB_VERSION_1900 = 18,
49
HOS_KB_VERSION_2000 = 19,
50
HOS_KB_VERSION_MAX = HOS_KB_VERSION_2000
51
};
52
53
#define HOS_TSEC_VERSION 4 //! TODO: Update on TSEC Root Key changes.
54
55
#define HOS_PKG11_MAGIC 0x31314B50
56
#define HOS_EKS_MAGIC 0x31534B45 // EKS1.
57
#define HOS_EKS_TSEC_VER (HOS_KB_VERSION_700 + HOS_TSEC_VERSION)
58
59
typedef struct _hos_eks_mbr_t
60
{
61
u32 magic;
62
u32 enabled;
63
u32 lot0;
64
u32 rsvd;
65
u8 tsec[SE_KEY_128_SIZE];
66
u8 troot[SE_KEY_128_SIZE];
67
u8 troot_dev[SE_KEY_128_SIZE];
68
} hos_eks_mbr_t;
69
70
static_assert(sizeof(hos_eks_mbr_t) == 64, "HOS EKS size is wrong!");
71
72
typedef struct _launch_ctxt_t
73
{
74
void *keyblob;
75
76
void *pkg1;
77
const pkg1_id_t *pkg1_id;
78
79
void *warmboot;
80
u32 warmboot_size;
81
void *secmon;
82
u32 secmon_size;
83
84
void *pkg2;
85
u32 pkg2_size;
86
bool new_pkg2;
87
88
void *kernel;
89
u32 kernel_size;
90
link_t kip1_list;
91
char* kip1_patches;
92
93
ini_sec_t *cfg;
94
} launch_ctxt_t;
95
96
extern u8 *cal0_buf;
97
98
void hos_eks_clear(u32 kb);
99
int hos_keygen(void *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt);
100
int hos_bis_keygen();
101
void hos_bis_keys_clear();
102
int hos_dump_cal0();
103
104
#endif
105
106