Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 theseven 1
//
2
//
143 theseven 3
//    Copyright 2010 TheSeven
2 theseven 4
//
5
//
427 farthen 6
//    This file is part of emCORE.
2 theseven 7
//
427 farthen 8
//    emCORE is free software: you can redistribute it and/or
2 theseven 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
//
427 farthen 13
//    emCORE is distributed in the hope that it will be useful,
2 theseven 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
427 farthen 19
//    with emCORE.  If not, see <http://www.gnu.org/licenses/>.
2 theseven 20
//
21
//
22
 
23
 
143 theseven 24
#include "global.h"
25
#include "hmacsha1.h"
26
#include "s5l8701.h"
27
#include "thread.h"
2 theseven 28
 
29
 
387 theseven 30
struct mutex hmacsha1_mutex;
31
 
32
 
143 theseven 33
void hmacsha1(void* data, uint32_t size, void* result)
2 theseven 34
{
35
    uint32_t ptr, i;
36
    uint32_t ctrl = 2;
387 theseven 37
    mutex_lock(&hmacsha1_mutex, TIMEOUT_BLOCK);
143 theseven 38
    PWRCON(1) &= ~4;
39
    for (ptr = 0; ptr < (size >> 2); ptr += 0x10)
2 theseven 40
    {
41
      for (i = 0; i < 0x10; i++) HASHDATAIN[i] = ((uint32_t*)data)[ptr + i];
42
      HASHCTRL = ctrl;
43
      ctrl = 0xA;
143 theseven 44
      while (HASHCTRL & 1) yield();
2 theseven 45
    }
46
    for (i = 0; i < 5; i ++) ((uint32_t*)result)[i] = HASHRESULT[i];
143 theseven 47
    PWRCON(1) |= 4;
387 theseven 48
    mutex_unlock(&hmacsha1_mutex);
2 theseven 49
}