[Midnightbsd-cvs] mports: security/mhash: Update to 0.9.9

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Tue Mar 25 21:52:05 EDT 2008


Log Message:
-----------
Update to 0.9.9

Modified Files:
--------------
    mports/security/mhash:
        Makefile (r1.1 -> r1.2)
        distinfo (r1.1 -> r1.2)

Added Files:
-----------
    mports/security/mhash/files:
        patch-include-mutils-mincludes.h (r1.1)
        patch-include-mutils-mutils.h (r1.1)
        patch-lib-gosthash.c (r1.1)
        patch-lib-keygen_mcrypt.c (r1.1)
        patch-lib-md5.c (r1.1)
        patch-lib-mhash.c (r1.1)
        patch-lib-mhash_sha1.c (r1.1)
        patch-lib-ripemd.c (r1.1)
        patch-lib-sha1.c (r1.1)
        patch-lib-sha512_sha384.c (r1.1)
        patch-lib-stdfns.c (r1.1)
        patch-lib-tiger.c (r1.1)
        patch-lib-whirlpool.c (r1.1)
        patch-src-hmac_test.c (r1.1)
        patch-src-keygen_test.c (r1.1)

-------------- next part --------------
Index: Makefile
===================================================================
RCS file: /home/cvs/mports/security/mhash/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -L security/mhash/Makefile -L security/mhash/Makefile -u -r1.1 -r1.2
--- security/mhash/Makefile
+++ security/mhash/Makefile
@@ -7,23 +7,24 @@
 #
 
 PORTNAME=	mhash
-PORTVERSION=	0.9.7.1
+PORTVERSION=	0.9.9
 CATEGORIES=	security
 MASTER_SITES=	SF
 
 MAINTAINER=	ports at MidnightBSD.org
 COMMENT=	An easy-to-use library for strong hashes such as MD5 and SHA1
+LICENSE=	lgpl
 
 USE_BZIP2=	yes
 USE_LDCONFIG=	yes
 GNU_CONFIGURE=	yes
-CONFIGURE_TARGET=--build=${MACHINE_ARCH}-portbld-freebsd${OSREL}
+CONFIGURE_TARGET=--build=${MACHINE_ARCH}-portbld-freebsd6.0
 CONFIGURE_ARGS+=	--with-LDFLAGS="${PTHREAD_LIBS}" --enable-static \
 			--with-gnu-ld
 
 MAN3=		mhash.3
 
-PORTDOCS=	example.c md5-rfc1321.txt skid2-authentication
+PORTDOCS=	example.c skid2-authentication
 
 post-install:
 .if !defined(NOPORTDOCS)
