-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcrypto.h
82 lines (69 loc) · 1.5 KB
/
crypto.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
mini - a Free Software replacement for the Nintendo/BroadOn IOS.
crypto hardware support
Copyright (C) 2008, 2009 Haxx Enterprises <[email protected]>
Copyright (C) 2008, 2009 Sven Peter <[email protected]>
Copyright (C) 2008, 2009 Hector Martin "marcan" <[email protected]>
# 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
*/
#ifndef __CRYPTO_H__
#define __CRYPTO_H__
#include "types.h"
#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
{
u8 boot2version;
u8 unknown1;
u8 unknown2;
u8 pad;
u32 update_tag;
u16 checksum;
} __attribute__((packed)) eep_ctr_t;
typedef struct
{
union {
struct {
u32 ms_id;
u32 ca_id;
u32 ng_key_id;
u8 ng_sig[60];
eep_ctr_t counters[2];
u8 fill[0x18];
u8 korean_key[16];
};
u8 data[256];
};
} __attribute__((packed)) seeprom_t;
extern otp_t otp;
extern seeprom_t seeprom;
void crypto_read_otp();
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);
void aes_ipc(volatile ipc_request *req);
#endif