2019-06-30 01:03:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018 naehrwert
|
2020-04-14 14:43:43 +00:00
|
|
|
* Copyright (c) 2018-2020 CTCaer
|
2019-06-30 01:03:00 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _HOS_H_
|
|
|
|
#define _HOS_H_
|
|
|
|
|
|
|
|
#include "pkg1.h"
|
|
|
|
#include "pkg2.h"
|
|
|
|
#include "../utils/types.h"
|
|
|
|
#include "../config/ini.h"
|
|
|
|
#include "../sec/tsec.h"
|
|
|
|
|
2020-04-30 00:43:29 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
2019-06-30 01:03:00 +00:00
|
|
|
#define KB_FIRMWARE_VERSION_100_200 0
|
|
|
|
#define KB_FIRMWARE_VERSION_300 1
|
|
|
|
#define KB_FIRMWARE_VERSION_301 2
|
|
|
|
#define KB_FIRMWARE_VERSION_400 3
|
|
|
|
#define KB_FIRMWARE_VERSION_500 4
|
|
|
|
#define KB_FIRMWARE_VERSION_600 5
|
|
|
|
#define KB_FIRMWARE_VERSION_620 6
|
|
|
|
#define KB_FIRMWARE_VERSION_700 7
|
|
|
|
#define KB_FIRMWARE_VERSION_810 8
|
2019-09-12 20:41:08 +00:00
|
|
|
#define KB_FIRMWARE_VERSION_900 9
|
2019-12-08 01:01:21 +00:00
|
|
|
#define KB_FIRMWARE_VERSION_910 10
|
|
|
|
#define KB_FIRMWARE_VERSION_MAX KB_FIRMWARE_VERSION_910
|
2019-06-30 01:03:00 +00:00
|
|
|
|
|
|
|
#define HOS_PKG11_MAGIC 0x31314B50
|
2020-04-30 00:43:29 +00:00
|
|
|
#define HOS_EKS_MAGIC 0x30534B45
|
|
|
|
|
|
|
|
typedef struct _hos_eks_keys_t
|
|
|
|
{
|
|
|
|
u8 dkg[0x10];
|
|
|
|
u8 mkk[0x10];
|
|
|
|
u8 fdk[0x10];
|
|
|
|
u8 dkk[0x10];
|
|
|
|
} hos_eks_keys_t;
|
|
|
|
|
|
|
|
typedef struct _hos_eks_mbr_t
|
|
|
|
{
|
|
|
|
u32 magic;
|
|
|
|
u32 enabled;
|
|
|
|
u32 sbk_low[2];
|
|
|
|
hos_eks_keys_t keys[6];
|
|
|
|
u32 magic2;
|
|
|
|
u32 rsvd2[3];
|
|
|
|
} hos_eks_mbr_t;
|
|
|
|
|
2020-05-05 16:11:39 +00:00
|
|
|
static_assert(sizeof(hos_eks_mbr_t) == 416, "HOS EKS storage bigger than MBR!");
|
2019-06-30 01:03:00 +00:00
|
|
|
|
|
|
|
typedef struct _launch_ctxt_t
|
|
|
|
{
|
|
|
|
void *keyblob;
|
|
|
|
|
|
|
|
void *pkg1;
|
|
|
|
const pkg1_id_t *pkg1_id;
|
|
|
|
|
|
|
|
void *warmboot;
|
|
|
|
u32 warmboot_size;
|
|
|
|
void *secmon;
|
|
|
|
u32 secmon_size;
|
|
|
|
|
|
|
|
void *pkg2;
|
|
|
|
u32 pkg2_size;
|
2020-04-30 00:43:29 +00:00
|
|
|
bool new_pkg2;
|
2019-06-30 01:03:00 +00:00
|
|
|
|
|
|
|
void *kernel;
|
|
|
|
u32 kernel_size;
|
|
|
|
link_t kip1_list;
|
|
|
|
char* kip1_patches;
|
|
|
|
|
|
|
|
ini_sec_t *cfg;
|
|
|
|
} launch_ctxt_t;
|
|
|
|
|
2020-04-30 00:43:29 +00:00
|
|
|
void hos_eks_get();
|
|
|
|
void hos_eks_save(u32 kb);
|
|
|
|
void hos_eks_clear(u32 kb);
|
|
|
|
int hos_keygen(u8 *keyblob, u32 kb, tsec_ctxt_t *tsec_ctxt);
|
2019-06-30 01:03:00 +00:00
|
|
|
|
|
|
|
#endif
|