Browse Source

Added nettle library

Nikos Mavrogiannopoulos 10 years ago
parent
commit
298e3117b7

+ 9
- 0
libs/nettle/Config.in View File

@@ -0,0 +1,9 @@
1
+# nettle avanced configuration
2
+
3
+menu "Configuration"
4
+	depends on PACKAGE_libnettle
5
+
6
+config LIBNETTLE_MINI
7
+	bool "use mini-gmp instead of gmp; the library will be much smaller at a 10x performance penalty. Note that this option may have side effects to programs that link to both nettle and gmp."
8
+
9
+endmenu

+ 85
- 0
libs/nettle/Makefile View File

@@ -0,0 +1,85 @@
1
+#
2
+# Copyright (C) 2014 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=nettle
11
+PKG_VERSION:=2.7.1
12
+PKG_RELEASE:=1
13
+
14
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15
+PKG_SOURCE_URL:=@GNU/nettle
16
+PKG_MD5SUM:=003d5147911317931dd453520eb234a5
17
+PKG_MAINTAINER:=Nikos Mavrogiannopoulos <nmav@gnutls.org>
18
+
19
+PKG_LICENSE:=LGPLv2
20
+PKG_LICENSE_FILES:=COPYING
21
+
22
+PKG_FIXUP:=autoreconf
23
+PKG_BUILD_PARALLEL:=0
24
+
25
+include $(INCLUDE_DIR)/package.mk
26
+
27
+define Package/libnettle
28
+  SECTION:=libs
29
+  CATEGORY:=Libraries
30
+  TITLE:=GNU crypto library
31
+  URL:=http://www.lysator.liu.se/~nisse/nettle/
32
+  DEPENDS+= +!LIBNETTLE_MINI:libgmp
33
+endef
34
+
35
+define Package/libnettle/config
36
+	source "$(SOURCE)/Config.in"
37
+endef
38
+
39
+TARGET_CFLAGS += $(FPIC)
40
+
41
+CONFIGURE_ARGS += \
42
+	--enable-shared \
43
+	--disable-openssl \
44
+	--disable-documentation \
45
+	--enable-static
46
+
47
+ifeq ($(CONFIG_LIBNETTLE_MINI),y)
48
+CONFIGURE_ARGS += --enable-mini-gmp
49
+endif
50
+
51
+ifeq ($(CONFIG_CPU_SUBTYPE),neon)
52
+CONFIGURE_ARGS += \
53
+	--enable-arm-neon
54
+endif
55
+
56
+define Build/Compile
57
+	$(call Build/Compile/Default, \
58
+		DESTDIR="$(PKG_INSTALL_DIR)" \
59
+		CC="$(TARGET_CC)" \
60
+		libnettle.so libhogweed.so
61
+	+$(MAKE) -i $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
62
+		DESTDIR="$(PKG_INSTALL_DIR)" \
63
+		install)
64
+endef
65
+
66
+define Build/InstallDev
67
+	$(INSTALL_DIR) $(1)/usr/include/nettle
68
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/nettle/*.h $(1)/usr/include/nettle/
69
+	$(INSTALL_DIR) $(1)/usr/lib
70
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnettle.{a,so*} $(1)/usr/lib/
71
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libhogweed.{a,so*} $(1)/usr/lib/
72
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
73
+	$(CP) \
74
+		$(PKG_INSTALL_DIR)/usr/lib/pkgconfig/nettle.pc \
75
+		$(PKG_INSTALL_DIR)/usr/lib/pkgconfig/hogweed.pc \
76
+		$(1)/usr/lib/pkgconfig/
77
+endef
78
+
79
+define Package/libnettle/install
80
+	$(INSTALL_DIR) $(1)/usr/lib
81
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnettle.so.* $(1)/usr/lib/
82
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libhogweed.so.* $(1)/usr/lib/
83
+endef
84
+
85
+$(eval $(call BuildPackage,libnettle))

+ 1738
- 0
libs/nettle/patches/0001-Updated-mini-gmp.patch
File diff suppressed because it is too large
View File


+ 463
- 0
libs/nettle/patches/0002-Added-option-to-use-mini-gmp-in-hogweed.patch View File

@@ -0,0 +1,463 @@
1
+From 8d5360e3e5eea3c9dbfd44f9b981f18a41605e45 Mon Sep 17 00:00:00 2001
2
+From: Nikos Mavrogiannopoulos <nmav@gnutls.org>
3
+Date: Sun, 9 Mar 2014 11:30:25 +0100
4
+Subject: [PATCH 2/5] Added option to use mini-gmp in hogweed.
5
+
6
+---
7
+ Makefile.in              |  8 +++--
8
+ bignum.h                 |  6 +++-
9
+ configure.ac             | 76 +++++++++++++++++++++++++++++++++++-------------
10
+ dsa.h                    |  2 +-
11
+ ecc-internal.h           |  2 +-
12
+ ecc.h                    |  2 +-
13
+ eccdata.c                | 12 +++++++-
14
+ examples/Makefile.in     |  2 +-
15
+ examples/ecc-benchmark.c |  2 ++
16
+ gmp-glue.c               |  1 +
17
+ gmp-glue.h               |  2 +-
18
+ hogweed.pc.in            |  2 +-
19
+ mini-gmp.c               |  2 +-
20
+ mini-gmp.h               |  9 ++++++
21
+ pkcs1.h                  |  2 +-
22
+ rsa.h                    |  2 +-
23
+ testsuite/Makefile.in    |  4 +--
24
+ testsuite/testutils.h    |  5 ++--
25
+ 18 files changed, 102 insertions(+), 39 deletions(-)
26
+
27
+diff --git a/Makefile.in b/Makefile.in
28
+index 3b0e1cb..42be3a9 100644
29
+--- a/Makefile.in
30
++++ b/Makefile.in
31
+@@ -16,6 +16,10 @@ MKDIR_P = @MKDIR_P@
32
+ 
33
+ OPT_ASM_SOURCES = @OPT_ASM_SOURCES@
34
+ 
35
++OPT_HOGWEED_SOURCES = @OPT_HOGWEED_SOURCES@
36
++
37
++OPT_HOGWEED_HEADERS = @OPT_HOGWEED_HEADERS@
38
++
39
+ SUBDIRS = tools testsuite examples
40
+ 
41
+ include config.make
42
+@@ -106,7 +110,7 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \
43
+ 		 nettle-meta-armors.c \
44
+ 		 write-be32.c write-le32.c write-le64.c
45
+ 
46
+-hogweed_SOURCES = sexp.c sexp-format.c \
47
++hogweed_SOURCES = $(OPT_HOGWEED_SOURCES) sexp.c sexp-format.c \
48
+ 		  sexp-transport.c sexp-transport-format.c \
49
+ 		  bignum.c bignum-next-prime.c \
50
+ 		  bignum-random.c bignum-random-prime.c \
51
+@@ -156,7 +160,7 @@ HEADERS = aes.h arcfour.h arctwo.h asn1.h bignum.h blowfish.h \
52
+ 	  pgp.h pkcs1.h realloc.h ripemd160.h rsa.h rsa-compat.h \
53
+ 	  salsa20.h sexp.h \
54
+ 	  serpent.h sha.h sha1.h sha2.h sha3.h twofish.h \
55
+-	  umac.h yarrow.h
56
++	  umac.h yarrow.h $(OPT_HOGWEED_HEADERS)
57
+ 
58
+ INSTALL_HEADERS = $(HEADERS) nettle-stdint.h
59
+ 
60
+diff --git a/bignum.h b/bignum.h
61
+index 746b21f..1f2ff07 100644
62
+--- a/bignum.h
63
++++ b/bignum.h
64
+@@ -28,7 +28,11 @@
65
+ 
66
+ #include "nettle-meta.h"
67
+ 
68
+-#include <gmp.h>
69
++#ifdef USE_MINI_GMP
70
++# include "mini-gmp.h"
71
++#else
72
++# include <gmp.h>
73
++#endif
74
+ #include "nettle-types.h"
75
+ 
76
+ #ifdef __cplusplus
77
+diff --git a/configure.ac b/configure.ac
78
+index 78a3d4e..93eb09a 100644
79
+--- a/configure.ac
80
++++ b/configure.ac
81
+@@ -72,6 +72,16 @@ AC_ARG_ENABLE(arm-neon,
82
+   AC_HELP_STRING([--enable-arm-neon], [Enable ARM Neon assembly. (default=auto)]),,
83
+   [enable_arm_neon=auto])
84
+ 
85
++AC_ARG_ENABLE(mini-gmp,
86
++  AC_HELP_STRING([--enable-mini-gmp], [Disable gmp support and enable mini-gmp. (default=disabled)]),,
87
++  [enable_mini_gmp=no])
88
++
89
++if test "x$enable_mini_gmp" = xyes ; then
90
++GMP_LIBS=""
91
++else
92
++GMP_LIBS="-lgmp"
93
++fi
94
++
95
+ LSH_RPATH_INIT([`echo $with_lib_path | sed 's/:/ /g'` \
96
+     `echo $exec_prefix | sed "s@^NONE@$prefix/lib@g" | sed "s@^NONE@$ac_default_prefix/lib@g"` \
97
+     /usr/local/lib /sw/local/lib /sw/lib \
98
+@@ -409,7 +419,7 @@ case "$host_os" in
99
+     LIBHOGWEED_SONAME='libhogweed.$(LIBHOGWEED_MAJOR).dylib'
100
+     LIBHOGWEED_FILE='libhogweed.$(LIBHOGWEED_MAJOR).$(LIBHOGWEED_MINOR).dylib'
101
+     LIBHOGWEED_LINK='$(CC) $(CFLAGS) -dynamiclib -L. $(LDFLAGS) -install_name ${libdir}/$(LIBHOGWEED_SONAME) -compatibility_version $(LIBHOGWEED_MAJOR) -current_version $(LIBHOGWEED_MAJOR).$(LIBHOGWEED_MINOR)'
102
+-    LIBHOGWEED_LIBS='-lnettle -lgmp'
103
++    LIBHOGWEED_LIBS='-lnettle $(GMP_LIBS)'
104
+     ;;
105
+   solaris*)
106
+     # Sun's ld uses -h to set the soname, and this option is passed
107
+@@ -425,7 +435,7 @@ case "$host_os" in
108
+     LIBHOGWEED_SONAME='$(LIBHOGWEED_FORLINK).$(LIBHOGWEED_MAJOR)'
109
+     LIBHOGWEED_FILE='$(LIBHOGWEED_SONAME).$(LIBHOGWEED_MINOR)'
110
+     LIBHOGWEED_LINK='$(CC) $(CFLAGS) $(LDFLAGS) -L. -G -h $(LIBHOGWEED_SONAME)'
111
+-    LIBHOGWEED_LIBS='-lnettle -lgmp'
112
++    LIBHOGWEED_LIBS='-lnettle $(GMP_LIBS)'
113
+     ;;
114
+   *)
115
+     LIBNETTLE_FORLINK=libnettle.so
116
+@@ -443,7 +453,7 @@ case "$host_os" in
117
+     # -lhogweed -lgmp -lnettle are still required). Also makes dlopen
118
+     # of libhogweed.so work, without having to use RTLD_GLOBAL.
119
+     # Depends on -L. above, to locate nettle.so.
120
+-    LIBHOGWEED_LIBS='-lnettle -lgmp'
121
++    LIBHOGWEED_LIBS='-lnettle $(GMP_LIBS)'
122
+     ;;
123
+ esac
124
+ 
125
+@@ -644,32 +654,55 @@ if test "x$nettle_cv_fcntl_locking" = "xyes" ; then
126
+   AC_DEFINE(HAVE_FCNTL_LOCKING)
127
+ fi
128
+ 
129
+-# Checks for libraries
130
+-AC_CHECK_LIB(gmp, __gmpz_getlimbn,,
131
+-    [AC_MSG_WARN(
132
++TESTSUITE_LIBS=""
133
++
134
++OPT_HOGWEED_SOURCES=""
135
++OPT_HOGWEED_HEADERS=""
136
++if test "x$enable_mini_gmp" = xyes ; then
137
++  OPT_HOGWEED_SOURCES="$OPT_HOGWEED_SOURCES mini-gmp.c"
138
++  OPT_HOGWEED_HEADERS="$OPT_HOGWEED_HEADERS mini-gmp.h"
139
++  AC_DEFINE([USE_MINI_GMP], 1, [Use mini-gmp instead of gmp])
140
++  IF_NOT_MINI_GMP='#'
141
++  GMP_NUMB_BITS="0"
142
++else
143
++
144
++  # Checks for libraries
145
++  AC_CHECK_LIB(gmp, __gmpz_getlimbn,,
146
++      [AC_MSG_WARN(
147
+ [GNU MP not found, or not 3.1 or up, see http://gmplib.org/.
148
+ Support for public key algorithms will be unavailable.])]
149
+-    enable_public_key=no)
150
++      enable_public_key=no)
151
+ 
152
+-# Add -R flags needed to run programs linked with gmp
153
+-LSH_RPATH_FIX
154
++  # Add -R flags needed to run programs linked with gmp
155
++  LSH_RPATH_FIX
156
+ 
157
+-# Check for gmp limb size
158
+-nettle_cv_gmp_numb_bits=0
159
+-if test "$enable_public_key" = yes; then
160
+-  AC_MSG_CHECKING([for GMP limb size])
161
+-  AC_COMPUTE_INT(nettle_cv_gmp_numb_bits, [GMP_NUMB_BITS],
162
+-      [#include <gmp.h>],
163
+-      [AC_MSG_FAILURE([cannot find value of GMP_NUMB_BITS])])
164
++  # Check for gmp limb size
165
++  nettle_cv_gmp_numb_bits=0
166
++  if test "$enable_public_key" = yes; then
167
++    AC_MSG_CHECKING([for GMP limb size])
168
++    AC_COMPUTE_INT(nettle_cv_gmp_numb_bits, [GMP_NUMB_BITS],
169
++        [#include <gmp.h>],
170
++        [AC_MSG_FAILURE([cannot find value of GMP_NUMB_BITS])])
171
+ 
172
+-  AC_MSG_RESULT([$nettle_cv_gmp_numb_bits bits])
173
++    AC_MSG_RESULT([$nettle_cv_gmp_numb_bits bits])
174
++  fi
175
++
176
++  GMP_NUMB_BITS="$nettle_cv_gmp_numb_bits"
177
++
178
++  AH_TEMPLATE([HAVE_MPZ_POWM_SEC], [Define if mpz_powm_sec is available (appeared in GMP-5)])
179
++  AC_CHECK_FUNC(__gmpz_powm_sec, [AC_DEFINE(HAVE_MPZ_POWM_SEC)])
180
++
181
++  IF_NOT_MINI_GMP=''
182
++  TESTSUITE_LIBS="-lgmp"
183
+ fi
184
+ 
185
+-GMP_NUMB_BITS="$nettle_cv_gmp_numb_bits"
186
+-AC_SUBST([GMP_NUMB_BITS])
187
++AC_SUBST([GMP_LIBS])
188
+ 
189
+-AH_TEMPLATE([HAVE_MPZ_POWM_SEC], [Define if mpz_powm_sec is available (appeared in GMP-5)])
190
+-AC_CHECK_FUNC(__gmpz_powm_sec, [AC_DEFINE(HAVE_MPZ_POWM_SEC)])
191
++dnl The testsuite requires gmp
192
++AC_SUBST([TESTSUITE_LIBS])
193
++AC_SUBST([GMP_NUMB_BITS])
194
++AC_SUBST([OPT_HOGWEED_SOURCES])
195
++AC_SUBST([OPT_HOGWEED_HEADERS])
196
+ 
197
+ AH_TEMPLATE([WITH_HOGWEED], [Defined if public key features are enabled])
198
+ 
199
+@@ -714,6 +747,7 @@ else
200
+   IF_DOCUMENTATION='#'
201
+ fi
202
+ 
203
++AC_SUBST(IF_NOT_MINI_GMP)
204
+ AC_SUBST(IF_HOGWEED)
205
+ AC_SUBST(IF_STATIC)
206
+ AC_SUBST(IF_SHARED)
207
+diff --git a/dsa.h b/dsa.h
208
+index 7ee2624..478e4fc 100644
209
+--- a/dsa.h
210
++++ b/dsa.h
211
+@@ -26,7 +26,7 @@
212
+ #ifndef NETTLE_DSA_H_INCLUDED
213
+ #define NETTLE_DSA_H_INCLUDED
214
+ 
215
+-#include <gmp.h>
216
++#include "bignum.h"
217
+ 
218
+ #include "nettle-types.h"
219
+ 
220
+diff --git a/ecc-internal.h b/ecc-internal.h
221
+index e8974fe..5cdd0e1 100644
222
+--- a/ecc-internal.h
223
++++ b/ecc-internal.h
224
+@@ -25,7 +25,7 @@
225
+ #ifndef NETTLE_ECC_INTERNAL_H_INCLUDED
226
+ #define NETTLE_ECC_INTERNAL_H_INCLUDED
227
+ 
228
+-#include <gmp.h>
229
++#include "bignum.h"
230
+ 
231
+ #include "nettle-types.h"
232
+ #include "ecc-curve.h"
233
+diff --git a/ecc.h b/ecc.h
234
+index 609d246..924f8ec 100644
235
+--- a/ecc.h
236
++++ b/ecc.h
237
+@@ -25,7 +25,7 @@
238
+ #ifndef NETTLE_ECC_H_INCLUDED
239
+ #define NETTLE_ECC_H_INCLUDED
240
+ 
241
+-#include <gmp.h>
242
++#include "bignum.h"
243
+ 
244
+ #include "nettle-types.h"
245
+ 
246
+diff --git a/eccdata.c b/eccdata.c
247
+index 466753c..24f64e3 100644
248
+--- a/eccdata.c
249
++++ b/eccdata.c
250
+@@ -24,11 +24,14 @@
251
+ 
252
+ /* Development of Nettle's ECC support was funded by the .SE Internet Fund. */
253
+ 
254
++#include "config.h"
255
++
256
+ #include <assert.h>
257
+ #include <stdio.h>
258
+ #include <stdlib.h>
259
+ #include <string.h>
260
+ 
261
++#include "mini-gmp.h"
262
+ #include "mini-gmp.c"
263
+ 
264
+ /* Affine coordinates, for simplicity. Infinity point represented as x
265
+@@ -895,6 +898,7 @@ int
266
+ main (int argc, char **argv)
267
+ {
268
+   struct ecc_curve ecc;
269
++  unsigned bits;
270
+ 
271
+   if (argc < 4)
272
+     {
273
+@@ -902,6 +906,7 @@ main (int argc, char **argv)
274
+       return EXIT_FAILURE;
275
+     }
276
+ 
277
++  bits = atoi(argv[4]);
278
+   ecc_curve_init (&ecc, atoi(argv[1]));
279
+ 
280
+   ecc_pippenger_precompute (&ecc, atoi(argv[2]), atoi(argv[3]));
281
+@@ -912,7 +917,12 @@ main (int argc, char **argv)
282
+   ecc_curve_check (&ecc);
283
+ 
284
+   if (argc > 4)
285
+-    output_curve (&ecc, atoi(argv[4]));
286
++    {
287
++      /* when using mini-gmp we cannot estimate it on configure */
288
++      if (bits == 0)
289
++        bits = GMP_NUMB_BITS;
290
++      output_curve (&ecc, bits);
291
++    }
292
+ 
293
+   return EXIT_SUCCESS;
294
+ }
295
+diff --git a/examples/Makefile.in b/examples/Makefile.in
296
+index 563d0dc..2bb0436 100644
297
+--- a/examples/Makefile.in
298
++++ b/examples/Makefile.in
299
+@@ -11,7 +11,7 @@ PRE_CPPFLAGS = -I.. -I$(top_srcdir)
300
+ PRE_LDFLAGS = -L..
301
+ 
302
+ OPENSSL_LIBFLAGS = @OPENSSL_LIBFLAGS@
303
+-BENCH_LIBS = @BENCH_LIBS@ -lm
304
++BENCH_LIBS = @BENCH_LIBS@ $(TESTSUITE_LIBS) -lm
305
+ 
306
+ HOGWEED_TARGETS = rsa-keygen$(EXEEXT) rsa-sign$(EXEEXT) \
307
+ 	      rsa-verify$(EXEEXT) rsa-encrypt$(EXEEXT) rsa-decrypt$(EXEEXT) \
308
+diff --git a/examples/ecc-benchmark.c b/examples/ecc-benchmark.c
309
+index 1faf6dc..16a1fd6 100644
310
+--- a/examples/ecc-benchmark.c
311
++++ b/examples/ecc-benchmark.c
312
+@@ -37,6 +37,8 @@
313
+ 
314
+ #include "timing.h"
315
+ 
316
++#undef USE_MINI_GMP
317
++#include <gmp.h>
318
+ #include "../ecc.h"
319
+ #include "../ecc-internal.h"
320
+ #include "../gmp-glue.h"
321
+diff --git a/gmp-glue.c b/gmp-glue.c
322
+index a2633a5..d76fdea 100644
323
+--- a/gmp-glue.c
324
++++ b/gmp-glue.c
325
+@@ -239,3 +239,4 @@ gmp_free_limbs (mp_limb_t *p, mp_size_t n)
326
+ 
327
+   free_func (p, (size_t) n * sizeof(mp_limb_t));
328
+ }
329
++
330
+diff --git a/gmp-glue.h b/gmp-glue.h
331
+index 269667f..f51b5b5 100644
332
+--- a/gmp-glue.h
333
++++ b/gmp-glue.h
334
+@@ -23,7 +23,7 @@
335
+ #ifndef NETTLE_GMP_GLUE_H_INCLUDED
336
+ #define NETTLE_GMP_GLUE_H_INCLUDED
337
+ 
338
+-#include <gmp.h>
339
++#include "bignum.h"
340
+ 
341
+ #include "nettle-stdint.h"
342
+ 
343
+diff --git a/hogweed.pc.in b/hogweed.pc.in
344
+index 457f5f2..9a9dea0 100644
345
+--- a/hogweed.pc.in
346
++++ b/hogweed.pc.in
347
+@@ -13,6 +13,6 @@ URL: http://www.lysator.liu.se/~nisse/nettle
348
+ Version: @PACKAGE_VERSION@
349
+ Requires.private: nettle
350
+ Libs: -L${libdir} -lhogweed
351
+-Libs.private: -lgmp
352
++Libs.private: @GMP_LIBS@
353
+ Cflags: -I${includedir}
354
+ 
355
+diff --git a/mini-gmp.c b/mini-gmp.c
356
+index 766df30..cf76a2a 100644
357
+--- a/mini-gmp.c
358
++++ b/mini-gmp.c
359
+@@ -1388,7 +1388,7 @@ mpz_clear (mpz_t r)
360
+   gmp_free (r->_mp_d);
361
+ }
362
+ 
363
+-static void *
364
++void *
365
+ mpz_realloc (mpz_t r, mp_size_t size)
366
+ {
367
+   size = GMP_MAX (size, 1);
368
+diff --git a/mini-gmp.h b/mini-gmp.h
369
+index d8f691f..dac7d1e 100644
370
+--- a/mini-gmp.h
371
++++ b/mini-gmp.h
372
+@@ -70,6 +70,11 @@ typedef struct
373
+   mp_limb_t *_mp_d;		/* Pointer to the limbs.  */
374
+ } __mpz_struct;
375
+ 
376
++typedef __mpz_struct MP_INT;
377
++
378
++#define GMP_NUMB_BITS (SIZEOF_LONG*8)
379
++#define GMP_NUMB_MASK (~0)
380
++
381
+ typedef __mpz_struct mpz_t[1];
382
+ 
383
+ typedef __mpz_struct *mpz_ptr;
384
+@@ -119,6 +124,10 @@ void mpz_init (mpz_t);
385
+ void mpz_init2 (mpz_t, mp_bitcnt_t);
386
+ void mpz_clear (mpz_t);
387
+ 
388
++void *
389
++mpz_realloc (mpz_t r, mp_size_t size);
390
++#define _mpz_realloc mpz_realloc
391
++
392
+ #define mpz_odd_p(z)   (((z)->_mp_size != 0) & (int) (z)->_mp_d[0])
393
+ #define mpz_even_p(z)  (! mpz_odd_p (z))
394
+ 
395
+diff --git a/pkcs1.h b/pkcs1.h
396
+index fa27225..f402688 100644
397
+--- a/pkcs1.h
398
++++ b/pkcs1.h
399
+@@ -26,7 +26,7 @@
400
+ #ifndef NETTLE_PKCS1_H_INCLUDED
401
+ #define NETTLE_PKCS1_H_INCLUDED
402
+ 
403
+-#include <gmp.h>
404
++#include "bignum.h"
405
+ #include "nettle-types.h"
406
+ 
407
+ #ifdef __cplusplus
408
+diff --git a/rsa.h b/rsa.h
409
+index 4226f38..c293cd1 100644
410
+--- a/rsa.h
411
++++ b/rsa.h
412
+@@ -26,7 +26,7 @@
413
+ #ifndef NETTLE_RSA_H_INCLUDED
414
+ #define NETTLE_RSA_H_INCLUDED
415
+ 
416
+-#include <gmp.h>
417
++#include "bignum.h"
418
+ #include "nettle-types.h"
419
+ 
420
+ #include "md5.h"
421
+diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in
422
+index 91f6e2a..c8ab5f6 100644
423
+--- a/testsuite/Makefile.in
424
++++ b/testsuite/Makefile.in
425
+@@ -47,7 +47,7 @@ TS_HOGWEED = $(TS_HOGWEED_SOURCES:.c=$(EXEEXT))
426
+ TS_C = $(TS_NETTLE) @IF_HOGWEED@ $(TS_HOGWEED)
427
+ TS_CXX = @IF_CXX@ $(CXX_SOURCES:.cxx=$(EXEEXT))
428
+ TARGETS = $(TS_C) $(TS_CXX)
429
+-TS_SH = sexp-conv-test pkcs1-conv-test symbols-test
430
++TS_SH = sexp-conv-test pkcs1-conv-test @IF_NOT_MINI_GMP@ symbols-test
431
+ TS_ALL = $(TARGETS) $(TS_SH)
432
+ EXTRA_SOURCES = sha1-huge-test.c
433
+ EXTRA_TARGETS = $(EXTRA_SOURCES:.c=$(EXEEXT))
434
+@@ -75,7 +75,7 @@ all: $(TARGETS) $(EXTRA_TARGETS)
435
+ 
436
+ LIB_HOGWEED = @IF_HOGWEED@ -lhogweed
437
+ TEST_OBJS = testutils.$(OBJEXT) ../nettle-internal.$(OBJEXT) \
438
+-	    $(LIB_HOGWEED) -lnettle $(LIBS)
439
++	    $(LIB_HOGWEED) -lnettle $(LIBS) $(TESTSUITE_LIBS)
440
+ 
441
+ ../nettle-internal.$(OBJEXT):
442
+ 	( cd .. && $(MAKE) nettle-internal.$(OBJEXT) )
443
+diff --git a/testsuite/testutils.h b/testsuite/testutils.h
444
+index 123bae2..a677a2a 100644
445
+--- a/testsuite/testutils.h
446
++++ b/testsuite/testutils.h
447
+@@ -12,11 +12,10 @@
448
+ #include <stdio.h>
449
+ #include <string.h>
450
+ 
451
+-#if HAVE_LIBGMP
452
+-# include "bignum.h"
453
+-#endif
454
+ 
455
+ #if WITH_HOGWEED
456
++# include <gmp.h>
457
++# undef USE_MINI_GMP
458
+ # include "rsa.h"
459
+ # include "dsa.h"
460
+ # include "ecc-curve.h"
461
+-- 
462
+1.9.2
463
+

