Browse Source

strongswan: gmpdh plugin, package and strongswan-isakmp metapackage

gmpdh plugin implements DH Groups (same as normal GMP plugin), but links to GMP statically and is stripped of all RSA based stuff. Binary size for plugin is ~20kbytes with no dependency on libgmp (200+ kbytes after squash), easilly fitting into flash space restricted devices.

strongswan-isakmp metapackage defines a minimal set of strongswan plugins (including gmpdh) for ISAKMP / IKEv1 PSK tunnels. Will fit even 4mb routers (like tplink wr841n) with disabled IPv6 support and packages (so its a trade - IPv6 or ipsec tunnels).

Signed-of-by: Mikalai Miadzvedz <brainsucker.na@gmail.com>
brainsucker-na 9 years ago
parent
commit
f705b3c0bf
2 changed files with 260 additions and 1 deletions
  1. 39
    1
      net/strongswan/Makefile
  2. 221
    0
      net/strongswan/patches/305-minimal_dh_plugin.patch

+ 39
- 1
net/strongswan/Makefile View File

@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=strongswan
11 11
 PKG_VERSION:=5.3.3
12
-PKG_RELEASE:=1
12
+PKG_RELEASE:=2
13 13
 
14 14
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
15 15
 PKG_SOURCE_URL:=http://download.strongswan.org/ http://download2.strongswan.org/
@@ -45,6 +45,7 @@ PKG_MOD_AVAILABLE:= \
45 45
 	gcm \
46 46
 	gcrypt \
47 47
 	gmp \
48
+	gmpdh \
48 49
 	ha \
49 50
 	hmac \
50 51
 	kernel-libipsec \
@@ -254,6 +255,37 @@ $(call Package/strongswan/description/Default)
254 255
  This meta-package contains only dependencies to match upstream defaults.
255 256
 endef
256 257
 
258
+
259
+define Package/strongswan-isakmp
260
+$(call Package/strongswan/Default)
261
+  TITLE+= (isakmp)
262
+  DEPENDS:= +strongswan \
263
+	+strongswan-charon \
264
+	+strongswan-mod-aes \
265
+	+strongswan-mod-des \
266
+	+strongswan-mod-gmpdh \
267
+	+strongswan-mod-hmac \
268
+	+strongswan-mod-kernel-netlink \
269
+	+strongswan-mod-md5 \
270
+	+strongswan-mod-nonce \
271
+	+strongswan-mod-pubkey \
272
+	+strongswan-mod-random \
273
+	+strongswan-mod-sha1 \
274
+	+strongswan-mod-socket-default \
275
+	+strongswan-mod-stroke \
276
+	+strongswan-mod-uci \
277
+	+strongswan-mod-updown \
278
+	+strongswan-utils
279
+endef
280
+
281
+define Package/strongswan-isakmp/description
282
+$(call Package/strongswan/description/Default)
283
+ This meta-package contains only dependencies to establish  ISAKMP /
284
+ IKE PSK connections, dropping other capabilities in favor of small size 
285
+ Can fit most routers even with 4Mb flash (after removing IPv6 support).
286
+endef
287
+
288
+
257 289
 define Package/strongswan-minimal
258 290
 $(call Package/strongswan/Default)
259 291
   TITLE+= (minimal)
@@ -376,6 +408,10 @@ define Package/strongswan-full/install
376 408
 	true
377 409
 endef
378 410
 
411
+define Package/strongswan-isakmp/install
412
+	true
413
+endef
414
+
379 415
 define Package/strongswan-minimal/install
380 416
 	true
381 417
 endef
@@ -454,6 +490,7 @@ $(eval $(call BuildPackage,strongswan))
454 490
 $(eval $(call BuildPackage,strongswan-default))
455 491
 $(eval $(call BuildPackage,strongswan-full))
456 492
 $(eval $(call BuildPackage,strongswan-minimal))
493
+$(eval $(call BuildPackage,strongswan-isakmp))
457 494
 $(eval $(call BuildPackage,strongswan-charon))
458 495
 $(eval $(call BuildPackage,strongswan-utils))
