aboutsummaryrefslogtreecommitdiffstats
path: root/community/iwd/fix-EAP-PEAP.patch
blob: 90c918cfb4d559b45ffb9b7b760d7122148b7229 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
From b768e26f1d40674cfc2d37df8c3a34444ccce530 Mon Sep 17 00:00:00 2001
From: Denis Kenzior <denkenz@gmail.com>
Date: Thu, 18 Apr 2019 10:46:37 -0500
Subject: [PATCH] Revert "mschaputil: use util_get_username"

This reverts commit 1e337259ceb9de011f188e4376f1171a4c9cc43c.

Using util_get_username was wrong in this context.  MSCHAPv2 expects us
to only strip the domain name from identities of the form
domain\identity.  util_get_username would also strip identities of the
form username@domain.com.
---
 Makefile.am      |  1 -
 src/mschaputil.c | 17 +++++++++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index bd68d0f0..ef0d9442 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -427,7 +427,6 @@ unit_test_wsc_LDADD = $(ell_ldadd)
 unit_test_eap_mschapv2_SOURCES = src/eap-mschapv2.h src/eap-mschapv2.c \
 				src/eap.c src/eap.h src/eap-private.h \
 				src/mschaputil.h src/mschaputil.c \
-				src/util.h src/util.c \
 				unit/test-eap-mschapv2.c
 unit_test_eap_mschapv2_LDADD = $(ell_ldadd)
 
diff --git a/src/mschaputil.c b/src/mschaputil.c
index 05e24f1f..b1ccf630 100644
--- a/src/mschaputil.c
+++ b/src/mschaputil.c
@@ -28,7 +28,6 @@
 
 #include "src/missing.h"
 #include "src/mschaputil.h"
-#include "src/util.h"
 
 /**
  * Internal function for generate_nt_response.
@@ -126,6 +125,20 @@ cleanup:
 	return r;
 }
 
+static const char *mschapv2_exlude_domain_name(const char *username)
+{
+	const char *c;
+
+	for (c = username; *c; c++) {
+		if (*c != '\\')
+			continue;
+
+		return c + 1;
+	}
+
+	return username;
+}
+
 /**
  * Internal function to generate the challenge used in nt_response
  * https://tools.ietf.org/html/rfc2759
@@ -148,7 +161,7 @@ static bool mschapv2_challenge_hash(const uint8_t *peer_challenge,
 	if (!check)
 		return false;
 
-	username = util_get_username(username);
+	username = mschapv2_exlude_domain_name(username);
 
 	l_checksum_update(check, peer_challenge, 16);
 	l_checksum_update(check, server_challenge, 16);
-- 
2.21.0