]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/eap.c
pppd: add experimental support for PEAP protocol, an extension of EAP
[ppp.git] / pppd / eap.c
index 4daada7bb56cd67dea305ba30cf46f5f1bc18370..b758711117948eb29c6b0a0ce6221f5c2e641e41 100644 (file)
  * Implemented EAP-TLS authentication
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include "pathnames.h"
 #include "md5.h"
 #include "eap.h"
+#ifdef USE_PEAP
+#include "peap.h"
+#endif /* USE_PEAP */
 
 #ifdef USE_SRP
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
 #include <t_pwd.h>
 #include <t_server.h>
 #include <t_client.h>
@@ -82,6 +92,8 @@
 #ifdef CHAPMS
 #include "chap_ms.h"
 #include "chap-new.h"
+
+extern int chapms_strip_domain;
 #endif /* CHAPMS */
 
 eap_state eap_states[NUM_PPP];         /* EAP state; one for each unit */
@@ -550,7 +562,7 @@ eap_figure_next_state(eap_state *esp, int status)
                        tpw.pebuf.name = esp->es_server.ea_peer;
                        tpw.pebuf.password.len = t_fromb64((char *)tpw.pwbuf,
                            cp);
-                       tpw.pebuf.password.data = tpw.pwbuf;
+                       tpw.pebuf.password.data = (char*) tpw.pwbuf;
                        tpw.pebuf.salt.len = t_fromb64((char *)tpw.saltbuf,
                            cp2);
                        tpw.pebuf.salt.data = tpw.saltbuf;
@@ -2207,6 +2219,11 @@ eap_request(eap_state *esp, u_char *inp, int id, int len)
 
            break;
 #endif /* CHAPMS */
+#ifdef USE_PEAP
+       case EAPT_PEAP:
+               peap_process(esp, id, inp, len, rhostname);
+               break;
+#endif /* USE_PEAP */
 
        default:
                info("EAP: unknown authentication type %d; Naking", typenum);
@@ -2251,8 +2268,6 @@ eap_response(eap_state *esp, u_char *inp, int id, int len)
        struct t_num A;
        SHA1_CTX ctxt;
        u_char dig[SHA_DIGESTSIZE];
-       SHA1_CTX ctxt;
-       u_char dig[SHA_DIGESTSIZE];
 #endif /* USE_SRP */
 
 #ifdef USE_EAPTLS
@@ -2545,6 +2560,14 @@ eap_response(eap_state *esp, u_char *inp, int id, int len)
                                        (remote_name[0] != '\0' && vallen == len))
                                strlcpy(rhostname, remote_name, sizeof (rhostname));
 
+                       /* strip the MS domain name */
+                       if (chapms_strip_domain && strrchr(rhostname, '\\')) {
+                               char tmp[MAXNAMELEN+1];
+
+                               strcpy(tmp, strrchr(rhostname, '\\') + 1);
+                               strcpy(rhostname, tmp);
+                       }
+
                        if (chap_verify_hook)
                                chap_verifier = chap_verify_hook;
                        else
@@ -3011,6 +3034,7 @@ eap_printpkt(u_char *inp, int inlen,
                        break;
 #endif /* USE_EAPTLS */
 
+#ifdef USE_SRP
                case EAPT_SRP:
                        if (len < 3)
                                goto truncated;
@@ -3098,6 +3122,7 @@ eap_printpkt(u_char *inp, int inlen,
                                break;
                        }
                        break;
+#endif  /* USE_SRP */
                }
                break;
 
@@ -3223,6 +3248,7 @@ eap_printpkt(u_char *inp, int inlen,
                        break;
 #endif /* CHAPMS */
 
+#ifdef USE_SRP
                case EAPT_SRP:
                        if (len < 1)
                                goto truncated;
@@ -3267,6 +3293,7 @@ eap_printpkt(u_char *inp, int inlen,
                                break;
                        }
                        break;
+#endif  /* USE_SRP */
                }
                break;