mini/crypto.h

83 lines
1.5 KiB
C
Raw Permalink Normal View History

/*
mini - a Free Software replacement for the Nintendo/BroadOn IOS.
2009-05-11 07:53:16 +02:00
crypto hardware 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-05-11 07:53:16 +02: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
*/
2009-05-11 07:53:16 +02:00
#ifndef __CRYPTO_H__
2009-04-13 22:13:45 +02:00
#define __CRYPTO_H__
#include "types.h"
2009-01-30 13:43:35 +01:00
#include "ipc.h"
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;
u32 unk2; // 0x00000007
} __attribute__((packed)) otp_t;
typedef struct
{
2009-03-10 07:05:11 +01:00
u8 boot2version;
u8 unknown1;
u8 unknown2;
u8 pad;
u32 update_tag;
u16 checksum;
2009-03-10 07:05:11 +01:00
} __attribute__((packed)) eep_ctr_t;
typedef struct
{
union {
struct {
2010-07-14 16:59:47 +02:00
u32 ms_id;
u32 ca_id;
u32 ng_key_id;
u8 ng_sig[60];
2009-03-10 07:05:11 +01:00
eep_ctr_t counters[2];
u8 fill[0x18];
u8 korean_key[16];
};
u8 data[256];
};
} __attribute__((packed)) seeprom_t;
extern otp_t otp;
2010-07-14 17:10:52 +02:00
extern seeprom_t seeprom;
void crypto_read_otp();
2009-01-30 13:43:35 +01:00
void crypto_ipc(volatile ipc_request *req);
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);
#endif
2009-04-13 22:13:45 +02:00