-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathaes.c
69 lines (62 loc) · 1.34 KB
/
aes.c
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
/*
BootMii - a Free Software replacement for the Nintendo/BroadOn IOS.
Requires mini.
aes
# 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
*/
#include "bootmii_ppc.h"
#include "string.h"
#include "aes.h"
#include "malloc.h"
#if !HARDWARE_AES
#include "main.h"
static u8 aes_iv[16];
void aes_reset(void) {}
void aes_set_iv(u8 *iv)
{
memcpy(aes_iv, iv, 16);
}
void aes_set_key(u8 *key)
{
my_aes_set_key(key);
}
void aes_decrypt(u8 *src, u8 *dst, u32 blocks, u8 keep_iv)
{
(void)keep_iv;
if(src == dst) {
#ifdef MSPACES
u8 *p = mspace_malloc(mem2space, 16*blocks);
#else
u8 *p = (void *)0x92000000;//malloc(16*blocks);
#endif
my_aes_decrypt(aes_iv, src, p, 16*blocks);
memcpy(dst, p, 16*blocks);
#ifdef MSPACES
mspace_free(mem2space, p);
#else
//free(p);
#endif
} else
my_aes_decrypt(aes_iv, src, dst, 16*blocks);
}
void aes_encrypt(u8 *src, u8 *dst, u32 blocks, u8 keep_iv)
{
(void)keep_iv;
if(src == dst) {
#ifdef MSPACES
u8 *p = mspace_malloc(mem2space, 16*blocks);
#else
u8 *p = (void *)92000000;//malloc(16*blocks);
#endif
my_aes_encrypt(aes_iv, src, p, 16*blocks);
memcpy(dst, p, 16*blocks);
#ifdef MSPACES
mspace_free(mem2space, p);
#else
//free(p);
#endif
} else
my_aes_encrypt(aes_iv, src, dst, 16*blocks);
}
#endif