Deleted Added
full compact
hash.c (22371) hash.c (29967)
1/* hash.c: The opiehash() library function.
2
1/* hash.c: The opiehash() library function.
2
3%%% copyright-cmetz
4This software is Copyright 1996 by Craig Metz, All Rights Reserved.
3%%% copyright-cmetz-96
4This software is Copyright 1996-1997 by Craig Metz, All Rights Reserved.
5The Inner Net License Version 2 applies to this software.
6You should have received a copy of the license with this software. If
7you didn't get a copy, you may request one from <license@inner.net>.
8
9 History:
10
5The Inner Net License Version 2 applies to this software.
6You should have received a copy of the license with this software. If
7you didn't get a copy, you may request one from <license@inner.net>.
8
9 History:
10
11 Updated by cmetz for OPIE 2.31. Added SHA support (which may
12 not be correct). Backed out previous optimizations as
13 they killed thread-safety.
11 Created by cmetz for OPIE 2.3 using the old hash.c as a guide.
12*/
13
14#include "opie_cfg.h"
14 Created by cmetz for OPIE 2.3 using the old hash.c as a guide.
15*/
16
17#include "opie_cfg.h"
18#if 0
19#include "sha.h"
20#endif /* 0 */
15#include "opie.h"
16
17#include <md4.h>
18#include <md5.h>
19
21#include "opie.h"
22
23#include <md4.h>
24#include <md5.h>
25
20static UINT4 mdx_tmp[4];
21#if 0
22static SHA_INFO sha;
23#endif /* 0 */
24
25VOIDRET opiehash FUNCTION((x, algorithm), VOIDPTR x AND unsigned algorithm)
26{
27 UINT4 *results = (UINT4 *)x;
28
29 switch(algorithm) {
30#if 0
31 case 3:
26VOIDRET opiehash FUNCTION((x, algorithm), VOIDPTR x AND unsigned algorithm)
27{
28 UINT4 *results = (UINT4 *)x;
29
30 switch(algorithm) {
31#if 0
32 case 3:
32 sha_init(&sha);
33 sha_update(&sha, (BYTE *)x, 8);
34 sha_final(&sha);
35 results[0] = sha.digest[0] ^ sha.digest[2] ^ sha.digest[4];
36 results[1] = sha.digest[1] ^ sha.digest[3] ^ sha.digest[5];
33 {
34 SHA_CTX sha;
35 SHAInit(&sha);
36 SHAUpdate(&sha, (unsigned char *)x, 8);
37 SHAFinal(&sha);
38 results[0] = sha.buffer[0] ^ sha.buffer[2] ^ sha.buffer[4];
39 results[1] = sha.buffer[1] ^ sha.buffer[3];
40 };
37 break;
38#endif /* 0 */
41 break;
42#endif /* 0 */
39 case 4: {
43 case 4:
44 {
40 MD4_CTX mdx;
45 MD4_CTX mdx;
46 UINT4 mdx_tmp[4];
47
41 MD4Init(&mdx);
42 MD4Update(&mdx, (unsigned char *)x, 8);
43 MD4Final((unsigned char *)mdx_tmp, &mdx);
44 results[0] = mdx_tmp[0] ^ mdx_tmp[2];
45 results[1] = mdx_tmp[1] ^ mdx_tmp[3];
48 MD4Init(&mdx);
49 MD4Update(&mdx, (unsigned char *)x, 8);
50 MD4Final((unsigned char *)mdx_tmp, &mdx);
51 results[0] = mdx_tmp[0] ^ mdx_tmp[2];
52 results[1] = mdx_tmp[1] ^ mdx_tmp[3];
53 };
46 break;
54 break;
47 }
48 case 5: {
55 case 5:
56 {
49 MD5_CTX mdx;
57 MD5_CTX mdx;
58 UINT4 mdx_tmp[4];
59
50 MD5Init(&mdx);
51 MD5Update(&mdx, (unsigned char *)x, 8);
52 MD5Final((unsigned char *)mdx_tmp, &mdx);
53 results[0] = mdx_tmp[0] ^ mdx_tmp[2];
54 results[1] = mdx_tmp[1] ^ mdx_tmp[3];
60 MD5Init(&mdx);
61 MD5Update(&mdx, (unsigned char *)x, 8);
62 MD5Final((unsigned char *)mdx_tmp, &mdx);
63 results[0] = mdx_tmp[0] ^ mdx_tmp[2];
64 results[1] = mdx_tmp[1] ^ mdx_tmp[3];
65 };
55 break;
66 break;
56 }
57 }
58}
67 }
68}