亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? xauth.c

?? ipsec vpn
?? C
?? 第 1 頁 / 共 4 頁
字號:
/* XAUTH related functions * * Copyright (C) 2001-2002 Colubris Networks * Copyright (C) 2003 Sean Mathews - Nu Tech Software Solutions, inc. * Copyright (C) 2003-2004 Xelerance Corporation * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License * for more details. * * RCSID $Id: xauth.c,v 1.41.4.3 2005/07/26 02:11:23 ken Exp $ * * This code originally written by Colubris Networks, Inc. * Extraction of patch and porting to 1.99 codebases by Xelerance Corporation * Porting to 2.x by Sean Mathews *///#ifdef XAUTH#include <stdio.h>#include <string.h>#include <stddef.h>#include <stdlib.h>#include <unistd.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <sys/queue.h>#include <crypt.h>#include <openswan.h>#include <openswan/ipsec_policy.h>#include "constants.h"#include "oswlog.h"#include "defs.h"#include "state.h"#include "id.h"#include "x509.h"#include "pgp.h"#include "certs.h"#include "smartcard.h"#ifdef XAUTH_USEPAM#include <security/pam_appl.h>#endif#include "connections.h"	/* needs id.h */#include "packet.h"#include "demux.h"	/* needs packet.h */#include "kernel.h"#include "log.h"#include "cookie.h"#include "server.h"#include "spdb.h"#include "timer.h"#include "rnd.h"#include "ipsec_doi.h"	/* needs demux.h and state.h */#include "whack.h"#include "sha1.h"#include "md5.h"#include "crypto.h" /* requires sha1.h and md5.h */#include "paths.h"#include "ike_alg.h"#include "xauth.h"#include "virtual.h"#ifdef HAVE_THREADS#include <pthread.h>#endifstatic stf_statusmodecfg_inI2(struct msg_digest *md);struct paththing pwdfile;extern bool encrypt_message(pb_stream *pbs, struct state *st); /* forward declaration */struct thread_arg{    struct state *st;    chunk_t	name;    chunk_t	password;    chunk_t     connname;};/*** Addresses assigned (usually via MODE_CONFIG) to the Initiator*/struct internal_addr{    ip_address    ipaddr;    ip_address    dns[2];    ip_address    wins[2];  };#ifdef XAUTH_USEPAMstaticint xauth_pam_conv(int num_msg, const struct pam_message **msgm,              struct pam_response **response, void *appdata_ptr);static struct pam_conv conv = {	xauth_pam_conv,	NULL  };/** * Get IP address from a PAM environment variable *  * @param pamh An open PAM filehandle * @param var Environment Variable to get the IP address from.  Usually IPADDR, DNS[12], WINS[12] * @param addr Pointer to var where you want IP address stored * @return int Return code */staticint get_addr(pam_handle_t *pamh,const char *var,ip_address *addr){	const char *c;	int retval;		c = pam_getenv(pamh,var);	if(c == NULL)	{		c="0.0.0.0";	}	retval = inet_pton(AF_INET,c,(void*) &addr->u.v4.sin_addr.s_addr);	addr->u.v4.sin_family = AF_INET;	return (retval > 0);}#endifoakley_auth_t xauth_calcbaseauth(oakley_auth_t baseauth){  switch(baseauth) {  case HybridInitRSA:  case HybridRespRSA:   case XAUTHInitRSA:        case XAUTHRespRSA:          baseauth = OAKLEY_RSA_SIG;    break;      case XAUTHInitDSS:        case XAUTHRespDSS:        case HybridInitDSS:   case HybridRespDSS:     baseauth = OAKLEY_DSS_SIG;    break;      case XAUTHInitPreShared:  case XAUTHRespPreShared:    baseauth = OAKLEY_PRESHARED_KEY;    break;      case XAUTHInitRSAEncryption:                       case XAUTHRespRSAEncryption:    baseauth = OAKLEY_RSA_ENC;    break;      case XAUTHInitRSARevisedEncryption:               case XAUTHRespRSARevisedEncryption:    baseauth = OAKLEY_RSA_ENC_REV;    break;  }    return baseauth;}      /** * Get inside IP address for a connection *  * @param con A currently active connection struct * @param ia internal_addr struct * @return int Return Code */staticint get_internal_addresses(struct connection *con,struct internal_addr *ia){#ifdef XAUTH_USEPAM    int retval;    char str[IDTOA_BUF+sizeof("ID=")+2];#endif#ifdef NAT_TRAVERSAL /* only NAT-T code lets us do virtual ends */    if (!isanyaddr(&con->spd.that.client.addr))    {	/** assumes IPv4, and also that the mask is ignored */	ia->ipaddr = con->spd.that.client.addr;    }    else#endif    {#ifdef XAUTH_USEPAM	    if(con->pamh == NULL)	    {		    /** Start PAM session, using 'pluto' as our PAM name */		    retval = pam_start("pluto", "user", &conv, &con->pamh);		    memset(ia,0,sizeof(*ia));		    if(retval == PAM_SUCCESS)		    {		            char buf[IDTOA_BUF];			    idtoa(&con->spd.that.id, buf, sizeof(buf));			    if (con->spd.that.id.kind == ID_DER_ASN1_DN)			    {				    /** Keep only the common name, if one exists */				    char *c1, *c2;				    c1 = strstr(buf, "CN=");				    if (c1) {					    c2 = strstr(c1, ", ");					    if (c2) *c2 = '\0';					    memmove(buf, c1+3, strlen(c1) + 1 - 3);				    }			    }			    snprintf(str, sizeof(str), "ID=%s", buf);			    pam_putenv(con->pamh,str);			    pam_open_session(con->pamh,0);		    }	    }	    if(con->pamh != NULL)	    {		    /** Put IP addresses from various variables into our                     *  internal address struct */		    get_addr(con->pamh,"IPADDR",&ia->ipaddr);		    get_addr(con->pamh,"DNS1",&ia->dns[0]);		    get_addr(con->pamh,"DNS2",&ia->dns[1]);		    get_addr(con->pamh,"WINS1",&ia->wins[0]);		    get_addr(con->pamh,"WINS2",&ia->wins[1]);	    }#endif    }    return 0;} /** * Compute HASH of Mode Config. * * @param dest  * @param start * @param roof * @param st State structure * @return size_t Length of the HASH */size_txauth_mode_cfg_hash(u_char *dest		    , const u_char *start		    , const u_char *roof		    , const struct state *st){    struct hmac_ctx ctx;    hmac_init_chunk(&ctx, st->st_oakley.hasher, st->st_skeyid_a);    hmac_update(&ctx, (const u_char *) &st->st_msgid_phase15		, sizeof(st->st_msgid_phase15));    hmac_update(&ctx, start, roof-start);    hmac_final(dest, &ctx);    DBG(DBG_CRYPT,	DBG_log("XAUTH: HASH computed:"); 	DBG_dump("", dest, ctx.hmac_digest_len));     return ctx.hmac_digest_len;}/** * Mode Config Reply * * Generates a reply stream containing Mode Config information (eg: IP, DNS, WINS) * * @param st State structure * @param resp Type of reply (int) * @param rbody Body of the reply (stream) * @param ap_id ISAMA Identifier  * @return stf_status STF_OK or STF_INTERNAL_ERROR */stf_status modecfg_resp(struct state *st			,unsigned int resp			,pb_stream *rbody			,u_int16_t replytype			,bool hackthat			,u_int16_t ap_id){    unsigned char *r_hash_start,*r_hashval;    /* START_HASH_PAYLOAD(rbody, ISAKMP_NEXT_ATTR); */    {      pb_stream hash_pbs;       int np = ISAKMP_NEXT_ATTR;      if (!out_generic(np, &isakmp_hash_desc, rbody, &hash_pbs)) 	return STF_INTERNAL_ERROR;       r_hashval = hash_pbs.cur;	/* remember where to plant value */       if (!out_zero(st->st_oakley.hasher->hash_digest_len, &hash_pbs, "HASH")) 	return STF_INTERNAL_ERROR;       close_output_pbs(&hash_pbs);       r_hash_start = (rbody)->cur;	/* hash from after HASH payload */     }    /* ATTR out */    {	struct  isakmp_mode_attr attrh;	struct isakmp_attribute attr;	pb_stream strattr,attrval;	int attr_type;	struct internal_addr ia;	int dns_idx, wins_idx;	bool dont_advance;	attrh.isama_np = ISAKMP_NEXT_NONE;	attrh.isama_type = replytype;	attrh.isama_identifier = ap_id;	if(!out_struct(&attrh, &isakmp_attr_desc, rbody, &strattr))	    return STF_INTERNAL_ERROR;		zero(&ia);	get_internal_addresses(st->st_connection, &ia);	if(!isanyaddr(&ia.dns[0]))	/* We got DNS addresses, answer with those */		resp |= LELEM(INTERNAL_IP4_DNS);	else		resp &= ~LELEM(INTERNAL_IP4_DNS);	if(!isanyaddr(&ia.wins[0]))	/* We got WINS addresses, answer with those */		resp |= LELEM(INTERNAL_IP4_NBNS);	else		resp &= ~LELEM(INTERNAL_IP4_NBNS);	if(hackthat) {	    if(memcmp(&st->st_connection->spd.that.client.addr		      ,&ia.ipaddr		      ,sizeof(ia.ipaddr)) != 0)		{		    /* Make the Internal IP address and Netmask as		     * that client address */		    st->st_connection->spd.that.client.addr = ia.ipaddr;		    st->st_connection->spd.that.client.maskbits = 32;		    st->st_connection->spd.that.has_client = TRUE;		}	}	attr_type = 0;	dns_idx = 0;	wins_idx = 0;	while(resp != 0)	{	    dont_advance = FALSE;	    if(resp & 1)	    {			const unsigned char *byte_ptr;		unsigned int len;		/* ISAKMP attr out */		attr.isaat_af_type = attr_type | ISAKMP_ATTR_AF_TLV;		out_struct(&attr, &isakmp_xauth_attribute_desc, &strattr, &attrval);		switch(attr_type)		{		        case INTERNAL_IP4_ADDRESS:		                len = addrbytesptr(&ia.ipaddr, &byte_ptr); 				out_raw(byte_ptr,len,&attrval,"IP4_addr"); 				break;			case INTERNAL_IP4_NETMASK:			    { 				    unsigned int  mask;#if 0				char mask[4],bits[8]={0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe};				int t,m=st->st_connection->that.host_addr.maskbit;				for(t=0;t<4;t++)				{				    if(m < 8) 					mask[t] = bits[m];				    else					mask[t] = 0xff;				    m -= 8;				}#endif				     				if (st->st_connection->spd.this.client.maskbits == 0) 					mask = 0; 				else 					mask = 0xffffffff * 1;				out_raw(&mask,4,&attrval,"IP4_mask");			    }			    break;			case INTERNAL_IP4_SUBNET:			    {				char mask[4],bits[8]={0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe};				int t,m=st->st_connection->spd.this.client.maskbits;				for(t=0;t<4;t++)				{				    if(m < 8) 					mask[t] = bits[m];				    else					mask[t] = 0xff;				    m -= 8;				    if(m < 0) m=0;				}				len = addrbytesptr(&st->st_connection->spd.this.client.addr, &byte_ptr);				out_raw(byte_ptr,len,&attrval,"IP4_subnet");				out_raw(mask,sizeof(mask),&attrval,"IP4_submsk"); 				    			    }			    break;		    			case INTERNAL_IP4_DNS: 				len = addrbytesptr(&ia.dns[dns_idx++], &byte_ptr); 				out_raw(byte_ptr,len,&attrval,"IP4_dns");				if(dns_idx < 2 && !isanyaddr(&ia.dns[dns_idx]))				{					dont_advance = TRUE;				} 				break;			case INTERNAL_IP4_NBNS: 				len = addrbytesptr(&ia.wins[wins_idx++], &byte_ptr); 				out_raw(byte_ptr,len,&attrval,"IP4_wins");				if(wins_idx < 2 && !isanyaddr(&ia.wins[wins_idx]))				{					dont_advance = TRUE;				} 				break;		default:		    openswan_log("attempt to send unsupported mode cfg attribute %s."			 , enum_show(&modecfg_attr_names, attr_type));		    break;		}		close_output_pbs(&attrval);	    }	    if (!dont_advance) {		    attr_type++;		    resp >>= 1;	    }	}	close_message(&strattr);    }    xauth_mode_cfg_hash(r_hashval,r_hash_start,rbody->cur,st);        close_message(rbody);    encrypt_message(rbody, st);    return STF_OK;}/** Set MODE_CONFIG data to client.  Pack IP Addresses, DNS, etc... and ship *  * @param st State Structure * @return stf_status */stf_status modecfg_send_set(struct state *st){	pb_stream reply,rbody;	char buf[256];	/* set up reply */	init_pbs(&reply, buf, sizeof(buf), "ModecfgR1");	st->st_state = STATE_MODE_CFG_R1;	/* HDR out */	{		struct isakmp_hdr hdr;		zero(&hdr);	/* default to 0 */		hdr.isa_version = ISAKMP_MAJOR_VERSION << ISA_MAJ_SHIFT | ISAKMP_MINOR_VERSION;		hdr.isa_np = ISAKMP_NEXT_HASH;		hdr.isa_xchg = ISAKMP_XCHG_MODE_CFG;		hdr.isa_flags = ISAKMP_FLAG_ENCRYPTION;		memcpy(hdr.isa_icookie, st->st_icookie, COOKIE_SIZE);		memcpy(hdr.isa_rcookie, st->st_rcookie, COOKIE_SIZE);		hdr.isa_msgid = st->st_msgid_phase15;		if (!out_struct(&hdr, &isakmp_hdr_desc, &reply, &rbody))		{			return STF_INTERNAL_ERROR;		}	}#define MODECFG_SET_ITEM ( LELEM(INTERNAL_IP4_ADDRESS) | LELEM(INTERNAL_IP4_SUBNET) | LELEM(INTERNAL_IP4_NBNS) | LELEM(INTERNAL_IP4_DNS) )	modecfg_resp(st		     ,MODECFG_SET_ITEM		     ,&rbody 		     ,ISAKMP_CFG_SET		     ,TRUE		     ,0/* XXX ID */);#undef MODECFG_SET_ITEM	clonetochunk(st->st_tpacket, reply.start, pbs_offset(&reply)			, "ModeCfg set");	/* Transmit */	send_packet(st, "ModeCfg set", TRUE);	/* RETRANSMIT if Main, SA_REPLACE if Aggressive */	if(st->st_event->ev_type != EVENT_RETRANSMIT	   && st->st_event->ev_type != EVENT_NULL)	{			delete_event(st);		event_schedule(EVENT_RETRANSMIT,EVENT_RETRANSMIT_DELAY_0,st);	}	return STF_OK;}/** Set MODE_CONFIG data to client.  Pack IP Addresses, DNS, etc... and ship *  * @param st State Structure * @return stf_status */stf_status modecfg_start_set(struct state *st){    if(st->st_msgid_phase15 == 0) {	/* pick a new message id */	st->st_msgid_phase15 = generate_msgid(st);    }    st->hidden_variables.st_modecfg_vars_set = TRUE;    return modecfg_send_set(st);}/** Send XAUTH credential request (username + password request) * @param st State * @return stf_status */stf_status xauth_send_request(struct state *st){    pb_stream reply;    pb_stream rbody;    char buf[256];    u_char *r_hash_start,*r_hashval;    /* set up reply */    init_pbs(&reply, buf, sizeof(buf), "xauth_buf");    openswan_log("XAUTH: Sending Username/Password request (XAUTH_R0)");    /* this is the beginning of a new exchange */    st->st_msgid_phase15 = generate_msgid(st);    st->st_state = STATE_XAUTH_R0;    /* HDR out */    {	struct isakmp_hdr hdr;	zero(&hdr);	/* default to 0 */	hdr.isa_version = ISAKMP_MAJOR_VERSION << ISA_MAJ_SHIFT | ISAKMP_MINOR_VERSION;	hdr.isa_np = ISAKMP_NEXT_HASH;	hdr.isa_xchg = ISAKMP_XCHG_MODE_CFG;	hdr.isa_flags = ISAKMP_FLAG_ENCRYPTION;	memcpy(hdr.isa_icookie, st->st_icookie, COOKIE_SIZE);	memcpy(hdr.isa_rcookie, st->st_rcookie, COOKIE_SIZE);	hdr.isa_msgid = st->st_msgid_phase15;	if (!out_struct(&hdr, &isakmp_hdr_desc, &reply, &rbody))	{	    return STF_INTERNAL_ERROR;	}    }    START_HASH_PAYLOAD(rbody, ISAKMP_NEXT_ATTR);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美videossexotv100| 精品少妇一区二区三区在线播放| 欧美日韩国产综合草草| 久久久久99精品国产片| 中文字幕一区二区三区乱码在线| 男女性色大片免费观看一区二区| 国产成人夜色高潮福利影视| 精品污污网站免费看| 精品欧美一区二区久久 | 亚洲欧美日韩一区| 精品一区二区三区免费观看 | 国产精品亚洲成人| 欧美另类z0zxhd电影| 亚洲人一二三区| 国产久卡久卡久卡久卡视频精品| 欧美精品一级二级三级| 国产精品久久久久久久岛一牛影视| 天堂成人国产精品一区| 91一区二区在线| 国产日韩一级二级三级| 美腿丝袜亚洲色图| 欧美另类久久久品| 国产午夜亚洲精品羞羞网站| 91精品欧美一区二区三区综合在 | 亚洲国产精品二十页| 一区二区三区成人在线视频| 国产成人在线观看| 久久精品视频在线免费观看| 韩国av一区二区| 久久亚洲捆绑美女| 国产在线精品一区二区夜色| 精品久久久久久久久久久久久久久| 天使萌一区二区三区免费观看| 日本高清免费不卡视频| 一区二区三区免费在线观看| 欧美午夜精品免费| 午夜亚洲国产au精品一区二区| 精品视频在线视频| 免费高清视频精品| 久久先锋影音av| 盗摄精品av一区二区三区| 国产精品久久夜| 色婷婷一区二区| 亚洲综合偷拍欧美一区色| 大尺度一区二区| 日韩美一区二区三区| 亚洲三级小视频| 亚洲欧美另类综合偷拍| 欧美在线你懂得| 最新不卡av在线| 国产一区在线观看视频| 日韩免费视频一区二区| 性久久久久久久久久久久| 色www精品视频在线观看| 国产精品网站一区| 国产精品一区二区无线| 欧美成人精精品一区二区频| 视频一区二区三区入口| 久久久久国色av免费看影院| 日韩1区2区日韩1区2区| 4hu四虎永久在线影院成人| 一区二区视频免费在线观看| 91亚洲永久精品| 亚洲精品国产第一综合99久久 | 欧美日韩国产在线观看| 亚洲欧美精品午睡沙发| 99r精品视频| 一区二区三区加勒比av| 国产网站一区二区| 国产+成+人+亚洲欧洲自线| 日本一区二区三区高清不卡| 国产成人自拍网| 国产欧美一区二区三区在线看蜜臀 | 日韩精品久久理论片| 欧美色图天堂网| 一区二区三区欧美久久| 欧美亚洲高清一区二区三区不卡| 亚洲免费观看高清完整| 欧美三级欧美一级| 亚洲成人av电影| av午夜精品一区二区三区| 精品国产91洋老外米糕| 国产成人精品www牛牛影视| 国产精品免费视频观看| 欧美日韩一区精品| 天天射综合影视| 日韩精品中文字幕一区| 从欧美一区二区三区| 亚洲精品日日夜夜| 在线播放国产精品二区一二区四区| 久久99精品久久久久久国产越南| 91黄色小视频| 午夜精品国产更新| 欧美性色欧美a在线播放| 狠狠v欧美v日韩v亚洲ⅴ| 中文av字幕一区| www.欧美亚洲| 亚洲男人都懂的| 欧美剧在线免费观看网站 | 日韩欧美中文字幕制服| 国产精品一区二区不卡| 亚洲三级在线观看| 欧美一级日韩不卡播放免费| av高清不卡在线| 蜜桃视频在线观看一区二区| 国产蜜臀av在线一区二区三区| 麻豆91在线观看| wwwwxxxxx欧美| 精品少妇一区二区三区日产乱码 | 最新高清无码专区| 欧美日韩另类国产亚洲欧美一级| 免费观看成人鲁鲁鲁鲁鲁视频| 亚洲色欲色欲www| 欧美亚洲国产怡红院影院| 成人在线视频一区| 日本午夜精品一区二区三区电影| 国产精品人成在线观看免费 | 制服丝袜中文字幕一区| 波波电影院一区二区三区| 人人精品人人爱| 亚洲一区在线电影| 亚洲人成网站精品片在线观看| 欧美一区二区三区四区五区| 一本到高清视频免费精品| 国产美女精品人人做人人爽| 亚洲男人天堂av网| 性做久久久久久久久| 亚洲欧美日韩国产手机在线| 国产精品久久久久久久久动漫 | 国产成人在线视频免费播放| 亚洲午夜成aⅴ人片| 亚洲欧美偷拍另类a∨色屁股| 精品国产123| 日韩午夜激情电影| 色婷婷综合久久久中文一区二区| 国产福利电影一区二区三区| 麻豆精品在线视频| 中文字幕不卡在线播放| 亚洲激情男女视频| 亚洲欧美日本韩国| 亚洲欧美另类久久久精品2019| 欧美精品一区二区三区蜜臀| 日韩欧美一区二区免费| 在线电影院国产精品| 欧美日韩一区二区欧美激情| 欧美日韩视频在线第一区 | 国产一区二区精品久久91| 一区二区三区av电影| 亚洲一区二区三区视频在线| 亚洲视频香蕉人妖| 中文字幕亚洲不卡| 亚洲欧美一区二区在线观看| 亚洲女同一区二区| 中文字幕中文字幕中文字幕亚洲无线| 日韩精品一区二区三区视频播放| 欧美性大战久久久久久久| 91精品国产综合久久久久久久久久| 91麻豆国产福利在线观看| 午夜伊人狠狠久久| 亚洲二区视频在线| 日韩不卡一区二区| 免费在线观看一区| 日韩一区欧美二区| 男女激情视频一区| 国产伦理精品不卡| 午夜精品福利在线| 91影院在线免费观看| 在线这里只有精品| 日韩小视频在线观看专区| 久久综合九色综合97_久久久| 久久综合九色综合欧美98| 国产精品国产三级国产a| 国产精品久久久久久妇女6080| 亚洲精品老司机| 国产精品精品国产色婷婷| 久久国产精品99精品国产| 国产成人免费在线| 91玉足脚交白嫩脚丫在线播放| 欧美午夜片在线观看| 欧美丰满嫩嫩电影| 久久久.com| 亚洲午夜电影在线| 久久99精品一区二区三区三区| 色悠悠久久综合| 99久久久无码国产精品| 国产欧美1区2区3区| 亚洲一区二区三区四区在线免费观看 | 亚洲午夜在线观看视频在线| 日韩黄色片在线观看| 国产精品亚洲专一区二区三区| 精品一二线国产| 国产一区二区三区综合| 欧美日韩国产首页| 久久精品综合网| 亚洲午夜视频在线| aaa亚洲精品| 日韩精品一区二区三区在线观看| 在线观看91精品国产入口| 欧美三级日韩三级国产三级| 亚洲国产欧美在线|