-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
311 lines (254 loc) · 15.1 KB
/
configure.ac
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
AC_PREREQ([2.68])
AC_INIT([Fe3C], [1.0])
# Keep the root directory clean and put automake's scripts in a subdirectory
AC_CONFIG_AUX_DIR([build-aux])
# Use C as the language of choice
AC_LANG([C])
# Use automake
# subdir-objects --> put objects into subdirectories named after the source files
# foreign --> not require all the GNU Coding Style files such as NEWS, README, AUTHORS, etc.
# -Wall -Werror --> turn all warnings into errors
AM_INIT_AUTOMAKE([subdir-objects foreign -Wall -Werror])
# Sanity-check correct srcdir
AC_CONFIG_SRCDIR([include/fe3c/eddsa.h])
# Do not build in verbose mode by default
AM_SILENT_RULES([yes])
# Check for the C compiler
AC_PROG_CC
# Check for the archiver
AM_PROG_AR
# Check for header files
AC_CHECK_HEADERS([stdint.h stddef.h])
# Check for typedefs and compiler characteristics
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_C_BIGENDIAN(
AC_DEFINE([FE3C_BIGENDIAN_TARGET]),
AC_DEFINE([FE3C_LILENDIAN_TARGET]),
AC_MSG_WARN([Cannot determine endianness])
)
# Set common flags
AM_CPPFLAGS="$AM_CPPFLAGS"
AM_CFLAGS="$AM_CFLAGS -Wall -Werror -Wextra"
AM_LDFLAGS="$AM_LDFLAGS"
# Use libtool
LT_INIT([])
# Export the .so version to the Makefiles
AC_SUBST([FE3C_VERSION_LIBSO], [1:0:0])
# Check if -fvisibility=hidden is supported to reduce .so size
VISIBILITY_CFLAGS="-fvisibility=hidden"
AC_CACHE_CHECK([whether -fvisibility=hidden is supported],
[fe3c_cv_visibility_hidden_supported],
[OLD_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM()],
[fe3c_cv_visibility_hidden_supported=yes],
[fe3c_cv_visibility_hidden_supported=no])
CFLAGS="$OLD_CFLAGS"])
# If failed to link with -fvisibility=hidden, reset VISIBILITY_CFLAGS
AS_IF([test "x$fe3c_cv_visibility_hidden_supported" != "xyes"],
[VISIBILITY_CFLAGS=""])
AM_CFLAGS="$AM_CFLAGS $VISIBILITY_CFLAGS"
# -------------------------------------------------------------------------------------------
# -------------------------------- Supported elliptic curves --------------------------------
# -------------------------------------------------------------------------------------------
ed25519="no"
AC_ARG_ENABLE([ed25519],
[AS_HELP_STRING([--enable-ed25519], [Enable support for the Ed25519 curve])],
[AS_IF([test "x$enableval" = "xyes"],
[ed25519="yes"],
[test "x$enableval" != "xno"],
[AC_MSG_ERROR([bad value ${enableval} for --enable-ed25519])])],
[])
AM_CONDITIONAL([FE3C_SUPPORT_CURVE_ED25519], [test "x$ed25519" = "xyes"])
AS_IF([test "x$ed25519" = "xyes"], AC_DEFINE([FE3C_SUPPORT_CURVE_ED25519]), [])
# -------------------------------------------------------------------------------------------
ed448="no"
AC_ARG_ENABLE([ed448],
[AS_HELP_STRING([--enable-ed448], [Enable support for the Ed448 curve])],
[AS_IF([test "x$enableval" = "xyes"],
[ed448="yes"],
[test "x$enableval" != "xno"],
[AC_MSG_ERROR([bad value ${enableval} for --enable-ed448])])],
[])
AM_CONDITIONAL([FE3C_SUPPORT_CURVE_ED448], [test "x$ed448" = "xyes"])
AS_IF([test "x$ed448" = "xyes"], AC_DEFINE([FE3C_SUPPORT_CURVE_ED448]), [])
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# ----------------------------- Optional features/optimizations -----------------------------
# -------------------------------------------------------------------------------------------
ed25519_small_precomputation="no"
AC_ARG_ENABLE([ed25519-small-precomputation],
[AS_HELP_STRING([--enable-ed25519-small-precomputation],
[Minimize the size of Ed25519 precomputation tables when using the comb method.
This may result in a smaller library size at the cost of decreased
performance.])],
[AS_IF([test "x$enableval" = "xyes"],
[ed25519_small_precomputation="yes"],
[test "x$enableval" != "xno"],
[AC_MSG_ERROR([bad value ${enableval} for --enable-ed25519-small-precomputation])])],
[])
AM_CONDITIONAL([FE3C_ED25519_SMALL_PRECOMPUTATION], [test "x$ed25519_small_precomputation" = "xyes"])
AS_IF([test "x$ed25519_small_precomputation" = "xyes"], AC_DEFINE([FE3C_ED25519_SMALL_PRECOMPUTATION]), [])
# -------------------------------------------------------------------------------------------
ed448_small_precomputation="no"
AC_ARG_ENABLE([ed448-small-precomputation],
[AS_HELP_STRING([--enable-ed448-small-precomputation],
[Minimize the size of Ed448 precomputation tables when using the comb method.
This may result in a smaller library size at the cost of decreased
performance.])],
[AS_IF([test "x$enableval" = "xyes"],
[ed448_small_precomputation="yes"],
[test "x$enableval" != "xno"],
[AC_MSG_ERROR([bad value ${enableval} for --enable-ed448-small-precomputation])])],
[])
AM_CONDITIONAL([FE3C_ED448_SMALL_PRECOMPUTATION], [test "x$ed448_small_precomputation" = "xyes"])
AS_IF([test "x$ed448_small_precomputation" = "xyes"], AC_DEFINE([FE3C_ED448_SMALL_PRECOMPUTATION]), [])
# -------------------------------------------------------------------------------------------
fast_squaring="yes"
AC_ARG_ENABLE([fast-squaring],
[AS_HELP_STRING([--disable-fast-squaring],
[Disable optimization of squaring in the field and reuse multiplication routine,
which should reduce code footprint but may decrease performance])],
[AS_IF([test "x$enableval" = "xno"],
[fast_squaring="no"],
[test "x$enableval" != "xyes"],
[AC_MSG_ERROR([bad value ${enableval} for --enable-fast-squaring])])],
[])
AM_CONDITIONAL([FE3C_FAST_SQUARING], [test "x$fast_squaring" = "xyes"])
AS_IF([test "x$fast_squaring" = "xyes"], AC_DEFINE([FE3C_FAST_SQUARING]), [])
# -------------------------------------------------------------------------------------------
ed25519_comb_method="yes"
AC_ARG_ENABLE([ed25519-comb-method],
[AS_HELP_STRING([--disable-ed25519-comb-method],
[Disable comb method of scalar multiplication for Ed25519, which may reduce data footprint,
but will definitely decrease performance])],
[AS_IF([test "x$enableval" = "xno"],
[ed25519_comb_method="no"],
[test "x$enableval" != "xyes"],
[AC_MSG_ERROR([bad value ${enableval} for --enable-ed25519-comb-method])])],
[])
AM_CONDITIONAL([FE3C_ED25519_COMB_METHOD], [test "x$ed25519_comb_method" = "xyes"])
AS_IF([test "x$ed25519_comb_method" = "xyes"], AC_DEFINE([FE3C_ED25519_COMB_METHOD]), [])
# -------------------------------------------------------------------------------------------
ed448_comb_method="yes"
AC_ARG_ENABLE([ed448-comb-method],
[AS_HELP_STRING([--disable-ed448-comb-method],
[Disable comb method of scalar multiplication for Ed448, which may reduce data footprint,
but will definitely decrease performance])],
[AS_IF([test "x$enableval" = "xno"],
[ed448_comb_method="no"],
[test "x$enableval" != "xyes"],
[AC_MSG_ERROR([bad value ${enableval} for --enable-ed448-comb-method])])],
[])
AM_CONDITIONAL([FE3C_ED448_COMB_METHOD], [test "x$ed448_comb_method" = "xyes"])
AS_IF([test "x$ed448_comb_method" = "xyes"], AC_DEFINE([FE3C_ED448_COMB_METHOD]), [])
# -------------------------------------------------------------------------------------------
ed25519_lattice_basis_reduction="no"
AC_ARG_ENABLE([ed25519-lattice-basis-reduction],
[AS_HELP_STRING([--enable-ed25519-lattice-basis-reduction],
[Enable lattice basis reduction (eprint:2020/454) during Ed25519 verification, which will increase
code footprint, but may increase verification performance.])],
[AS_IF([test "x$enableval" = "xyes"],
[ed25519_lattice_basis_reduction="yes"],
[test "x$enableval" != "xno"],
[AC_MSG_ERROR([bad value ${enableval} for --enable-ed25519-lattice-basis-reduction])])],
[])
AM_CONDITIONAL([FE3C_ED25519_LATTICE_BASIS_REDUCTION], [test "x$ed25519_lattice_basis_reduction" = "xyes"])
AS_IF([test "x$ed25519_lattice_basis_reduction" = "xyes"], AC_DEFINE([FE3C_ED25519_LATTICE_BASIS_REDUCTION]), [])
# -------------------------------------------------------------------------------------------
ed448_lattice_basis_reduction="no"
AC_ARG_ENABLE([ed448-lattice-basis-reduction],
[AS_HELP_STRING([--enable-ed448-lattice-basis-reduction],
[Enable lattice basis reduction (eprint:2020/454) during Ed448 verification, which will increase
code footprint, but may increase verification performance.])],
[AS_IF([test "x$enableval" = "xyes"],
[ed448_lattice_basis_reduction="yes"],
[test "x$enableval" != "xno"],
[AC_MSG_ERROR([bad value ${enableval} for --enable-ed448-lattice-basis-reduction])])],
[])
AM_CONDITIONAL([FE3C_ED448_LATTICE_BASIS_REDUCTION], [test "x$ed448_lattice_basis_reduction" = "xyes"])
AS_IF([test "x$ed448_lattice_basis_reduction" = "xyes"], AC_DEFINE([FE3C_ED448_LATTICE_BASIS_REDUCTION]), [])
# -------------------------------------------------------------------------------------------
skip_zeroization="no"
AC_ARG_ENABLE([zeroization],
[AS_HELP_STRING([--disable-zeroization],
[Disable zeroization of intermediate results on stack, which may marginally increase
performance and reduce code footprint, but decreases security in systems where stack
is shared with unsafe code, which may read data left behind by crypto operations])],
[AS_IF([test "x$enableval" = "xno"],
[skip_zeroization="yes"],
[test "x$enableval" != "xyes"],
[AC_MSG_ERROR([bad value ${enableval} for --enable-zeroization])])],
[])
AM_CONDITIONAL([FE3C_SKIP_ZEROIZATION], [test "x$skip_zeroization" = "xyes"])
AS_IF([test "x$skip_zeroization" = "xyes"], AC_DEFINE([FE3C_SKIP_ZEROIZATION]), [])
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# --------------------------------- Architecture intrinsics ---------------------------------
# -------------------------------------------------------------------------------------------
archbits="64"
AC_ARG_ENABLE([32bit],
[AS_HELP_STRING([--enable-32bit],
[Optimize elliptic curve arithmetic for 32-bit architecture(s)])],
[AS_IF([test "x$enableval" = "xyes"],
[archbits="32"],
[test "x$enableval" != "xno"],
[AC_MSG_ERROR([bad value ${enableval} for --enable-32bit])])],
[])
AC_SUBST([archbits])
AS_IF([test "x$archbits" = "x32"], AC_DEFINE([FE3C_32BIT]), AC_DEFINE([FE3C_64BIT]))
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------- Debug options --------------------------------------
# -------------------------------------------------------------------------------------------
sanity_checks="no"
AC_ARG_ENABLE([sanity-checks],
[AS_HELP_STRING([--enable-sanity-checks],
[Enable sanity-check assertions in the code])],
[AS_IF([test "x$enableval" = "xyes"],
[sanity_checks="yes"],
[test "x$enableval" != "xno"],
[AC_MSG_ERROR([bad value ${enableval} for --enable-sanity-checks])])]
[])
AS_IF([test "x$sanity_checks" = "xyes"], AC_DEFINE([FE3C_ENABLE_SANITY_CHECKS]), [])
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
AC_CONFIG_FILES([Makefile src/Makefile])
# Export the changed variables to the Makefiles
AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_LDFLAGS])
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
AC_OUTPUT
AC_MSG_RESULT([
$PACKAGE $VERSION
Curve Ed25519 supported: ${ed25519}
Curve Ed448 supported: ${ed448}
Architecture: ${archbits}-bit
Sanity checks enabled: ${sanity_checks}
Skip secret zeroization on stack: ${skip_zeroization}
Optimized field element squaring: ${fast_squaring}
Comb method for scalar multiplication:
Ed25519: ${ed25519_comb_method}
Ed448: ${ed448_comb_method}
Lattice basis reduction in double scalar multiplication:
Ed25519: ${ed25519_lattice_basis_reduction}
Ed448: ${ed448_lattice_basis_reduction}
Small precomputation tables:
Ed25519: ${ed25519_small_precomputation}
Ed448: ${ed448_small_precomputation}
])