Index: distinfo
===================================================================
RCS file: /home/cvs/mports/security/mhash/distinfo,v
retrieving revision 1.1
retrieving revision 1.2
diff -L security/mhash/distinfo -L security/mhash/distinfo -u -r1.1 -r1.2
--- security/mhash/distinfo
+++ security/mhash/distinfo
@@ -1,3 +1,3 @@
-MD5 (mhash-0.9.7.1.tar.bz2) = e2a7f6594d468c5d0edbfa788dbdca0f
-SHA256 (mhash-0.9.7.1.tar.bz2) = e9ac257ba9fd62e54011ed1282c7c1bf5fbd72bf84484ad6a293ece43f8d641c
-SIZE (mhash-0.9.7.1.tar.bz2) = 727397
+MD5 (mhash-0.9.9.tar.bz2) = d113a853e0ac21c49c5a1acea0daaade
+SHA256 (mhash-0.9.9.tar.bz2) = 3b14491ba06f6ae8d7755314eb1c82596c422743c5adb5ef65f358313370dc9e
+SIZE (mhash-0.9.9.tar.bz2) = 634563
--- /dev/null
+++ security/mhash/files/patch-lib-md5.c
@@ -0,0 +1,23 @@
+diff -urN -x .svn ../../branches/vendor/mhash/lib/md5.c ./lib/md5.c
+--- ../../branches/vendor/mhash/lib/md5.c	2008-01-16 14:26:51.000000000 +0200
++++ ./lib/md5.c	2008-01-16 15:11:08.000000000 +0200
+@@ -140,14 +140,14 @@
+ /* The four core functions - F1 is optimized somewhat */
+ 
+ /* #define F1(x, y, z) (x & y | ~x & z) */
+-#define F1(x, y, z) (z ^ (x & (y ^ z)))
+-#define F2(x, y, z) F1(z, x, y)
+-#define F3(x, y, z) (x ^ y ^ z)
+-#define F4(x, y, z) (y ^ (x | ~z))
++#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
++#define F2(x, y, z) F1((z), (x), (y))
++#define F3(x, y, z) ((x) ^ (y) ^ (z))
++#define F4(x, y, z) ((y) ^ ((x) | ~(z)))
+ 
+ /* This is the central step in the MD5 algorithm. */
+ #define MD5STEP(f, w, x, y, z, data, s) \
+-	( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
++	( (w) += f(x, y, z) + (data),  (w) = (w)<<(s) | (w)>>(32-(s)),  (w) += (x) )
+ 
+ /*
+  * The core of the MD5 algorithm, this alters an existing MD5 hash to
--- /dev/null
+++ security/mhash/files/patch-lib-gosthash.c
@@ -0,0 +1,42 @@
+diff -urN -x .svn ../../branches/vendor/mhash/lib/gosthash.c ./lib/gosthash.c
+--- ../../branches/vendor/mhash/lib/gosthash.c	2008-01-16 14:26:51.000000000 +0200
++++ ./lib/gosthash.c	2008-01-16 15:12:01.000000000 +0200
+@@ -273,22 +273,22 @@
+  */
+ 
+ #define GOST_ENCRYPT(key) \
+-GOST_ENCRYPT_ROUND(key[0], key[1]) \
+-GOST_ENCRYPT_ROUND(key[2], key[3]) \
+-GOST_ENCRYPT_ROUND(key[4], key[5]) \
+-GOST_ENCRYPT_ROUND(key[6], key[7]) \
+-GOST_ENCRYPT_ROUND(key[0], key[1]) \
+-GOST_ENCRYPT_ROUND(key[2], key[3]) \
+-GOST_ENCRYPT_ROUND(key[4], key[5]) \
+-GOST_ENCRYPT_ROUND(key[6], key[7]) \
+-GOST_ENCRYPT_ROUND(key[0], key[1]) \
+-GOST_ENCRYPT_ROUND(key[2], key[3]) \
+-GOST_ENCRYPT_ROUND(key[4], key[5]) \
+-GOST_ENCRYPT_ROUND(key[6], key[7]) \
+-GOST_ENCRYPT_ROUND(key[7], key[6]) \
+-GOST_ENCRYPT_ROUND(key[5], key[4]) \
+-GOST_ENCRYPT_ROUND(key[3], key[2]) \
+-GOST_ENCRYPT_ROUND(key[1], key[0]) \
++GOST_ENCRYPT_ROUND((key)[0], (key)[1]) \
++GOST_ENCRYPT_ROUND((key)[2], (key)[3]) \
++GOST_ENCRYPT_ROUND((key)[4], (key)[5]) \
++GOST_ENCRYPT_ROUND((key)[6], (key)[7]) \
++GOST_ENCRYPT_ROUND((key)[0], (key)[1]) \
++GOST_ENCRYPT_ROUND((key)[2], (key)[3]) \
++GOST_ENCRYPT_ROUND((key)[4], (key)[5]) \
++GOST_ENCRYPT_ROUND((key)[6], (key)[7]) \
++GOST_ENCRYPT_ROUND((key)[0], (key)[1]) \
++GOST_ENCRYPT_ROUND((key)[2], (key)[3]) \
++GOST_ENCRYPT_ROUND((key)[4], (key)[5]) \
++GOST_ENCRYPT_ROUND((key)[6], (key)[7]) \
++GOST_ENCRYPT_ROUND((key)[7], (key)[6]) \
++GOST_ENCRYPT_ROUND((key)[5], (key)[4]) \
++GOST_ENCRYPT_ROUND((key)[3], (key)[2]) \
++GOST_ENCRYPT_ROUND((key)[1], (key)[0]) \
+ t = r; \
+ r = l; \
+ l = t;
--- /dev/null
+++ security/mhash/files/patch-lib-stdfns.c
@@ -0,0 +1,54 @@
+diff -urN -x .svn ../../branches/mhash-dist/lib/stdfns.c ./lib/stdfns.c
+--- ../../branches/mhash-dist/lib/stdfns.c	2008-01-16 02:34:17.000000000 +0200
++++ ./lib/stdfns.c	2008-01-16 02:35:49.000000000 +0200
+@@ -332,11 +332,11 @@
+ 		{
+ 			return(0);
+ 		}
+-		return(-MAXINT);
++		return(-INT_MAX);
+ 	}
+ 	if (s2 == NULL)
+ 	{
+-		return(MAXINT);
++		return(INT_MAX);
+ 	}
+ 
+ 	return(memcmp(s1, s2, n));
+@@ -463,11 +463,11 @@
+ 		{
+ 			return(0);
+ 		}
+-		return(-MAXINT);
++		return(-INT_MAX);
+ 	}
+ 	if (src2 == NULL)
+ 	{
+-		return(MAXINT);
++		return(INT_MAX);
+ 	}
+ 	return(strcmp((char *) src1, (char *) src2));
+ }
+@@ -486,11 +486,11 @@
+ 		{
+ 			return(0);
+ 		}
+-		return(-MAXINT);
++		return(-INT_MAX);
+ 	}
+ 	if (src2 == NULL)
+ 	{
+-		return(MAXINT);
++		return(INT_MAX);
+ 	}
+ 	return(strncmp((char *) src1, (char *) src2, n));
+ }
+@@ -524,6 +524,8 @@
+ 	mutils_word8 *ptrOut = buffer;
+ 	mutils_word32 loop;
+ 
++	if (buffer == NULL)
++		return(NULL);
+ 	for (loop = 0; loop < len; loop++, ptrIn++)
+ 	{
+ 		*ptrOut++ = mutils_val2char((*ptrIn & 0xf0) >> 4);
--- /dev/null
+++ security/mhash/files/patch-lib-tiger.c
@@ -0,0 +1,210 @@
+diff -urN -x .svn ../../branches/vendor/mhash/lib/tiger.c ./lib/tiger.c
+--- ../../branches/vendor/mhash/lib/tiger.c	2008-01-16 14:26:51.000000000 +0200
++++ ./lib/tiger.c	2008-01-16 15:08:55.000000000 +0200
+@@ -62,26 +62,26 @@
+ #ifdef OPTIMIZE_FOR_ALPHA
+ /* This is the official definition of round */
+ #define round(a,b,c,x,mul) \
+-      c ^= x; \
+-      a -= t1[((c)>>(0*8))&0xFF] ^ t2[((c)>>(2*8))&0xFF] ^ \
++      (c) ^= (x); \
++      (a) -= t1[((c)>>(0*8))&0xFF] ^ t2[((c)>>(2*8))&0xFF] ^ \
+ 	   t3[((c)>>(4*8))&0xFF] ^ t4[((c)>>(6*8))&0xFF] ; \
+-      b += t4[((c)>>(1*8))&0xFF] ^ t3[((c)>>(3*8))&0xFF] ^ \
++      (b) += t4[((c)>>(1*8))&0xFF] ^ t3[((c)>>(3*8))&0xFF] ^ \
+ 	   t2[((c)>>(5*8))&0xFF] ^ t1[((c)>>(7*8))&0xFF] ; \
+-      b *= mul;
++      (b) *= (mul);
+ #else
+ /* This code works faster when compiled on 32-bit machines */
+ /* (but works slower on Alpha) */
+ #define round(a,b,c,x,mul) \
+-      c ^= x; \
+-      a -= t1[(mutils_word8)(c)] ^ \
++      (c) ^= (x); \
++      (a) -= t1[(mutils_word8)(c)] ^ \
+            t2[(mutils_word8)(((mutils_word32)(c))>>(2*8))] ^ \
+ 	   t3[(mutils_word8)((c)>>(4*8))] ^ \
+            t4[(mutils_word8)(((mutils_word32)((c)>>(4*8)))>>(2*8))] ; \
+-      b += t4[(mutils_word8)(((mutils_word32)(c))>>(1*8))] ^ \
++      (b) += t4[(mutils_word8)(((mutils_word32)(c))>>(1*8))] ^ \
+            t3[(mutils_word8)(((mutils_word32)(c))>>(3*8))] ^ \
+ 	   t2[(mutils_word8)(((mutils_word32)((c)>>(4*8)))>>(1*8))] ^ \
+            t1[(mutils_word8)(((mutils_word32)((c)>>(4*8)))>>(3*8))]; \
+-      b *= mul;
++      (b) *= (mul);
+ #endif
+ 
+ #define pass(a,b,c,mul) \
+@@ -149,18 +149,18 @@
+   register mutils_word64 x0, x1, x2, x3, x4, x5, x6, x7; \
+   mutils_word8 pass_no;					 \
+ \
+-  a = state[0]; \
+-  b = state[1]; \
+-  c = state[2]; \
++  a = (state)[0]; \
++  b = (state)[1]; \
++  c = (state)[2]; \
+ \
+-  x0=str[0]; x1=str[1]; x2=str[2]; x3=str[3]; \
+-  x4=str[4]; x5=str[5]; x6=str[6]; x7=str[7]; \
++  x0=(str)[0]; x1=(str)[1]; x2=(str)[2]; x3=(str)[3]; \
++  x4=(str)[4]; x5=(str)[5]; x6=(str)[6]; x7=(str)[7]; \
+ \
+   compress; \
+ \
+-  state[0] = a; \
+-  state[1] = b; \
+-  state[2] = c; \
++  (state)[0] = a; \
++  (state)[1] = b; \
++  (state)[2] = c; \
+ }
+ 
+ #ifndef OPTIMIZE_FOR_ALPHA
+@@ -173,20 +173,20 @@
+ #else /* OPTIMIZE_FOR_ALPHA */
+ /* The compress function is inlined: works better on Alpha.        */
+ #define tiger_compress(str, state) \
+-  tiger_compress_macro(((mutils_word64*)str), ((mutils_word64*)state))
++  tiger_compress_macro(((mutils_word64*)(str)), ((mutils_word64*)(state)))
+ #endif /* OPTIMIZE_FOR_ALPHA */
+ 
+ #ifndef EXTRACT_UCHAR
+ #define EXTRACT_UCHAR(p)  (*(mutils_word8 *)(p))
+ #endif
+ 
+-#define STRING2INT64(s) ((((((((((((((mutils_word64)(EXTRACT_UCHAR(s+7) << 8)    \
+-			 | EXTRACT_UCHAR(s+6)) << 8)  \
+-			 | EXTRACT_UCHAR(s+5)) << 8)  \
+-			 | EXTRACT_UCHAR(s+4)) << 8)  \
+-			 | EXTRACT_UCHAR(s+3)) << 8)  \
+-			 | EXTRACT_UCHAR(s+2)) << 8)  \
+-			 | EXTRACT_UCHAR(s+1)) << 8)  \
++#define STRING2INT64(s) ((((((((((((((mutils_word64)(EXTRACT_UCHAR((s)+7) << 8)    \
++			 | EXTRACT_UCHAR((s)+6)) << 8)  \
++			 | EXTRACT_UCHAR((s)+5)) << 8)  \
++			 | EXTRACT_UCHAR((s)+4)) << 8)  \
++			 | EXTRACT_UCHAR((s)+3)) << 8)  \
++			 | EXTRACT_UCHAR((s)+2)) << 8)  \
++			 | EXTRACT_UCHAR((s)+1)) << 8)  \
+ 			 | EXTRACT_UCHAR(s))
+ 
+ static void tiger_block(struct tiger_ctx *ctx, mutils_word8 * str)
+@@ -362,35 +362,35 @@
+ 
+ #define sub64(s0, s1, p0, p1) \
+       temps0 = (p0); \
+-      tcarry = s0 < temps0; \
+-      s0 -= temps0; \
+-      s1 -= (p1) + tcarry;
++      tcarry = (s0) < temps0; \
++      (s0) -= temps0; \
++      (s1) -= (p1) + tcarry;
+ 
+ #define add64(s0, s1, p0, p1) \
+       temps0 = (p0); \
+-      s0 += temps0; \
+-      tcarry = s0 < temps0; \
+-      s1 += (p1) + tcarry;
++      (s0) += temps0; \
++      tcarry = (s0) < temps0; \
++      (s1) += (p1) + tcarry;
+ 
+ #define xor64(s0, s1, p0, p1) \
+-      s0 ^= (p0); \
+-      s1 ^= (p1);
++      (s0) ^= (p0); \
++      (s1) ^= (p1);
+ 
+ #define mul5(s0, s1) \
+-      tempt0 = s0<<2; \
+-      tempt1 = (s1<<2)|(s0>>30); \
++      tempt0 = (s0)<<2; \
++      tempt1 = ((s1)<<2)|((s0)>>30); \
+       add64(s0, s1, tempt0, tempt1);
+ 
+ #define mul7(s0, s1) \
+-      tempt0 = s0<<3; \
+-      tempt1 = (s1<<3)|(s0>>29); \
++      tempt0 = (s0)<<3; \
++      tempt1 = ((s1)<<3)|((s0)>>29); \
+       sub64(tempt0, tempt1, s0, s1); \
+-      s0 = tempt0; \
+-      s1 = tempt1;
++      (s0) = tempt0; \
++      (s1) = tempt1;
+ 
+ #define mul9(s0, s1) \
+-      tempt0 = s0<<3; \
+-      tempt1 = (s1<<3)|(s0>>29); \
++      tempt0 = (s0)<<3; \
++      tempt1 = ((s1)<<3)|((s0)>>29); \
+       add64(s0, s1, tempt0, tempt1);
+ 
+ #define save_abc \
+@@ -497,33 +497,33 @@
+   mutils_word32 i; \
+   int pass_no; \
+ \
+-  a0 = state[0]; \
+-  a1 = state[1]; \
+-  b0 = state[2]; \
+-  b1 = state[3]; \
+-  c0 = state[4]; \
+-  c1 = state[5]; \
++  a0 = (state)[0]; \
++  a1 = (state)[1]; \
++  b0 = (state)[2]; \
++  b1 = (state)[3]; \
++  c0 = (state)[4]; \
++  c1 = (state)[5]; \
+ \
+-  x00=str[0*2]; x01=str[0*2+1]; x10=str[1*2]; x11=str[1*2+1]; \
+-  x20=str[2*2]; x21=str[2*2+1]; x30=str[3*2]; x31=str[3*2+1]; \
+-  x40=str[4*2]; x41=str[4*2+1]; x50=str[5*2]; x51=str[5*2+1]; \
+-  x60=str[6*2]; x61=str[6*2+1]; x70=str[7*2]; x71=str[7*2+1]; \
++  x00=(str)[0*2]; x01=(str)[0*2+1]; x10=(str)[1*2]; x11=(str)[1*2+1]; \
++  x20=(str)[2*2]; x21=(str)[2*2+1]; x30=(str)[3*2]; x31=(str)[3*2+1]; \
++  x40=(str)[4*2]; x41=(str)[4*2+1]; x50=(str)[5*2]; x51=(str)[5*2+1]; \
++  x60=(str)[6*2]; x61=(str)[6*2+1]; x70=(str)[7*2]; x71=(str)[7*2+1]; \
+ \
+   compress; \
+ \
+-  state[0] = a0; \
+-  state[1] = a1; \
+-  state[2] = b0; \
+-  state[3] = b1; \
+-  state[4] = c0; \
+-  state[5] = c1; \
++  (state)[0] = a0; \
++  (state)[1] = a1; \
++  (state)[2] = b0; \
++  (state)[3] = b1; \
++  (state)[4] = c0; \
++  (state)[5] = c1; \
+ }
+ 
+ #define UNROLL_COMPRESS
+ #ifdef UNROLL_COMPRESS
+ /* The compress function is inlined */
+ #define tiger_compress(str, state) \
+-  tiger_compress_macro(((mutils_word32*)str), ((mutils_word32*)state))
++  tiger_compress_macro(((mutils_word32*)(str)), ((mutils_word32*)(state)))
+ #else
+ /* The compress function is a function */
+ tiger_compress(__const mutils_word32 *str, mutils_word32 state[6])
+@@ -537,9 +537,9 @@
+ #define EXTRACT_UCHAR(p)  (*(mutils_word8 *)(p))
+ #endif
+ 
+-#define STRING2INT(s) ((((((EXTRACT_UCHAR(s+3) << 8)    \
+-			 | EXTRACT_UCHAR(s+2)) << 8)  \
+-			 | EXTRACT_UCHAR(s+1)) << 8)  \
++#define STRING2INT(s) ((((((EXTRACT_UCHAR((s)+3) << 8)    \
++			 | EXTRACT_UCHAR((s)+2)) << 8)  \
++			 | EXTRACT_UCHAR((s)+1)) << 8)  \
+ 			 | EXTRACT_UCHAR(s))
+ 
+ static void tiger_block(struct tiger_ctx *ctx, mutils_word8 * block)
--- /dev/null
+++ security/mhash/files/patch-src-keygen_test.c
@@ -0,0 +1,108 @@
+diff -urN -x .svn ../../branches/vendor/mhash/src/keygen_test.c ./src/keygen_test.c
+--- ../../branches/vendor/mhash/src/keygen_test.c	2008-01-16 14:34:18.000000000 +0200
++++ ./src/keygen_test.c	2008-01-16 15:36:24.000000000 +0200
+@@ -43,6 +43,12 @@
+ 
+ 	passlen=sizeof(PASSWORD1);
+ 	password = mutils_malloc(passlen+1);
++	if (password == NULL)
++	{
++		fprintf(stderr, "KEYGEN-Test (KEYGEN_MCRYPT): Failed\n");
++		fprintf(stderr, "Cannot allocate memory.\n");
++		return(MUTILS_SYSTEM_RESOURCE_ERROR);
++	}
+ 	mutils_strncpy(password, (mutils_word8 *) PASSWORD1, passlen);
+ 	
+ 	if (mhash_get_keygen_max_key_size(KEYGEN_MCRYPT)==0) {
+@@ -64,6 +70,8 @@
+ 	{
+ 		fprintf(stderr, "KEYGEN-Test (KEYGEN_MCRYPT): Failed\n");
+ 		fprintf(stderr, "Cannot allocate memory.\n");
++		mutils_free(password);
++		mutils_free(salt);
+ 		return(MUTILS_SYSTEM_RESOURCE_ERROR);
+ 	}
+ 
+@@ -74,12 +82,16 @@
+ 	
+ 	mhash_keygen_ext(KEYGEN_MCRYPT, data, key, keysize, password, passlen);
+ 
++	mutils_free(salt);
++
+ 	tmp = mutils_asciify(key, keysize);
+ 
+ 	if (tmp == NULL)
+ 	{
+ 		fprintf(stderr, "KEYGEN-Test (KEYGEN_MCRYPT): Failed\n");
+ 		fprintf(stderr, "Cannot allocate memory (2).\n");
++		mutils_free(password);
++		mutils_free(key);
+ 		return(MUTILS_SYSTEM_RESOURCE_ERROR);
+ 	}
+ 
+@@ -91,6 +103,7 @@
+ 	if (result != 0) {
+ 		fprintf(stderr, "KEYGEN-Test (KEYGEN_MCRYPT): Failed\n");
+ 		fprintf(stderr, "Expecting: 0x%s\nGot: 0x%s\n", KEY1, tmp);
++		mutils_free(tmp);
+ 		return(MUTILS_INVALID_RESULT);
+ 	}
+ 
+@@ -98,6 +111,12 @@
+ 
+ 	passlen = sizeof(PASSWORD2);
+ 	password = (mutils_word8 *) mutils_malloc(passlen + 1);
++	if (password == NULL)
++	{
++		fprintf(stderr, "KEYGEN-Test (KEYGEN_MCRYPT): Failed\n");
++		fprintf(stderr, "Cannot allocate memory.\n");
++		return(MUTILS_SYSTEM_RESOURCE_ERROR);
++	}
+ 	mutils_strncpy(password, (mutils_word8 *) PASSWORD2, passlen);
+ 	
+ 	if (mhash_get_keygen_max_key_size(KEYGEN_S2K_SALTED)==0) {
+@@ -114,6 +133,15 @@
+ 	salt = (mutils_word8 *) mutils_malloc(salt_size);
+ 	key = (mutils_word8 *) mutils_malloc(keysize);
+ 	
++	if ((salt == NULL) || (key == NULL))
++	{
++		fprintf(stderr, "KEYGEN-Test (KEYGEN_MCRYPT): Failed\n");
++		fprintf(stderr, "Cannot allocate memory.\n");
++		mutils_free(password);
++		mutils_free(salt);
++		return(MUTILS_SYSTEM_RESOURCE_ERROR);
++	}
++
+ 	data.hash_algorithm[0] = MHASH_SHA1;
+ 	data.count = 0;
+ 	data.salt = salt;
+@@ -121,10 +149,19 @@
+ 	
+ 	mhash_keygen_ext(KEYGEN_S2K_SALTED, data, key, keysize, password, passlen);
+ 
+-	mutils_memset(tmp, 0, keysize * 2);
++	mutils_free(salt);
+ 
+ 	tmp = mutils_asciify(key, keysize);
+ 
++	if (tmp == NULL)
++	{
++		fprintf(stderr, "KEYGEN-Test (KEYGEN_MCRYPT): Failed\n");
++		fprintf(stderr, "Cannot allocate memory.\n");
++		mutils_free(password);
++		mutils_free(key);
++		return(MUTILS_SYSTEM_RESOURCE_ERROR);
++	}
++
+ 	result = mutils_strcmp((mutils_word8 *) KEY2, tmp);
+ 
+ 	mutils_free(password);
+@@ -133,6 +170,7 @@
+ 	if (mutils_strcmp((mutils_word8 *) KEY2, tmp) != 0) {
+ 		fprintf(stderr, "KEYGEN-Test (KEYGEN_S2K_SALTED): Failed\n");
+ 		fprintf(stderr, "Expecting: 0x%s\nGot: 0x%s\n", KEY2, tmp);
++		mutils_free(tmp);
+ 		return(MUTILS_INVALID_RESULT);
+ 	}
+ 
--- /dev/null
+++ security/mhash/files/patch-src-hmac_test.c
@@ -0,0 +1,101 @@
+diff -urN -x .svn ../../branches/vendor/mhash/src/hmac_test.c ./src/hmac_test.c
+--- ../../branches/vendor/mhash/src/hmac_test.c	2008-01-16 14:34:18.000000000 +0200
++++ ./src/hmac_test.c	2008-01-16 15:33:23.000000000 +0200
+@@ -45,10 +45,23 @@
+ 
+ 	passlen=sizeof(KEY1) - 1;
+ 	password = mutils_malloc(passlen + 1);
++	if (password == NULL)
++	{
++		fprintf(stderr, "HMAC-Test: Failed\n");
++		fprintf(stderr, "Cannot allocate memory.\n");
++		return(MUTILS_SYSTEM_RESOURCE_ERROR);
++	}
+ 	mutils_memcpy(password, (mutils_word8 *) KEY1, passlen);
+ 
+ 	datalen = mutils_strlen((mutils_word8 *) DATA1);
+ 	data = mutils_malloc(datalen+1);
++	if (data == NULL)
++	{
++		fprintf(stderr, "HMAC-Test: Failed\n");
++		fprintf(stderr, "Cannot allocate memory.\n");
++		mutils_free(password);
++		return(MUTILS_SYSTEM_RESOURCE_ERROR);
++	}
+ 	mutils_strcpy(data, (mutils_word8 *) DATA1);
+ 
+ 	td = mhash_hmac_init(MHASH_MD5, password, passlen,
+@@ -58,6 +71,14 @@
+ 	mac = mhash_hmac_end(td);
+ 
+ 	tmp = mutils_asciify(mac, mhash_get_block_size(MHASH_MD5));
++	if (tmp == NULL)
++	{
++		fprintf(stderr, "HMAC-Test: Failed\n");
++		fprintf(stderr, "Cannot allocate memory.\n");
++		mutils_free(password);
++		mutils_free(data);
++		return(MUTILS_SYSTEM_RESOURCE_ERROR);
++	}
+ 	
+ 	result = mutils_strcmp((mutils_word8 *) DIGEST1, tmp);
+ 
+@@ -69,6 +90,7 @@
+ 		fprintf(stderr, "Digest size: %d\n", mhash_get_block_size(MHASH_MD5));
+ 		fprintf(stderr, "Expecting: 0x%s\n", DIGEST1);
+ 		fprintf(stderr, "Got: 0x%s\n", tmp);
++		mutils_free(tmp);
+ 		return(MUTILS_INVALID_RESULT);
+ 	}
+ 
+@@ -76,14 +98,25 @@
+ 
+ 	/* Test No 2 */	
+ 	
+-	mutils_memset(tmp, 0, sizeof(tmp));
+-	
+ 	passlen=sizeof(KEY2) - 1;
+ 	password = (mutils_word8 *) mutils_malloc(passlen+1);
++	if (password == NULL)
++	{
++		fprintf(stderr, "HMAC-Test: Failed\n");
++		fprintf(stderr, "Cannot allocate memory.\n");
++		return(MUTILS_SYSTEM_RESOURCE_ERROR);
++	}
+ 	mutils_memcpy(password, KEY2, passlen);
+ 	
+ 	datalen = mutils_strlen((mutils_word8 *) DATA2);
+ 	data = (mutils_word8 *) mutils_malloc(datalen+1);
++	if (data == NULL)
++	{
++		fprintf(stderr, "HMAC-Test: Failed\n");
++		fprintf(stderr, "Cannot allocate memory.\n");
++		mutils_free(password);
++		return(MUTILS_SYSTEM_RESOURCE_ERROR);
++	}
+ 	mutils_strcpy(data, (mutils_word8 *) DATA2);
+ 
+ 	td = mhash_hmac_init(MHASH_MD5, password, passlen,
+@@ -93,6 +126,14 @@
+ 	mac = mhash_hmac_end(td);
+ 
+ 	tmp = mutils_asciify(mac, mhash_get_block_size(MHASH_MD5));
++	if (tmp == NULL)
++	{
++		fprintf(stderr, "HMAC-Test: Failed\n");
++		fprintf(stderr, "Cannot allocate memory.\n");
++		mutils_free(password);
++		mutils_free(data);
++		return(MUTILS_SYSTEM_RESOURCE_ERROR);
++	}
+ 	
+ 	result = mutils_strcmp((mutils_word8 *) DIGEST2, tmp);
+ 
+@@ -103,6 +144,7 @@
+ 	{
+ 		fprintf(stderr, "HMAC-Test: Failed\n");
+ 		fprintf(stderr, "Expecting: 0x%s\nGot: 0x%s\n", DIGEST2, tmp);
++		mutils_free(tmp);
+ 		return(MUTILS_INVALID_RESULT);
+ 	}
+ 
--- /dev/null
+++ security/mhash/files/patch-include-mutils-mincludes.h
@@ -0,0 +1,46 @@
+diff -urN -x .svn ../../branches/mhash-dist/include/mutils/mincludes.h ./include/mutils/mincludes.h
+--- ../../branches/mhash-dist/include/mutils/mincludes.h	2008-01-16 02:34:17.000000000 +0200
++++ ./include/mutils/mincludes.h	2008-01-16 02:35:49.000000000 +0200
+@@ -100,20 +100,28 @@
+ #include <stdint.h>
+ #endif
+ 
+-#if !defined(INT_MAX)
+-#define INT_MAX ((int) (~0U>>1))
+-#endif
+-
+-#if !defined(MAXINT)
+-#define MAXINT INT_MAX
+-#endif
++#ifndef	INT_MAX
++#ifdef	INTMAX
++#define	INT_MAX	INTMAX
++#else	/* INTMAX */
++#ifdef	MAXINT
++#define	INT_MAX	MAXINT
++#else	/* MAXINT */
++#error	Cannot find either INT_MAX, INTMAX, or MAXINT
++#endif	/* MAXINT */
++#endif	/* INTMAX */
++#endif	/* INT_MAX */
+ 
+-#if !defined(INT_MIN)
+-#define INT_MIN (-INT_MAX - 1)
+-#endif
+-
+-#if !defined(MININT)
+-#define MININT INT_MIN
+-#endif
++#ifndef	INT_MIN
++#ifdef	INTMIN
++#define	INT_MIN	INTMIN
++#else	/* INTMIN */
++#ifdef	MININT
++#define	INT_MIN	MININT
++#else	/* MININT */
++#error	Cannot find either INT_MIN, INTMIN, or MININT
++#endif	/* MININT */
++#endif	/* INTMIN */
++#endif	/* INT_MIN */
+ 
+ #endif
--- /dev/null
+++ security/mhash/files/patch-lib-keygen_mcrypt.c
@@ -0,0 +1,27 @@
+diff -urN -x .svn ../../branches/vendor/mhash/lib/keygen_mcrypt.c ./lib/keygen_mcrypt.c
+--- ../../branches/vendor/mhash/lib/keygen_mcrypt.c	2008-01-16 14:34:18.000000000 +0200
++++ ./lib/keygen_mcrypt.c	2008-01-16 15:26:44.000000000 +0200
+@@ -52,8 +52,10 @@
+ 	
+ 	while (1) {
+ 		td = mhash_init(algorithm);
+-		if (td == MHASH_FAILED)
++		if (td == MHASH_FAILED) {
++			mutils_free(key);
+ 			return(-MUTILS_INVALID_FUNCTION);
++		}
+ 		
+ 		if (salt_z == MUTILS_TRUE)
+ 			mhash(td, salt, salt_size);
+@@ -66,8 +68,10 @@
+ 		digest = mhash_end(td);
+ 
+ #if defined(MHASH_ROBUST)
+-		if (digest == NULL)
++		if (digest == NULL) {
++			mutils_free(key);
+ 			return(-MUTILS_INVALID_RESULT);
++		}
+ #endif
+ 
+ 		if (size > block_size) {
--- /dev/null
+++ security/mhash/files/patch-include-mutils-mutils.h
@@ -0,0 +1,97 @@
+diff -urN -x .svn ../../branches/mhash-dist/include/mutils/mutils.h ./include/mutils/mutils.h
+--- ../../branches/mhash-dist/include/mutils/mutils.h	2008-01-16 02:34:17.000000000 +0200
++++ ./include/mutils/mutils.h	2008-01-16 02:42:32.000000000 +0200
+@@ -103,22 +103,22 @@
+ #endif
+ 
+ #if defined(false)
+-#define MUTILS_FALSE (mutils_boolean) false
++#define MUTILS_FALSE ((mutils_boolean) false)
+ #else
+ #if defined(FALSE)
+-#define MUTILS_FALSE (mutils_boolean) FALSE
++#define MUTILS_FALSE ((mutils_boolean) FALSE)
+ #else
+-#define MUTILS_FALSE (mutils_boolean) 0
++#define MUTILS_FALSE ((mutils_boolean) 0)
+ #endif /* FALSE */
+ #endif /* false */
+ 
+ #if defined(true)
+-#define MUTILS_TRUE (mutils_boolean) true
++#define MUTILS_TRUE ((mutils_boolean) true)
+ #else
+ #if defined(TRUE)
+-#define MUTILS_TRUE (mutils_boolean) TRUE
++#define MUTILS_TRUE ((mutils_boolean) TRUE)
+ #else
+-#define MUTILS_TRUE (mutils_boolean) -1
++#define MUTILS_TRUE ((mutils_boolean) -1)
+ #endif /* TRUE */
+ #endif /* true */
+ 
+@@ -167,16 +167,16 @@
+ 
+ #define mutils_swapendian32(a) \
+ 	((mutils_word32) \
+-		(((a & (mutils_word32) 0x000000ffU) << 24) | \
+-		 ((a & (mutils_word32) 0x0000ff00U) << 8)  | \
+-		 ((a & (mutils_word32) 0x00ff0000U) >> 8)  | \
+-		 ((a & (mutils_word32) 0xff000000U) >> 24))  \
++		((((a) & (mutils_word32) 0x000000ffU) << 24) | \
++		 (((a) & (mutils_word32) 0x0000ff00U) << 8)  | \
++		 (((a) & (mutils_word32) 0x00ff0000U) >> 8)  | \
++		 (((a) & (mutils_word32) 0xff000000U) >> 24))  \
+ 	)
+ 
+ #define mutils_swapendian16(a) \
+ 	((mutils_word16) \
+-		(((a & (mutils_word16) 0x00ffU) << 8) | \
+-		 ((a & (mutils_word16) 0xff00U) >> 8))  \
++		((((a) & (mutils_word16) 0x00ffU) << 8) | \
++		 (((a) & (mutils_word16) 0xff00U) >> 8))  \
+ 	 )
+ 
+ 
+@@ -193,30 +193,30 @@
+ #define mutils_lend32(n) mutils_swapendian32(n)
+ #define mutils_lend16(n) mutils_swapendian16(n)
+ 
+-#define mutils_bend64(n) n
+-#define mutils_bend32(n) n
+-#define mutils_bend16(n) n
++#define mutils_bend64(n) (n)
++#define mutils_bend32(n) (n)
++#define mutils_bend16(n) (n)
+ 
+ #define mutils_lend2sys64(n) mutils_swapendian64(n)
+ #define mutils_lend2sys32(n) mutils_swapendian32(n)
+ #define mutils_lend2sys16(n) mutils_swapendian16(n)
+ 
+-#define mutils_bend2sys32(n) n
+-#define mutils_bend2sys16(n) n
++#define mutils_bend2sys32(n) (n)
++#define mutils_bend2sys16(n) (n)
+ 
+ #else
+ 
+-#define mutils_lend64(n) n
+-#define mutils_lend32(n) n
+-#define mutils_lend16(n) n
++#define mutils_lend64(n) (n)
++#define mutils_lend32(n) (n)
++#define mutils_lend16(n) (n)
+ 
+ #define mutils_bend64(n) mutils_swapendian64(n)
+ #define mutils_bend32(n) mutils_swapendian32(n)
+ #define mutils_bend16(n) mutils_swapendian16(n)
+ 
+-#define mutils_lend2sys64(n) n
+-#define mutils_lend2sys32(n) n
+-#define mutils_lend2sys16(n) n
++#define mutils_lend2sys64(n) (n)
++#define mutils_lend2sys32(n) (n)
++#define mutils_lend2sys16(n) (n)
+ 
+ #define mutils_bend2sys64(n) mutils_swapendian64(n)
+ #define mutils_bend2sys32(n) mutils_swapendian32(n)
--- /dev/null
+++ security/mhash/files/patch-lib-sha1.c
@@ -0,0 +1,31 @@
+diff -urN -x .svn ../../branches/vendor/mhash/lib/sha1.c ./lib/sha1.c
+--- ../../branches/vendor/mhash/lib/sha1.c	2008-01-16 14:26:51.000000000 +0200
++++ ./lib/sha1.c	2008-01-16 15:00:01.000000000 +0200
+@@ -59,10 +59,10 @@
+    save one boolean operation each - thanks to Rich Schroeppel,
+    rcs at cs.arizona.edu for discovering this */
+ 
+-#define f1(x,y,z)   ( z ^ ( x & ( y ^ z ) ) )           /* Rounds  0-19 */
+-#define f2(x,y,z)   ( x ^ y ^ z )                       /* Rounds 20-39 */
+-#define f3(x,y,z)   ( ( x & y ) | ( z & ( x | y ) ) )   /* Rounds 40-59 */
+-#define f4(x,y,z)   ( x ^ y ^ z )                       /* Rounds 60-79 */
++#define f1(x,y,z)   ( (z) ^ ( (x) & ( (y) ^ (z) ) ) )   /* Rounds  0-19 */
++#define f2(x,y,z)   ( (x) ^ (y) ^ (z) )                 /* Rounds 20-39 */
++#define f3(x,y,z)   ( ( (x) & (y) ) | ( (z) & ( (x) | (y) ) ) )   /* Rounds 40-59 */
++#define f4(x,y,z)   ( (x) ^ (y) ^ (z) )                 /* Rounds 60-79 */
+ 
+ /* The SHA Mysterious Constants */
+ 
+@@ -97,9 +97,9 @@
+    bit.  Thanks to Jim Gillogly, jim at rand.org, and an anonymous contributor
+    for this information */
+ 
+-#define expand(W,i) ( W[ i & 15 ] = \
+-		      ROTL( 1, ( W[ i & 15 ] ^ W[ (i - 14) & 15 ] ^ \
+-				 W[ (i - 8) & 15 ] ^ W[ (i - 3) & 15 ] ) ) )
++#define expand(W,i) ( W[ (i) & 15 ] = \
++		      ROTL( 1, ( W[ (i) & 15 ] ^ W[ ((i) - 14) & 15 ] ^ \
++				 W[ ((i) - 8) & 15 ] ^ W[ ((i) - 3) & 15 ] ) ) )
+ 
+ 
+ /* The prototype SHA sub-round.  The fundamental sub-round is:
--- /dev/null
+++ security/mhash/files/patch-lib-sha512_sha384.c
@@ -0,0 +1,24 @@
+diff -urN -x .svn ../../branches/vendor/mhash/lib/sha512_sha384.c ./lib/sha512_sha384.c
+--- ../../branches/vendor/mhash/lib/sha512_sha384.c	2008-01-16 14:26:52.000000000 +0200
++++ ./lib/sha512_sha384.c	2008-01-16 14:57:58.000000000 +0200
+@@ -129,13 +129,13 @@
+ #endif
+ 
+ #define STRING2INT64(s) ((((((((((((((mutils_word64)(EXTRACT_UCHAR(s) << 8)    \
+-			 | EXTRACT_UCHAR(s+1)) << 8)  \
+-			 | EXTRACT_UCHAR(s+2)) << 8)  \
+-			 | EXTRACT_UCHAR(s+3)) << 8)  \
+-			 | EXTRACT_UCHAR(s+4)) << 8)  \
+-			 | EXTRACT_UCHAR(s+5)) << 8)  \
+-			 | EXTRACT_UCHAR(s+6)) << 8)  \
+-			 | EXTRACT_UCHAR(s+7))
++			 | EXTRACT_UCHAR((s)+1)) << 8)  \
++			 | EXTRACT_UCHAR((s)+2)) << 8)  \
++			 | EXTRACT_UCHAR((s)+3)) << 8)  \
++			 | EXTRACT_UCHAR((s)+4)) << 8)  \
++			 | EXTRACT_UCHAR((s)+5)) << 8)  \
++			 | EXTRACT_UCHAR((s)+6)) << 8)  \
++			 | EXTRACT_UCHAR((s)+7))
+ 
+ /* Initialize the SHA512/384 values */
+ 
--- /dev/null
+++ security/mhash/files/patch-lib-mhash.c
@@ -0,0 +1,12 @@
+diff -urN -x .svn ../../branches/vendor/mhash/lib/mhash.c ./lib/mhash.c
+--- ../../branches/vendor/mhash/lib/mhash.c	2008-01-16 14:26:51.000000000 +0200
++++ ./lib/mhash.c	2008-01-16 15:22:29.000000000 +0200
+@@ -299,7 +299,7 @@
+ 	{
+ 		ret->hmac_key = (mutils_word8 *) mutils_malloc(ret->hmac_key_size);
+ 
+-		if (ret == NULL)
++		if (ret->hmac_key == NULL)
+ 		{
+ 			mutils_free(ret->state);
+ 			mutils_free(ret);
--- /dev/null
+++ security/mhash/files/patch-lib-ripemd.c
@@ -0,0 +1,33 @@
+diff -urN -x .svn ../../branches/vendor/mhash/lib/ripemd.c ./lib/ripemd.c
+--- ../../branches/vendor/mhash/lib/ripemd.c	2008-01-16 14:26:51.000000000 +0200
++++ ./lib/ripemd.c	2008-01-16 15:02:04.000000000 +0200
+@@ -55,13 +55,13 @@
+ /* 32-bit rotate left - kludged with shifts */
+ #define ROTL(n,X)  (((X)<<(n))|((X)>>(32-(n))))
+ 
+-#define f0(x,y,z)  (x^y^z)
++#define f0(x,y,z)  ((x)^(y)^(z))
+ //#define f16(x,y,z) ((x&y)|(~(x) & z))
+ #define f16(x,y,z) ((z)^((x)&((y)^(z))))
+-#define f32(x,y,z) ((x|~(y))^z)
++#define f32(x,y,z) (((x)|~(y))^(z))
+ //#define f48(x,y,z) ((x&z)|(y&~(z)))
+ #define f48(x,y,z) ((y)^((z)&((x)^(y))))
+-#define f64(x,y,z) (x^(y|(~z)))
++#define f64(x,y,z) ((x)^((y)|(~(z))))
+ 
+ #define K0  0x00000000
+ #define K1  0x5A827999     /* 2^30 * sqrt(2) */
+@@ -913,9 +913,9 @@
+ #define EXTRACT_UCHAR(p)  (*(mutils_word8 *)(p))
+ #endif
+ 
+-#define STRING2INT(s) ((((((EXTRACT_UCHAR(s+3) << 8)    \
+-			 | EXTRACT_UCHAR(s+2)) << 8)  \
+-			 | EXTRACT_UCHAR(s+1)) << 8)  \
++#define STRING2INT(s) ((((((EXTRACT_UCHAR((s)+3) << 8)    \
++			 | EXTRACT_UCHAR((s)+2)) << 8)  \
++			 | EXTRACT_UCHAR((s)+1)) << 8)  \
+ 			 | EXTRACT_UCHAR(s))
+ 
+ static void ripemd_block(struct ripemd_ctx *ctx, mutils_word8 *block)
--- /dev/null
+++ security/mhash/files/patch-lib-whirlpool.c
@@ -0,0 +1,18 @@
+diff -urN -x .svn ../../branches/vendor/mhash/lib/whirlpool.c ./lib/whirlpool.c
+--- ../../branches/vendor/mhash/lib/whirlpool.c	2008-01-16 14:26:51.000000000 +0200
++++ ./lib/whirlpool.c	2008-01-16 15:13:06.000000000 +0200
+@@ -883,10 +883,10 @@
+  * Increment the block counter by step
+  */
+ #define INCCTR(cnt,step) do {        \
+- if ((cnt[3] += (step)) < (step))    \
+-   if (!(++cnt[2]))                  \
+-     if (!(++cnt[1]))                \
+-       if (!(++cnt[0]));             \
++ if (((cnt)[3] += (step)) < (step))    \
++   if (!(++(cnt)[2]))                  \
++     if (!(++(cnt)[1]))                \
++       if (!(++(cnt)[0]));             \
+ } while(0);
+ 
+ 
--- /dev/null
+++ security/mhash/files/patch-lib-mhash_sha1.c
@@ -0,0 +1,16 @@
+diff -urN -x .svn ../../branches/vendor/mhash/lib/mhash_sha1.h ./lib/mhash_sha1.h
+--- ../../branches/vendor/mhash/lib/mhash_sha1.h	2008-01-16 14:26:51.000000000 +0200
++++ ./lib/mhash_sha1.h	2008-01-16 15:01:05.000000000 +0200
+@@ -39,9 +39,9 @@
+ #endif
+ 
+ #define STRING2INT(s) ((((((EXTRACT_UCHAR(s) << 8)    \
+-			 | EXTRACT_UCHAR(s+1)) << 8)  \
+-			 | EXTRACT_UCHAR(s+2)) << 8)  \
+-			 | EXTRACT_UCHAR(s+3))
++			 | EXTRACT_UCHAR((s)+1)) << 8)  \
++			 | EXTRACT_UCHAR((s)+2)) << 8)  \
++			 | EXTRACT_UCHAR((s)+3))
+ #else
+ mutils_word32 STRING2INT(mutils_word8 *s)
+ {


More information about the Midnightbsd-cvs mailing list