1 /* hash.c: The opiehash() library function.
4 This software is Copyright 1996-2001 by Craig Metz, All Rights Reserved.
5 The Inner Net License Version 3 applies to this software.
6 You should have received a copy of the license with this software. If
7 you didn't get a copy, you may request one from <license@inner.net>.
11 Modified by cmetz for OPIE 2.4. Use struct opie_otpkey for binary arg.
12 Modified by cmetz for OPIE 2.31. Added SHA support (which may
13 not be correct). Backed out previous optimizations as
14 they killed thread-safety.
15 Created by cmetz for OPIE 2.3 using the old hash.c as a guide.
27 VOIDRET opiehash FUNCTION((x, algorithm), struct opie_otpkey *x AND
30 UINT4 *results = (UINT4 *)x;
38 SHA1_Update(&sha, (unsigned char *)x, 8);
39 SHA1_Final((unsigned char *)digest, &sha);
40 results[0] = digest[0] ^ digest[2] ^ digest[4];
41 results[1] = digest[1] ^ digest[3];
50 MD4Update(&mdx, (unsigned char *)x, 8);
51 MD4Final((unsigned char *)mdx_tmp, &mdx);
52 results[0] = mdx_tmp[0] ^ mdx_tmp[2];
53 results[1] = mdx_tmp[1] ^ mdx_tmp[3];
62 MD5Update(&mdx, (unsigned char *)x, 8);
63 MD5Final((unsigned char *)mdx_tmp, &mdx);
64 results[0] = mdx_tmp[0] ^ mdx_tmp[2];
65 results[1] = mdx_tmp[1] ^ mdx_tmp[3];