summaryrefslogtreecommitdiffstats
path: root/recipes-security/libmhash
diff options
context:
space:
mode:
authorJackie Huang <jackie.huang@windriver.com>2017-07-28 10:00:57 +0800
committerArmin Kuster <akuster808@gmail.com>2017-08-13 08:26:14 -0700
commitaae40f506ab557b10b5642937881a12aa9d0414b (patch)
tree6abf15178cef3d1bb44afb4d1647771236835821 /recipes-security/libmhash
parent1c3afde094d6cb7951957a67f4127dc06abecaa5 (diff)
downloadmeta-security-aae40f506ab557b10b5642937881a12aa9d0414b.tar.gz
libmhash: add new recipe
Mhash is a free (under GNU Lesser GPL) library which provides a uniform interface to a large number of hash algorithms. These algorithms can be used to compute checksums, message digests, and other signatures. Signed-off-by: Jackie Huang <jackie.huang@windriver.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'recipes-security/libmhash')
-rw-r--r--recipes-security/libmhash/files/Makefile.test13
-rw-r--r--recipes-security/libmhash/files/mhash.c32
-rw-r--r--recipes-security/libmhash/files/run-ptest12
-rw-r--r--recipes-security/libmhash/libmhash_0.9.9.9.bb37
4 files changed, 94 insertions, 0 deletions
diff --git a/recipes-security/libmhash/files/Makefile.test b/recipes-security/libmhash/files/Makefile.test
new file mode 100644
index 0000000..2e32626
--- /dev/null
+++ b/recipes-security/libmhash/files/Makefile.test
@@ -0,0 +1,13 @@
1#
2# Makefile for compiling mhash tests
3#
4
5ALL = mhash
6
7all: $(ALL)
8
9mhash: mhash.c
10 $(CC) $(CFLAGS) $(LDFLAGS) -o mhash mhash.c -lmhash
11
12clean:
13 rm -f *.debug $(ALL)
diff --git a/recipes-security/libmhash/files/mhash.c b/recipes-security/libmhash/files/mhash.c
new file mode 100644
index 0000000..5d123cc
--- /dev/null
+++ b/recipes-security/libmhash/files/mhash.c
@@ -0,0 +1,32 @@
1#include <mhash.h>
2#include <stdio.h>
3
4int main()
5{
6
7 char password[] = "Jefe";
8 int keylen = 4;
9 char data[] = "what do ya want for nothing?";
10 int datalen = 28;
11 MHASH td;
12 unsigned char mac[16];
13 int j;
14
15 td = mhash_hmac_init(MHASH_MD5, password, keylen, mhash_get_hash_pblock(MHASH_MD5));
16
17 mhash(td, data, datalen);
18 mhash_hmac_deinit(td, mac);
19
20/*
21 * The output should be 0x750c783e6ab0b503eaa86e310a5db738
22 * according to RFC 2104.
23 */
24
25 printf("0x");
26 for (j = 0; j < mhash_get_block_size(MHASH_MD5); j++) {
27 printf("%.2x", mac[j]);
28 }
29 printf("\n");
30
31 exit(0);
32}
diff --git a/recipes-security/libmhash/files/run-ptest b/recipes-security/libmhash/files/run-ptest
new file mode 100644
index 0000000..2b0b94a
--- /dev/null
+++ b/recipes-security/libmhash/files/run-ptest
@@ -0,0 +1,12 @@
1#!/bin/sh
2
3OUTPUT=$($(dirname $0)/mhash)
4MHASH_MD5="0x750c783e6ab0b503eaa86e310a5db738"
5
6if [ x"$OUTPUT" = x"$MHASH_MD5" ]; then
7 echo "PASS: mhash ptest"
8 exit 0
9else
10 echo "FAIL: mhash ptest"
11 exit 1
12fi
diff --git a/recipes-security/libmhash/libmhash_0.9.9.9.bb b/recipes-security/libmhash/libmhash_0.9.9.9.bb
new file mode 100644
index 0000000..9b34cb1
--- /dev/null
+++ b/recipes-security/libmhash/libmhash_0.9.9.9.bb
@@ -0,0 +1,37 @@
1SUMMARY = "Library of hashing algorithms."
2DESCRIPTION = "\
3 Mhash is a free (under GNU Lesser GPL) library \
4 which provides a uniform interface to a large number of hash \
5 algorithms. These algorithms can be used to compute checksums, \
6 message digests, and other signatures. \
7 "
8HOMEPAGE = "http://mhash.sourceforge.net/"
9
10LICENSE = "LGPLv2.0"
11LIC_FILES_CHKSUM = "file://COPYING;md5=3bf50002aefd002f49e7bb854063f7e7"
12
13S = "${WORKDIR}/mhash-${PV}"
14
15SECTION = "libs"
16
17SRC_URI = "${SOURCEFORGE_MIRROR}/mhash/mhash-${PV}.tar.bz2 \
18 file://Makefile.test \
19 file://mhash.c \
20 file://run-ptest \
21 "
22
23SRC_URI[md5sum] = "f91c74f9ccab2b574a98be5bc31eb280"
24SRC_URI[sha256sum] = "56521c52a9033779154432d0ae47ad7198914785265e1f570cee21ab248dfef0"
25
26inherit autotools-brokensep ptest
27
28do_compile_ptest() {
29 if [ ! -d ${S}/demo ]; then mkdir ${S}/demo; fi
30 cp ${WORKDIR}/Makefile.test ${S}/demo/Makefile
31 cp ${WORKDIR}/mhash.c ${S}/demo/
32 make -C ${S}/demo CFLAGS="${CFLAGS} -I${S}/include/" LDFLAGS="${LDFLAGS} -L${S}/lib/.libs"
33}
34
35do_install_ptest() {
36 install -m 0755 ${S}/demo/mhash ${D}${PTEST_PATH}
37}