mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-10-20 05:49:08 +02:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1fb25b7dca | ||
![]() |
31f034e386 | ||
![]() |
2374f409de | ||
![]() |
a4e0db2b97 | ||
![]() |
43d34c9d3b | ||
![]() |
1c3ff61699 |
33
configure.ac
33
configure.ac
@@ -13,7 +13,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
|
|||||||
|
|
||||||
LIBBSD_ABI_MAJOR=0
|
LIBBSD_ABI_MAJOR=0
|
||||||
LIBBSD_ABI_MINOR=11
|
LIBBSD_ABI_MINOR=11
|
||||||
LIBBSD_ABI_PATCH=2
|
LIBBSD_ABI_PATCH=3
|
||||||
|
|
||||||
LIBBSD_ABI="$LIBBSD_ABI_MAJOR:$LIBBSD_ABI_MINOR:$LIBBSD_ABI_PATCH"
|
LIBBSD_ABI="$LIBBSD_ABI_MAJOR:$LIBBSD_ABI_MINOR:$LIBBSD_ABI_PATCH"
|
||||||
AC_SUBST([LIBBSD_ABI])
|
AC_SUBST([LIBBSD_ABI])
|
||||||
@@ -64,14 +64,27 @@ AM_CONDITIONAL([HAVE_LIBTESTU01],
|
|||||||
[test "x$ac_cv_lib_testu01_unif01_CreateExternGenBits" = "xyes"])
|
[test "x$ac_cv_lib_testu01_unif01_CreateExternGenBits" = "xyes"])
|
||||||
|
|
||||||
saved_LIBS="$LIBS"
|
saved_LIBS="$LIBS"
|
||||||
AC_SEARCH_LIBS([MD5Update], [md], [
|
AC_SEARCH_LIBS([dlsym], [dl], [
|
||||||
AC_SEARCH_LIBS([SHA512Update], [md], [
|
AS_IF([test "x$ac_cv_search_dlsym" != "xnone required"], [
|
||||||
MD_LIBS="-lmd"
|
LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_dlsym"
|
||||||
])
|
])
|
||||||
], [
|
], [
|
||||||
AC_MSG_ERROR([cannot find required message digest functions in libc or libmd])
|
AC_MSG_ERROR([cannot find required dlsym function])
|
||||||
|
])
|
||||||
|
AC_SEARCH_LIBS([MD5Update], [md], [
|
||||||
|
AS_IF([test "x$ac_cv_search_MD5Update" != "xnone required"], [
|
||||||
|
LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_MD5Update"
|
||||||
|
])
|
||||||
|
], [
|
||||||
|
AC_MSG_ERROR([cannot find required MD5 functions in libc or libmd])
|
||||||
|
])
|
||||||
|
AC_SEARCH_LIBS([SHA512Update], [md], [
|
||||||
|
AS_IF([test "x$ac_cv_search_SHA512Update" != "xnone required"], [
|
||||||
|
LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_SHA512Update"
|
||||||
|
])
|
||||||
|
], [
|
||||||
|
AC_MSG_ERROR([cannot find required SHA-2 functions in libc or libmd])
|
||||||
])
|
])
|
||||||
AC_SUBST([MD_LIBS])
|
|
||||||
LIBS="$saved_LIBS"
|
LIBS="$saved_LIBS"
|
||||||
|
|
||||||
is_windows=no
|
is_windows=no
|
||||||
@@ -81,10 +94,9 @@ AS_CASE([$host_os],
|
|||||||
saved_LIBS="$LIBS"
|
saved_LIBS="$LIBS"
|
||||||
AC_SEARCH_LIBS([clock_gettime], [rt], [
|
AC_SEARCH_LIBS([clock_gettime], [rt], [
|
||||||
AS_IF([test "x$ac_cv_search_clock_gettime" != "xnone required"], [
|
AS_IF([test "x$ac_cv_search_clock_gettime" != "xnone required"], [
|
||||||
CLOCK_GETTIME_LIBS="$ac_cv_search_clock_gettime"
|
LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_clock_gettime"
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
AC_SUBST([CLOCK_GETTIME_LIBS])
|
|
||||||
LIBS="$saved_LIBS"
|
LIBS="$saved_LIBS"
|
||||||
],
|
],
|
||||||
[*-musl*], [
|
[*-musl*], [
|
||||||
@@ -192,8 +204,7 @@ AC_LINK_IFELSE(
|
|||||||
[AC_DEFINE([HAVE___REGISTER_ATFORK], [1],
|
[AC_DEFINE([HAVE___REGISTER_ATFORK], [1],
|
||||||
[Define to 1 if you have __register_atfork])
|
[Define to 1 if you have __register_atfork])
|
||||||
AC_MSG_RESULT([yes])],
|
AC_MSG_RESULT([yes])],
|
||||||
[ARC4RANDOM_ATFORK_LIBS="-pthread"
|
[LIBBSD_LIBS="$LIBBSD_LIBS -pthread"
|
||||||
AC_SUBST([ARC4RANDOM_ATFORK_LIBS])
|
|
||||||
AC_MSG_RESULT([no])
|
AC_MSG_RESULT([no])
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -202,6 +213,8 @@ AC_CHECK_FUNCS([clearenv dirfd fopencookie __fpurge \
|
|||||||
pstat_getproc sysconf])
|
pstat_getproc sysconf])
|
||||||
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xtrue"])
|
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xtrue"])
|
||||||
|
|
||||||
|
AC_SUBST([LIBBSD_LIBS])
|
||||||
|
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
Makefile
|
Makefile
|
||||||
include/Makefile
|
include/Makefile
|
||||||
|
@@ -187,10 +187,10 @@
|
|||||||
# else
|
# else
|
||||||
# ifndef __cplusplus
|
# ifndef __cplusplus
|
||||||
# define __offsetof(type, field) \
|
# define __offsetof(type, field) \
|
||||||
((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field))
|
((size_t)(uintptr_t)((const volatile void *)&((type *)0)->field))
|
||||||
# else
|
# else
|
||||||
# define __offsetof(type, field) \
|
# define __offsetof(type, field) \
|
||||||
(__offsetof__ (reinterpret_cast <__size_t> \
|
(__offsetof__ (reinterpret_cast <size_t> \
|
||||||
(&reinterpret_cast <const volatile char &> \
|
(&reinterpret_cast <const volatile char &> \
|
||||||
(static_cast<type *> (0)->field))))
|
(static_cast<type *> (0)->field))))
|
||||||
# endif
|
# endif
|
||||||
@@ -243,15 +243,15 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __DECONST
|
#ifndef __DECONST
|
||||||
#define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var))
|
#define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __DEVOLATILE
|
#ifndef __DEVOLATILE
|
||||||
#define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var))
|
#define __DEVOLATILE(type, var) ((type)(uintptr_t)(volatile void *)(var))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __DEQUALIFY
|
#ifndef __DEQUALIFY
|
||||||
#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var))
|
#define __DEQUALIFY(type, var) ((type)(uintptr_t)(const volatile void *)(var))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -52,9 +52,7 @@ libbsd_la_DEPENDENCIES = \
|
|||||||
$(libbsd_la_included_sources) \
|
$(libbsd_la_included_sources) \
|
||||||
libbsd.map
|
libbsd.map
|
||||||
libbsd_la_LIBADD = \
|
libbsd_la_LIBADD = \
|
||||||
$(MD_LIBS) \
|
$(LIBBSD_LIBS) \
|
||||||
$(CLOCK_GETTIME_LIBS) \
|
|
||||||
$(ARC4RANDOM_ATFORK_LIBS) \
|
|
||||||
$(nil)
|
$(nil)
|
||||||
libbsd_la_LDFLAGS = \
|
libbsd_la_LDFLAGS = \
|
||||||
-version-number $(LIBBSD_ABI)
|
-version-number $(LIBBSD_ABI)
|
||||||
|
@@ -8,4 +8,5 @@ Description: Utility functions from BSD systems
|
|||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
URL: https://libbsd.freedesktop.org/
|
URL: https://libbsd.freedesktop.org/
|
||||||
Libs: -L${libdir} -lbsd
|
Libs: -L${libdir} -lbsd
|
||||||
|
Libs.private: @LIBBSD_LIBS@
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
86
src/md5.c
86
src/md5.c
@@ -24,68 +24,100 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
#include <md5.h>
|
#include <md5.h>
|
||||||
#include "local-link.h"
|
|
||||||
|
static void (*libmd_MD5Init)(MD5_CTX *);
|
||||||
|
static void (*libmd_MD5Update)(MD5_CTX *, const uint8_t *, size_t);
|
||||||
|
static void (*libmd_MD5Pad)(MD5_CTX *);
|
||||||
|
static void (*libmd_MD5Final)(uint8_t [MD5_DIGEST_LENGTH], MD5_CTX *);
|
||||||
|
static void (*libmd_MD5Transform)(uint32_t [4], const uint8_t [MD5_BLOCK_LENGTH]);
|
||||||
|
static char *(*libmd_MD5End)(MD5_CTX *, char *);
|
||||||
|
static char *(*libmd_MD5File)(const char *, char *);
|
||||||
|
static char *(*libmd_MD5FileChunk)(const char *, char *, off_t, off_t);
|
||||||
|
static char *(*libmd_MD5Data)(const uint8_t *, size_t, char *);
|
||||||
|
|
||||||
|
static void *
|
||||||
|
libmd_loader(const char *symbol)
|
||||||
|
{
|
||||||
|
void *func;
|
||||||
|
|
||||||
|
func = dlsym(RTLD_NEXT, symbol);
|
||||||
|
if (func == NULL) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"libbsd: cannot find wrapped symbol %s in libc or libmd\n",
|
||||||
|
symbol);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
return func;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define libmd_wrapper(symbol) \
|
||||||
|
if (libmd_ ## symbol == NULL) \
|
||||||
|
libmd_ ## symbol = libmd_loader(#symbol)
|
||||||
|
|
||||||
void
|
void
|
||||||
bsd_MD5Init(MD5_CTX *context)
|
MD5Init(MD5_CTX *context)
|
||||||
{
|
{
|
||||||
MD5Init(context);
|
libmd_wrapper(MD5Init);
|
||||||
|
libmd_MD5Init(context);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5Init, bsd_MD5Init, LIBBSD_0.0);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
bsd_MD5Update(MD5_CTX *context, const uint8_t *data, size_t len)
|
MD5Update(MD5_CTX *context, const uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
MD5Update(context, data, len);
|
libmd_wrapper(MD5Update);
|
||||||
|
libmd_MD5Update(context, data, len);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5Update, bsd_MD5Update, LIBBSD_0.0);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
bsd_MD5Pad(MD5_CTX *context)
|
MD5Pad(MD5_CTX *context)
|
||||||
{
|
{
|
||||||
MD5Pad(context);
|
libmd_wrapper(MD5Pad);
|
||||||
|
libmd_MD5Pad(context);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5Pad, bsd_MD5Pad, LIBBSD_0.0);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
bsd_MD5Final(uint8_t digest[MD5_DIGEST_LENGTH], MD5_CTX *context)
|
MD5Final(uint8_t digest[MD5_DIGEST_LENGTH], MD5_CTX *context)
|
||||||
{
|
{
|
||||||
MD5Final(digest, context);
|
libmd_wrapper(MD5Final);
|
||||||
|
libmd_MD5Final(digest, context);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5Final, bsd_MD5Final, LIBBSD_0.0);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
bsd_MD5Transform(uint32_t state[4], const uint8_t block[MD5_BLOCK_LENGTH])
|
MD5Transform(uint32_t state[4], const uint8_t block[MD5_BLOCK_LENGTH])
|
||||||
{
|
{
|
||||||
MD5Transform(state, block);
|
libmd_wrapper(MD5Transform);
|
||||||
|
libmd_MD5Transform(state, block);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5Transform, bsd_MD5Transform, LIBBSD_0.0);
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
bsd_MD5End(MD5_CTX *context, char *buf)
|
MD5End(MD5_CTX *context, char *buf)
|
||||||
{
|
{
|
||||||
return MD5End(context, buf);
|
libmd_wrapper(MD5End);
|
||||||
|
return libmd_MD5End(context, buf);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5End, bsd_MD5End, LIBBSD_0.0);
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
bsd_MD5File(const char *filename, char *buf)
|
MD5File(const char *filename, char *buf)
|
||||||
{
|
{
|
||||||
|
libmd_wrapper(MD5File);
|
||||||
return MD5File(filename, buf);
|
return MD5File(filename, buf);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5File, bsd_MD5File, LIBBSD_0.0);
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
bsd_MD5FileChunk(const char *filename, char *buf, off_t offset, off_t length)
|
MD5FileChunk(const char *filename, char *buf, off_t offset, off_t length)
|
||||||
{
|
{
|
||||||
return MD5FileChunk(filename, buf, offset, length);
|
libmd_wrapper(MD5FileChunk);
|
||||||
|
return libmd_MD5FileChunk(filename, buf, offset, length);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5FileChunk, bsd_MD5FileChunk, LIBBSD_0.0);
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
bsd_MD5Data(const uint8_t *data, size_t len, char *buf)
|
MD5Data(const uint8_t *data, size_t len, char *buf)
|
||||||
{
|
{
|
||||||
return MD5Data(data, len, buf);
|
libmd_wrapper(MD5Data);
|
||||||
|
return libmd_MD5Data(data, len, buf);
|
||||||
}
|
}
|
||||||
libbsd_symver_variant(MD5Data, bsd_MD5Data, LIBBSD_0.0);
|
|
||||||
|
@@ -52,8 +52,6 @@ check_PROGRAMS = \
|
|||||||
vis-openbsd \
|
vis-openbsd \
|
||||||
$(nil)
|
$(nil)
|
||||||
|
|
||||||
md5_LDADD = $(LDADD) $(MD_LIBS)
|
|
||||||
|
|
||||||
if HAVE_LIBTESTU01
|
if HAVE_LIBTESTU01
|
||||||
arc4random_LDADD = $(LDADD) $(TESTU01_LIBS)
|
arc4random_LDADD = $(LDADD) $(TESTU01_LIBS)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user