From 67a8d1ff999b97ec2fbb000d15891ace4f282a2d Mon Sep 17 00:00:00 2001 From: markm Date: Mon, 2 Jun 2003 21:43:14 +0000 Subject: Tidy the code up a fraction. Re-release with a 2-clause BSD license with the kind permission of the author/copyright holder. Thanks to: phk --- lib/libcrypt/crypt-md5.c | 52 ++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 19 deletions(-) (limited to 'lib/libcrypt') diff --git a/lib/libcrypt/crypt-md5.c b/lib/libcrypt/crypt-md5.c index 49710d6..33186cd 100644 --- a/lib/libcrypt/crypt-md5.c +++ b/lib/libcrypt/crypt-md5.c @@ -1,20 +1,40 @@ -/* - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp - * ---------------------------------------------------------------------------- +/*- + * Copyright (c) 2003 Poul-Henning Kamp + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); -#include +#include + +#include +#include #include #include -#include -#include +#include + #include "crypt.h" /* @@ -31,12 +51,7 @@ crypt_md5(const char *pw, const char *salt) u_char final[MD5_SIZE]; static const char *sp, *ep; static char passwd[120], *p; - static const char *magic = "$1$"; /* - * This string is magic for - * this algorithm. Having - * it this way, we can get - * better later on. - */ + static const char *magic = "$1$"; /* Refine the Salt first */ sp = salt; @@ -127,13 +142,12 @@ crypt_md5(const char *pw, const char *salt) _crypt_to64(p, l, 4); p += 4; l = (final[ 4]<<16) | (final[10]<<8) | final[ 5]; _crypt_to64(p, l, 4); p += 4; - l = final[11] ; + l = final[11]; _crypt_to64(p, l, 2); p += 2; *p = '\0'; /* Don't leave anything around in vm they could use. */ memset(final, 0, sizeof(final)); - return passwd; + return (passwd); } - -- cgit v1.1