diff --git a/contrib/src/gnutls/SHA512SUMS b/contrib/src/gnutls/SHA512SUMS
index d6b2d98fe4565cdf18a562009057b1432dd7f30e..5a5d95cddf4818411369246da5361a5af540933a 100644
--- a/contrib/src/gnutls/SHA512SUMS
+++ b/contrib/src/gnutls/SHA512SUMS
@@ -1 +1 @@
-3205fcfe3344f777f5c8d2162de2ac338cfdfabaa55d7b829e59160cfec434651f704a9bac355f5003d1841448c4b0303dc6e06a935801aa922504b297bdd093  gnutls-3.1.25.tar.xz
+ab11bb46e69a689f275cc158d8bc031bb09287a2193a2d9ccb36c04a8e106d9204754bd148c67417e6d63ed0c75750bbe7b602424bb7dcd9af2e25d9275ef02d  gnutls-3.4.0.tar.xz
diff --git a/contrib/src/gnutls/downgrade-automake-requirement.patch b/contrib/src/gnutls/downgrade-automake-requirement.patch
index 62b156d98834898384667a2fed83f3eb1d6c0bc2..5e977a4c95ca2a0d09b333807e325e18ffbc851d 100644
--- a/contrib/src/gnutls/downgrade-automake-requirement.patch
+++ b/contrib/src/gnutls/downgrade-automake-requirement.patch
@@ -1,11 +1,11 @@
---- gnutls-3.1.14/configure.ac.orig	2013-09-17 18:17:09.840217108 +0200
-+++ gnutls-3.1.14/configure.ac	2013-09-17 18:19:36.609535012 +0200
+--- gnutls-3.4.0/configure.ac.orig	2013-09-17 18:17:09.840217108 +0200
++++ gnutls-3.4.0/configure.ac	2013-09-17 18:19:36.609535012 +0200
 @@ -26,7 +26,7 @@
  AC_CONFIG_MACRO_DIR([m4])
  AC_CANONICAL_HOST
  
--AM_INIT_AUTOMAKE([1.12.2 no-dist-gzip dist-xz dist-lzip -Wall -Wno-override])
-+AM_INIT_AUTOMAKE([1.11.1 no-dist-gzip dist-xz -Wall -Wno-override])
+-AM_INIT_AUTOMAKE([1.12.2 subdir-objects no-dist-gzip dist-xz dist-lzip -Wall -Wno-override])
++AM_INIT_AUTOMAKE([1.11.1 subdir-objects no-dist-gzip dist-xz -Wall -Wno-override])
  m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  AC_CONFIG_HEADERS([config.h])
  
diff --git a/contrib/src/gnutls/gnutls-no-egd.patch b/contrib/src/gnutls/gnutls-no-egd.patch
index c0e3407570a641c479d38b1bd22c01473b4aebec..d4b5f093e7116eaa211b60adc2d97ea078568320 100644
--- a/contrib/src/gnutls/gnutls-no-egd.patch
+++ b/contrib/src/gnutls/gnutls-no-egd.patch
@@ -1,81 +1,107 @@
-diff -ru gnutls.orig/lib/nettle/rnd.c gnutls/lib/nettle/rnd.c
---- gnutls-3.1.10/lib/nettle/Makefile.am.orig	2013-03-25 14:41:50.265377296 +0100
-+++ gnutls-3.1.10/lib/nettle/Makefile.am	2013-03-25 14:50:17.436084975 +0100
-@@ -33,7 +33,7 @@
+ {a => b}/lib/nettle/Makefile.am  |  2 +-
+ {a => b}/lib/nettle/Makefile.in  | 11 +++++------
+ {a => b}/lib/nettle/rnd-common.c |  7 +++++--
+ 3 files changed, 11 insertions(+), 9 deletions(-)
+
+diff --git a/lib/nettle/Makefile.am b/lib/nettle/Makefile.am
+index e84ed1f..4767663 100644
+--- a/lib/nettle/Makefile.am
++++ b/lib/nettle/Makefile.am
+@@ -38,7 +38,7 @@ endif
  
  noinst_LTLIBRARIES = libcrypto.la
  
--libcrypto_la_SOURCES = pk.c mpi.c mac.c cipher.c rnd.c init.c egd.c egd.h \
-+libcrypto_la_SOURCES = pk.c mpi.c mac.c cipher.c rnd.c init.c \
- 	multi.c wmnaf.c ecc_free.c ecc.h ecc_make_key.c ecc_shared_secret.c \
- 	ecc_map.c ecc_mulmod.c ecc_mulmod_cached.c \
- 	ecc_points.c ecc_projective_dbl_point_3.c ecc_projective_isneutral.c \
---- gnutls-3.1.10/lib/nettle/Makefile.in.orig	2013-03-25 14:41:50.268710655 +0100
-+++ gnutls-3.1.10/lib/nettle/Makefile.in	2013-03-25 14:51:42.180123726 +0100
-@@ -219,7 +219,7 @@
+-libcrypto_la_SOURCES = pk.c mpi.c mac.c cipher.c init.c egd.c egd.h \
++libcrypto_la_SOURCES = pk.c mpi.c mac.c cipher.c init.c \
+ 	gnettle.h rnd-common.h rnd-common.c \
+ 	rnd.c
+ 
+diff --git a/lib/nettle/Makefile.in b/lib/nettle/Makefile.in
+index 88ae7cf..6ddd536 100644
+--- a/lib/nettle/Makefile.in
++++ b/lib/nettle/Makefile.in
+@@ -221,8 +221,8 @@ CONFIG_CLEAN_FILES =
+ CONFIG_CLEAN_VPATH_FILES =
  LTLIBRARIES = $(noinst_LTLIBRARIES)
  libcrypto_la_LIBADD =
