a1b0b5f80a41d67da428c9457e6363e9411c8bf5
[feed/packages.git] / net / strongswan / patches / 305-minimal_dh_plugin.patch
1 --- a/configure.ac
2 +++ b/configure.ac
3 @@ -133,6 +133,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([curve25519], [disable Curve25519 Diffie-Hellman plugin.])
9 ARG_DISBL_SET([hmac], [disable HMAC crypto implementation plugin.])
10 ARG_ENABL_SET([md4], [enable MD4 software implementation plugin.])
11 @@ -1362,6 +1363,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([curve25519], [s charon scripts nm cmd])
17 ADD_PLUGIN([agent], [s charon nm cmd])
18 ADD_PLUGIN([keychain], [s charon cmd])
19 @@ -1498,6 +1500,7 @@ AM_CONDITIONAL(USE_SHA3, test x$sha3 = x
20 AM_CONDITIONAL(USE_MGF1, test x$mgf1 = 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_CURVE25519, test x$curve25519 = xtrue)
25 AM_CONDITIONAL(USE_RDRAND, test x$rdrand = xtrue)
26 AM_CONDITIONAL(USE_AESNI, test x$aesni = xtrue)
27 @@ -1756,6 +1759,7 @@ AC_CONFIG_FILES([
28 src/libstrongswan/plugins/mgf1/Makefile
29 src/libstrongswan/plugins/fips_prf/Makefile
30 src/libstrongswan/plugins/gmp/Makefile
31 + src/libstrongswan/plugins/gmpdh/Makefile
32 src/libstrongswan/plugins/curve25519/Makefile
33 src/libstrongswan/plugins/rdrand/Makefile
34 src/libstrongswan/plugins/aesni/Makefile
35 --- a/src/libstrongswan/Makefile.am
36 +++ b/src/libstrongswan/Makefile.am
37 @@ -313,6 +313,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_CURVE25519
49 SUBDIRS += plugins/curve25519
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_ @}*/