Browse Source

Add more verbose debug output for GSM-Milenage use (RAND,SRES,Kc)

Jouni Malinen 16 years ago
parent
commit
a532c108bd
1 changed files with 15 additions and 10 deletions
  1. 15 10
      src/eap_peer/eap_sim.c

+ 15 - 10
src/eap_peer/eap_sim.c

@@ -171,6 +171,7 @@ static int eap_sim_gsm_auth(struct eap_sm *sm, struct eap_sim_data *data)
 	if (conf->password) {
 		u8 opc[16], k[16];
 		const char *pos;
+		size_t i;
 		wpa_printf(MSG_DEBUG, "EAP-SIM: Use internal GSM-Milenage "
 			   "implementation for authentication");
 		if (conf->password_len < 65) {
@@ -189,16 +190,20 @@ static int eap_sim_gsm_auth(struct eap_sm *sm, struct eap_sim_data *data)
 		if (hexstr2bin(pos, opc, 16))
 			return -1;
 
-		if (gsm_milenage(opc, k, data->rand[0],
-				 data->sres[0], data->kc[0]) ||
-		    gsm_milenage(opc, k, data->rand[1],
-				 data->sres[1], data->kc[1]) ||
-		    (data->num_chal > 2 &&
-		     gsm_milenage(opc, k, data->rand[2],
-				  data->sres[2], data->kc[2]))) {
-			wpa_printf(MSG_DEBUG, "EAP-SIM: GSM-Milenage "
-				   "authentication could not be completed");
-			return -1;
+		for (i = 0; i < data->num_chal; i++) {
+			if (gsm_milenage(opc, k, data->rand[i],
+					 data->sres[i], data->kc[i])) {
+				wpa_printf(MSG_DEBUG, "EAP-SIM: "
+					   "GSM-Milenage authentication "
+					   "could not be completed");
+				return -1;
+			}
+			wpa_hexdump(MSG_DEBUG, "EAP-SIM: RAND",
+				    data->rand[i], GSM_RAND_LEN);
+			wpa_hexdump_key(MSG_DEBUG, "EAP-SIM: SRES",
+					data->sres[i], EAP_SIM_SRES_LEN);
+			wpa_hexdump_key(MSG_DEBUG, "EAP-SIM: Kc",
+					data->kc[i], EAP_SIM_KC_LEN);
 		}
 		return 0;
 	}