throttle speed before ejection
[aversive.git] / modules / crypto / md5 / hmac_md5.c
1 /*  
2  *  Copyright Droids Corporation, Microb Technology, Eirbot (2005)
3  * 
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  *
18  *  Revision : $Id: hmac_md5.c,v 1.2.4.1 2006-11-26 21:06:02 zer0 Exp $
19  *
20  */
21
22 #include <string.h>
23 #include "md5.h"
24
25 void HMAC_MD5 (unsigned char *output, const unsigned char *input, 
26                unsigned char *key, unsigned int inputLen, unsigned int keyLen)
27 {
28         unsigned int i;
29         MD5_CTX context;
30         unsigned char key_tmp[64];      
31         
32         for (i=0;i<64;i++)
33                 key_tmp[i] = (i<keyLen)?key[i]^0x36:0x36;
34
35         MD5Init(&context);
36         MD5Update(&context, key_tmp, 64);
37         MD5Update(&context, input, inputLen);
38         MD5Final(output, &context);
39
40         for (i=0;i<64;i++)
41                 key_tmp[i] = (i<keyLen)?key[i]^0x5c:0x5c;
42
43
44         MD5Init(&context);
45         MD5Update(&context, key_tmp, 64);
46         MD5Update(&context, output, 16);
47         MD5Final(output, &context);
48 }
49