+ 1241
- 0
libs/nettle/patches/0003-Include-local-macros-in-nettle.m4-to-allow-regenerat.patch
File diff suppressed because it is too large
View File


+ 100
- 0
libs/nettle/patches/0004-Added-auto-generated-nettle-config.h.patch View File

@@ -0,0 +1,100 @@
1
+From 7508bb15de94b38402152757f75ff3e2094fdd86 Mon Sep 17 00:00:00 2001
2
+From: Nikos Mavrogiannopoulos <nmav@gnutls.org>
3
+Date: Sun, 9 Mar 2014 13:27:03 +0100
4
+Subject: [PATCH 4/5] Added-auto-generated-nettle-config.h
5
+
6
+---
7
+ Makefile.in              | 4 ++--
8
+ bignum.h                 | 1 +
9
+ configure.ac             | 1 +
10
+ examples/ecc-benchmark.c | 1 +
11
+ nettle-config.h.in       | 6 ++++++
12
+ testsuite/testutils.h    | 1 +
13
+ 7 files changed, 13 insertions(+), 2 deletions(-)
14
+ create mode 100644 nettle-config.h.in
15
+
16
+diff --git a/Makefile.in b/Makefile.in
17
+index 42be3a9..280dd30 100644
18
+--- a/Makefile.in
19
++++ b/Makefile.in
20
+@@ -151,7 +151,7 @@ HEADERS = aes.h arcfour.h arctwo.h asn1.h bignum.h blowfish.h \
21
+ 	  des.h des-compat.h dsa.h ecc-curve.h ecc.h ecdsa.h \
22
+ 	  gcm.h gosthash94.h hmac.h \
23
+ 	  knuth-lfib.h \
24
+-	  macros.h \
25
++	  macros.h nettle-config.h \
26
+ 	  md2.h md4.h \
27
+ 	  md5.h md5-compat.h \
28
+ 	  memxor.h \
29
+@@ -174,7 +174,7 @@ DISTFILES = $(SOURCES) $(HEADERS) getopt.h .bootstrap run-tests \
30
+ 	config.guess config.sub install-sh texinfo.tex \
31
+ 	config.h.in config.m4.in config.make.in	Makefile.in \
32
+ 	README AUTHORS COPYING.LIB INSTALL NEWS TODO ChangeLog \
33
+-	nettle.pc.in hogweed.pc.in \
34
++	nettle.pc.in hogweed.pc.in nettle-config.h.in \
35
+ 	memxor.c $(des_headers) descore.README \
36
+ 	aes-internal.h camellia-internal.h serpent-internal.h \
37
+ 	cast128_sboxes.h desinfo.h desCode.h \
38
+diff --git a/bignum.h b/bignum.h
39
+index 1f2ff07..c31ccaa 100644
40
+--- a/bignum.h
41
++++ b/bignum.h
42
+@@ -26,6 +26,7 @@
43
+ #ifndef NETTLE_BIGNUM_H_INCLUDED
44
+ #define NETTLE_BIGNUM_H_INCLUDED
45
+ 
46
++#include "nettle-config.h"
47
+ #include "nettle-meta.h"
48
+ 
49
+ #ifdef USE_MINI_GMP
50
+diff --git a/configure.ac b/configure.ac
51
+index c24f954..cb65bcd 100644
52
+--- a/configure.ac
53
++++ b/configure.ac
54
+@@ -10,6 +10,7 @@ AC_CONFIG_AUX_DIR([.])
55
+ AC_CONFIG_MACRO_DIR([.])
56
+ 
57
+ AC_CONFIG_HEADER([config.h])
58
++AC_CONFIG_HEADER([nettle-config.h])
59
+ 
60
+ LIBNETTLE_MAJOR=4
61
+ LIBNETTLE_MINOR=7
62
+diff --git a/examples/ecc-benchmark.c b/examples/ecc-benchmark.c
63
+index 16a1fd6..eaaf3a5 100644
64
+--- a/examples/ecc-benchmark.c
65
++++ b/examples/ecc-benchmark.c
66
+@@ -38,6 +38,7 @@
67
+ #include "timing.h"
68
+ 
69
+ #undef USE_MINI_GMP
70
++#define NETTLE_CONFIG_H_INCLUDED
71
+ #include <gmp.h>
72
+ #include "../ecc.h"
73
+ #include "../ecc-internal.h"
74
+diff --git a/nettle-config.h.in b/nettle-config.h.in
75
+new file mode 100644
76
+index 0000000..11330ff
77
+--- /dev/null
78
++++ b/nettle-config.h.in
79
+@@ -0,0 +1,6 @@
80
++#ifndef NETTLE_CONFIG_H_INCLUDED
81
++#define NETTLE_CONFIG_H_INCLUDED
82
++
83
++#undef USE_MINI_GMP
84
++
85
++#endif
86
+diff --git a/testsuite/testutils.h b/testsuite/testutils.h
87
+index a677a2a..6e9b30c 100644
88
+--- a/testsuite/testutils.h
89
++++ b/testsuite/testutils.h
90
+@@ -15,6 +15,7 @@
91
+ 
92
+ #if WITH_HOGWEED
93
+ # include <gmp.h>
94
++# define NETTLE_CONFIG_H_INCLUDED
95
+ # undef USE_MINI_GMP
96
+ # include "rsa.h"
97
+ # include "dsa.h"
98
+-- 
99
+1.9.2
100
+

