diff --git a/CMakeLists.txt b/CMakeLists.txt index 25fcb72..306550f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,7 @@ if(NOT ENABLE_SSE AND ENABLE_AVX) set(ENABLE_AVX OFF) endif() + option(FETCH_AUTO "automatically download and build dependencies" OFF) #option(FETCH_SPAN_LITE "download and build span" OFF)) @@ -87,6 +88,13 @@ EVAL(FETCH_SPAN_LITE_IMPL (DEFINED FETCH_SPAN_LITE AND FETCH_SPAN_LITE) OR ((NOT DEFINED FETCH_SPAN_LITE) AND (FETCH_AUTO AND ENABLE_SPAN_LITE))) +if(CRYPTO_TOOLS_STD_VER EQUAL 14 OR CRYPTO_TOOLS_STD_VER EQUAL 17) + set(ENABLE_SPAN_LITE ON) +else() + set(ENABLE_SPAN_LITE OFF) + set(FETCH_SPAN_LITE_IMPL OFF) +endif() + #option(FETCH_SPAN_LITE "download and build span" OFF)) EVAL(FETCH_GMP_IMPL (DEFINED FETCH_GMP AND FETCH_GMP) OR diff --git a/cmake/cryptoToolsDepHelper.cmake b/cmake/cryptoToolsDepHelper.cmake index 0e1f97e..afb89da 100644 --- a/cmake/cryptoToolsDepHelper.cmake +++ b/cmake/cryptoToolsDepHelper.cmake @@ -244,8 +244,9 @@ if (FETCH_SPAN_LITE_IMPL) include("${CMAKE_CURRENT_LIST_DIR}/../thirdparty/getSpanLite.cmake") endif() -FIND_SPAN(REQUIRED) - +if(ENABLE_SPAN_LITE) + FIND_SPAN(REQUIRED) +endif() ## GMP ########################################################################### diff --git a/cryptoTools/Common/block.h b/cryptoTools/Common/block.h index fec9e8d..c25cbcc 100644 --- a/cryptoTools/Common/block.h +++ b/cryptoTools/Common/block.h @@ -71,7 +71,8 @@ namespace osuCrypto template::value && + std::is_standard_layout::value&& + std::is_trivial::value && (sizeof(T) <= 16) && (16 % sizeof(T) == 0) >::type> @@ -176,7 +177,8 @@ namespace osuCrypto // For integer types, this will be specialized with SSE futher down. template OC_FORCEINLINE static typename std::enable_if< - std::is_pod::value && + std::is_standard_layout::value&& + std::is_trivial::value && (sizeof(T) <= 16) && (16 % sizeof(T) == 0), block>::type allSame(T val) diff --git a/cryptoTools/Crypto/Blake2.h b/cryptoTools/Crypto/Blake2.h index 9cadcb0..c53eddb 100644 --- a/cryptoTools/Crypto/Blake2.h +++ b/cryptoTools/Crypto/Blake2.h @@ -56,7 +56,10 @@ namespace osuCrypto { // Add length bytes pointed to by dataIn to the internal Blake2 state. template - typename std::enable_if::value>::type Update(const T* dataIn, u64 length) + typename std::enable_if< + std::is_standard_layout::value&& + std::is_trivial::value + >::type Update(const T* dataIn, u64 length) { blake2b_update(&state, dataIn, length * sizeof(T)); } @@ -77,7 +80,12 @@ namespace osuCrypto { // Finalize the Blake2 hash and output the result to out. // Only sizeof(T) bytes of the output are written. template - typename std::enable_if::value && sizeof(T) <= MaxHashSize && std::is_pointer::value == false>::type + typename std::enable_if< + std::is_standard_layout::value&& + std::is_trivial::value && + sizeof(T) <= MaxHashSize && + std::is_pointer::value == false + >::type Final(T& out) { if (sizeof(T) != outputLength()) diff --git a/cryptoTools/Crypto/Hashable.h b/cryptoTools/Crypto/Hashable.h index 4fe4335..39abd2d 100644 --- a/cryptoTools/Crypto/Hashable.h +++ b/cryptoTools/Crypto/Hashable.h @@ -16,7 +16,11 @@ namespace osuCrypto { struct Hashable : std::false_type {}; template - struct Hashable::value>::type> : std::true_type + struct Hashable::value&& + std::is_trivial::value>::type + > : std::true_type { template static void hash(const T& t, Hasher& hasher) diff --git a/cryptoTools/Network/Channel.h b/cryptoTools/Network/Channel.h index 74ce7da..4ccf48b 100644 --- a/cryptoTools/Network/Channel.h +++ b/cryptoTools/Network/Channel.h @@ -60,13 +60,13 @@ namespace osuCrypto { // Sends length number of T pointed to by src over the network. The type T // must be POD. Returns once all the data has been sent. template - typename std::enable_if::value, void>::type + typename std::enable_if::value, void>::type send(const T* src, u64 length); // Sends the data in buf over the network. The type Container must meet the // requirements defined in IoBuffer.h. Returns once all the data has been sent. template - typename std::enable_if::value, void>::type + typename std::enable_if::value, void>::type send(const T& buf); // Sends the data in buf over the network. The type Container must meet the @@ -80,7 +80,7 @@ namespace osuCrypto { // Returns before the data has been sent. The life time of the data must be // managed externally to ensure it lives longer than the async operations. template - typename std::enable_if::value, void>::type + typename std::enable_if::value, void>::type asyncSend(const T* data, u64 length); // Sends the data in buf over the network. The type Container must meet the @@ -107,7 +107,7 @@ namespace osuCrypto { // Returns before the data has been sent. The life time of the data must be // managed externally to ensure it lives longer than the async operations. template - typename std::enable_if::value, void>::type + typename std::enable_if::value, void>::type asyncSend(const T& data); // Sends the data in buf over the network. The type T must be POD. @@ -140,20 +140,20 @@ namespace osuCrypto { // Returns before the data has been sent. The life time of the data must be // managed externally to ensure it lives longer than the async operations. template - typename std::enable_if::value, std::future>::type + typename std::enable_if::value, std::future>::type asyncSendFuture(const T* data, u64 length); // Performs a data copy and then sends the data in buf over the network. // The type T must be POD. Returns before the data has been sent. template - typename std::enable_if::value, void>::type + typename std::enable_if::value, void>::type asyncSendCopy(const T& buff); // Performs a data copy and then sends the data in buf over the network. // The type T must be POD. Returns before the data has been sent. template - typename std::enable_if::value, void>::type + typename std::enable_if::value, void>::type asyncSendCopy(const T* bufferPtr, u64 length); // Performs a data copy and then sends the data in buf over the network. @@ -193,34 +193,34 @@ namespace osuCrypto { // Receive data over the network. The function returns once all the data // has been received. template - typename std::enable_if::value, void>::type + typename std::enable_if::value, void>::type recv(T* dest, u64 length); // Receive data over the network. The function returns once all the data // has been received. template - typename std::enable_if::value, void>::type + typename std::enable_if::value, void>::type recv(T& dest) { recv(&dest, 1); } // Receive data over the network asynchronously. The function returns right away, // before the data has been received. When all the data has benn received the // future is set. template - typename std::enable_if::value, std::future>::type + typename std::enable_if::value, std::future>::type asyncRecv(T* dest, u64 length); // Receive data over the network asynchronously. The function returns right away, // before the data has been received. When all the data has benn received the // future is set and the callback fn is called. template - typename std::enable_if::value, std::future>::type + typename std::enable_if::value, std::future>::type asyncRecv(T* dest, u64 length, std::function fn); // Receive data over the network asynchronously. The function returns right away, // before the data has been received. When all the data has benn received the // future is set. template - typename std::enable_if::value, std::future>::type + typename std::enable_if::value, std::future>::type asyncRecv(T& dest) { return asyncRecv(&dest, 1); } // Receive data over the network asynchronously. The function returns right away, @@ -759,7 +759,7 @@ namespace osuCrypto { template - typename std::enable_if::value, void>::type + typename std::enable_if::value, void>::type Channel::send(const T* buffT, u64 sizeT) { asyncSendFuture(buffT, sizeT).get(); @@ -767,7 +767,7 @@ namespace osuCrypto { template - typename std::enable_if::value, std::future>::type + typename std::enable_if::value, std::future>::type Channel::asyncSendFuture(const T* buffT, u64 sizeT) { u8* buff = (u8*)buffT; @@ -796,14 +796,14 @@ namespace osuCrypto { template - typename std::enable_if::value, void>::type + typename std::enable_if::value, void>::type Channel::send(const T& buffT) { send(&buffT, 1); } template - typename std::enable_if::value, std::future>::type + typename std::enable_if::value, std::future>::type Channel::asyncRecv(T* buffT, u64 sizeT) { u8* buff = (u8*)buffT; @@ -830,7 +830,7 @@ namespace osuCrypto { } template - typename std::enable_if::value, std::future>::type + typename std::enable_if::value, std::future>::type Channel::asyncRecv(T* buffT, u64 sizeT, std::function fn) { u8* buff = (u8*)buffT; @@ -858,7 +858,7 @@ namespace osuCrypto { } template - typename std::enable_if::value, void>::type + typename std::enable_if::value, void>::type Channel::asyncSend(const T* buffT, u64 sizeT) { u8* buff = (u8*)buffT; @@ -880,7 +880,7 @@ namespace osuCrypto { template - typename std::enable_if::value, void>::type + typename std::enable_if::value, void>::type Channel::asyncSend(const T& v) { asyncSend(&v, 1); @@ -938,14 +938,14 @@ namespace osuCrypto { template - typename std::enable_if::value, void>::type + typename std::enable_if::value, void>::type Channel::recv(T* buff, u64 size) { asyncRecv(buff, size).get(); } template - typename std::enable_if::value, void>::type + typename std::enable_if::value, void>::type Channel::asyncSendCopy(const T* bufferPtr, u64 length) { std::vector bs((u8*)bufferPtr, (u8*)bufferPtr + length * sizeof(T)); @@ -954,7 +954,7 @@ namespace osuCrypto { template - typename std::enable_if::value, void>::type + typename std::enable_if::value, void>::type Channel::asyncSendCopy(const T& buf) { asyncSendCopy(&buf, 1); diff --git a/cryptoTools/Network/IoBuffer.h b/cryptoTools/Network/IoBuffer.h index 86ad61a..deaf18e 100644 --- a/cryptoTools/Network/IoBuffer.h +++ b/cryptoTools/Network/IoBuffer.h @@ -110,6 +110,8 @@ namespace osuCrypto #define _SILENCE_CXX20_IS_POD_DEPRECATION_WARNING + + /// type trait that defines what is considered a STL like Container /// /// Must have the following member types: pointer, size_type, value_type @@ -127,8 +129,8 @@ namespace osuCrypto std::is_convertible< typename Container::size_type, decltype(std::declval().size())>::value&& - std::is_pod::value&& - std::is_pod::value == false>::type + std::is_trivial::value&& + std::is_trivial::value == false>::type , void>; diff --git a/thirdparty/getCoproto.cmake b/thirdparty/getCoproto.cmake index 01189bc..61a303d 100644 --- a/thirdparty/getCoproto.cmake +++ b/thirdparty/getCoproto.cmake @@ -2,7 +2,7 @@ set(USER_NAME ) set(TOKEN ) set(GIT_REPOSITORY "https://github.com/Visa-Research/coproto.git") -set(GIT_TAG "fd097b1f2498b73140dd6e2e3d0ee5c5e3c60cd2" ) +set(GIT_TAG "22c98abba47dbfacd421e3dcd90702fff74de6f3" ) set(CLONE_DIR "${OC_THIRDPARTY_CLONE_DIR}/coproto") set(BUILD_DIR "${CLONE_DIR}/out/build/${OC_CONFIG}") @@ -25,7 +25,7 @@ if(NOT coproto_FOUND) -DCOPROTO_NO_SYSTEM_PATH=${NO_SYSTEM_PATH} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DVERBOSE_FETCH=true - -DCOPROTO_FETCH_SPAN=ON + -DCOPROTO_FETCH_SPAN=OFF -DCOPROTO_FETCH_FUNCTION2=ON -DCOPROTO_FETCH_MACORO=ON -DCOPROTO_FETCH_BOOST=${LOCAL_COPROTO_FETCH_BOOST}