summaryrefslogtreecommitdiffstats
path: root/sntrup761.sh
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2024-09-16 07:37:05 +0200
committerDamien Miller <djm@mindrot.org>2024-09-16 07:37:51 +0200
commit0ca128c9ee894f1b0067abd473bfb33171df67f8 (patch)
tree8d4daa5e1360dc5cd5f5065158efcb933af866dd /sntrup761.sh
parentupstream: minor grammar/sort fixes for refuseconnection; ok djm (diff)
downloadopenssh-0ca128c9ee894f1b0067abd473bfb33171df67f8.tar.xz
openssh-0ca128c9ee894f1b0067abd473bfb33171df67f8.zip
upstream: use 64 bit math to avoid signed underflow. upstream code
relies on using -fwrapv to provide defined over/underflow behaviour, but we use -ftrapv to catch integer errors and abort the program. ok dtucker@ OpenBSD-Commit-ID: 8933369b33c17b5f02479503d0a92d87bc3a574b
Diffstat (limited to '')
-rw-r--r--sntrup761.sh7
1 files changed, 6 insertions, 1 deletions
diff --git a/sntrup761.sh b/sntrup761.sh
index 92c803bb1..4de8dc334 100644
--- a/sntrup761.sh
+++ b/sntrup761.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# $OpenBSD: sntrup761.sh,v 1.8 2024/09/15 02:20:51 djm Exp $
+# $OpenBSD: sntrup761.sh,v 1.9 2024/09/16 05:37:05 djm Exp $
# Placed in the Public Domain.
#
AUTHOR="supercop-20240808/crypto_kem/sntrup761/ref/implementors"
@@ -63,8 +63,13 @@ for i in $FILES; do
-e "s/static void crypto_int16_minmax/void crypto_int16_minmax/"
;;
*/cryptoint/crypto_int32.h)
+ # Use int64_t for intermediate values in crypto_int32_minmax to
+ # prevent signed 32-bit integer overflow when called by
+ # crypto_sort_int32. Original code depends on -fwrapv (we set -ftrapv)
sed -e "s/static void crypto_int32_store/void crypto_int32_store/" \
-e "s/^[#]define crypto_int32_optblocker.*//" \
+ -e "s/crypto_int32 crypto_int32_r = crypto_int32_y ^ crypto_int32_x;/crypto_int64 crypto_int32_r = (crypto_int64)crypto_int32_y ^ (crypto_int64)crypto_int32_x;/" \
+ -e "s/crypto_int32 crypto_int32_z = crypto_int32_y - crypto_int32_x;/crypto_int64 crypto_int32_z = (crypto_int64)crypto_int32_y - (crypto_int64)crypto_int32_x;/" \
-e "s/static void crypto_int32_minmax/void crypto_int32_minmax/"
;;
*/cryptoint/crypto_int64.h)