459 496
 $(eval $(call BuildPackage,strongswan-libtls))
@@ -484,6 +521,7 @@ $(eval $(call BuildPlugin,fips-prf,FIPS PRF crypto,+strongswan-mod-sha1))
484 521
 $(eval $(call BuildPlugin,gcm,GCM AEAD wrapper crypto,))
485 522
 $(eval $(call BuildPlugin,gcrypt,libgcrypt,+PACKAGE_strongswan-mod-gcrypt:libgcrypt))
486 523
 $(eval $(call BuildPlugin,gmp,libgmp,+PACKAGE_strongswan-mod-gmp:libgmp))
524
+$(eval $(call BuildPlugin,gmpdh,DH-Groups; no libgmp dep,))
487 525
 $(eval $(call BuildPlugin,ha,high availability cluster,))
488 526
 $(eval $(call BuildPlugin,hmac,HMAC crypto,))
489 527
 $(eval $(call BuildPlugin,kernel-libipsec,libipsec kernel interface,))

+ 221
- 0
net/strongswan/patches/305-minimal_dh_plugin.patch View File

@@ -0,0 +1,221 @@
1
+--- a/configure.ac
2
++++ b/configure.ac
3
+@@ -135,6 +135,7 @@ ARG_DISBL_SET([fips-prf],       [disable
4
+ ARG_ENABL_SET([gcm],            [enables the GCM AEAD wrapper crypto plugin.])
5
+ ARG_ENABL_SET([gcrypt],         [enables the libgcrypt plugin.])
6
+ ARG_DISBL_SET([gmp],            [disable GNU MP (libgmp) based crypto implementation plugin.])
7
++ARG_DISBL_SET([gmpdh],          [disable GNU MP (libgmp) based static-linked crypto DH minimal implementation plugin.])
8
+ ARG_DISBL_SET([hmac],           [disable HMAC crypto implementation plugin.])
9
+ ARG_ENABL_SET([md4],            [enable MD4 software implementation plugin.])
10
+ ARG_DISBL_SET([md5],            [disable MD5 software implementation plugin.])
11
+@@ -1310,6 +1311,7 @@ ADD_PLUGIN([gcrypt],               [s ch
12
+ ADD_PLUGIN([af-alg],               [s charon scepclient pki scripts medsrv attest nm cmd aikgen])
13
+ ADD_PLUGIN([fips-prf],             [s charon nm cmd])
14
+ ADD_PLUGIN([gmp],                  [s charon scepclient pki scripts manager medsrv attest nm cmd aikgen])
15
++ADD_PLUGIN([gmpdh],                [s charon scepclient pki scripts manager medsrv attest nm cmd aikgen])
16
+ ADD_PLUGIN([agent],                [s charon nm cmd])
17
+ ADD_PLUGIN([keychain],             [s charon cmd])
18
+ ADD_PLUGIN([chapoly],              [s charon scripts nm cmd])
19
+@@ -1441,6 +1443,7 @@ AM_CONDITIONAL(USE_SHA1, test x$sha1 = x
20
+ AM_CONDITIONAL(USE_SHA2, test x$sha2 = xtrue)
21
+ AM_CONDITIONAL(USE_FIPS_PRF, test x$fips_prf = xtrue)
22
+ AM_CONDITIONAL(USE_GMP, test x$gmp = xtrue)
23
++AM_CONDITIONAL(USE_GMPDH, test x$gmpdh = xtrue)
24
+ AM_CONDITIONAL(USE_RDRAND, test x$rdrand = xtrue)
25
+ AM_CONDITIONAL(USE_AESNI, test x$aesni = xtrue)
26
+ AM_CONDITIONAL(USE_RANDOM, test x$random = xtrue)
27
+@@ -1688,6 +1691,7 @@ AC_CONFIG_FILES([
28
+ 	src/libstrongswan/plugins/sha2/Makefile
29
+ 	src/libstrongswan/plugins/fips_prf/Makefile
30
+ 	src/libstrongswan/plugins/gmp/Makefile
31
++	src/libstrongswan/plugins/gmpdh/Makefile
32
+ 	src/libstrongswan/plugins/rdrand/Makefile
33
+ 	src/libstrongswan/plugins/aesni/Makefile
34
+ 	src/libstrongswan/plugins/random/Makefile
35
+--- a/src/libstrongswan/Makefile.am
36
++++ b/src/libstrongswan/Makefile.am
37
+@@ -295,6 +295,13 @@ if MONOLITHIC
38
+ endif
39
+ endif
40
+ 
41
++if USE_GMPDH
42
++  SUBDIRS += plugins/gmpdh
43
++if MONOLITHIC
44
++  libstrongswan_la_LIBADD += plugins/gmpdh/libstrongswan-gmpdh.la
45
++endif
46
++endif
47
++
48
+ if USE_RDRAND
49
+   SUBDIRS += plugins/rdrand
50
+ if MONOLITHIC
51
+--- /dev/null
52
++++ b/src/libstrongswan/plugins/gmpdh/Makefile.am
53
+@@ -0,0 +1,19 @@
54
++AM_CPPFLAGS = \
55
++	-I$(top_srcdir)/src/libstrongswan
56
++
57
++AM_CFLAGS = \
58
++	$(PLUGIN_CFLAGS)
59
++
60
++if MONOLITHIC
61
++noinst_LTLIBRARIES = libstrongswan-gmpdh.la
62
++else
63
++plugin_LTLIBRARIES = libstrongswan-gmpdh.la
64
++endif
65
++
66
++libstrongswan_gmpdh_la_SOURCES = \
67
++	gmpdh_plugin.h gmpdh_plugin.c \
68
++	../gmp/gmp_diffie_hellman.c ../gmp/gmp_diffie_hellman.h 
69
++
70
++	
71
++libstrongswan_gmpdh_la_LDFLAGS = -module -avoid-version -Wl,-Bstatic -Wl,-lgmp -Wl,-Bdynamic -Wl,--as-needed
72
++libstrongswan_gmpdh_la_LIBADD  =
73
+--- /dev/null
74
++++ b/src/libstrongswan/plugins/gmpdh/gmpdh_plugin.c
75
+@@ -0,0 +1,101 @@
76
++/*
77
++ * Copyright (C) 2008-2009 Martin Willi
78
++ * Hochschule fuer Technik Rapperswil
79
++ *
80
++ * This program is free software; you can redistribute it and/or modify it
81
++ * under the terms of the GNU General Public License as published by the
82
++ * Free Software Foundation; either version 2 of the License, or (at your
83
++ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
84
++ *
85
++ * This program is distributed in the hope that it will be useful, but
86
++ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
87
++ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
88
++ * for more details.
89
++ */
90
++
91
++#include "gmpdh_plugin.h"
92
++
93
++#include <library.h>
94
++#include "../gmp/gmp_diffie_hellman.h"
95
++
96
++typedef struct private_gmpdh_plugin_t private_gmpdh_plugin_t;
97
++
98
++/**
99
++ * private data of gmp_plugin
100
++ */
101
++struct private_gmpdh_plugin_t {
102
++
103
++	/**
104
++	 * public functions
105
++	 */
106
++	gmpdh_plugin_t public;
107
++};
108
++
109
++METHOD(plugin_t, get_name, char*,
110
++	private_gmpdh_plugin_t *this)
111
++{
112
++	return "gmpdh";
113
++}
114
++
115
++METHOD(plugin_t, get_features, int,
116
++	private_gmpdh_plugin_t *this, plugin_feature_t *features[])
117
++{
118
++	static plugin_feature_t f[] = {
119
++		/* DH groups */
120
++		PLUGIN_REGISTER(DH, gmp_diffie_hellman_create),
121
++			PLUGIN_PROVIDE(DH, MODP_2048_BIT),
122
++				PLUGIN_DEPENDS(RNG, RNG_STRONG),
123
++			PLUGIN_PROVIDE(DH, MODP_2048_224),
124
++				PLUGIN_DEPENDS(RNG, RNG_STRONG),
125
++			PLUGIN_PROVIDE(DH, MODP_2048_256),
126
++				PLUGIN_DEPENDS(RNG, RNG_STRONG),
127
++			PLUGIN_PROVIDE(DH, MODP_1536_BIT),
128
++				PLUGIN_DEPENDS(RNG, RNG_STRONG),
129
++			PLUGIN_PROVIDE(DH, MODP_3072_BIT),
130
++				PLUGIN_DEPENDS(RNG, RNG_STRONG),
131
++			PLUGIN_PROVIDE(DH, MODP_4096_BIT),
132
++				PLUGIN_DEPENDS(RNG, RNG_STRONG),
133
++			PLUGIN_PROVIDE(DH, MODP_6144_BIT),
134
++				PLUGIN_DEPENDS(RNG, RNG_STRONG),
135
++			PLUGIN_PROVIDE(DH, MODP_8192_BIT),
136
++				PLUGIN_DEPENDS(RNG, RNG_STRONG),
137
++			PLUGIN_PROVIDE(DH, MODP_1024_BIT),
138
++				PLUGIN_DEPENDS(RNG, RNG_STRONG),
139
++			PLUGIN_PROVIDE(DH, MODP_1024_160),
140
++				PLUGIN_DEPENDS(RNG, RNG_STRONG),
141
++			PLUGIN_PROVIDE(DH, MODP_768_BIT),
142
++				PLUGIN_DEPENDS(RNG, RNG_STRONG),
143
++		PLUGIN_REGISTER(DH, gmp_diffie_hellman_create_custom),
144
++			PLUGIN_PROVIDE(DH, MODP_CUSTOM),
145
++				PLUGIN_DEPENDS(RNG, RNG_STRONG),
146
++	};
147
++	*features = f;
148
++	return countof(f);
149
++}
150
++
151
++METHOD(plugin_t, destroy, void,
152
++	private_gmpdh_plugin_t *this)
153
++{
154
++	free(this);
155
++}
156
++
157
++/*
158
++ * see header file
159
++ */
160
++plugin_t *gmpdh_plugin_create()
161
++{
162
++	private_gmpdh_plugin_t *this;
163
++
164
++	INIT(this,
165
++		.public = {
166
++			.plugin = {
167
++				.get_name = _get_name,
168
++				.get_features = _get_features,
169
++				.destroy = _destroy,
170
++			},
171
++		},
172
++	);
173
++
174
++	return &this->public.plugin;
175
++}
176
++
177
+--- /dev/null
178
++++ b/src/libstrongswan/plugins/gmpdh/gmpdh_plugin.h
179
+@@ -0,0 +1,42 @@
180
++/*
181
++ * Copyright (C) 2008 Martin Willi
182
++ * Hochschule fuer Technik Rapperswil
183
++ *
184
++ * This program is free software; you can redistribute it and/or modify it
185
++ * under the terms of the GNU General Public License as published by the
186
++ * Free Software Foundation; either version 2 of the License, or (at your
187
++ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
188
++ *
189
++ * This program is distributed in the hope that it will be useful, but
190
++ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
191
++ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
192
++ * for more details.
193
++ */
194
++
195
++/**
196
++ * @defgroup gmpdh_p gmpdh
197
++ * @ingroup plugins
198
++ *
199
++ * @defgroup gmpdh_plugin gmpdh_plugin
200
++ * @{ @ingroup gmpdh_p
201
++ */
202
++
203
++#ifndef GMPDH_PLUGIN_H_
204
++#define GMPDH_PLUGIN_H_
205
++
206
++#include <plugins/plugin.h>
207
++
208
++typedef struct gmpdh_plugin_t gmpdh_plugin_t;
209
++
210
++/**
211
++ * Plugin implementing asymmetric crypto algorithms using the GNU MP library.
212
++ */
213
++struct gmpdh_plugin_t {
214
++
215
++	/**
216
++	 * implements plugin interface
217
++	 */
218
++	plugin_t plugin;
219
++};
220
++
221
++#endif /** GMPDH_PLUGIN_H_ @}*/