⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eapotp.c

📁 Linux上的802.1x 的supplicant的实现。很多supplicant程序都是基于它开发的
💻 C
字号:
/******************************************************************* * EAP One Time Password (OTP/GTC) implementation. * * Licensed under a dual GPL/BSD license.  (See LICENSE file for more info.) * * File: eapotp.c * * Authors: Chris.Hessing@utah.edu * * $Id: eapotp.c,v 1.18 2006/06/01 22:49:50 galimorerpg Exp $ * $Date: 2006/06/01 22:49:50 $ * $Log: eapotp.c,v $ * Revision 1.18  2006/06/01 22:49:50  galimorerpg * Converted all instances of u_char to uint8_t * Fixed a bad #include in the generic frame handler. * * Revision 1.17  2006/05/29 04:17:58  chessing * Fixes for some memory leaks. * * Revision 1.16  2006/04/25 01:17:43  chessing * LOTS of code cleanups, new error checking/debugging code added, and other misc. fixes/changes. * * Revision 1.15  2005/10/17 03:56:54  chessing * Updates to the libxsupconfig library.  It no longer relies on other source from the main tree, so it can be used safely in other code with problems. * * Revision 1.14  2005/10/14 02:26:18  shaftoe * - cleanup gcc 4 warnings * - (re)add support for a pid in the form of /var/run/xsupplicant.<iface>.pid * * -- Eric Evans <eevans@sym-link.com> * * Revision 1.13  2005/08/09 01:39:16  chessing * Cleaned out old commit notes from the released version.  Added a few small features including the ability to disable the friendly warnings that are spit out.  (Such as the warning that is displayed when keys aren't rotated after 10 minutes.)  We should also be able to start when the interface is down.  Last, but not least, we can handle empty network configs.  (This may be useful for situations where there isn't a good reason to have a default network defined.) * * *******************************************************************/#include <openssl/ssl.h>#include <string.h>#include <strings.h>#include "xsupconfig.h"#include "profile.h"#include "eap.h"#include "xsup_debug.h"#include "xsup_err.h"#include "frame_structs.h"#include "eapotp.h"#ifdef USE_EFENCE#include <efence.h>#endif/***************************************************** * * Setup to handle OTP EAP requests * *****************************************************/int eapotp_setup(struct generic_eap_data *thisint){  if (!xsup_assert((thisint != NULL), "thisint != NULL", FALSE))    return XEMALLOC;  thisint->eap_data = (int *)malloc(sizeof(int));  if (thisint->eap_data == NULL) return XEMALLOC;  // Do anything special that might be needed for this EAP type to work.  debug_printf(DEBUG_EVERYTHING, "Initalized EAP-OTP!\n");  return XENONE;}/***************************************************** * * Process OTP EAP Requests * * ******************************************************/int eapotp_process(struct generic_eap_data *thisint, uint8_t *dataoffs, 		   int insize, uint8_t *outframe, int *outsize){  char *otp_chal;  char resp[512];  struct config_eap_otp *userdata;  debug_printf(DEBUG_EVERYTHING, "(EAP-OTP) Processing.\n");  if (!xsup_assert((thisint != NULL), "thisint != NULL", FALSE))    return XEMALLOC;  if (!xsup_assert((dataoffs != NULL), "dataoffs != NULL", FALSE))    return XEMALLOC;  if (!xsup_assert((outframe != NULL), "outframe != NULL", FALSE))    return XEMALLOC;  if (!xsup_assert((outsize != NULL), "outsize != NULL", FALSE))    return XEMALLOC;  debug_printf(DEBUG_AUTHTYPES, "OTP/GTC packet dump : \n");  debug_hex_printf(DEBUG_AUTHTYPES, dataoffs, insize);  *outsize = 0;  userdata = thisint->eap_conf_data;  if (!xsup_assert((userdata != NULL), "userdata != NULL", FALSE))    return XEMALLOC;  if (thisint->tempPwd == NULL)     {      otp_chal = (char *)malloc(insize+1);      if (otp_chal == NULL)	{	  debug_printf(DEBUG_NORMAL, "Couldn't allocate memory for OTP/GTC challenge!\n");	  *outsize = 0;	  return 0;	}      bzero(otp_chal, insize+1);      memcpy(otp_chal, dataoffs, insize);      debug_printf(DEBUG_NORMAL, "Challenge : %s\n",otp_chal);      // We need a password.      thisint->need_password = 1;      thisint->eaptype = strdup("EAP-OTP/GTC");      thisint->eapchallenge = otp_chal;      *outsize = 0;      return XENONE;    }  // Make sure we have something to process...  if (dataoffs == NULL) return XENONE;  /*  debug_printf(DEBUG_NORMAL, "Response : ");      gets(&resp); */  strcpy((char *) outframe, resp);  *outsize = strlen(resp);  return *outsize;}/******************************************************* * * Return any keying material that we may have. * *******************************************************/int eapotp_get_keys(struct interface_data *thisint){  return -1;   // No keys to return;}/******************************************************* * * Clean up after ourselves.  This will get called when we get a packet that * needs to be processed requests a different EAP type.  It will also be  * called on termination of the program. * *******************************************************/int eapotp_cleanup(struct generic_eap_data *thisint){  // Clean up after ourselves.  debug_printf(DEBUG_AUTHTYPES, "(EAP-OTP) Cleaning up.\n");  return XENONE;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -