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

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

?? ssl.c

?? 一個開源的VPN原碼
?? C
?? 第 1 頁 / 共 5 頁
字號:
/* *  OpenVPN -- An application to securely tunnel IP networks *             over a single UDP port, with support for TLS-based *             session authentication and key exchange, *             packet encryption, packet authentication, and *             packet compression. * *  Copyright (C) 2002 James Yonan <jim@yonan.net> * *  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. * *  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. * *  You should have received a copy of the GNU General Public License *  along with this program (see the file COPYING included with this *  distribution); if not, write to the Free Software Foundation, Inc., *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *//* * The routines in this file deal with dynamically negotiating * the data channel HMAC and cipher keys through a TLS session. * * Both the TLS session and the data channel are multiplexed * over the same UDP port. */#include "config.h"#if defined(USE_CRYPTO) && defined(USE_SSL)#include "syshead.h"#include "ssl.h"#include "error.h"#include "common.h"#include "socket.h"#include "thread.h"#include "misc.h"#include "fdmisc.h"#include "interval.h"#include "memdbg.h"#ifdef BIO_DEBUGstatic FILE *biofp;static bool biofp_toggle;static time_t biofp_last_open;static const int biofp_reopen_interval = 600;static voidclose_biofp(){  if (biofp)    {      ASSERT (!fclose (biofp));      biofp = NULL;    }}static voidopen_biofp(){  const time_t current = time (NULL);  const pid_t pid = getpid ();  if (biofp_last_open + biofp_reopen_interval < current)    close_biofp();  if (!biofp)    {      char fn[256];      snprintf(fn, sizeof(fn), "bio/%d-%d.log", pid, biofp_toggle);      biofp = fopen (fn, "w");      ASSERT (biofp);      biofp_last_open = time (NULL);      biofp_toggle ^= 1;    }}static voidbio_debug_data (const char *mode, BIO *bio, uint8_t *buf, int len, const char *desc){  if (len > 0)    {      open_biofp();      fprintf(biofp, "BIO_%s %s time=" time_format " bio=" ptr_format " len=%d data=%s\n",	      mode, desc, time (NULL), bio, len, format_hex (buf, len, 0));      fflush (biofp);    }}static voidbio_debug_oc (const char *mode, BIO *bio){  open_biofp();  fprintf(biofp, "BIO %s time=" time_format " bio=" ptr_format "\n",	  mode, time (NULL), bio);  fflush (biofp);}#endif/* * Max number of bytes we will add * for data structures common to both * data and control channel packets. * (opcode only).  */voidtls_adjust_frame_parameters(struct frame *frame){  frame->extra_frame += 1; /* space for opcode */}/* * Max number of bytes we will add * to control channel packet.  */static voidtls_init_control_channel_frame_parameters(const struct frame *data_channel_frame,					  struct frame *frame){  /*   * frame->extra_frame is already initialized with tls_auth buffer requirements,   * if --tls-auth is enabled.   */  /* set extra_frame */  tls_adjust_frame_parameters(frame);  reliable_ack_adjust_frame_parameters(frame, CONTROL_SEND_ACK_MAX);  frame->extra_frame += SID_SIZE;  frame->extra_frame += sizeof (packet_id_type);  /* finalize parameters based on data_channel_frame */  frame->mtu = MTU_EXTRA_SIZE (data_channel_frame) - frame->extra_frame;  frame->extra_buffer += frame->extra_frame;}voidinit_ssl_lib (){  SSL_library_init ();  SSL_load_error_strings ();  OpenSSL_add_all_algorithms ();  init_crypto_lib();  /*   * If you build the OpenSSL library and OpenVPN with   * CRYPTO_MDEBUG, you will get a listing of OpenSSL   * memory leaks on program termination.   */#ifdef CRYPTO_MDEBUG  CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);#endif}voidfree_ssl_lib (){#ifdef CRYPTO_MDEBUG  FILE* fp = fopen ("sdlog", "w");  ASSERT (fp);  CRYPTO_mem_leaks_fp (fp);  fclose (fp);#endif  EVP_cleanup ();  ERR_free_strings ();}/* * OpenSSL library calls back here if the private key * is protected by a password. */intpem_password_callback (char *buf, int size, int rwflag, void *u){#ifdef HAVE_GETPASS  static char passbuf[256];  if (!strlen (passbuf))    {      char *gp = getpass ("Enter PEM pass phrase:");      strncpynt (passbuf, gp, sizeof (passbuf));      memset (gp, 0, strlen (gp));    }  if (buf)    {      if (!strlen (passbuf))	msg (M_FATAL, "TLS Error: need PEM password for private key");      strncpynt (buf, passbuf, size);      CLEAR (passbuf);      return strlen (buf);    }#else  msg (M_FATAL, "Sorry but I can't read a password from the console because this operating system or C library doesn't support the getpass() function");#endif  return 0;}/* * OpenSSL callback to get a temporary RSA key, mostly * used for export ciphers. */static RSA *tmp_rsa_cb (SSL * s, int is_export, int keylength){  static RSA *rsa_tmp = NULL;  if (rsa_tmp == NULL)    {      msg (D_HANDSHAKE, "Generating temp (%d bit) RSA key", keylength);      rsa_tmp = RSA_generate_key (keylength, RSA_F4, NULL, NULL);    }  return (rsa_tmp);}/* make cp safe to be passed to system() */static voidsystem_safe_string (char *cp){  int c;  while (c = *cp)    {      if (isalnum (c)	  || c == '/'	  || c == '.' || c == '@' || c == '_' || c == '-' || c == '=')	;      else	*cp = '.';      ++cp;    }}/* * Our verify callback function -- check * that an incoming peer certificate is good. */static const char *verify_command;voidtls_set_verify_command (const char *cmd){  verify_command = cmd;}static intverify_callback (int preverify_ok, X509_STORE_CTX * ctx){  char txt[512];  X509_NAME_oneline (X509_get_subject_name (ctx->current_cert), txt,		     sizeof (txt));  txt[sizeof (txt) - 1] = '\0';  system_safe_string (txt);  if (!preverify_ok)    {      /* Remote site specified a certificate, but it's not correct */      msg (D_TLS_ERRORS, "VERIFY ERROR: depth=%d, error=%s: %s",	   ctx->error_depth, X509_verify_cert_error_string (ctx->error), txt);      return 0;			/* Reject connection */    }  if (verify_command)    {      char command[512];      struct buffer out;      int ret;      buf_set_write (&out, command, sizeof (command));      buf_printf (&out, "%s %d %s", verify_command, ctx->error_depth, txt);      msg (D_TLS_DEBUG, "executing verify command: %s", command);      ret = openvpn_system (command);      if (ret != -1 && WEXITSTATUS (ret) == 0)	{	  msg (D_HANDSHAKE, "VERIFY SCRIPT OK: depth=%d, %s",	       ctx->error_depth, txt);	  return 1;		/* Accept connection */	}      else	{	  if (ret == -1 || WEXITSTATUS (ret) == 127)	    msg (M_ERR, "Verify command failed to execute: %s", command);	  msg (D_HANDSHAKE, "VERIFY SCRIPT ERROR: depth=%d, %s",	       ctx->error_depth, txt);	  return 0;		/* Reject connection */	}    }  else    {      msg (D_HANDSHAKE, "VERIFY OK: depth=%d, %s", ctx->error_depth, txt);      return 1;			/* Accept connection */    }}/* * Print debugging information on SSL/TLS session negotiation. */static voidinfo_callback (INFO_CALLBACK_SSL_CONST SSL * s, int where, int ret){  if (where & SSL_CB_LOOP)    {      msg (D_HANDSHAKE_VERBOSE, "SSL state (%s): %s",	   where & SSL_ST_CONNECT ? "connect" :	   where & SSL_ST_ACCEPT ? "accept" :	   "undefined", SSL_state_string_long (s));    }  else if (where & SSL_CB_ALERT)    {      msg (D_HANDSHAKE_VERBOSE, "SSL alert (%s): %s: %s",	   where & SSL_CB_READ ? "read" : "write",	   SSL_alert_type_string_long (ret),	   SSL_alert_desc_string_long (ret));    }}/* * Initialize SSL context. * All files are in PEM format. */SSL_CTX *init_ssl (bool server,	  const char *ca_file,	  const char *dh_file,	  const char *cert_file,	  const char *priv_key_file,	  const char *cipher_list){  SSL_CTX *ctx;  DH *dh;  BIO *bio;  if (server)    {      ctx = SSL_CTX_new (TLSv1_server_method ());      if (ctx == NULL)	msg (M_SSLERR, "SSL_CTX_new TLSv1_server_method");      SSL_CTX_set_tmp_rsa_callback (ctx, tmp_rsa_cb);      /* Get Diffie Hellman Parameters */      if (!(bio = BIO_new_file (dh_file, "r")))	msg (M_SSLERR, "Cannot open %s for DH parameters", dh_file);      dh = PEM_read_bio_DHparams (bio, NULL, NULL, NULL);      BIO_free (bio);      if (!dh)	msg (M_SSLERR, "Cannot load DH parameters from %s", dh_file);      if (!SSL_CTX_set_tmp_dh (ctx, dh))	msg (M_SSLERR, "SSL_CTX_set_tmp_dh");      msg (D_TLS_DEBUG_LOW, "Diffie-Hellman initialized with %d bit key",	   8 * DH_size (dh));      DH_free (dh);    }  else				/* if client */    {      ctx = SSL_CTX_new (TLSv1_client_method ());      if (ctx == NULL)	msg (M_SSLERR, "SSL_CTX_new TLSv1_client_method");    }  /* Set SSL options */  SSL_CTX_set_session_cache_mode (ctx, SSL_SESS_CACHE_OFF);  SSL_CTX_set_options (ctx, SSL_OP_SINGLE_DH_USE);  /* Set callback for getting password from user to decrypt private key */  SSL_CTX_set_default_passwd_cb (ctx, pem_password_callback);#if 1  /* Load Certificate */  if (!SSL_CTX_use_certificate_file (ctx, cert_file, SSL_FILETYPE_PEM))    msg (M_SSLERR, "Cannot load certificate file %s", cert_file);#else  /* Load Certificate -- for some reason, this function sometimes     inexplicably fails during restarts with a PEM_R_NO_START_LINE     error. */  if (!SSL_CTX_use_certificate_chain_file (ctx, cert_file))    msg (M_SSLERR, "Cannot load certificate chain file %s", cert_file);#endif  /* Load Private Key */  if (!SSL_CTX_use_PrivateKey_file (ctx, priv_key_file, SSL_FILETYPE_PEM))    msg (M_SSLERR, "Cannot load private key file %s", priv_key_file);  warn_if_group_others_accessible (priv_key_file);  /* Check Private Key */  if (!SSL_CTX_check_private_key (ctx))    msg (M_SSLERR, "Private key does not match the certificate");  /* Load CA file for verifying peer supplied certificate */  if (!SSL_CTX_load_verify_locations (ctx, ca_file, NULL))    msg (M_SSLERR, "Cannot load CA certificate file %s (SSL_CTX_load_verify_locations)", ca_file);#if 1  /* Load names of CAs from file and use it as a client CA list */  {    STACK_OF(X509_NAME) *cert_names;    cert_names = SSL_load_client_CA_file (ca_file);    if (!cert_names)      msg (M_SSLERR, "Cannot load CA certificate file %s (SSL_load_client_CA_file)", ca_file);    SSL_CTX_set_client_CA_list (ctx, cert_names);  }#endif  /* Require peer certificate verification */  SSL_CTX_set_verify (ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,		      verify_callback);  /* Connection information callback */  SSL_CTX_set_info_callback (ctx, info_callback);  /* Allowable ciphers */  if (cipher_list)    {      if (!SSL_CTX_set_cipher_list (ctx, cipher_list))	msg (M_SSLERR, "Problem with cipher list: %s", cipher_list);    }  return ctx;}/* * Print a one line summary of SSL/TLS session handshake. */static voidprint_details (SSL * c_ssl, const char *prefix){  SSL_CIPHER *ciph;  X509 *cert;  char s1[256];  char s2[256];  s1[0] = s2[0] = 0;  ciph = SSL_get_current_cipher (c_ssl);  snprintf (s1, sizeof (s1), "%s %s, cipher %s %s",	    prefix,	    SSL_get_version (c_ssl),	    SSL_CIPHER_get_version (ciph), SSL_CIPHER_get_name (ciph));  cert = SSL_get_peer_certificate (c_ssl);  if (cert != NULL)    {      EVP_PKEY *pkey = X509_get_pubkey (cert);      if (pkey != NULL)	{	  if (pkey->type == EVP_PKEY_RSA && pkey->pkey.rsa != NULL	      && pkey->pkey.rsa->n != NULL)	    {	      snprintf (s2, sizeof (s2), ", %d bit RSA",			BN_num_bits (pkey->pkey.rsa->n));	    }	  else if (pkey->type == EVP_PKEY_DSA && pkey->pkey.dsa != NULL		   && pkey->pkey.dsa->p != NULL)	    {	      snprintf (s2, sizeof (s2), ", %d bit DSA",			BN_num_bits (pkey->pkey.dsa->p));	    }	  EVP_PKEY_free (pkey);	}      X509_free (cert);    }  /* The SSL API does not allow us to look at temporary RSA/DH keys,   * otherwise we should print their lengths too */  msg (D_HANDSHAKE, "%s%s", s1, s2);}/* * Show the TLS ciphers that are available for us to use * in the OpenSSL library. */voidshow_available_tls_ciphers (){  SSL_CTX *ctx;  SSL *ssl;  const char *cipher_name;  int priority = 0;  ctx = SSL_CTX_new (TLSv1_method ());  if (!ctx)    msg (M_SSLERR, "Cannot create SSL_CTX object");  ssl = SSL_new (ctx);  if (!ssl)    msg (M_SSLERR, "Cannot create SSL object");  printf ("Available TLS Ciphers,\n");  printf ("listed in order of preference:\n\n");  while (cipher_name = SSL_get_cipher_list (ssl, priority++))

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品自拍在线| 久久久不卡影院| 日韩欧美国产三级电影视频| 久久亚洲精精品中文字幕早川悠里| 久久久国际精品| 亚洲精品乱码久久久久久久久| 亚洲午夜国产一区99re久久| 久久99日本精品| av电影在线观看一区| 欧美日韩国产a| 久久精品视频一区| 亚洲一卡二卡三卡四卡无卡久久 | 国产成人精品网址| 91高清视频在线| 亚洲精品一线二线三线无人区| 欧美国产日韩亚洲一区| 午夜婷婷国产麻豆精品| 成人综合婷婷国产精品久久免费| 欧洲精品在线观看| 国产婷婷精品av在线| 亚洲观看高清完整版在线观看| 国产精品一级黄| 欧美精品三级在线观看| 国产欧美日本一区二区三区| 一区二区三区欧美| 国产乱子伦一区二区三区国色天香| 色琪琪一区二区三区亚洲区| 久久亚洲综合色一区二区三区| 一区二区三区在线视频观看 | 欧美大片免费久久精品三p| 中文字幕亚洲欧美在线不卡| 免费人成精品欧美精品| 色老头久久综合| 欧美国产1区2区| 毛片基地黄久久久久久天堂| 在线观看中文字幕不卡| 欧美激情一区在线观看| 麻豆国产精品官网| 欧美日韩黄视频| 亚洲欧洲中文日韩久久av乱码| 久久精品久久精品| 欧美男男青年gay1069videost| 国产精品久久久久影视| 国产在线精品一区在线观看麻豆| 欧美色图片你懂的| 136国产福利精品导航| 国产成人在线免费| 精品久久免费看| 日韩成人午夜电影| 欧美三级视频在线播放| 亚洲欧洲色图综合| 国产v综合v亚洲欧| 久久丝袜美腿综合| 美女在线视频一区| 337p亚洲精品色噜噜狠狠| 亚洲夂夂婷婷色拍ww47| 色综合天天综合网天天狠天天| 欧美激情综合网| 国产精品一区二区免费不卡| 精品成人a区在线观看| 日韩国产欧美在线视频| 91丨九色丨蝌蚪富婆spa| 欧美国产综合一区二区| 国产精品综合av一区二区国产馆| 日韩一级黄色大片| 免费在线看成人av| 日韩欧美一区二区视频| 麻豆精品一二三| 日韩精品影音先锋| 久久99精品国产91久久来源| 欧美一卡二卡三卡四卡| 奇米精品一区二区三区在线观看| 欧美精品免费视频| 日精品一区二区| 欧美精品色综合| 日本成人在线看| 91精品国产aⅴ一区二区| 蜜乳av一区二区| 精品免费99久久| 国产一区二区三区四区五区美女 | 美女看a上一区| 精品国产乱码久久久久久老虎| 蓝色福利精品导航| 久久精品一区二区三区不卡| 成人性生交大片免费看视频在线| 中文字幕一区二区三区不卡在线 | 综合精品久久久| 色播五月激情综合网| 亚洲狠狠丁香婷婷综合久久久| 日本道在线观看一区二区| 亚洲国产你懂的| 69堂国产成人免费视频| 精品一区二区三区久久| 国产亚洲人成网站| 91丨porny丨首页| 午夜精品福利久久久| 欧美大胆人体bbbb| 高清在线成人网| 艳妇臀荡乳欲伦亚洲一区| 91精品国产欧美一区二区| 国产一区二区三区电影在线观看| 国产精品毛片久久久久久久 | 免费看欧美女人艹b| 久久久高清一区二区三区| 97成人超碰视| 日韩av电影免费观看高清完整版| 久久嫩草精品久久久久| 一本一本久久a久久精品综合麻豆| 调教+趴+乳夹+国产+精品| 欧美精品一区二区不卡| 一本久道久久综合中文字幕| 天天色图综合网| 中文久久乱码一区二区| 欧美日韩国产一区| 国产不卡一区视频| 亚洲综合免费观看高清完整版在线 | 欧美日韩二区三区| 国产一本一道久久香蕉| 亚洲欧美日韩成人高清在线一区| 538在线一区二区精品国产| 国产激情91久久精品导航| 亚洲婷婷在线视频| 欧美成人女星排行榜| 99re热视频这里只精品| 免费一级片91| 国产精品成人午夜| 7777精品久久久大香线蕉| 成人av在线一区二区| 日本亚洲视频在线| 国产精品国产精品国产专区不片| 欧美精品在欧美一区二区少妇| 国产精品一区三区| 日韩在线播放一区二区| 国产精品久久久久久久久免费桃花| 欧美亚洲日本国产| 成人午夜激情影院| 日本不卡一二三区黄网| 亚洲精品写真福利| 久久久久综合网| 51精品国自产在线| 色婷婷av一区| 成人综合婷婷国产精品久久蜜臀 | 日韩精品在线看片z| 欧美午夜在线一二页| 国产福利精品一区| 日本在线播放一区二区三区| 亚洲人吸女人奶水| 国产亚洲精品7777| 欧美电视剧免费观看| 欧美日韩国产高清一区二区 | 亚洲va中文字幕| 1区2区3区国产精品| 国产亚洲一区二区在线观看| 欧美一区二区三区日韩| 欧美性猛片xxxx免费看久爱| 99在线精品视频| 国产91富婆露脸刺激对白| 国内国产精品久久| 老司机精品视频线观看86| 性久久久久久久久久久久 | 欧美酷刑日本凌虐凌虐| 在线日韩av片| 色哟哟在线观看一区二区三区| 国产剧情一区二区| 久久99国产乱子伦精品免费| 日韩一区欧美二区| 亚洲444eee在线观看| 亚洲综合无码一区二区| 亚洲黄色尤物视频| 国产精品二三区| 国产精品美女视频| 国产精品丝袜一区| 国产精品色眯眯| 国产精品丝袜黑色高跟| 国产女同互慰高潮91漫画| 国产午夜精品久久久久久久| 欧美精品一区二区三区在线播放| 91精品久久久久久蜜臀| 91精品国产综合久久久久久| 欧美日韩不卡一区二区| 欧美夫妻性生活| 日韩一卡二卡三卡| 亚洲永久免费av| 亚洲同性同志一二三专区| 亚洲欧美偷拍另类a∨色屁股| 中文字幕人成不卡一区| 亚洲手机成人高清视频| 亚洲免费观看高清完整版在线观看 | 日韩精品成人一区二区三区| 日本中文字幕一区| 免费成人在线影院| 久久激五月天综合精品| 极品美女销魂一区二区三区免费| 另类专区欧美蜜桃臀第一页| 久久成人18免费观看| 韩国视频一区二区| 国产成人精品免费看| 91在线云播放| 精品视频资源站| 日韩限制级电影在线观看|