[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: php-mhah appears broken in 3.5 and 3.6



On Sun, Nov 07, 2004 at 09:18:15PM -0700, Chris Kuethe wrote:
> On Sun, 7 Nov 2004 19:03:11 -0800, Tim Howe <tim_(_at_)_deschutesdigital_(_dot_)_com> wrote:
> > Using a test php page... php-mhash returns a string of zeros as the hash
> > value for anything... I have tried this on two different 3.5 installs and on
> > a 3.6 install.  I have also confirmed my results through another person
> > who has 3.6 installed.
> > 
> > I don't know if it's an mhash issue or an issue with the php extension port.
> > No error messages appear in Apache logs.
> > 
> > Anyone else see this or have a work-around?
> 
> It could very well be mhash that's broken. The example given in the
> php manual doesn't work either.
> 
> <?php
> $input = "what do ya want for nothing?";
> $hash = mhash(MHASH_MD5, $input);
> echo "The hash is " . bin2hex($hash) . "<br />\n";
> $hash = mhash(MHASH_MD5, $input, "Jefe");
> echo "The hmac is " . bin2hex($hash) . "<br />\n";
> ?>
> 
> also prints zeros.
> 
> This is the first I've seen of it as I tend to use SHA1 which does work. 

I've noticed this some time ago, since I specifically need MD5 for Credit
Card stuffs.

the mhash C calls work:

$ cat work/c/mhash/mhash.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <mhash.h>

int
main(int argc, char *argv[])
{
	char password[] = "thisismykey";
	int keylen = sizeof(password);
	char data[1024];
	int datalen;
	MHASH td;
	unsigned char mac[16];
	int j;

	(void)snprintf(data, sizeof(data), "%s", argv[1]);

	datalen = strlen(data);

	td = mhash_hmac_init(MHASH_MD5, password, keylen,
		mhash_get_hash_pblock(MHASH_MD5));

	mhash(td, data, datalen);
	mhash_hmac_deinit(td, mac);

	for (j = 0; j < mhash_get_block_size(MHASH_MD5); j++) {
		printf("%.2x", mac[j]);
	}
	printf("\n");

	return(0);
}
$ cat work/c/mhash/Makefile
STATIC_LIBS=	/usr/local/lib/libmhash.a

all:	mhash

mhash: mhash.o
	cc -static mhash.o ${STATIC_LIBS} -o mhash

mhash.o: mhash.c
	cc -I/usr/local/include -c mhash.c -o mhash.o

clean:
	rm -f mhash.o mhash

realclean: clean
	rm -f a.out *.core *~
$

-- 
<jakemsr_(_at_)_jakemsr_(_dot_)_com>



Visit your host, monkey.org