diff options
Diffstat (limited to 'meta-security/recipes-security/libmhash/files')
3 files changed, 57 insertions, 0 deletions
diff --git a/meta-security/recipes-security/libmhash/files/Makefile.test b/meta-security/recipes-security/libmhash/files/Makefile.test new file mode 100644 index 000000000..2e32626e2 --- /dev/null +++ b/meta-security/recipes-security/libmhash/files/Makefile.test @@ -0,0 +1,13 @@ +# +# Makefile for compiling mhash tests +# + +ALL = mhash + +all: $(ALL) + +mhash: mhash.c + $(CC) $(CFLAGS) $(LDFLAGS) -o mhash mhash.c -lmhash + +clean: + rm -f *.debug $(ALL) diff --git a/meta-security/recipes-security/libmhash/files/mhash.c b/meta-security/recipes-security/libmhash/files/mhash.c new file mode 100644 index 000000000..5d123cc28 --- /dev/null +++ b/meta-security/recipes-security/libmhash/files/mhash.c @@ -0,0 +1,32 @@ +#include <mhash.h> +#include <stdio.h> + +int main() +{ + + char password[] = "Jefe"; + int keylen = 4; + char data[] = "what do ya want for nothing?"; + int datalen = 28; + MHASH td; + unsigned char mac[16]; + int j; + + td = mhash_hmac_init(MHASH_MD5, password, keylen, mhash_get_hash_pblock(MHASH_MD5)); + + mhash(td, data, datalen); + mhash_hmac_deinit(td, mac); + +/* + * The output should be 0x750c783e6ab0b503eaa86e310a5db738 + * according to RFC 2104. + */ + + printf("0x"); + for (j = 0; j < mhash_get_block_size(MHASH_MD5); j++) { + printf("%.2x", mac[j]); + } + printf("\n"); + + exit(0); +} diff --git a/meta-security/recipes-security/libmhash/files/run-ptest b/meta-security/recipes-security/libmhash/files/run-ptest new file mode 100644 index 000000000..2b0b94a6e --- /dev/null +++ b/meta-security/recipes-security/libmhash/files/run-ptest @@ -0,0 +1,12 @@ +#!/bin/sh + +OUTPUT=$($(dirname $0)/mhash) +MHASH_MD5="0x750c783e6ab0b503eaa86e310a5db738" + +if [ x"$OUTPUT" = x"$MHASH_MD5" ]; then + echo "PASS: mhash ptest" + exit 0 +else + echo "FAIL: mhash ptest" + exit 1 +fi |