1 /* keycrunch.c: The opiekeycrunch() 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 arg.
12 Created by cmetz for OPIE 2.3 using the old keycrunch.c as a guide.
19 #endif /* HAVE_STRING_H */
22 #endif /* HAVE_STDLIB_H */
27 int opiekeycrunch
FUNCTION((algorithm
, result
, seed
, secret
), int algorithm AND
28 struct opie_otpkey
*result AND
char *seed AND
char *secret
)
33 if (!result
|| !seed
|| !secret
)
36 i
= strlen(seed
) + strlen(secret
);
37 if (!(c
= malloc(i
+ 1)))
44 while(*c2
= *(secret
++)) c2
++;
47 if (isspace(*(c2
++) = tolower(*(seed
++))))
50 if (!(algorithm
& 0x10))
54 opiehashlen(algorithm
& 0x0f, c
, result
, i
);