summaryrefslogtreecommitdiffstats
path: root/lib/libcrypt
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2003-06-02 21:43:14 +0000
committermarkm <markm@FreeBSD.org>2003-06-02 21:43:14 +0000
commit67a8d1ff999b97ec2fbb000d15891ace4f282a2d (patch)
tree8ef3f87e8c7c2f82541a3e37baceac0edcddcb6c /lib/libcrypt
parent52a564bd3f35ffd01f53a0488307386dc1d2a0e8 (diff)
downloadFreeBSD-src-67a8d1ff999b97ec2fbb000d15891ace4f282a2d.zip
FreeBSD-src-67a8d1ff999b97ec2fbb000d15891ace4f282a2d.tar.gz
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
Diffstat (limited to 'lib/libcrypt')
-rw-r--r--lib/libcrypt/crypt-md5.c52
1 files changed, 33 insertions, 19 deletions
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):
- * <phk@FreeBSD.org> 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 <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <unistd.h>
+#include <sys/types.h>
+
+#include <err.h>
+#include <md5.h>
#include <stdio.h>
#include <string.h>
-#include <md5.h>
-#include <err.h>
+#include <unistd.h>
+
#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);
}
-
OpenPOWER on IntegriCloud