[Pkg-swan-devel] [strongswan] 04/05: Fix openssl HMAC init and re-enable vectors test

Yves-Alexis Perez corsac at moszumanska.debian.org
Tue May 30 12:17:22 UTC 2017


This is an automated email from the git hooks/post-receive script.

corsac pushed a commit to branch jessie-security
in repository strongswan.

commit b6cd0321f586c28357962afd7090b9540a2da8d2
Author: Yves-Alexis Perez <corsac at corsac.net>
Date:   Tue May 30 10:07:26 2017 +0200

    Fix openssl HMAC init and re-enable vectors test
    
    * debian/rules:
      - revert disabling of vectors test
    * debian/patches:
      - 0001-openssl-Don-t-pre-initialize-OpenSSL-HMAC-with-an-em added,
      backported from upstream, fix HMAC initialization with recent OpenSSL.
---
 debian/changelog                                   | 10 +++
 ...-t-pre-initialize-OpenSSL-HMAC-with-an-em.patch | 74 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 debian/rules                                       |  4 --
 4 files changed, 85 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 2bc5b82..98cd9f7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
+strongswan (5.2.1-6+deb8u4) UNRELEASED; urgency=medium
+
+  * debian/rules:
+    - revert disabling of vectors test
+  * debian/patches:
+    - 0001-openssl-Don-t-pre-initialize-OpenSSL-HMAC-with-an-em added,
+    backported from upstream, fix HMAC initialization with recent OpenSSL.
+
+ -- Yves-Alexis Perez <corsac at debian.org>  Tue, 30 May 2017 10:05:04 +0200
+
 strongswan (5.2.1-6+deb8u3) jessie-security; urgency=medium
 
   * debian/patches:
diff --git a/debian/patches/0001-openssl-Don-t-pre-initialize-OpenSSL-HMAC-with-an-em.patch b/debian/patches/0001-openssl-Don-t-pre-initialize-OpenSSL-HMAC-with-an-em.patch
new file mode 100644
index 0000000..4723f6d
--- /dev/null
+++ b/debian/patches/0001-openssl-Don-t-pre-initialize-OpenSSL-HMAC-with-an-em.patch
@@ -0,0 +1,74 @@
+From c2906c8f21af7555e0f786b6474cf4c7dc0c7651 Mon Sep 17 00:00:00 2001
+From: Martin Willi <martin at revosec.ch>
+Date: Mon, 30 Mar 2015 10:25:41 +0200
+Subject: [PATCH] openssl: Don't pre-initialize OpenSSL HMAC with an empty key
+
+With OpenSSL commit 929b0d70c19f60227f89fac63f22a21f21950823 setting an empty
+key fails if no previous key has been set on that HMAC.
+
+In 9138f49e we explicitly added the check we remove now, as HMAC_Update()
+might crash if HMAC_Init_ex() has not been called yet. To avoid that, we
+set and check a flag locally to let any get_mac() call fail if set_key() has
+not yet been called.
+---
+ src/libstrongswan/plugins/openssl/openssl_hmac.c | 22 ++++++++++++++++------
+ 1 file changed, 16 insertions(+), 6 deletions(-)
+
+diff --git a/src/libstrongswan/plugins/openssl/openssl_hmac.c b/src/libstrongswan/plugins/openssl/openssl_hmac.c
+index 4f0bcc7c3..065187a8c 100644
+--- a/src/libstrongswan/plugins/openssl/openssl_hmac.c
++++ b/src/libstrongswan/plugins/openssl/openssl_hmac.c
+@@ -69,15 +69,26 @@ struct private_mac_t {
+ 	 * Current HMAC context
+ 	 */
+ 	HMAC_CTX hmac;
++
++	/**
++	 * Key set on HMAC_CTX?
++	 */
++	bool key_set;
+ };
+ 
+ METHOD(mac_t, set_key, bool,
+ 	private_mac_t *this, chunk_t key)
+ {
+ #if OPENSSL_VERSION_NUMBER >= 0x10000000L
+-	return HMAC_Init_ex(&this->hmac, key.ptr, key.len, this->hasher, NULL);
++	if (HMAC_Init_ex(&this->hmac, key.ptr, key.len, this->hasher, NULL))
++	{
++		this->key_set = TRUE;
++		return TRUE;
++	}
++	return FALSE;
+ #else /* OPENSSL_VERSION_NUMBER < 1.0 */
+ 	HMAC_Init_ex(&this->hmac, key.ptr, key.len, this->hasher, NULL);
++	this->key_set = TRUE;
+ 	return TRUE;
+ #endif
+ }
+@@ -85,6 +96,10 @@ METHOD(mac_t, set_key, bool,
+ METHOD(mac_t, get_mac, bool,
+ 	private_mac_t *this, chunk_t data, u_int8_t *out)
+ {
++	if (!this->key_set)
++	{
++		return FALSE;
++	}
+ #if OPENSSL_VERSION_NUMBER >= 0x10000000L
+ 	if (!HMAC_Update(&this->hmac, data.ptr, data.len))
+ 	{
+@@ -153,11 +168,6 @@ static mac_t *hmac_create(hash_algorithm_t algo)
+ 	}
+ 
+ 	HMAC_CTX_init(&this->hmac);
+-	if (!set_key(this, chunk_empty))
+-	{
+-		destroy(this);
+-		return NULL;
+-	}
+ 
+ 	return &this->public;
+ }
+-- 
+2.11.0
+
diff --git a/debian/patches/series b/debian/patches/series
index 6ef7c13..59adb6e 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -7,3 +7,4 @@ CVE-2015-4171_enforce_remote_auth.patch
 CVE-2015-8023_eap_mschapv2_state.patch
 CVE-2017-9022_insufficient_input_validation_gmp_plugin.patch
 CVE-2017-9023_incorrect_handling_of_choice_types_in_asn1_parser.patch
+0001-openssl-Don-t-pre-initialize-OpenSSL-HMAC-with-an-em.patch
diff --git a/debian/rules b/debian/rules
index 697b6a0..ba9eefa 100755
--- a/debian/rules
+++ b/debian/rules
@@ -2,10 +2,6 @@
 export DEB_LDFLAGS_MAINT_APPEND=-Wl,--as-needed -Wl,-O1
 #export DEB_LDFLAGS_MAINT_APPEND=-Wl,--as-needed -Wl,-O1 -Wl,-z,defs
 export DEB_BUILD_MAINT_OPTIONS=hardening=+all
-# the vectors test is failing now, maybe because of an OpenSSL regression
-# disable the for now so we meet the CRD for CVE-2017-902{2,3}
-# Yves-Alexis Perez / 20170529
-export TESTS_SUITES_EXCLUDE="vectors"
 
 CONFIGUREARGS := --libdir=/usr/lib --libexecdir=/usr/lib \
 		--enable-ldap --enable-curl \

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-swan/strongswan.git



More information about the Pkg-swan-devel mailing list