Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/nyx/nyx_gui/hos/hos.h
2547 views
1
/*
2
* Copyright (c) 2018 naehrwert
3
* Copyright (c) 2018-2025 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_MKEY_VER_100 = 0,
31
HOS_MKEY_VER_300 = 1,
32
HOS_MKEY_VER_301 = 2,
33
HOS_MKEY_VER_400 = 3,
34
HOS_MKEY_VER_500 = 4,
35
HOS_MKEY_VER_600 = 5,
36
HOS_MKEY_VER_620 = 6,
37
HOS_MKEY_VER_700 = 7,
38
HOS_MKEY_VER_810 = 8,
39
HOS_MKEY_VER_900 = 9,
40
HOS_MKEY_VER_910 = 10,
41
HOS_MKEY_VER_1210 = 11,
42
HOS_MKEY_VER_1300 = 12,
43
HOS_MKEY_VER_1400 = 13,
44
HOS_MKEY_VER_1500 = 14,
45
HOS_MKEY_VER_1600 = 15,
46
HOS_MKEY_VER_1700 = 16,
47
HOS_MKEY_VER_1800 = 17,
48
HOS_MKEY_VER_1900 = 18,
49
HOS_MKEY_VER_2000 = 19,
50
HOS_MKEY_VER_2100 = 20,
51
HOS_MKEY_VER_MAX = HOS_MKEY_VER_2100
52
};
53
54
#define HOS_TSEC_VERSION 4 //! TODO: Update on TSEC Root Key changes.
55
56
#define HOS_PKG11_MAGIC 0x31314B50
57
#define HOS_EKS_MAGIC 0x31534B45 // EKS1.
58
#define HOS_EKS_TSEC_VER (HOS_MKEY_VER_700 + HOS_TSEC_VERSION)
59
60
typedef struct _hos_eks_mbr_t
61
{
62
u32 magic;
63
u32 enabled;
64
u32 lot0;
65
u32 rsvd;
66
u8 tsec[SE_KEY_128_SIZE];
67
u8 troot[SE_KEY_128_SIZE];
68
u8 troot_dev[SE_KEY_128_SIZE];
69
} hos_eks_mbr_t;
70
71
static_assert(sizeof(hos_eks_mbr_t) == 64, "HOS EKS size is wrong!");
72
73
typedef struct _launch_ctxt_t
74
{
75
void *pkg1;
76
const pkg1_id_t *pkg1_id;
77
78
void *warmboot;
79
u32 warmboot_size;
80
void *secmon;
81
u32 secmon_size;
82
83
void *pkg2;
84
u32 pkg2_size;
85
bool new_pkg2;
86
87
void *kernel;
88
u32 kernel_size;
89
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 mkey);
99
int hos_keygen(pkg1_eks_t *eks, u32 mkey, 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