mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 15:43:32 +01:00
hs_pow: Replace libb2 dependency with hashx's internal blake2
This forgoes another external library dependency, and instead introduces a compatibility header so that interested parties (who already depend on equix, like hs_pow and unit tests) can use the implementation of blake2b included in hashx. Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
This commit is contained in:
parent
ffa8531fe0
commit
bfa2102c95
@ -435,9 +435,6 @@ AC_DEFUN([ADD_MODULE], [
|
|||||||
m4_foreach_w([module], MODULES, [ADD_MODULE([module])])
|
m4_foreach_w([module], MODULES, [ADD_MODULE([module])])
|
||||||
AC_SUBST(TOR_MODULES_ALL_ENABLED)
|
AC_SUBST(TOR_MODULES_ALL_ENABLED)
|
||||||
|
|
||||||
dnl Blake2 check for Equi-X support.
|
|
||||||
PKG_CHECK_MODULES([LIBB2], [libb2])
|
|
||||||
|
|
||||||
dnl check for the correct "ar" when cross-compiling.
|
dnl check for the correct "ar" when cross-compiling.
|
||||||
dnl (AM_PROG_AR was new in automake 1.11.2, which we do not yet require,
|
dnl (AM_PROG_AR was new in automake 1.11.2, which we do not yet require,
|
||||||
dnl so kludge up a replacement for the case where it isn't there yet.)
|
dnl so kludge up a replacement for the case where it isn't there yet.)
|
||||||
|
@ -20,8 +20,7 @@ src_app_tor_LDADD = libtor.a \
|
|||||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ $(TOR_LIBS_CRYPTLIB) \
|
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ $(TOR_LIBS_CRYPTLIB) \
|
||||||
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||||
@CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \
|
@CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \
|
||||||
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@ \
|
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@
|
||||||
@LIBB2_LIBS@
|
|
||||||
|
|
||||||
if COVERAGE_ENABLED
|
if COVERAGE_ENABLED
|
||||||
src_app_tor_cov_SOURCES = $(src_app_tor_SOURCES)
|
src_app_tor_cov_SOURCES = $(src_app_tor_SOURCES)
|
||||||
@ -33,6 +32,5 @@ src_app_tor_cov_LDADD = src/test/libtor-testing.a \
|
|||||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ $(TOR_LIBS_CRYPTLIB) \
|
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ $(TOR_LIBS_CRYPTLIB) \
|
||||||
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ \
|
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ \
|
||||||
@CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \
|
@CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \
|
||||||
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@ \
|
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@
|
||||||
@LIBB2_LIBS@
|
|
||||||
endif
|
endif
|
||||||
|
@ -8,3 +8,5 @@ tinytest*.h
|
|||||||
ext/siphash.h
|
ext/siphash.h
|
||||||
ext/byteorder.h
|
ext/byteorder.h
|
||||||
ext/tor_readpassphrase.h
|
ext/tor_readpassphrase.h
|
||||||
|
|
||||||
|
ext/equix/hashx/src/blake2.h
|
47
src/ext/compat_blake2.h
Normal file
47
src/ext/compat_blake2.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/* Copyright (c) 2023, The Tor Project, Inc. */
|
||||||
|
/* See LICENSE for licensing information */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file compat_blake2.h
|
||||||
|
*
|
||||||
|
* \brief Compatibility adapter providing blake2b using ext/equix/hashx
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef TOR_COMPAT_BLAKE2_H
|
||||||
|
#define TOR_COMPAT_BLAKE2_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "lib/cc/compat_compiler.h"
|
||||||
|
#include "ext/equix/hashx/src/blake2.h"
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
blake2b_init_param(blake2b_state *S, const blake2b_param *P)
|
||||||
|
{
|
||||||
|
return hashx_blake2b_init_param(S, P);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
blake2b_init(blake2b_state *S, const uint8_t digest_length)
|
||||||
|
{
|
||||||
|
blake2b_param P;
|
||||||
|
memset(&P, 0, sizeof P);
|
||||||
|
P.digest_length = digest_length;
|
||||||
|
P.fanout = 1;
|
||||||
|
P.depth = 1;
|
||||||
|
return blake2b_init_param(S, &P);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
blake2b_update(blake2b_state *S, const uint8_t *in, uint64_t inlen)
|
||||||
|
{
|
||||||
|
return hashx_blake2b_update(S, in, inlen);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
blake2b_final(blake2b_state *S, uint8_t *out, uint8_t outlen)
|
||||||
|
{
|
||||||
|
return hashx_blake2b_final(S, out, outlen);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* !defined(TOR_COMPAT_BLAKE2_H) */
|
@ -1,5 +1,8 @@
|
|||||||
|
|
||||||
AM_CPPFLAGS += -I$(srcdir)/src/ext -Isrc/ext
|
AM_CPPFLAGS += \
|
||||||
|
-I$(srcdir)/src/ext/ \
|
||||||
|
-I$(srcdir)/src/ext/equix/include/ \
|
||||||
|
-I$(srcdir)/src/ext/equix/hashx/include/
|
||||||
|
|
||||||
# TODO: put this with other equix/hashx ext defs when those happen,
|
# TODO: put this with other equix/hashx ext defs when those happen,
|
||||||
# and also add it to the autoconf config header. For now this is here
|
# and also add it to the autoconf config header. For now this is here
|
||||||
@ -19,6 +22,7 @@ EXTHEADERS = \
|
|||||||
src/ext/tinytest_macros.h \
|
src/ext/tinytest_macros.h \
|
||||||
src/ext/tor_queue.h \
|
src/ext/tor_queue.h \
|
||||||
src/ext/siphash.h \
|
src/ext/siphash.h \
|
||||||
|
src/ext/compat_blake2.h \
|
||||||
src/ext/timeouts/timeout.h \
|
src/ext/timeouts/timeout.h \
|
||||||
src/ext/timeouts/timeout-debug.h \
|
src/ext/timeouts/timeout-debug.h \
|
||||||
src/ext/timeouts/timeout-bitops.c \
|
src/ext/timeouts/timeout-bitops.c \
|
||||||
|
@ -9,12 +9,10 @@
|
|||||||
|
|
||||||
typedef unsigned __int128 uint128_t;
|
typedef unsigned __int128 uint128_t;
|
||||||
|
|
||||||
// TODO fixme
|
|
||||||
#include <blake2.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "ext/ht.h"
|
#include "ext/ht.h"
|
||||||
|
#include "ext/compat_blake2.h"
|
||||||
#include "core/or/circuitlist.h"
|
#include "core/or/circuitlist.h"
|
||||||
#include "core/or/origin_circuit_st.h"
|
#include "core/or/origin_circuit_st.h"
|
||||||
#include "feature/hs/hs_cache.h"
|
#include "feature/hs/hs_cache.h"
|
||||||
|
@ -14,8 +14,7 @@ FUZZING_LIBS = \
|
|||||||
@TOR_SYSTEMD_LIBS@ \
|
@TOR_SYSTEMD_LIBS@ \
|
||||||
@TOR_LZMA_LIBS@ \
|
@TOR_LZMA_LIBS@ \
|
||||||
@TOR_ZSTD_LIBS@ \
|
@TOR_ZSTD_LIBS@ \
|
||||||
@TOR_TRACE_LIBS@ \
|
@TOR_TRACE_LIBS@
|
||||||
@LIBB2_LIBS@
|
|
||||||
|
|
||||||
oss-fuzz-prereqs: \
|
oss-fuzz-prereqs: \
|
||||||
src/test/libtor-testing.a
|
src/test/libtor-testing.a
|
||||||
|
@ -301,7 +301,7 @@ src_test_test_switch_id_LDADD = \
|
|||||||
$(TOR_UTIL_TESTING_LIBS) \
|
$(TOR_UTIL_TESTING_LIBS) \
|
||||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
|
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
|
||||||
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_USERENV@ \
|
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_USERENV@ \
|
||||||
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@ @LIBB2_LIBS@
|
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@
|
||||||
src_test_test_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
|
src_test_test_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
|
||||||
@TOR_LDFLAGS_libevent@
|
@TOR_LDFLAGS_libevent@
|
||||||
src_test_test_LDADD = \
|
src_test_test_LDADD = \
|
||||||
@ -309,7 +309,7 @@ src_test_test_LDADD = \
|
|||||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
|
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
|
||||||
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||||
@CURVE25519_LIBS@ \
|
@CURVE25519_LIBS@ \
|
||||||
@TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@ @LIBB2_LIBS@
|
@TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@
|
||||||
|
|
||||||
src_test_test_slow_CPPFLAGS = $(src_test_test_CPPFLAGS)
|
src_test_test_slow_CPPFLAGS = $(src_test_test_CPPFLAGS)
|
||||||
src_test_test_slow_CFLAGS = $(src_test_test_CFLAGS)
|
src_test_test_slow_CFLAGS = $(src_test_test_CFLAGS)
|
||||||
@ -337,7 +337,7 @@ src_test_bench_LDADD = \
|
|||||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
|
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
|
||||||
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||||
@CURVE25519_LIBS@ \
|
@CURVE25519_LIBS@ \
|
||||||
@TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@ @LIBB2_LIBS@
|
@TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@
|
||||||
|
|
||||||
src_test_test_workqueue_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
|
src_test_test_workqueue_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
|
||||||
@TOR_LDFLAGS_libevent@
|
@TOR_LDFLAGS_libevent@
|
||||||
@ -346,7 +346,7 @@ src_test_test_workqueue_LDADD = \
|
|||||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
|
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
|
||||||
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||||
@CURVE25519_LIBS@ \
|
@CURVE25519_LIBS@ \
|
||||||
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@ @LIBB2_LIBS@
|
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@
|
||||||
|
|
||||||
src_test_test_timers_CPPFLAGS = $(src_test_test_CPPFLAGS)
|
src_test_test_timers_CPPFLAGS = $(src_test_test_CPPFLAGS)
|
||||||
src_test_test_timers_CFLAGS = $(src_test_test_CFLAGS)
|
src_test_test_timers_CFLAGS = $(src_test_test_CFLAGS)
|
||||||
@ -357,7 +357,7 @@ src_test_test_timers_LDADD = \
|
|||||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
|
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
|
||||||
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||||
@CURVE25519_LIBS@ \
|
@CURVE25519_LIBS@ \
|
||||||
@TOR_LZMA_LIBS@ @TOR_TRACE_LIBS@ @LIBB2_LIBS@
|
@TOR_LZMA_LIBS@ @TOR_TRACE_LIBS@
|
||||||
src_test_test_timers_LDFLAGS = $(src_test_test_LDFLAGS)
|
src_test_test_timers_LDFLAGS = $(src_test_test_LDFLAGS)
|
||||||
|
|
||||||
# ADD_C_FILE: INSERT HEADERS HERE.
|
# ADD_C_FILE: INSERT HEADERS HERE.
|
||||||
@ -391,7 +391,7 @@ src_test_test_ntor_cl_LDADD = \
|
|||||||
libtor.a \
|
libtor.a \
|
||||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
|
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
|
||||||
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||||
@CURVE25519_LIBS@ @TOR_LZMA_LIBS@ @TOR_TRACE_LIBS@ @LIBB2_LIBS@
|
@CURVE25519_LIBS@ @TOR_LZMA_LIBS@ @TOR_TRACE_LIBS@
|
||||||
src_test_test_ntor_cl_AM_CPPFLAGS = \
|
src_test_test_ntor_cl_AM_CPPFLAGS = \
|
||||||
$(AM_CPPFLAGS)
|
$(AM_CPPFLAGS)
|
||||||
|
|
||||||
@ -401,7 +401,7 @@ src_test_test_hs_ntor_cl_LDADD = \
|
|||||||
libtor.a \
|
libtor.a \
|
||||||
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
|
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
|
||||||
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ \
|
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ \
|
||||||
@CURVE25519_LIBS@ @TOR_TRACE_LIBS@ @LIBB2_LIBS@
|
@CURVE25519_LIBS@ @TOR_TRACE_LIBS@
|
||||||
src_test_test_hs_ntor_cl_AM_CPPFLAGS = \
|
src_test_test_hs_ntor_cl_AM_CPPFLAGS = \
|
||||||
$(AM_CPPFLAGS)
|
$(AM_CPPFLAGS)
|
||||||
|
|
||||||
@ -413,7 +413,7 @@ src_test_test_bt_cl_LDADD = \
|
|||||||
$(TOR_UTIL_TESTING_LIBS) \
|
$(TOR_UTIL_TESTING_LIBS) \
|
||||||
@TOR_LIB_MATH@ \
|
@TOR_LIB_MATH@ \
|
||||||
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
|
||||||
@TOR_TRACE_LIBS@ @LIBB2_LIBS@
|
@TOR_TRACE_LIBS@
|
||||||
src_test_test_bt_cl_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
|
src_test_test_bt_cl_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
|
||||||
src_test_test_bt_cl_CPPFLAGS= $(src_test_AM_CPPFLAGS) $(TEST_CPPFLAGS)
|
src_test_test_bt_cl_CPPFLAGS= $(src_test_AM_CPPFLAGS) $(TEST_CPPFLAGS)
|
||||||
endif
|
endif
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "test/test.h"
|
#include "test/test.h"
|
||||||
#include "lib/crypt_ops/aes.h"
|
#include "lib/crypt_ops/aes.h"
|
||||||
#include "siphash.h"
|
#include "siphash.h"
|
||||||
|
#include "ext/compat_blake2.h"
|
||||||
#include "ext/equix/hashx/include/hashx.h"
|
#include "ext/equix/hashx/include/hashx.h"
|
||||||
#include "lib/crypt_ops/crypto_curve25519.h"
|
#include "lib/crypt_ops/crypto_curve25519.h"
|
||||||
#include "lib/crypt_ops/crypto_dh.h"
|
#include "lib/crypt_ops/crypto_dh.h"
|
||||||
@ -21,9 +22,6 @@
|
|||||||
#include "ed25519_vectors.inc"
|
#include "ed25519_vectors.inc"
|
||||||
#include "test/log_test_helpers.h"
|
#include "test/log_test_helpers.h"
|
||||||
|
|
||||||
// TODO fixme
|
|
||||||
#include <blake2.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_STAT_H
|
#ifdef HAVE_SYS_STAT_H
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user