summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel2019-09-23 14:01:24 -0400
committerGuillaume Horel2019-10-05 11:25:15 -0400
commit249a0f17006290c473d58aa9c1257f9aa25abf16 (patch)
tree2e1578237f7930ae5324107e22e9c8c9960940ac
parent7edff4e9036a96727c589d8f849c0b65304cbc1c (diff)
downloadaur-249a0f17006290c473d58aa9c1257f9aa25abf16.tar.gz
version bump
-rw-r--r--.SRCINFO8
-rw-r--r--PKGBUILD14
-rw-r--r--cmake.patch539
-rw-r--r--fix-warnings.patch11
4 files changed, 551 insertions, 21 deletions
diff --git a/.SRCINFO b/.SRCINFO
index f09b20afe7bc..5d2789adfd32 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -7,10 +7,10 @@ pkgbase = libdecaf
license = MIT
makedepends = cmake
makedepends = python
- source = https://sourceforge.net/projects/ed448goldilocks/files/libdecaf-1.0.0.tgz
- source = fix-warnings.patch
- sha256sums = a332d09731c9af9bef071ae7aa700a0ae59161bc94d78ace32fe21dd4c328d04
- sha256sums = a3618955de5972e388490c8f8ea1d46aac242bc148e2bd81bac56c9b1b4dcbad
+ source = libdecaf-1.0.0::git+git://git.code.sf.net/p/ed448goldilocks/code
+ source = cmake.patch
+ sha256sums = SKIP
+ sha256sums = 9b723855f1f86889a2f78257adab619e6787ca1439f3aa8af7b81cb842b93f8d
pkgname = libdecaf
diff --git a/PKGBUILD b/PKGBUILD
index 8057fd767dc5..773cc6c8ec7d 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -8,18 +8,20 @@ depends=()
makedepends=('cmake' 'python')
license=('MIT')
arch=('x86_64')
-source=("https://sourceforge.net/projects/ed448goldilocks/files/$pkgname-$pkgver.tgz"
- "fix-warnings.patch")
-sha256sums=('a332d09731c9af9bef071ae7aa700a0ae59161bc94d78ace32fe21dd4c328d04'
- 'a3618955de5972e388490c8f8ea1d46aac242bc148e2bd81bac56c9b1b4dcbad')
+source=("libdecaf-1.0.0::git+git://git.code.sf.net/p/ed448goldilocks/code"
+ "cmake.patch")
+sha256sums=('SKIP'
+ '9b723855f1f86889a2f78257adab619e6787ca1439f3aa8af7b81cb842b93f8d')
prepare() {
cd "${srcdir}/${pkgname}-${pkgver}"
- patch -p1 < ../fix-warnings.patch
+ patch -p1 < ../cmake.patch
mkdir -p build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr \
- -DCMAKE_INSTALL_LIBDIR=lib ..
+ -DCMAKE_INSTALL_LIBDIR=lib \
+ -DENABLE_STATIC=OFF \
+ -DENABLE_TESTS=ON ..
}
build() {
diff --git a/cmake.patch b/cmake.patch
new file mode 100644
index 000000000000..83b75d1cf988
--- /dev/null
+++ b/cmake.patch
@@ -0,0 +1,539 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index cb1bbba..bb04bce 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -15,7 +15,7 @@ find_package( PythonInterp 2.7 REQUIRED )
+ option(ENABLE_SHARED "Build shared library." ON)
+ option(ENABLE_STATIC "Build static library." ON)
+ option(ENABLE_STRICT "Build with strict compile options." YES)
+-option(ENABLE_TESTS "Enable compilation of tests." YES)
++option(ENABLE_TESTS "Enable compilation of tests." OFF)
+ option(GENERATED_SOURCE_PATH "Where the generated source code is stored, default in the building tree" OFF)
+
+ if (GENERATED_SOURCE_PATH)
+@@ -23,7 +23,7 @@ if (GENERATED_SOURCE_PATH)
+ else()
+ set(GSOURCE_PATH ${PROJECT_BINARY_DIR}/src/GENERATED)
+ endif()
+-message("Generated source code will be in ${GSOURCE_PATH}")
++message("Generated source code in ${GSOURCE_PATH}")
+
+ if(NOT CPACK_GENERATOR AND NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX)
+ set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
+@@ -49,40 +49,41 @@ if(MSVC)
+ set(STRICT_OPTIONS_CPP "${STRICT_OPTIONS_CPP} /WX")
+ endif()
+ else()
+- set(STRICT_OPTIONS_CXX "${STRICT_OPTIONS_CXX} -std=c++11 -O2 ")
+- set(STRICT_OPTIONS_CPP "${STRICT_OPTIONS_CPP} -Wall -Wuninitialized -Wno-deprecated-declarations -Wno-missing-field-initializers ")
+- set(STRICT_OPTIONS_C "${STRICT_OPTIONS_C} -std=c99 -O2 -Wstrict-prototypes -Wno-error=strict-prototypes -ffunction-sections -fdata-sections -fvisibility=hidden -fomit-frame-pointer ")
++ set(STRICT_OPTIONS_CXX "${STRICT_OPTIONS_CXX} -std=c++11 -O2")
++ set(STRICT_OPTIONS_CPP "${STRICT_OPTIONS_CPP} -Wall -Wuninitialized -Wno-deprecated-declarations -Wno-missing-field-initializers")
++ set(STRICT_OPTIONS_C "${STRICT_OPTIONS_C} -std=c99 -O2 -Wstrict-prototypes -Wno-error=strict-prototypes -fvisibility=hidden")
+ if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+- set(STRICT_OPTIONS_CPP "${STRICT_OPTIONS_CPP} -Qunused-arguments -Wno-array-bounds ")
++ set(STRICT_OPTIONS_CPP "${STRICT_OPTIONS_CPP} -Qunused-arguments -Wno-array-bounds")
+ endif()
+ if(APPLE)
+- set(STRICT_OPTIONS_CPP "${STRICT_OPTIONS_CPP} -Wno-error=unknown-warning-option -Qunused-arguments -Wno-tautological-compare -Wno-unused-function -Wno-array-bounds ")
+- set(STRICT_OPTIONS_CXX "${STRICT_OPTIONS_CXX} -stdlib=libc++ ")
++ set(STRICT_OPTIONS_CPP "${STRICT_OPTIONS_CPP} -Wno-error=unknown-warning-option -Qunused-arguments -Wno-tautological-compare -Wno-unused-function -Wno-array-bounds")
+ endif()
+ if(ENABLE_STRICT)
+- set(STRICT_OPTIONS_CPP "${STRICT_OPTIONS_CPP} -Werror -Wextra -Wno-unused-parameter -fno-strict-aliasing ")
++ set(STRICT_OPTIONS_CPP "${STRICT_OPTIONS_CPP} -Werror -Wextra -Wno-unused-parameter -fno-strict-aliasing")
+ endif()
+ endif()
+
+-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${STRICT_OPTIONS_C}")
+-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${STRICT_OPTIONS_CXX}")
++set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${STRICT_OPTIONS_C} ${STRICT_OPTIONS_CPP}")
++set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${STRICT_OPTIONS_CXX} ${STRICT_OPTIONS_CPP}")
+
+ add_subdirectory(src)
+
+ if(ENABLE_TESTS)
+- enable_testing()
++ enable_testing()
+ add_subdirectory(test)
+ endif()
+
+ include(CMakePackageConfigHelpers)
++set(ConfigPackageLocation share/decaf/cmake)
+ export(EXPORT ${EXPORT_TARGETS_NAME}Targets
+ FILE "${CMAKE_CURRENT_BINARY_DIR}/DecafTargets.cmake"
+ )
+-configure_file(cmake/DecafConfig.cmake.in
++configure_package_config_file(cmake/DecafConfig.cmake.in
+ "${CMAKE_CURRENT_BINARY_DIR}/DecafConfig.cmake"
+- @ONLY
++ INSTALL_DESTINATION ${ConfigPackageLocation}
++ NO_SET_AND_CHECK_MACRO
+ )
+-set(ConfigPackageLocation share/decaf/cmake)
++
+ install(EXPORT ${EXPORT_TARGETS_NAME}Targets
+ FILE DecafTargets.cmake
+ DESTINATION ${ConfigPackageLocation}
+@@ -109,7 +110,7 @@ set(CPACK_PACKAGE_NAME "decaf")
+ set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
+ set(CPACK_SOURCE_GENERATOR "TGZ")
+ set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
+-set(CPACK_SOURCE_IGNORE_FILES
++set(CPACK_SOURCE_IGnore_FILES
+ "^${CMAKE_BINARY_DIR}"
+ "/\\\\..+"
+ )
+diff --git a/cmake/DecafConfig.cmake.in b/cmake/DecafConfig.cmake.in
+index 05837f9..730dbbd 100644
+--- a/cmake/DecafConfig.cmake.in
++++ b/cmake/DecafConfig.cmake.in
+@@ -28,23 +28,25 @@
+ # DECAF_LIBRARIES - The libraries needed to use decaf
+ # DECAF_CPPFLAGS - The compilation flags needed to use decaf
+
++@PACKAGE_INIT@
++
++include("${CMAKE_CURRENT_LIST_DIR}/DecafTargets.cmake")
+
+ if(@ENABLE_SHARED@)
+ set(DECAF_TARGETNAME decaf)
+- set(DECAF_LIBRARIES ${DECAF_TARGETNAME})
+ else()
+ set(DECAF_TARGETNAME decaf-static)
+- if(TARGET ${DECAF_TARGETNAME})
+- get_target_property(DECAF_LIBRARIES ${DECAF_TARGETNAME} LOCATION)
+- get_target_property(DECAF_LINK_LIBRARIES ${DECAF_TARGETNAME} INTERFACE_LINK_LIBRARIES)
+- if(DECAF_LINK_LIBRARIES)
+- list(APPEND DECAF_LIBRARIES ${DECAF_LINK_LIBRARIES})
+- endif()
+- endif()
+ endif()
++
+ get_target_property(DECAF_INCLUDE_DIRS ${DECAF_TARGETNAME} INTERFACE_INCLUDE_DIRECTORIES)
+-list(INSERT DECAF_INCLUDE_DIRS 0 "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
+-list(REMOVE_DUPLICATES DECAF_INCLUDE_DIRS)
++
++if(TARGET ${DECAF_TARGETNAME})
++ get_target_property(DECAF_LIBRARIES ${DECAF_TARGETNAME} LOCATION)
++ get_target_property(DECAF_LINK_LIBRARIES ${DECAF_TARGETNAME} INTERFACE_LINK_LIBRARIES)
++ if(DECAF_LINK_LIBRARIES)
++ list(APPEND DECAF_LIBRARIES ${DECAF_LINK_LIBRARIES})
++ endif()
++endif()
+
+ set(DECAF_CPPFLAGS @DECAF_CPPFLAGS@)
+ set(DECAF_FOUND 1)
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 0294fc6..aaf54fd 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -5,6 +5,10 @@
+ #
+ ############################################################################
+
++if(MSVC)
++ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
++endif()
++
+ set(DECAF_HEADER_FILES
+ include/constant_time.h
+ include/field.h
+@@ -79,17 +83,14 @@ if(ENABLE_STATIC)
+ add_library(decaf-static STATIC ${DECAF_HEADER_FILES} ${DECAF_SOURCE_FILES_C} ${DECAF_SOURCE_FILES_CXX} $<TARGET_OBJECTS:p25519> $<TARGET_OBJECTS:p448> $<TARGET_OBJECTS:CURVE25519> $<TARGET_OBJECTS:CURVE448>)
+ add_dependencies(decaf-static generatedCode)
+ set_target_properties(decaf-static PROPERTIES OUTPUT_NAME decaf)
+- target_include_directories(decaf-static PUBLIC)
++ target_include_directories(decaf-static INTERFACE $<INSTALL_INTERFACE:include/decaf>)
+ target_link_libraries(decaf-static INTERFACE)
+ endif()
+ if(ENABLE_SHARED)
+ add_library(decaf SHARED ${DECAF_HEADER_FILES} ${DECAF_SOURCE_FILES_C} ${DECAF_SOURCE_FILES_CXX} $<TARGET_OBJECTS:p25519> $<TARGET_OBJECTS:p448> $<TARGET_OBJECTS:CURVE25519> $<TARGET_OBJECTS:CURVE448>)
+ add_dependencies(decaf generatedCode)
+- if(APPLE)
+- set_target_properties(decaf PROPERTIES LINK_FLAGS "-stdlib=libc++")
+- endif()
+ set_target_properties(decaf PROPERTIES VERSION ${DECAF_SO_VERSION})
+- target_include_directories(decaf PUBLIC)
++ target_include_directories(decaf INTERFACE $<INSTALL_INTERFACE:include/decaf>)
+ target_link_libraries(decaf PRIVATE)
+ if(MSVC)
+ if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
+diff --git a/src/include/word.h b/src/include/word.h
+index de22693..d10a804 100644
+--- a/src/include/word.h
++++ b/src/include/word.h
+@@ -50,12 +50,16 @@ extern int posix_memalign(void **, size_t, size_t);
+
+ #if (ARCH_WORD_BITS == 64)
+ typedef uint64_t word_t, mask_t;
++ static const mask_t DECAF_MASK_ALL_SET = (mask_t)0xFFFFFFFFFFFFFFFF;
++ static const mask_t DECAF_MASK_ALL_UNSET = (mask_t)0x0;
+ typedef __uint128_t dword_t;
+ typedef int32_t hsword_t;
+ typedef int64_t sword_t;
+ typedef __int128_t dsword_t;
+ #elif (ARCH_WORD_BITS == 32)
+ typedef uint32_t word_t, mask_t;
++ static const mask_t DECAF_MASK_ALL_SET = (mask_t)0xFFFFFFFF;
++ static const mask_t DECAF_MASK_ALL_UNSET = (mask_t)0x0;
+ typedef uint64_t dword_t;
+ typedef int16_t hsword_t;
+ typedef int32_t sword_t;
+diff --git a/src/p25519/arch_32/f_impl.c b/src/p25519/arch_32/f_impl.c
+index edaa62a..ea11658 100644
+--- a/src/p25519/arch_32/f_impl.c
++++ b/src/p25519/arch_32/f_impl.c
+@@ -48,7 +48,7 @@ void gf_mul (gf_s *__restrict__ cs, const gf as, const gf bs) {
+ accum >>= 26;
+
+ assert(accum < masko);
+- c[1] += accum;
++ c[1] += (uint32_t)accum;
+ }
+
+ void gf_mulw_unsigned (gf_s *__restrict__ cs, const gf as, uint32_t b) {
+@@ -80,7 +80,7 @@ void gf_mulw_unsigned (gf_s *__restrict__ cs, const gf as, uint32_t b) {
+ accum >>= 26;
+
+ assert(accum < masko);
+- c[1] += accum;
++ c[1] += (uint32_t)accum;
+ }
+
+ void gf_sqr (gf_s *__restrict__ cs, const gf as) {
+diff --git a/src/p448/arch_32/f_impl.c b/src/p448/arch_32/f_impl.c
+index 0770bd9..b525668 100644
+--- a/src/p448/arch_32/f_impl.c
++++ b/src/p448/arch_32/f_impl.c
+@@ -88,11 +88,11 @@ void gf_mulw_unsigned (gf_s *__restrict__ cs, const gf as, uint32_t b) {
+
+ accum0 += accum8 + c[8];
+ c[8] = accum0 & mask;
+- c[9] += accum0 >> 28;
++ c[9] += (uint32_t)(accum0 >> 28);
+
+ accum8 += c[0];
+ c[0] = accum8 & mask;
+- c[1] += accum8 >> 28;
++ c[1] += (uint32_t)(accum8 >> 28);
+ }
+
+ void gf_sqr (gf_s *__restrict__ cs, const gf as) {
+diff --git a/src/per_curve/decaf.tmpl.c b/src/per_curve/decaf.tmpl.c
+index 5714e4d..5852314 100644
+--- a/src/per_curve/decaf.tmpl.c
++++ b/src/per_curve/decaf.tmpl.c
+@@ -1273,7 +1273,7 @@ decaf_error_t decaf_x$(gf_shortname) (
+ else if (t == X_PRIVATE_BITS-1) sb = -1;
+
+ mask_t k_t = (sb>>(t%8)) & 1;
+- k_t = -k_t; /* set to all 0s or all 1s */
++ k_t = k_t?DECAF_MASK_ALL_SET:DECAF_MASK_ALL_UNSET; /* set to all 0s or all 1s */
+
+ swap ^= k_t;
+ gf_cond_swap(x2,x3,swap);
+@@ -1394,7 +1394,7 @@ void decaf_x$(gf_shortname)_derive_public_key (
+ memcpy(scalar2,scalar,sizeof(scalar2));
+ scalar2[0] &= -(uint8_t)COFACTOR;
+
+- scalar2[X_PRIVATE_BYTES-1] &= ~(-1u<<((X_PRIVATE_BITS+7)%8));
++ scalar2[X_PRIVATE_BYTES-1] &= ~(0xFF<<((X_PRIVATE_BITS+7)%8));
+ scalar2[X_PRIVATE_BYTES-1] |= 1<<((X_PRIVATE_BITS+7)%8);
+
+ scalar_t the_scalar;
+diff --git a/src/per_curve/elligator.tmpl.c b/src/per_curve/elligator.tmpl.c
+index 12d97b8..51ef140 100644
+--- a/src/per_curve/elligator.tmpl.c
++++ b/src/per_curve/elligator.tmpl.c
+@@ -109,13 +109,13 @@ API_NS(invert_elligator_nonuniform) (
+ uint32_t hint_
+ ) {
+ mask_t hint = hint_;
+- mask_t sgn_s = -(hint & 1),
+- sgn_altx = -(hint>>1 & 1),
+- sgn_r0 = -(hint>>2 & 1),
++ mask_t sgn_s = ((hint & 1)?DECAF_MASK_ALL_SET:DECAF_MASK_ALL_UNSET),
++ sgn_altx = ((hint>>1 & 1)?DECAF_MASK_ALL_SET:DECAF_MASK_ALL_UNSET),
++ sgn_r0 = ((hint>>2 & 1)?DECAF_MASK_ALL_SET:DECAF_MASK_ALL_UNSET),
+ /* FUTURE MAGIC: eventually if there's a curve which needs sgn_ed_T but not sgn_r0,
+ * change this mask extraction.
+ */
+- sgn_ed_T = -(hint>>3 & 1);
++ sgn_ed_T = ((hint>>3 & 1)?DECAF_MASK_ALL_SET:DECAF_MASK_ALL_UNSET);
+ gf a,b,c;
+ API_NS(deisogenize)(a,b,c,p,sgn_s,sgn_altx,sgn_ed_T);
+
+diff --git a/src/per_curve/scalar.tmpl.c b/src/per_curve/scalar.tmpl.c
+index 64af132..aa20a3c 100644
+--- a/src/per_curve/scalar.tmpl.c
++++ b/src/per_curve/scalar.tmpl.c
+@@ -37,15 +37,15 @@ static DECAF_NOINLINE void sc_subx(
+ unsigned int i;
+ for (i=0; i<SCALAR_LIMBS; i++) {
+ chain = (chain + accum[i]) - sub->limb[i];
+- out->limb[i] = chain;
++ out->limb[i] = (decaf_word_t)chain;
+ chain >>= WBITS;
+ }
+- decaf_word_t borrow = chain+extra; /* = 0 or -1 */
++ decaf_word_t borrow = (decaf_word_t)chain+extra; /* = 0 or -1 */
+
+ chain = 0;
+ for (i=0; i<SCALAR_LIMBS; i++) {
+ chain = (chain + out->limb[i]) + (p->limb[i] & borrow);
+- out->limb[i] = chain;
++ out->limb[i] = (decaf_word_t)chain;
+ chain >>= WBITS;
+ }
+ }
+@@ -66,22 +66,22 @@ static DECAF_NOINLINE void sc_montmul (
+ decaf_dword_t chain = 0;
+ for (j=0; j<SCALAR_LIMBS; j++) {
+ chain += ((decaf_dword_t)mand)*mier[j] + accum[j];
+- accum[j] = chain;
++ accum[j] = (decaf_word_t)chain;
+ chain >>= WBITS;
+ }
+- accum[j] = chain;
++ accum[j] = (decaf_word_t)chain;
+
+ mand = accum[0] * MONTGOMERY_FACTOR;
+ chain = 0;
+ mier = sc_p->limb;
+ for (j=0; j<SCALAR_LIMBS; j++) {
+ chain += (decaf_dword_t)mand*mier[j] + accum[j];
+- if (j) accum[j-1] = chain;
++ if (j) accum[j-1] = (decaf_word_t)chain;
+ chain >>= WBITS;
+ }
+ chain += accum[j];
+ chain += hi_carry;
+- accum[j-1] = chain;
++ accum[j-1] = (decaf_word_t)chain;
+ hi_carry = chain >> WBITS;
+ }
+
+@@ -179,10 +179,10 @@ void API_NS(scalar_add) (
+ unsigned int i;
+ for (i=0; i<SCALAR_LIMBS; i++) {
+ chain = (chain + a->limb[i]) + b->limb[i];
+- out->limb[i] = chain;
++ out->limb[i] = (decaf_word_t)chain;
+ chain >>= WBITS;
+ }
+- sc_subx(out, out->limb, sc_p, sc_p, chain);
++ sc_subx(out, out->limb, sc_p, sc_p, (decaf_word_t)chain);
+ }
+
+ void
+@@ -193,7 +193,7 @@ API_NS(scalar_set_unsigned) (
+ memset(out,0,sizeof(scalar_t));
+ unsigned int i = 0;
+ for (; i<sizeof(uint64_t)/sizeof(decaf_word_t); i++) {
+- out->limb[i] = w;
++ out->limb[i] = (decaf_word_t)w;
+ #if DECAF_WORD_BITS < 64
+ w >>= 8*sizeof(decaf_word_t);
+ #endif
+@@ -242,7 +242,7 @@ decaf_error_t API_NS(scalar_decode)(
+
+ API_NS(scalar_mul)(s,s,API_NS(scalar_one)); /* ham-handed reduce */
+
+- return decaf_succeed_if(~word_is_zero(accum));
++ return decaf_succeed_if(~word_is_zero((decaf_word_t)accum));
+ }
+
+ void API_NS(scalar_destroy) (
+@@ -314,17 +314,17 @@ void API_NS(scalar_halve) (
+ scalar_t out,
+ const scalar_t a
+ ) {
+- decaf_word_t mask = -(a->limb[0] & 1);
++ decaf_word_t mask = (a->limb[0] & 1)?DECAF_WORD_ALL_SET:DECAF_WORD_ALL_UNSET;
+ decaf_dword_t chain = 0;
+ unsigned int i;
+ for (i=0; i<SCALAR_LIMBS; i++) {
+ chain = (chain + a->limb[i]) + (sc_p->limb[i] & mask);
+- out->limb[i] = chain;
++ out->limb[i] = (decaf_word_t)chain;
+ chain >>= DECAF_WORD_BITS;
+ }
+ for (i=0; i<SCALAR_LIMBS-1; i++) {
+ out->limb[i] = out->limb[i]>>1 | out->limb[i+1]<<(WBITS-1);
+ }
+- out->limb[i] = out->limb[i]>>1 | chain<<(WBITS-1);
++ out->limb[i] = out->limb[i]>>1 | (decaf_word_t)(chain<<(WBITS-1));
+ }
+
+diff --git a/src/per_field/f_generic.tmpl.c b/src/per_field/f_generic.tmpl.c
+index 563a6e5..ad3fc10 100644
+--- a/src/per_field/f_generic.tmpl.c
++++ b/src/per_field/f_generic.tmpl.c
+@@ -26,7 +26,7 @@ void gf_serialize (uint8_t serial[SER_BYTES], const gf x) {
+ fill += LIMB_PLACE_VALUE(LIMBPERM(j));
+ j++;
+ }
+- serial[i] = buffer;
++ serial[i] = (uint8_t)buffer;
+ fill -= 8;
+ buffer >>= 8;
+ }
+@@ -37,7 +37,7 @@ mask_t gf_lobit(const gf x) {
+ gf y;
+ gf_copy(y,x);
+ gf_strong_reduce(y);
+- return -(y->limb[0]&1);
++ return (y->limb[0]&1)?DECAF_MASK_ALL_SET:DECAF_MASK_ALL_UNSET;
+ }
+
+ /** Deserialize from wire format; return -1 on success and 0 on failure. */
+@@ -46,19 +46,19 @@ mask_t gf_deserialize (gf x, const uint8_t serial[SER_BYTES], uint8_t hi_nmask)
+ dword_t buffer = 0;
+ dsword_t scarry = 0;
+ UNROLL for (unsigned int i=0; i<NLIMBS; i++) {
+- UNROLL while (fill < LIMB_PLACE_VALUE(LIMBPERM(i)) && j < SER_BYTES) {
++ UNROLL while (fill < (unsigned int)(LIMB_PLACE_VALUE(LIMBPERM(i))) && j < SER_BYTES) {
+ uint8_t sj = serial[j];
+ if (j==SER_BYTES-1) sj &= ~hi_nmask;
+ buffer |= ((dword_t)sj) << fill;
+ fill += 8;
+ j++;
+ }
+- x->limb[LIMBPERM(i)] = (i<NLIMBS-1) ? buffer & LIMB_MASK(LIMBPERM(i)) : buffer;
++ x->limb[LIMBPERM(i)] = (word_t)((i<NLIMBS-1) ? buffer & LIMB_MASK(LIMBPERM(i)) : buffer);
+ fill -= LIMB_PLACE_VALUE(LIMBPERM(i));
+ buffer >>= LIMB_PLACE_VALUE(LIMBPERM(i));
+ scarry = (scarry + x->limb[LIMBPERM(i)] - MODULUS->limb[LIMBPERM(i)]) >> (8*sizeof(word_t));
+ }
+- return word_is_zero(buffer) & ~word_is_zero(scarry);
++ return word_is_zero((word_t)buffer) & ~word_is_zero((word_t)scarry);
+ }
+
+ /** Reduce to canonical form. */
+@@ -82,7 +82,7 @@ void gf_strong_reduce (gf a) {
+ */
+ assert(word_is_zero(scarry) | word_is_zero(scarry+1));
+
+- word_t scarry_0 = scarry;
++ word_t scarry_0 = (word_t)scarry;
+ dword_t carry = 0;
+
+ /* add it back */
+diff --git a/src/public_include/decaf/common.h b/src/public_include/decaf/common.h
+index 2493525..0abde45 100644
+--- a/src/public_include/decaf/common.h
++++ b/src/public_include/decaf/common.h
+@@ -93,8 +93,25 @@ typedef int64_t decaf_dsword_t; /**< Signed double-word size for internal co
+ #error "Only supporting DECAF_WORD_BITS = 32 or 64 for now"
+ #endif
+
+-/** DECAF_TRUE = -1 so that DECAF_TRUE & x = x */
+-static const decaf_bool_t DECAF_TRUE = -(decaf_bool_t)1;
++/* MSCV compiler doesn't like the trick to have -1 assigned to an unsigned int to
++ * set it to all ones, so do it openly */
++#if DECAF_WORD_BITS == 64
++/** DECAF_TRUE = all ones so that DECAF_TRUE & x = x */
++static const decaf_bool_t DECAF_TRUE = (decaf_bool_t)0xFFFFFFFFFFFFFFFF;
++/** DECAF_WORD_ALL_SET : all ones */
++static const decaf_word_t DECAF_WORD_ALL_SET = (decaf_word_t)0xFFFFFFFFFFFFFFFF;
++/** DECAF_WORD_ALL_UNSET : all zeros */
++static const decaf_word_t DECAF_WORD_ALL_UNSET = (decaf_word_t)0x0;
++#elif DECAF_WORD_BITS == 32 /**< The number of bits in a word */
++/** DECAF_TRUE = all ones so that DECAF_TRUE & x = x */
++static const decaf_bool_t DECAF_TRUE = (decaf_bool_t)0xFFFFFFFF;
++/** DECAF_WORD_ALL_SET : all ones */
++static const decaf_word_t DECAF_WORD_ALL_SET = (decaf_word_t)0xFFFFFFFF;
++/** DECAF_WORD_ALL_UNSET : all zeros */
++static const decaf_word_t DECAF_WORD_ALL_UNSET = (decaf_word_t)0x0;
++#else
++#error "Only supporting DECAF_WORD_BITS = 32 or 64 for now"
++#endif
+
+ /** DECAF_FALSE = 0 so that DECAF_FALSE & x = 0 */
+ static const decaf_bool_t DECAF_FALSE = 0;
+diff --git a/src/sha512.c b/src/sha512.c
+index 1cdd5ce..364bc3e 100644
+--- a/src/sha512.c
++++ b/src/sha512.c
+@@ -243,11 +243,11 @@ void decaf_sha512_final(decaf_sha512_ctx_t ctx, uint8_t *out, size_t length) {
+ }
+
+ for (size_t i=0; i<8; i++)
+- ctx->block[120 + i] = bp >> (56 - 8*i);
++ ctx->block[120 + i] = (uint8_t)(bp >> (56 - 8*i));
+ hashblock(ctx);
+
+ for (size_t i=0; i<length; i++) {
+- out[i] = ctx->state[i/8] >> (56 - 8*(i%8));
++ out[i] = (uint8_t)(ctx->state[i/8] >> (56 - 8*(i%8)));
+ }
+
+ decaf_sha512_init(ctx);
+diff --git a/src/shake.c b/src/shake.c
+index 7cd3a5b..5205c86 100644
+--- a/src/shake.c
++++ b/src/shake.c
+@@ -98,7 +98,7 @@ decaf_error_t decaf_sha3_update (
+ uint8_t* state = &decaf_sponge->state->b[decaf_sponge->params->position];
+ if (cando > len) {
+ for (i = 0; i < len; i += 1) state[i] ^= in[i];
+- decaf_sponge->params->position += len;
++ decaf_sponge->params->position += (uint8_t)len;
+ break;
+ } else {
+ for (i = 0; i < cando; i += 1) state[i] ^= in[i];
+@@ -121,7 +121,7 @@ decaf_error_t decaf_sha3_output (
+
+ if (decaf_sponge->params->max_out != 0xFF) {
+ if (decaf_sponge->params->remaining >= len) {
+- decaf_sponge->params->remaining -= len;
++ decaf_sponge->params->remaining -= (uint8_t)len;
+ } else {
+ decaf_sponge->params->remaining = 0;
+ ret = DECAF_FAILURE;
+@@ -148,7 +148,7 @@ decaf_error_t decaf_sha3_output (
+ uint8_t* state = &decaf_sponge->state->b[decaf_sponge->params->position];
+ if (cando > len) {
+ memcpy(out, state, len);
+- decaf_sponge->params->position += len;
++ decaf_sponge->params->position += (uint8_t)len;
+ return ret;
+ } else {
+ memcpy(out, state, cando);
+diff --git a/src/spongerng.c b/src/spongerng.c
+index fea7702..bba336e 100644
+--- a/src/spongerng.c
++++ b/src/spongerng.c
+@@ -25,6 +25,9 @@
+ #if defined(_MSC_VER)
+ # include <io.h>
+ #include <BaseTsd.h>
++#define open _open
++#define read _read
++#define close _close
+ typedef SSIZE_T ssize_t;
+ #else
+ # include <unistd.h>
+@@ -110,7 +113,7 @@ void decaf_spongerng_next (
+ uint8_t lenx[8];
+ size_t len1 = len;
+ for (unsigned i=0; i<sizeof(lenx); i++) {
+- lenx[i] = len1;
++ lenx[i] = (uint8_t)len1;
+ len1 >>= 8;
+ }
+ decaf_sha3_update(prng->sponge,lenx,sizeof(lenx));
+diff --git a/test/shakesum.c b/test/shakesum.c
+index 7d9019a..02d9397 100644
+--- a/test/shakesum.c
++++ b/test/shakesum.c
+@@ -20,7 +20,7 @@ typedef SSIZE_T ssize_t;
+ #include <decaf/shake.h>
+ #include <decaf/sha512.h>
+
+-static void usage() {
++static void usage(void) {
+ fprintf(
+ stderr,
+ "decaf_shakesum [shake256|shake128|sha3-224|sha3-384|sha3-512|sha512] < infile > outfile\n"
diff --git a/fix-warnings.patch b/fix-warnings.patch
deleted file mode 100644
index 27d2110a9eb7..000000000000
--- a/fix-warnings.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/src/public_include/decaf/common.h
-+++ b/src/public_include/decaf/common.h
-@@ -115,7 +115,8 @@
- /** Return DECAF_TRUE iff x == DECAF_SUCCESS */
- static DECAF_INLINE decaf_bool_t
- decaf_successful(decaf_error_t e) {
-- decaf_dword_t w = ((decaf_word_t)e) ^ ((decaf_word_t)DECAF_SUCCESS);
-+ decaf_word_t succ = DECAF_SUCCESS;
-+ decaf_dword_t w = ((decaf_word_t)e) ^ succ;
- return (w-1)>>DECAF_WORD_BITS;
- }