crypt.c revision 55535
1254322Serwin/*
2254322Serwin * Copyright (c) 1999
3254322Serwin *      Mark Murray.  All rights reserved.
4254322Serwin *
5254322Serwin * Redistribution and use in source and binary forms, with or without
6254322Serwin * modification, are permitted provided that the following conditions
7254322Serwin * are met:
8254322Serwin * 1. Redistributions of source code must retain the above copyright
9254322Serwin *    notice, this list of conditions and the following disclaimer.
10254322Serwin * 2. Redistributions in binary form must reproduce the above copyright
11254322Serwin *    notice, this list of conditions and the following disclaimer in the
12254322Serwin *    documentation and/or other materials provided with the distribution.
13254322Serwin *
14254322Serwin * THIS SOFTWARE IS PROVIDED BY MARK MURRAY AND CONTRIBUTORS ``AS IS'' AND
15254322Serwin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16254322Serwin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17254322Serwin * ARE DISCLAIMED.  IN NO EVENT SHALL MARK MURRAY OR CONTRIBUTORS BE LIABLE
18254322Serwin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19254322Serwin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20254322Serwin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21254322Serwin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22254322Serwin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23254322Serwin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24254322Serwin * SUCH DAMAGE.
25254322Serwin *
26254322Serwin * $FreeBSD: head/lib/libcrypt/crypt.c 55535 2000-01-07 06:33:54Z kris $
27254322Serwin *
28254322Serwin */
29254322Serwin
30254322Serwin#if defined(LIBC_SCCS) && !defined(lint)
31254322Serwinstatic char rcsid[] = "$FreeBSD: head/lib/libcrypt/crypt.c 55535 2000-01-07 06:33:54Z kris $";
32254322Serwin#endif /* LIBC_SCCS and not lint */
33254322Serwin
34254322Serwin#include <string.h>
35254322Serwin#include "crypt.h"
36254322Serwin
37254322Serwinchar *
38254322Serwincrypt(char *passwd, char *salt)
39254322Serwin{
40254322Serwin	if (!strncmp(salt, "$1$", 3))
41254322Serwin		return crypt_md5(passwd, salt);
42254322Serwin#ifdef NONEXPORTABLE_CRYPT
43254322Serwin	return crypt_des(passwd, salt);
44254322Serwin#else
45254322Serwin	return crypt_md5(passwd, salt);
46254322Serwin#endif
47254322Serwin}
48254322Serwin