crypt.c revision 51462
11984Scsgr/* 251462Smarkm * Copyright (c) 1999 351462Smarkm * Mark Murray. All rights reserved. 443092Smarkm * 551462Smarkm * Redistribution and use in source and binary forms, with or without 651462Smarkm * modification, are permitted provided that the following conditions 751462Smarkm * are met: 851462Smarkm * 1. Redistributions of source code must retain the above copyright 951462Smarkm * notice, this list of conditions and the following disclaimer. 1051462Smarkm * 2. Redistributions in binary form must reproduce the above copyright 1151462Smarkm * notice, this list of conditions and the following disclaimer in the 1251462Smarkm * documentation and/or other materials provided with the distribution. 1351462Smarkm * 1451462Smarkm * THIS SOFTWARE IS PROVIDED BY MARK MURRAY AND CONTRIBUTORS ``AS IS'' AND 1551462Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1651462Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1751462Smarkm * ARE DISCLAIMED. IN NO EVENT SHALL MARK MURRAY OR CONTRIBUTORS BE LIABLE 1851462Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1951462Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2051462Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2151462Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2251462Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2351462Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2451462Smarkm * SUCH DAMAGE. 2551462Smarkm * 2650476Speter * $FreeBSD: head/lib/libcrypt/crypt.c 51462 1999-09-20 12:45:49Z markm $ 2743092Smarkm * 2842981Sbrandon */ 2942981Sbrandon 3043092Smarkm#if defined(LIBC_SCCS) && !defined(lint) 3150488Speterstatic char rcsid[] = "$FreeBSD: head/lib/libcrypt/crypt.c 51462 1999-09-20 12:45:49Z markm $"; 3243092Smarkm#endif /* LIBC_SCCS and not lint */ 3342981Sbrandon 3417141Sjkh#include <string.h> 3551462Smarkm#include "crypt.h" 361984Scsgr 3743092Smarkmchar * 3851462Smarkmcrypt(char *passwd, char *salt) 391984Scsgr{ 4051462Smarkm if (!strncmp(salt, "$1$", 3)) 4151462Smarkm return crypt_md5(passwd, salt); 4251462Smarkm if (!strncmp(salt, "$3$", 3)) 4351462Smarkm return crypt_sha(passwd, salt); 4451462Smarkm#ifdef NONEXPORTABLE_CRYPT 4551462Smarkm return crypt_des(passwd, salt); 4651462Smarkm#else 4751462Smarkm return NULL; 4851462Smarkm#endif 491984Scsgr} 50