2020-12-29 00:59:15 +00:00
|
|
|
#!/bin/sh
|
2021-01-04 21:58:58 +00:00
|
|
|
# $OpenBSD: sntrup761.sh,v 1.4 2021/01/04 21:58:58 dtucker Exp $
|
2020-12-29 00:59:15 +00:00
|
|
|
# Placed in the Public Domain.
|
|
|
|
#
|
|
|
|
AUTHOR="supercop-20201130/crypto_kem/sntrup761/ref/implementors"
|
|
|
|
FILES="
|
2021-01-04 21:58:58 +00:00
|
|
|
supercop-20201130/crypto_sort/int32/portable4/int32_minmax.inc
|
|
|
|
supercop-20201130/crypto_sort/int32/portable4/sort.c
|
|
|
|
supercop-20201130/crypto_sort/uint32/useint32/sort.c
|
2020-12-29 00:59:15 +00:00
|
|
|
supercop-20201130/crypto_kem/sntrup761/ref/uint64.h
|
|
|
|
supercop-20201130/crypto_kem/sntrup761/ref/uint16.h
|
|
|
|
supercop-20201130/crypto_kem/sntrup761/ref/uint32.h
|
|
|
|
supercop-20201130/crypto_kem/sntrup761/ref/int8.h
|
|
|
|
supercop-20201130/crypto_kem/sntrup761/ref/int16.h
|
|
|
|
supercop-20201130/crypto_kem/sntrup761/ref/int32.h
|
|
|
|
supercop-20201130/crypto_kem/sntrup761/ref/uint32.c
|
|
|
|
supercop-20201130/crypto_kem/sntrup761/ref/int32.c
|
|
|
|
supercop-20201130/crypto_kem/sntrup761/ref/paramsmenu.h
|
|
|
|
supercop-20201130/crypto_kem/sntrup761/ref/params.h
|
|
|
|
supercop-20201130/crypto_kem/sntrup761/ref/Decode.h
|
|
|
|
supercop-20201130/crypto_kem/sntrup761/ref/Decode.c
|
|
|
|
supercop-20201130/crypto_kem/sntrup761/ref/Encode.h
|
|
|
|
supercop-20201130/crypto_kem/sntrup761/ref/Encode.c
|
|
|
|
supercop-20201130/crypto_kem/sntrup761/ref/kem.c
|
|
|
|
"
|
|
|
|
###
|
|
|
|
|
|
|
|
set -e
|
|
|
|
cd $1
|
|
|
|
echo -n '/* $'
|
|
|
|
echo 'OpenBSD: $ */'
|
|
|
|
echo
|
|
|
|
echo '/*'
|
|
|
|
echo ' * Public Domain, Authors:'
|
|
|
|
sed -e '/Alphabetical order:/d' -e 's/^/ * - /' < $AUTHOR
|
|
|
|
echo ' */'
|
|
|
|
echo
|
|
|
|
echo '#include <string.h>'
|
|
|
|
echo '#include "crypto_api.h"'
|
|
|
|
echo
|
|
|
|
echo '#define CRYPTO_NAMESPACE(s) s'
|
|
|
|
echo
|
|
|
|
for i in $FILES; do
|
|
|
|
echo "/* from $i */"
|
|
|
|
grep \
|
|
|
|
-v '#include' $i | \
|
2021-01-04 21:58:58 +00:00
|
|
|
case "$i" in
|
|
|
|
# Use int64_t for intermediate values in int32_MINMAX to prevent signed
|
|
|
|
# 32-bit integer overflow when called by crypto_sort_uint32.
|
|
|
|
*/int32_minmax.inc)
|
|
|
|
sed -e "s/int32 ab = b ^ a/int64_t ab = (int64_t)b ^ (int64_t)a/" \
|
|
|
|
-e "s/int32 c = b - a/int64_t c = (int64_t)b - (int64_t)a/"
|
|
|
|
;;
|
|
|
|
*/int32/portable4/sort.c)
|
|
|
|
sed -e "s/void crypto_sort/static void crypto_sort_int32/g"
|
|
|
|
;;
|
|
|
|
*/uint32/useint32/sort.c)
|
|
|
|
sed -e "s/void crypto_sort/static void crypto_sort_uint32/g"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
sed -e "s/crypto_kem_/crypto_kem_sntrup761_/g" \
|
2020-12-29 00:59:15 +00:00
|
|
|
-e "s/^extern void /static void /" \
|
2021-01-03 18:05:21 +00:00
|
|
|
-e "s/^void /static void /" \
|
|
|
|
-e "/^typedef int32_t int32;$/d"
|
2021-01-04 21:58:58 +00:00
|
|
|
esac
|
2020-12-29 00:59:15 +00:00
|
|
|
echo
|
|
|
|
done
|