Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
273 theseven 1
//
2
//
3
//    Copyright 2010 TheSeven
4
//
5
//
6
//    This file is part of emBIOS.
7
//
8
//    emBIOS is free software: you can redistribute it and/or
9
//    modify it under the terms of the GNU General Public License as
10
//    published by the Free Software Foundation, either version 2 of the
11
//    License, or (at your option) any later version.
12
//
13
//    emBIOS is distributed in the hope that it will be useful,
14
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
//    See the GNU General Public License for more details.
17
//
18
//    You should have received a copy of the GNU General Public License along
19
//    with emBIOS.  If not, see <http://www.gnu.org/licenses/>.
20
//
21
//
22
 
23
 
24
#include "global.h"
25
#include "hwkeyaes.h"
26
#include "s5l8702.h"
27
#include "thread.h"
28
 
29
 
30
void hwkeyaes(enum hwkeyaes_direction direction, uint32_t keyidx, void* data, uint32_t size)
31
{
32
    int i;
33
    clockgate_enable(7, true);
34
    for (i = 0; i < 4; i++) AESIV[i] = 0;
35
    AESUNKREG0 = 1;
36
    AESUNKREG0 = 0;
37
    AESCONTROL = 1;
38
    AESUNKREG1 = 0;
39
    AESTYPE = keyidx;
40
    AESTYPE2 = ~AESTYPE;
41
    AESUNKREG2 = 0;
42
    AESKEYLEN = direction == HWKEYAES_ENCRYPT ? 9 : 8;
43
    AESOUTSIZE = size;
44
    AESOUTADDR = data;
45
    AESINSIZE = size;
46
    AESINADDR = data;
47
    AESAUXSIZE = size;
48
    AESAUXADDR = data;
49
    AESSIZE3 = size;
50
	clean_dcache();
51
    AESGO = 1;
52
	invalidate_dcache();
53
    while (!(AESSTATUS & 0xf)) sleep(100);
54
    clockgate_enable(7, false);
55
}