2009-04-10 18:15:10 +02:00
|
|
|
/*
|
|
|
|
mini - a Free Software replacement for the Nintendo/BroadOn IOS.
|
|
|
|
|
|
|
|
crypto support
|
|
|
|
|
2009-04-13 22:13:45 +02:00
|
|
|
Copyright (C) 2008, 2009 Haxx Enterprises <bushing@gmail.com>
|
|
|
|
Copyright (C) 2008, 2009 Sven Peter <svenpeter@gmail.com>
|
2009-04-13 23:00:22 +02:00
|
|
|
Copyright (C) 2008, 2009 Hector Martin "marcan" <marcan@marcansoft.com>
|
2009-04-10 18:15:10 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, version 2.
|
|
|
|
|
|
|
|
This program is distributed in the hope that 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, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
*/
|
2009-01-17 15:05:13 +01:00
|
|
|
#ifndef __CRYPTO_H__
|
2009-04-13 22:13:45 +02:00
|
|
|
#define __CRYPTO_H__
|
2009-01-17 15:05:13 +01:00
|
|
|
|
|
|
|
#include "types.h"
|
2009-01-30 13:43:35 +01:00
|
|
|
#include "ipc.h"
|
2009-01-17 15:05:13 +01:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
u8 boot1_hash[20];
|
|
|
|
u8 common_key[16];
|
|
|
|
u32 ng_id;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u8 ng_priv[30];
|
|
|
|
u8 _wtf1[18];
|
|
|
|
};
|
|
|
|
struct {
|
|
|
|
u8 _wtf2[28];
|
|
|
|
u8 nand_hmac[20];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
u8 nand_key[16];
|
|
|
|
u8 rng_key[16];
|
|
|
|
u32 unk1;
|
2009-03-06 05:26:54 +01:00
|
|
|
u32 unk2; // 0x00000007
|
2009-01-17 15:05:13 +01:00
|
|
|
} __attribute__((packed)) otp_t;
|
|
|
|
|
2009-03-06 05:26:54 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2009-03-10 07:05:11 +01:00
|
|
|
u8 boot2version;
|
|
|
|
u8 unknown1;
|
|
|
|
u8 unknown2;
|
|
|
|
u8 pad;
|
2009-03-06 05:26:54 +01:00
|
|
|
u32 update_tag;
|
|
|
|
u16 checksum;
|
2009-03-10 07:05:11 +01:00
|
|
|
} __attribute__((packed)) eep_ctr_t;
|
2009-03-06 05:26:54 +01:00
|
|
|
|
2009-01-17 15:05:13 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u32 dunno0; // 0x2 = MS
|
|
|
|
u32 dunno1; // 0x1 = CA
|
|
|
|
u32 ng_key_id;
|
|
|
|
u8 ng_sig[60];
|
2009-03-10 07:05:11 +01:00
|
|
|
eep_ctr_t counters[2];
|
2009-03-06 05:26:54 +01:00
|
|
|
u8 fill[0x18];
|
2009-01-17 15:05:13 +01:00
|
|
|
u8 korean_key[16];
|
|
|
|
};
|
2009-03-06 05:26:54 +01:00
|
|
|
u8 data[256];
|
2009-01-17 15:05:13 +01:00
|
|
|
};
|
|
|
|
} __attribute__((packed)) seeprom_t;
|
|
|
|
|
|
|
|
extern otp_t otp;
|
|
|
|
|
|
|
|
void crypto_read_otp();
|
2009-01-30 13:43:35 +01:00
|
|
|
void crypto_ipc(volatile ipc_request *req);
|
2009-01-17 15:05:13 +01:00
|
|
|
|
|
|
|
void crypto_initialize();
|
|
|
|
|
|
|
|
void aes_reset(void);
|
|
|
|
void aes_set_iv(u8 *iv);
|
|
|
|
void aes_empty_iv();
|
|
|
|
void aes_set_key(u8 *key);
|
|
|
|
void aes_decrypt(u8 *src, u8 *dst, u32 blocks, u8 keep_iv);
|
2009-01-30 13:43:35 +01:00
|
|
|
void aes_ipc(volatile ipc_request *req);
|
2009-01-17 15:05:13 +01:00
|
|
|
|
|
|
|
#endif
|
2009-04-13 22:13:45 +02:00
|
|
|
|