Artifact
3805fea315843695276a839a18494418438ed90f:
0000: 2f 2a 0a 20 2a 20 43 6f 70 79 72 69 67 68 74 20  /*. * Copyright 
0010: 28 43 29 20 31 39 39 37 2d 32 30 30 30 20 4d 61  (C) 1997-2000 Ma
0020: 74 74 20 4e 65 77 6d 61 6e 20 3c 6d 61 74 74 40  tt Newman <matt@
0030: 6e 6f 76 61 64 69 67 6d 2e 63 6f 6d 3e 0a 20 2a  novadigm.com>. *
0040: 0a 20 2a 20 54 4c 53 20 28 61 6b 61 20 53 53 4c  . * TLS (aka SSL
0050: 29 20 43 68 61 6e 6e 65 6c 20 2d 20 63 61 6e 20  ) Channel - can 
0060: 62 65 20 6c 61 79 65 72 65 64 20 6f 6e 20 61 6e  be layered on an
0070: 79 20 62 69 2d 64 69 72 65 63 74 69 6f 6e 61 6c  y bi-directional
0080: 0a 20 2a 20 54 63 6c 5f 43 68 61 6e 6e 65 6c 20  . * Tcl_Channel 
0090: 28 4e 6f 74 65 3a 20 52 65 71 75 69 72 65 73 20  (Note: Requires 
00a0: 54 72 66 20 43 6f 72 65 20 50 61 74 63 68 29 0a  Trf Core Patch).
00b0: 20 2a 0a 20 2a 20 54 68 69 73 20 77 61 73 20 62   *. * This was b
00c0: 75 69 6c 74 20 66 72 6f 6d 20 73 63 72 61 74 63  uilt from scratc
00d0: 68 20 62 61 73 65 64 20 75 70 6f 6e 20 6f 62 73  h based upon obs
00e0: 65 72 76 61 74 69 6f 6e 20 6f 66 20 4f 70 65 6e  ervation of Open
00f0: 53 53 4c 20 30 2e 39 2e 32 42 0a 20 2a 0a 20 2a  SSL 0.9.2B. *. *
0100: 20 41 64 64 69 74 69 6f 6e 20 63 72 65 64 69 74   Addition credit
0110: 20 69 73 20 64 75 65 20 66 6f 72 20 41 6e 64 72   is due for Andr
0120: 65 61 73 20 4b 75 70 72 69 65 73 20 28 61 2e 6b  eas Kupries (a.k
0130: 75 70 72 69 65 73 40 77 65 73 74 65 6e 64 2e 63  upries@westend.c
0140: 6f 6d 29 2c 20 66 6f 72 0a 20 2a 20 70 72 6f 76  om), for. * prov
0150: 69 64 69 6e 67 20 74 68 65 20 54 63 6c 5f 52 65  iding the Tcl_Re
0160: 70 6c 61 63 65 43 68 61 6e 6e 65 6c 20 6d 65 63  placeChannel mec
0170: 68 61 6e 69 73 6d 20 61 6e 64 20 77 6f 72 6b 69  hanism and worki
0180: 6e 67 20 63 6c 6f 73 65 6c 79 20 77 69 74 68 20  ng closely with 
0190: 6d 65 0a 20 2a 20 74 6f 20 65 6e 68 61 6e 63 65  me. * to enhance
01a0: 20 69 74 20 74 6f 20 73 75 70 70 6f 72 74 20 66   it to support f
01b0: 75 6c 6c 20 66 69 6c 65 65 76 65 6e 74 20 73 65  ull fileevent se
01c0: 6d 61 6e 74 69 63 73 2e 0a 20 2a 0a 20 2a 20 41  mantics.. *. * A
01d0: 6c 73 6f 20 77 6f 72 6b 20 64 6f 6e 65 20 62 79  lso work done by
01e0: 20 74 68 65 20 66 6f 6c 6c 6f 77 20 70 65 6f 70   the follow peop
01f0: 6c 65 20 70 72 6f 76 69 64 65 64 20 74 68 65 20  le provided the 
0200: 69 6d 70 65 74 75 73 20 74 6f 20 64 6f 20 74 68  impetus to do th
0210: 69 73 20 22 72 69 67 68 74 22 3a 2d 0a 20 2a 09  is "right":-. *.
0220: 74 63 6c 53 53 4c 20 28 43 6f 6c 69 6e 20 4d 63  tclSSL (Colin Mc
0230: 43 6f 72 6d 61 63 6b 2c 20 53 68 61 72 65 64 20  Cormack, Shared 
0240: 54 65 63 68 6e 6f 6c 6f 67 79 29 0a 20 2a 09 53  Technology). *.S
0250: 53 4c 74 63 6c 20 28 50 65 74 65 72 20 41 6e 74  SLtcl (Peter Ant
0260: 6d 61 6e 29 0a 20 2a 0a 20 2a 2f 0a 23 69 66 6e  man). *. */.#ifn
0270: 64 65 66 20 5f 54 4c 53 49 4e 54 5f 48 0a 23 64  def _TLSINT_H.#d
0280: 65 66 69 6e 65 20 5f 54 4c 53 49 4e 54 5f 48 0a  efine _TLSINT_H.
0290: 0a 23 69 6e 63 6c 75 64 65 20 22 74 6c 73 2e 68  .#include "tls.h
02a0: 22 0a 23 69 6e 63 6c 75 64 65 20 3c 65 72 72 6e  ".#include <errn
02b0: 6f 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 73  o.h>.#include <s
02c0: 74 72 69 6e 67 2e 68 3e 0a 0a 23 69 66 64 65 66  tring.h>..#ifdef
02d0: 20 5f 5f 57 49 4e 33 32 5f 5f 0a 23 64 65 66 69   __WIN32__.#defi
02e0: 6e 65 20 57 49 4e 33 32 5f 4c 45 41 4e 5f 41 4e  ne WIN32_LEAN_AN
02f0: 44 5f 4d 45 41 4e 0a 23 69 6e 63 6c 75 64 65 20  D_MEAN.#include 
0300: 3c 77 69 6e 64 6f 77 73 2e 68 3e 0a 23 69 6e 63  <windows.h>.#inc
0310: 6c 75 64 65 20 3c 77 69 6e 63 72 79 70 74 2e 68  lude <wincrypt.h
0320: 3e 20 2f 2a 20 4f 70 65 6e 53 53 4c 20 6e 65 65  > /* OpenSSL nee
0330: 64 73 20 74 68 69 73 20 6f 6e 20 57 69 6e 64 6f  ds this on Windo
0340: 77 73 20 2a 2f 0a 23 65 6e 64 69 66 0a 0a 2f 2a  ws */.#endif../*
0350: 20 48 61 6e 64 6c 65 20 74 63 6c 38 2e 33 2d 3e   Handle tcl8.3->
0360: 74 63 6c 38 2e 34 20 43 4f 4e 53 54 20 63 68 61  tcl8.4 CONST cha
0370: 6e 67 65 73 20 2a 2f 0a 23 69 66 6e 64 65 66 20  nges */.#ifndef 
0380: 43 4f 4e 53 54 38 34 0a 23 64 65 66 69 6e 65 20  CONST84.#define 
0390: 43 4f 4e 53 54 38 34 0a 23 65 6e 64 69 66 0a 0a  CONST84.#endif..
03a0: 23 69 66 64 65 66 20 4e 4f 5f 50 41 54 45 4e 54  #ifdef NO_PATENT
03b0: 53 0a 23 20 20 64 65 66 69 6e 65 20 4e 4f 5f 49  S.#  define NO_I
03c0: 44 45 41 0a 23 20 20 64 65 66 69 6e 65 20 4e 4f  DEA.#  define NO
03d0: 5f 52 43 32 0a 23 20 20 64 65 66 69 6e 65 20 4e  _RC2.#  define N
03e0: 4f 5f 52 43 34 0a 23 20 20 64 65 66 69 6e 65 20  O_RC4.#  define 
03f0: 4e 4f 5f 52 43 35 0a 23 20 20 64 65 66 69 6e 65  NO_RC5.#  define
0400: 20 4e 4f 5f 52 53 41 0a 23 20 20 69 66 6e 64 65   NO_RSA.#  ifnde
0410: 66 20 4e 4f 5f 53 53 4c 32 0a 23 20 20 20 20 64  f NO_SSL2.#    d
0420: 65 66 69 6e 65 20 4e 4f 5f 53 53 4c 32 0a 23 20  efine NO_SSL2.# 
0430: 20 65 6e 64 69 66 0a 23 65 6e 64 69 66 0a 0a 23   endif.#endif..#
0440: 69 66 64 65 66 20 42 53 41 46 45 0a 23 69 6e 63  ifdef BSAFE.#inc
0450: 6c 75 64 65 20 3c 73 73 6c 2e 68 3e 0a 23 69 6e  lude <ssl.h>.#in
0460: 63 6c 75 64 65 20 3c 65 72 72 2e 68 3e 0a 23 69  clude <err.h>.#i
0470: 6e 63 6c 75 64 65 20 3c 72 61 6e 64 2e 68 3e 0a  nclude <rand.h>.
0480: 23 65 6c 73 65 0a 23 69 6e 63 6c 75 64 65 20 3c  #else.#include <
0490: 6f 70 65 6e 73 73 6c 2f 73 73 6c 2e 68 3e 0a 23  openssl/ssl.h>.#
04a0: 69 6e 63 6c 75 64 65 20 3c 6f 70 65 6e 73 73 6c  include <openssl
04b0: 2f 65 72 72 2e 68 3e 0a 23 69 6e 63 6c 75 64 65  /err.h>.#include
04c0: 20 3c 6f 70 65 6e 73 73 6c 2f 72 61 6e 64 2e 68   <openssl/rand.h
04d0: 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 6f 70 65 6e  >.#include <open
04e0: 73 73 6c 2f 6f 70 65 6e 73 73 6c 76 2e 68 3e 0a  ssl/opensslv.h>.
04f0: 23 65 6e 64 69 66 0a 0a 2f 2a 0a 20 2a 20 44 65  #endif../*. * De
0500: 74 65 72 6d 69 6e 65 20 69 66 20 77 65 20 73 68  termine if we sh
0510: 6f 75 6c 64 20 75 73 65 20 74 68 65 20 70 72 65  ould use the pre
0520: 2d 4f 70 65 6e 53 53 4c 20 31 2e 31 2e 30 20 41  -OpenSSL 1.1.0 A
0530: 50 49 0a 20 2a 2f 0a 23 75 6e 64 65 66 20 54 43  PI. */.#undef TC
0540: 4c 54 4c 53 5f 4f 50 45 4e 53 53 4c 5f 50 52 45  LTLS_OPENSSL_PRE
0550: 5f 31 5f 31 0a 23 69 66 20 28 64 65 66 69 6e 65  _1_1.#if (define
0560: 64 28 4c 49 42 52 45 53 53 4c 5f 56 45 52 53 49  d(LIBRESSL_VERSI
0570: 4f 4e 5f 4e 55 4d 42 45 52 29 29 20 7c 7c 20 4f  ON_NUMBER)) || O
0580: 50 45 4e 53 53 4c 5f 56 45 52 53 49 4f 4e 5f 4e  PENSSL_VERSION_N
0590: 55 4d 42 45 52 20 3c 20 30 78 31 30 31 30 30 30  UMBER < 0x101000
05a0: 30 30 4c 0a 23 20 20 64 65 66 69 6e 65 20 54 43  00L.#  define TC
05b0: 4c 54 4c 53 5f 4f 50 45 4e 53 53 4c 5f 50 52 45  LTLS_OPENSSL_PRE
05c0: 5f 31 5f 31 5f 41 50 49 20 31 0a 23 65 6e 64 69  _1_1_API 1.#endi
05d0: 66 0a 0a 23 69 66 64 65 66 20 54 43 4c 5f 53 54  f..#ifdef TCL_ST
05e0: 4f 52 41 47 45 5f 43 4c 41 53 53 0a 23 20 75 6e  ORAGE_CLASS.# un
05f0: 64 65 66 20 54 43 4c 5f 53 54 4f 52 41 47 45 5f  def TCL_STORAGE_
0600: 43 4c 41 53 53 0a 23 65 6e 64 69 66 0a 23 69 66  CLASS.#endif.#if
0610: 64 65 66 20 42 55 49 4c 44 5f 74 6c 73 0a 23 20  def BUILD_tls.# 
0620: 64 65 66 69 6e 65 20 54 43 4c 5f 53 54 4f 52 41  define TCL_STORA
0630: 47 45 5f 43 4c 41 53 53 20 44 4c 4c 45 58 50 4f  GE_CLASS DLLEXPO
0640: 52 54 0a 23 65 6c 73 65 0a 23 20 64 65 66 69 6e  RT.#else.# defin
0650: 65 20 54 43 4c 5f 53 54 4f 52 41 47 45 5f 43 4c  e TCL_STORAGE_CL
0660: 41 53 53 20 44 4c 4c 49 4d 50 4f 52 54 0a 23 65  ASS DLLIMPORT.#e
0670: 6e 64 69 66 0a 20 0a 23 69 66 6e 64 65 66 20 45  ndif. .#ifndef E
0680: 43 4f 4e 4e 41 42 4f 52 54 45 44 0a 23 64 65 66  CONNABORTED.#def
0690: 69 6e 65 20 45 43 4f 4e 4e 41 42 4f 52 54 45 44  ine ECONNABORTED
06a0: 09 31 33 30 09 2f 2a 20 53 6f 66 74 77 61 72 65  .130./* Software
06b0: 20 63 61 75 73 65 64 20 63 6f 6e 6e 65 63 74 69   caused connecti
06c0: 6f 6e 20 61 62 6f 72 74 20 2a 2f 0a 23 65 6e 64  on abort */.#end
06d0: 69 66 0a 23 69 66 6e 64 65 66 20 45 43 4f 4e 4e  if.#ifndef ECONN
06e0: 52 45 53 45 54 0a 23 64 65 66 69 6e 65 20 45 43  RESET.#define EC
06f0: 4f 4e 4e 52 45 53 45 54 09 31 33 31 09 2f 2a 20  ONNRESET.131./* 
0700: 43 6f 6e 6e 65 63 74 69 6f 6e 20 72 65 73 65 74  Connection reset
0710: 20 62 79 20 70 65 65 72 20 2a 2f 0a 23 65 6e 64   by peer */.#end
0720: 69 66 0a 0a 23 69 66 64 65 66 20 54 43 4c 45 58  if..#ifdef TCLEX
0730: 54 5f 54 43 4c 54 4c 53 5f 44 45 42 55 47 0a 23  T_TCLTLS_DEBUG.#
0740: 64 65 66 69 6e 65 20 64 70 72 69 6e 74 66 28 2e  define dprintf(.
0750: 2e 2e 29 20 7b 20 66 70 72 69 6e 74 66 28 73 74  ..) { fprintf(st
0760: 64 65 72 72 2c 20 22 25 73 3a 25 69 3a 22 2c 20  derr, "%s:%i:", 
0770: 5f 5f 66 75 6e 63 5f 5f 2c 20 5f 5f 4c 49 4e 45  __func__, __LINE
0780: 5f 5f 29 3b 20 66 70 72 69 6e 74 66 28 73 74 64  __); fprintf(std
0790: 65 72 72 2c 20 5f 5f 56 41 5f 41 52 47 53 5f 5f  err, __VA_ARGS__
07a0: 29 3b 20 66 70 72 69 6e 74 66 28 73 74 64 65 72  ); fprintf(stder
07b0: 72 2c 20 22 5c 6e 22 29 3b 20 7d 0a 23 65 6c 73  r, "\n"); }.#els
07c0: 65 0a 23 64 65 66 69 6e 65 20 64 70 72 69 6e 74  e.#define dprint
07d0: 66 28 2e 2e 2e 29 20 69 66 20 28 30 29 20 7b 20  f(...) if (0) { 
07e0: 66 70 72 69 6e 74 66 28 73 74 64 65 72 72 2c 20  fprintf(stderr, 
07f0: 5f 5f 56 41 5f 41 52 47 53 5f 5f 29 3b 20 7d 0a  __VA_ARGS__); }.
0800: 23 65 6e 64 69 66 0a 0a 23 64 65 66 69 6e 65 20  #endif..#define 
0810: 53 53 4c 5f 45 52 52 4f 52 28 73 73 6c 2c 65 72  SSL_ERROR(ssl,er
0820: 72 29 09 5c 0a 20 20 20 20 28 28 63 68 61 72 2a  r).\.    ((char*
0830: 29 45 52 52 5f 72 65 61 73 6f 6e 5f 65 72 72 6f  )ERR_reason_erro
0840: 72 5f 73 74 72 69 6e 67 28 28 75 6e 73 69 67 6e  r_string((unsign
0850: 65 64 20 6c 6f 6e 67 29 53 53 4c 5f 67 65 74 5f  ed long)SSL_get_
0860: 65 72 72 6f 72 28 28 73 73 6c 29 2c 28 65 72 72  error((ssl),(err
0870: 29 29 29 29 0a 2f 2a 0a 20 2a 20 4f 70 65 6e 53  ))))./*. * OpenS
0880: 53 4c 20 42 49 4f 20 52 6f 75 74 69 6e 65 73 0a  SL BIO Routines.
0890: 20 2a 2f 0a 23 64 65 66 69 6e 65 20 42 49 4f 5f   */.#define BIO_
08a0: 54 59 50 45 5f 54 43 4c 09 28 31 39 7c 30 78 30  TYPE_TCL.(19|0x0
08b0: 34 30 30 29 0a 0a 2f 2a 0a 20 2a 20 44 65 66 69  400)../*. * Defi
08c0: 6e 65 73 20 66 6f 72 20 53 74 61 74 65 2e 66 6c  nes for State.fl
08d0: 61 67 73 0a 20 2a 2f 0a 23 64 65 66 69 6e 65 20  ags. */.#define 
08e0: 54 4c 53 5f 54 43 4c 5f 41 53 59 4e 43 09 28 31  TLS_TCL_ASYNC.(1
08f0: 3c 3c 30 29 09 2f 2a 20 6e 6f 6e 2d 62 6c 6f 63  <<0)./* non-bloc
0900: 6b 69 6e 67 20 6d 6f 64 65 20 2a 2f 0a 23 64 65  king mode */.#de
0910: 66 69 6e 65 20 54 4c 53 5f 54 43 4c 5f 53 45 52  fine TLS_TCL_SER
0920: 56 45 52 09 28 31 3c 3c 31 29 09 2f 2a 20 53 65  VER.(1<<1)./* Se
0930: 72 76 65 72 2d 53 69 64 65 20 2a 2f 0a 23 64 65  rver-Side */.#de
0940: 66 69 6e 65 20 54 4c 53 5f 54 43 4c 5f 49 4e 49  fine TLS_TCL_INI
0950: 54 09 28 31 3c 3c 32 29 09 2f 2a 20 49 6e 69 74  T.(1<<2)./* Init
0960: 69 61 6c 69 7a 69 6e 67 20 63 6f 6e 6e 65 63 74  ializing connect
0970: 69 6f 6e 20 2a 2f 0a 23 64 65 66 69 6e 65 20 54  ion */.#define T
0980: 4c 53 5f 54 43 4c 5f 44 45 42 55 47 09 28 31 3c  LS_TCL_DEBUG.(1<
0990: 3c 33 29 09 2f 2a 20 53 68 6f 77 20 64 65 62 75  <3)./* Show debu
09a0: 67 20 74 72 61 63 69 6e 67 20 2a 2f 0a 23 64 65  g tracing */.#de
09b0: 66 69 6e 65 20 54 4c 53 5f 54 43 4c 5f 43 41 4c  fine TLS_TCL_CAL
09c0: 4c 42 41 43 4b 09 28 31 3c 3c 34 29 09 2f 2a 20  LBACK.(1<<4)./* 
09d0: 49 6e 20 61 20 63 61 6c 6c 62 61 63 6b 2c 20 70  In a callback, p
09e0: 72 65 76 65 6e 74 20 75 70 64 61 74 65 0a 09 09  revent update...
09f0: 09 09 09 20 2a 20 6c 6f 6f 70 69 6e 67 20 70 72  ... * looping pr
0a00: 6f 62 6c 65 6d 2e 20 5b 42 75 67 20 31 36 35 32  oblem. [Bug 1652
0a10: 33 38 30 5d 20 2a 2f 0a 23 64 65 66 69 6e 65 20  380] */.#define 
0a20: 54 4c 53 5f 54 43 4c 5f 48 41 4e 44 53 48 41 4b  TLS_TCL_HANDSHAK
0a30: 45 5f 46 41 49 4c 45 44 20 28 31 3c 3c 35 29 20  E_FAILED (1<<5) 
0a40: 2f 2a 20 53 65 74 20 6f 6e 20 68 61 6e 64 73 68  /* Set on handsh
0a50: 61 6b 65 20 66 61 69 6c 75 72 65 73 20 61 6e 64  ake failures and
0a60: 20 6f 6e 63 65 0a 20 20 20 20 20 20 20 20 20 20   once.          
0a70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0a80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2a                 *
0a90: 20 73 65 74 2c 20 61 6c 6c 20 66 75 72 74 68 65   set, all furthe
0aa0: 72 20 49 2f 4f 20 77 69 6c 6c 20 72 65 73 75 6c  r I/O will resul
0ab0: 74 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  t.              
0ac0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0ad0: 20 20 20 20 20 20 20 20 20 20 20 2a 20 69 6e 20             * in 
0ae0: 45 43 4f 4e 4e 41 42 4f 52 54 45 44 20 65 72 72  ECONNABORTED err
0af0: 6f 72 73 2e 20 2a 2f 0a 0a 23 64 65 66 69 6e 65  ors. */..#define
0b00: 20 54 4c 53 5f 54 43 4c 5f 44 45 4c 41 59 20 28   TLS_TCL_DELAY (
0b10: 35 29 0a 0a 2f 2a 0a 20 2a 20 54 68 69 73 20 73  5)../*. * This s
0b20: 74 72 75 63 74 75 72 65 20 64 65 73 63 72 69 62  tructure describ
0b30: 65 73 20 74 68 65 20 70 65 72 2d 69 6e 73 74 61  es the per-insta
0b40: 6e 63 65 20 73 74 61 74 65 0a 20 2a 20 6f 66 20  nce state. * of 
0b50: 61 6e 20 73 73 6c 20 63 68 61 6e 6e 65 6c 2e 0a  an ssl channel..
0b60: 20 2a 0a 20 2a 20 54 68 65 20 53 53 4c 20 70 72   *. * The SSL pr
0b70: 6f 63 65 73 73 69 6e 67 20 63 6f 6e 74 65 78 74  ocessing context
0b80: 20 69 73 20 6d 61 69 6e 74 61 69 6e 65 64 20 68   is maintained h
0b90: 65 72 65 2c 20 69 6e 20 74 68 65 20 43 6c 69 65  ere, in the Clie
0ba0: 6e 74 44 61 74 61 0a 20 2a 2f 0a 74 79 70 65 64  ntData. */.typed
0bb0: 65 66 20 73 74 72 75 63 74 20 53 74 61 74 65 20  ef struct State 
0bc0: 7b 0a 20 20 20 20 54 63 6c 5f 43 68 61 6e 6e 65  {.    Tcl_Channe
0bd0: 6c 20 73 65 6c 66 3b 09 2f 2a 20 74 68 69 73 20  l self;./* this 
0be0: 73 6f 63 6b 65 74 20 63 68 61 6e 6e 65 6c 20 2a  socket channel *
0bf0: 2f 0a 20 20 20 20 54 63 6c 5f 54 69 6d 65 72 54  /.    Tcl_TimerT
0c00: 6f 6b 65 6e 20 74 69 6d 65 72 3b 0a 0a 20 20 20  oken timer;..   
0c10: 20 69 6e 74 20 66 6c 61 67 73 3b 09 09 2f 2a 20   int flags;../* 
0c20: 73 65 65 20 53 74 61 74 65 2e 66 6c 61 67 73 20  see State.flags 
0c30: 61 62 6f 76 65 20 20 2a 2f 0a 20 20 20 20 69 6e  above  */.    in
0c40: 74 20 77 61 74 63 68 4d 61 73 6b 3b 09 2f 2a 20  t watchMask;./* 
0c50: 63 75 72 72 65 6e 74 20 57 61 74 63 68 50 72 6f  current WatchPro
0c60: 63 20 6d 61 73 6b 20 2a 2f 0a 20 20 20 20 69 6e  c mask */.    in
0c70: 74 20 6d 6f 64 65 3b 09 09 2f 2a 20 63 75 72 72  t mode;../* curr
0c80: 65 6e 74 20 6d 6f 64 65 20 6f 66 20 70 61 72 65  ent mode of pare
0c90: 6e 74 20 63 68 61 6e 6e 65 6c 20 2a 2f 0a 0a 20  nt channel */.. 
0ca0: 20 20 20 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69     Tcl_Interp *i
0cb0: 6e 74 65 72 70 3b 09 2f 2a 20 69 6e 74 65 72 70  nterp;./* interp
0cc0: 72 65 74 65 72 20 69 6e 20 77 68 69 63 68 20 74  reter in which t
0cd0: 68 69 73 20 72 65 73 69 64 65 73 20 2a 2f 0a 20  his resides */. 
0ce0: 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 63 61 6c 6c     Tcl_Obj *call
0cf0: 62 61 63 6b 3b 09 2f 2a 20 73 63 72 69 70 74 20  back;./* script 
0d00: 63 61 6c 6c 65 64 20 66 6f 72 20 74 72 61 63 69  called for traci
0d10: 6e 67 2c 20 76 65 72 69 66 79 69 6e 67 20 61 6e  ng, verifying an
0d20: 64 20 65 72 72 6f 72 73 20 2a 2f 0a 20 20 20 20  d errors */.    
0d30: 54 63 6c 5f 4f 62 6a 20 2a 70 61 73 73 77 6f 72  Tcl_Obj *passwor
0d40: 64 3b 09 2f 2a 20 73 63 72 69 70 74 20 63 61 6c  d;./* script cal
0d50: 6c 65 64 20 66 6f 72 20 63 65 72 74 69 66 69 63  led for certific
0d60: 61 74 65 20 70 61 73 73 77 6f 72 64 20 2a 2f 20  ate password */ 
0d70: 0a 0a 20 20 20 20 69 6e 74 20 76 66 6c 61 67 73  ..    int vflags
0d80: 3b 09 09 2f 2a 20 76 65 72 69 66 79 20 66 6c 61  ;../* verify fla
0d90: 67 73 20 2a 2f 0a 20 20 20 20 53 53 4c 20 2a 73  gs */.    SSL *s
0da0: 73 6c 3b 09 09 2f 2a 20 53 74 72 75 63 74 20 66  sl;../* Struct f
0db0: 6f 72 20 53 53 4c 20 70 72 6f 63 65 73 73 69 6e  or SSL processin
0dc0: 67 20 2a 2f 0a 20 20 20 20 53 53 4c 5f 43 54 58  g */.    SSL_CTX
0dd0: 20 2a 63 74 78 3b 09 2f 2a 20 53 53 4c 20 43 6f   *ctx;./* SSL Co
0de0: 6e 74 65 78 74 20 2a 2f 0a 20 20 20 20 42 49 4f  ntext */.    BIO
0df0: 20 2a 62 69 6f 3b 09 09 2f 2a 20 53 74 72 75 63   *bio;../* Struc
0e00: 74 20 66 6f 72 20 53 53 4c 20 70 72 6f 63 65 73  t for SSL proces
0e10: 73 69 6e 67 20 2a 2f 0a 20 20 20 20 42 49 4f 20  sing */.    BIO 
0e20: 2a 70 5f 62 69 6f 3b 09 09 2f 2a 20 50 61 72 65  *p_bio;../* Pare
0e30: 6e 74 20 42 49 4f 20 28 74 68 61 74 20 69 73 20  nt BIO (that is 
0e40: 6c 61 79 65 72 65 64 20 6f 6e 20 54 63 6c 5f 43  layered on Tcl_C
0e50: 68 61 6e 6e 65 6c 29 20 2a 2f 0a 0a 20 20 20 20  hannel) */..    
0e60: 63 68 61 72 20 2a 65 72 72 3b 0a 7d 20 53 74 61  char *err;.} Sta
0e70: 74 65 3b 0a 0a 23 69 66 64 65 66 20 55 53 45 5f  te;..#ifdef USE_
0e80: 54 43 4c 5f 53 54 55 42 53 0a 23 69 66 6e 64 65  TCL_STUBS.#ifnde
0e90: 66 20 54 63 6c 5f 53 74 61 63 6b 43 68 61 6e 6e  f Tcl_StackChann
0ea0: 65 6c 0a 23 65 72 72 6f 72 20 22 55 6e 61 62 6c  el.#error "Unabl
0eb0: 65 20 74 6f 20 63 6f 6d 70 69 6c 65 20 6f 6e 20  e to compile on 
0ec0: 74 68 69 73 20 76 65 72 73 69 6f 6e 20 6f 66 20  this version of 
0ed0: 54 63 6c 22 0a 23 65 6e 64 69 66 20 2f 2a 20 54  Tcl".#endif /* T
0ee0: 63 6c 5f 47 65 74 53 74 61 63 6b 65 64 43 68 61  cl_GetStackedCha
0ef0: 6e 6e 65 6c 20 2a 2f 0a 23 65 6e 64 69 66 20 2f  nnel */.#endif /
0f00: 2a 20 55 53 45 5f 54 43 4c 5f 53 54 55 42 53 20  * USE_TCL_STUBS 
0f10: 2a 2f 0a 0a 2f 2a 0a 20 2a 20 46 6f 72 77 61 72  */../*. * Forwar
0f20: 64 20 64 65 63 6c 61 72 61 74 69 6f 6e 73 0a 20  d declarations. 
0f30: 2a 2f 0a 0a 54 63 6c 5f 43 68 61 6e 6e 65 6c 54  */..Tcl_ChannelT
0f40: 79 70 65 20 2a 54 6c 73 5f 43 68 61 6e 6e 65 6c  ype *Tls_Channel
0f50: 54 79 70 65 20 5f 41 4e 53 49 5f 41 52 47 53 5f  Type _ANSI_ARGS_
0f60: 28 28 76 6f 69 64 29 29 3b 0a 54 63 6c 5f 43 68  ((void));.Tcl_Ch
0f70: 61 6e 6e 65 6c 20 20 20 20 20 54 6c 73 5f 47 65  annel     Tls_Ge
0f80: 74 50 61 72 65 6e 74 20 5f 41 4e 53 49 5f 41 52  tParent _ANSI_AR
0f90: 47 53 5f 28 28 53 74 61 74 65 20 2a 73 74 61 74  GS_((State *stat
0fa0: 65 50 74 72 29 29 3b 0a 0a 54 63 6c 5f 4f 62 6a  ePtr));..Tcl_Obj
0fb0: 20 20 20 20 20 20 20 20 20 2a 54 6c 73 5f 4e 65           *Tls_Ne
0fc0: 77 58 35 30 39 4f 62 6a 20 5f 41 4e 53 49 5f 41  wX509Obj _ANSI_A
0fd0: 52 47 53 5f 20 28 28 20 54 63 6c 5f 49 6e 74 65  RGS_ (( Tcl_Inte
0fe0: 72 70 20 2a 69 6e 74 65 72 70 2c 20 58 35 30 39  rp *interp, X509
0ff0: 20 2a 63 65 72 74 29 29 3b 0a 76 6f 69 64 20 20   *cert));.void  
1000: 20 20 20 20 20 20 20 20 20 20 54 6c 73 5f 45 72            Tls_Er
1010: 72 6f 72 20 5f 41 4e 53 49 5f 41 52 47 53 5f 20  ror _ANSI_ARGS_ 
1020: 28 28 53 74 61 74 65 20 2a 73 74 61 74 65 50 74  ((State *statePt
1030: 72 2c 20 63 68 61 72 20 2a 6d 73 67 29 29 3b 0a  r, char *msg));.
1040: 76 6f 69 64 20 20 20 20 20 20 20 20 20 20 20 20  void            
1050: 54 6c 73 5f 46 72 65 65 20 5f 41 4e 53 49 5f 41  Tls_Free _ANSI_A
1060: 52 47 53 5f 20 28 28 63 68 61 72 20 2a 62 6c 6f  RGS_ ((char *blo
1070: 63 6b 50 74 72 29 29 3b 0a 76 6f 69 64 20 20 20  ckPtr));.void   
1080: 20 20 20 20 20 20 20 20 20 54 6c 73 5f 43 6c 65           Tls_Cle
1090: 61 6e 20 5f 41 4e 53 49 5f 41 52 47 53 5f 20 28  an _ANSI_ARGS_ (
10a0: 28 53 74 61 74 65 20 2a 73 74 61 74 65 50 74 72  (State *statePtr
10b0: 29 29 3b 0a 69 6e 74 20 20 20 20 20 20 20 20 20  ));.int         
10c0: 20 20 20 20 54 6c 73 5f 57 61 69 74 46 6f 72 43      Tls_WaitForC
10d0: 6f 6e 6e 65 63 74 20 5f 41 4e 53 49 5f 41 52 47  onnect _ANSI_ARG
10e0: 53 5f 28 28 20 53 74 61 74 65 20 2a 73 74 61 74  S_(( State *stat
10f0: 65 50 74 72 2c 20 69 6e 74 20 2a 65 72 72 6f 72  ePtr, int *error
1100: 43 6f 64 65 50 74 72 29 29 3b 0a 0a 42 49 4f 20  CodePtr));..BIO 
1110: 20 20 20 20 20 20 20 20 20 20 20 20 2a 42 49 4f              *BIO
1120: 5f 6e 65 77 5f 74 63 6c 20 5f 41 4e 53 49 5f 41  _new_tcl _ANSI_A
1130: 52 47 53 5f 28 28 53 74 61 74 65 2a 20 73 74 61  RGS_((State* sta
1140: 74 65 50 74 72 2c 20 69 6e 74 20 66 6c 61 67 73  tePtr, int flags
1150: 29 29 3b 0a 0a 23 65 6e 64 69 66 20 2f 2a 20 5f  ));..#endif /* _
1160: 54 4c 53 49 4e 54 5f 48 20 2a 2f 0a              TLSINT_H */.