lede-packages-rs

git clone git://archive.git.mtrnord.blog/MTRNord/lede-packages-rs.git
Log | Files | Refs | README | LICENSE

305-minimal_dh_plugin.patch (6889B)


      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([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 @@ -1347,6 +1348,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 @@ -1480,6 +1482,7 @@ AM_CONDITIONAL(USE_SHA2, test x$sha2 = x
     20  AM_CONDITIONAL(USE_SHA3, test x$sha3 = 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 @@ -1733,6 +1736,7 @@ AC_CONFIG_FILES([
     28  	src/libstrongswan/plugins/sha3/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 @@ -307,6 +307,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_ @}*/