diff options
author | Jackie Huang <jackie.huang@windriver.com> | 2017-07-28 10:00:57 +0800 |
---|---|---|
committer | Armin Kuster <akuster808@gmail.com> | 2017-08-13 08:26:14 -0700 |
commit | aae40f506ab557b10b5642937881a12aa9d0414b (patch) | |
tree | 6abf15178cef3d1bb44afb4d1647771236835821 /recipes-security/libmhash | |
parent | 1c3afde094d6cb7951957a67f4127dc06abecaa5 (diff) | |
download | meta-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.test | 13 | ||||
-rw-r--r-- | recipes-security/libmhash/files/mhash.c | 32 | ||||
-rw-r--r-- | recipes-security/libmhash/files/run-ptest | 12 | ||||
-rw-r--r-- | recipes-security/libmhash/libmhash_0.9.9.9.bb | 37 |
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 | |||
5 | ALL = mhash | ||
6 | |||
7 | all: $(ALL) | ||
8 | |||
9 | mhash: mhash.c | ||
10 | $(CC) $(CFLAGS) $(LDFLAGS) -o mhash mhash.c -lmhash | ||
11 | |||
12 | clean: | ||
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 | |||
4 | int 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 | |||
3 | OUTPUT=$($(dirname $0)/mhash) | ||
4 | MHASH_MD5="0x750c783e6ab0b503eaa86e310a5db738" | ||
5 | |||
6 | if [ x"$OUTPUT" = x"$MHASH_MD5" ]; then | ||
7 | echo "PASS: mhash ptest" | ||
8 | exit 0 | ||
9 | else | ||
10 | echo "FAIL: mhash ptest" | ||
11 | exit 1 | ||
12 | fi | ||
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 @@ | |||
1 | SUMMARY = "Library of hashing algorithms." | ||
2 | DESCRIPTION = "\ | ||
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 | " | ||
8 | HOMEPAGE = "http://mhash.sourceforge.net/" | ||
9 | |||
10 | LICENSE = "LGPLv2.0" | ||
11 | LIC_FILES_CHKSUM = "file://COPYING;md5=3bf50002aefd002f49e7bb854063f7e7" | ||
12 | |||
13 | S = "${WORKDIR}/mhash-${PV}" | ||
14 | |||
15 | SECTION = "libs" | ||
16 | |||
17 | SRC_URI = "${SOURCEFORGE_MIRROR}/mhash/mhash-${PV}.tar.bz2 \ | ||
18 | file://Makefile.test \ | ||
19 | file://mhash.c \ | ||
20 | file://run-ptest \ | ||
21 | " | ||
22 | |||
23 | SRC_URI[md5sum] = "f91c74f9ccab2b574a98be5bc31eb280" | ||
24 | SRC_URI[sha256sum] = "56521c52a9033779154432d0ae47ad7198914785265e1f570cee21ab248dfef0" | ||
25 | |||
26 | inherit autotools-brokensep ptest | ||
27 | |||
28 | do_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 | |||
35 | do_install_ptest() { | ||
36 | install -m 0755 ${S}/demo/mhash ${D}${PTEST_PATH} | ||
37 | } | ||