+ 34
- 0
libs/nettle/patches/0005-allow-der-iterator-to-be-used-with-mini-gmp.patch View File

@@ -0,0 +1,34 @@
1
+From d71b3138cbdc3852c96a2639995f2d7f44b1c76c Mon Sep 17 00:00:00 2001
2
+From: Nikos Mavrogiannopoulos <nmav@gnutls.org>
3
+Date: Sat, 29 Mar 2014 09:12:41 +0100
4
+Subject: [PATCH 5/5] allow der-iterator to be used with mini-gmp
5
+
6
+---
7
+ der-iterator.c | 4 ++--
8
+ 1 file changed, 2 insertions(+), 2 deletions(-)
9
+
10
+diff --git a/der-iterator.c b/der-iterator.c
11
+index 2e6efd5..5ab15b9 100644
12
+--- a/der-iterator.c
13
++++ b/der-iterator.c
14
+@@ -30,7 +30,7 @@
15
+ #include <assert.h>
16
+ #include <stdlib.h>
17
+ 
18
+-#if HAVE_LIBGMP
19
++#if defined(HAVE_LIBGMP) || defined(USE_MINI_GMP)
20
+ #include "bignum.h"
21
+ #endif
22
+ 
23
+@@ -246,7 +246,7 @@ asn1_der_get_uint32(struct asn1_der_iterator *i,
24
+   return 1;
25
+ }
26
+ 
27
+-#if HAVE_LIBGMP
28
++#if defined(HAVE_LIBGMP) || defined(USE_MINI_GMP)
29
+ int
30
+ asn1_der_get_bignum(struct asn1_der_iterator *i,
31
+ 		    mpz_t x, unsigned max_bits)
32
+-- 
33
+1.9.2
34
+