diff options
Diffstat (limited to 'lib/libcrypt')
-rw-r--r-- | lib/libcrypt/Makefile | 41 | ||||
-rw-r--r-- | lib/libcrypt/crypt-md5.c | 6 | ||||
-rw-r--r-- | lib/libcrypt/crypt-nthash.c | 11 | ||||
-rw-r--r-- | lib/libcrypt/crypt-sha256.c | 7 | ||||
-rw-r--r-- | lib/libcrypt/crypt-sha512.c | 7 | ||||
-rw-r--r-- | lib/libcrypt/crypt.c | 1 | ||||
-rw-r--r-- | lib/libcrypt/libcrypt.aldscript | 1 | ||||
-rw-r--r-- | lib/libcrypt/libcrypt.ldscript | 1 | ||||
-rw-r--r-- | lib/libcrypt/misc.c | 1 | ||||
-rw-r--r-- | lib/libcrypt/tests/Makefile | 1 |
10 files changed, 40 insertions, 37 deletions
diff --git a/lib/libcrypt/Makefile b/lib/libcrypt/Makefile index 9511bba81e26..e939bae1bc25 100644 --- a/lib/libcrypt/Makefile +++ b/lib/libcrypt/Makefile @@ -1,6 +1,3 @@ -# -# - SHLIBDIR?= /lib .include <src.opts.mk> @@ -10,12 +7,11 @@ PACKAGE= runtime SHLIB_MAJOR= 5 LIB= crypt -.PATH: ${SRCTOP}/lib/libmd ${SRCTOP}/sys/crypto/sha2 SRCS= crypt.c misc.c \ - crypt-md5.c md5c.c \ - crypt-nthash.c md4c.c \ - crypt-sha256.c sha256c.c \ - crypt-sha512.c sha512c.c + crypt-md5.c \ + crypt-nthash.c \ + crypt-sha256.c \ + crypt-sha512.c MAN= crypt.3 MLINKS= crypt.3 crypt_get_format.3 crypt.3 crypt_r.3 \ crypt.3 crypt_set_format.3 @@ -29,17 +25,6 @@ SRCS+= crypt-des.c crypt-blowfish.c blowfish.c CFLAGS+= -I${.CURDIR} -DHAS_DES -DHAS_BLOWFISH .endif -.for sym in MD4Init MD4Final MD4Update MD4Pad \ - MD5Init MD5Final MD5Update MD5Pad \ - SHA224_Init SHA224_Final SHA224_Update \ - SHA256_Init SHA256_Final SHA256_Update \ - SHA512_224_Init SHA512_224_Final SHA512_224_Update \ - SHA512_256_Init SHA512_256_Final SHA512_256_Update \ - SHA384_Init SHA384_Final SHA384_Update \ - SHA512_Init SHA512_Final SHA512_Update -CFLAGS+= -D${sym}=__${sym} -.endfor - WARNS?= 2 PRECIOUSLIB= @@ -47,4 +32,22 @@ PRECIOUSLIB= HAS_TESTS= SUBDIR.${MK_TESTS}+= tests +LIBADD+= md +SHLIB_LDSCRIPT= libcrypt.ldscript +STATIC_LDSCRIPT= libcrypt.aldscript +CLEANFILES+= libcrypt.ald + +libcrypt.ald: ${.CURDIR}/${STATIC_LDSCRIPT} + sed -e 's,@@LIB@@,${LIB},g' \ + -e 's,@@STATICLIB_SUFFIX@@,${_STATICLIB_SUFFIX},g' \ + ${.ALLSRC} > ${.TARGET} + +all: ${STATIC_LDSCRIPT} libcrypt.ald + +install-libcrypt.a: libcrypt.ald + ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${_INSTALLFLAGS} libcrypt.ald ${DESTDIR}${_LIBDIR}/lib${LIB}.a + +realinstall: install-libcrypt.a + .include <bsd.lib.mk> diff --git a/lib/libcrypt/crypt-md5.c b/lib/libcrypt/crypt-md5.c index 3fb80c1ba540..609fbbf67b77 100644 --- a/lib/libcrypt/crypt-md5.c +++ b/lib/libcrypt/crypt-md5.c @@ -26,13 +26,13 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> #include <sys/types.h> #include <err.h> #include <md5.h> #include <stdio.h> #include <string.h> +#include <strings.h> #include <unistd.h> #include "crypt.h" @@ -85,7 +85,7 @@ crypt_md5(const char *pw, const char *salt, char *buffer) (u_int)(pl > MD5_SIZE ? MD5_SIZE : pl)); /* Don't leave anything around in vm they could use. */ - memset(final, 0, sizeof(final)); + explicit_bzero(final, sizeof(final)); /* Then something really weird... */ for (i = strlen(pw); i; i >>= 1) @@ -141,7 +141,7 @@ crypt_md5(const char *pw, const char *salt, char *buffer) *buffer = '\0'; /* Don't leave anything around in vm they could use. */ - memset(final, 0, sizeof(final)); + explicit_bzero(final, sizeof(final)); return (0); } diff --git a/lib/libcrypt/crypt-nthash.c b/lib/libcrypt/crypt-nthash.c index 28c832dd6f9f..774fe3437c25 100644 --- a/lib/libcrypt/crypt-nthash.c +++ b/lib/libcrypt/crypt-nthash.c @@ -26,7 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> #include <sys/types.h> #include <netinet/in.h> @@ -57,17 +56,17 @@ crypt_nthash(const char *pw, const char *salt __unused, char *buffer) u_char hash[MD4_SIZE]; const char *s; MD4_CTX ctx; - - bzero(unipw, sizeof(unipw)); + + bzero(unipw, sizeof(unipw)); /* convert to unicode (thanx Archie) */ unipwLen = 0; for (s = pw; unipwLen < sizeof(unipw) / 2 && *s; s++) unipw[unipwLen++] = htons(*s << 8); - + /* Compute MD4 of Unicode password */ - MD4Init(&ctx); + MD4Init(&ctx); MD4Update(&ctx, (u_char *)unipw, unipwLen*sizeof(u_int16_t)); - MD4Final(hash, &ctx); + MD4Final(hash, &ctx); buffer = stpcpy(buffer, magic); *buffer++ = '$'; diff --git a/lib/libcrypt/crypt-sha256.c b/lib/libcrypt/crypt-sha256.c index 35c36bf93f3d..6da1d518b12d 100644 --- a/lib/libcrypt/crypt-sha256.c +++ b/lib/libcrypt/crypt-sha256.c @@ -41,6 +41,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <strings.h> #include "crypt.h" @@ -234,9 +235,9 @@ crypt_sha256(const char *key, const char *salt, char *buffer) * the SHA256 implementation as well. */ SHA256_Init(&ctx); SHA256_Final(alt_result, &ctx); - memset(temp_result, '\0', sizeof(temp_result)); - memset(p_bytes, '\0', key_len); - memset(s_bytes, '\0', salt_len); + explicit_bzero(temp_result, sizeof(temp_result)); + explicit_bzero(p_bytes, key_len); + explicit_bzero(s_bytes, salt_len); return (0); } diff --git a/lib/libcrypt/crypt-sha512.c b/lib/libcrypt/crypt-sha512.c index 640398afadc4..b760623b5d8d 100644 --- a/lib/libcrypt/crypt-sha512.c +++ b/lib/libcrypt/crypt-sha512.c @@ -41,6 +41,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <strings.h> #include "crypt.h" @@ -246,9 +247,9 @@ crypt_sha512(const char *key, const char *salt, char *buffer) * the SHA512 implementation as well. */ SHA512_Init(&ctx); SHA512_Final(alt_result, &ctx); - memset(temp_result, '\0', sizeof(temp_result)); - memset(p_bytes, '\0', key_len); - memset(s_bytes, '\0', salt_len); + explicit_bzero(temp_result, sizeof(temp_result)); + explicit_bzero(p_bytes, key_len); + explicit_bzero(s_bytes, salt_len); return (0); } diff --git a/lib/libcrypt/crypt.c b/lib/libcrypt/crypt.c index b4d0743df6cf..aaf3552f95ff 100644 --- a/lib/libcrypt/crypt.c +++ b/lib/libcrypt/crypt.c @@ -27,7 +27,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> #include <sys/types.h> #include <string.h> diff --git a/lib/libcrypt/libcrypt.aldscript b/lib/libcrypt/libcrypt.aldscript new file mode 100644 index 000000000000..cfc8020dd9e3 --- /dev/null +++ b/lib/libcrypt/libcrypt.aldscript @@ -0,0 +1 @@ +INPUT(-l@@LIB@@@@STATICLIB_SUFFIX@@ -lmd) diff --git a/lib/libcrypt/libcrypt.ldscript b/lib/libcrypt/libcrypt.ldscript new file mode 100644 index 000000000000..a0b20fa43fe8 --- /dev/null +++ b/lib/libcrypt/libcrypt.ldscript @@ -0,0 +1 @@ +INPUT(@@SHLIB@@ AS_NEEDED(-lmd)) diff --git a/lib/libcrypt/misc.c b/lib/libcrypt/misc.c index ce55f5234fa7..e5db6b5dd838 100644 --- a/lib/libcrypt/misc.c +++ b/lib/libcrypt/misc.c @@ -29,7 +29,6 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/cdefs.h> #include <sys/types.h> #include "crypt.h" diff --git a/lib/libcrypt/tests/Makefile b/lib/libcrypt/tests/Makefile index 8e97c95f95f2..f64fafe3c8cb 100644 --- a/lib/libcrypt/tests/Makefile +++ b/lib/libcrypt/tests/Makefile @@ -1,4 +1,3 @@ - ATF_TESTS_C+= crypt_tests NETBSD_ATF_TESTS_C+= crypt_test |