2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 *************************************************************************
34 -------- ---------- ----------------------------------------------
35 Name Date Modification logs
37 Rita 11-23-04 Modify MD5 and SHA-1
41 #define uint8 unsigned char
45 #define uint32 unsigned long int
52 #define MD5_MAC_LEN 16
54 typedef struct _MD5_CTX
{
55 UINT32 Buf
[4]; // buffers of four states
56 UCHAR Input
[64]; // input message
57 UINT32 LenInBitCount
[2]; // length counter for input message, 0 up to 64 bits
60 VOID
MD5Init(MD5_CTX
*pCtx
);
61 VOID
MD5Update(MD5_CTX
*pCtx
, UCHAR
*pData
, UINT32 LenInBytes
);
62 VOID
MD5Final(UCHAR Digest
[16], MD5_CTX
*pCtx
);
63 VOID
MD5Transform(UINT32 Buf
[4], UINT32 Mes
[16]);
65 void md5_mac(u8
*key
, size_t key_len
, u8
*data
, size_t data_len
, u8
*mac
);
66 void hmac_md5(u8
*key
, size_t key_len
, u8
*data
, size_t data_len
, u8
*mac
);
71 typedef struct _SHA_CTX
73 UINT32 Buf
[5]; // buffers of five states
74 UCHAR Input
[80]; // input message
75 UINT32 LenInBitCount
[2]; // length counter for input message, 0 up to 64 bits
79 VOID
SHAInit(SHA_CTX
*pCtx
);
80 UCHAR
SHAUpdate(SHA_CTX
*pCtx
, UCHAR
*pData
, UINT32 LenInBytes
);
81 VOID
SHAFinal(SHA_CTX
*pCtx
, UCHAR Digest
[20]);
82 VOID
SHATransform(UINT32 Buf
[5], UINT32 Mes
[20]);
84 #define SHA_DIGEST_LEN 20
87 /******************************************************************************/
93 uint32 erk
[64]; /* encryption round keys */
94 uint32 drk
[64]; /* decryption round keys */
95 int nr
; /* number of rounds */
99 int rtmp_aes_set_key( aes_context
*ctx
, uint8
*key
, int nbits
);
100 void rtmp_aes_encrypt( aes_context
*ctx
, uint8 input
[16], uint8 output
[16] );
101 void rtmp_aes_decrypt( aes_context
*ctx
, uint8 input
[16], uint8 output
[16] );
103 void F(char *password
, unsigned char *ssid
, int ssidlength
, int iterations
, int count
, unsigned char *output
);
104 int PasswordHash(char *password
, unsigned char *ssid
, int ssidlength
, unsigned char *output
);