Updating lib/libcrypt
Change-Id: I4dc5ca7c86abc5295ffc57386a14dd1d790fd489
This commit is contained in:
+7
-19
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: md5crypt.c,v 1.9 2007/01/17 23:24:22 hubertf Exp $ */
|
||||
/* $NetBSD: md5crypt.c,v 1.12 2012/08/30 12:16:49 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
@@ -15,38 +15,22 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if !defined(lint)
|
||||
__RCSID("$NetBSD: md5crypt.c,v 1.9 2007/01/17 23:24:22 hubertf Exp $");
|
||||
__RCSID("$NetBSD: md5crypt.c,v 1.12 2012/08/30 12:16:49 drochner Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* NOTE: We are also built for inclusion in libcrypto; when built for that
|
||||
* environment, use the libcrypto versions of the MD5 routines, so save
|
||||
* having to pull two versions into the same program.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef libcrypto
|
||||
#include <openssl/md5.h>
|
||||
#else
|
||||
#include <md5.h>
|
||||
#endif
|
||||
|
||||
#include "crypt.h"
|
||||
|
||||
#define MD5_MAGIC "$1$"
|
||||
#define MD5_MAGIC_LEN 3
|
||||
|
||||
#ifdef libcrypto
|
||||
#define INIT(x) MD5_Init((x))
|
||||
#define UPDATE(x, b, l) MD5_Update((x), (b), (l))
|
||||
#define FINAL(v, x) MD5_Final((v), (x))
|
||||
#else
|
||||
#define INIT(x) MD5Init((x))
|
||||
#define UPDATE(x, b, l) MD5Update((x), (b), (l))
|
||||
#define FINAL(v, x) MD5Final((v), (x))
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ -117,6 +101,8 @@ __md5crypt(const char *pw, const char *salt)
|
||||
|
||||
FINAL(final, &ctx);
|
||||
|
||||
/* memset(&ctx, 0, sizeof(ctx)); done by MD5Final() */
|
||||
|
||||
/*
|
||||
* And now, just to make sure things don't run too fast. On a 60 MHz
|
||||
* Pentium this takes 34 msec, so you would need 30 seconds to build
|
||||
@@ -144,6 +130,8 @@ __md5crypt(const char *pw, const char *salt)
|
||||
FINAL(final, &ctx1);
|
||||
}
|
||||
|
||||
/* memset(&ctx1, 0, sizeof(ctx1)); done by MD5Final() */
|
||||
|
||||
p = passwd + sl + MD5_MAGIC_LEN + 1;
|
||||
|
||||
l = (final[ 0]<<16) | (final[ 6]<<8) | final[12]; __crypt_to64(p,l,4); p += 4;
|
||||
@@ -155,6 +143,6 @@ __md5crypt(const char *pw, const char *salt)
|
||||
*p = '\0';
|
||||
|
||||
/* Don't leave anything around in vm they could use. */
|
||||
memset(final, 0, sizeof(final));
|
||||
__explicit_bzero(final, sizeof(final));
|
||||
return (passwd);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user