From 756ace83937658050e49713b0dc8b2608e84124f Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 10 Nov 2022 15:29:35 +0100 Subject: [PATCH] Fix compilation with -lcrypto ##build --- libr/crypto/hash/Makefile | 33 ------------------- libr/crypto/hash/md4.c | 4 +-- libr/crypto/hash/md4.h | 6 ++-- libr/crypto/hash/meson.build | 64 ------------------------------------ libr/crypto/hash/state.c | 2 +- 5 files changed, 6 insertions(+), 103 deletions(-) delete mode 100644 libr/crypto/hash/Makefile delete mode 100644 libr/crypto/hash/meson.build diff --git a/libr/crypto/hash/Makefile b/libr/crypto/hash/Makefile deleted file mode 100644 index 7d5142fccd..0000000000 --- a/libr/crypto/hash/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -include ../config.mk - -NAME=r_hash -BINDEPS+=r_util -PCLIBS=@LIBXXHASH@ -# HACK -ifneq ($(OSTYPE),darwin) -ifneq ($(OSTYPE),haiku) -LDFLAGS+=-lm -LINK=-lm -endif -endif - -R2DEPS=r_util -OBJS=state.o hash.o hamdist.o crca.o fletcher.o sip.o -OBJS+=entropy.o hcalc.o adler32.o luhn.o ssdeep.o - -ifeq ($(HAVE_LIB_SSL),1) -CFLAGS+=${SSL_CFLAGS} -LDFLAGS+=${SSL_LDFLAGS} -LINK+=${SSL_LDFLAGS} -else -OBJS+=md4.o md5.o sha1.o sha2.o -endif - -ifeq ($(USE_LIB_XXHASH),1) -LDFLAGS+=${LIB_XXHASH} -LINK+=${LIBXXHASH} -else -OBJS+=xxhash.o -endif - -include ../rules.mk diff --git a/libr/crypto/hash/md4.c b/libr/crypto/hash/md4.c index aca041e0d7..2adc06536e 100644 --- a/libr/crypto/hash/md4.c +++ b/libr/crypto/hash/md4.c @@ -140,7 +140,7 @@ static void copy4(ut8 *out, ut32 x) { out[3] = (x >> 24) & 0xFF; } -void MD4(const ut8 *in, int n, ut8 *out) { +R_IPI void r_hash_md4(const ut8 *in, int n, ut8 *out) { ut8 buf[128]; ut32 M[16]; ut32 b = n * 8; @@ -189,7 +189,7 @@ void MD4(const ut8 *in, int n, ut8 *out) { } #else -void MD4(const ut8 *in, int n, ut8 *out) { +R_IPI void r_hash_md4(const ut8 *in, int n, ut8 *out) { R_LOG_ERROR ("md4 is only available on GPL builds"); } #endif diff --git a/libr/crypto/hash/md4.h b/libr/crypto/hash/md4.h index ae90b9ebb0..6cdbf14e82 100644 --- a/libr/crypto/hash/md4.h +++ b/libr/crypto/hash/md4.h @@ -1,6 +1,6 @@ -#ifndef _R_MD4_H -#define _R_MD4_H +#ifndef R_HASH_MD4_H +#define R_HASH_MD4_H -void MD4(const ut8 *in, int n, ut8 *out); +R_IPI void r_hash_md4 (const ut8 *in, int n, ut8 *out); #endif diff --git a/libr/crypto/hash/meson.build b/libr/crypto/hash/meson.build deleted file mode 100644 index 0c54db0399..0000000000 --- a/libr/crypto/hash/meson.build +++ /dev/null @@ -1,64 +0,0 @@ -r_hash_sources = files( - 'adler32.c', - 'hcalc.c', - 'crca.c', - 'sip.c', - 'entropy.c', - 'fletcher.c', - 'hamdist.c', - 'hash.c', - 'ssdeep.c', - 'luhn.c', - 'state.c' -) - -dependencies = [mth, r_util_dep] - -if use_sys_xxhash - dependencies += files(sys_xxhash) -else - r_hash_sources += files('xxhash.c') -endif - -if use_sys_openssl - dependencies += [sys_openssl] -else - r_hash_sources += files('md4.c', 'md5.c', 'sha1.c', 'sha2.c') -endif - -r_hash = library('r_hash', r_hash_sources, - include_directories: [platform_inc], - c_args: library_cflags, - dependencies: dependencies, - install: true, - implicit_include_directories: false, - install_rpath: rpath_lib, - soversion: r2_libversion -) - -r_hash_dep = declare_dependency(link_with: r_hash, - include_directories: [platform_inc]) - -if get_option('blob') -r_hash_static = static_library('r_hash_static', r_hash_sources, - include_directories: [platform_inc], - c_args: library_cflags, - dependencies: [ mth, r_util_static_dep ], - install: true, - implicit_include_directories: false, -) -r_hash_static_dep = declare_dependency(link_with: r_hash_static, - include_directories: [platform_inc]) -endif - -# pkgconfig_mod.generate(r_hash, -# subdirs: 'libr', -# version: r2_version, -# name: 'r_hash', -# filebase: 'r_hash', -# libraries: pkgcfg_sanitize_libs, -# requires: [ -# 'r_util' -# ], -# description: 'radare foundation libraries' -# ) diff --git a/libr/crypto/hash/state.c b/libr/crypto/hash/state.c index 8050c8f9de..174187d0a0 100644 --- a/libr/crypto/hash/state.c +++ b/libr/crypto/hash/state.c @@ -177,7 +177,7 @@ R_API ut8 *r_hash_do_md5(RHash *ctx, const ut8 *input, int len) { R_API ut8 *r_hash_do_md4(RHash *ctx, const ut8 *input, int len) { if (len >= 0) { - MD4 (input, len, ctx->digest); + r_hash_md4 (input, len, ctx->digest); return ctx->digest; } return NULL;