You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

221 lines
6.8 KiB

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