Artifact
337abc57f76de68bc3a3db1b698f632595d9c1dd:
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 53 4c 49 4e 54 5f 48 0a 23 64 def _TSLINT_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 64 65 66 69 6e 65 20 4e 4f 5f 49 44 45 S.#define NO_IDE
03c0: 41 0a 23 64 65 66 69 6e 65 20 4e 4f 5f 52 43 32 A.#define NO_RC2
03d0: 0a 23 64 65 66 69 6e 65 20 4e 4f 5f 52 43 34 0a .#define NO_RC4.
03e0: 23 64 65 66 69 6e 65 20 4e 4f 5f 52 43 35 0a 23 #define NO_RC5.#
03f0: 64 65 66 69 6e 65 20 4e 4f 5f 52 53 41 0a 23 64 define NO_RSA.#d
0400: 65 66 69 6e 65 20 4e 4f 5f 53 53 4c 32 0a 23 65 efine NO_SSL2.#e
0410: 6e 64 69 66 0a 0a 23 69 66 64 65 66 20 42 53 41 ndif..#ifdef BSA
0420: 46 45 0a 23 69 6e 63 6c 75 64 65 20 3c 73 73 6c FE.#include <ssl
0430: 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 65 72 .h>.#include <er
0440: 72 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 72 r.h>.#include <r
0450: 61 6e 64 2e 68 3e 0a 23 65 6c 73 65 0a 23 69 6e and.h>.#else.#in
0460: 63 6c 75 64 65 20 3c 6f 70 65 6e 73 73 6c 2f 73 clude <openssl/s
0470: 73 6c 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c sl.h>.#include <
0480: 6f 70 65 6e 73 73 6c 2f 65 72 72 2e 68 3e 0a 23 openssl/err.h>.#
0490: 69 6e 63 6c 75 64 65 20 3c 6f 70 65 6e 73 73 6c include <openssl
04a0: 2f 72 61 6e 64 2e 68 3e 0a 23 65 6e 64 69 66 0a /rand.h>.#endif.
04b0: 0a 23 69 66 6e 64 65 66 20 53 53 4c 5f 4f 50 5f .#ifndef SSL_OP_
04c0: 4e 4f 5f 54 4c 53 76 31 5f 31 0a 23 64 65 66 69 NO_TLSv1_1.#defi
04d0: 6e 65 20 4e 4f 5f 54 4c 53 31 5f 31 0a 23 65 6e ne NO_TLS1_1.#en
04e0: 64 69 66 0a 0a 23 69 66 6e 64 65 66 20 53 53 4c dif..#ifndef SSL
04f0: 5f 4f 50 5f 4e 4f 5f 54 4c 53 76 31 5f 32 0a 23 _OP_NO_TLSv1_2.#
0500: 64 65 66 69 6e 65 20 4e 4f 5f 54 4c 53 31 5f 32 define NO_TLS1_2
0510: 0a 23 65 6e 64 69 66 0a 0a 23 69 66 64 65 66 20 .#endif..#ifdef
0520: 54 43 4c 5f 53 54 4f 52 41 47 45 5f 43 4c 41 53 TCL_STORAGE_CLAS
0530: 53 0a 23 20 75 6e 64 65 66 20 54 43 4c 5f 53 54 S.# undef TCL_ST
0540: 4f 52 41 47 45 5f 43 4c 41 53 53 0a 23 65 6e 64 ORAGE_CLASS.#end
0550: 69 66 0a 23 69 66 64 65 66 20 42 55 49 4c 44 5f if.#ifdef BUILD_
0560: 74 6c 73 0a 23 20 64 65 66 69 6e 65 20 54 43 4c tls.# define TCL
0570: 5f 53 54 4f 52 41 47 45 5f 43 4c 41 53 53 20 44 _STORAGE_CLASS D
0580: 4c 4c 45 58 50 4f 52 54 0a 23 65 6c 73 65 0a 23 LLEXPORT.#else.#
0590: 20 64 65 66 69 6e 65 20 54 43 4c 5f 53 54 4f 52 define TCL_STOR
05a0: 41 47 45 5f 43 4c 41 53 53 20 44 4c 4c 49 4d 50 AGE_CLASS DLLIMP
05b0: 4f 52 54 0a 23 65 6e 64 69 66 0a 20 0a 23 69 66 ORT.#endif. .#if
05c0: 6e 64 65 66 20 45 43 4f 4e 4e 41 42 4f 52 54 45 ndef ECONNABORTE
05d0: 44 0a 23 64 65 66 69 6e 65 20 45 43 4f 4e 4e 41 D.#define ECONNA
05e0: 42 4f 52 54 45 44 09 31 33 30 09 2f 2a 20 53 6f BORTED.130./* So
05f0: 66 74 77 61 72 65 20 63 61 75 73 65 64 20 63 6f ftware caused co
0600: 6e 6e 65 63 74 69 6f 6e 20 61 62 6f 72 74 20 2a nnection abort *
0610: 2f 0a 23 65 6e 64 69 66 0a 23 69 66 6e 64 65 66 /.#endif.#ifndef
0620: 20 45 43 4f 4e 4e 52 45 53 45 54 0a 23 64 65 66 ECONNRESET.#def
0630: 69 6e 65 20 45 43 4f 4e 4e 52 45 53 45 54 09 31 ine ECONNRESET.1
0640: 33 31 09 2f 2a 20 43 6f 6e 6e 65 63 74 69 6f 6e 31./* Connection
0650: 20 72 65 73 65 74 20 62 79 20 70 65 65 72 20 2a reset by peer *
0660: 2f 0a 23 65 6e 64 69 66 0a 0a 23 69 66 64 65 66 /.#endif..#ifdef
0670: 20 44 45 42 55 47 0a 23 64 65 66 69 6e 65 20 64 DEBUG.#define d
0680: 70 72 69 6e 74 66 20 66 70 72 69 6e 74 66 0a 23 printf fprintf.#
0690: 65 6c 73 65 0a 23 64 65 66 69 6e 65 20 64 70 72 else.#define dpr
06a0: 69 6e 74 66 20 69 66 20 28 30 29 20 66 70 72 69 intf if (0) fpri
06b0: 6e 74 66 0a 23 65 6e 64 69 66 0a 0a 23 64 65 66 ntf.#endif..#def
06c0: 69 6e 65 20 53 53 4c 5f 45 52 52 4f 52 28 73 73 ine SSL_ERROR(ss
06d0: 6c 2c 65 72 72 29 09 5c 0a 20 20 20 20 28 28 63 l,err).\. ((c
06e0: 68 61 72 2a 29 45 52 52 5f 72 65 61 73 6f 6e 5f har*)ERR_reason_
06f0: 65 72 72 6f 72 5f 73 74 72 69 6e 67 28 28 75 6e error_string((un
0700: 73 69 67 6e 65 64 20 6c 6f 6e 67 29 53 53 4c 5f signed long)SSL_
0710: 67 65 74 5f 65 72 72 6f 72 28 28 73 73 6c 29 2c get_error((ssl),
0720: 28 65 72 72 29 29 29 29 0a 2f 2a 0a 20 2a 20 4f (err))))./*. * O
0730: 70 65 6e 53 53 4c 20 42 49 4f 20 52 6f 75 74 69 penSSL BIO Routi
0740: 6e 65 73 0a 20 2a 2f 0a 23 64 65 66 69 6e 65 20 nes. */.#define
0750: 42 49 4f 5f 54 59 50 45 5f 54 43 4c 09 28 31 39 BIO_TYPE_TCL.(19
0760: 7c 30 78 30 34 30 30 29 0a 0a 2f 2a 0a 20 2a 20 |0x0400)../*. *
0770: 44 65 66 69 6e 65 73 20 66 6f 72 20 53 74 61 74 Defines for Stat
0780: 65 2e 66 6c 61 67 73 0a 20 2a 2f 0a 23 64 65 66 e.flags. */.#def
0790: 69 6e 65 20 54 4c 53 5f 54 43 4c 5f 41 53 59 4e ine TLS_TCL_ASYN
07a0: 43 09 28 31 3c 3c 30 29 09 2f 2a 20 6e 6f 6e 2d C.(1<<0)./* non-
07b0: 62 6c 6f 63 6b 69 6e 67 20 6d 6f 64 65 20 2a 2f blocking mode */
07c0: 0a 23 64 65 66 69 6e 65 20 54 4c 53 5f 54 43 4c .#define TLS_TCL
07d0: 5f 53 45 52 56 45 52 09 28 31 3c 3c 31 29 09 2f _SERVER.(1<<1)./
07e0: 2a 20 53 65 72 76 65 72 2d 53 69 64 65 20 2a 2f * Server-Side */
07f0: 0a 23 64 65 66 69 6e 65 20 54 4c 53 5f 54 43 4c .#define TLS_TCL
0800: 5f 49 4e 49 54 09 28 31 3c 3c 32 29 09 2f 2a 20 _INIT.(1<<2)./*
0810: 49 6e 69 74 69 61 6c 69 7a 69 6e 67 20 63 6f 6e Initializing con
0820: 6e 65 63 74 69 6f 6e 20 2a 2f 0a 23 64 65 66 69 nection */.#defi
0830: 6e 65 20 54 4c 53 5f 54 43 4c 5f 44 45 42 55 47 ne TLS_TCL_DEBUG
0840: 09 28 31 3c 3c 33 29 09 2f 2a 20 53 68 6f 77 20 .(1<<3)./* Show
0850: 64 65 62 75 67 20 74 72 61 63 69 6e 67 20 2a 2f debug tracing */
0860: 0a 23 64 65 66 69 6e 65 20 54 4c 53 5f 54 43 4c .#define TLS_TCL
0870: 5f 43 41 4c 4c 42 41 43 4b 09 28 31 3c 3c 34 29 _CALLBACK.(1<<4)
0880: 09 2f 2a 20 49 6e 20 61 20 63 61 6c 6c 62 61 63 ./* In a callbac
0890: 6b 2c 20 70 72 65 76 65 6e 74 20 75 70 64 61 74 k, prevent updat
08a0: 65 0a 09 09 09 09 09 20 2a 20 6c 6f 6f 70 69 6e e...... * loopin
08b0: 67 20 70 72 6f 62 6c 65 6d 2e 20 5b 42 75 67 20 g problem. [Bug
08c0: 31 36 35 32 33 38 30 5d 20 2a 2f 0a 23 64 65 66 1652380] */.#def
08d0: 69 6e 65 20 54 4c 53 5f 54 43 4c 5f 48 41 4e 44 ine TLS_TCL_HAND
08e0: 53 48 41 4b 45 5f 46 41 49 4c 45 44 20 28 31 3c SHAKE_FAILED (1<
08f0: 3c 35 29 20 2f 2a 20 53 65 74 20 6f 6e 20 68 61 <5) /* Set on ha
0900: 6e 64 73 68 61 6b 65 20 66 61 69 6c 75 72 65 73 ndshake failures
0910: 20 61 6e 64 20 6f 6e 63 65 0a 20 20 20 20 20 20 and once.
0920: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0930: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0940: 20 20 20 2a 20 73 65 74 2c 20 61 6c 6c 20 66 75 * set, all fu
0950: 72 74 68 65 72 20 49 2f 4f 20 77 69 6c 6c 20 72 rther I/O will r
0960: 65 73 75 6c 74 0a 20 20 20 20 20 20 20 20 20 20 esult.
0970: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0980: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2a *
0990: 20 69 6e 20 45 43 4f 4e 4e 41 42 4f 52 54 45 44 in ECONNABORTED
09a0: 20 65 72 72 6f 72 73 2e 20 2a 2f 0a 0a 23 64 65 errors. */..#de
09b0: 66 69 6e 65 20 54 4c 53 5f 54 43 4c 5f 44 45 4c fine TLS_TCL_DEL
09c0: 41 59 20 28 35 29 0a 0a 2f 2a 0a 20 2a 20 54 68 AY (5)../*. * Th
09d0: 69 73 20 73 74 72 75 63 74 75 72 65 20 64 65 73 is structure des
09e0: 63 72 69 62 65 73 20 74 68 65 20 70 65 72 2d 69 cribes the per-i
09f0: 6e 73 74 61 6e 63 65 20 73 74 61 74 65 0a 20 2a nstance state. *
0a00: 20 6f 66 20 61 6e 20 73 73 6c 20 63 68 61 6e 6e of an ssl chann
0a10: 65 6c 2e 0a 20 2a 0a 20 2a 20 54 68 65 20 53 53 el.. *. * The SS
0a20: 4c 20 70 72 6f 63 65 73 73 69 6e 67 20 63 6f 6e L processing con
0a30: 74 65 78 74 20 69 73 20 6d 61 69 6e 74 61 69 6e text is maintain
0a40: 65 64 20 68 65 72 65 2c 20 69 6e 20 74 68 65 20 ed here, in the
0a50: 43 6c 69 65 6e 74 44 61 74 61 0a 20 2a 2f 0a 74 ClientData. */.t
0a60: 79 70 65 64 65 66 20 73 74 72 75 63 74 20 53 74 ypedef struct St
0a70: 61 74 65 20 7b 0a 20 20 20 20 54 63 6c 5f 43 68 ate {. Tcl_Ch
0a80: 61 6e 6e 65 6c 20 73 65 6c 66 3b 09 2f 2a 20 74 annel self;./* t
0a90: 68 69 73 20 73 6f 63 6b 65 74 20 63 68 61 6e 6e his socket chann
0aa0: 65 6c 20 2a 2f 0a 20 20 20 20 54 63 6c 5f 54 69 el */. Tcl_Ti
0ab0: 6d 65 72 54 6f 6b 65 6e 20 74 69 6d 65 72 3b 0a merToken timer;.
0ac0: 0a 20 20 20 20 69 6e 74 20 66 6c 61 67 73 3b 09 . int flags;.
0ad0: 09 2f 2a 20 73 65 65 20 53 74 61 74 65 2e 66 6c ./* see State.fl
0ae0: 61 67 73 20 61 62 6f 76 65 20 20 2a 2f 0a 20 20 ags above */.
0af0: 20 20 69 6e 74 20 77 61 74 63 68 4d 61 73 6b 3b int watchMask;
0b00: 09 2f 2a 20 63 75 72 72 65 6e 74 20 57 61 74 63 ./* current Watc
0b10: 68 50 72 6f 63 20 6d 61 73 6b 20 2a 2f 0a 20 20 hProc mask */.
0b20: 20 20 69 6e 74 20 6d 6f 64 65 3b 09 09 2f 2a 20 int mode;../*
0b30: 63 75 72 72 65 6e 74 20 6d 6f 64 65 20 6f 66 20 current mode of
0b40: 70 61 72 65 6e 74 20 63 68 61 6e 6e 65 6c 20 2a parent channel *
0b50: 2f 0a 0a 20 20 20 20 54 63 6c 5f 49 6e 74 65 72 /.. Tcl_Inter
0b60: 70 20 2a 69 6e 74 65 72 70 3b 09 2f 2a 20 69 6e p *interp;./* in
0b70: 74 65 72 70 72 65 74 65 72 20 69 6e 20 77 68 69 terpreter in whi
0b80: 63 68 20 74 68 69 73 20 72 65 73 69 64 65 73 20 ch this resides
0b90: 2a 2f 0a 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a */. Tcl_Obj *
0ba0: 63 61 6c 6c 62 61 63 6b 3b 09 2f 2a 20 73 63 72 callback;./* scr
0bb0: 69 70 74 20 63 61 6c 6c 65 64 20 66 6f 72 20 74 ipt called for t
0bc0: 72 61 63 69 6e 67 2c 20 76 65 72 69 66 79 69 6e racing, verifyin
0bd0: 67 20 61 6e 64 20 65 72 72 6f 72 73 20 2a 2f 0a g and errors */.
0be0: 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 70 61 73 Tcl_Obj *pas
0bf0: 73 77 6f 72 64 3b 09 2f 2a 20 73 63 72 69 70 74 sword;./* script
0c00: 20 63 61 6c 6c 65 64 20 66 6f 72 20 63 65 72 74 called for cert
0c10: 69 66 69 63 61 74 65 20 70 61 73 73 77 6f 72 64 ificate password
0c20: 20 2a 2f 20 0a 0a 20 20 20 20 69 6e 74 20 76 66 */ .. int vf
0c30: 6c 61 67 73 3b 09 09 2f 2a 20 76 65 72 69 66 79 lags;../* verify
0c40: 20 66 6c 61 67 73 20 2a 2f 0a 20 20 20 20 53 53 flags */. SS
0c50: 4c 20 2a 73 73 6c 3b 09 09 2f 2a 20 53 74 72 75 L *ssl;../* Stru
0c60: 63 74 20 66 6f 72 20 53 53 4c 20 70 72 6f 63 65 ct for SSL proce
0c70: 73 73 69 6e 67 20 2a 2f 0a 20 20 20 20 53 53 4c ssing */. SSL
0c80: 5f 43 54 58 20 2a 63 74 78 3b 09 2f 2a 20 53 53 _CTX *ctx;./* SS
0c90: 4c 20 43 6f 6e 74 65 78 74 20 2a 2f 0a 20 20 20 L Context */.
0ca0: 20 42 49 4f 20 2a 62 69 6f 3b 09 09 2f 2a 20 53 BIO *bio;../* S
0cb0: 74 72 75 63 74 20 66 6f 72 20 53 53 4c 20 70 72 truct for SSL pr
0cc0: 6f 63 65 73 73 69 6e 67 20 2a 2f 0a 20 20 20 20 ocessing */.
0cd0: 42 49 4f 20 2a 70 5f 62 69 6f 3b 09 09 2f 2a 20 BIO *p_bio;../*
0ce0: 50 61 72 65 6e 74 20 42 49 4f 20 28 74 68 61 74 Parent BIO (that
0cf0: 20 69 73 20 6c 61 79 65 72 65 64 20 6f 6e 20 54 is layered on T
0d00: 63 6c 5f 43 68 61 6e 6e 65 6c 29 20 2a 2f 0a 0a cl_Channel) */..
0d10: 20 20 20 20 63 68 61 72 20 2a 65 72 72 3b 0a 7d char *err;.}
0d20: 20 53 74 61 74 65 3b 0a 0a 2f 2a 0a 20 2a 20 54 State;../*. * T
0d30: 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 64 65 66 he following def
0d40: 69 6e 69 74 69 6f 6e 73 20 68 61 76 65 20 74 6f initions have to
0d50: 20 62 65 20 75 73 61 62 6c 65 20 66 6f 72 20 38 be usable for 8
0d60: 2e 32 2e 30 2d 38 2e 33 2e 31 20 61 6e 64 20 38 .2.0-8.3.1 and 8
0d70: 2e 33 2e 32 2b 2e 0a 20 2a 20 54 68 65 20 64 69 .3.2+.. * The di
0d80: 66 66 65 72 65 6e 63 65 73 20 62 65 74 77 65 65 fferences betwee
0d90: 6e 20 74 68 65 73 65 20 76 65 72 73 69 6f 6e 73 n these versions
0da0: 3a 0a 20 2a 0a 20 2a 20 38 2e 30 2d 38 2e 31 3a :. *. * 8.0-8.1:
0db0: 09 54 68 65 72 65 20 69 73 20 6e 6f 20 73 75 70 .There is no sup
0dc0: 70 6f 72 74 20 66 6f 72 20 74 68 65 73 65 20 69 port for these i
0dd0: 6e 20 54 4c 53 20 31 2e 34 20 28 67 65 74 20 31 n TLS 1.4 (get 1
0de0: 2e 33 29 2e 20 20 54 68 69 73 0a 20 2a 09 09 77 .3). This. *..w
0df0: 61 73 20 74 68 65 20 76 65 72 73 69 6f 6e 20 77 as the version w
0e00: 69 74 68 20 74 68 65 20 6f 72 69 67 69 6e 61 6c ith the original
0e10: 20 70 61 74 63 68 2e 0a 20 2a 0a 20 2a 20 38 2e patch.. *. * 8.
0e20: 32 2e 30 2d 09 43 68 61 6e 67 65 64 20 73 65 6d 2.0-.Changed sem
0e30: 61 6e 74 69 63 73 20 66 6f 72 20 54 63 6c 5f 53 antics for Tcl_S
0e40: 74 61 63 6b 43 68 61 6e 6e 65 6c 20 28 54 63 6c tackChannel (Tcl
0e50: 5f 52 65 70 6c 61 63 65 43 68 61 6e 6e 65 6c 29 _ReplaceChannel)
0e60: 2e 0a 20 2a 20 38 2e 33 2e 31 3a 09 43 68 65 63 .. * 8.3.1:.Chec
0e70: 6b 20 61 74 20 72 75 6e 74 69 6d 65 20 74 6f 20 k at runtime to
0e80: 73 77 69 74 63 68 20 74 68 65 20 62 65 68 61 76 switch the behav
0e90: 69 6f 75 72 2e 20 54 68 65 20 70 61 74 63 68 20 iour. The patch
0ea0: 69 73 20 70 61 72 74 0a 20 2a 09 09 6f 66 20 74 is part. *..of t
0eb0: 68 65 20 63 6f 72 65 20 66 72 6f 6d 20 6e 6f 77 he core from now
0ec0: 20 6f 6e 2e 0a 20 2a 0a 20 2a 20 38 2e 33 2e 32 on.. *. * 8.3.2
0ed0: 2b 3a 09 53 74 61 63 6b 65 64 20 63 68 61 6e 6e +:.Stacked chann
0ee0: 65 6c 73 20 72 65 77 72 69 74 74 65 6e 20 66 6f els rewritten fo
0ef0: 72 20 62 65 74 74 65 72 20 62 65 68 61 76 69 6f r better behavio
0f00: 75 72 20 69 6e 20 73 6f 6d 65 0a 20 2a 09 09 73 ur in some. *..s
0f10: 69 74 75 61 74 69 6f 6e 73 20 28 63 6c 6f 73 69 ituations (closi
0f20: 6e 67 29 2e 20 53 6f 6d 65 20 6e 65 77 20 41 50 ng). Some new AP
0f30: 49 27 73 2c 20 73 65 6d 61 6e 74 69 63 20 63 68 I's, semantic ch
0f40: 61 6e 67 65 73 2e 0a 20 2a 0a 20 2a 20 54 68 65 anges.. *. * The
0f50: 20 66 6f 6c 6c 6f 77 69 6e 67 20 6d 61 67 69 63 following magic
0f60: 20 77 61 73 20 61 64 61 70 74 65 64 20 66 72 6f was adapted fro
0f70: 6d 20 54 72 66 20 32 2e 31 20 28 4b 75 70 72 69 m Trf 2.1 (Kupri
0f80: 65 73 29 2e 0a 20 2a 2f 0a 0a 23 64 65 66 69 6e es).. */..#defin
0f90: 65 20 54 4c 53 5f 43 48 41 4e 4e 45 4c 5f 56 45 e TLS_CHANNEL_VE
0fa0: 52 53 49 4f 4e 5f 31 09 30 78 31 0a 23 64 65 66 RSION_1.0x1.#def
0fb0: 69 6e 65 20 54 4c 53 5f 43 48 41 4e 4e 45 4c 5f ine TLS_CHANNEL_
0fc0: 56 45 52 53 49 4f 4e 5f 32 09 30 78 32 0a 65 78 VERSION_2.0x2.ex
0fd0: 74 65 72 6e 20 69 6e 74 20 63 68 61 6e 6e 65 6c tern int channel
0fe0: 54 79 70 65 56 65 72 73 69 6f 6e 3b 0a 0a 23 69 TypeVersion;..#i
0ff0: 66 64 65 66 20 55 53 45 5f 54 43 4c 5f 53 54 55 fdef USE_TCL_STU
1000: 42 53 0a 23 69 66 6e 64 65 66 20 54 63 6c 5f 53 BS.#ifndef Tcl_S
1010: 74 61 63 6b 43 68 61 6e 6e 65 6c 0a 2f 2a 0a 20 tackChannel./*.
1020: 2a 20 54 68 65 20 63 6f 72 65 20 77 65 20 61 72 * The core we ar
1030: 65 20 63 6f 6d 70 69 6c 69 6e 67 20 61 67 61 69 e compiling agai
1040: 6e 73 74 20 69 73 20 6e 6f 74 20 70 61 74 63 68 nst is not patch
1050: 65 64 2c 20 73 6f 20 73 75 70 70 6c 79 20 74 68 ed, so supply th
1060: 65 0a 20 2a 20 6e 65 63 65 73 73 73 61 72 79 20 e. * necesssary
1070: 64 65 66 69 6e 69 74 69 6f 6e 73 20 68 65 72 65 definitions here
1080: 20 62 79 20 6f 75 72 73 65 6c 76 65 73 2e 20 54 by ourselves. T
1090: 68 65 20 66 6f 72 6d 20 63 68 6f 73 65 6e 20 66 he form chosen f
10a0: 6f 72 0a 20 2a 20 74 68 65 20 70 72 6f 63 65 64 or. * the proced
10b0: 75 72 65 20 6d 61 63 72 6f 73 20 28 72 65 73 65 ure macros (rese
10c0: 72 76 65 64 58 58 58 29 20 77 69 6c 6c 20 6e 6f rvedXXX) will no
10d0: 74 69 66 79 20 75 73 20 69 66 20 74 68 65 20 63 tify us if the c
10e0: 6f 72 65 0a 20 2a 20 64 6f 65 73 20 6e 6f 74 20 ore. * does not
10f0: 68 61 76 65 20 74 68 65 73 65 20 72 65 73 65 72 have these reser
1100: 76 65 64 20 6c 6f 63 61 74 69 6f 6e 73 20 61 6e ved locations an
1110: 79 6d 6f 72 65 2e 0a 20 2a 0a 20 2a 20 21 21 20 ymore.. *. * !!
1120: 53 79 6e 63 68 72 6f 6e 69 7a 65 20 74 68 65 20 Synchronize the
1130: 70 72 6f 63 65 64 75 72 65 20 69 6e 64 69 63 65 procedure indice
1140: 73 20 69 6e 20 74 68 65 69 72 20 64 65 66 69 6e s in their defin
1150: 69 74 69 6f 6e 73 20 77 69 74 68 0a 20 2a 20 20 itions with. *
1160: 20 20 74 68 65 20 70 61 74 63 68 20 74 6f 20 74 the patch to t
1170: 63 6c 2e 64 65 63 6c 73 2c 20 61 73 20 74 68 65 cl.decls, as the
1180: 79 20 68 61 76 65 20 74 6f 20 62 65 20 74 68 65 y have to be the
1190: 20 73 61 6d 65 2e 0a 20 2a 2f 0a 0a 2f 2a 20 32 same.. */../* 2
11a0: 38 31 20 2a 2f 0a 74 79 70 65 64 65 66 20 54 63 81 */.typedef Tc
11b0: 6c 5f 43 68 61 6e 6e 65 6c 20 28 74 6c 73 5f 53 l_Channel (tls_S
11c0: 74 61 63 6b 43 68 61 6e 6e 65 6c 29 20 5f 41 4e tackChannel) _AN
11d0: 53 49 5f 41 52 47 53 5f 28 28 54 63 6c 5f 49 6e SI_ARGS_((Tcl_In
11e0: 74 65 72 70 2a 20 69 6e 74 65 72 70 2c 0a 09 09 terp* interp,...
11f0: 09 09 09 09 20 20 20 20 54 63 6c 5f 43 68 61 6e .... Tcl_Chan
1200: 6e 65 6c 54 79 70 65 2a 20 74 79 70 65 50 74 72 nelType* typePtr
1210: 2c 0a 09 09 09 09 09 09 20 20 20 20 43 6c 69 65 ,....... Clie
1220: 6e 74 44 61 74 61 20 69 6e 73 74 61 6e 63 65 44 ntData instanceD
1230: 61 74 61 2c 0a 09 09 09 09 09 09 20 20 20 20 69 ata,....... i
1240: 6e 74 20 6d 61 73 6b 2c 0a 09 09 09 09 09 09 20 nt mask,.......
1250: 20 20 20 54 63 6c 5f 43 68 61 6e 6e 65 6c 20 70 Tcl_Channel p
1260: 72 65 76 43 68 61 6e 29 29 3b 0a 2f 2a 20 32 38 revChan));./* 28
1270: 32 20 2a 2f 0a 74 79 70 65 64 65 66 20 76 6f 69 2 */.typedef voi
1280: 64 20 28 74 6c 73 5f 55 6e 73 74 61 63 6b 43 68 d (tls_UnstackCh
1290: 61 6e 6e 65 6c 29 20 5f 41 4e 53 49 5f 41 52 47 annel) _ANSI_ARG
12a0: 53 5f 28 28 54 63 6c 5f 49 6e 74 65 72 70 2a 20 S_((Tcl_Interp*
12b0: 69 6e 74 65 72 70 2c 0a 09 09 09 09 09 20 20 20 interp,......
12c0: 20 20 20 20 54 63 6c 5f 43 68 61 6e 6e 65 6c 20 Tcl_Channel
12d0: 63 68 61 6e 29 29 3b 0a 0a 23 64 65 66 69 6e 65 chan));..#define
12e0: 20 54 63 6c 5f 53 74 61 63 6b 43 68 61 6e 6e 65 Tcl_StackChanne
12f0: 6c 20 20 20 20 20 28 28 74 6c 73 5f 53 74 61 63 l ((tls_Stac
1300: 6b 43 68 61 6e 6e 65 6c 2a 29 20 74 63 6c 53 74 kChannel*) tclSt
1310: 75 62 73 50 74 72 2d 3e 72 65 73 65 72 76 65 64 ubsPtr->reserved
1320: 32 38 31 29 0a 23 64 65 66 69 6e 65 20 54 63 6c 281).#define Tcl
1330: 5f 55 6e 73 74 61 63 6b 43 68 61 6e 6e 65 6c 20 _UnstackChannel
1340: 28 28 74 6c 73 5f 55 6e 73 74 61 63 6b 43 68 61 ((tls_UnstackCha
1350: 6e 6e 65 6c 2a 29 20 74 63 6c 53 74 75 62 73 50 nnel*) tclStubsP
1360: 74 72 2d 3e 72 65 73 65 72 76 65 64 32 38 32 29 tr->reserved282)
1370: 0a 0a 23 65 6e 64 69 66 20 2f 2a 20 54 63 6c 5f ..#endif /* Tcl_
1380: 53 74 61 63 6b 43 68 61 6e 6e 65 6c 20 2a 2f 0a StackChannel */.
1390: 0a 23 69 66 6e 64 65 66 20 54 63 6c 5f 47 65 74 .#ifndef Tcl_Get
13a0: 53 74 61 63 6b 65 64 43 68 61 6e 6e 65 6c 0a 2f StackedChannel./
13b0: 2a 0a 20 2a 20 53 65 70 61 72 61 74 65 20 64 65 *. * Separate de
13c0: 66 69 6e 69 74 69 6f 6e 2c 20 61 76 61 69 6c 61 finition, availa
13d0: 62 6c 65 20 69 6e 20 38 2e 32 2c 20 62 75 74 20 ble in 8.2, but
13e0: 6e 6f 74 20 38 2e 31 20 61 6e 64 20 62 65 66 6f not 8.1 and befo
13f0: 72 65 20 21 0a 20 2a 2f 0a 0a 2f 2a 20 32 38 33 re !. */../* 283
1400: 20 2a 2f 0a 74 79 70 65 64 65 66 20 54 63 6c 5f */.typedef Tcl_
1410: 43 68 61 6e 6e 65 6c 20 28 74 6c 73 5f 47 65 74 Channel (tls_Get
1420: 53 74 61 63 6b 65 64 43 68 61 6e 6e 65 6c 29 20 StackedChannel)
1430: 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 54 63 6c _ANSI_ARGS_((Tcl
1440: 5f 43 68 61 6e 6e 65 6c 20 63 68 61 6e 29 29 3b _Channel chan));
1450: 0a 0a 23 64 65 66 69 6e 65 20 54 63 6c 5f 47 65 ..#define Tcl_Ge
1460: 74 53 74 61 63 6b 65 64 43 68 61 6e 6e 65 6c 20 tStackedChannel
1470: 28 28 74 6c 73 5f 47 65 74 53 74 61 63 6b 65 64 ((tls_GetStacked
1480: 43 68 61 6e 6e 65 6c 2a 29 20 74 63 6c 53 74 75 Channel*) tclStu
1490: 62 73 50 74 72 2d 3e 72 65 73 65 72 76 65 64 32 bsPtr->reserved2
14a0: 38 33 29 0a 0a 23 65 6e 64 69 66 20 2f 2a 20 54 83)..#endif /* T
14b0: 63 6c 5f 47 65 74 53 74 61 63 6b 65 64 43 68 61 cl_GetStackedCha
14c0: 6e 6e 65 6c 20 2a 2f 0a 0a 0a 23 69 66 6e 64 65 nnel */...#ifnde
14d0: 66 20 54 43 4c 5f 43 48 41 4e 4e 45 4c 5f 56 45 f TCL_CHANNEL_VE
14e0: 52 53 49 4f 4e 5f 32 0a 2f 2a 0a 20 2a 20 43 6f RSION_2./*. * Co
14f0: 72 65 20 69 73 20 6f 6c 64 65 72 20 74 68 61 6e re is older than
1500: 20 38 2e 33 2e 32 2e 20 20 53 75 70 70 6c 79 20 8.3.2. Supply
1510: 74 68 65 20 6d 69 73 73 69 6e 67 20 64 65 66 69 the missing defi
1520: 6e 69 74 69 6f 6e 73 20 66 6f 72 0a 20 2a 20 74 nitions for. * t
1530: 68 65 20 6e 65 77 20 41 50 49 27 73 20 69 6e 20 he new API's in
1540: 38 2e 33 2e 32 2e 0a 20 2a 2f 0a 23 64 65 66 69 8.3.2.. */.#defi
1550: 6e 65 20 45 4d 55 4c 41 54 45 5f 43 48 41 4e 4e ne EMULATE_CHANN
1560: 45 4c 5f 56 45 52 53 49 4f 4e 5f 32 0a 0a 74 79 EL_VERSION_2..ty
1570: 70 65 64 65 66 20 73 74 72 75 63 74 20 54 6c 73 pedef struct Tls
1580: 43 68 61 6e 6e 65 6c 54 79 70 65 56 65 72 73 69 ChannelTypeVersi
1590: 6f 6e 5f 2a 20 54 6c 73 43 68 61 6e 6e 65 6c 54 on_* TlsChannelT
15a0: 79 70 65 56 65 72 73 69 6f 6e 3b 0a 23 64 65 66 ypeVersion;.#def
15b0: 69 6e 65 20 54 43 4c 5f 43 48 41 4e 4e 45 4c 5f ine TCL_CHANNEL_
15c0: 56 45 52 53 49 4f 4e 5f 32 09 28 28 54 6c 73 43 VERSION_2.((TlsC
15d0: 68 61 6e 6e 65 6c 54 79 70 65 56 65 72 73 69 6f hannelTypeVersio
15e0: 6e 29 20 30 78 32 29 0a 0a 74 79 70 65 64 65 66 n) 0x2)..typedef
15f0: 20 69 6e 74 20 28 54 6c 73 44 72 69 76 65 72 48 int (TlsDriverH
1600: 61 6e 64 6c 65 72 50 72 6f 63 29 20 5f 41 4e 53 andlerProc) _ANS
1610: 49 5f 41 52 47 53 5f 28 28 43 6c 69 65 6e 74 44 I_ARGS_((ClientD
1620: 61 74 61 20 69 6e 73 74 61 6e 63 65 44 61 74 61 ata instanceData
1630: 2c 0a 09 09 09 09 09 69 6e 74 20 69 6e 74 65 72 ,......int inter
1640: 65 73 74 4d 61 73 6b 29 29 3b 0a 2f 2a 20 33 39 estMask));./* 39
1650: 34 20 2a 2f 0a 74 79 70 65 64 65 66 20 69 6e 74 4 */.typedef int
1660: 20 28 74 6c 73 5f 52 65 61 64 52 61 77 29 20 20 (tls_ReadRaw)
1670: 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 54 63 6c _ANSI_ARGS_((Tcl
1680: 5f 43 68 61 6e 6e 65 6c 20 63 68 61 6e 2c 20 63 _Channel chan, c
1690: 68 61 72 20 2a 64 73 74 2c 0a 09 09 09 09 09 69 har *dst,......i
16a0: 6e 74 20 62 79 74 65 73 54 6f 52 65 61 64 29 29 nt bytesToRead))
16b0: 3b 0a 2f 2a 20 33 39 35 20 2a 2f 0a 74 79 70 65 ;./* 395 */.type
16c0: 64 65 66 20 69 6e 74 20 28 74 6c 73 5f 57 72 69 def int (tls_Wri
16d0: 74 65 52 61 77 29 20 5f 41 4e 53 49 5f 41 52 47 teRaw) _ANSI_ARG
16e0: 53 5f 28 28 54 63 6c 5f 43 68 61 6e 6e 65 6c 20 S_((Tcl_Channel
16f0: 63 68 61 6e 2c 20 63 68 61 72 20 2a 73 72 63 2c chan, char *src,
1700: 0a 09 09 09 09 09 69 6e 74 20 73 72 63 4c 65 6e ......int srcLen
1710: 29 29 3b 0a 2f 2a 20 33 39 37 20 2a 2f 0a 74 79 ));./* 397 */.ty
1720: 70 65 64 65 66 20 69 6e 74 20 28 74 6c 73 5f 47 pedef int (tls_G
1730: 65 74 54 6f 70 43 68 61 6e 6e 65 6c 29 20 5f 41 etTopChannel) _A
1740: 4e 53 49 5f 41 52 47 53 5f 28 28 54 63 6c 5f 43 NSI_ARGS_((Tcl_C
1750: 68 61 6e 6e 65 6c 20 63 68 61 6e 29 29 3b 0a 0a hannel chan));..
1760: 2f 2a 0a 20 2a 20 47 65 6e 65 72 61 74 69 6e 67 /*. * Generating
1770: 20 63 6f 64 65 20 66 6f 72 20 61 63 63 65 73 73 code for access
1780: 69 6e 67 20 74 68 65 73 65 20 70 61 72 74 73 20 ing these parts
1790: 6f 66 20 74 68 65 20 73 74 75 62 20 74 61 62 6c of the stub tabl
17a0: 65 20 77 68 65 6e 0a 20 2a 20 63 6f 6d 70 69 6c e when. * compil
17b0: 69 6e 67 20 61 67 61 69 6e 73 74 20 61 20 63 6f ing against a co
17c0: 72 65 20 6f 6c 64 65 72 20 74 68 61 6e 20 38 2e re older than 8.
17d0: 33 2e 32 20 69 73 20 61 20 68 61 73 73 6c 65 20 3.2 is a hassle
17e0: 62 65 63 61 75 73 65 20 65 76 65 6e 0a 20 2a 20 because even. *
17f0: 74 68 65 20 27 72 65 73 65 72 76 65 64 58 58 58 the 'reservedXXX
1800: 27 20 66 69 65 6c 64 73 20 6f 66 20 74 68 65 20 ' fields of the
1810: 73 74 72 75 63 74 75 72 65 20 61 72 65 20 6e 6f structure are no
1820: 74 20 64 65 66 69 6e 65 64 20 79 65 74 2e 20 53 t defined yet. S
1830: 6f 0a 20 2a 20 77 65 20 68 61 76 65 20 74 6f 20 o. * we have to
1840: 77 72 69 74 65 20 75 70 20 73 6f 6d 65 20 6d 61 write up some ma
1850: 63 72 6f 73 20 68 69 64 69 6e 67 20 73 6f 6d 65 cros hiding some
1860: 20 76 65 72 79 20 68 61 63 6b 69 73 68 20 70 6f very hackish po
1870: 69 6e 74 65 72 0a 20 2a 20 61 72 69 74 68 6d 65 inter. * arithme
1880: 74 69 63 73 20 74 6f 20 67 65 74 20 61 74 20 74 tics to get at t
1890: 68 65 73 65 20 66 69 65 6c 64 73 2e 20 57 65 20 hese fields. We
18a0: 61 73 73 75 6d 65 20 74 68 61 74 20 70 6f 69 6e assume that poin
18b0: 74 65 72 20 74 6f 0a 20 2a 20 66 75 6e 63 74 69 ter to. * functi
18c0: 6f 6e 73 20 61 72 65 20 61 6c 77 61 79 73 20 6f ons are always o
18d0: 66 20 74 68 65 20 73 61 6d 65 20 73 69 7a 65 2e f the same size.
18e0: 0a 20 2a 2f 0a 0a 23 64 65 66 69 6e 65 20 53 54 . */..#define ST
18f0: 55 42 5f 42 41 53 45 20 20 20 28 28 63 68 61 72 UB_BASE ((char
1900: 2a 29 28 26 28 74 63 6c 53 74 75 62 73 50 74 72 *)(&(tclStubsPtr
1910: 2d 3e 74 63 6c 5f 55 74 66 4e 63 61 73 65 63 6d ->tcl_UtfNcasecm
1920: 70 29 29 29 20 2f 2a 20 66 69 65 6c 64 20 33 37 p))) /* field 37
1930: 30 20 2a 2f 0a 23 64 65 66 69 6e 65 20 70 72 6f 0 */.#define pro
1940: 63 50 74 72 53 69 7a 65 20 28 73 69 7a 65 6f 66 cPtrSize (sizeof
1950: 20 28 54 63 6c 5f 44 72 69 76 65 72 42 6c 6f 63 (Tcl_DriverBloc
1960: 6b 4d 6f 64 65 50 72 6f 63 20 2a 29 29 0a 23 64 kModeProc *)).#d
1970: 65 66 69 6e 65 20 49 44 58 28 6e 29 20 20 20 20 efine IDX(n)
1980: 20 20 28 28 28 6e 29 2d 33 37 30 29 20 2a 20 70 (((n)-370) * p
1990: 72 6f 63 50 74 72 53 69 7a 65 29 0a 23 64 65 66 rocPtrSize).#def
19a0: 69 6e 65 20 53 4c 4f 54 28 6e 29 20 20 20 20 20 ine SLOT(n)
19b0: 28 53 54 55 42 5f 42 41 53 45 20 2b 20 49 44 58 (STUB_BASE + IDX
19c0: 28 6e 29 29 0a 0a 23 64 65 66 69 6e 65 20 54 63 (n))..#define Tc
19d0: 6c 5f 52 65 61 64 52 61 77 09 09 28 2a 28 28 74 l_ReadRaw..(*((t
19e0: 6c 73 5f 52 65 61 64 52 61 77 2a 2a 29 09 28 53 ls_ReadRaw**).(S
19f0: 4c 4f 54 28 33 39 34 29 29 29 29 0a 23 64 65 66 LOT(394)))).#def
1a00: 69 6e 65 20 54 63 6c 5f 57 72 69 74 65 52 61 77 ine Tcl_WriteRaw
1a10: 09 09 28 2a 28 28 74 6c 73 5f 57 72 69 74 65 52 ..(*((tls_WriteR
1a20: 61 77 2a 2a 29 09 28 53 4c 4f 54 28 33 39 35 29 aw**).(SLOT(395)
1a30: 29 29 29 0a 23 64 65 66 69 6e 65 20 54 63 6c 5f ))).#define Tcl_
1a40: 47 65 74 54 6f 70 43 68 61 6e 6e 65 6c 09 28 2a GetTopChannel.(*
1a50: 28 28 74 6c 73 5f 47 65 74 54 6f 70 43 68 61 6e ((tls_GetTopChan
1a60: 6e 65 6c 2a 2a 29 28 53 4c 4f 54 28 33 39 36 29 nel**)(SLOT(396)
1a70: 29 29 29 0a 0a 2f 2a 0a 20 2a 20 52 65 71 75 69 )))../*. * Requi
1a80: 72 65 64 2c 20 65 61 73 79 20 65 6d 75 6c 61 74 red, easy emulat
1a90: 69 6f 6e 2e 0a 20 2a 2f 0a 23 64 65 66 69 6e 65 ion.. */.#define
1aa0: 20 54 63 6c 5f 43 68 61 6e 6e 65 6c 47 65 74 4f Tcl_ChannelGetO
1ab0: 70 74 69 6f 6e 50 72 6f 63 28 63 68 61 6e 44 72 ptionProc(chanDr
1ac0: 69 76 65 72 29 20 28 28 63 68 61 6e 44 72 69 76 iver) ((chanDriv
1ad0: 65 72 29 2d 3e 67 65 74 4f 70 74 69 6f 6e 50 72 er)->getOptionPr
1ae0: 6f 63 29 0a 0a 23 65 6e 64 69 66 20 2f 2a 20 54 oc)..#endif /* T
1af0: 43 4c 5f 43 48 41 4e 4e 45 4c 5f 56 45 52 53 49 CL_CHANNEL_VERSI
1b00: 4f 4e 5f 32 20 2a 2f 0a 0a 23 65 6e 64 69 66 20 ON_2 */..#endif
1b10: 2f 2a 20 55 53 45 5f 54 43 4c 5f 53 54 55 42 53 /* USE_TCL_STUBS
1b20: 20 2a 2f 0a 0a 2f 2a 0a 20 2a 20 46 6f 72 77 61 */../*. * Forwa
1b30: 72 64 20 64 65 63 6c 61 72 61 74 69 6f 6e 73 0a rd declarations.
1b40: 20 2a 2f 0a 0a 45 58 54 45 52 4e 20 54 63 6c 5f */..EXTERN Tcl_
1b50: 43 68 61 6e 6e 65 6c 54 79 70 65 20 2a 54 6c 73 ChannelType *Tls
1b60: 5f 43 68 61 6e 6e 65 6c 54 79 70 65 20 5f 41 4e _ChannelType _AN
1b70: 53 49 5f 41 52 47 53 5f 28 28 76 6f 69 64 29 29 SI_ARGS_((void))
1b80: 3b 0a 45 58 54 45 52 4e 20 54 63 6c 5f 43 68 61 ;.EXTERN Tcl_Cha
1b90: 6e 6e 65 6c 09 54 6c 73 5f 47 65 74 50 61 72 65 nnel.Tls_GetPare
1ba0: 6e 74 20 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 nt _ANSI_ARGS_((
1bb0: 53 74 61 74 65 20 2a 73 74 61 74 65 50 74 72 29 State *statePtr)
1bc0: 29 3b 0a 0a 45 58 54 45 52 4e 20 54 63 6c 5f 4f );..EXTERN Tcl_O
1bd0: 62 6a 2a 09 09 54 6c 73 5f 4e 65 77 58 35 30 39 bj*..Tls_NewX509
1be0: 4f 62 6a 20 5f 41 4e 53 49 5f 41 52 47 53 5f 20 Obj _ANSI_ARGS_
1bf0: 28 28 20 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 (( Tcl_Interp *i
1c00: 6e 74 65 72 70 2c 20 58 35 30 39 20 2a 63 65 72 nterp, X509 *cer
1c10: 74 29 29 3b 0a 45 58 54 45 52 4e 20 76 6f 69 64 t));.EXTERN void
1c20: 09 09 54 6c 73 5f 45 72 72 6f 72 20 5f 41 4e 53 ..Tls_Error _ANS
1c30: 49 5f 41 52 47 53 5f 20 28 28 53 74 61 74 65 20 I_ARGS_ ((State
1c40: 2a 73 74 61 74 65 50 74 72 2c 20 63 68 61 72 20 *statePtr, char
1c50: 2a 6d 73 67 29 29 3b 0a 45 58 54 45 52 4e 20 76 *msg));.EXTERN v
1c60: 6f 69 64 09 09 54 6c 73 5f 46 72 65 65 20 5f 41 oid..Tls_Free _A
1c70: 4e 53 49 5f 41 52 47 53 5f 20 28 28 63 68 61 72 NSI_ARGS_ ((char
1c80: 20 2a 62 6c 6f 63 6b 50 74 72 29 29 3b 0a 45 58 *blockPtr));.EX
1c90: 54 45 52 4e 20 76 6f 69 64 09 09 54 6c 73 5f 43 TERN void..Tls_C
1ca0: 6c 65 61 6e 20 5f 41 4e 53 49 5f 41 52 47 53 5f lean _ANSI_ARGS_
1cb0: 20 28 28 53 74 61 74 65 20 2a 73 74 61 74 65 50 ((State *stateP
1cc0: 74 72 29 29 3b 0a 45 58 54 45 52 4e 20 69 6e 74 tr));.EXTERN int
1cd0: 09 09 54 6c 73 5f 57 61 69 74 46 6f 72 43 6f 6e ..Tls_WaitForCon
1ce0: 6e 65 63 74 20 5f 41 4e 53 49 5f 41 52 47 53 5f nect _ANSI_ARGS_
1cf0: 28 28 20 53 74 61 74 65 20 2a 73 74 61 74 65 50 (( State *stateP
1d00: 74 72 2c 0a 09 09 09 09 09 09 09 69 6e 74 20 2a tr,........int *
1d10: 65 72 72 6f 72 43 6f 64 65 50 74 72 29 29 3b 0a errorCodePtr));.
1d20: 0a 45 58 54 45 52 4e 20 42 49 4f 5f 4d 45 54 48 .EXTERN BIO_METH
1d30: 4f 44 20 2a 09 42 49 4f 5f 73 5f 74 63 6c 20 5f OD *.BIO_s_tcl _
1d40: 41 4e 53 49 5f 41 52 47 53 5f 28 28 76 6f 69 64 ANSI_ARGS_((void
1d50: 29 29 3b 0a 45 58 54 45 52 4e 20 42 49 4f 20 2a ));.EXTERN BIO *
1d60: 09 09 42 49 4f 5f 6e 65 77 5f 74 63 6c 20 5f 41 ..BIO_new_tcl _A
1d70: 4e 53 49 5f 41 52 47 53 5f 28 28 53 74 61 74 65 NSI_ARGS_((State
1d80: 2a 20 73 74 61 74 65 50 74 72 2c 20 69 6e 74 20 * statePtr, int
1d90: 66 6c 61 67 73 29 29 3b 0a 0a 23 65 6e 64 69 66 flags));..#endif
1da0: 20 2f 2a 20 5f 54 4c 53 49 4e 54 5f 48 20 2a 2f /* _TLSINT_H */
1db0: 0a .