From 64707e82165bb32db5763b38bf550b538bcd4eec Mon Sep 17 00:00:00 2001 From: Timo Weingärtner Date: Sat, 27 Apr 2013 18:07:22 +0200 Subject: make Brokencrypt_md5 also broken on little-endian otherwise broken hashes from big-endian systems won't work also remove ASM_MD5 #ifndef's, we don't have assembler code here --- md5.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'md5.c') diff --git a/md5.c b/md5.c index 0fb1a78..94f1e2a 100644 --- a/md5.c +++ b/md5.c @@ -19,29 +19,17 @@ */ #include +#include #include "md5.h" #ifndef HIGHFIRST #define byteReverse(buf, len) /* Nothing */ #else -static void byteReverse(unsigned char *buf, unsigned longs); - -#ifndef ASM_MD5 -/* - * Note: this code is harmless on little-endian machines. - */ -static void byteReverse(unsigned char *buf, unsigned longs) -{ - uint32 t; - do { - t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | - ((unsigned) buf[1] << 8 | buf[0]); - *(uint32 *) buf = t; - buf += 4; - } while (--longs); +static void byteReverse(unsigned char *buf, unsigned longs) { + for (; longs; --longs, buf +=4) + *((uint32 *) buf) = bswap_32(*((uint32 *) buf)); } #endif -#endif /* * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious @@ -151,8 +139,6 @@ void MD5Name(MD5Final)(unsigned char digest[16], struct MD5Context *ctx) memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ } -#ifndef ASM_MD5 - /* The four core functions - F1 is optimized somewhat */ /* #define F1(x, y, z) (x & y | ~x & z) */ @@ -252,5 +238,3 @@ void MD5Name(MD5Transform)(uint32 buf[4], uint32 const in[16]) buf[2] += c; buf[3] += d; } - -#endif -- cgit v1.2.3 From be53f76279d158aa3e5fb2960f9ae4da52201857 Mon Sep 17 00:00:00 2001 From: Timo Weingärtner Date: Sat, 11 May 2013 01:43:50 +0200 Subject: replace self-defined uint32 with uint32_t from stdint.h unsigned int is not guaranteed to have 32 bits --- md5.c | 22 +++++++++++----------- md5.h | 10 +++++----- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'md5.c') diff --git a/md5.c b/md5.c index 94f1e2a..2bc558e 100644 --- a/md5.c +++ b/md5.c @@ -27,7 +27,7 @@ #else static void byteReverse(unsigned char *buf, unsigned longs) { for (; longs; --longs, buf +=4) - *((uint32 *) buf) = bswap_32(*((uint32 *) buf)); + *((uint32_t *) buf) = bswap_32(*((uint32_t *) buf)); } #endif @@ -52,12 +52,12 @@ void MD5Name(MD5Init)(struct MD5Context *ctx) */ void MD5Name(MD5Update)(struct MD5Context *ctx, unsigned const char *buf, unsigned len) { - uint32 t; + uint32_t t; /* Update bitcount */ t = ctx->bits[0]; - if ((ctx->bits[0] = t + ((uint32) len << 3)) < t) + if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t) ctx->bits[1]++; /* Carry from low to high */ ctx->bits[1] += len >> 29; @@ -75,7 +75,7 @@ void MD5Name(MD5Update)(struct MD5Context *ctx, unsigned const char *buf, unsign } memcpy(p, buf, t); byteReverse(ctx->in, 16); - MD5Name(MD5Transform)(ctx->buf, (uint32 *) ctx->in); + MD5Name(MD5Transform)(ctx->buf, (uint32_t *) ctx->in); buf += t; len -= t; } @@ -84,7 +84,7 @@ void MD5Name(MD5Update)(struct MD5Context *ctx, unsigned const char *buf, unsign while (len >= 64) { memcpy(ctx->in, buf, 64); byteReverse(ctx->in, 16); - MD5Name(MD5Transform)(ctx->buf, (uint32 *) ctx->in); + MD5Name(MD5Transform)(ctx->buf, (uint32_t *) ctx->in); buf += 64; len -= 64; } @@ -119,7 +119,7 @@ void MD5Name(MD5Final)(unsigned char digest[16], struct MD5Context *ctx) /* Two lots of padding: Pad the first block to 64 bytes */ memset(p, 0, count); byteReverse(ctx->in, 16); - MD5Name(MD5Transform)(ctx->buf, (uint32 *) ctx->in); + MD5Name(MD5Transform)(ctx->buf, (uint32_t *) ctx->in); /* Now fill the next block with 56 bytes */ memset(ctx->in, 0, 56); @@ -130,10 +130,10 @@ void MD5Name(MD5Final)(unsigned char digest[16], struct MD5Context *ctx) byteReverse(ctx->in, 14); /* Append length in bits and transform */ - ((uint32 *) ctx->in)[14] = ctx->bits[0]; - ((uint32 *) ctx->in)[15] = ctx->bits[1]; + ((uint32_t *) ctx->in)[14] = ctx->bits[0]; + ((uint32_t *) ctx->in)[15] = ctx->bits[1]; - MD5Name(MD5Transform)(ctx->buf, (uint32 *) ctx->in); + MD5Name(MD5Transform)(ctx->buf, (uint32_t *) ctx->in); byteReverse((unsigned char *) ctx->buf, 4); memcpy(digest, ctx->buf, 16); memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ @@ -156,9 +156,9 @@ void MD5Name(MD5Final)(unsigned char digest[16], struct MD5Context *ctx) * reflect the addition of 16 longwords of new data. MD5Update blocks * the data and converts bytes into longwords for this routine. */ -void MD5Name(MD5Transform)(uint32 buf[4], uint32 const in[16]) +void MD5Name(MD5Transform)(uint32_t buf[4], uint32_t const in[16]) { - register uint32 a, b, c, d; + register uint32_t a, b, c, d; a = buf[0]; b = buf[1]; diff --git a/md5.h b/md5.h index 103f168..b48edea 100644 --- a/md5.h +++ b/md5.h @@ -2,22 +2,22 @@ #ifndef MD5_H #define MD5_H -typedef unsigned int uint32; +#include struct MD5Context { - uint32 buf[4]; - uint32 bits[2]; + uint32_t buf[4]; + uint32_t bits[2]; unsigned char in[64]; }; void GoodMD5Init(struct MD5Context *); void GoodMD5Update(struct MD5Context *, unsigned const char *, unsigned); void GoodMD5Final(unsigned char digest[16], struct MD5Context *); -void GoodMD5Transform(uint32 buf[4], uint32 const in[16]); +void GoodMD5Transform(uint32_t buf[4], uint32_t const in[16]); void BrokenMD5Init(struct MD5Context *); void BrokenMD5Update(struct MD5Context *, unsigned const char *, unsigned); void BrokenMD5Final(unsigned char digest[16], struct MD5Context *); -void BrokenMD5Transform(uint32 buf[4], uint32 const in[16]); +void BrokenMD5Transform(uint32_t buf[4], uint32_t const in[16]); char *Goodcrypt_md5(const char *pw, const char *salt); char *Brokencrypt_md5(const char *pw, const char *salt); -- cgit v1.2.3 From 495461432ca4034d49ee37cb398c6bd253d6f66d Mon Sep 17 00:00:00 2001 From: Timo Weingärtner Date: Sat, 11 May 2013 19:34:44 +0200 Subject: md5.c: fix compiler warnings --- md5.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'md5.c') diff --git a/md5.c b/md5.c index 2bc558e..3565e55 100644 --- a/md5.c +++ b/md5.c @@ -130,13 +130,12 @@ void MD5Name(MD5Final)(unsigned char digest[16], struct MD5Context *ctx) byteReverse(ctx->in, 14); /* Append length in bits and transform */ - ((uint32_t *) ctx->in)[14] = ctx->bits[0]; - ((uint32_t *) ctx->in)[15] = ctx->bits[1]; + memcpy(ctx->in + 56, ctx->bits, 8); MD5Name(MD5Transform)(ctx->buf, (uint32_t *) ctx->in); byteReverse((unsigned char *) ctx->buf, 4); memcpy(digest, ctx->buf, 16); - memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ + memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ } /* The four core functions - F1 is optimized somewhat */ -- cgit v1.2.3 From e493c1467bbaebfbaf2a9a6b1da3398b76232ce5 Mon Sep 17 00:00:00 2001 From: Timo Weingärtner Date: Tue, 14 May 2013 20:22:36 +0200 Subject: remove CVS $Id line and static version number --- INSTALL | 1 - README | 3 --- changelog | 1 - contrib/README.txt | 2 -- md5.c | 2 -- md5_crypt.c | 2 -- pam_pwdfile.c | 4 ---- 7 files changed, 15 deletions(-) (limited to 'md5.c') diff --git a/INSTALL b/INSTALL index 97ed833..5fe4680 100644 --- a/INSTALL +++ b/INSTALL @@ -1,5 +1,4 @@ INSTALL for pam_pwdfile PAM module - Charl P. Botha -$Id: INSTALL,v 1.4 2001-04-17 21:18:15 cpbotha Exp $ --------------------------------------------------------------------------- This file is the quick and dirty on how to get pam_pwdfile compiled on your diff --git a/README b/README index d5c82f9..4f07913 100644 --- a/README +++ b/README @@ -1,9 +1,6 @@ README for pam_pwdfile PAM module - Charl P. Botha -$Id: README,v 1.12 2003-12-20 19:21:19 cpbotha Exp $ --------------------------------------------------------------------------- -This is version 0.99 of pam_pwdfile. - This pam module can be used for the authentication service only, in cases where one wants to use a different set of passwords than those in the main system password database. E.g. in our case we have an imap server running, diff --git a/changelog b/changelog index e545376..9936e81 100644 --- a/changelog +++ b/changelog @@ -1,5 +1,4 @@ changelog for pam_pwdfile PAM module - Charl P. Botha -$Id: changelog,v 1.20 2003-12-20 19:30:57 cpbotha Exp $ --------------------------------------------------------------------------- 0.99 : Sat Dec 20 20:30:37 CET 2003 diff --git a/contrib/README.txt b/contrib/README.txt index a8c8462..1c0f886 100644 --- a/contrib/README.txt +++ b/contrib/README.txt @@ -1,5 +1,3 @@ -$Id: README.txt,v 1.3 2003-07-07 15:09:41 cpbotha Exp $ - * Makefile.standalone-0.95 and pam-pwdfile.spec were contributed by Jason F. McBrayer . You can use these for building RPMs of pam_pwdfile; you should also be able to use the Makefile to build diff --git a/md5.c b/md5.c index 3565e55..542ff80 100644 --- a/md5.c +++ b/md5.c @@ -1,6 +1,4 @@ /* - * $Id: md5.c,v 1.1 2002-05-11 14:42:35 cpbotha Exp $ - * * This code implements the MD5 message-digest algorithm. * The algorithm is due to Ron Rivest. This code was * written by Colin Plumb in 1993, no copyright is claimed. diff --git a/md5_crypt.c b/md5_crypt.c index 7871b45..639b1d3 100644 --- a/md5_crypt.c +++ b/md5_crypt.c @@ -1,6 +1,4 @@ /* - * $Id: md5_crypt.c,v 1.1 2002-05-11 14:42:35 cpbotha Exp $ - * * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): * wrote this file. As long as you retain this notice you diff --git a/pam_pwdfile.c b/pam_pwdfile.c index 4e8805d..9b96fe3 100644 --- a/pam_pwdfile.c +++ b/pam_pwdfile.c @@ -1,13 +1,9 @@ /* pam_pwdfile.c copyright 1999-2003 by Charl P. Botha * - * $Id: pam_pwdfile.c,v 1.18 2003-12-20 19:21:19 cpbotha Exp $ - * * pam authentication module that can be pointed at any username/crypted * text file so that pam using application can use an alternate set of * passwords than specified in system password database * - * version 0.99 - * * Copyright (c) Charl P. Botha, 1999-2003. All rights reserved * * Redistribution and use in source and binary forms, with or without -- cgit v1.2.3