blob: 3867f9e2a7a3da6b4ead1b9d1b56de5b6feb264f (
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
#!/bin/sh
# This script copies files from the nettle upstream, with necessary
# adjustments for bundling in GnuTLS.
set +e
: ${srcdir=.}
SRC=$srcdir/devel/nettle
DST=$srcdir/lib/nettle/backport
IMPORTS="
block-internal.h
cfb.c
cfb.h
cmac.c
cmac.h
cmac-aes128.c
cmac-aes256.c
chacha-core-internal.c
chacha-crypt.c
chacha-internal.h
chacha-poly1305.c
chacha-poly1305.h
chacha-set-key.c
chacha-set-nonce.c
chacha.h
poly1305-internal.c
poly1305-internal.h
poly1305.h
xts.c
xts.h
xts-aes128.c
xts-aes256.c
siv-cmac.c
siv-cmac.h
siv-cmac-aes128.c
siv-cmac-aes256.c
"
PUBLIC="
aes.h
bignum.h
ctr.h
des.h
ecc-curve.h
ecc.h
macros.h
memops.h
memxor.h
nettle-meta.h
nettle-types.h
"
test -d $DST || mkdir $DST
for f in $IMPORTS; do
src=$SRC/$f
dst=$DST/$f
if test -f $src; then
if test -f $dst; then
echo "Replacing $dst (existing file backed up in $dst~)"
mv $dst $dst~
else
echo "Copying file $dst"
fi
cp $src $dst
# Use <nettle/*.h> for public headers.
for h in $PUBLIC; do
p=$(echo $h | sed 's/\./\\./g')
if grep '^#include "'$p'"' $dst 2>&1 >/dev/null; then
sed 's!^#include "'$p'"!#include <nettle/'$h'>!' $dst > $dst-t && \
mv $dst-t $dst
fi
done
# Remove unused <assert.h>.
if grep '^#include <assert\.h>' $dst 2>&1 >/dev/null; then
if ! grep 'assert *(' $dst 2>&1 >/dev/null; then
sed '/^#include <assert\.h>/d' $dst > $dst-t && mv $dst-t $dst
fi
fi
case $dst in
*.h)
# Rename header guard so as not to conflict with the public ones.
if grep '^#ifndef NETTLE_.*_H\(_INCLUDED\)*' $dst 2>&1 >/dev/null; then
g=$(sed -n 's/^#ifndef NETTLE_\(.*_H\(_INCLUDED\)*\)/\1/p' $dst)
sed 's/\(NETTLE_'$g'\)/GNUTLS_LIB_NETTLE_BACKPORT_\1/' $dst > $dst-t && \
mv $dst-t $dst
fi
;;
esac
case $dst in
*.h)
# Add prefix to function symbols avoid clashing with the public ones.
sed -e 's/^#define \(.*\) nettle_\1/#define \1 gnutls_nettle_backport_\1/' \
-e 's/^#define _\(.*\) _nettle_\1/#define _\1 _gnutls_nettle_backport_\1/' \
-e 's/^#define \(.*\) _nettle_\1/#define \1 _gnutls_nettle_backport_\1/' \
$dst > $dst-t && \
mv $dst-t $dst
;;
esac
case $dst in
*/cfb.c | */cmac.c | */xts.c | */siv-cmac.c)
sed \
-e 's/"nettle-internal\.h"/"nettle-alloca.h"/' \
$dst > $dst-t && mv $dst-t $dst
;;
esac
case $dst in
*/*.[ch])
sed \
-e '/^#include <nettle\/nettle-types\.h>/a\
#include "block8.h"
' \
$dst > $dst-t && mv $dst-t $dst
;;
esac
case $dst in
*/siv-cmac*.[ch])
sed \
-e '/^#include "cmac\.h"/ { i\
#ifdef HAVE_NETTLE_CMAC128_UPDATE\
#include <nettle/cmac.h>\
#else\
#include "cmac.h"\
#endif
; d
}' \
$dst > $dst-t && mv $dst-t $dst
;;
esac
else
echo "Error: $src not found" 1>&2
exit 1
fi
done
|