- am_libcrypto_la_OBJECTS = pk.lo mpi.lo mac.lo cipher.lo rnd.lo init.lo \
--	egd.lo multi.lo wmnaf.lo ecc_free.lo ecc_make_key.lo \
-+	multi.lo wmnaf.lo ecc_free.lo ecc_make_key.lo \
- 	ecc_shared_secret.lo ecc_map.lo ecc_mulmod.lo \
- 	ecc_mulmod_cached.lo ecc_points.lo \
- 	ecc_projective_dbl_point_3.lo ecc_projective_isneutral.lo \
-@@ -1536,7 +1536,7 @@
- 	-I$(srcdir)/../includes -I$(builddir)/../includes \
- 	-I$(builddir)/../../gl -I$(srcdir)/.. $(am__append_1)
+-am__libcrypto_la_SOURCES_DIST = pk.c mpi.c mac.c cipher.c init.c egd.c \
+-	egd.h gnettle.h rnd-common.h rnd-common.c rnd.c rnd-fips.c \
++am__libcrypto_la_SOURCES_DIST = pk.c mpi.c mac.c cipher.c init.c \
++	gnettle.h rnd-common.h rnd-common.c rnd.c rnd-fips.c \
+ 	int/drbg-aes-self-test.c int/dsa-fips.h \
+ 	int/dsa-keygen-fips186.c int/dsa-validate.c \
+ 	int/provable-prime.c int/drbg-aes.c int/drbg-aes.h \
+@@ -233,7 +233,7 @@ am__dirstamp = $(am__leading_dot)dirstamp
+ @ENABLE_FIPS140_TRUE@	int/dsa-keygen-fips186.lo \
+ @ENABLE_FIPS140_TRUE@	int/dsa-validate.lo int/provable-prime.lo \
+ @ENABLE_FIPS140_TRUE@	int/drbg-aes.lo int/rsa-keygen-fips186.lo
+-am_libcrypto_la_OBJECTS = pk.lo mpi.lo mac.lo cipher.lo init.lo egd.lo \
++am_libcrypto_la_OBJECTS = pk.lo mpi.lo mac.lo cipher.lo init.lo \
+ 	rnd-common.lo rnd.lo $(am__objects_1)
+ libcrypto_la_OBJECTS = $(am_libcrypto_la_OBJECTS)
+ AM_V_lt = $(am__v_lt_@AM_V@)
+@@ -1279,8 +1279,8 @@ AM_CPPFLAGS = -I$(srcdir)/int -I$(srcdir)/../../gl \
+ 	-I$(builddir)/../includes -I$(builddir)/../../gl \
+ 	-I$(srcdir)/.. $(am__append_1)
  noinst_LTLIBRARIES = libcrypto.la
--libcrypto_la_SOURCES = pk.c mpi.c mac.c cipher.c rnd.c init.c egd.c egd.h \
-+libcrypto_la_SOURCES = pk.c mpi.c mac.c cipher.c rnd.c init.c \
- 	multi.c wmnaf.c ecc_free.c ecc.h ecc_make_key.c ecc_shared_secret.c \
- 	ecc_map.c ecc_mulmod.c ecc_mulmod_cached.c \
- 	ecc_points.c ecc_projective_dbl_point_3.c ecc_projective_isneutral.c \
-@@ -1610,7 +1610,6 @@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecc_shared_secret.Plo@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecc_sign_hash.Plo@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecc_verify_hash.Plo@am__quote@
+-libcrypto_la_SOURCES = pk.c mpi.c mac.c cipher.c init.c egd.c egd.h \
+-	gnettle.h rnd-common.h rnd-common.c rnd.c $(am__append_2)
++libcrypto_la_SOURCES = pk.c mpi.c mac.c cipher.c init.c gnettle.h \
++	rnd-common.h rnd-common.c rnd.c $(am__append_2)
+ all: all-am
+ 
+ .SUFFIXES:
+@@ -1355,7 +1355,6 @@ distclean-compile:
+ 	-rm -f *.tab.c
+ 
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cipher.Plo@am__quote@
 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/egd.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/init.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mac.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mpi.Plo@am__quote@
