File md5-use-in-tree-MD5-rather-than-libcrypto.patch of Package istgt
From 0c5a66fd2d137897419a0b8340a15f2965d89380 Mon Sep 17 00:00:00 2001
From: David Disseldorp <ddiss@suse.de>
Date: Fri, 5 Apr 2013 16:13:36 +0200
Subject: [PATCH 07/12] md5: use in-tree MD5 rather than libcrypto
Currently libcrypto (openssl) is linked purely for md5 calculation
utilities. Use the tiny in tree library instead, and do away with the
libcrypto dependency.
Signed-off-by: David Disseldorp <ddiss@suse.de>
---
configure | 91 ---------------------------------------------------------
configure.in | 2 --
src/istgt_md5.c | 40 +++++--------------------
src/istgt_md5.h | 11 ++-----
4 files changed, 10 insertions(+), 134 deletions(-)
diff --git configure configure
index 122aee3..83d3838 100755
--- configure
+++ configure
@@ -3472,97 +3472,6 @@ _ACEOF
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MD5Update in -lmd" >&5
-$as_echo_n "checking for MD5Update in -lmd... " >&6; }
-if ${ac_cv_lib_md_MD5Update+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lmd $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char MD5Update ();
-int
-main ()
-{
-return MD5Update ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_md_MD5Update=yes
-else
- ac_cv_lib_md_MD5Update=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_md_MD5Update" >&5
-$as_echo "$ac_cv_lib_md_MD5Update" >&6; }
-if test "x$ac_cv_lib_md_MD5Update" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBMD 1
-_ACEOF
-
- LIBS="-lmd $LIBS"
-
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MD5_Update in -lcrypto" >&5
-$as_echo_n "checking for MD5_Update in -lcrypto... " >&6; }
-if ${ac_cv_lib_crypto_MD5_Update+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcrypto $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char MD5_Update ();
-int
-main ()
-{
-return MD5_Update ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_crypto_MD5_Update=yes
-else
- ac_cv_lib_crypto_MD5_Update=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_MD5_Update" >&5
-$as_echo "$ac_cv_lib_crypto_MD5_Update" >&6; }
-if test "x$ac_cv_lib_crypto_MD5_Update" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBCRYPTO 1
-_ACEOF
-
- LIBS="-lcrypto $LIBS"
-
-fi
-
-fi
-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cam_open_spec_device in -lcam" >&5
$as_echo_n "checking for cam_open_spec_device in -lcam... " >&6; }
if ${ac_cv_lib_cam_cam_open_spec_device+:} false; then :
diff --git configure.in configure.in
index 05c7eed..52e0af9 100644
--- configure.in
+++ configure.in
@@ -60,8 +60,6 @@ esac
# Checks for libraries.
AC_CHECK_LIB([pthread], [pthread_create])
-AC_CHECK_LIB([md], [MD5Update], ,
- [AC_CHECK_LIB([crypto], [MD5_Update])])
AC_CHECK_LIB([cam], [cam_open_spec_device])
# Checks for header files.
diff --git src/istgt_md5.c src/istgt_md5.c
index 6148cb5..fae5024 100644
--- src/istgt_md5.c
+++ src/istgt_md5.c
@@ -33,62 +33,36 @@
#include <stdint.h>
#include <stddef.h>
-#ifdef HAVE_LIBMD
-#include <sys/types.h>
-#include <md5.h>
-#else
-#include <openssl/md5.h>
-#endif
#include "istgt.h"
+#include "md5.h"
#include "istgt_md5.h"
int
istgt_md5init(ISTGT_MD5CTX *md5ctx)
{
- int rc;
-
if (md5ctx == NULL)
return -1;
-#ifdef HAVE_LIBMD
- MD5Init(&md5ctx->md5ctx);
- rc = 1;
-#else
- rc = MD5_Init(&md5ctx->md5ctx);
-#endif
- return rc;
+ MD5_Init(&md5ctx->state);
+ return 0;
}
int
istgt_md5final(void *md5, ISTGT_MD5CTX *md5ctx)
{
- int rc;
-
if (md5ctx == NULL || md5 == NULL)
return -1;
-#ifdef HAVE_LIBMD
- MD5Final(md5, &md5ctx->md5ctx);
- rc = 1;
-#else
- rc = MD5_Final(md5, &md5ctx->md5ctx);
-#endif
- return rc;
+ MD5_Final(md5, &md5ctx->state);
+ return 0;
}
int
istgt_md5update(ISTGT_MD5CTX *md5ctx, const void *data, size_t len)
{
- int rc;
-
if (md5ctx == NULL)
return -1;
if (data == NULL || len <= 0)
return 0;
-#ifdef HAVE_LIBMD
- MD5Update(&md5ctx->md5ctx, data, len);
- rc = 1;
-#else
- rc = MD5_Update(&md5ctx->md5ctx, data, len);
-#endif
- return rc;
+ MD5_Update(&md5ctx->state, data, len);
+ return 0;
}
diff --git src/istgt_md5.h src/istgt_md5.h
index 355efb4..cf80d62 100644
--- src/istgt_md5.h
+++ src/istgt_md5.h
@@ -30,17 +30,12 @@
#include <stddef.h>
-#ifdef HAVE_LIBMD
-#include <sys/types.h>
-#include <md5.h>
-#else
-#include <openssl/md5.h>
-#endif
+#include "md5.h"
-#define ISTGT_MD5DIGEST_LEN MD5_DIGEST_LENGTH
+#define ISTGT_MD5DIGEST_LEN 16
typedef struct istgt_md5ctx_t {
- MD5_CTX md5ctx;
+ struct md5 state;
} ISTGT_MD5CTX;
int istgt_md5init(ISTGT_MD5CTX *md5ctx);
--
2.1.2