2013-08-27 13:07:43 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-08-27 13:07:43 +00:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2013-01-26 05:22:58 +00:00
|
|
|
// Based off of twintig http://git.infradead.org/?p=users/segher/wii.git
|
|
|
|
// Copyright 2007,2008 Segher Boessenkool <segher@kernel.crashing.org>
|
|
|
|
// Licensed under the terms of the GNU GPL, version 2
|
|
|
|
// http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
|
|
|
|
2013-01-28 12:18:53 +00:00
|
|
|
/*
|
2013-08-25 00:49:58 +00:00
|
|
|
*
|
2013-01-28 12:18:53 +00:00
|
|
|
* Structs for keys.bin taken from:
|
2013-08-25 00:49:58 +00:00
|
|
|
*
|
2014-02-17 04:51:41 +00:00
|
|
|
* mini - a Free Software replacement for the Nintendo/BroadOn IOS.
|
|
|
|
* crypto hardware support
|
2013-08-25 00:49:58 +00:00
|
|
|
*
|
2014-02-17 04:51:41 +00:00
|
|
|
* Copyright (C) 2008, 2009 Haxx Enterprises <bushing@gmail.com>
|
|
|
|
* Copyright (C) 2008, 2009 Sven Peter <svenpeter@gmail.com>
|
|
|
|
* Copyright (C) 2008, 2009 Hector Martin "marcan" <marcan@marcansoft.com>
|
2013-08-25 00:49:58 +00:00
|
|
|
*
|
2013-01-28 12:18:53 +00:00
|
|
|
* # This code is licensed to you under the terms of the GNU GPL, version 2;
|
|
|
|
* # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
|
|
|
*/
|
2013-01-26 05:22:58 +00:00
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2013-01-28 12:18:53 +00:00
|
|
|
|
2015-05-08 21:28:03 +00:00
|
|
|
#include "Common/CommonFuncs.h"
|
|
|
|
#include "Common/CommonTypes.h"
|
2013-01-28 12:18:53 +00:00
|
|
|
|
|
|
|
void get_ng_cert(u8* ng_cert_out, u32 NG_id, u32 NG_key_id, const u8* NG_priv, const u8* NG_sig);
|
|
|
|
void get_ap_sig_and_cert(u8 *sig_out, u8 *ap_cert_out, u64 title_id, u8 *data, u32 data_size, const u8 *NG_priv, u32 NG_id);
|
|
|
|
|
|
|
|
void make_blanksig_ec_cert(u8 *cert_out, const char *signer, const char *name, const u8 *private_key, u32 key_id);
|
|
|
|
|
|
|
|
|
|
|
|
class EcWii
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
EcWii();
|
|
|
|
~EcWii();
|
|
|
|
static EcWii& GetInstance();
|
2014-02-09 23:29:13 +00:00
|
|
|
u32 getNgId() {return Common::swap32(BootMiiKeysBin.ng_id);}
|
|
|
|
u32 getNgKeyId() {return Common::swap32(BootMiiKeysBin.ng_key_id);}
|
|
|
|
const u8* getNgPriv() {return BootMiiKeysBin.ng_priv;}
|
2014-09-11 17:00:40 +00:00
|
|
|
const u8* getNgSig() {return BootMiiKeysBin.ng_sig;}
|
2013-01-28 12:18:53 +00:00
|
|
|
private:
|
|
|
|
void InitDefaults();
|
2013-08-25 00:49:58 +00:00
|
|
|
|
2013-01-28 12:18:53 +00:00
|
|
|
#pragma pack(push,1)
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
u8 boot2version;
|
|
|
|
u8 unknown1;
|
|
|
|
u8 unknown2;
|
|
|
|
u8 pad;
|
|
|
|
u32 update_tag;
|
|
|
|
u16 checksum;
|
|
|
|
}
|
|
|
|
#ifndef _WIN32
|
2013-08-25 00:49:58 +00:00
|
|
|
__attribute__((packed))
|
2013-01-28 12:18:53 +00:00
|
|
|
#endif
|
|
|
|
eep_ctr_t;
|
2013-08-25 00:49:58 +00:00
|
|
|
|
|
|
|
struct
|
2013-01-28 12:18:53 +00:00
|
|
|
{
|
2014-02-09 23:29:13 +00:00
|
|
|
u8 creator [0x100]; // 0x000
|
|
|
|
u8 boot1_hash [ 0x14]; // 0x100
|
|
|
|
u8 common_key [ 0x10]; // 0x114
|
|
|
|
u32 ng_id; // 0x124
|
2014-08-30 21:23:13 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2014-02-09 23:29:13 +00:00
|
|
|
u8 ng_priv [ 0x1e]; // 0x128
|
|
|
|
u8 pad1 [ 0x12];
|
2013-01-28 12:18:53 +00:00
|
|
|
};
|
2014-08-30 21:23:13 +00:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
2014-02-09 23:29:13 +00:00
|
|
|
u8 pad2 [ 0x1c];
|
|
|
|
u8 nand_hmac [ 0x14]; //0x144
|
2013-01-28 12:18:53 +00:00
|
|
|
};
|
|
|
|
};
|
2014-02-09 23:29:13 +00:00
|
|
|
u8 nand_key [ 0x10]; //0x158
|
|
|
|
u8 rng_key [ 0x10]; //0x168
|
|
|
|
u32 unk1; //0x178
|
|
|
|
u32 unk2; //0x17C
|
|
|
|
u8 eeprom_pad [ 0x80]; //0x180
|
|
|
|
|
|
|
|
u32 ms_id; //0x200
|
|
|
|
u32 ca_id; //0x204
|
|
|
|
u32 ng_key_id; //0x208
|
|
|
|
u8 ng_sig [ 0x3c]; //0x20c
|
|
|
|
eep_ctr_t counters [ 0x02]; //0x248
|
|
|
|
u8 fill [ 0x18]; //0x25c
|
|
|
|
u8 korean_key [ 0x10]; //0x274
|
|
|
|
u8 pad3 [ 0x74]; //0x284
|
|
|
|
u16 prng_seed [ 0x02]; //0x2F8
|
|
|
|
u8 pad4 [ 0x04]; //0x2FC
|
|
|
|
|
|
|
|
u8 crack_pad [0x100]; //0x300
|
2013-08-25 00:49:58 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-01-28 12:18:53 +00:00
|
|
|
#ifndef _WIN32
|
2013-08-25 00:49:58 +00:00
|
|
|
__attribute__((packed))
|
2013-01-28 12:18:53 +00:00
|
|
|
#endif
|
2013-08-25 00:49:58 +00:00
|
|
|
|
2013-01-28 12:18:53 +00:00
|
|
|
BootMiiKeysBin;
|
2013-08-25 00:49:58 +00:00
|
|
|
|
2013-01-28 12:18:53 +00:00
|
|
|
#pragma pack(pop)
|
2013-08-25 00:49:58 +00:00
|
|
|
|
2013-01-28 12:18:53 +00:00
|
|
|
};
|