summaryrefslogtreecommitdiff
path: root/sntrup761.sh
blob: 7fa9e3249047235f41246ac384f515d633636056 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
#       $OpenBSD: sntrup761.sh,v 1.1 2020/12/29 00:59:15 djm Exp $
#       Placed in the Public Domain.
#
AUTHOR="supercop-20201130/crypto_kem/sntrup761/ref/implementors"
FILES="
	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
"
SORT_I32="
	supercop-20201130/crypto_sort/int32/portable4/int32_minmax.inc
	supercop-20201130/crypto_sort/int32/portable4/sort.c
"
SORT_U32="supercop-20201130/crypto_sort/uint32/useint32/sort.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 $SORT_I32; do
	echo "/* from $i */"
	grep \
	   -v '#include' $i | \
	   sed -e "s/void crypto_sort/static void crypto_sort_int32/g"
	echo
done
echo "/* from $SORT_U32 */"
grep \
   -v '#include' $SORT_U32 | \
   sed -e "s/void crypto_sort/static void crypto_sort_uint32/g"
echo
for i in $FILES; do
	echo "/* from $i */"
	grep \
	   -v '#include' $i | \
	   sed -e "s/crypto_kem_/crypto_kem_sntrup761_/g" \
		-e "s/^extern void /static void /" \
		-e "s/^void /static void /"
	echo
done