---- gnutls-3.1.10/lib/nettle/rnd.c.orig	2013-03-21 21:42:28.000000000 +0100
-+++ gnutls-3.1.10/lib/nettle/rnd.c	2013-03-25 14:52:50.004027534 +0100
-@@ -205,7 +205,7 @@
+diff --git a/lib/nettle/rnd-common.c b/lib/nettle/rnd-common.c
+index c69ff3b..80b5f32 100644
+--- a/lib/nettle/rnd-common.c
++++ b/lib/nettle/rnd-common.c
+@@ -139,7 +139,7 @@ void _rnd_system_entropy_deinit(void)
  #include <sys/time.h>
  #include <fcntl.h>
  #include <locks.h>
 -#include "egd.h"
 +//#include "egd.h"
  
- #define DEVICE_READ_SIZE 16
- #define DEVICE_READ_SIZE_MAX 32
-@@ -276,6 +276,7 @@
-   return 0;
+ static int _gnutls_urandom_fd = -1;
+ static mode_t _gnutls_urandom_fd_mode = 0;
+@@ -208,6 +208,7 @@ static int _rnd_get_system_entropy_urandom(void* _rnd, size_t size)
+ 	return 0;
  }
  
 +#if 0
- static int
- do_device_source_egd (int init)
+ static
+ int _rnd_get_system_entropy_egd(void* _rnd, size_t size)
  {
-@@ -329,6 +330,7 @@
-     }
-   return 0;
+@@ -232,6 +233,7 @@ int _rnd_get_system_entropy_egd(void* _rnd, size_t size)
+ 
+ 	return 0;
  }
 +#endif
  
- static int
- do_device_source (int init)
-@@ -346,11 +348,13 @@
+ int _rnd_system_entropy_check(void)
+ {
+@@ -268,6 +270,7 @@ int _rnd_system_entropy_init(void)
  
-       do_source = do_device_source_urandom;
-       ret = do_source (init);
+ 	return 0;
+ fallback:
 +#if 0
-       if (ret < 0)
-         {
-           do_source = do_device_source_egd;
-           ret = do_source (init);
-         }
+ 	_gnutls_urandom_fd = _rndegd_connect_socket();
+ 	if (_gnutls_urandom_fd < 0) {
+ 		_gnutls_debug_log("Cannot open egd socket!\n");
+@@ -281,7 +284,7 @@ fallback:
+ 	}
+ 
+ 	_rnd_get_system_entropy = _rnd_get_system_entropy_egd;
+-	
 +#endif
+ 	return 0;
+ }
  
-       if (ret < 0)
-         {
diff --git a/contrib/src/gnutls/rules.mak b/contrib/src/gnutls/rules.mak
index c91416696a510f2098c5cc46a58382b649880fe3..b672e12b615d45c826b06f7fa982433fda92f0b5 100644
--- a/contrib/src/gnutls/rules.mak
+++ b/contrib/src/gnutls/rules.mak
@@ -1,7 +1,7 @@
 # GnuTLS
 
-GNUTLS_VERSION := 3.1.25
-GNUTLS_URL := ftp://ftp.gnutls.org/gcrypt/gnutls/v3.1/gnutls-$(GNUTLS_VERSION).tar.xz
+GNUTLS_VERSION := 3.4.0
+GNUTLS_URL := ftp://ftp.gnutls.org/gcrypt/gnutls/v3.4/gnutls-$(GNUTLS_VERSION).tar.xz
 
 PKGS += gnutls
 ifeq ($(call need_pkg,"gnutls >= 3.0.20"),)
diff --git a/contrib/src/nettle/SHA512SUMS b/contrib/src/nettle/SHA512SUMS
index 38275a3336bf66475b8e6d0a6ad48ee80d7fa28b..93ffc75f50b8f8608e19e499e66eb7a101ea0026 100644
--- a/contrib/src/nettle/SHA512SUMS
+++ b/contrib/src/nettle/SHA512SUMS
@@ -1 +1 @@
-297c69e90bbd448f72e854abe5cc7868c08d710e1c1bcd6a14adf06e25629d58a3ef4d65ab588d001ec7091aa583032312ad15b416ea5479e5bf0ea63717f473  nettle-2.7.1.tar.gz
+f0e75218de0ef516e09ee3180fe22a2617272d0118b7239e641d0f5c097377671c6966afd8bd316cb091811d7b731bc83ffc518cef1076c40ae5a31c007910e9  nettle-3.1.tar.gz
diff --git a/contrib/src/nettle/rules.mak b/contrib/src/nettle/rules.mak
index f832eda440ce1b546374ce62c5d927ef2a0e99c7..6e832bcca31218bff254db7c8143f29bebba5958 100644
--- a/contrib/src/nettle/rules.mak
+++ b/contrib/src/nettle/rules.mak
@@ -1,9 +1,9 @@
 # Nettle
 
-NETTLE_VERSION := 2.7.1
+NETTLE_VERSION := 3.1
 NETTLE_URL := ftp://ftp.gnu.org/gnu/nettle/nettle-$(NETTLE_VERSION).tar.gz
 
-ifeq ($(call need_pkg,"nettle >= 2.7"),)
+ifeq ($(call need_pkg,"nettle >= 3.1"),)
 PKGS_FOUND += nettle
 endif